package v;

/* JADX INFO: loaded from: classes.dex */
public final class f {

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public c f17942d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public c f17943e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public c f17944f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public c f17945g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f17946h;
    public int i;

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

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

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ g f17955r;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public d f17940b = null;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f17941c = 0;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f17949l = 0;

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public int f17951n = 0;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f17952o = 0;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f17953p = 0;

    public f(g gVar, int i, c cVar, c cVar2, c cVar3, c cVar4, int i5) {
        this.f17955r = gVar;
        this.f17946h = 0;
        this.i = 0;
        this.f17947j = 0;
        this.f17948k = 0;
        this.f17954q = 0;
        this.f17939a = i;
        this.f17942d = cVar;
        this.f17943e = cVar2;
        this.f17944f = cVar3;
        this.f17945g = cVar4;
        this.f17946h = gVar.f17974j0;
        this.i = gVar.f17970f0;
        this.f17947j = gVar.f17975k0;
        this.f17948k = gVar.f17971g0;
        this.f17954q = i5;
    }

    public final void a(d dVar) {
        int i = this.f17939a;
        g gVar = this.f17955r;
        if (i == 0) {
            int iD = gVar.D(dVar, this.f17954q);
            if (dVar.f17902c0[0] == 3) {
                this.f17953p++;
                iD = 0;
            }
            this.f17949l = iD + (dVar.f17893V != 8 ? gVar.f17958C0 : 0) + this.f17949l;
            int iC = gVar.C(dVar, this.f17954q);
            if (this.f17940b == null || this.f17941c < iC) {
                this.f17940b = dVar;
                this.f17941c = iC;
                this.f17950m = iC;
            }
        } else {
            int iD2 = gVar.D(dVar, this.f17954q);
            int iC2 = gVar.C(dVar, this.f17954q);
            if (dVar.f17902c0[1] == 3) {
                this.f17953p++;
                iC2 = 0;
            }
            this.f17950m = iC2 + (dVar.f17893V != 8 ? gVar.f17959D0 : 0) + this.f17950m;
            if (this.f17940b == null || this.f17941c < iD2) {
                this.f17940b = dVar;
                this.f17941c = iD2;
                this.f17949l = iD2;
            }
        }
        this.f17952o++;
    }

