package defpackage;

import com.hierynomus.asn1.ASN1ParseException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.NoSuchElementException;

/* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2934 extends ᵢˇᵭ {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final /* synthetic */ int f11375;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ C2934(int i, ᵼᵫᵧˀ r2) {
        super(r2);
        this.f11375 = i;
    }

    /* JADX WARN: Finally extract failed */
    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public final AbstractC2943 m7146(AbstractC1728 abstractC1728, byte[] bArr) throws IOException {
        C1572 c1572;
        int i;
        C1614 c1614 = null;
        switch (this.f11375) {
            case 0:
                if (abstractC1728.f6878 != EnumC4278.f16052) {
                    return new C4970(abstractC1728, Arrays.copyOfRange(bArr, 1, bArr.length), bArr[0]);
                }
                try {
                    c1572 = new C1572((ᵼᵫᵧˀ) ((ᵢˇᵭ) this).ᵧᵾˀˈ, bArr);
                    ᵼᵫᵧˀ r8 = c1572.f6234;
                    try {
                        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                        byte b = 0;
                        while (c1572.available() > 0) {
                            r8.getClass();
                            AbstractC1728 abstractC17282 = ᵼᵫᵧˀ.ᵺʙ(c1572);
                            Object[] objArr = {abstractC17282};
                            if (!(abstractC17282.f6877 == abstractC1728.f6877)) {
                                throw new IllegalStateException(String.format("Expected an ASN.1 BIT STRING as Constructed object, got: %s", objArr));
                            }
                            byte[] bArr2 = ᵼᵫᵧˀ.ᐧﾞ(ᵼᵫᵧˀ.ᵧـˌᵎ(c1572), c1572);
                            byteArrayOutputStream.write(bArr2, 1, bArr2.length - 1);
                            if (c1572.available() <= 0) {
                                b = bArr2[0];
                            }
                        }
                        C4970 c4970 = new C4970(abstractC1728, byteArrayOutputStream.toByteArray(), b);
                        c1572.close();
                        return c4970;
                    } catch (Throwable th) {
                        try {
                            throw th;
                        } finally {
                            try {
                                c1572.close();
                            } catch (Throwable th2) {
                                th.addSuppressed(th2);
                            }
                        }
                    }
                } catch (IOException e) {
                    throw new ASN1ParseException(e, "Unable to parse Constructed ASN.1 BIT STRING", new Object[0]);
                }
            case 1:
                boolean z = bArr.length == 1;
                int length = bArr.length;
                if (z) {
                    boolean z2 = bArr[0] != 0;
                    c1614 = new C1614(AbstractC1728.f6869, bArr);
                    c1614.f6407 = z2;
                } else {
                    ᵹˉᵞ.ᵳٴᵶ(AbstractC2990.m7313(length, "Value of ASN1Boolean should have length 1, but was "));
                }
                return c1614;
            case 2:
                return new C3859(new BigInteger(bArr), bArr);
            case 3:
                BigInteger bigInteger = new BigInteger(bArr);
                C3175 c3175 = new C3175(AbstractC1728.f6868, bArr);
                c3175.f12036 = bigInteger;
                return c3175;
            case 4:
                if (bArr.length == 0) {
                    return new C4940(AbstractC1728.f6870, C4940.f18349);
                }
                ᵹˉᵞ.ᵳٴᵶ("ASN.1 NULL can not have a value");
                return null;
            case 5:
                if (bArr.length <= 0) {
                    ᵹˉᵞ.ˌᵜᵹᵩ("An ASN.1 OBJECT IDENTIFIER should have at least a one byte value");
                    return null;
                }
                ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bArr);
                StringBuilder sb = new StringBuilder();
                int i2 = byteArrayInputStream.read();
                sb.append(i2 / 40);
                sb.append('.');
                sb.append(i2 % 40);
                while (byteArrayInputStream.available() > 0) {
                    int i3 = byteArrayInputStream.read();
                    if (i3 < 127) {
                        sb.append('.');
                        sb.append(i3);
                    } else {
                        BigInteger bigIntegerValueOf = BigInteger.valueOf(i3 & 127);
                        do {
                            i = byteArrayInputStream.read();
                            bigIntegerValueOf = bigIntegerValueOf.shiftLeft(7).add(BigInteger.valueOf(i & 127));
                        } while (i > 127);
                        sb.append('.');
                        sb.append(bigIntegerValueOf);
                    }
                }
                String string = sb.toString();
                C3760 c3760 = new C3760(AbstractC1728.f6872, bArr);
                c3760.f14013 = string;
                return c3760;
            case C1339.STRING_SET_FIELD_NUMBER /* 6 */:
                return new C2105(abstractC1728, bArr);
            case C1339.DOUBLE_FIELD_NUMBER /* 7 */:
                ArrayList arrayList = new ArrayList();
                try {
                    C1572 c15722 = new C1572((ᵼᵫᵧˀ) ((ᵢˇᵭ) this).ᵧᵾˀˈ, bArr);
                    while (true) {
                        try {
                            boolean z3 = c15722.available() > 0;
                            if (!z3) {
                                c15722.close();
                                return new C5443(arrayList, bArr);
                            }
                            try {
                                arrayList.add(c15722.m4551());
                            } catch (Exception e2) {
                                throw new NoSuchElementException(e2.getMessage());
                            }
                        } finally {
                            try {
                                throw th;
                            } finally {
                                try {
                                    c15722.close();
                                } catch (Throwable th3) {
                                    th.addSuppressed(th3);
                                }
                            }
                        }
                    }
                } catch (IOException e3) {
                    throw new ASN1ParseException(e3, "Unable to parse the ASN.1 SEQUENCE contents.", new Object[0]);
                }
            case C1339.BYTES_FIELD_NUMBER /* 8 */:
                HashSet hashSet = new HashSet();
                try {
                    c1572 = new C1572((ᵼᵫᵧˀ) ((ᵢˇᵭ) this).ᵧᵾˀˈ, bArr);
                    while (true) {
                        try {
                            try {
                            } finally {
                            }
                        } catch (IOException unused) {
                        }
                        boolean z4 = c1572.available() > 0;
                        if (!z4) {
                            c1572.close();
                            return new C3440(hashSet, bArr);
                        }
                        try {
                            hashSet.add(c1572.m4551());
                        } catch (Exception e4) {
                            throw new NoSuchElementException(e4.getMessage());
                        }
                    }
                } catch (IOException e5) {
                    throw new ASN1ParseException(e5, "Could not parse ASN.1 SET contents.", new Object[0]);
                }
            default:
                return new C3647(abstractC1728, bArr, (ᵼᵫᵧˀ) ((ᵢˇᵭ) this).ᵧᵾˀˈ);
        }
    }
}
