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

import java.util.AbstractList;
import java.util.Arrays;
import java.util.RandomAccess;

/* JADX INFO: loaded from: classes3.dex */
public final class a0 extends AbstractC1254b implements RandomAccess {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final a0 f13762d;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Object[] f13763b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f13764c;

    static {
        a0 a0Var = new a0(new Object[0], 0);
        f13762d = a0Var;
        a0Var.f13765a = false;
    }

    public a0(Object[] objArr, int i6) {
        this.f13763b = objArr;
        this.f13764c = i6;
    }

    @Override // com.google.crypto.tink.shaded.protobuf.InterfaceC1277z
    public final InterfaceC1277z a(int i6) {
        if (i6 >= this.f13764c) {
            return new a0(Arrays.copyOf(this.f13763b, i6), this.f13764c);
        }
        throw new IllegalArgumentException();
    }

    @Override // com.google.crypto.tink.shaded.protobuf.AbstractC1254b, java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
    public final boolean add(Object obj) {
        e();
        int i6 = this.f13764c;
        Object[] objArr = this.f13763b;
        if (i6 == objArr.length) {
            this.f13763b = Arrays.copyOf(objArr, ((i6 * 3) / 2) + 1);
        }
        Object[] objArr2 = this.f13763b;
        int i7 = this.f13764c;
        this.f13764c = i7 + 1;
        objArr2[i7] = obj;
        ((AbstractList) this).modCount++;
        return true;
    }

    public final void g(int i6) {
        if (i6 < 0 || i6 >= this.f13764c) {
            StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "Index:", ", Size:");
            sbR.append(this.f13764c);
            throw new IndexOutOfBoundsException(sbR.toString());
        }
    }

    @Override // java.util.AbstractList, java.util.List
    public final Object get(int i6) {
        g(i6);
        return this.f13763b[i6];
    }

    @Override // com.google.crypto.tink.shaded.protobuf.AbstractC1254b, java.util.AbstractList, java.util.List
    public final Object remove(int i6) {
        e();
        g(i6);
        Object[] objArr = this.f13763b;
        Object obj = objArr[i6];
        if (i6 < this.f13764c - 1) {
            System.arraycopy(objArr, i6 + 1, objArr, i6, (r2 - i6) - 1);
        }
        this.f13764c--;
        ((AbstractList) this).modCount++;
        return obj;
    }

    @Override // java.util.AbstractList, java.util.List
    public final Object set(int i6, Object obj) {
        e();
        g(i6);
        Object[] objArr = this.f13763b;
        Object obj2 = objArr[i6];
        objArr[i6] = obj;
        ((AbstractList) this).modCount++;
        return obj2;
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
    public final int size() {
        return this.f13764c;
    }

    @Override // java.util.AbstractList, java.util.List
    public final void add(int i6, Object obj) {
        int i7;
        e();
        if (i6 >= 0 && i6 <= (i7 = this.f13764c)) {
            Object[] objArr = this.f13763b;
            if (i7 < objArr.length) {
                System.arraycopy(objArr, i6, objArr, i6 + 1, i7 - i6);
            } else {
                Object[] objArr2 = new Object[Z0.o.A(i7, 3, 2, 1)];
                System.arraycopy(objArr, 0, objArr2, 0, i6);
                System.arraycopy(this.f13763b, i6, objArr2, i6 + 1, this.f13764c - i6);
                this.f13763b = objArr2;
            }
            this.f13763b[i6] = obj;
            this.f13764c++;
            ((AbstractList) this).modCount++;
            return;
        }
        StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "Index:", ", Size:");
        sbR.append(this.f13764c);
        throw new IndexOutOfBoundsException(sbR.toString());
    }
}
