package o; import java.util.NoSuchElementException; /* loaded from: classes6.dex */ public final class fVM extends AbstractC13175fSw implements InterfaceC13204fTr { private InterfaceC13169fSq b; private T d; private long e; public fVM(InterfaceC13169fSq interfaceC13169fSq, long j, T t) { this.b = interfaceC13169fSq; this.e = j; this.d = t; } @Override // o.AbstractC13175fSw public final void e(InterfaceC13176fSx interfaceC13176fSx) { this.b.subscribe(new IeS(interfaceC13176fSx, this.e, this.d)); } @Override // o.InterfaceC13204fTr public final AbstractC13163fSk b() { return new fVL(this.b, this.e, this.d, true); } /* loaded from: classes6.dex */ static final class IeS implements InterfaceC13174fSv, fSJ { private long a; private T b; private InterfaceC13176fSx c; private long d; private boolean e; private fSJ h; IeS(InterfaceC13176fSx interfaceC13176fSx, long j, T t) { this.c = interfaceC13176fSx; this.d = j; this.b = t; } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { if (EnumC13192fTf.d(this.h, fsj)) { this.h = fsj; this.c.onSubscribe(this); } } @Override // o.fSJ public final void dispose() { this.h.dispose(); } @Override // o.fSJ public final boolean isDisposed() { return this.h.isDisposed(); } @Override // o.InterfaceC13174fSv public final void onNext(T t) { if (this.e) { return; } long j = this.a; if (j != this.d) { this.a = j + 1; return; } this.e = true; this.h.dispose(); this.c.e(t); } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { if (this.e) { C13418fZu.c(th); } else { this.e = true; this.c.onError(th); } } @Override // o.InterfaceC13174fSv public final void onComplete() { if (this.e) { return; } this.e = true; T t = this.b; if (t != null) { this.c.e(t); } else { this.c.onError(new NoSuchElementException()); } } } }