package o;

import android.graphics.RectF;
import android.text.Layout;
import java.util.ArrayList;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Ne0 {
    public final Me0 a;
    public final C2331rQ b;
    public final long c;
    public final float d;
    public final float e;
    public final ArrayList f;

    public Ne0(Me0 me0, C2331rQ c2331rQ, long j) {
        this.a = me0;
        this.b = c2331rQ;
        this.c = j;
        ArrayList arrayList = c2331rQ.h;
        float fD = 0.0f;
        this.d = arrayList.isEmpty() ? 0.0f : ((BV) arrayList.get(0)).a.d.d(0);
        if (!arrayList.isEmpty()) {
            BV bv = (BV) AbstractC3117zi.j0(arrayList);
            fD = bv.a.d.d(r4.g - 1) + bv.f;
        }
        this.e = fD;
        this.f = c2331rQ.g;
    }

    public static int d(Ne0 ne0, int i) {
        return ne0.b.c(i, false);
    }

    public final int a(int i) {
        C2331rQ c2331rQ = this.b;
        ArrayList arrayList = c2331rQ.h;
        c2331rQ.k(i);
        BV bv = (BV) arrayList.get(i == ((C0977d7) c2331rQ.a.f292o).m.length() ? AbstractC0008Ai.R(arrayList) : AbstractC0249Jp.F(i, arrayList));
        return bv.a.d.f.isRtlCharAt(bv.d(i)) ? 2 : 1;
    }

    public final T00 b(int i) {
        float fI;
        float fI2;
        float fH;
        float fH2;
        C2331rQ c2331rQ = this.b;
        c2331rQ.j(i);
        ArrayList arrayList = c2331rQ.h;
        BV bv = (BV) arrayList.get(AbstractC0249Jp.F(i, arrayList));
        J4 j4 = bv.a;
        int iD = bv.d(i);
        CharSequence charSequence = j4.e;
        if (iD < 0 || iD >= charSequence.length()) {
            StringBuilder sbO = AbstractC0126Ew.o(iD, "offset(", ") is out of bounds [0,");
            sbO.append(charSequence.length());
            sbO.append(')');
            AbstractC2228qH.a(sbO.toString());
        }
        Le0 le0 = j4.d;
        Layout layout = le0.f;
        int lineForOffset = layout.getLineForOffset(iD);
        float fG = le0.g(lineForOffset);
        float fE = le0.e(lineForOffset);
        boolean z = layout.getParagraphDirection(lineForOffset) == 1;
        boolean zIsRtlCharAt = layout.isRtlCharAt(iD);
        if (!z || zIsRtlCharAt) {
            if (z && zIsRtlCharAt) {
                fH = le0.i(iD, false);
                fH2 = le0.i(iD + 1, true);
            } else if (zIsRtlCharAt) {
                fH = le0.h(iD, false);
                fH2 = le0.h(iD + 1, true);
            } else {
                fI = le0.i(iD, false);
                fI2 = le0.i(iD + 1, true);
            }
            float f = fH;
            fI = fH2;
            fI2 = f;
        } else {
            fI = le0.h(iD, false);
            fI2 = le0.h(iD + 1, true);
        }
        RectF rectF = new RectF(fI, fG, fI2, fE);
        return bv.a(new T00(rectF.left, rectF.top, rectF.right, rectF.bottom));
    }

    public final T00 c(int i) {
        C2331rQ c2331rQ = this.b;
        ArrayList arrayList = c2331rQ.h;
        c2331rQ.k(i);
        BV bv = (BV) arrayList.get(i == ((C0977d7) c2331rQ.a.f292o).m.length() ? AbstractC0008Ai.R(arrayList) : AbstractC0249Jp.F(i, arrayList));
        J4 j4 = bv.a;
        int iD = bv.d(i);
        CharSequence charSequence = j4.e;
        Le0 le0 = j4.d;
        if (iD < 0 || iD > charSequence.length()) {
            StringBuilder sbO = AbstractC0126Ew.o(iD, "offset(", ") is out of bounds [0,");
            sbO.append(charSequence.length());
            sbO.append(']');
            AbstractC2228qH.a(sbO.toString());
        }
        float fH = le0.h(iD, false);
        int lineForOffset = le0.f.getLineForOffset(iD);
        return bv.a(new T00(fH, le0.g(lineForOffset), fH, le0.e(lineForOffset)));
    }

    public final float e(int i) {
        C2331rQ c2331rQ = this.b;
        c2331rQ.l(i);
        ArrayList arrayList = c2331rQ.h;
        BV bv = (BV) arrayList.get(AbstractC0249Jp.G(i, arrayList));
        J4 j4 = bv.a;
        int i2 = i - bv.d;
        Le0 le0 = j4.d;
        return le0.f.getLineLeft(i2) + (i2 == le0.g + (-1) ? le0.j : 0.0f);
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof Ne0)) {
            return false;
        }
        Ne0 ne0 = (Ne0) obj;
        return F3.c(this.a, ne0.a) && this.b.equals(ne0.b) && C1470iI.a(this.c, ne0.c) && this.d == ne0.d && this.e == ne0.e && F3.c(this.f, ne0.f);
    }

    public final float f(int i) {
        C2331rQ c2331rQ = this.b;
        c2331rQ.l(i);
        ArrayList arrayList = c2331rQ.h;
        BV bv = (BV) arrayList.get(AbstractC0249Jp.G(i, arrayList));
        J4 j4 = bv.a;
        int i2 = i - bv.d;
        Le0 le0 = j4.d;
        return le0.f.getLineRight(i2) + (i2 == le0.g + (-1) ? le0.k : 0.0f);
    }

    public final int g(int i) {
        C2331rQ c2331rQ = this.b;
        c2331rQ.l(i);
        ArrayList arrayList = c2331rQ.h;
        BV bv = (BV) arrayList.get(AbstractC0249Jp.G(i, arrayList));
        J4 j4 = bv.a;
        return j4.d.f.getLineStart(i - bv.d) + bv.b;
    }

    public final int h(int i) {
        C2331rQ c2331rQ = this.b;
        ArrayList arrayList = c2331rQ.h;
        c2331rQ.k(i);
        BV bv = (BV) arrayList.get(i == ((C0977d7) c2331rQ.a.f292o).m.length() ? AbstractC0008Ai.R(arrayList) : AbstractC0249Jp.F(i, arrayList));
        J4 j4 = bv.a;
        int iD = bv.d(i);
        Le0 le0 = j4.d;
        return le0.f.getParagraphDirection(le0.f.getLineForOffset(iD)) == 1 ? 1 : 2;
    }

    public final int hashCode() {
        return this.f.hashCode() + AbstractC0126Ew.d(this.e, AbstractC0126Ew.d(this.d, AbstractC0126Ew.f((this.b.hashCode() + (this.a.hashCode() * 31)) * 31, 31, this.c), 31), 31);
    }

    public final O4 i(int i, int i2) {
        C2331rQ c2331rQ = this.b;
        C0977d7 c0977d7 = (C0977d7) c2331rQ.a.f292o;
        if (i < 0 || i > i2 || i2 > c0977d7.m.length()) {
            AbstractC2228qH.a("Start(" + i + ") or End(" + i2 + ") is out of range [0.." + c0977d7.m.length() + "), or start > end!");
        }
        if (i == i2) {
            return Q4.a();
        }
        O4 o4A = Q4.a();
        AbstractC0249Jp.I(c2331rQ.h, AbstractC2378rs0.u(i, i2), new PH(o4A, i, i2, 3));
        return o4A;
    }

    public final long j(int i) {
        int iJ;
        int i2;
        int i3;
        C2331rQ c2331rQ = this.b;
        ArrayList arrayList = c2331rQ.h;
        c2331rQ.k(i);
        BV bv = (BV) arrayList.get(i == ((C0977d7) c2331rQ.a.f292o).m.length() ? AbstractC0008Ai.R(arrayList) : AbstractC0249Jp.F(i, arrayList));
        J4 j4 = bv.a;
        int iD = bv.d(i);
        C0862bw c0862bwJ = j4.d.j();
        if (c0862bwJ.h(c0862bwJ.j(iD))) {
            c0862bwJ.a(iD);
            iJ = iD;
            while (iJ != -1 && (!c0862bwJ.h(iJ) || c0862bwJ.d(iJ))) {
                iJ = c0862bwJ.j(iJ);
            }
        } else {
            c0862bwJ.a(iD);
            iJ = c0862bwJ.g(iD) ? (!c0862bwJ.e(iD) || c0862bwJ.c(iD)) ? c0862bwJ.j(iD) : iD : c0862bwJ.c(iD) ? c0862bwJ.j(iD) : -1;
        }
        if (iJ == -1) {
            iJ = iD;
        }
        if (c0862bwJ.d(c0862bwJ.i(iD))) {
            c0862bwJ.a(iD);
            i2 = iD;
            while (i2 != -1 && (c0862bwJ.h(i2) || !c0862bwJ.d(i2))) {
                i2 = c0862bwJ.i(i2);
            }
        } else {
            c0862bwJ.a(iD);
            if (c0862bwJ.c(iD)) {
                if (!c0862bwJ.e(iD) || c0862bwJ.g(iD)) {
                    i3 = c0862bwJ.i(iD);
                    i2 = i3;
                } else {
                    i2 = iD;
                }
            } else if (c0862bwJ.g(iD)) {
                i3 = c0862bwJ.i(iD);
                i2 = i3;
            } else {
                i2 = -1;
            }
        }
        if (i2 != -1) {
            iD = i2;
        }
        return bv.b(false, AbstractC2378rs0.u(iJ, iD));
    }

    public final String toString() {
        return "TextLayoutResult(layoutInput=" + this.a + ", multiParagraph=" + this.b + ", size=" + ((Object) C1470iI.b(this.c)) + ", firstBaseline=" + this.d + ", lastBaseline=" + this.e + ", placeholderRects=" + this.f + ')';
    }
}
