package defpackage;

import androidx.media3.container.NalUnitUtil;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import defpackage.dw7;
import kotlin.Metadata;
import kotlin.reflect.KClass;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\b'\u0018\u0000*\b\b\u0000\u0010\u0002*\u00020\u00012\b\u0012\u0004\u0012\u00028\u00000\u0003¨\u0006\u0004"}, d2 = {"Lc1;", "", "T", "Ln25;", "kotlinx-serialization-core"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@qq4
@vx8
public abstract class c1<T> implements n25<T> {
    public o52 a(da1 da1Var, String str) {
        return da1Var.getD().d(str, getA());
    }

    public yi8 b(fl2 fl2Var, Object obj) {
        cr4.g(obj, AppMeasurementSdk.ConditionalUserProperty.VALUE);
        return fl2Var.getE().e(getA(), obj);
    }

    /* JADX INFO: renamed from: c */
    public abstract KClass getA();

    @Override // defpackage.o52
    public final Object deserialize(ux1 ux1Var) {
        bi8 descriptor = getDescriptor();
        da1 da1VarC = ux1Var.c(descriptor);
        dw7.h hVar = new dw7.h();
        Object objY = null;
        while (true) {
            int iW = da1VarC.w(getDescriptor());
            if (iW == -1) {
                if (objY != null) {
                    da1VarC.b(descriptor);
                    return objY;
                }
                throw new IllegalArgumentException(("Polymorphic value has not been read for class " + ((String) hVar.a)).toString());
            }
            if (iW == 0) {
                hVar.a = da1VarC.k(getDescriptor(), iW);
            } else {
                if (iW != 1) {
                    StringBuilder sb = new StringBuilder("Invalid index in polymorphic deserialization of ");
                    String str = (String) hVar.a;
                    if (str == null) {
                        str = "unknown class";
                    }
                    sb.append(str);
                    sb.append("\n Expected 0, 1 or DECODE_DONE(-1), but found ");
                    sb.append(iW);
                    throw new xi8(sb.toString());
                }
                Object obj = hVar.a;
                if (obj == null) {
                    throw new IllegalArgumentException("Cannot read polymorphic value before its type token");
                }
                hVar.a = obj;
                objY = da1VarC.y(getDescriptor(), iW, kc7.a(this, da1VarC, (String) obj), null);
            }
        }
    }

    @Override // defpackage.yi8
    public final void serialize(fl2 fl2Var, Object obj) {
        cr4.g(obj, AppMeasurementSdk.ConditionalUserProperty.VALUE);
        yi8 yi8VarB = kc7.b(this, fl2Var, obj);
        bi8 descriptor = getDescriptor();
        fa1 fa1VarC = fl2Var.c(descriptor);
        fa1VarC.n(getDescriptor(), 0, yi8VarB.getDescriptor().getC());
        fa1VarC.q(getDescriptor(), 1, yi8VarB, obj);
        fa1VarC.b(descriptor);
    }
}
