package T;

import B.V;
import G0.InterfaceC0279y;
import G0.K;
import J0.j1;
import K.C0464l0;
import K.S0;
import T0.C0596g;
import T0.C0604o;
import T0.J;
import T0.L;
import T0.N;
import V.i0;
import Z0.C0860a;
import Z0.C0864e;
import Z0.InterfaceC0866g;
import android.graphics.PointF;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.HandwritingGesture;
import i0.InterfaceC2255s;
import o0.C2631b;
import o0.C2632c;

/* JADX INFO: loaded from: classes.dex */
public abstract class t {
    public static final int a(C0464l0 c0464l0, long j4, j1 j1Var) {
        long jC0;
        int iH;
        S0 s0D = c0464l0.d();
        if (s0D != null) {
            C0604o c0604o = s0D.f3742a.f6472b;
            InterfaceC0279y interfaceC0279yC = c0464l0.c();
            if (interfaceC0279yC != null && (iH = h(c0604o, (jC0 = interfaceC0279yC.c0(j4)), j1Var)) != -1) {
                return c0604o.g(C2631b.a(jC0, (c0604o.b(iH) + c0604o.f(iH)) / 2.0f, 1));
            }
        }
        return -1;
    }

    public static final long b(C0464l0 c0464l0, C2632c c2632c, C2632c c2632c2, int i6) {
        long jI = i(c0464l0, c2632c, i6);
        if (N.c(jI)) {
            return N.f6481b;
        }
        long jI2 = i(c0464l0, c2632c2, i6);
        if (N.c(jI2)) {
            return N.f6481b;
        }
        int i7 = (int) (jI >> 32);
        int i8 = (int) (jI2 & 4294967295L);
        return android.support.v4.media.session.b.g(Math.min(i7, i7), Math.max(i8, i8));
    }

    public static final boolean c(L l, int i6) {
        C0604o c0604o = l.f6472b;
        int iD = c0604o.d(i6);
        return i6 == l.f(iD) || i6 == c0604o.c(iD, false) ? l.g(i6) != l.a(i6) : l.a(i6) != l.a(i6 - 1);
    }

    public static final ExtractedText d(Z0.y yVar) {
        ExtractedText extractedText = new ExtractedText();
        String str = yVar.f9136a.f6510b;
        extractedText.text = str;
        extractedText.startOffset = 0;
        extractedText.partialEndOffset = str.length();
        extractedText.partialStartOffset = -1;
        long j4 = yVar.f9137b;
        extractedText.selectionStart = N.f(j4);
        extractedText.selectionEnd = N.e(j4);
        extractedText.flags = !S4.p.E0(yVar.f9136a.f6510b, '\n') ? 1 : 0;
        return extractedText;
    }

    public static final long e(PointF pointF) {
        float f6 = pointF.x;
        float f7 = pointF.y;
        return (((long) Float.floatToRawIntBits(f6)) << 32) | (((long) Float.floatToRawIntBits(f7)) & 4294967295L);
    }

    public static final boolean f(C2632c c2632c, float f6, float f7) {
        return f6 <= c2632c.f21789c && c2632c.f21787a <= f6 && f7 <= c2632c.f21790d && c2632c.f21788b <= f7;
    }

    public static int g(HandwritingGesture handwritingGesture, V v3) {
        String fallbackText = handwritingGesture.getFallbackText();
        if (fallbackText == null) {
            return 3;
        }
        v3.invoke(new C0860a(fallbackText, 1));
        return 5;
    }

    public static final int h(C0604o c0604o, long j4, j1 j1Var) {
        float fG = j1Var != null ? j1Var.g() : 0.0f;
        int i6 = (int) (4294967295L & j4);
        int iE = c0604o.e(Float.intBitsToFloat(i6));
        if (Float.intBitsToFloat(i6) < c0604o.f(iE) - fG || Float.intBitsToFloat(i6) > c0604o.b(iE) + fG) {
            return -1;
        }
        int i7 = (int) (j4 >> 32);
        if (Float.intBitsToFloat(i7) < (-fG) || Float.intBitsToFloat(i7) > c0604o.f6535d + fG) {
            return -1;
        }
        return iE;
    }

    public static final long i(C0464l0 c0464l0, C2632c c2632c, int i6) {
        K k6 = J.f6460b;
        S0 s0D = c0464l0.d();
        C0604o c0604o = s0D != null ? s0D.f3742a.f6472b : null;
        InterfaceC0279y interfaceC0279yC = c0464l0.c();
        return (c0604o == null || interfaceC0279yC == null) ? N.f6481b : c0604o.h(c2632c.i(interfaceC0279yC.c0(0L)), i6, k6);
    }

    public static final boolean j(int i6) {
        int type = Character.getType(i6);
        return type == 23 || type == 20 || type == 22 || type == 30 || type == 29 || type == 24 || type == 21;
    }

    public static final boolean k(int i6) {
        return Character.isWhitespace(i6) || i6 == 160;
    }

    public static final boolean l(int i6) {
        int type;
        return (!k(i6) || (type = Character.getType(i6)) == 14 || type == 13 || i6 == 10) ? false : true;
    }

    public static final InterfaceC2255s m(InterfaceC2255s interfaceC2255s, e eVar, C0464l0 c0464l0, i0 i0Var) {
        return interfaceC2255s.then(new q(eVar, c0464l0, i0Var));
    }

    public static void n(long j4, C0596g c0596g, boolean z6, V v3) {
        if (z6) {
            int i6 = N.f6482c;
            int iCharCount = (int) (j4 >> 32);
            int iCharCount2 = (int) (j4 & 4294967295L);
            int iCodePointBefore = iCharCount > 0 ? Character.codePointBefore(c0596g, iCharCount) : 10;
            int iCodePointAt = iCharCount2 < c0596g.f6510b.length() ? Character.codePointAt(c0596g, iCharCount2) : 10;
            if (l(iCodePointBefore) && (k(iCodePointAt) || j(iCodePointAt))) {
                do {
                    iCharCount -= Character.charCount(iCodePointBefore);
                    if (iCharCount == 0) {
                        break;
                    } else {
                        iCodePointBefore = Character.codePointBefore(c0596g, iCharCount);
                    }
                } while (l(iCodePointBefore));
                j4 = android.support.v4.media.session.b.g(iCharCount, iCharCount2);
            } else if (l(iCodePointAt) && (k(iCodePointBefore) || j(iCodePointBefore))) {
                do {
                    iCharCount2 += Character.charCount(iCodePointAt);
                    if (iCharCount2 == c0596g.f6510b.length()) {
                        break;
                    } else {
                        iCodePointAt = Character.codePointAt(c0596g, iCharCount2);
                    }
                } while (l(iCodePointAt));
                j4 = android.support.v4.media.session.b.g(iCharCount, iCharCount2);
            }
        }
        int i7 = (int) (4294967295L & j4);
        v3.invoke(new o(new InterfaceC0866g[]{new Z0.x(i7, i7), new C0864e(N.d(j4), 0)}));
    }
}
