package defpackage;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Iterator;
import java.util.StringTokenizer;

/* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4838 extends ᵢˇᵭ {

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ C4838(ˊᵻ r1, int i) {
        super(r1);
        this.f17967 = i;
    }

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public static void m10163(C3760 c3760) {
        String str = c3760.f14013;
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        StringTokenizer stringTokenizer = new StringTokenizer(str, ".");
        byteArrayOutputStream.write((Integer.parseInt(stringTokenizer.nextToken()) * 40) + Integer.parseInt(stringTokenizer.nextToken()));
        while (stringTokenizer.hasMoreTokens()) {
            BigInteger bigInteger = new BigInteger(stringTokenizer.nextToken());
            if (bigInteger.intValue() <= 0 || bigInteger.intValue() >= 127) {
                for (int iBitLength = ((bigInteger.bitLength() / 7) + (bigInteger.bitLength() % 7 > 0 ? 1 : 0)) - 1; iBitLength >= 0; iBitLength--) {
                    byte bByteValue = (byte) (bigInteger.shiftRight(iBitLength * 7).byteValue() & Byte.MAX_VALUE);
                    if (iBitLength > 0) {
                        bByteValue = (byte) (bByteValue | 128);
                    }
                    byteArrayOutputStream.write(bByteValue);
                }
            } else {
                byteArrayOutputStream.write(bigInteger.intValue());
            }
        }
        c3760.f20538 = byteArrayOutputStream.toByteArray();
    }

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public void m10164(C3647 c3647) throws IOException {
        AbstractC2943 abstractC2943 = c3647.f13554;
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ˊᵻ r4 = (ˊᵻ) ((ᵢˇᵭ) this).ᵧᵾˀˈ;
        C3692 c3692 = new C3692(r4, byteArrayOutputStream);
        try {
            if (c3647.f13555) {
                c3692.m8285(abstractC2943);
            } else {
                abstractC2943.f11406.mo2387(r4).ᵞʡ(abstractC2943, c3692);
            }
            c3647.f13557 = byteArrayOutputStream.toByteArray();
            c3692.close();
        } catch (Throwable th) {
            try {
                throw th;
            } catch (Throwable th2) {
                try {
                    c3692.close();
                } catch (Throwable th3) {
                    th.addSuppressed(th3);
                }
                throw th2;
            }
        }
    }

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public final void m10165(AbstractC2943 abstractC2943, C3692 c3692) throws IOException {
        switch (this.f17967) {
            case 0:
                C4970 c4970 = (C4970) abstractC2943;
                c3692.write(c4970.f18463);
                c3692.write(c4970.f12177);
                break;
            case 1:
                c3692.write(((C1614) abstractC2943).f6407 ? 1 : 0);
                break;
            case 2:
                C3859 c3859 = (C3859) abstractC2943;
                if (c3859.f20538 == null) {
                    c3859.f20538 = c3859.f14356.toByteArray();
                }
                c3692.write(c3859.f20538);
                break;
            case 3:
                c3692.write(((C3175) abstractC2943).f20538);
                break;
            case 4:
                break;
            case 5:
                C3760 c3760 = (C3760) abstractC2943;
                if (c3760.f20538 == null) {
                    m10163(c3760);
                }
                c3692.write(c3760.f20538);
                break;
            case C1339.STRING_SET_FIELD_NUMBER /* 6 */:
                c3692.write(((C2105) abstractC2943).f12177);
                break;
            case C1339.DOUBLE_FIELD_NUMBER /* 7 */:
                C5443 c5443 = (C5443) abstractC2943;
                byte[] bArr = c5443.f20426;
                if (bArr == null) {
                    Iterator it = c5443.iterator();
                    while (it.hasNext()) {
                        c3692.m8285((AbstractC2943) it.next());
                    }
                    break;
                } else {
                    c3692.write(bArr);
                    break;
                }
            case C1339.BYTES_FIELD_NUMBER /* 8 */:
                C3440 c3440 = (C3440) abstractC2943;
                byte[] bArr2 = c3440.f12871;
                if (bArr2 == null) {
                    Iterator it2 = c3440.iterator();
                    while (it2.hasNext()) {
                        c3692.m8285((AbstractC2943) it2.next());
                    }
                    break;
                } else {
                    c3692.write(bArr2);
                    break;
                }
            default:
                C3647 c3647 = (C3647) abstractC2943;
                if (c3647.f13557 == null) {
                    m10164(c3647);
                }
                c3692.write(c3647.f13557);
                break;
        }
    }

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public final int m10166(AbstractC2943 abstractC2943) throws IOException {
        switch (this.f17967) {
            case 0:
                return ((C4970) abstractC2943).f12177.length + 1;
            case 1:
                return 1;
            case 2:
                C3859 c3859 = (C3859) abstractC2943;
                if (c3859.f20538 == null) {
                    c3859.f20538 = c3859.f14356.toByteArray();
                }
                return c3859.f20538.length;
            case 3:
                return ((C3175) abstractC2943).f20538.length;
            case 4:
                return 0;
            case 5:
                C3760 c3760 = (C3760) abstractC2943;
                if (c3760.f20538 == null) {
                    m10163(c3760);
                }
                return c3760.f20538.length;
            case C1339.STRING_SET_FIELD_NUMBER /* 6 */:
                return ((C2105) abstractC2943).f12177.length;
            case C1339.DOUBLE_FIELD_NUMBER /* 7 */:
                C5443 c5443 = (C5443) abstractC2943;
                if (c5443.f20426 == null) {
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    C3692 c3692 = new C3692((ˊᵻ) ((ᵢˇᵭ) this).ᵧᵾˀˈ, byteArrayOutputStream);
                    Iterator it = c5443.iterator();
                    while (it.hasNext()) {
                        c3692.m8285((AbstractC2943) it.next());
                    }
                    c5443.f20426 = byteArrayOutputStream.toByteArray();
                }
                return c5443.f20426.length;
            case C1339.BYTES_FIELD_NUMBER /* 8 */:
                C3440 c3440 = (C3440) abstractC2943;
                if (c3440.f12871 == null) {
                    ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
                    C3692 c36922 = new C3692((ˊᵻ) ((ᵢˇᵭ) this).ᵧᵾˀˈ, byteArrayOutputStream2);
                    Iterator it2 = c3440.iterator();
                    while (it2.hasNext()) {
                        c36922.m8285((AbstractC2943) it2.next());
                    }
                    c3440.f12871 = byteArrayOutputStream2.toByteArray();
                }
                return c3440.f12871.length;
            default:
                C3647 c3647 = (C3647) abstractC2943;
                if (c3647.f13557 == null) {
                    m10164(c3647);
                }
                return c3647.f13557.length;
        }
    }
}
