package defpackage;

import androidx.media3.container.NalUnitUtil;
import com.google.android.gms.auth.api.proxy.AuthApiStatusCodes;
import defpackage.hf1;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import net.zetetic.database.DatabaseUtils;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\u0002\n\u0000¨\u0006\u0000"}, d2 = {"ktor-client-core"}, k = 2, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
public final class l98 {
    public static final jh5 a = h55.a("io.ktor.client.plugins.sse.SSE");
    public static final i11 b = tm1.a(a.a, new od0(13), "SSE");

    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public /* synthetic */ class a extends xr3 implements qq3<k98> {
        public static final a a = new a(0, k98.class, "<init>", "<init>()V", 0);

        @Override // defpackage.qq3
        public final Object invoke() {
            k98 k98Var = new k98();
            int i = pg2.d;
            k98Var.a = tg2.g(AuthApiStatusCodes.AUTH_API_INVALID_CREDENTIALS, xg2.d);
            return k98Var;
        }
    }

    @Metadata(d1 = {"\u0000\u000e\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u0004\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u00002\u0006\u0010\u0003\u001a\u00020\u0002H\n¢\u0006\u0004\b\u0004\u0010\u0005"}, d2 = {"Lfd4;", "request", "Lvy6;", "content", "<anonymous>", "(Lfd4;Lvy6;)Lvy6;"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "io.ktor.client.plugins.sse.SSEKt$SSE$2$1", f = "SSE.kt", i = {}, l = {}, m = "invokeSuspend", n = {}, s = {})
    @vx8
    public static final class b extends SuspendLambda implements ir3<fd4, vy6, Continuation<? super vy6>, Object> {
        public /* synthetic */ fd4 a;
        public /* synthetic */ vy6 b;
        public final /* synthetic */ long c;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public b(long j, Continuation continuation) {
            super(3, continuation);
            this.c = j;
        }

        @Override // defpackage.ir3
        public final Object invoke(Object obj, Object obj2, Object obj3) {
            b bVar = new b(this.c, (Continuation) obj3);
            bVar.a = (fd4) obj;
            bVar.b = (vy6) obj2;
            return bVar.invokeSuspend(e6a.a);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            s38.b(obj);
            fd4 fd4Var = this.a;
            vy6 vy6Var = this.b;
            dx dxVar = xj0.a;
            jh5 jh5Var = l98.a;
            fx fxVar = fd4Var.f;
            if (!cr4.b(fxVar.a(dxVar), Boxing.boxBoolean(true))) {
                return vy6Var;
            }
            l98.a.h("Sending SSE request " + fd4Var.a);
            fd4Var.c(g98.a, e6a.a);
            pg2 pg2Var = (pg2) fxVar.a(xj0.b);
            Boolean bool = (Boolean) fxVar.a(xj0.c);
            Boolean bool2 = (Boolean) fxVar.a(xj0.d);
            fxVar.d(kd4.a, new j98());
            hf1 b = vy6Var.getB();
            if (b != null) {
                vc4.e(fd4Var, b);
            }
            return new h98(pg2Var != null ? pg2Var.a : this.c, bool != null ? bool.booleanValue() : false, bool2 != null ? bool2.booleanValue() : false, vy6Var);
        }
    }

    @Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0005\u001a\u00020\u0004*\u000e\u0012\u0004\u0012\u00020\u0001\u0012\u0004\u0012\u00020\u00020\u00002\u0006\u0010\u0003\u001a\u00020\u0001H\n¢\u0006\u0004\b\u0005\u0010\u0006"}, d2 = {"Lj77;", "Ltd4;", "Lua4;", "<destruct>", "Le6a;", "<anonymous>", "(Lj77;Ltd4;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "io.ktor.client.plugins.sse.SSEKt$SSE$2$2", f = "SSE.kt", i = {}, l = {DatabaseUtils.STATEMENT_OTHER}, m = "invokeSuspend", n = {}, s = {})
    public static final class c extends SuspendLambda implements ir3<j77<td4, ua4>, td4, Continuation<? super e6a>, Object> {
        public int a;
        public /* synthetic */ j77 b;
        public /* synthetic */ td4 c;

        @Override // defpackage.ir3
        public final Object invoke(Object obj, Object obj2, Object obj3) {
            c cVar = new c(3, (Continuation) obj3);
            cVar.b = (j77) obj;
            cVar.c = (td4) obj2;
            return cVar.invokeSuspend(e6a.a);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            int i = this.a;
            e6a e6aVar = e6a.a;
            if (i != 0) {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                return e6aVar;
            }
            s38.b(obj);
            j77 j77Var = this.b;
            td4 td4Var = this.c;
            fz9 fz9Var = td4Var.a;
            Object obj2 = td4Var.b;
            rd4 rd4VarG = ((ua4) j77Var.a).g();
            pe4 c = rd4VarG.getC();
            hf1 hf1VarC = vc4.c(rd4VarG);
            if (!(yd4.b(rd4VarG).getD() instanceof h98)) {
                l98.a.h("Skipping non SSE response from " + yd4.b(rd4VarG).getB());
                return e6aVar;
            }
            pe4 pe4Var = pe4.d;
            if (!cr4.b(c, pe4Var)) {
                throw new i98(rd4VarG, null, "Expected status code " + pe4Var.a + " but was " + c.a, 2);
            }
            hf1 hf1VarD = hf1VarC != null ? hf1VarC.d() : null;
            hf1 hf1Var = hf1.h.b;
            if (!cr4.b(hf1VarD, hf1Var)) {
                throw new i98(rd4VarG, null, "Expected Content-Type " + hf1Var + " but was " + hf1VarC, 2);
            }
            if (!(obj2 instanceof m98)) {
                throw new i98(rd4VarG, null, "Expected " + iw7.a.getOrCreateKotlinClass(m98.class).getSimpleName() + " content but was " + obj2, 2);
            }
            l98.a.h("Receive SSE session from " + yd4.b(rd4VarG).getB() + ": " + obj2);
            td4 td4Var2 = new td4(fz9Var, new n11((ua4) j77Var.a, (m98) obj2));
            this.b = null;
            this.a = 1;
            return j77Var.h(td4Var2, this) == ck1Var ? ck1Var : e6aVar;
        }
    }
}
