package o; import android.R; import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; /* renamed from: o.fVr, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C13274fVr extends fUX { private fSS> b; private int d; private EnumC13357fYN e; public C13274fVr(InterfaceC13169fSq interfaceC13169fSq, fSS> fss, int i, EnumC13357fYN enumC13357fYN) { super(interfaceC13169fSq); this.b = fss; this.e = enumC13357fYN; this.d = Math.max(8, i); } @Override // o.AbstractC13163fSk public final void subscribeActual(InterfaceC13174fSv interfaceC13174fSv) { if (C13328fXb.d(this.c, interfaceC13174fSv, this.b)) { return; } if (this.e == EnumC13357fYN.IMMEDIATE) { this.c.subscribe(new LWm(new C13406fZi(interfaceC13174fSv), this.b, this.d)); } else { this.c.subscribe(new RVV(interfaceC13174fSv, this.b, this.d, this.e == EnumC13357fYN.END)); } } /* renamed from: o.fVr$LWm */ /* loaded from: classes6.dex */ static final class LWm extends AtomicInteger implements InterfaceC13174fSv, fSJ { private volatile boolean a; private InterfaceC13174fSv b; private volatile boolean c; volatile boolean d; private int e; private fSS> f; private int g; private InterfaceC13414fZq h; private fSJ i; private IeS j; LWm(InterfaceC13174fSv interfaceC13174fSv, fSS> fss, int i) { this.b = interfaceC13174fSv; this.f = fss; this.e = i; this.j = new IeS<>(interfaceC13174fSv, this); } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { if (EnumC13192fTf.d(this.i, fsj)) { this.i = fsj; if (fsj instanceof InterfaceC13412fZo) { InterfaceC13412fZo interfaceC13412fZo = (InterfaceC13412fZo) fsj; int b = interfaceC13412fZo.b(3); if (b == 1) { this.g = b; this.h = interfaceC13412fZo; this.a = true; this.b.onSubscribe(this); e(); return; } if (b == 2) { this.g = b; this.h = interfaceC13412fZo; this.b.onSubscribe(this); return; } } this.h = new C13416fZs(this.e); this.b.onSubscribe(this); } } @Override // o.InterfaceC13174fSv public final void onNext(T t) { if (this.a) { return; } if (this.g == 0) { this.h.b(t); } e(); } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { if (this.a) { C13418fZu.c(th); return; } this.a = true; dispose(); this.b.onError(th); } @Override // o.InterfaceC13174fSv public final void onComplete() { if (this.a) { return; } this.a = true; e(); } final void e() { if (getAndIncrement() != 0) { return; } while (!this.c) { if (!this.d) { boolean z = this.a; try { T b = this.h.b(); boolean z2 = b == null; if (z && z2) { this.c = true; this.b.onComplete(); return; } else if (!z2) { try { InterfaceC13169fSq interfaceC13169fSq = (InterfaceC13169fSq) Objects.requireNonNull(this.f.a(b), "The mapper returned a null ObservableSource"); this.d = true; interfaceC13169fSq.subscribe(this.j); } catch (Throwable th) { C13147fSI.c(th); dispose(); this.h.e(); this.b.onError(th); return; } } } catch (Throwable th2) { C13147fSI.c(th2); dispose(); this.h.e(); this.b.onError(th2); return; } } if (decrementAndGet() == 0) { return; } } this.h.e(); } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.fVr$LWm$IeS */ /* loaded from: classes6.dex */ public static final class IeS extends AtomicReference implements InterfaceC13174fSv { private LWm a; private InterfaceC13174fSv b; IeS(InterfaceC13174fSv interfaceC13174fSv, LWm lWm) { this.b = interfaceC13174fSv; this.a = lWm; } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { EnumC13192fTf.c(this, fsj); } @Override // o.InterfaceC13174fSv public final void onNext(U u) { this.b.onNext(u); } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { this.a.dispose(); this.b.onError(th); } @Override // o.InterfaceC13174fSv public final void onComplete() { LWm lWm = this.a; lWm.d = false; lWm.e(); } } @Override // o.fSJ public final void dispose() { this.c = true; EnumC13192fTf.e(this.j); this.i.dispose(); if (getAndIncrement() == 0) { this.h.e(); } } @Override // o.fSJ public final boolean isDisposed() { return this.c; } } /* renamed from: o.fVr$RVV */ /* loaded from: classes6.dex */ static final class RVV extends AtomicInteger implements InterfaceC13174fSv, fSJ { volatile boolean a; final C13355fYI b = new C13355fYI(); final boolean c; private int d; fSJ e; private fSS> f; private volatile boolean g; private Sts h; private InterfaceC13174fSv i; private volatile boolean j; private int m; private InterfaceC13414fZq n; RVV(InterfaceC13174fSv interfaceC13174fSv, fSS> fss, int i, boolean z) { this.i = interfaceC13174fSv; this.f = fss; this.d = i; this.c = z; this.h = new Sts<>(interfaceC13174fSv, this); } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { if (EnumC13192fTf.d(this.e, fsj)) { this.e = fsj; if (fsj instanceof InterfaceC13412fZo) { InterfaceC13412fZo interfaceC13412fZo = (InterfaceC13412fZo) fsj; int b = interfaceC13412fZo.b(3); if (b == 1) { this.m = b; this.n = interfaceC13412fZo; this.g = true; this.i.onSubscribe(this); a(); return; } if (b == 2) { this.m = b; this.n = interfaceC13412fZo; this.i.onSubscribe(this); return; } } this.n = new C13416fZs(this.d); this.i.onSubscribe(this); } } @Override // o.InterfaceC13174fSv public final void onNext(T t) { if (this.m == 0) { this.n.b(t); } a(); } @Override // o.InterfaceC13174fSv public final void onComplete() { this.g = true; a(); } @Override // o.fSJ public final void dispose() { this.j = true; this.e.dispose(); EnumC13192fTf.e(this.h); Throwable b = fYR.b(this.b); if (b == null || b == fYR.b) { return; } C13418fZu.c(b); } final void a() { if (getAndIncrement() != 0) { return; } InterfaceC13174fSv interfaceC13174fSv = this.i; InterfaceC13414fZq interfaceC13414fZq = this.n; C13355fYI c13355fYI = this.b; while (true) { if (!this.a) { if (this.j) { interfaceC13414fZq.e(); return; } if (!this.c && c13355fYI.get() != null) { interfaceC13414fZq.e(); this.j = true; Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13174fSv.onComplete(); return; } else { if (b != fYR.b) { interfaceC13174fSv.onError(b); return; } return; } } boolean z = this.g; try { T b2 = interfaceC13414fZq.b(); boolean z2 = b2 == null; if (z && z2) { this.j = true; Throwable b3 = fYR.b(c13355fYI); if (b3 == null) { interfaceC13174fSv.onComplete(); return; } else { if (b3 != fYR.b) { interfaceC13174fSv.onError(b3); return; } return; } } if (!z2) { try { InterfaceC13169fSq interfaceC13169fSq = (InterfaceC13169fSq) Objects.requireNonNull(this.f.a(b2), "The mapper returned a null ObservableSource"); if (interfaceC13169fSq instanceof InterfaceC13189fTc) { try { R.bool boolVar = (Object) ((InterfaceC13189fTc) interfaceC13169fSq).d(); if (boolVar != null && !this.j) { interfaceC13174fSv.onNext(boolVar); } } catch (Throwable th) { C13147fSI.c(th); if (!fYR.c(c13355fYI, th)) { C13418fZu.c(th); } } } else { this.a = true; interfaceC13169fSq.subscribe(this.h); } } catch (Throwable th2) { C13147fSI.c(th2); this.j = true; this.e.dispose(); interfaceC13414fZq.e(); 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; } } } } catch (Throwable th3) { C13147fSI.c(th3); this.j = true; this.e.dispose(); if (!fYR.c(c13355fYI, th3)) { C13418fZu.c(th3); } Throwable b5 = fYR.b(c13355fYI); if (b5 == null) { interfaceC13174fSv.onComplete(); return; } else { if (b5 != fYR.b) { interfaceC13174fSv.onError(b5); return; } return; } } } if (decrementAndGet() == 0) { return; } } } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.fVr$RVV$Sts */ /* loaded from: classes6.dex */ public static final class Sts extends AtomicReference implements InterfaceC13174fSv { private InterfaceC13174fSv c; private RVV d; Sts(InterfaceC13174fSv interfaceC13174fSv, RVV rvv) { this.c = interfaceC13174fSv; this.d = rvv; } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { EnumC13192fTf.c(this, fsj); } @Override // o.InterfaceC13174fSv public final void onNext(R r) { this.c.onNext(r); } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { RVV rvv = this.d; if (fYR.c(rvv.b, th)) { if (!rvv.c) { rvv.e.dispose(); } rvv.a = false; rvv.a(); return; } C13418fZu.c(th); } @Override // o.InterfaceC13174fSv public final void onComplete() { RVV rvv = this.d; rvv.a = false; rvv.a(); } } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { if (fYR.c(this.b, th)) { this.g = true; a(); } else { C13418fZu.c(th); } } @Override // o.fSJ public final boolean isDisposed() { return this.j; } } }