package com.google.crypto.tink.shaded.protobuf;

import com.google.crypto.tink.shaded.protobuf.a;
import com.google.crypto.tink.shaded.protobuf.e;
import com.google.crypto.tink.shaded.protobuf.z;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/* loaded from: classes3.dex */
public abstract class x extends com.google.crypto.tink.shaded.protobuf.a {
    private static Map<Object, x> defaultInstanceMap = new ConcurrentHashMap();
    protected k1 unknownFields = k1.e();
    protected int memoizedSerializedSize = -1;

    /* loaded from: classes3.dex */
    public static abstract class a extends a.AbstractC0324a {

        /* renamed from: p, reason: collision with root package name */
        private final x f14470p;

        /* renamed from: q, reason: collision with root package name */
        protected x f14471q;

        /* renamed from: r, reason: collision with root package name */
        protected boolean f14472r = false;

        /* JADX INFO: Access modifiers changed from: protected */
        public a(x xVar) {
            this.f14470p = xVar;
            this.f14471q = (x) xVar.l(d.NEW_MUTABLE_INSTANCE);
        }

        private void s(x xVar, x xVar2) {
            z0.a().d(xVar).a(xVar, xVar2);
        }

        public final x i() {
            x buildPartial = buildPartial();
            if (buildPartial.s()) {
                return buildPartial;
            }
            throw a.AbstractC0324a.h(buildPartial);
        }

        @Override // com.google.crypto.tink.shaded.protobuf.o0.a
        /* renamed from: j, reason: merged with bridge method [inline-methods] */
        public x buildPartial() {
            if (this.f14472r) {
                return this.f14471q;
            }
            this.f14471q.u();
            this.f14472r = true;
            return this.f14471q;
        }

        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public a clone() {
            a newBuilderForType = getDefaultInstanceForType().newBuilderForType();
            newBuilderForType.q(buildPartial());
            return newBuilderForType;
        }

        /* JADX INFO: Access modifiers changed from: protected */
        public final void l() {
            if (this.f14472r) {
                n();
                this.f14472r = false;
            }
        }

        protected void n() {
            x xVar = (x) this.f14471q.l(d.NEW_MUTABLE_INSTANCE);
            s(xVar, this.f14471q);
            this.f14471q = xVar;
        }

        @Override // com.google.crypto.tink.shaded.protobuf.p0
        /* renamed from: o, reason: merged with bridge method [inline-methods] */
        public x getDefaultInstanceForType() {
            return this.f14470p;
        }

        /* JADX INFO: Access modifiers changed from: protected */
        @Override // com.google.crypto.tink.shaded.protobuf.a.AbstractC0324a
        /* renamed from: p, reason: merged with bridge method [inline-methods] */
        public a d(x xVar) {
            return q(xVar);
        }

        public a q(x xVar) {
            l();
            s(this.f14471q, xVar);
            return this;
        }
    }

    /* loaded from: classes3.dex */
    protected static class b extends com.google.crypto.tink.shaded.protobuf.b {

        /* renamed from: b, reason: collision with root package name */
        private final x f14473b;

        public b(x xVar) {
            this.f14473b = xVar;
        }
    }

    /* loaded from: classes3.dex */
    public static class c extends n {
    }

    /* loaded from: classes3.dex */
    public enum d {
        GET_MEMOIZED_IS_INITIALIZED,
        SET_MEMOIZED_IS_INITIALIZED,
        BUILD_MESSAGE_INFO,
        NEW_MUTABLE_INSTANCE,
        NEW_BUILDER,
        GET_DEFAULT_INSTANCE,
        GET_PARSER
    }

    private static x A(x xVar, h hVar, p pVar) {
        i v10 = hVar.v();
        x B = B(xVar, v10, pVar);
        try {
            v10.a(0);
            return B;
        } catch (a0 e10) {
            throw e10.i(B);
        }
    }

    static x B(x xVar, i iVar, p pVar) {
        x xVar2 = (x) xVar.l(d.NEW_MUTABLE_INSTANCE);
        try {
            d1 d10 = z0.a().d(xVar2);
            d10.j(xVar2, j.O(iVar), pVar);
            d10.b(xVar2);
            return xVar2;
        } catch (IOException e10) {
            if (e10.getCause() instanceof a0) {
                throw ((a0) e10.getCause());
            }
            throw new a0(e10.getMessage()).i(xVar2);
        } catch (RuntimeException e11) {
            if (e11.getCause() instanceof a0) {
                throw ((a0) e11.getCause());
            }
            throw e11;
        }
    }

