package okio;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@kotlin.Metadata(d1 = {"\u0000*\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0011\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0010\u0018\u0000 \u00192\b\u0012\u0004\u0012\u00020\u00020\u00012\u00060\u0003j\u0002`\u0004:\u0001\u001aB!\b\u0002\u0012\u000e\u0010\u0006\u001a\n\u0012\u0006\b\u0001\u0012\u00020\u00020\u0005\u0012\u0006\u0010\b\u001a\u00020\u0007¢\u0006\u0004\b\t\u0010\nJ\u0018\u0010\r\u001a\u00020\u00022\u0006\u0010\f\u001a\u00020\u000bH\u0096\u0002¢\u0006\u0004\b\r\u0010\u000eR\"\u0010\u0006\u001a\n\u0012\u0006\b\u0001\u0012\u00020\u00020\u00058\u0000X\u0080\u0004¢\u0006\f\n\u0004\b\u000f\u0010\u0010\u001a\u0004\b\u0011\u0010\u0012R\u001a\u0010\b\u001a\u00020\u00078\u0000X\u0080\u0004¢\u0006\f\n\u0004\b\u0013\u0010\u0014\u001a\u0004\b\u0015\u0010\u0016R\u0014\u0010\u0018\u001a\u00020\u000b8VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u000f\u0010\u0017¨\u0006\u001b"}, d2 = {"Lokio/Options;", "Lkotlin/collections/AbstractList;", "Lokio/ByteString;", "Ljava/util/RandomAccess;", "Lkotlin/collections/RandomAccess;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "byteStrings", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "trie", "<init>", "([Lokio/ByteString;[I)V", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "index", "f", "(I)Lokio/ByteString;", "b", "[Lokio/ByteString;", "g", "()[Lokio/ByteString;", "c", "[I", "h", "()[I", "()I", "size", "d", "Companion", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
public final class Options extends kotlin.collections.AbstractList<okio.ByteString> implements java.util.RandomAccess {

    /* JADX INFO: renamed from: d, reason: from kotlin metadata */
    public static final okio.Options.Companion INSTANCE = new okio.Options.Companion(null);

    /* JADX INFO: renamed from: b, reason: from kotlin metadata */
    private final okio.ByteString[] byteStrings;

    /* JADX INFO: renamed from: c, reason: from kotlin metadata */
    private final int[] trie;

    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(d1 = {"\u0000>\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J[\u0010\u0011\u001a\u00020\u00102\b\b\u0002\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0007\u001a\u00020\u00062\b\b\u0002\u0010\t\u001a\u00020\b2\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u000b0\n2\b\b\u0002\u0010\r\u001a\u00020\b2\b\b\u0002\u0010\u000e\u001a\u00020\b2\f\u0010\u000f\u001a\b\u0012\u0004\u0012\u00020\b0\nH\u0002¢\u0006\u0004\b\u0011\u0010\u0012J#\u0010\u0015\u001a\u00020\u00142\u0012\u0010\f\u001a\n\u0012\u0006\b\u0001\u0012\u00020\u000b0\u0013\"\u00020\u000bH\u0007¢\u0006\u0004\b\u0015\u0010\u0016R\u0018\u0010\u0019\u001a\u00020\u0004*\u00020\u00068BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0017\u0010\u0018¨\u0006\u001a"}, d2 = {"Lokio/Options$Companion;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "<init>", "()V", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "nodeOffset", "Lokio/Buffer;", "node", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "byteStringOffset", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "Lokio/ByteString;", "byteStrings", "fromIndex", "toIndex", "indexes", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "a", "(JLokio/Buffer;ILjava/util/List;IILjava/util/List;)V", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "Lokio/Options;", "d", "([Lokio/ByteString;)Lokio/Options;", "c", "(Lokio/Buffer;)J", "intCount", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
    @kotlin.jvm.internal.SourceDebugExtension
    public static final class Companion {
        public /* synthetic */ Companion(kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private final void a(long nodeOffset, okio.Buffer node, int byteStringOffset, java.util.List byteStrings, int fromIndex, int toIndex, java.util.List indexes) {
            int i;
            int i2;
            int i5;
            long j;
            int i6 = byteStringOffset;
            if (fromIndex >= toIndex) {
                throw new java.lang.IllegalArgumentException("Failed requirement.");
            }
            for (int i7 = fromIndex; i7 < toIndex; i7++) {
                if (((okio.ByteString) byteStrings.get(i7)).B() < i6) {
                    throw new java.lang.IllegalArgumentException("Failed requirement.");
                }
            }
            okio.ByteString byteString = (okio.ByteString) byteStrings.get(fromIndex);
            okio.ByteString byteString2 = (okio.ByteString) byteStrings.get(toIndex - 1);
            if (i6 == byteString.B()) {
                int iIntValue = ((java.lang.Number) indexes.get(fromIndex)).intValue();
                int i8 = fromIndex + 1;
                okio.ByteString byteString3 = (okio.ByteString) byteStrings.get(i8);
                i = i8;
                i2 = iIntValue;
                byteString = byteString3;
            } else {
                i = fromIndex;
                i2 = -1;
            }
            if (byteString.f(i6) == byteString2.f(i6)) {
                int iMin = java.lang.Math.min(byteString.B(), byteString2.B());
                int i9 = 0;
                for (int i10 = i6; i10 < iMin && byteString.f(i10) == byteString2.f(i10); i10++) {
                    i9++;
                }
                long jC = nodeOffset + c(node) + ((long) 2) + ((long) i9) + 1;
                node.writeInt(-i9);
                node.writeInt(i2);
                int i11 = i6 + i9;
                while (i6 < i11) {
                    node.writeInt(byteString.f(i6) & 255);
                    i6++;
                }
                if (i + 1 == toIndex) {
                    if (i11 != ((okio.ByteString) byteStrings.get(i)).B()) {
                        throw new java.lang.IllegalStateException("Check failed.");
                    }
                    node.writeInt(((java.lang.Number) indexes.get(i)).intValue());
                    return;
                } else {
                    okio.Buffer buffer = new okio.Buffer();
                    node.writeInt(((int) (c(buffer) + jC)) * (-1));
                    a(jC, buffer, i11, byteStrings, i, toIndex, indexes);
                    node.L1(buffer);
                    return;
                }
            }
            int i12 = 1;
            for (int i13 = i + 1; i13 < toIndex; i13++) {
                if (((okio.ByteString) byteStrings.get(i13 - 1)).f(i6) != ((okio.ByteString) byteStrings.get(i13)).f(i6)) {
                    i12++;
                }
            }
            long jC2 = nodeOffset + c(node) + ((long) 2) + ((long) (i12 * 2));
            node.writeInt(i12);
            node.writeInt(i2);
            for (int i14 = i; i14 < toIndex; i14++) {
                byte bF = ((okio.ByteString) byteStrings.get(i14)).f(i6);
                if (i14 == i || bF != ((okio.ByteString) byteStrings.get(i14 - 1)).f(i6)) {
                    node.writeInt(bF & 255);
                }
            }
            okio.Buffer buffer2 = new okio.Buffer();
            while (i < toIndex) {
                byte bF2 = ((okio.ByteString) byteStrings.get(i)).f(i6);
                int i15 = i + 1;
                int i16 = i15;
                while (true) {
                    if (i16 >= toIndex) {
                        i5 = toIndex;
                        break;
                    } else {
                        if (bF2 != ((okio.ByteString) byteStrings.get(i16)).f(i6)) {
                            i5 = i16;
                            break;
                        }
                        i16++;
                    }
                }
                if (i15 == i5 && i6 + 1 == ((okio.ByteString) byteStrings.get(i)).B()) {
                    node.writeInt(((java.lang.Number) indexes.get(i)).intValue());
                    j = jC2;
                } else {
                    node.writeInt(((int) (c(buffer2) + jC2)) * (-1));
                    j = jC2;
                    a(j, buffer2, i6 + 1, byteStrings, i, i5, indexes);
                }
                jC2 = j;
                i = i5;
            }
            node.L1(buffer2);
        }

        static /* synthetic */ void b(okio.Options.Companion companion, long j, okio.Buffer buffer, int i, java.util.List list, int i2, int i5, java.util.List list2, int i6, java.lang.Object obj) {
            if ((i6 & 1) != 0) {
                j = 0;
            }
            companion.a(j, buffer, (i6 & 4) != 0 ? 0 : i, list, (i6 & 16) != 0 ? 0 : i2, (i6 & 32) != 0 ? list.size() : i5, list2);
        }

        private final long c(okio.Buffer buffer) {
            return buffer.getSize() / ((long) 4);
        }

        public final okio.Options d(okio.ByteString... byteStrings) {
            kotlin.jvm.internal.Intrinsics.l(byteStrings, "byteStrings");
            kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker = null;
            if (byteStrings.length == 0) {
                return new okio.Options(new okio.ByteString[0], new int[]{0, -1}, defaultConstructorMarker);
            }
            java.util.List listF1 = kotlin.collections.ArraysKt.F1(byteStrings);
            kotlin.collections.CollectionsKt.C(listF1);
            int size = listF1.size();
            java.util.ArrayList arrayList = new java.util.ArrayList(size);
            for (int i = 0; i < size; i++) {
                arrayList.add(-1);
            }
            int length = byteStrings.length;
            int i2 = 0;
            int i5 = 0;
            while (i2 < length) {
                arrayList.set(kotlin.collections.CollectionsKt.n(listF1, byteStrings[i2], 0, 0, 6, (java.lang.Object) null), java.lang.Integer.valueOf(i5));
                i2++;
                i5++;
            }
            if (((okio.ByteString) listF1.get(0)).B() <= 0) {
                throw new java.lang.IllegalArgumentException("the empty byte string is not a supported option");
            }
            int i6 = 0;
            while (i6 < listF1.size()) {
                okio.ByteString byteString = (okio.ByteString) listF1.get(i6);
                int i7 = i6 + 1;
                int i8 = i7;
                while (i8 < listF1.size()) {
                    okio.ByteString byteString2 = (okio.ByteString) listF1.get(i8);
                    if (!byteString2.C(byteString)) {
                        break;
                    }
                    if (byteString2.B() == byteString.B()) {
                        throw new java.lang.IllegalArgumentException(("duplicate option: " + byteString2).toString());
                    }
                    if (((java.lang.Number) arrayList.get(i8)).intValue() > ((java.lang.Number) arrayList.get(i6)).intValue()) {
                        listF1.remove(i8);
                        arrayList.remove(i8);
                    } else {
                        i8++;
                    }
                }
                i6 = i7;
            }
            okio.Buffer buffer = new okio.Buffer();
            b(this, 0L, buffer, 0, listF1, 0, 0, arrayList, 53, null);
            int iC = (int) c(buffer);
            int[] iArr = new int[iC];
            for (int i9 = 0; i9 < iC; i9++) {
                iArr[i9] = buffer.readInt();
            }
            java.lang.Object[] objArrCopyOf = java.util.Arrays.copyOf(byteStrings, byteStrings.length);
            kotlin.jvm.internal.Intrinsics.k(objArrCopyOf, "copyOf(...)");
            return new okio.Options((okio.ByteString[]) objArrCopyOf, iArr, defaultConstructorMarker);
        }

        private Companion() {
        }
    }

    public /* synthetic */ Options(okio.ByteString[] byteStringArr, int[] iArr, kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker) {
        this(byteStringArr, iArr);
    }

    public static final okio.Options l(okio.ByteString... byteStringArr) {
        return INSTANCE.d(byteStringArr);
    }

    public int b() {
        return this.byteStrings.length;
    }

    public final /* bridge */ boolean contains(java.lang.Object obj) {
        if (obj instanceof okio.ByteString) {
            return e((okio.ByteString) obj);
        }
        return false;
    }

    public /* bridge */ boolean e(okio.ByteString byteString) {
        return super/*kotlin.collections.AbstractCollection*/.contains(byteString);
    }

    /* JADX INFO: renamed from: f, reason: merged with bridge method [inline-methods] */
    public okio.ByteString get(int index) {
        return this.byteStrings[index];
    }

    /* JADX INFO: renamed from: g, reason: from getter */
    public final okio.ByteString[] getByteStrings() {
        return this.byteStrings;
    }

    /* JADX INFO: renamed from: h, reason: from getter */
    public final int[] getTrie() {
        return this.trie;
    }

    public /* bridge */ int i(okio.ByteString byteString) {
        return super.indexOf(byteString);
    }

    public final /* bridge */ int indexOf(java.lang.Object obj) {
        if (obj instanceof okio.ByteString) {
            return i((okio.ByteString) obj);
        }
        return -1;
    }

    public /* bridge */ int j(okio.ByteString byteString) {
        return super.lastIndexOf(byteString);
    }

    public final /* bridge */ int lastIndexOf(java.lang.Object obj) {
        if (obj instanceof okio.ByteString) {
            return j((okio.ByteString) obj);
        }
        return -1;
    }

    private Options(okio.ByteString[] byteStringArr, int[] iArr) {
        this.byteStrings = byteStringArr;
        this.trie = iArr;
    }
}