    public final void b(int i, boolean z8, boolean z9) {
        g gVar;
        int i5;
        d dVar;
        char c3;
        int i8;
        int i9;
        int i10;
        int i11;
        int i12 = this.f17952o;
        int i13 = 0;
        while (true) {
            gVar = this.f17955r;
            if (i13 >= i12 || (i11 = this.f17951n + i13) >= gVar.f17969O0) {
                break;
            }
            d dVar2 = gVar.f17968N0[i11];
            if (dVar2 != null) {
                dVar2.t();
            }
            i13++;
        }
        if (i12 == 0 || this.f17940b == null) {
            return;
        }
        boolean z10 = z9 && i == 0;
        int i14 = -1;
        int i15 = -1;
        for (int i16 = 0; i16 < i12; i16++) {
            int i17 = this.f17951n + (z8 ? (i12 - 1) - i16 : i16);
            if (i17 >= gVar.f17969O0) {
                break;
            }
            if (gVar.f17968N0[i17].f17893V == 0) {
                if (i14 == -1) {
                    i14 = i16;
                }
                i15 = i16;
            }
        }
        if (this.f17939a != 0) {
            d dVar3 = this.f17940b;
            dVar3.X = gVar.q0;
            int i18 = this.f17946h;
            if (i > 0) {
                i18 += gVar.f17958C0;
            }
            c cVar = dVar3.f17922x;
            c cVar2 = dVar3.f17924z;
            if (z8) {
                cVar2.a(this.f17944f, i18);
                if (z9) {
                    cVar.a(this.f17942d, this.f17947j);
                }
                if (i > 0) {
                    this.f17944f.f17868b.f17922x.a(cVar2, 0);
                }
            } else {
                cVar.a(this.f17942d, i18);
                if (z9) {
                    cVar2.a(this.f17944f, this.f17947j);
                }
                if (i > 0) {
                    this.f17942d.f17868b.f17924z.a(cVar, 0);
                }
            }
            int i19 = 0;
            d dVar4 = null;
            while (i19 < i12) {
                int i20 = this.f17951n + i19;
                if (i20 >= gVar.f17969O0) {
                    return;
                }
                d dVar5 = gVar.f17968N0[i20];
                if (i19 == 0) {
                    dVar5.e(dVar5.f17923y, this.f17943e, this.i);
                    int i21 = gVar.f17981r0;
                    float f3 = gVar.f17987x0;
                    if (this.f17951n == 0) {
                        int i22 = gVar.f17983t0;
                        i5 = -1;
                        if (i22 != -1) {
                            f3 = gVar.f17989z0;
                        }
                        i21 = i22;
                        dVar5.f17895Y = i21;
                        dVar5.f17891T = f3;
                    } else {
                        i5 = -1;
                    }
                    if (z9 && (i22 = gVar.f17985v0) != i5) {
                        f3 = gVar.f17957B0;
                        i21 = i22;
                    }
                    dVar5.f17895Y = i21;
                    dVar5.f17891T = f3;
                }
                if (i19 == i12 - 1) {
                    dVar5.e(dVar5.f17874A, this.f17945g, this.f17948k);
                }
                if (dVar4 != null) {
                    c cVar3 = dVar5.f17923y;
                    int i23 = gVar.f17959D0;
                    c cVar4 = dVar4.f17874A;
                    cVar3.a(cVar4, i23);
                    c cVar5 = dVar5.f17923y;
                    if (i19 == i14) {
                        int i24 = this.i;
                        if (cVar5.f()) {
                            cVar5.f17872f = i24;
                        }
                    }
                    cVar4.a(cVar5, 0);
                    if (i19 == i15 + 1) {
                        int i25 = this.f17948k;
                        if (cVar4.f()) {
                            cVar4.f17872f = i25;
                        }
                    }
                }
                if (dVar5 != dVar3) {
                    if (z8) {
                        int i26 = gVar.f17960E0;
                        if (i26 == 0) {
                            dVar5.f17924z.a(cVar2, 0);
                        } else if (i26 == 1) {
                            dVar5.f17922x.a(cVar, 0);
                        } else if (i26 == 2) {
                            dVar5.f17922x.a(cVar, 0);
                            dVar5.f17924z.a(cVar2, 0);
                        }
                    } else {
                        int i27 = gVar.f17960E0;
                        if (i27 == 0) {
                            dVar5.f17922x.a(cVar, 0);
                        } else if (i27 == 1) {
                            dVar5.f17924z.a(cVar2, 0);
                        } else if (i27 == 2) {
                            if (z10) {
                                dVar5.f17922x.a(this.f17942d, this.f17946h);
                                dVar5.f17924z.a(this.f17944f, this.f17947j);
                            } else {
                                dVar5.f17922x.a(cVar, 0);
                                dVar5.f17924z.a(cVar2, 0);
                            }
                        }
                    }
                }
                i19++;
                dVar4 = dVar5;
            }
            return;
        }
        d dVar6 = this.f17940b;
        dVar6.f17895Y = gVar.f17981r0;
        int i28 = this.i;
        if (i > 0) {
            i28 += gVar.f17959D0;
        }
        c cVar6 = this.f17943e;
        c cVar7 = dVar6.f17923y;
        cVar7.a(cVar6, i28);
        c cVar8 = dVar6.f17874A;
        if (z9) {
            cVar8.a(this.f17945g, this.f17948k);
        }
        if (i > 0) {
            this.f17943e.f17868b.f17874A.a(cVar7, 0);
        }
        if (gVar.f17961F0 != 3 || dVar6.f17921w) {
            dVar = dVar6;
        } else {
            for (int i29 = 0; i29 < i12; i29++) {
                int i30 = this.f17951n + (z8 ? (i12 - 1) - i29 : i29);
                if (i30 >= gVar.f17969O0) {
                    break;
                }
                dVar = gVar.f17968N0[i30];
                if (dVar.f17921w) {
                    break;
                }
            }
            dVar = dVar6;
        }
        int i31 = 0;
        d dVar7 = null;
        while (i31 < i12) {
            int i32 = z8 ? (i12 - 1) - i31 : i31;
            int i33 = this.f17951n + i32;
            if (i33 >= gVar.f17969O0) {
                return;
            }
            d dVar8 = gVar.f17968N0[i33];
            if (i31 == 0) {
                dVar8.e(dVar8.f17922x, this.f17942d, this.f17946h);
            }
            if (i32 == 0) {
                int i34 = gVar.q0;
                float f7 = gVar.f17986w0;
                if (this.f17951n == 0) {
                    int i35 = gVar.f17982s0;
                    i8 = i34;
                    i9 = -1;
                    if (i35 != -1) {
                        f7 = gVar.f17988y0;
                    }
                    i10 = i35;
                    dVar8.X = i10;
                    dVar8.f17890S = f7;
                } else {
                    i8 = i34;
                    i9 = -1;
                }
                if (!z9 || (i35 = gVar.f17984u0) == i9) {
                    i10 = i8;
                    dVar8.X = i10;
                    dVar8.f17890S = f7;
                } else {
                    f7 = gVar.f17956A0;
                    i10 = i35;
                    dVar8.X = i10;
                    dVar8.f17890S = f7;
                }
            }
            if (i31 == i12 - 1) {
                dVar8.e(dVar8.f17924z, this.f17944f, this.f17947j);
            }
            if (dVar7 != null) {
                c cVar9 = dVar8.f17922x;
                int i36 = gVar.f17958C0;
                c cVar10 = dVar7.f17924z;
                cVar9.a(cVar10, i36);
                c cVar11 = dVar8.f17922x;
                if (i31 == i14) {
                    int i37 = this.f17946h;
                    if (cVar11.f()) {
                        cVar11.f17872f = i37;
                    }
                }
                cVar10.a(cVar11, 0);
                if (i31 == i15 + 1) {
                    int i38 = this.f17947j;
                    if (cVar10.f()) {
                        cVar10.f17872f = i38;
                    }
                }
            }
            if (dVar8 != dVar6) {
                int i39 = gVar.f17961F0;
                c3 = 3;
                if (i39 == 3 && dVar.f17921w && dVar8 != dVar && dVar8.f17921w) {
                    dVar8.f17875B.a(dVar.f17875B, 0);
                } else if (i39 == 0) {
                    dVar8.f17923y.a(cVar7, 0);
                } else if (i39 == 1) {
                    dVar8.f17874A.a(cVar8, 0);
                } else if (z10) {
                    dVar8.f17923y.a(this.f17943e, this.i);
                    dVar8.f17874A.a(this.f17945g, this.f17948k);
                } else {
                    dVar8.f17923y.a(cVar7, 0);
                    dVar8.f17874A.a(cVar8, 0);
                }
            } else {
                c3 = 3;
            }
            i31++;
            dVar7 = dVar8;
        }
    }

