package kotlin.reflect.w.internal.y0.g;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import kotlin.reflect.w.internal.y0.i.a;
import kotlin.reflect.w.internal.y0.i.c;
import kotlin.reflect.w.internal.y0.i.d;
import kotlin.reflect.w.internal.y0.i.e;
import kotlin.reflect.w.internal.y0.i.f;
import kotlin.reflect.w.internal.y0.i.h;
import kotlin.reflect.w.internal.y0.i.j;
import kotlin.reflect.w.internal.y0.i.p;
import kotlin.reflect.w.internal.y0.i.q;
import kotlin.reflect.w.internal.y0.i.r;
import kotlin.reflect.w.internal.y0.i.v;

/* JADX INFO: loaded from: classes2.dex */
public final class w extends h implements q {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final w f8118f;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static r<w> f8119m = new a();

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final c f8120n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public List<v> f8121o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public byte f8122p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int f8123q;

    public static class a extends kotlin.reflect.w.internal.y0.i.b<w> {
        @Override // kotlin.reflect.w.internal.y0.i.r
        public Object a(d dVar, f fVar) {
            return new w(dVar, fVar, null);
        }
    }

    public static final class b extends h.b<w, b> implements q {

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        public int f8124m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        public List<v> f8125n = Collections.emptyList();

        @Override // r.i0.w.b.y0.i.p.a
        public p a() {
            w wVarM = m();
            if (wVarM.i()) {
                return wVarM;
            }
            throw new v();
        }

        @Override // r.i0.w.b.y0.i.h.b
        public Object clone() {
            b bVar = new b();
            bVar.n(m());
            return bVar;
        }

        @Override // kotlin.reflect.w.internal.y0.i.a.AbstractC0155a, r.i0.w.b.y0.i.p.a
        public /* bridge */ /* synthetic */ p.a h(d dVar, f fVar) throws Throwable {
            o(dVar, fVar);
            return this;
        }

        @Override // kotlin.reflect.w.internal.y0.i.a.AbstractC0155a
        /* JADX INFO: renamed from: j */
        public /* bridge */ /* synthetic */ a.AbstractC0155a h(d dVar, f fVar) throws Throwable {
            o(dVar, fVar);
            return this;
        }

        @Override // r.i0.w.b.y0.i.h.b
        /* JADX INFO: renamed from: k */
        public h.b clone() {
            b bVar = new b();
            bVar.n(m());
            return bVar;
        }

        @Override // r.i0.w.b.y0.i.h.b
        public /* bridge */ /* synthetic */ h.b l(h hVar) {
            n((w) hVar);
            return this;
        }

        public w m() {
            w wVar = new w(this, null);
            if ((this.f8124m & 1) == 1) {
                this.f8125n = Collections.unmodifiableList(this.f8125n);
                this.f8124m &= -2;
            }
            wVar.f8121o = this.f8125n;
            return wVar;
        }

        public b n(w wVar) {
            if (wVar == w.f8118f) {
                return this;
            }
            if (!wVar.f8121o.isEmpty()) {
                if (this.f8125n.isEmpty()) {
                    this.f8125n = wVar.f8121o;
                    this.f8124m &= -2;
                } else {
                    if ((this.f8124m & 1) != 1) {
                        this.f8125n = new ArrayList(this.f8125n);
                        this.f8124m |= 1;
                    }
                    this.f8125n.addAll(wVar.f8121o);
                }
            }
            this.f8259f = this.f8259f.b(wVar.f8120n);
            return this;
        }

