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