package n3;

import M.J;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import com.google.android.material.button.MaterialButton;
import com.martsnew.tv.R;
import java.lang.reflect.Field;
import v3.AbstractC1674a;
import x3.g;
import x3.k;
import x3.u;

/* JADX INFO: renamed from: n3.c, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1275c {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public k f15139b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f15140c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f15141d;

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f15144g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f15145h;
    public PorterDuff.Mode i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public ColorStateList f15146j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public ColorStateList f15147k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public ColorStateList f15148l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public g f15149m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public boolean f15150n = false;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public boolean f15151o = false;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public boolean f15152p = false;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public boolean f15153q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public RippleDrawable f15154r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public int f15155s;

    public C1275c(MaterialButton materialButton, k kVar) {
        this.f15138a = materialButton;
        this.f15139b = kVar;
    }

    public final u a() {
        RippleDrawable rippleDrawable = this.f15154r;
        if (rippleDrawable == null || rippleDrawable.getNumberOfLayers() <= 1) {
            return null;
        }
        return this.f15154r.getNumberOfLayers() > 2 ? (u) this.f15154r.getDrawable(2) : (u) this.f15154r.getDrawable(1);
    }

    public final g b(boolean z8) {
        RippleDrawable rippleDrawable = this.f15154r;
        if (rippleDrawable == null || rippleDrawable.getNumberOfLayers() <= 0) {
            return null;
        }
        return (g) ((LayerDrawable) ((InsetDrawable) this.f15154r.getDrawable(0)).getDrawable()).getDrawable(!z8 ? 1 : 0);
    }

    public final void c(k kVar) {
        this.f15139b = kVar;
        if (b(false) != null) {
            b(false).setShapeAppearanceModel(kVar);
        }
        if (b(true) != null) {
            b(true).setShapeAppearanceModel(kVar);
        }
        if (a() != null) {
            a().setShapeAppearanceModel(kVar);
        }
    }

    public final void d(int i, int i5) {
        Field field = J.f4065a;
        MaterialButton materialButton = this.f15138a;
        int paddingStart = materialButton.getPaddingStart();
        int paddingTop = materialButton.getPaddingTop();
        int paddingEnd = materialButton.getPaddingEnd();
        int paddingBottom = materialButton.getPaddingBottom();
        int i8 = this.f15142e;
        int i9 = this.f15143f;
        this.f15143f = i5;
        this.f15142e = i;
        if (!this.f15151o) {
            e();
        }
        materialButton.setPaddingRelative(paddingStart, (paddingTop + i) - i8, paddingEnd, (paddingBottom + i5) - i9);
    }

    public final void e() {
        g gVar = new g(this.f15139b);
        MaterialButton materialButton = this.f15138a;
        gVar.g(materialButton.getContext());
        gVar.setTintList(this.f15146j);
        PorterDuff.Mode mode = this.i;
        if (mode != null) {
            gVar.setTintMode(mode);
        }
        float f3 = this.f15145h;
        ColorStateList colorStateList = this.f15147k;
        gVar.f18614q.f18596j = f3;
        gVar.invalidateSelf();
        x3.f fVar = gVar.f18614q;
        if (fVar.f18591d != colorStateList) {
            fVar.f18591d = colorStateList;
            gVar.onStateChange(gVar.getState());
        }
        g gVar2 = new g(this.f15139b);
        gVar2.setTint(0);
        float f7 = this.f15145h;
        int iS = this.f15150n ? W2.g.s(materialButton, R.attr.colorSurface) : 0;
        gVar2.f18614q.f18596j = f7;
        gVar2.invalidateSelf();
        ColorStateList colorStateListValueOf = ColorStateList.valueOf(iS);
        x3.f fVar2 = gVar2.f18614q;
        if (fVar2.f18591d != colorStateListValueOf) {
            fVar2.f18591d = colorStateListValueOf;
            gVar2.onStateChange(gVar2.getState());
        }
        g gVar3 = new g(this.f15139b);
        this.f15149m = gVar3;
        gVar3.setTint(-1);
        RippleDrawable rippleDrawable = new RippleDrawable(AbstractC1674a.a(this.f15148l), new InsetDrawable((Drawable) new LayerDrawable(new Drawable[]{gVar2, gVar}), this.f15140c, this.f15142e, this.f15141d, this.f15143f), this.f15149m);
        this.f15154r = rippleDrawable;
        materialButton.setInternalBackground(rippleDrawable);
        g gVarB = b(false);
        if (gVarB != null) {
            gVarB.h(this.f15155s);
        }
    }

    public final void f() {
        g gVarB = b(false);
        g gVarB2 = b(true);
        if (gVarB != null) {
            float f3 = this.f15145h;
            ColorStateList colorStateList = this.f15147k;
            gVarB.f18614q.f18596j = f3;
            gVarB.invalidateSelf();
            x3.f fVar = gVarB.f18614q;
            if (fVar.f18591d != colorStateList) {
                fVar.f18591d = colorStateList;
                gVarB.onStateChange(gVarB.getState());
            }
            if (gVarB2 != null) {
                float f7 = this.f15145h;
                int iS = this.f15150n ? W2.g.s(this.f15138a, R.attr.colorSurface) : 0;
                gVarB2.f18614q.f18596j = f7;
                gVarB2.invalidateSelf();
                ColorStateList colorStateListValueOf = ColorStateList.valueOf(iS);
                x3.f fVar2 = gVarB2.f18614q;
                if (fVar2.f18591d != colorStateListValueOf) {
                    fVar2.f18591d = colorStateListValueOf;
                    gVarB2.onStateChange(gVarB2.getState());
                }
            }
        }
    }
}
