package com.facetec.sdk; import java.util.Arrays; /* loaded from: classes.dex */ final class ni extends mt { private transient byte[][] b; private transient int[] d; /* JADX INFO: Access modifiers changed from: package-private */ public ni(ms msVar, int i) { super(null); ng.d(msVar.e, 0L, i); nc ncVar = msVar.b; int i2 = 0; int i3 = 0; int i4 = 0; while (i3 < i) { if (ncVar.a == ncVar.e) { throw new AssertionError("s.limit == s.pos"); } i3 += ncVar.a - ncVar.e; i4++; ncVar = ncVar.i; } this.b = new byte[i4]; this.d = new int[i4 << 1]; nc ncVar2 = msVar.b; int i5 = 0; while (i2 < i) { this.b[i5] = ncVar2.b; i2 += ncVar2.a - ncVar2.e; if (i2 > i) { i2 = i; } int[] iArr = this.d; iArr[i5] = i2; iArr[this.b.length + i5] = ncVar2.e; ncVar2.c = true; i5++; ncVar2 = ncVar2.i; } } @Override // com.facetec.sdk.mt public final String b() { return j().b(); } @Override // com.facetec.sdk.mt public final String e() { return j().e(); } @Override // com.facetec.sdk.mt public final String c() { return j().c(); } @Override // com.facetec.sdk.mt public final mt f() { return j().f(); } @Override // com.facetec.sdk.mt public final mt d() { return j().d(); } @Override // com.facetec.sdk.mt public final mt a() { return j().a(); } @Override // com.facetec.sdk.mt public final mt e(int i, int i2) { return j().e(i, i2); } @Override // com.facetec.sdk.mt public final byte d(int i) { ng.d(this.d[this.b.length - 1], i, 1L); int a = a(i); int i2 = a == 0 ? 0 : this.d[a - 1]; int[] iArr = this.d; byte[][] bArr = this.b; return bArr[a][(i - i2) + iArr[bArr.length + a]]; } private int a(int i) { int binarySearch = Arrays.binarySearch(this.d, 0, this.b.length, i + 1); return binarySearch >= 0 ? binarySearch : ~binarySearch; } @Override // com.facetec.sdk.mt public final int i() { return this.d[this.b.length - 1]; } @Override // com.facetec.sdk.mt public final byte[] g() { int[] iArr = this.d; byte[][] bArr = this.b; byte[] bArr2 = new byte[iArr[bArr.length - 1]]; int length = bArr.length; int i = 0; int i2 = 0; while (i < length) { int[] iArr2 = this.d; int i3 = iArr2[length + i]; int i4 = iArr2[i]; System.arraycopy(this.b[i], i3, bArr2, i2, i4 - i2); i++; i2 = i4; } return bArr2; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.facetec.sdk.mt public final void c(ms msVar) { int length = this.b.length; int i = 0; int i2 = 0; while (i < length) { int[] iArr = this.d; int i3 = iArr[length + i]; int i4 = iArr[i]; nc ncVar = new nc(this.b[i], i3, (i3 + i4) - i2); if (msVar.b == null) { ncVar.f = ncVar; ncVar.i = ncVar; msVar.b = ncVar; } else { msVar.b.f.c(ncVar); } i++; i2 = i4; } msVar.e += i2; } @Override // com.facetec.sdk.mt public final boolean b(int i, mt mtVar, int i2, int i3) { if (i() - i3 < 0) { return false; } int a = a(0); while (i3 > 0) { int i4 = a == 0 ? 0 : this.d[a - 1]; int min = Math.min(i3, ((this.d[a] - i4) + i4) - i); int[] iArr = this.d; byte[][] bArr = this.b; if (!mtVar.c(i2, bArr[a], (i - i4) + iArr[bArr.length + a], min)) { return false; } i += min; i2 += min; i3 -= min; a++; } return true; } @Override // com.facetec.sdk.mt public final boolean c(int i, byte[] bArr, int i2, int i3) { if (i < 0 || i > i() - i3 || i2 < 0 || i2 > bArr.length - i3) { return false; } int a = a(i); while (i3 > 0) { int i4 = a == 0 ? 0 : this.d[a - 1]; int min = Math.min(i3, ((this.d[a] - i4) + i4) - i); int[] iArr = this.d; byte[][] bArr2 = this.b; if (!ng.c(bArr2[a], (i - i4) + iArr[bArr2.length + a], bArr, i2, min)) { return false; } i += min; i2 += min; i3 -= min; a++; } return true; } private mt j() { return new mt(g()); } @Override // com.facetec.sdk.mt public final boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof mt) { mt mtVar = (mt) obj; if (mtVar.i() == i() && b(0, mtVar, 0, i())) { return true; } } return false; } @Override // com.facetec.sdk.mt public final int hashCode() { int i = this.c; if (i != 0) { return i; } int length = this.b.length; int i2 = 0; int i3 = 1; int i4 = 0; while (i2 < length) { byte[] bArr = this.b[i2]; int[] iArr = this.d; int i5 = iArr[length + i2]; int i6 = iArr[i2]; for (int i7 = i5; i7 < (i6 - i4) + i5; i7++) { i3 = (i3 * 31) + bArr[i7]; } i2++; i4 = i6; } this.c = i3; return i3; } @Override // com.facetec.sdk.mt public final String toString() { return j().toString(); } private Object writeReplace() { return j(); } }