package n;

import java.util.Arrays;
import o.AbstractC2628a;
import x4.AbstractC3250p;

/* JADX INFO: loaded from: classes.dex */
public final class e0 implements Cloneable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public /* synthetic */ boolean f21420a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public /* synthetic */ int[] f21421b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public /* synthetic */ Object[] f21422c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public /* synthetic */ int f21423d;

    public e0(int i6) {
        int i7;
        int i8 = 4;
        while (true) {
            i7 = 40;
            if (i8 >= 32) {
                break;
            }
            int i9 = (1 << i8) - 12;
            if (40 <= i9) {
                i7 = i9;
                break;
            }
            i8++;
        }
        int i10 = i7 / 4;
        this.f21421b = new int[i10];
        this.f21422c = new Object[i10];
    }

    /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
    public final e0 clone() throws CloneNotSupportedException {
        Object objClone = super.clone();
        kotlin.jvm.internal.o.f(objClone, "null cannot be cast to non-null type androidx.collection.SparseArrayCompat<E of androidx.collection.SparseArrayCompat>");
        e0 e0Var = (e0) objClone;
        e0Var.f21421b = (int[]) this.f21421b.clone();
        e0Var.f21422c = (Object[]) this.f21422c.clone();
        return e0Var;
    }

    public final Object b(int i6) {
        Object obj;
        int iA = AbstractC2628a.a(this.f21423d, i6, this.f21421b);
        if (iA < 0 || (obj = this.f21422c[iA]) == AbstractC2593u.f21480c) {
            return null;
        }
        return obj;
    }

    public final int c(int i6) {
        if (this.f21420a) {
            AbstractC2593u.a(this);
        }
        return this.f21421b[i6];
    }

    public final void d(int i6, Object obj) {
        int iA = AbstractC2628a.a(this.f21423d, i6, this.f21421b);
        if (iA >= 0) {
            this.f21422c[iA] = obj;
            return;
        }
        int i7 = ~iA;
        int i8 = this.f21423d;
        if (i7 < i8) {
            Object[] objArr = this.f21422c;
            if (objArr[i7] == AbstractC2593u.f21480c) {
                this.f21421b[i7] = i6;
                objArr[i7] = obj;
                return;
            }
        }
        if (this.f21420a && i8 >= this.f21421b.length) {
            AbstractC2593u.a(this);
            i7 = ~AbstractC2628a.a(this.f21423d, i6, this.f21421b);
        }
        int i9 = this.f21423d;
        if (i9 >= this.f21421b.length) {
            int i10 = (i9 + 1) * 4;
            int i11 = 4;
            while (true) {
                if (i11 >= 32) {
                    break;
                }
                int i12 = (1 << i11) - 12;
                if (i10 <= i12) {
                    i10 = i12;
                    break;
                }
                i11++;
            }
            int i13 = i10 / 4;
            int[] iArrCopyOf = Arrays.copyOf(this.f21421b, i13);
            kotlin.jvm.internal.o.g(iArrCopyOf, "copyOf(...)");
            this.f21421b = iArrCopyOf;
            Object[] objArrCopyOf = Arrays.copyOf(this.f21422c, i13);
            kotlin.jvm.internal.o.g(objArrCopyOf, "copyOf(...)");
            this.f21422c = objArrCopyOf;
        }
        int i14 = this.f21423d;
        if (i14 - i7 != 0) {
            int[] iArr = this.f21421b;
            int i15 = i7 + 1;
            AbstractC3250p.x(i15, i7, i14, iArr, iArr);
            Object[] objArr2 = this.f21422c;
            AbstractC3250p.B(objArr2, i15, objArr2, i7, this.f21423d);
        }
        this.f21421b[i7] = i6;
        this.f21422c[i7] = obj;
        this.f21423d++;
    }

    public final int e() {
        if (this.f21420a) {
            AbstractC2593u.a(this);
        }
        return this.f21423d;
    }

    public final Object f(int i6) {
        if (this.f21420a) {
            AbstractC2593u.a(this);
        }
        Object[] objArr = this.f21422c;
        if (i6 < objArr.length) {
            return objArr[i6];
        }
        throw new ArrayIndexOutOfBoundsException();
    }

    public final String toString() {
        if (e() <= 0) {
            return "{}";
        }
        StringBuilder sb = new StringBuilder(this.f21423d * 28);
        sb.append('{');
        int i6 = this.f21423d;
        for (int i7 = 0; i7 < i6; i7++) {
            if (i7 > 0) {
                sb.append(", ");
            }
            sb.append(c(i7));
            sb.append('=');
            Object objF = f(i7);
            if (objF != this) {
                sb.append(objF);
            } else {
                sb.append("(this Map)");
            }
        }
        sb.append('}');
        String string = sb.toString();
        kotlin.jvm.internal.o.g(string, "toString(...)");
        return string;
    }
}
