package p138.p329.p330.p334.p335;

import com.hierynomus.asn1.ASN1ParseException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Iterator;
import p138.p329.p330.AbstractC6080;
import p138.p329.p330.AbstractC6081;
import p138.p329.p330.C6077;
import p138.p329.p330.C6079;
import p138.p329.p330.p331.p332.C6082;
import p138.p329.p330.p331.p333.C6084;
import p138.p329.p330.p334.AbstractC6087;
import p138.p329.p330.p334.AbstractC6088;
import p138.p329.p330.p334.InterfaceC6085;

/* JADX INFO: renamed from: ދ.ށ.֏.ރ.ރ.ހ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C6109 extends AbstractC6087<AbstractC6087> implements InterfaceC6085 {

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final AbstractC6087 f17035;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public byte[] f17036;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public C6082 f17037;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public boolean f17038;

    /* JADX INFO: renamed from: ދ.ށ.֏.ރ.ރ.ހ$ؠ, reason: contains not printable characters */
    public static class C6111 extends AbstractC6080<C6109> {
        public C6111(C6082 c6082) {
            super(c6082);
        }

        @Override // p138.p329.p330.AbstractC6080
        /* JADX INFO: renamed from: ֏ */
        public AbstractC6087 mo9451(AbstractC6088 abstractC6088, byte[] bArr) {
            return new C6109(abstractC6088, bArr, this.f17003, null);
        }
    }

    /* JADX INFO: renamed from: ދ.ށ.֏.ރ.ރ.ހ$ހ, reason: contains not printable characters */
    public static class C6112 extends AbstractC6081<C6109> {
        public C6112(C6084 c6084) {
            super(c6084);
        }

        @Override // p138.p329.p330.AbstractC6081
        /* JADX INFO: renamed from: ֏ */
        public int mo9452(AbstractC6087 abstractC6087) throws IOException {
            C6109 c6109 = (C6109) abstractC6087;
            if (c6109.f17036 == null) {
                m9467(c6109);
            }
            return c6109.f17036.length;
        }

        @Override // p138.p329.p330.AbstractC6081
        /* JADX INFO: renamed from: ֏ */
        public void mo9453(AbstractC6087 abstractC6087, C6079 c6079) throws IOException {
            C6109 c6109 = (C6109) abstractC6087;
            if (c6109.f17036 == null) {
                m9467(c6109);
            }
            c6079.write(c6109.f17036);
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final void m9467(C6109 c6109) throws IOException {
            AbstractC6087 abstractC6087 = c6109.f17035;
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            C6079 c6079 = new C6079(this.f17004, byteArrayOutputStream);
            try {
                if (c6109.f17038) {
                    c6079.m9450(abstractC6087);
                } else {
                    abstractC6087.f17009.mo9462(this.f17004).mo9453(abstractC6087, c6079);
                }
                c6109.f17036 = byteArrayOutputStream.toByteArray();
                c6079.close();
            } catch (Throwable th) {
                try {
                    throw th;
                } catch (Throwable th2) {
                    try {
                        c6079.close();
                    } catch (Throwable th3) {
                        th.addSuppressed(th3);
                    }
                    throw th2;
                }
            }
        }
    }

    public C6109(AbstractC6088 abstractC6088, AbstractC6087 abstractC6087, boolean z) {
        super(z ? abstractC6088.m9463() : abstractC6088.m9464(abstractC6087.f17009.f17023));
        this.f17038 = true;
        this.f17035 = abstractC6087;
        this.f17038 = z;
        this.f17036 = null;
    }

    public /* synthetic */ C6109(AbstractC6088 abstractC6088, byte[] bArr, C6082 c6082, C6110 c6110) {
        super(abstractC6088);
        this.f17038 = true;
        this.f17036 = bArr;
        this.f17037 = c6082;
        this.f17035 = null;
    }

    @Override // java.lang.Iterable
    public Iterator<AbstractC6087> iterator() {
        return ((C6101) m9465(AbstractC6088.f17019)).iterator();
    }

    @Override // p138.p329.p330.p334.AbstractC6087
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(C6109.class.getSimpleName());
        sb.append("[");
        sb.append(this.f17009);
        if (this.f17035 != null) {
            sb.append(",");
            sb.append(this.f17035);
        } else {
            sb.append(",<unknown>");
        }
        sb.append("]");
        return sb.toString();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public <T extends AbstractC6087> T m9465(AbstractC6088<T> abstractC6088) {
        AbstractC6087 abstractC6087 = this.f17035;
        if (abstractC6087 != null && abstractC6087.f17009.equals(abstractC6088)) {
            return (T) this.f17035;
        }
        if (this.f17035 != null || this.f17036 == null) {
            throw new ASN1ParseException("Unable to parse the implicit Tagged Object with %s, it is explicit", abstractC6088);
        }
        return (T) abstractC6088.mo9461(this.f17037).mo9451(abstractC6088, this.f17036);
    }

    @Override // p138.p329.p330.p334.AbstractC6087
    /* JADX INFO: renamed from: ހ */
    public AbstractC6087 mo9457() {
        return m9466();
    }

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public AbstractC6087 m9466() {
        AbstractC6087 abstractC6087 = this.f17035;
        if (abstractC6087 != null) {
            return abstractC6087;
        }
        try {
            C6077 c6077 = new C6077(this.f17037, this.f17036);
            try {
                AbstractC6087 abstractC6087M9449 = c6077.m9449();
                c6077.close();
                return abstractC6087M9449;
            } finally {
            }
        } catch (ASN1ParseException e) {
            throw new ASN1ParseException(e, "Unable to parse the explicit Tagged Object with %s, it might be implicit", this.f17009);
        } catch (IOException e2) {
            throw new ASN1ParseException(e2, "Could not parse the inputstream", new Object[0]);
        }
    }
}
