package o; import java.io.ByteArrayOutputStream; import java.io.IOException; import net.sf.scuba.smartcards.ISO7816; /* loaded from: classes.dex */ public final class aGS { private int a; private static int a(byte b) { if (b >= 48 && b <= 57) { return b - ISO7816.INS_DECREASE; } if (b >= 65 && b <= 70) { return b - 55; } if (b < 97 || b > 102) { return -1; } return b - 87; } public final void b(C13556fcZ c13556fcZ, C16613piz c16613piz, Eaa eaa) throws IOException { String trim; StringBuilder sb = new StringBuilder(); while (true) { sb.setLength(0); while (true) { char b = (char) eaa.b(); if (b == '\r' || b == '\n') { break; } else { sb.append(b); } } if (sb.length() != 0 && sb.charAt(0) != '%') { return; } int indexOf = sb.indexOf(":"); if (indexOf != -1) { trim = sb.substring(0, indexOf).trim(); String trim2 = sb.substring(indexOf + 1).trim(); Integer num = C13556fcZ.b.get(trim); if (num != null) { int intValue = num.intValue(); if (intValue == 8) { c13556fcZ.e(8, trim2.trim()); String[] split = trim2.split(" "); int parseInt = Integer.parseInt(split[0]); int parseInt2 = Integer.parseInt(split[1]); int parseInt3 = Integer.parseInt(split[3]); if (!c13556fcZ.d(28)) { c13556fcZ.d(28, parseInt); } if (!c13556fcZ.d(29)) { c13556fcZ.d(29, parseInt2); } if (!c13556fcZ.d(30)) { c13556fcZ.d(30, parseInt3); } if (!c13556fcZ.d(31)) { int i = parseInt3 != 1 ? (parseInt3 == 2 || parseInt3 == 3 || parseInt3 == 4) ? 3 : 0 : 1; if (i != 0) { c13556fcZ.d(31, i * parseInt * parseInt2); } } } else if (intValue == 36) { int i2 = this.a; StringBuilder sb2 = new StringBuilder(); sb2.append(c13556fcZ.o(this.a)); sb2.append(" "); sb2.append(trim2); c13556fcZ.e(i2, sb2.toString()); } else if (!C13556fcZ.a.containsKey(num) || c13556fcZ.d(num.intValue())) { this.a = 0; } else { c13556fcZ.e(num.intValue(), trim2); this.a = num.intValue(); } this.a = num.intValue(); } } else { trim = sb.toString().trim(); } if (!trim.equals("%BeginPhotoshop")) { if (!trim.equals("%%BeginICCProfile")) { if (trim.equals("%begin_xml_packet")) { byte[] bytes = "".getBytes(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); int length = bytes.length; int i3 = 0; while (i3 != length) { byte b2 = eaa.b(); i3 = b2 == bytes[i3] ? i3 + 1 : 0; byteArrayOutputStream.write(b2); } String str = new String(byteArrayOutputStream.toByteArray(), UeM.d); new RKF(); RKF.c(str, c16613piz); } } else { byte[] b3 = b(eaa); if (b3 != null) { new GXv(); GXv.a(new C0925RrQ(b3), c16613piz); } } } else { byte[] b4 = b(eaa); if (b4 != null) { new EKY(); EKY.b(new C0629LEh(b4), b4.length, c16613piz); } } } } private static byte[] b(Eaa eaa) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); boolean z = false; char c = 0; byte b = 0; int i = 0; while (!z) { b = eaa.b(); if (c != 0) { if (c != 1) { if (c == 2) { int a = a(b); if (a != -1) { i = a << 4; c = 3; } else { if (b != 13 && b != 10) { return null; } c = 0; } } else if (c == 3) { int a2 = a(b); if (a2 == -1) { return null; } byteArrayOutputStream.write(a2 + i); c = 2; } else { continue; } } else if (b != 32) { z = true; } else { c = 2; } } else if (b != 10 && b != 13 && b != 32) { if (b != 37) { return null; } c = 1; } } while (b != 10) { b = eaa.b(); } return byteArrayOutputStream.toByteArray(); } }