package a.i.b.a.c.e.b;

import a.i.b.a.c.e.b.b.a;
import a.i.b.a.c.e.b.b.c;
import a.i.b.a.c.e.b.b.f;
import a.i.b.a.c.g.d;
import a.i.b.a.c.g.d.b;
import a.i.b.a.c.g.e;
import a.i.b.a.c.g.g;
import a.i.b.a.c.g.i;
import a.i.b.a.c.g.k;
import a.i.b.a.c.g.q;
import a.i.b.a.c.g.s;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.ttpic.baseutils.ApiHelper$VERSION_CODES;
import java.io.IOException;

public final class b$e extends i implements f {
    public static s<b$e> BsC = new 1();
    private static final b$e BxP;
    private final d BsB;
    private int BsD;
    private byte BsG;
    private int BsH;
    public a BxQ;
    public c BxR;
    public c BxS;
    public c BxT;

    /* synthetic */ b$e(e eVar, g gVar, byte b) {
        this(eVar, gVar);
    }

    private b$e(i.a aVar) {
        super((byte) 0);
        this.BsG = (byte) -1;
        this.BsH = -1;
        this.BsB = aVar.BsB;
    }

    private b$e() {
        this.BsG = (byte) -1;
        this.BsH = -1;
        this.BsB = d.Bzq;
    }

    public static b$e egV() {
        return BxP;
    }

    private b$e(e eVar, g gVar) {
        AppMethodBeat.i(121229);
        this.BsG = (byte) -1;
        this.BsH = -1;
        ecA();
        b ehS = d.ehS();
        a.i.b.a.c.g.f e = a.i.b.a.c.g.f.e(ehS, 1);
        int i = 0;
        while (i == 0) {
            try {
                int vc = eVar.vc();
                c.a egR;
                switch (vc) {
                    case 0:
                        i = 1;
                        break;
                    case 10:
                        a.a egM;
                        if ((this.BsD & 1) == 1) {
                            egM = this.BxQ.egM();
                        } else {
                            egM = null;
                        }
                        this.BxQ = (a) eVar.a(a.BsC, gVar);
                        if (egM != null) {
                            egM.c(this.BxQ);
                            this.BxQ = egM.egO();
                        }
                        this.BsD |= 1;
                        break;
                    case ApiHelper$VERSION_CODES.JELLY_BEAN_MR2 /*18*/:
                        if ((this.BsD & 2) == 2) {
                            egR = this.BxR.egR();
                        } else {
                            egR = null;
                        }
                        this.BxR = (c) eVar.a(c.BsC, gVar);
                        if (egR != null) {
                            egR.c(this.BxR);
                            this.BxR = egR.egT();
                        }
                        this.BsD |= 2;
                        break;
                    case ApiHelper$VERSION_CODES.O /*26*/:
                        if ((this.BsD & 4) == 4) {
                            egR = this.BxS.egR();
                        } else {
                            egR = null;
                        }
                        this.BxS = (c) eVar.a(c.BsC, gVar);
                        if (egR != null) {
                            egR.c(this.BxS);
                            this.BxS = egR.egT();
                        }
                        this.BsD |= 4;
                        break;
                    case 34:
                        if ((this.BsD & 8) == 8) {
                            egR = this.BxT.egR();
                        } else {
                            egR = null;
                        }
                        this.BxT = (c) eVar.a(c.BsC, gVar);
                        if (egR != null) {
                            egR.c(this.BxT);
                            this.BxT = egR.egT();
                        }
                        this.BsD |= 8;
                        break;
                    default:
                        if (!a(eVar, e, gVar, vc)) {
                            i = 1;
                            break;
                        }
                        break;
                }
            } catch (k e2) {
                e2.BzY = this;
                AppMethodBeat.o(121229);
                throw e2;
            } catch (IOException e3) {
                k kVar = new k(e3.getMessage());
                kVar.BzY = this;
                AppMethodBeat.o(121229);
                throw kVar;
            } catch (Throwable th) {
                try {
                    e.flush();
                    this.BsB = ehS.ehW();
                } catch (IOException e4) {
                    this.BsB = ehS.ehW();
                } catch (Throwable th2) {
                    this.BsB = ehS.ehW();
                    AppMethodBeat.o(121229);
                }
                eio();
                AppMethodBeat.o(121229);
            }
        }
        try {
            e.flush();
            this.BsB = ehS.ehW();
        } catch (IOException e5) {
            this.BsB = ehS.ehW();
        } catch (Throwable th3) {
            this.BsB = ehS.ehW();
            AppMethodBeat.o(121229);
        }
        eio();
        AppMethodBeat.o(121229);
    }

    static {
        AppMethodBeat.i(121235);
        b$e b_e = new b$e();
        BxP = b_e;
        b_e.ecA();
        AppMethodBeat.o(121235);
    }

    public final s<b$e> ecy() {
        return BsC;
    }

    public final boolean egW() {
        return (this.BsD & 1) == 1;
    }

    public final boolean egX() {
        return (this.BsD & 2) == 2;
    }

    public final boolean egY() {
        return (this.BsD & 4) == 4;
    }

    public final boolean egZ() {
        return (this.BsD & 8) == 8;
    }

    private void ecA() {
        AppMethodBeat.i(121230);
        this.BxQ = a.egK();
        this.BxR = c.egQ();
        this.BxS = c.egQ();
        this.BxT = c.egQ();
        AppMethodBeat.o(121230);
    }

    public final boolean isInitialized() {
        byte b = this.BsG;
        if (b == (byte) 1) {
            return true;
        }
        if (b == (byte) 0) {
            return false;
        }
        this.BsG = (byte) 1;
        return true;
    }

    public final void a(a.i.b.a.c.g.f fVar) {
        AppMethodBeat.i(121231);
        vq();
        if ((this.BsD & 1) == 1) {
            fVar.a(1, this.BxQ);
        }
        if ((this.BsD & 2) == 2) {
            fVar.a(2, this.BxR);
        }
        if ((this.BsD & 4) == 4) {
            fVar.a(3, this.BxS);
        }
        if ((this.BsD & 8) == 8) {
            fVar.a(4, this.BxT);
        }
        fVar.d(this.BsB);
        AppMethodBeat.o(121231);
    }

    public final int vq() {
        AppMethodBeat.i(121232);
        int i = this.BsH;
        if (i != -1) {
            AppMethodBeat.o(121232);
            return i;
        }
        i = 0;
        if ((this.BsD & 1) == 1) {
            i = a.i.b.a.c.g.f.c(1, this.BxQ) + 0;
        }
        if ((this.BsD & 2) == 2) {
            i += a.i.b.a.c.g.f.c(2, this.BxR);
        }
        if ((this.BsD & 4) == 4) {
            i += a.i.b.a.c.g.f.c(3, this.BxS);
        }
        if ((this.BsD & 8) == 8) {
            i += a.i.b.a.c.g.f.c(4, this.BxT);
        }
        i += this.BsB.size();
        this.BsH = i;
        AppMethodBeat.o(121232);
        return i;
    }

    public final /* synthetic */ q.a ecC() {
        AppMethodBeat.i(121233);
        a b = a.ehc().b(this);
        AppMethodBeat.o(121233);
        return b;
    }

    public final /* synthetic */ q.a ecD() {
        AppMethodBeat.i(121234);
        a ehc = a.ehc();
        AppMethodBeat.o(121234);
        return ehc;
    }

    public final /* bridge */ /* synthetic */ q ecE() {
        return BxP;
    }
}
