package o;

import android.graphics.Rect;
import android.os.LocaleList;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Locale;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class NK {
    public final View a;
    public final DH b;
    public MK e;
    public C2066oe0 f;
    public Qj0 g;
    public Rect l;
    public final IK m;
    public OC c = new C1072e7(21);
    public OC d = new C1072e7(22);
    public C2730ve0 h = new C2730ve0("", 4, Ue0.b);
    public HG i = HG.g;
    public final ArrayList j = new ArrayList();
    public final Object k = AbstractC2001nt0.y(3, new C1164f5(8, this));

    public NK(View view, C2873x4 c2873x4, DH dh) {
        this.a = view;
        this.b = dh;
        this.m = new IK(c2873x4, dh);
    }

    public final R00 a(EditorInfo editorInfo) {
        int i;
        int i2;
        C2730ve0 c2730ve0 = this.h;
        String str = c2730ve0.a.m;
        long j = c2730ve0.b;
        HG hg = this.i;
        int i3 = hg.e;
        int i4 = hg.d;
        boolean z = hg.a;
        if (i3 == 1) {
            i = z ? 6 : 0;
        } else if (i3 == 0) {
            i = 1;
        } else if (i3 == 2) {
            i = 2;
        } else if (i3 == 6) {
            i = 5;
        } else if (i3 == 5) {
            i = 7;
        } else if (i3 == 3) {
            i = 3;
        } else if (i3 == 4) {
            i = 4;
        } else {
            if (i3 != 7) {
                throw new IllegalStateException("invalid ImeAction");
            }
        }
        editorInfo.imeOptions = i;
        C2138pM c2138pM = hg.f;
        if (F3.c(c2138pM, C2138pM.n)) {
            editorInfo.hintLocales = null;
        } else {
            ArrayList arrayList = new ArrayList(AbstractC0034Bi.W(c2138pM, 10));
            Iterator it = c2138pM.l.iterator();
            while (it.hasNext()) {
                arrayList.add(((C2043oM) it.next()).a);
            }
            Locale[] localeArr = (Locale[]) arrayList.toArray(new Locale[0]);
            editorInfo.hintLocales = new LocaleList((Locale[]) Arrays.copyOf(localeArr, localeArr.length));
        }
        if (i4 == 1) {
            i2 = 1;
        } else if (i4 == 2) {
            editorInfo.imeOptions |= Integer.MIN_VALUE;
            i2 = 1;
        } else if (i4 == 3) {
            i2 = 2;
        } else if (i4 == 4) {
            i2 = 3;
        } else if (i4 == 5) {
            i2 = 17;
        } else if (i4 == 6) {
            i2 = 33;
        } else if (i4 == 7) {
            i2 = 129;
        } else if (i4 == 8) {
            i2 = 18;
        } else {
            if (i4 != 9) {
                throw new IllegalStateException("Invalid Keyboard Type");
            }
            i2 = 8194;
        }
        editorInfo.inputType = i2;
        if (!z && (i2 & 1) == 1) {
            editorInfo.inputType = 131072 | i2;
            if (hg.e == 1) {
                editorInfo.imeOptions |= 1073741824;
            }
        }
        int i5 = editorInfo.inputType;
        if ((i5 & 1) == 1) {
            int i6 = hg.b;
            if (i6 == 1) {
                editorInfo.inputType = i5 | 4096;
            } else if (i6 == 2) {
                editorInfo.inputType = i5 | 8192;
            } else if (i6 == 3) {
                editorInfo.inputType = i5 | 16384;
            }
            if (hg.c) {
                editorInfo.inputType |= 32768;
            }
        }
        int i7 = Ue0.c;
        editorInfo.initialSelStart = (int) (j >> 32);
        editorInfo.initialSelEnd = (int) (j & 4294967295L);
        AbstractC0752ap.c0(editorInfo, str);
        editorInfo.imeOptions |= 33554432;
        if (!AbstractC1870mb0.a || i4 == 7 || i4 == 8) {
            AbstractC0752ap.d0(editorInfo, false);
        } else {
            AbstractC0752ap.d0(editorInfo, true);
            editorInfo.setSupportedHandwritingGestures(AbstractC0008Ai.S(AbstractC2588u4.l(), AbstractC2588u4.A(), AbstractC2588u4.x(), AbstractC2588u4.z(), AbstractC2588u4.B(), AbstractC2588u4.C(), AbstractC2588u4.D()));
            editorInfo.setSupportedHandwritingGesturePreviews(AbstractC0940cn0.H(AbstractC2588u4.l(), AbstractC2588u4.A(), AbstractC2588u4.x(), AbstractC2588u4.z()));
        }
        JK jk = KK.a;
        if (C2004nv.d()) {
            C2004nv.a().i(editorInfo);
        }
        R00 r00 = new R00(this.h, new C0247Jn(22, this), this.i.c, this.e, this.f, this.g);
        this.j.add(new WeakReference(r00));
        return r00;
    }
}
