package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.LocaleList;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.TextView;
import androidx.core.content.res.h;
import java.lang.ref.WeakReference;
import java.util.Locale;

/* JADX INFO: compiled from: AppCompatTextHelper.java */
/* JADX INFO: loaded from: classes.dex */
class c0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final TextView f827a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private y0 f828b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private y0 f829c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private y0 f830d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private y0 f831e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private y0 f832f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private y0 f833g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private y0 f834h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private final e0 f835i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private int f836j = 0;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private int f837k = -1;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private Typeface f838l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private boolean f839m;

    /* JADX INFO: compiled from: AppCompatTextHelper.java */
    class a extends h.f {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ int f840a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ int f841b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        final /* synthetic */ WeakReference f842c;

        a(int i3, int i4, WeakReference weakReference) {
            this.f840a = i3;
            this.f841b = i4;
            this.f842c = weakReference;
        }

        @Override // androidx.core.content.res.h.f
        /* JADX INFO: renamed from: h */
        public void f(int i3) {
        }

        @Override // androidx.core.content.res.h.f
        /* JADX INFO: renamed from: i */
        public void g(Typeface typeface) {
            int i3;
            if (Build.VERSION.SDK_INT >= 28 && (i3 = this.f840a) != -1) {
                typeface = g.a(typeface, i3, (this.f841b & 2) != 0);
            }
            c0.this.n(this.f842c, typeface);
        }
    }

    /* JADX INFO: compiled from: AppCompatTextHelper.java */
    class b implements Runnable {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        final /* synthetic */ TextView f844e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        final /* synthetic */ Typeface f845f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        final /* synthetic */ int f846g;

        b(c0 c0Var, TextView textView, Typeface typeface, int i3) {
            this.f844e = textView;
            this.f845f = typeface;
            this.f846g = i3;
        }

        @Override // java.lang.Runnable
        public void run() {
            this.f844e.setTypeface(this.f845f, this.f846g);
        }
    }

    /* JADX INFO: compiled from: AppCompatTextHelper.java */
    static class c {
        static Drawable[] a(TextView textView) {
            return textView.getCompoundDrawablesRelative();
        }

        static void b(TextView textView, Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
            textView.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, drawable2, drawable3, drawable4);
        }

        static void c(TextView textView, Locale locale) {
            textView.setTextLocale(locale);
        }
    }

    /* JADX INFO: compiled from: AppCompatTextHelper.java */
    static class d {
        static Locale a(String str) {
            return Locale.forLanguageTag(str);
        }
    }

    /* JADX INFO: compiled from: AppCompatTextHelper.java */
    static class e {
        static LocaleList a(String str) {
            return LocaleList.forLanguageTags(str);
        }

        static void b(TextView textView, LocaleList localeList) {
            textView.setTextLocales(localeList);
        }
    }

    /* JADX INFO: compiled from: AppCompatTextHelper.java */
    static class f {
        static int a(TextView textView) {
            return textView.getAutoSizeStepGranularity();
        }

        static void b(TextView textView, int i3, int i4, int i5, int i6) {
            textView.setAutoSizeTextTypeUniformWithConfiguration(i3, i4, i5, i6);
        }

        static void c(TextView textView, int[] iArr, int i3) {
            textView.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i3);
        }

        static boolean d(TextView textView, String str) {
            return textView.setFontVariationSettings(str);
        }
    }

    /* JADX INFO: compiled from: AppCompatTextHelper.java */
    static class g {
        static Typeface a(Typeface typeface, int i3, boolean z2) {
            return Typeface.create(typeface, i3, z2);
        }
    }

    c0(TextView textView) {
        this.f827a = textView;
        this.f835i = new e0(textView);
    }

    private void B(int i3, float f3) {
        this.f835i.w(i3, f3);
    }

    private void C(Context context, a1 a1Var) {
        String strO;
        this.f836j = a1Var.k(c.j.A2, this.f836j);
        int i3 = Build.VERSION.SDK_INT;
        if (i3 >= 28) {
            int iK = a1Var.k(c.j.F2, -1);
            this.f837k = iK;
            if (iK != -1) {
                this.f836j = (this.f836j & 2) | 0;
            }
        }
        int i4 = c.j.E2;
        if (!a1Var.s(i4) && !a1Var.s(c.j.G2)) {
            int i5 = c.j.z2;
            if (a1Var.s(i5)) {
                this.f839m = false;
                int iK2 = a1Var.k(i5, 1);
                if (iK2 == 1) {
                    this.f838l = Typeface.SANS_SERIF;
                    return;
                } else if (iK2 == 2) {
                    this.f838l = Typeface.SERIF;
                    return;
                } else {
                    if (iK2 != 3) {
                        return;
                    }
                    this.f838l = Typeface.MONOSPACE;
                    return;
                }
            }
            return;
        }
        this.f838l = null;
        int i6 = c.j.G2;
        if (a1Var.s(i6)) {
            i4 = i6;
        }
        int i7 = this.f837k;
        int i8 = this.f836j;
        if (!context.isRestricted()) {
            try {
                Typeface typefaceJ = a1Var.j(i4, this.f836j, new a(i7, i8, new WeakReference(this.f827a)));
                if (typefaceJ != null) {
                    if (i3 < 28 || this.f837k == -1) {
                        this.f838l = typefaceJ;
                    } else {
                        this.f838l = g.a(Typeface.create(typefaceJ, 0), this.f837k, (this.f836j & 2) != 0);
                    }
                }
                this.f839m = this.f838l == null;
            } catch (Resources.NotFoundException | UnsupportedOperationException unused) {
            }
        }
        if (this.f838l != null || (strO = a1Var.o(i4)) == null) {
            return;
        }
        if (Build.VERSION.SDK_INT < 28 || this.f837k == -1) {
            this.f838l = Typeface.create(strO, this.f836j);
        } else {
            this.f838l = g.a(Typeface.create(strO, 0), this.f837k, (this.f836j & 2) != 0);
        }
    }

    private void a(Drawable drawable, y0 y0Var) {
        if (drawable == null || y0Var == null) {
            return;
        }
        k.i(drawable, y0Var, this.f827a.getDrawableState());
    }

    private static y0 d(Context context, k kVar, int i3) {
        ColorStateList colorStateListF = kVar.f(context, i3);
        if (colorStateListF == null) {
            return null;
        }
        y0 y0Var = new y0();
        y0Var.f1142d = true;
        y0Var.f1139a = colorStateListF;
        return y0Var;
    }

    private void y(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4, Drawable drawable5, Drawable drawable6) {
        int i3 = Build.VERSION.SDK_INT;
        if (i3 >= 17 && (drawable5 != null || drawable6 != null)) {
            Drawable[] drawableArrA = c.a(this.f827a);
            TextView textView = this.f827a;
            if (drawable5 == null) {
                drawable5 = drawableArrA[0];
            }
            if (drawable2 == null) {
                drawable2 = drawableArrA[1];
            }
            if (drawable6 == null) {
                drawable6 = drawableArrA[2];
            }
            if (drawable4 == null) {
                drawable4 = drawableArrA[3];
            }
            c.b(textView, drawable5, drawable2, drawable6, drawable4);
            return;
        }
        if (drawable == null && drawable2 == null && drawable3 == null && drawable4 == null) {
            return;
        }
        if (i3 >= 17) {
            Drawable[] drawableArrA2 = c.a(this.f827a);
            if (drawableArrA2[0] != null || drawableArrA2[2] != null) {
                TextView textView2 = this.f827a;
                Drawable drawable7 = drawableArrA2[0];
                if (drawable2 == null) {
                    drawable2 = drawableArrA2[1];
                }
                Drawable drawable8 = drawableArrA2[2];
                if (drawable4 == null) {
                    drawable4 = drawableArrA2[3];
                }
                c.b(textView2, drawable7, drawable2, drawable8, drawable4);
                return;
            }
        }
        Drawable[] compoundDrawables = this.f827a.getCompoundDrawables();
        TextView textView3 = this.f827a;
        if (drawable == null) {
            drawable = compoundDrawables[0];
        }
        if (drawable2 == null) {
            drawable2 = compoundDrawables[1];
        }
        if (drawable3 == null) {
            drawable3 = compoundDrawables[2];
        }
        if (drawable4 == null) {
            drawable4 = compoundDrawables[3];
        }
        textView3.setCompoundDrawablesWithIntrinsicBounds(drawable, drawable2, drawable3, drawable4);
    }

    private void z() {
        y0 y0Var = this.f834h;
        this.f828b = y0Var;
        this.f829c = y0Var;
        this.f830d = y0Var;
        this.f831e = y0Var;
        this.f832f = y0Var;
        this.f833g = y0Var;
    }

    void A(int i3, float f3) {
        if (androidx.core.widget.b.f2028a || l()) {
            return;
        }
        B(i3, f3);
    }

    void b() {
        if (this.f828b != null || this.f829c != null || this.f830d != null || this.f831e != null) {
            Drawable[] compoundDrawables = this.f827a.getCompoundDrawables();
            a(compoundDrawables[0], this.f828b);
            a(compoundDrawables[1], this.f829c);
            a(compoundDrawables[2], this.f830d);
            a(compoundDrawables[3], this.f831e);
        }
        if (Build.VERSION.SDK_INT >= 17) {
            if (this.f832f == null && this.f833g == null) {
                return;
            }
            Drawable[] drawableArrA = c.a(this.f827a);
            a(drawableArrA[0], this.f832f);
            a(drawableArrA[2], this.f833g);
        }
    }

    void c() {
        this.f835i.b();
    }

    int e() {
        return this.f835i.h();
    }

    int f() {
        return this.f835i.i();
    }

    int g() {
        return this.f835i.j();
    }

    int[] h() {
        return this.f835i.k();
    }

    int i() {
        return this.f835i.l();
    }

    ColorStateList j() {
        y0 y0Var = this.f834h;
        if (y0Var != null) {
            return y0Var.f1139a;
        }
        return null;
    }

    PorterDuff.Mode k() {
        y0 y0Var = this.f834h;
        if (y0Var != null) {
            return y0Var.f1140b;
        }
        return null;
    }

    boolean l() {
        return this.f835i.q();
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x00c9  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x0104  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x0109  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x010c  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x0119  */
    /* JADX WARN: Removed duplicated region for block: B:61:0x0140  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x0187  */
    /* JADX WARN: Removed duplicated region for block: B:88:0x01a6  */
    @android.annotation.SuppressLint({"NewApi"})
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    void m(android.util.AttributeSet r24, int r25) {
        /*
            Method dump skipped, instruction units count: 792
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.c0.m(android.util.AttributeSet, int):void");
    }

    void n(WeakReference<TextView> weakReference, Typeface typeface) {
        if (this.f839m) {
            this.f838l = typeface;
            TextView textView = weakReference.get();
            if (textView != null) {
                if (androidx.core.view.y.U(textView)) {
                    textView.post(new b(this, textView, typeface, this.f836j));
                } else {
                    textView.setTypeface(typeface, this.f836j);
                }
            }
        }
    }

    void o(boolean z2, int i3, int i4, int i5, int i6) {
        if (androidx.core.widget.b.f2028a) {
            return;
        }
        c();
    }

    void p() {
        b();
    }

    void q(Context context, int i3) {
        String strO;
        ColorStateList colorStateListC;
        ColorStateList colorStateListC2;
        ColorStateList colorStateListC3;
        a1 a1VarT = a1.t(context, i3, c.j.x2);
        int i4 = c.j.I2;
        if (a1VarT.s(i4)) {
            s(a1VarT.a(i4, false));
        }
        int i5 = Build.VERSION.SDK_INT;
        if (i5 < 23) {
            int i6 = c.j.B2;
            if (a1VarT.s(i6) && (colorStateListC3 = a1VarT.c(i6)) != null) {
                this.f827a.setTextColor(colorStateListC3);
            }
            int i7 = c.j.D2;
            if (a1VarT.s(i7) && (colorStateListC2 = a1VarT.c(i7)) != null) {
                this.f827a.setLinkTextColor(colorStateListC2);
            }
            int i8 = c.j.C2;
            if (a1VarT.s(i8) && (colorStateListC = a1VarT.c(i8)) != null) {
                this.f827a.setHintTextColor(colorStateListC);
            }
        }
        int i9 = c.j.y2;
        if (a1VarT.s(i9) && a1VarT.f(i9, -1) == 0) {
            this.f827a.setTextSize(0, 0.0f);
        }
        C(context, a1VarT);
        if (i5 >= 26) {
            int i10 = c.j.H2;
            if (a1VarT.s(i10) && (strO = a1VarT.o(i10)) != null) {
                f.d(this.f827a, strO);
            }
        }
        a1VarT.w();
        Typeface typeface = this.f838l;
        if (typeface != null) {
            this.f827a.setTypeface(typeface, this.f836j);
        }
    }

    void r(TextView textView, InputConnection inputConnection, EditorInfo editorInfo) {
        if (Build.VERSION.SDK_INT >= 30 || inputConnection == null) {
            return;
        }
        u.a.f(editorInfo, textView.getText());
    }

    void s(boolean z2) {
        this.f827a.setAllCaps(z2);
    }

    void t(int i3, int i4, int i5, int i6) throws IllegalArgumentException {
        this.f835i.s(i3, i4, i5, i6);
    }

    void u(int[] iArr, int i3) throws IllegalArgumentException {
        this.f835i.t(iArr, i3);
    }

    void v(int i3) {
        this.f835i.u(i3);
    }

    void w(ColorStateList colorStateList) {
        if (this.f834h == null) {
            this.f834h = new y0();
        }
        y0 y0Var = this.f834h;
        y0Var.f1139a = colorStateList;
        y0Var.f1142d = colorStateList != null;
        z();
    }

    void x(PorterDuff.Mode mode) {
        if (this.f834h == null) {
            this.f834h = new y0();
        }
        y0 y0Var = this.f834h;
        y0Var.f1140b = mode;
        y0Var.f1141c = mode != null;
        z();
    }
}
