discord-jadx/app/src/main/java/g0/o.java

239 lines
9.4 KiB
Java

package g0;
import d0.t.c;
import d0.t.k;
import d0.t.n;
import d0.t.q;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.RandomAccess;
import kotlin.TypeCastException;
import kotlin.jvm.internal.DefaultConstructorMarker;
import okio.ByteString;
/* compiled from: Options.kt */
public final class o extends c<ByteString> implements RandomAccess {
public static final a j = new a(null);
public final ByteString[] k;
public final int[] l;
/* compiled from: Options.kt */
public static final class a {
public a(DefaultConstructorMarker defaultConstructorMarker) {
}
public final void a(long j, e eVar, int i, List<? extends ByteString> list, int i2, int i3, List<Integer> list2) {
int i4;
int i5;
int i6;
int i7;
e eVar2;
int i8 = i;
if (i2 < i3) {
for (int i9 = i2; i9 < i3; i9++) {
if (!(((ByteString) list.get(i9)).j() >= i8)) {
throw new IllegalArgumentException("Failed requirement.".toString());
}
}
ByteString byteString = (ByteString) list.get(i2);
ByteString byteString2 = (ByteString) list.get(i3 - 1);
if (i8 == byteString.j()) {
int i10 = i2 + 1;
i4 = i10;
i5 = list2.get(i2).intValue();
byteString = (ByteString) list.get(i10);
} else {
i4 = i2;
i5 = -1;
}
if (byteString.m(i8) != byteString2.m(i8)) {
int i11 = 1;
for (int i12 = i4 + 1; i12 < i3; i12++) {
if (((ByteString) list.get(i12 - 1)).m(i8) != ((ByteString) list.get(i12)).m(i8)) {
i11++;
}
}
long b = b(eVar) + j + ((long) 2) + ((long) (i11 * 2));
eVar.W(i11);
eVar.W(i5);
for (int i13 = i4; i13 < i3; i13++) {
byte m = ((ByteString) list.get(i13)).m(i8);
if (i13 == i4 || m != ((ByteString) list.get(i13 - 1)).m(i8)) {
eVar.W(m & 255);
}
}
e eVar3 = new e();
while (i4 < i3) {
byte m2 = ((ByteString) list.get(i4)).m(i8);
int i14 = i4 + 1;
int i15 = i14;
while (true) {
if (i15 >= i3) {
i6 = i3;
break;
} else if (m2 != ((ByteString) list.get(i15)).m(i8)) {
i6 = i15;
break;
} else {
i15++;
}
}
if (i14 == i6 && i8 + 1 == ((ByteString) list.get(i4)).j()) {
eVar.W(list2.get(i4).intValue());
i7 = i6;
eVar2 = eVar3;
} else {
eVar.W(((int) (b(eVar3) + b)) * -1);
i7 = i6;
eVar2 = eVar3;
a(b, eVar3, i8 + 1, list, i4, i6, list2);
}
eVar3 = eVar2;
i4 = i7;
}
eVar.O(eVar3);
return;
}
int min = Math.min(byteString.j(), byteString2.j());
int i16 = i8;
int i17 = 0;
while (i16 < min && byteString.m(i16) == byteString2.m(i16)) {
i17++;
i16++;
}
long b2 = b(eVar) + j + ((long) 2) + ((long) i17) + 1;
eVar.W(-i17);
eVar.W(i5);
int i18 = i8 + i17;
while (i8 < i18) {
eVar.W(byteString.m(i8) & 255);
i8++;
}
if (i4 + 1 == i3) {
if (i18 == ((ByteString) list.get(i4)).j()) {
eVar.W(list2.get(i4).intValue());
return;
}
throw new IllegalStateException("Check failed.".toString());
}
e eVar4 = new e();
eVar.W(((int) (b(eVar4) + b2)) * -1);
a(b2, eVar4, i18, list, i4, i3, list2);
eVar.O(eVar4);
return;
}
throw new IllegalArgumentException("Failed requirement.".toString());
}
public final long b(e eVar) {
return eVar.j / ((long) 4);
}
public final o c(ByteString... byteStringArr) {
m.checkParameterIsNotNull(byteStringArr, "byteStrings");
int i = 0;
if (byteStringArr.length == 0) {
return new o(new ByteString[0], new int[]{0, -1}, null);
}
List<? extends ByteString> mutableList = k.toMutableList(byteStringArr);
q.sort(mutableList);
ArrayList arrayList = new ArrayList(byteStringArr.length);
for (ByteString byteString : byteStringArr) {
arrayList.add(-1);
}
Object[] array = arrayList.toArray(new Integer[0]);
if (array != null) {
Integer[] numArr = (Integer[]) array;
List<Integer> mutableListOf = n.mutableListOf((Integer[]) Arrays.copyOf(numArr, numArr.length));
int length = byteStringArr.length;
int i2 = 0;
int i3 = 0;
while (i2 < length) {
mutableListOf.set(n.binarySearch$default(mutableList, byteStringArr[i2], 0, 0, 6, null), Integer.valueOf(i3));
i2++;
i3++;
}
if (((ByteString) mutableList.get(0)).j() > 0) {
int i4 = 0;
while (i4 < mutableList.size()) {
ByteString byteString2 = (ByteString) mutableList.get(i4);
int i5 = i4 + 1;
int i6 = i5;
while (i6 < mutableList.size()) {
ByteString byteString3 = (ByteString) mutableList.get(i6);
Objects.requireNonNull(byteString3);
m.checkParameterIsNotNull(byteString2, "prefix");
if (!byteString3.n(0, byteString2, 0, byteString2.j())) {
continue;
break;
}
if (!(byteString3.j() != byteString2.j())) {
throw new IllegalArgumentException(("duplicate option: " + byteString3).toString());
} else if (mutableListOf.get(i6).intValue() > mutableListOf.get(i4).intValue()) {
mutableList.remove(i6);
mutableListOf.remove(i6);
} else {
i6++;
}
}
i4 = i5;
}
e eVar = new e();
a(0, eVar, 0, mutableList, 0, mutableList.size(), mutableListOf);
int[] iArr = new int[((int) b(eVar))];
while (!eVar.v()) {
iArr[i] = eVar.readInt();
i++;
}
Object[] copyOf = Arrays.copyOf(byteStringArr, byteStringArr.length);
m.checkExpressionValueIsNotNull(copyOf, "java.util.Arrays.copyOf(this, size)");
return new o((ByteString[]) copyOf, iArr, null);
}
throw new IllegalArgumentException("the empty byte string is not a supported option".toString());
}
throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
}
}
public o(ByteString[] byteStringArr, int[] iArr, DefaultConstructorMarker defaultConstructorMarker) {
this.k = byteStringArr;
this.l = iArr;
}
@Override // d0.t.a, java.util.Collection, java.util.List
public final /* bridge */ boolean contains(Object obj) {
if (obj instanceof ByteString) {
return super.contains((ByteString) obj);
}
return false;
}
@Override // d0.t.c, java.util.List
public Object get(int i) {
return this.k[i];
}
@Override // d0.t.a
public int getSize() {
return this.k.length;
}
@Override // d0.t.c, java.util.List
public final /* bridge */ int indexOf(Object obj) {
if (obj instanceof ByteString) {
return super.indexOf((ByteString) obj);
}
return -1;
}
@Override // d0.t.c, java.util.List
public final /* bridge */ int lastIndexOf(Object obj) {
if (obj instanceof ByteString) {
return super.lastIndexOf((ByteString) obj);
}
return -1;
}
}