package androidx.datastore.preferences.protobuf;

import androidx.datastore.preferences.protobuf.y;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* loaded from: classes.dex */
abstract class e0 {

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

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

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

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

        private b() {
            super();
        }

        static List f(Object obj, long j10) {
            return (List) o1.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 y.b)) ? ((y.b) f10).a(i10) : new ArrayList(i10);
                o1.O(obj, j10, c0Var2);
                return c0Var2;
            }
            if (f4037c.isAssignableFrom(f10.getClass())) {
                ArrayList arrayList = new ArrayList(f10.size() + i10);
                arrayList.addAll(f10);
                o1.O(obj, j10, arrayList);
                c0Var = arrayList;
            } else {
                if (!(f10 instanceof n1)) {
                    if (!(f10 instanceof x0) || !(f10 instanceof y.b)) {
                        return f10;
                    }
                    y.b bVar = (y.b) f10;
                    if (bVar.h()) {
                        return f10;
                    }
                    y.b a10 = bVar.a(f10.size() + i10);
                    o1.O(obj, j10, a10);
                    return a10;
                }
                c0 c0Var3 = new c0(f10.size() + i10);
                c0Var3.addAll((n1) f10);
                o1.O(obj, j10, c0Var3);
                c0Var = c0Var3;
            }
            return c0Var;
        }

        @Override // androidx.datastore.preferences.protobuf.e0
        void c(Object obj, long j10) {
            Object unmodifiableList;
            List list = (List) o1.A(obj, j10);
            if (list instanceof d0) {
                unmodifiableList = ((d0) list).c();
            } else {
                if (f4037c.isAssignableFrom(list.getClass())) {
                    return;
                }
                if ((list instanceof x0) && (list instanceof y.b)) {
                    y.b bVar = (y.b) list;
                    if (bVar.h()) {
                        bVar.d();
                        return;
                    }
                    return;
                }
                unmodifiableList = Collections.unmodifiableList(list);
            }
            o1.O(obj, j10, unmodifiableList);
        }

        @Override // androidx.datastore.preferences.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;
            }
            o1.O(obj, j10, f10);
        }

        @Override // androidx.datastore.preferences.protobuf.e0
        List e(Object obj, long j10) {
            return g(obj, j10, 10);
        }
    }

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

        static y.b f(Object obj, long j10) {
            return (y.b) o1.A(obj, j10);
        }

        @Override // androidx.datastore.preferences.protobuf.e0
        void c(Object obj, long j10) {
            f(obj, j10).d();
        }

        @Override // androidx.datastore.preferences.protobuf.e0
        void d(Object obj, Object obj2, long j10) {
            y.b f10 = f(obj, j10);
            y.b 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;
            }
            o1.O(obj, j10, f11);
        }

        @Override // androidx.datastore.preferences.protobuf.e0
        List e(Object obj, long j10) {
            y.b f10 = f(obj, j10);
            if (f10.h()) {
                return f10;
            }
            int size = f10.size();
            y.b a10 = f10.a(size == 0 ? 10 : size * 2);
            o1.O(obj, j10, a10);
            return a10;
        }
    }

    static {
        f4035a = new b();
        f4036b = new c();
    }

    private e0() {
    }

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

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

    /* 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);
}
