package o; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; /* renamed from: o.fUN, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C13216fUN extends AbstractC13163fSk { private int a; private InterfaceC13169fSq b; private EnumC13357fYN c; private fSS> d; public C13216fUN(InterfaceC13169fSq interfaceC13169fSq, fSS> fss, EnumC13357fYN enumC13357fYN, int i) { this.b = interfaceC13169fSq; this.d = fss; this.c = enumC13357fYN; this.a = i; } @Override // o.AbstractC13163fSk public final void subscribeActual(InterfaceC13174fSv interfaceC13174fSv) { if (fUP.a(this.b, this.d, interfaceC13174fSv)) { return; } this.b.subscribe(new LWm(interfaceC13174fSv, this.d, this.a, this.c)); } /* renamed from: o.fUN$LWm */ /* loaded from: classes6.dex */ static final class LWm extends fUJ { R g; volatile int h; private IeS i; private InterfaceC13174fSv j; private fSS> m; LWm(InterfaceC13174fSv interfaceC13174fSv, fSS> fss, int i, EnumC13357fYN enumC13357fYN) { super(i, enumC13357fYN); this.j = interfaceC13174fSv; this.m = fss; this.i = new IeS<>(this); } @Override // o.fUJ final void c() { this.j.onSubscribe(this); } @Override // o.fUJ final void e() { if (getAndIncrement() != 0) { return; } InterfaceC13174fSv interfaceC13174fSv = this.j; EnumC13357fYN enumC13357fYN = this.e; InterfaceC13414fZq interfaceC13414fZq = this.d; C13355fYI c13355fYI = this.b; int i = 1; while (true) { if (this.c) { interfaceC13414fZq.e(); this.g = null; } else { int i2 = this.h; if (c13355fYI.get() == null || (enumC13357fYN != EnumC13357fYN.IMMEDIATE && (enumC13357fYN != EnumC13357fYN.BOUNDARY || i2 != 0))) { if (i2 == 0) { boolean z = this.a; try { T b = interfaceC13414fZq.b(); boolean z2 = b == null; if (z && z2) { Throwable b2 = fYR.b(c13355fYI); if (b2 == null) { interfaceC13174fSv.onComplete(); return; } else { if (b2 != fYR.b) { interfaceC13174fSv.onError(b2); return; } return; } } if (!z2) { try { fSD fsd = (fSD) Objects.requireNonNull(this.m.a(b), "The mapper returned a null SingleSource"); this.h = 1; fsd.c(this.i); } catch (Throwable th) { C13147fSI.c(th); this.f.dispose(); interfaceC13414fZq.e(); if (!fYR.c(c13355fYI, th)) { C13418fZu.c(th); } Throwable b3 = fYR.b(c13355fYI); if (b3 == null) { interfaceC13174fSv.onComplete(); return; } else { if (b3 != fYR.b) { interfaceC13174fSv.onError(b3); return; } return; } } } } catch (Throwable th2) { C13147fSI.c(th2); this.c = true; this.f.dispose(); if (!fYR.c(c13355fYI, th2)) { C13418fZu.c(th2); } Throwable b4 = fYR.b(c13355fYI); if (b4 == null) { interfaceC13174fSv.onComplete(); return; } else { if (b4 != fYR.b) { interfaceC13174fSv.onError(b4); return; } return; } } } else if (i2 == 2) { R r = this.g; this.g = null; interfaceC13174fSv.onNext(r); this.h = 0; } } } i = addAndGet(-i); if (i == 0) { return; } } interfaceC13414fZq.e(); this.g = null; Throwable b5 = fYR.b(c13355fYI); if (b5 == null) { interfaceC13174fSv.onComplete(); } else if (b5 != fYR.b) { interfaceC13174fSv.onError(b5); } } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.fUN$LWm$IeS */ /* loaded from: classes6.dex */ public static final class IeS extends AtomicReference implements InterfaceC13176fSx { private LWm c; IeS(LWm lWm) { this.c = lWm; } @Override // o.InterfaceC13176fSx public final void onSubscribe(fSJ fsj) { EnumC13192fTf.c(this, fsj); } @Override // o.InterfaceC13176fSx public final void e(R r) { LWm lWm = this.c; lWm.g = r; lWm.h = 2; lWm.e(); } @Override // o.InterfaceC13176fSx public final void onError(Throwable th) { LWm lWm = this.c; if (fYR.c(lWm.b, th)) { if (lWm.e != EnumC13357fYN.END) { lWm.f.dispose(); } lWm.h = 0; lWm.e(); return; } C13418fZu.c(th); } } @Override // o.fUJ final void a() { EnumC13192fTf.e(this.i); } @Override // o.fUJ final void b() { this.g = null; } } }