package com.google.android.gms.internal.firebase_ml; /* loaded from: classes2.dex */ public abstract class zzij extends zzif { protected abstract int zza(CharSequence charSequence, int i, int i2); protected abstract char[] zzai(int i); /* JADX INFO: Access modifiers changed from: protected */ public final String zza(String str, int i) { int length = str.length(); char[] zzhk = zzih.zzhk(); int i2 = 0; int i3 = 0; while (i < length) { if (i < length) { int i4 = i + 1; char charAt = str.charAt(i); int i5 = charAt; if (charAt >= 55296) { i5 = charAt; if (charAt <= 57343) { if (charAt > 56319) { StringBuilder sb = new StringBuilder(82); sb.append("Unexpected low surrogate character '"); sb.append(charAt); sb.append("' with value "); sb.append((int) charAt); sb.append(" at index "); sb.append(i); throw new IllegalArgumentException(sb.toString()); } if (i4 == length) { i5 = -charAt; } else { char charAt2 = str.charAt(i4); if (Character.isLowSurrogate(charAt2)) { i5 = Character.toCodePoint(charAt, charAt2); } else { StringBuilder sb2 = new StringBuilder(83); sb2.append("Expected low surrogate but got char '"); sb2.append(charAt2); sb2.append("' with value "); sb2.append((int) charAt2); sb2.append(" at index "); sb2.append(i4); throw new IllegalArgumentException(sb2.toString()); } } } } if (i5 < 0) { throw new IllegalArgumentException("Trailing high surrogate at end of input"); } char[] zzai = zzai(i5); int i6 = (Character.isSupplementaryCodePoint(i5) ? 2 : 1) + i; if (zzai != null) { int i7 = i - i2; int i8 = i3 + i7; int length2 = zzai.length + i8; if (zzhk.length < length2) { zzhk = zza(zzhk, i3, ((length2 + length) - i) + 32); } if (i7 > 0) { str.getChars(i2, i, zzhk, i3); i3 = i8; } if (zzai.length > 0) { System.arraycopy(zzai, 0, zzhk, i3, zzai.length); i3 += zzai.length; } i2 = i6; } i = zza(str, i6, length); } else { throw new IndexOutOfBoundsException("Index exceeds specified range"); } } int i9 = length - i2; if (i9 > 0) { int i10 = i9 + i3; if (zzhk.length < i10) { zzhk = zza(zzhk, i3, i10); } str.getChars(i2, length, zzhk, i3); i3 = i10; } return new String(zzhk, 0, i3); } private static char[] zza(char[] cArr, int i, int i2) { char[] cArr2 = new char[i2]; if (i > 0) { System.arraycopy(cArr, 0, cArr2, 0, i); } return cArr2; } }