package o;

import java.util.List;
import java.util.regex.Pattern;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class EQ extends AbstractC0752ap {
    public static final C2804wO m;
    public static final C2804wO n;

    /* renamed from: o, reason: collision with root package name */
    public static final byte[] f102o;
    public static final byte[] p;
    public static final byte[] q;
    public final C0135Ff i;
    public final List j;
    public final C2804wO k;
    public long l;

    static {
        Pattern pattern = C2804wO.d;
        m = AbstractC2378rs0.L("multipart/mixed");
        AbstractC2378rs0.L("multipart/alternative");
        AbstractC2378rs0.L("multipart/digest");
        AbstractC2378rs0.L("multipart/parallel");
        n = AbstractC2378rs0.L("multipart/form-data");
        f102o = new byte[]{58, 32};
        p = new byte[]{13, 10};
        q = new byte[]{45, 45};
    }

    public EQ(C0135Ff c0135Ff, C2804wO c2804wO, List list) {
        this.i = c0135Ff;
        this.j = list;
        Pattern pattern = C2804wO.d;
        this.k = AbstractC2378rs0.L(c2804wO + "; boundary=" + c0135Ff.n());
        this.l = -1L;
    }

    @Override // o.AbstractC0752ap
    public final C2804wO A() {
        return this.k;
    }

    @Override // o.AbstractC0752ap
    public final void k0(InterfaceC1592jf interfaceC1592jf) {
        n0(interfaceC1592jf, false);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final long n0(InterfaceC1592jf interfaceC1592jf, boolean z) {
        C0732af c0732af;
        InterfaceC1592jf c0732af2;
        if (z) {
            c0732af2 = new C0732af();
            c0732af = c0732af2;
        } else {
            c0732af = 0;
            c0732af2 = interfaceC1592jf;
        }
        List list = this.j;
        int size = list.size();
        long j = 0;
        int i = 0;
        while (true) {
            C0135Ff c0135Ff = this.i;
            byte[] bArr = q;
            byte[] bArr2 = p;
            if (i >= size) {
                c0732af2.write(bArr);
                c0732af2.o(c0135Ff);
                c0732af2.write(bArr);
                c0732af2.write(bArr2);
                if (!z) {
                    return j;
                }
                long j2 = j + c0732af.m;
                c0732af.b();
                return j2;
            }
            DQ dq = (DQ) list.get(i);
            LE le = dq.a;
            AbstractC0752ap abstractC0752ap = dq.b;
            c0732af2.write(bArr);
            c0732af2.o(c0135Ff);
            c0732af2.write(bArr2);
            int size2 = le.size();
            for (int i2 = 0; i2 < size2; i2++) {
                c0732af2.J(le.b(i2)).write(f102o).J(le.d(i2)).write(bArr2);
            }
            C2804wO c2804wOA = abstractC0752ap.A();
            if (c2804wOA != null) {
                c0732af2.J("Content-Type: ").J(c2804wOA.a).write(bArr2);
            }
            long jZ = abstractC0752ap.z();
            if (jZ != -1) {
                c0732af2.J("Content-Length: ").K(jZ).write(bArr2);
            } else if (z) {
                c0732af.b();
                return -1L;
            }
            c0732af2.write(bArr2);
            if (z) {
                j += jZ;
            } else {
                abstractC0752ap.k0(c0732af2);
            }
            c0732af2.write(bArr2);
            i++;
        }
    }

    @Override // o.AbstractC0752ap
    public final long z() {
        long j = this.l;
        if (j != -1) {
            return j;
        }
        long jN0 = n0(null, true);
        this.l = jN0;
        return jN0;
    }
}