        /* JADX WARN: Removed duplicated region for block: B:15:0x001b  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public r.i0.w.b.y0.g.w.b o(kotlin.reflect.w.internal.y0.i.d r3, kotlin.reflect.w.internal.y0.i.f r4) throws java.lang.Throwable {
            /*
                r2 = this;
                r0 = 0
                r.i0.w.b.y0.i.r<r.i0.w.b.y0.g.w> r1 = kotlin.reflect.w.internal.y0.g.w.f8119m     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                java.lang.Object r3 = r1.a(r3, r4)     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                r.i0.w.b.y0.g.w r3 = (kotlin.reflect.w.internal.y0.g.w) r3     // Catch: java.lang.Throwable -> Lf kotlin.reflect.w.internal.y0.i.j -> L11
                if (r3 == 0) goto Le
                r2.n(r3)
            Le:
                return r2
            Lf:
                r3 = move-exception
                goto L19
            L11:
                r3 = move-exception
                r.i0.w.b.y0.i.p r4 = r3.f8275f     // Catch: java.lang.Throwable -> Lf
                r.i0.w.b.y0.g.w r4 = (kotlin.reflect.w.internal.y0.g.w) r4     // Catch: java.lang.Throwable -> Lf
                throw r3     // Catch: java.lang.Throwable -> L17
            L17:
                r3 = move-exception
                r0 = r4
            L19:
                if (r0 == 0) goto L1e
                r2.n(r0)
            L1e:
                throw r3
            */
            throw new UnsupportedOperationException("Method not decompiled: r.i0.w.b.y0.g.w.b.o(r.i0.w.b.y0.i.d, r.i0.w.b.y0.i.f):r.i0.w.b.y0.g.w$b");
        }
    }

    static {
        w wVar = new w();
        f8118f = wVar;
        wVar.f8121o = Collections.emptyList();
    }

    public w() {
        this.f8122p = (byte) -1;
        this.f8123q = -1;
        this.f8120n = c.f8234f;
    }

    public w(d dVar, f fVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        this.f8122p = (byte) -1;
        this.f8123q = -1;
        this.f8121o = Collections.emptyList();
        c.b bVarN = c.n();
        e eVarK = e.k(bVarN, 1);
        boolean z2 = false;
        boolean z3 = false;
        while (!z2) {
            try {
                try {
                    int iO = dVar.o();
                    if (iO != 0) {
                        if (iO == 10) {
                            if (!(z3 & true)) {
                                this.f8121o = new ArrayList();
                                z3 |= true;
                            }
                            this.f8121o.add((v) dVar.h(v.f8090m, fVar));
                        } else if (!dVar.r(iO, eVarK)) {
                        }
                    }
                    z2 = true;
                } catch (j e2) {
                    e2.f8275f = this;
                    throw e2;
                } catch (IOException e3) {
                    j jVar = new j(e3.getMessage());
                    jVar.f8275f = this;
                    throw jVar;
                }
            } catch (Throwable th) {
                if (z3 & true) {
                    this.f8121o = Collections.unmodifiableList(this.f8121o);
                }
                try {
                    eVarK.j();
                } catch (IOException unused) {
                } catch (Throwable th2) {
                    this.f8120n = bVarN.d();
                    throw th2;
                }
                this.f8120n = bVarN.d();
                throw th;
            }
        }
        if (z3 & true) {
            this.f8121o = Collections.unmodifiableList(this.f8121o);
        }
        try {
            eVarK.j();
        } catch (IOException unused2) {
        } catch (Throwable th3) {
            this.f8120n = bVarN.d();
            throw th3;
        }
        this.f8120n = bVarN.d();
    }

    public static b k(w wVar) {
        b bVar = new b();
        bVar.n(wVar);
        return bVar;
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public p.a c() {
        return k(this);
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public void d(e eVar) throws IOException {
        f();
        for (int i2 = 0; i2 < this.f8121o.size(); i2++) {
            eVar.r(1, this.f8121o.get(i2));
        }
        eVar.u(this.f8120n);
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public int f() {
        int i2 = this.f8123q;
        if (i2 != -1) {
            return i2;
        }
        int iE = 0;
        for (int i3 = 0; i3 < this.f8121o.size(); i3++) {
            iE += e.e(1, this.f8121o.get(i3));
        }
        int size = this.f8120n.size() + iE;
        this.f8123q = size;
        return size;
    }

    @Override // kotlin.reflect.w.internal.y0.i.p
    public p.a g() {
        return new b();
    }

    @Override // kotlin.reflect.w.internal.y0.i.q
    public final boolean i() {
        byte b2 = this.f8122p;
        if (b2 == 1) {
            return true;
        }
        if (b2 == 0) {
            return false;
        }
        this.f8122p = (byte) 1;
        return true;
    }

    public b l() {
        return k(this);
    }

    public w(h.b bVar, kotlin.reflect.w.internal.y0.g.a aVar) {
        super(bVar);
        this.f8122p = (byte) -1;
        this.f8123q = -1;
        this.f8120n = bVar.f8259f;
    }
}
