package com.google.android.gms.internal.clearcut; import com.kofax.mobile.sdk._internal.impl.camera.h; import java.nio.ByteBuffer; /* loaded from: classes2.dex */ final class zzfj extends zzfg { /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.android.gms.internal.clearcut.zzfg public final void zzb(CharSequence charSequence, ByteBuffer byteBuffer) { long j; char c; long j2; long j3; long j4; int i; char c2; char charAt; long zzb = zzfd.zzb(byteBuffer); long position = byteBuffer.position() + zzb; long limit = byteBuffer.limit() + zzb; int length = charSequence.length(); if (length > limit - position) { char charAt2 = charSequence.charAt(length - 1); int limit2 = byteBuffer.limit(); StringBuilder sb = new StringBuilder(37); sb.append("Failed writing "); sb.append(charAt2); sb.append(" at index "); sb.append(limit2); throw new ArrayIndexOutOfBoundsException(sb.toString()); } int i2 = 0; while (true) { j = 1; c = 128; if (i2 >= length || (charAt = charSequence.charAt(i2)) >= 128) { break; } zzfd.zza(position, (byte) charAt); i2++; position++; } if (i2 == length) { j2 = position - zzb; } else { while (i2 < length) { char charAt3 = charSequence.charAt(i2); if (charAt3 >= c || position >= limit) { if (charAt3 < 2048 && position <= limit - 2) { zzfd.zza(position, (byte) ((charAt3 >>> 6) | 960)); j4 = position + 2; zzfd.zza(position + j, (byte) ((charAt3 & '?') | c)); j3 = zzb; } else { if ((charAt3 >= 55296 && 57343 >= charAt3) || position > limit - 3) { j3 = zzb; if (position > limit - 4) { if (55296 <= charAt3 && charAt3 <= 57343 && ((i = i2 + 1) == length || !Character.isSurrogatePair(charAt3, charSequence.charAt(i)))) { throw new zzfi(i2, length); } StringBuilder sb2 = new StringBuilder(46); sb2.append("Failed writing "); sb2.append(charAt3); sb2.append(" at index "); sb2.append(position); throw new ArrayIndexOutOfBoundsException(sb2.toString()); } int i3 = i2 + 1; if (i3 != length) { char charAt4 = charSequence.charAt(i3); if (Character.isSurrogatePair(charAt3, charAt4)) { int codePoint = Character.toCodePoint(charAt3, charAt4); zzfd.zza(position, (byte) ((codePoint >>> 18) | 240)); c2 = 128; zzfd.zza(position + j, (byte) (((codePoint >>> 12) & 63) | 128)); zzfd.zza(position + 2, (byte) (((codePoint >>> 6) & 63) | 128)); zzfd.zza(position + 3, (byte) ((codePoint & 63) | 128)); position = 4 + position; i2 = i3; } else { i2 = i3; } } throw new zzfi(i2 - 1, length); } zzfd.zza(position, (byte) ((charAt3 >>> '\f') | h.Az)); j3 = zzb; zzfd.zza(position + j, (byte) (((charAt3 >>> 6) & 63) | 128)); zzfd.zza(position + 2, (byte) ((charAt3 & '?') | 128)); j4 = position + 3; } position = j4; c2 = 128; } else { zzfd.zza(position, (byte) charAt3); position += j; j3 = zzb; c2 = c; } i2++; c = c2; zzb = j3; j = 1; } j2 = position - zzb; } byteBuffer.position((int) j2); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.android.gms.internal.clearcut.zzfg public final int zzb(CharSequence charSequence, byte[] bArr, int i, int i2) { long j; long j2; int i3; long j3; char charAt; long j4 = i; long j5 = i2 + j4; int length = charSequence.length(); if (length > i2 || bArr.length - i2 < i) { char charAt2 = charSequence.charAt(length - 1); StringBuilder sb = new StringBuilder(37); sb.append("Failed writing "); sb.append(charAt2); sb.append(" at index "); sb.append(i + i2); throw new ArrayIndexOutOfBoundsException(sb.toString()); } int i4 = 0; while (true) { j = 1; if (i4 >= length || (charAt = charSequence.charAt(i4)) >= 128) { break; } zzfd.zza(bArr, j4, (byte) charAt); i4++; j4++; } if (i4 == length) { return (int) j4; } while (i4 < length) { char charAt3 = charSequence.charAt(i4); if (charAt3 >= 128 || j4 >= j5) { if (charAt3 < 2048 && j4 <= j5 - 2) { zzfd.zza(bArr, j4, (byte) ((charAt3 >>> 6) | 960)); j2 = 2 + j4; zzfd.zza(bArr, j4 + j, (byte) ((charAt3 & '?') | 128)); } else { if ((charAt3 >= 55296 && 57343 >= charAt3) || j4 > j5 - 3) { if (j4 > j5 - 4) { if (55296 <= charAt3 && charAt3 <= 57343 && ((i3 = i4 + 1) == length || !Character.isSurrogatePair(charAt3, charSequence.charAt(i3)))) { throw new zzfi(i4, length); } StringBuilder sb2 = new StringBuilder(46); sb2.append("Failed writing "); sb2.append(charAt3); sb2.append(" at index "); sb2.append(j4); throw new ArrayIndexOutOfBoundsException(sb2.toString()); } int i5 = i4 + 1; if (i5 != length) { char charAt4 = charSequence.charAt(i5); if (Character.isSurrogatePair(charAt3, charAt4)) { int codePoint = Character.toCodePoint(charAt3, charAt4); zzfd.zza(bArr, j4, (byte) ((codePoint >>> 18) | 240)); j3 = 1; zzfd.zza(bArr, j4 + 1, (byte) (((codePoint >>> 12) & 63) | 128)); zzfd.zza(bArr, 2 + j4, (byte) (((codePoint >>> 6) & 63) | 128)); zzfd.zza(bArr, j4 + 3, (byte) ((codePoint & 63) | 128)); j4 = 4 + j4; i4 = i5; } else { i4 = i5; } } throw new zzfi(i4 - 1, length); } zzfd.zza(bArr, j4, (byte) ((charAt3 >>> '\f') | h.Az)); zzfd.zza(bArr, j4 + j, (byte) (((charAt3 >>> 6) & 63) | 128)); j2 = j4 + 3; zzfd.zza(bArr, j4 + 2, (byte) ((charAt3 & '?') | 128)); } j4 = j2; j3 = 1; } else { zzfd.zza(bArr, j4, (byte) charAt3); j4 += j; j3 = j; } i4++; j = j3; } return (int) j4; } /* JADX WARN: Code restructure failed: missing block: B:71:0x0055, code lost: return -1; */ @Override // com.google.android.gms.internal.clearcut.zzfg /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ final int zzb(int r12, byte[] r13, int r14, int r15) { /* Method dump skipped, instructions count: 207 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.clearcut.zzfj.zzb(int, byte[], int, int):int"); } private static int zza(byte[] bArr, int i, long j, int i2) { int zzam; int zzp; int zzd; if (i2 == 0) { zzam = zzff.zzam(i); return zzam; } if (i2 == 1) { zzp = zzff.zzp(i, zzfd.zza(bArr, j)); return zzp; } if (i2 != 2) { throw new AssertionError(); } zzd = zzff.zzd(i, zzfd.zza(bArr, j), zzfd.zza(bArr, j + 1)); return zzd; } }