    public final int c() {
        return this.f17939a == 1 ? this.f17950m - this.f17955r.f17959D0 : this.f17950m;
    }

    public final int d() {
        return this.f17939a == 0 ? this.f17949l - this.f17955r.f17958C0 : this.f17949l;
    }

    public final void e(int i) {
        g gVar;
        int i5;
        int i8 = this.f17953p;
        if (i8 == 0) {
            return;
        }
        int i9 = this.f17952o;
        int i10 = i / i8;
        int i11 = 0;
        while (true) {
            gVar = this.f17955r;
            if (i11 >= i9 || (i5 = this.f17951n + i11) >= gVar.f17969O0) {
                break;
            }
            d dVar = gVar.f17968N0[i5];
            if (this.f17939a == 0) {
                if (dVar != null) {
                    int[] iArr = dVar.f17902c0;
                    if (iArr[0] == 3 && dVar.f17908j == 0) {
                        gVar.E(1, i10, iArr[1], dVar.i(), dVar);
                    }
                }
            } else if (dVar != null) {
                int[] iArr2 = dVar.f17902c0;
                if (iArr2[1] == 3 && dVar.f17909k == 0) {
                    int i12 = iArr2[0];
                    int i13 = i10;
                    gVar.E(i12, dVar.l(), 1, i13, dVar);
                    i10 = i13;
                }
            }
            i11++;
        }
        this.f17949l = 0;
        this.f17950m = 0;
        this.f17940b = null;
        this.f17941c = 0;
        int i14 = this.f17952o;
        for (int i15 = 0; i15 < i14; i15++) {
            int i16 = this.f17951n + i15;
            if (i16 >= gVar.f17969O0) {
                return;
            }
            d dVar2 = gVar.f17968N0[i16];
            if (this.f17939a == 0) {
                int iL = dVar2.l();
                int i17 = gVar.f17958C0;
                if (dVar2.f17893V == 8) {
                    i17 = 0;
                }
                this.f17949l = iL + i17 + this.f17949l;
                int iC = gVar.C(dVar2, this.f17954q);
                if (this.f17940b == null || this.f17941c < iC) {
                    this.f17940b = dVar2;
                    this.f17941c = iC;
                    this.f17950m = iC;
                }
            } else {
                int iD = gVar.D(dVar2, this.f17954q);
                int iC2 = gVar.C(dVar2, this.f17954q);
                int i18 = gVar.f17959D0;
                if (dVar2.f17893V == 8) {
                    i18 = 0;
                }
                this.f17950m = iC2 + i18 + this.f17950m;
                if (this.f17940b == null || this.f17941c < iD) {
                    this.f17940b = dVar2;
                    this.f17941c = iD;
                    this.f17949l = iD;
                }
            }
        }
    }

    public final void f(int i, c cVar, c cVar2, c cVar3, c cVar4, int i5, int i8, int i9, int i10, int i11) {
        this.f17939a = i;
        this.f17942d = cVar;
        this.f17943e = cVar2;
        this.f17944f = cVar3;
        this.f17945g = cVar4;
        this.f17946h = i5;
        this.i = i8;
        this.f17947j = i9;
        this.f17948k = i10;
        this.f17954q = i11;
    }
}
