package o; import com.airbnb.deeplinkdispatch.UrlTreeKt; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; /* renamed from: o.gni, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C15333gni implements InterfaceC15580gug { private int a; private int b; private boolean c; private Writer e; private String f; private boolean j; private String[] d = new String[12]; private int[] g = new int[4]; private String[] i = new String[8]; private boolean[] h = new boolean[4]; private final void b(boolean z) throws IOException { String str; if (!this.c) { return; } int i = this.a; int i2 = i + 1; this.a = i2; this.c = false; boolean[] zArr = this.h; if (zArr.length <= i2) { boolean[] zArr2 = new boolean[i + 5]; System.arraycopy(zArr, 0, zArr2, 0, i2); this.h = zArr2; } boolean[] zArr3 = this.h; int i3 = this.a; int i4 = i3 - 1; zArr3[i3] = zArr3[i4]; int i5 = this.g[i4]; while (true) { int[] iArr = this.g; int i6 = this.a; if (i5 < iArr[i6]) { this.e.write(32); this.e.write("xmlns"); int i7 = i5 << 1; if (!"".equals(this.i[i7])) { this.e.write(58); this.e.write(this.i[i7]); } else { boolean z2 = this.c; int i8 = this.a; if (z2) { i8++; } if (i8 == 0) { str = null; } else { str = this.d[((z2 ? this.a + 1 : this.a) * 3) - 3]; } if ("".equals(str) && !"".equals(this.i[i7 + 1])) { throw new IllegalStateException("Cannot set default namespace for elements in no namespace"); } } this.e.write("=\""); c(this.i[i7 + 1], 34); this.e.write(34); i5++; } else { int i9 = i6 + 1; if (iArr.length <= i9) { int[] iArr2 = new int[i6 + 8]; System.arraycopy(iArr, 0, iArr2, 0, i9); this.g = iArr2; } int[] iArr3 = this.g; int i10 = this.a; iArr3[i10 + 1] = iArr3[i10]; this.e.write(z ? " />" : UrlTreeKt.configurablePathSegmentSuffix); return; } } } /* JADX WARN: Code restructure failed: missing block: B:19:0x002b, code lost: if (r1 != '\'') goto L31; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private final void c(java.lang.String r6, int r7) throws java.io.IOException { /* r5 = this; r0 = 0 L1: int r1 = r6.length() if (r0 >= r1) goto La6 char r1 = r6.charAt(r0) r2 = 9 java.lang.String r3 = "&#" if (r1 == r2) goto L83 r2 = 10 if (r1 == r2) goto L83 r2 = 13 if (r1 == r2) goto L83 r2 = 34 if (r1 == r2) goto L47 r4 = 60 if (r1 == r4) goto L3f r4 = 62 if (r1 == r4) goto L37 r4 = 38 if (r1 == r4) goto L2e r4 = 39 if (r1 == r4) goto L47 goto L56 L2e: java.io.Writer r1 = r5.e java.lang.String r2 = "&" r1.write(r2) goto La2 L37: java.io.Writer r1 = r5.e java.lang.String r2 = ">" r1.write(r2) goto La2 L3f: java.io.Writer r1 = r5.e java.lang.String r2 = "<" r1.write(r2) goto La2 L47: if (r1 != r7) goto L56 java.io.Writer r3 = r5.e if (r1 != r2) goto L50 java.lang.String r1 = """ goto L52 L50: java.lang.String r1 = "'" L52: r3.write(r1) goto La2 L56: r2 = 32 if (r1 < r2) goto L6c r2 = 64 if (r1 == r2) goto L6c r2 = 127(0x7f, float:1.78E-43) if (r1 < r2) goto L66 boolean r2 = r5.j if (r2 == 0) goto L6c L66: java.io.Writer r2 = r5.e r2.write(r1) goto La2 L6c: java.io.Writer r2 = r5.e java.lang.StringBuilder r4 = new java.lang.StringBuilder r4.(r3) r4.append(r1) java.lang.String r1 = ";" r4.append(r1) java.lang.String r1 = r4.toString() r2.write(r1) goto La2 L83: r2 = -1 if (r7 != r2) goto L8c java.io.Writer r2 = r5.e r2.write(r1) goto La2 L8c: java.io.Writer r2 = r5.e java.lang.StringBuilder r4 = new java.lang.StringBuilder r4.(r3) r4.append(r1) r1 = 59 r4.append(r1) java.lang.String r1 = r4.toString() r2.write(r1) La2: int r0 = r0 + 1 goto L1 La6: return */ throw new UnsupportedOperationException("Method not decompiled: o.C15333gni.c(java.lang.String, int):void"); } @Override // o.InterfaceC15580gug public final void b(String str) throws IOException { this.e.write("= r4) goto L48 java.lang.String[] r4 = r6.i r4 = r4[r3] boolean r4 = r4.equals(r1) if (r4 != 0) goto L49 int r3 = r3 + 1 goto L2f L48: r2 = r1 L49: if (r2 == 0) goto L4c return r2 L4c: int r0 = r0 + (-2) goto Lc L4f: if (r9 != 0) goto L52 return r2 L52: boolean r8 = r1.equals(r7) if (r8 == 0) goto L59 goto L8d L59: java.lang.StringBuilder r8 = new java.lang.StringBuilder java.lang.String r9 = "n" r8.(r9) int r9 = r6.b int r0 = r9 + 1 r6.b = r0 r8.append(r9) java.lang.String r8 = r8.toString() int[] r9 = r6.g int r0 = r6.a int r0 = r0 + 1 r9 = r9[r0] int r9 = r9 << 1 int r9 = r9 + (-2) L79: if (r9 < 0) goto L8a java.lang.String[] r0 = r6.i r0 = r0[r9] boolean r0 = r8.equals(r0) if (r0 == 0) goto L87 r1 = r2 goto L8b L87: int r9 = r9 + (-2) goto L79 L8a: r1 = r8 L8b: if (r1 == 0) goto L59 L8d: boolean r8 = r6.c r9 = 0 r6.c = r9 r6.e(r1, r7) r6.c = r8 return r1 */ throw new UnsupportedOperationException("Method not decompiled: o.C15333gni.b(java.lang.String, boolean, boolean):java.lang.String"); } @Override // o.InterfaceC15580gug public final void e(String str, String str2) throws IOException { b(false); if (str == null) { str = ""; } if (str2 == null) { str2 = ""; } if (str.equals(b(str2, true, false))) { return; } int[] iArr = this.g; int i = this.a + 1; int i2 = iArr[i]; iArr[i] = i2 + 1; int i3 = i2 << 1; String[] strArr = this.i; int i4 = i3 + 1; if (strArr.length < i4) { String[] strArr2 = new String[strArr.length + 16]; System.arraycopy(strArr, 0, strArr2, 0, i3); this.i = strArr2; } String[] strArr3 = this.i; strArr3[i3] = str; strArr3[i4] = str2; } @Override // o.InterfaceC15580gug public final void b(OutputStream outputStream, String str) throws IOException { this.e = str == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, str); int[] iArr = this.g; iArr[0] = 2; iArr[1] = 2; String[] strArr = this.i; strArr[0] = ""; strArr[1] = ""; strArr[2] = "xml"; strArr[3] = "http://www.w3.org/XML/1998/namespace"; this.c = false; this.b = 0; this.a = 0; this.j = false; this.f = str; if (str == null || !str.toLowerCase().startsWith("utf")) { return; } this.j = true; } @Override // o.InterfaceC15580gug public final InterfaceC15580gug a(String str, String str2) throws IOException { b(false); if (this.h[this.a]) { this.e.write("\r\n"); for (int i = 0; i < this.a; i++) { this.e.write(" "); } } int i2 = this.a * 3; String[] strArr = this.d; if (strArr.length < i2 + 3) { String[] strArr2 = new String[strArr.length + 12]; System.arraycopy(strArr, 0, strArr2, 0, i2); this.d = strArr2; } String b = str == null ? "" : b(str, true, true); if ("".equals(str)) { for (int i3 = this.g[this.a]; i3 < this.g[this.a + 1]; i3++) { int i4 = i3 << 1; if ("".equals(this.i[i4]) && !"".equals(this.i[i4 + 1])) { throw new IllegalStateException("Cannot set default namespace for elements in no namespace"); } } } String[] strArr3 = this.d; strArr3[i2] = str; strArr3[i2 + 1] = b; strArr3[i2 + 2] = str2; this.e.write(60); if (!"".equals(b)) { this.e.write(b); this.e.write(58); } this.e.write(str2); this.c = true; return this; } @Override // o.InterfaceC15580gug public final InterfaceC15580gug c(String str, String str2, String str3) throws IOException { if (!this.c) { throw new IllegalStateException("illegal position for attribute"); } if (str == null) { str = ""; } String b = "".equals(str) ? "" : b(str, false, true); this.e.write(32); if (!"".equals(b)) { this.e.write(b); this.e.write(58); } this.e.write(str2); this.e.write(61); int i = str3.indexOf(34) != -1 ? 39 : 34; this.e.write(i); c(str3, i); this.e.write(i); return this; } @Override // o.InterfaceC15580gug public final void d() throws IOException { b(false); this.e.flush(); } @Override // o.InterfaceC15580gug public final InterfaceC15580gug b(String str, String str2) throws IOException { if (!this.c) { this.a--; } if ((str == null && this.d[this.a * 3] != null) || ((str != null && !str.equals(this.d[this.a * 3])) || !this.d[(this.a * 3) + 2].equals(str2))) { StringBuilder sb = new StringBuilder(" does not match start"); throw new IllegalArgumentException(sb.toString()); } if (this.c) { b(true); this.a--; } else { if (this.h[this.a + 1]) { this.e.write("\r\n"); for (int i = 0; i < this.a; i++) { this.e.write(" "); } } this.e.write(""); } @Override // o.InterfaceC15580gug public final void c(String str) throws IOException { b(false); this.e.write(""); } @Override // o.InterfaceC15580gug public final void g(String str) throws IOException { b(false); this.e.write(""); } @Override // o.InterfaceC15580gug public final void e(String str) throws IOException { b(false); this.h[this.a] = false; c(str, -1); } }