package defpackage;

import androidx.media3.container.NalUnitUtil;
import kotlin.Metadata;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.reflect.KType;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@DebugMetadata(c = "io.ktor.websocket.serialization.WebsocketChannelSerializationKt", f = "WebsocketChannelSerialization.kt", i = {0, 0, 0, 1, 1}, l = {96, 105}, m = "receiveDeserializedBase", n = {"typeInfo", "converter", "charset", "typeInfo", "frame"}, s = {"L$0", "L$1", "L$2", "L$0", "L$1"})
final class bpa extends ContinuationImpl {
    public fz9 a;
    public Object b;
    public /* synthetic */ Object c;
    public int d;

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) throws ipa {
        this.c = obj;
        int i = (this.d | Integer.MIN_VALUE) - Integer.MIN_VALUE;
        this.d = i;
        ck1 ck1Var = ck1.a;
        if (i == 0) {
            s38.b(obj);
            throw null;
        }
        if (i == 1) {
            fpa fpaVar = (fpa) this.b;
            fz9 fz9Var = this.a;
            s38.b(obj);
            kp3 kp3Var = (kp3) obj;
            if (!fpaVar.b(kp3Var)) {
                throw new ipa("Converter doesn't support frame type " + kp3Var.b.name(), kp3Var);
            }
            this.a = fz9Var;
            this.b = kp3Var;
            this.d = 2;
            fpaVar.a(kp3Var);
            throw null;
        }
        if (i != 2) {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        kp3 kp3Var2 = (kp3) this.b;
        fz9 fz9Var2 = this.a;
        s38.b(obj);
        if (fz9Var2.a.isInstance(obj)) {
            return obj;
        }
        if (obj == null) {
            KType kType = fz9Var2.b;
            if (kType == null || !kType.isMarkedNullable()) {
                throw new ipa("Frame has null content", kp3Var2);
            }
            return null;
        }
        throw new ipa("Can't deserialize value: expected value of type " + fz9Var2.a.getSimpleName() + ", got " + iw7.a.getOrCreateKotlinClass(obj.getClass()).getSimpleName(), kp3Var2);
    }
}
