package T;

import C0.B;
import D.C0135f;
import F1.k0;
import J0.j1;
import K.C0464l0;
import T0.N;
import V.i0;
import android.graphics.Rect;
import android.os.LocaleList;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import androidx.media3.exoplayer.DecoderReuseEvaluation;
import androidx.media3.extractor.ts.TsExtractor;
import b1.C1186a;
import b1.C1187b;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Locale;
import x4.AbstractC3250p;
import x4.AbstractC3252r;
import x4.AbstractC3253s;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final View f6375a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final p f6376b;

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public j1 f6381g;
    public Rect l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final u f6386m;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public J4.c f6377c = new S2.f(4);

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public J4.c f6378d = new S2.f(5);

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public Z0.y f6382h = new Z0.y("", N.f6481b, 4);

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public Z0.k f6383i = Z0.k.f9110g;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final ArrayList f6384j = new ArrayList();

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final Object f6385k = m1.g.j(w4.i.f25467c, new C0135f(this, 14));

    public x(View view, b bVar, p pVar) {
        this.f6375a = view;
        this.f6376b = pVar;
        this.f6386m = new u(bVar, pVar);
    }

    public final y a(EditorInfo editorInfo) {
        int i6;
        int i7;
        Z0.y yVar = this.f6382h;
        String str = yVar.f9136a.f6510b;
        Z0.k kVar = this.f6383i;
        int i8 = kVar.f9115e;
        boolean z6 = kVar.f9111a;
        if (i8 == 1) {
            i6 = z6 ? 6 : 0;
        } else if (i8 == 0) {
            i6 = 1;
        } else if (i8 == 2) {
            i6 = 2;
        } else if (i8 == 6) {
            i6 = 5;
        } else if (i8 == 5) {
            i6 = 7;
        } else if (i8 == 3) {
            i6 = 3;
        } else if (i8 == 4) {
            i6 = 4;
        } else {
            if (i8 != 7) {
                throw new IllegalStateException("invalid ImeAction");
            }
        }
        editorInfo.imeOptions = i6;
        C1187b c1187b = C1187b.f13227c;
        C1187b c1187b2 = kVar.f9116f;
        if (kotlin.jvm.internal.o.c(c1187b2, c1187b)) {
            editorInfo.hintLocales = null;
        } else {
            ArrayList arrayList = new ArrayList(AbstractC3253s.G(c1187b2, 10));
            Iterator it = c1187b2.f13228a.iterator();
            while (it.hasNext()) {
                arrayList.add(((C1186a) it.next()).f13226a);
            }
            Locale[] localeArr = (Locale[]) arrayList.toArray(new Locale[0]);
            editorInfo.hintLocales = new LocaleList((Locale[]) Arrays.copyOf(localeArr, localeArr.length));
        }
        int i9 = kVar.f9114d;
        if (i9 == 1) {
            i7 = 1;
        } else if (i9 == 2) {
            editorInfo.imeOptions |= Integer.MIN_VALUE;
            i7 = 1;
        } else if (i9 == 3) {
            i7 = 2;
        } else if (i9 == 4) {
            i7 = 3;
        } else if (i9 == 5) {
            i7 = 17;
        } else if (i9 == 6) {
            i7 = 33;
        } else if (i9 == 7) {
            i7 = TsExtractor.TS_STREAM_TYPE_AC3;
        } else if (i9 == 8) {
            i7 = 18;
        } else {
            if (i9 != 9) {
                throw new IllegalStateException("Invalid Keyboard Type");
            }
            i7 = 8194;
        }
        editorInfo.inputType = i7;
        if (!z6 && (i7 & 1) == 1) {
            editorInfo.inputType = i7 | 131072;
            if (kVar.f9115e == 1) {
                editorInfo.imeOptions |= 1073741824;
            }
        }
        int i10 = editorInfo.inputType;
        if ((i10 & 1) == 1) {
            int i11 = kVar.f9112b;
            if (i11 == 1) {
                editorInfo.inputType = i10 | 4096;
            } else if (i11 == 2) {
                editorInfo.inputType = i10 | 8192;
            } else if (i11 == 3) {
                editorInfo.inputType = i10 | 16384;
            }
            if (kVar.f9113c) {
                editorInfo.inputType |= DecoderReuseEvaluation.DISCARD_REASON_AUDIO_BYPASS_POSSIBLE;
            }
        }
        int i12 = N.f6482c;
        long j4 = yVar.f9137b;
        editorInfo.initialSelStart = (int) (j4 >> 32);
        editorInfo.initialSelEnd = (int) (j4 & 4294967295L);
        android.support.v4.media.session.b.I(editorInfo, str);
        editorInfo.imeOptions |= 33554432;
        if (!S.e.f6130a || i9 == 7 || i9 == 8) {
            android.support.v4.media.session.b.J(editorInfo, false);
        } else {
            android.support.v4.media.session.b.J(editorInfo, true);
            editorInfo.setSupportedHandwritingGestures(AbstractC3252r.B(k0.m(), k0.A(), k0.w(), k0.y(), k0.B(), k0.C(), k0.D()));
            editorInfo.setSupportedHandwritingGesturePreviews(AbstractC3250p.Y(new Class[]{k0.m(), k0.A(), k0.w(), k0.y()}));
        }
        v vVar = w.f6374a;
        if (T1.h.d()) {
            T1.h.a().g(editorInfo);
        }
        y yVar2 = new y(this.f6382h, new B(this, 18), this.f6383i.f9113c, this.f6379e, this.f6380f, this.f6381g);
        this.f6384j.add(new WeakReference(yVar2));
        return yVar2;
    }
}