    static x C(x xVar, byte[] bArr, int i10, int i11, p pVar) {
        x xVar2 = (x) xVar.l(d.NEW_MUTABLE_INSTANCE);
        try {
            d1 d10 = z0.a().d(xVar2);
            d10.h(xVar2, bArr, i10, i10 + i11, new e.a(pVar));
            d10.b(xVar2);
            if (xVar2.memoizedHashCode == 0) {
                return xVar2;
            }
            throw new RuntimeException();
        } catch (IOException e10) {
            if (e10.getCause() instanceof a0) {
                throw ((a0) e10.getCause());
            }
            throw new a0(e10.getMessage()).i(xVar2);
        } catch (IndexOutOfBoundsException unused) {
            throw a0.j().i(xVar2);
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static void D(Class cls, x xVar) {
        defaultInstanceMap.put(cls, xVar);
    }

    private static x j(x xVar) {
        if (xVar == null || xVar.s()) {
            return xVar;
        }
        throw xVar.g().a().i(xVar);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static z.d o() {
        return a1.i();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static x p(Class cls) {
        x xVar = defaultInstanceMap.get(cls);
        if (xVar == null) {
            try {
                Class.forName(cls.getName(), true, cls.getClassLoader());
                xVar = defaultInstanceMap.get(cls);
            } catch (ClassNotFoundException e10) {
                throw new IllegalStateException("Class initialization cannot fail.", e10);
            }
        }
        if (xVar == null) {
            xVar = ((x) n1.i(cls)).getDefaultInstanceForType();
            if (xVar == null) {
                throw new IllegalStateException();
            }
            defaultInstanceMap.put(cls, xVar);
        }
        return xVar;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static Object r(Method method, Object obj, Object... objArr) {
        try {
            return method.invoke(obj, objArr);
        } catch (IllegalAccessException e10) {
            throw new RuntimeException("Couldn't use Java reflection to implement protocol message reflection.", e10);
        } catch (InvocationTargetException e11) {
            Throwable cause = e11.getCause();
            if (cause instanceof RuntimeException) {
                throw ((RuntimeException) cause);
            }
            if (cause instanceof Error) {
                throw ((Error) cause);
            }
            throw new RuntimeException("Unexpected exception thrown by generated accessor method.", cause);
        }
    }

    protected static final boolean t(x xVar, boolean z10) {
        byte byteValue = ((Byte) xVar.l(d.GET_MEMOIZED_IS_INITIALIZED)).byteValue();
        if (byteValue == 1) {
            return true;
        }
        if (byteValue == 0) {
            return false;
        }
        boolean c10 = z0.a().d(xVar).c(xVar);
        if (z10) {
            xVar.m(d.SET_MEMOIZED_IS_INITIALIZED, c10 ? xVar : null);
        }
        return c10;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static z.d v(z.d dVar) {
        int size = dVar.size();
        return dVar.a(size == 0 ? 10 : size * 2);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static Object x(o0 o0Var, String str, Object[] objArr) {
        return new b1(o0Var, str, objArr);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static x y(x xVar, h hVar, p pVar) {
        return j(A(xVar, hVar, pVar));
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static x z(x xVar, byte[] bArr, p pVar) {
        return j(C(xVar, bArr, 0, bArr.length, pVar));
    }

    @Override // com.google.crypto.tink.shaded.protobuf.o0
    /* renamed from: E, reason: merged with bridge method [inline-methods] */
    public final a toBuilder() {
        a aVar = (a) l(d.NEW_BUILDER);
        aVar.q(this);
        return aVar;
    }

    @Override // com.google.crypto.tink.shaded.protobuf.o0
    public void a(k kVar) {
        z0.a().d(this).i(this, l.P(kVar));
    }

    @Override // com.google.crypto.tink.shaded.protobuf.a
    int d() {
        return this.memoizedSerializedSize;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (getDefaultInstanceForType().getClass().isInstance(obj)) {
            return z0.a().d(this).d(this, (x) obj);
        }
        return false;
    }

    @Override // com.google.crypto.tink.shaded.protobuf.o0
    public int getSerializedSize() {
        if (this.memoizedSerializedSize == -1) {
            this.memoizedSerializedSize = z0.a().d(this).e(this);
        }
        return this.memoizedSerializedSize;
    }

    @Override // com.google.crypto.tink.shaded.protobuf.a
    void h(int i10) {
        this.memoizedSerializedSize = i10;
    }

    public int hashCode() {
        int i10 = this.memoizedHashCode;
        if (i10 != 0) {
            return i10;
        }
        int g10 = z0.a().d(this).g(this);
        this.memoizedHashCode = g10;
        return g10;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public Object i() {
        return l(d.BUILD_MESSAGE_INFO);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public final a k() {
        return (a) l(d.NEW_BUILDER);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public Object l(d dVar) {
        return n(dVar, null, null);
    }

    protected Object m(d dVar, Object obj) {
        return n(dVar, obj, null);
    }

    protected abstract Object n(d dVar, Object obj, Object obj2);

    @Override // com.google.crypto.tink.shaded.protobuf.p0
    /* renamed from: q, reason: merged with bridge method [inline-methods] */
    public final x getDefaultInstanceForType() {
        return (x) l(d.GET_DEFAULT_INSTANCE);
    }

    public final boolean s() {
        return t(this, true);
    }

    public String toString() {
        return q0.e(this, super.toString());
    }

    protected void u() {
        z0.a().d(this).b(this);
    }

    @Override // com.google.crypto.tink.shaded.protobuf.o0
    /* renamed from: w, reason: merged with bridge method [inline-methods] */
    public final a newBuilderForType() {
        return (a) l(d.NEW_BUILDER);
    }
}
