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

import com.google.crypto.tink.shaded.protobuf.z;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public abstract class e0 {

    /* renamed from: a, reason: collision with root package name */
    private static final e0 f14334a;

    /* renamed from: b, reason: collision with root package name */
    private static final e0 f14335b;

    /* loaded from: classes3.dex */
    private static final class b extends e0 {

        /* renamed from: c, reason: collision with root package name */
        private static final Class f14336c = Collections.unmodifiableList(Collections.emptyList()).getClass();

        private b() {
            super();
        }

        static List f(Object obj, long j10) {
            return (List) n1.A(obj, j10);
        }

        /* JADX WARN: Multi-variable type inference failed */
        private static List g(Object obj, long j10, int i10) {
            c0 c0Var;
            List f10 = f(obj, j10);
            if (f10.isEmpty()) {
                List c0Var2 = f10 instanceof d0 ? new c0(i10) : ((f10 instanceof x0) && (f10 instanceof z.d)) ? ((z.d) f10).a(i10) : new ArrayList(i10);
                n1.O(obj, j10, c0Var2);
                return c0Var2;
            }
            if (f14336c.isAssignableFrom(f10.getClass())) {
                ArrayList arrayList = new ArrayList(f10.size() + i10);
                arrayList.addAll(f10);
                n1.O(obj, j10, arrayList);
                c0Var = arrayList;
            } else {
                if (!(f10 instanceof m1)) {
                    if (!(f10 instanceof x0) || !(f10 instanceof z.d)) {
                        return f10;
                    }
                    z.d dVar = (z.d) f10;
                    if (dVar.h()) {
                        return f10;
                    }
                    z.d a10 = dVar.a(f10.size() + i10);
                    n1.O(obj, j10, a10);
                    return a10;
                }
                c0 c0Var3 = new c0(f10.size() + i10);
                c0Var3.addAll((m1) f10);
                n1.O(obj, j10, c0Var3);
                c0Var = c0Var3;
            }
            return c0Var;
        }

        @Override // com.google.crypto.tink.shaded.protobuf.e0
        void c(Object obj, long j10) {
            Object unmodifiableList;
            List list = (List) n1.A(obj, j10);
            if (list instanceof d0) {
                unmodifiableList = ((d0) list).c();
            } else {
                if (f14336c.isAssignableFrom(list.getClass())) {
                    return;
                }
                if ((list instanceof x0) && (list instanceof z.d)) {
                    z.d dVar = (z.d) list;
                    if (dVar.h()) {
                        dVar.d();
                        return;
                    }
                    return;
                }
                unmodifiableList = Collections.unmodifiableList(list);
            }
            n1.O(obj, j10, unmodifiableList);
        }

        @Override // com.google.crypto.tink.shaded.protobuf.e0
        void d(Object obj, Object obj2, long j10) {
            List f10 = f(obj2, j10);
            List g10 = g(obj, j10, f10.size());
            int size = g10.size();
            int size2 = f10.size();
            if (size > 0 && size2 > 0) {
                g10.addAll(f10);
            }
            if (size > 0) {
                f10 = g10;
            }
            n1.O(obj, j10, f10);
        }

        @Override // com.google.crypto.tink.shaded.protobuf.e0
        List e(Object obj, long j10) {
            return g(obj, j10, 10);
        }
    }

    /* loaded from: classes3.dex */
    private static final class c extends e0 {
        private c() {
            super();
        }

        static z.d f(Object obj, long j10) {
            return (z.d) n1.A(obj, j10);
        }

        @Override // com.google.crypto.tink.shaded.protobuf.e0
        void c(Object obj, long j10) {
            f(obj, j10).d();
        }

        @Override // com.google.crypto.tink.shaded.protobuf.e0
        void d(Object obj, Object obj2, long j10) {
            z.d f10 = f(obj, j10);
            z.d f11 = f(obj2, j10);
            int size = f10.size();
            int size2 = f11.size();
            if (size > 0 && size2 > 0) {
                if (!f10.h()) {
                    f10 = f10.a(size2 + size);
                }
                f10.addAll(f11);
            }
            if (size > 0) {
                f11 = f10;
            }
            n1.O(obj, j10, f11);
        }

        @Override // com.google.crypto.tink.shaded.protobuf.e0
        List e(Object obj, long j10) {
            z.d f10 = f(obj, j10);
            if (f10.h()) {
                return f10;
            }
            int size = f10.size();
            z.d a10 = f10.a(size == 0 ? 10 : size * 2);
            n1.O(obj, j10, a10);
            return a10;
        }
    }

    static {
        f14334a = new b();
        f14335b = new c();
    }

    private e0() {
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static e0 a() {
        return f14334a;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static e0 b() {
        return f14335b;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public abstract void c(Object obj, long j10);

    /* JADX INFO: Access modifiers changed from: package-private */
    public abstract void d(Object obj, Object obj2, long j10);

    /* JADX INFO: Access modifiers changed from: package-private */
    public abstract List e(Object obj, long j10);
}
