package j;

import M4.k;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.StateSet;
import com.google.android.gms.internal.measurement.X1;
import d2.q;
import k.AbstractC1083b;
import k.AbstractC1084c;
import n.C1234s0;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: renamed from: j.e, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1060e extends Drawable implements Drawable.Callback {

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public static final /* synthetic */ int f13640J = 0;

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public long f13641A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public d2.b f13642B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public C1057b f13643C;
    public boolean D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public C1057b f13644E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public X1 f13645F;

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

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

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

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

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public Drawable f13651t;

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

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

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

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public long f13657z;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public int f13652u = 255;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public int f13654w = -1;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public int f13646G = -1;
    public int H = -1;

    public C1060e(C1057b c1057b, Resources resources) {
        i(new C1057b(c1057b, this, resources));
        onStateChange(getState());
        jumpToCurrentState();
    }

    /* JADX WARN: Code restructure failed: missing block: B:98:0x0272, code lost:
    
        r5.onStateChange(r5.getState());
     */
    /* JADX WARN: Code restructure failed: missing block: B:99:0x0279, code lost:
    
        return r5;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static C1060e c(Context context, Resources resources, XmlResourceParser xmlResourceParser, AttributeSet attributeSet, Resources.Theme theme) throws Throwable {
        int depth;
        int next;
        int next2;
        Context context2 = context;
        Resources resources2 = resources;
        String name = xmlResourceParser.getName();
        if (!name.equals("animated-selector")) {
            throw new XmlPullParserException(xmlResourceParser.getPositionDescription() + ": invalid animated-selector tag " + name);
        }
        C1060e c1060e = new C1060e(null, null);
        TypedArray typedArrayG = E.b.g(resources2, theme, attributeSet, AbstractC1084c.f13737a);
        int i = 1;
        c1060e.setVisible(typedArrayG.getBoolean(1, true), true);
        C1057b c1057b = c1060e.f13644E;
        c1057b.f13613d |= AbstractC1083b.b(typedArrayG);
        int i5 = 2;
        c1057b.i = typedArrayG.getBoolean(2, c1057b.i);
        int i8 = 3;
        c1057b.f13620l = typedArrayG.getBoolean(3, c1057b.f13620l);
        c1057b.f13633y = typedArrayG.getInt(4, c1057b.f13633y);
        c1057b.f13634z = typedArrayG.getInt(5, c1057b.f13634z);
        boolean z8 = false;
        c1060e.setDither(typedArrayG.getBoolean(0, c1057b.f13631w));
        C1057b c1057b2 = c1060e.f13648q;
        if (resources2 != null) {
            c1057b2.f13611b = resources2;
            int i9 = resources2.getDisplayMetrics().densityDpi;
            if (i9 == 0) {
                i9 = 160;
            }
            int i10 = c1057b2.f13612c;
            c1057b2.f13612c = i9;
            if (i10 != i9) {
                c1057b2.f13621m = false;
                c1057b2.f13618j = false;
            }
        } else {
            c1057b2.getClass();
        }
        typedArrayG.recycle();
        int depth2 = xmlResourceParser.getDepth() + 1;
        while (true) {
            int next3 = xmlResourceParser.next();
            if (next3 == i || ((depth = xmlResourceParser.getDepth()) < depth2 && next3 == i8)) {
                break;
            }
            if (next3 == i5 && depth <= depth2) {
                if (xmlResourceParser.getName().equals("item")) {
                    TypedArray typedArrayG2 = E.b.g(resources2, theme, attributeSet, AbstractC1084c.f13738b);
                    int resourceId = typedArrayG2.getResourceId(z8 ? 1 : 0, z8 ? 1 : 0);
                    int resourceId2 = typedArrayG2.getResourceId(i, -1);
                    Drawable drawableF = resourceId2 > 0 ? C1234s0.d().f(context2, resourceId2) : null;
                    typedArrayG2.recycle();
                    int attributeCount = attributeSet.getAttributeCount();
                    int[] iArr = new int[attributeCount];
                    int i11 = z8 ? 1 : 0;
                    for (int i12 = i11 == true ? 1 : 0; i12 < attributeCount; i12++) {
                        int attributeNameResource = attributeSet.getAttributeNameResource(i12);
                        if (attributeNameResource != 0 && attributeNameResource != 16842960 && attributeNameResource != 16843161) {
                            int i13 = (i11 == true ? 1 : 0) + 1;
                            if (!attributeSet.getAttributeBooleanValue(i12, z8)) {
                                attributeNameResource = -attributeNameResource;
                            }
                            iArr[i11 == true ? 1 : 0] = attributeNameResource;
                            i11 = i13;
                        }
                    }
                    int[] iArrTrimStateSet = StateSet.trimStateSet(iArr, i11 == true ? 1 : 0);
                    if (drawableF == null) {
                        do {
                            next2 = xmlResourceParser.next();
                        } while (next2 == 4);
                        if (next2 != 2) {
                            throw new XmlPullParserException(xmlResourceParser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or child tag defining a drawable");
                        }
                        if (xmlResourceParser.getName().equals("vector")) {
                            drawableF = new q();
                            drawableF.inflate(resources2, xmlResourceParser, attributeSet, theme);
                        } else {
                            drawableF = AbstractC1083b.a(resources, xmlResourceParser, attributeSet, theme);
                        }
                    }
                    if (drawableF == null) {
                        throw new XmlPullParserException(xmlResourceParser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or child tag defining a drawable");
                    }
                    C1057b c1057b3 = c1060e.f13644E;
                    int iA = c1057b3.a(drawableF);
                    c1057b3.H[iA] = iArrTrimStateSet;
                    c1057b3.f13609J.i(iA, Integer.valueOf(resourceId));
                } else if (xmlResourceParser.getName().equals("transition")) {
                    TypedArray typedArrayG3 = E.b.g(resources2, theme, attributeSet, AbstractC1084c.f13739c);
                    int resourceId3 = typedArrayG3.getResourceId(2, -1);
                    int resourceId4 = typedArrayG3.getResourceId(1, -1);
                    int resourceId5 = typedArrayG3.getResourceId(z8 ? 1 : 0, -1);
                    Drawable drawableF2 = resourceId5 > 0 ? C1234s0.d().f(context2, resourceId5) : null;
                    boolean z9 = typedArrayG3.getBoolean(3, z8);
                    typedArrayG3.recycle();
                    if (drawableF2 == null) {
                        do {
                            next = xmlResourceParser.next();
                        } while (next == 4);
                        if (next != 2) {
                            throw new XmlPullParserException(xmlResourceParser.getPositionDescription() + ": <transition> tag requires a 'drawable' attribute or child tag defining a drawable");
                        }
                        if (xmlResourceParser.getName().equals("animated-vector")) {
                            drawableF2 = new d2.e(context2);
                            drawableF2.inflate(resources2, xmlResourceParser, attributeSet, theme);
                        } else {
                            drawableF2 = AbstractC1083b.a(resources, xmlResourceParser, attributeSet, theme);
                        }
                    }
                    if (drawableF2 == null) {
                        throw new XmlPullParserException(xmlResourceParser.getPositionDescription() + ": <transition> tag requires a 'drawable' attribute or child tag defining a drawable");
                    }
                    if (resourceId3 == -1 || resourceId4 == -1) {
                        break;
                    }
                    C1057b c1057b4 = c1060e.f13644E;
                    int iA2 = c1057b4.a(drawableF2);
                    long j8 = resourceId3;
                    long j9 = resourceId4;
                    long j10 = (j8 << 32) | j9;
                    long j11 = z9 ? 8589934592L : 0L;
                    long j12 = iA2;
                    c1057b4.f13608I.c(j10, Long.valueOf(j12 | j11));
                    if (z9) {
                        c1057b4.f13608I.c((j9 << 32) | j8, Long.valueOf(j12 | 4294967296L | j11));
                    }
                    context2 = context;
                    resources2 = resources;
                    i = 1;
                    z8 = false;
                    i5 = 2;
                    i8 = 3;
                } else {
                    context2 = context;
                    resources2 = resources;
                }
                i = 1;
                i5 = 2;
                i8 = 3;
            }
        }
        throw new XmlPullParserException(xmlResourceParser.getPositionDescription() + ": <transition> tag requires 'fromId' & 'toId' attributes");
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x003d  */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0061  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0066 A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:26:? A[ADDED_TO_REGION, RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void a(boolean z8) {
        boolean z9;
        Drawable drawable;
        boolean z10 = true;
        this.f13653v = true;
        long jUptimeMillis = SystemClock.uptimeMillis();
        Drawable drawable2 = this.f13650s;
        if (drawable2 != null) {
            long j8 = this.f13657z;
            if (j8 != 0) {
                if (j8 <= jUptimeMillis) {
                    drawable2.setAlpha(this.f13652u);
                    this.f13657z = 0L;
                } else {
                    drawable2.setAlpha(((255 - (((int) ((j8 - jUptimeMillis) * 255)) / this.f13648q.f13633y)) * this.f13652u) / 255);
                    z9 = true;
                }
            }
            drawable = this.f13651t;
            if (drawable == null) {
                long j9 = this.f13641A;
                if (j9 != 0) {
                    if (j9 <= jUptimeMillis) {
                        drawable.setVisible(false, false);
                        this.f13651t = null;
                        this.f13641A = 0L;
                    } else {
                        drawable.setAlpha(((((int) ((j9 - jUptimeMillis) * 255)) / this.f13648q.f13634z) * this.f13652u) / 255);
                    }
                }
                if (z8 && z10) {
                    scheduleSelf(this.f13656y, jUptimeMillis + 16);
                    return;
                }
                return;
            }
            this.f13641A = 0L;
            z10 = z9;
            if (z8) {
                return;
            } else {
                return;
            }
        }
        this.f13657z = 0L;
        z9 = false;
        drawable = this.f13651t;
        if (drawable == null) {
        }
        z10 = z9;
        if (z8) {
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void applyTheme(Resources.Theme theme) {
        b(theme);
        onStateChange(getState());
    }

    public final void b(Resources.Theme theme) {
        C1057b c1057b = this.f13648q;
        if (theme == null) {
            c1057b.getClass();
            return;
        }
        c1057b.c();
        int i = c1057b.f13617h;
        Drawable[] drawableArr = c1057b.f13616g;
        for (int i5 = 0; i5 < i; i5++) {
            Drawable drawable = drawableArr[i5];
            if (drawable != null && drawable.canApplyTheme()) {
                drawableArr[i5].applyTheme(theme);
                c1057b.f13614e |= drawableArr[i5].getChangingConfigurations();
            }
        }
        Resources resources = theme.getResources();
        if (resources != null) {
            c1057b.f13611b = resources;
            int i8 = resources.getDisplayMetrics().densityDpi;
            if (i8 == 0) {
                i8 = 160;
            }
            int i9 = c1057b.f13612c;
            c1057b.f13612c = i8;
            if (i9 != i8) {
                c1057b.f13621m = false;
                c1057b.f13618j = false;
            }
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean canApplyTheme() {
        return this.f13648q.canApplyTheme();
    }

    public final void d(Drawable drawable) {
        if (this.f13642B == null) {
            this.f13642B = new d2.b();
        }
        d2.b bVar = this.f13642B;
        bVar.f11349r = drawable.getCallback();
        drawable.setCallback(bVar);
        try {
            if (this.f13648q.f13633y <= 0 && this.f13653v) {
                drawable.setAlpha(this.f13652u);
            }
            C1057b c1057b = this.f13648q;
            if (c1057b.f13604C) {
                drawable.setColorFilter(c1057b.f13603B);
            } else {
                if (c1057b.f13606F) {
                    drawable.setTintList(c1057b.D);
                }
                C1057b c1057b2 = this.f13648q;
                if (c1057b2.f13607G) {
                    drawable.setTintMode(c1057b2.f13605E);
                }
            }
            drawable.setVisible(isVisible(), true);
            drawable.setDither(this.f13648q.f13631w);
            drawable.setState(getState());
            drawable.setLevel(getLevel());
            drawable.setBounds(getBounds());
            drawable.setLayoutDirection(getLayoutDirection());
            drawable.setAutoMirrored(this.f13648q.f13602A);
            Rect rect = this.f13649r;
            if (rect != null) {
                drawable.setHotspotBounds(rect.left, rect.top, rect.right, rect.bottom);
            }
            d2.b bVar2 = this.f13642B;
            Drawable.Callback callback = (Drawable.Callback) bVar2.f11349r;
            bVar2.f11349r = null;
            drawable.setCallback(callback);
        } catch (Throwable th) {
            d2.b bVar3 = this.f13642B;
            Drawable.Callback callback2 = (Drawable.Callback) bVar3.f11349r;
            bVar3.f11349r = null;
            drawable.setCallback(callback2);
            throw th;
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void draw(Canvas canvas) {
        Drawable drawable = this.f13650s;
        if (drawable != null) {
            drawable.draw(canvas);
        }
        Drawable drawable2 = this.f13651t;
        if (drawable2 != null) {
            drawable2.draw(canvas);
        }
    }

    public final void e() {
        boolean z8;
        Drawable drawable = this.f13651t;
        boolean z9 = true;
        if (drawable != null) {
            drawable.jumpToCurrentState();
            this.f13651t = null;
            z8 = true;
        } else {
            z8 = false;
        }
        Drawable drawable2 = this.f13650s;
        if (drawable2 != null) {
            drawable2.jumpToCurrentState();
            if (this.f13653v) {
                this.f13650s.setAlpha(this.f13652u);
            }
        }
        if (this.f13641A != 0) {
            this.f13641A = 0L;
            z8 = true;
        }
        if (this.f13657z != 0) {
            this.f13657z = 0L;
        } else {
            z9 = z8;
        }
        if (z9) {
            invalidateSelf();
        }
    }

    public final Drawable f() {
        if (!this.f13655x && super.mutate() == this) {
            C1057b c1057b = new C1057b(this.f13644E, this, null);
            c1057b.f13608I = c1057b.f13608I.clone();
            c1057b.f13609J = c1057b.f13609J.clone();
            i(c1057b);
            this.f13655x = true;
        }
        return this;
    }

    public final Drawable g() {
        if (!this.D) {
            f();
            C1057b c1057b = this.f13643C;
            c1057b.f13608I = c1057b.f13608I.clone();
            c1057b.f13609J = c1057b.f13609J.clone();
            this.D = true;
        }
        return this;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getAlpha() {
        return this.f13652u;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getChangingConfigurations() {
        return super.getChangingConfigurations() | this.f13648q.getChangingConfigurations();
    }

    @Override // android.graphics.drawable.Drawable
    public final Drawable.ConstantState getConstantState() {
        boolean z8;
        C1057b c1057b = this.f13648q;
        if (!c1057b.f13629u) {
            c1057b.c();
            c1057b.f13629u = true;
            int i = c1057b.f13617h;
            Drawable[] drawableArr = c1057b.f13616g;
            int i5 = 0;
            while (true) {
                if (i5 >= i) {
                    c1057b.f13630v = true;
                    z8 = true;
                    break;
                }
                if (drawableArr[i5].getConstantState() == null) {
                    c1057b.f13630v = false;
                    z8 = false;
                    break;
                }
                i5++;
            }
        } else {
            z8 = c1057b.f13630v;
        }
        if (!z8) {
            return null;
        }
        this.f13648q.f13613d = getChangingConfigurations();
        return this.f13648q;
    }

    @Override // android.graphics.drawable.Drawable
    public final Drawable getCurrent() {
        return this.f13650s;
    }

    @Override // android.graphics.drawable.Drawable
    public final void getHotspotBounds(Rect rect) {
        Rect rect2 = this.f13649r;
        if (rect2 != null) {
            rect.set(rect2);
        } else {
            super.getHotspotBounds(rect);
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final int getIntrinsicHeight() {
        C1057b c1057b = this.f13648q;
        if (c1057b.f13620l) {
            if (!c1057b.f13621m) {
                c1057b.b();
            }
            return c1057b.f13623o;
        }
        Drawable drawable = this.f13650s;
        if (drawable != null) {
            return drawable.getIntrinsicHeight();
        }
        return -1;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getIntrinsicWidth() {
        C1057b c1057b = this.f13648q;
        if (c1057b.f13620l) {
            if (!c1057b.f13621m) {
                c1057b.b();
            }
            return c1057b.f13622n;
        }
        Drawable drawable = this.f13650s;
        if (drawable != null) {
            return drawable.getIntrinsicWidth();
        }
        return -1;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getMinimumHeight() {
        C1057b c1057b = this.f13648q;
        if (c1057b.f13620l) {
            if (!c1057b.f13621m) {
                c1057b.b();
            }
            return c1057b.f13625q;
        }
        Drawable drawable = this.f13650s;
        if (drawable != null) {
            return drawable.getMinimumHeight();
        }
        return 0;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getMinimumWidth() {
        C1057b c1057b = this.f13648q;
        if (c1057b.f13620l) {
            if (!c1057b.f13621m) {
                c1057b.b();
            }
            return c1057b.f13624p;
        }
        Drawable drawable = this.f13650s;
        if (drawable != null) {
            return drawable.getMinimumWidth();
        }
        return 0;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getOpacity() {
        Drawable drawable = this.f13650s;
        if (drawable != null && drawable.isVisible()) {
            C1057b c1057b = this.f13648q;
            if (c1057b.f13626r) {
                return c1057b.f13627s;
            }
            c1057b.c();
            int i = c1057b.f13617h;
            Drawable[] drawableArr = c1057b.f13616g;
            opacity = i > 0 ? drawableArr[0].getOpacity() : -2;
            for (int i5 = 1; i5 < i; i5++) {
                opacity = Drawable.resolveOpacity(opacity, drawableArr[i5].getOpacity());
            }
            c1057b.f13627s = opacity;
            c1057b.f13626r = true;
        }
        return opacity;
    }

    @Override // android.graphics.drawable.Drawable
    public final void getOutline(Outline outline) {
        Drawable drawable = this.f13650s;
        if (drawable != null) {
            drawable.getOutline(outline);
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean getPadding(Rect rect) {
        C1057b c1057b = this.f13648q;
        boolean padding = false;
        Rect rect2 = null;
        if (!c1057b.i) {
            Rect rect3 = c1057b.f13619k;
            if (rect3 != null || c1057b.f13618j) {
                rect2 = rect3;
            } else {
                c1057b.c();
                Rect rect4 = new Rect();
                int i = c1057b.f13617h;
                Drawable[] drawableArr = c1057b.f13616g;
                for (int i5 = 0; i5 < i; i5++) {
                    if (drawableArr[i5].getPadding(rect4)) {
                        if (rect2 == null) {
                            rect2 = new Rect(0, 0, 0, 0);
                        }
                        int i8 = rect4.left;
                        if (i8 > rect2.left) {
                            rect2.left = i8;
                        }
                        int i9 = rect4.top;
                        if (i9 > rect2.top) {
                            rect2.top = i9;
                        }
                        int i10 = rect4.right;
                        if (i10 > rect2.right) {
                            rect2.right = i10;
                        }
                        int i11 = rect4.bottom;
                        if (i11 > rect2.bottom) {
                            rect2.bottom = i11;
                        }
                    }
                }
                c1057b.f13618j = true;
                c1057b.f13619k = rect2;
            }
        }
        if (rect2 != null) {
            rect.set(rect2);
            if ((rect2.left | rect2.top | rect2.bottom | rect2.right) != 0) {
                padding = true;
            }
        } else {
            Drawable drawable = this.f13650s;
            padding = drawable != null ? drawable.getPadding(rect) : super.getPadding(rect);
        }
        if (this.f13648q.f13602A && getLayoutDirection() == 1) {
            int i12 = rect.left;
            rect.left = rect.right;
            rect.right = i12;
        }
        return padding;
    }

    /* JADX WARN: Removed duplicated region for block: B:26:0x0055  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean h(int i) {
        if (i == this.f13654w) {
            return false;
        }
        long jUptimeMillis = SystemClock.uptimeMillis();
        if (this.f13648q.f13634z > 0) {
            Drawable drawable = this.f13651t;
            if (drawable != null) {
                drawable.setVisible(false, false);
            }
            Drawable drawable2 = this.f13650s;
            if (drawable2 != null) {
                this.f13651t = drawable2;
                this.f13641A = ((long) this.f13648q.f13634z) + jUptimeMillis;
            } else {
                this.f13651t = null;
                this.f13641A = 0L;
            }
        } else {
            Drawable drawable3 = this.f13650s;
            if (drawable3 != null) {
                drawable3.setVisible(false, false);
            }
        }
        if (i >= 0) {
            C1057b c1057b = this.f13648q;
            if (i < c1057b.f13617h) {
                Drawable drawableD = c1057b.d(i);
                this.f13650s = drawableD;
                this.f13654w = i;
                if (drawableD != null) {
                    int i5 = this.f13648q.f13633y;
                    if (i5 > 0) {
                        this.f13657z = jUptimeMillis + ((long) i5);
                    }
                    d(drawableD);
                }
            } else {
                this.f13650s = null;
                this.f13654w = -1;
            }
        }
        if (this.f13657z != 0 || this.f13641A != 0) {
            k kVar = this.f13656y;
            if (kVar == null) {
                this.f13656y = new k(25, this);
            } else {
                unscheduleSelf(kVar);
            }
            a(true);
        }
        invalidateSelf();
        return true;
    }

    public final void i(C1057b c1057b) {
        this.f13648q = c1057b;
        int i = this.f13654w;
        if (i >= 0) {
            Drawable drawableD = c1057b.d(i);
            this.f13650s = drawableD;
            if (drawableD != null) {
                d(drawableD);
            }
        }
        this.f13651t = null;
        this.f13643C = c1057b;
        this.f13644E = c1057b;
    }

    @Override // android.graphics.drawable.Drawable.Callback
    public final void invalidateDrawable(Drawable drawable) {
        C1057b c1057b = this.f13648q;
        if (c1057b != null) {
            c1057b.f13626r = false;
            c1057b.f13628t = false;
        }
        if (drawable != this.f13650s || getCallback() == null) {
            return;
        }
        getCallback().invalidateDrawable(this);
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean isAutoMirrored() {
        return this.f13648q.f13602A;
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean isStateful() {
        return true;
    }

    public final boolean j(boolean z8, boolean z9) {
        boolean visible = super.setVisible(z8, z9);
        Drawable drawable = this.f13651t;
        if (drawable != null) {
            drawable.setVisible(z8, z9);
        }
        Drawable drawable2 = this.f13650s;
        if (drawable2 != null) {
            drawable2.setVisible(z8, z9);
        }
        return visible;
    }

    @Override // android.graphics.drawable.Drawable
    public final void jumpToCurrentState() {
        e();
        X1 x12 = this.f13645F;
        if (x12 != null) {
            x12.M();
            this.f13645F = null;
            h(this.f13646G);
            this.f13646G = -1;
            this.H = -1;
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final Drawable mutate() {
        if (!this.f13647I) {
            g();
            C1057b c1057b = this.f13644E;
            c1057b.f13608I = c1057b.f13608I.clone();
            c1057b.f13609J = c1057b.f13609J.clone();
            this.f13647I = true;
        }
        return this;
    }

    @Override // android.graphics.drawable.Drawable
    public final void onBoundsChange(Rect rect) {
        Drawable drawable = this.f13651t;
        if (drawable != null) {
            drawable.setBounds(rect);
        }
        Drawable drawable2 = this.f13650s;
        if (drawable2 != null) {
            drawable2.setBounds(rect);
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean onLayoutDirectionChanged(int i) {
        C1057b c1057b = this.f13648q;
        int i5 = this.f13654w;
        int i8 = c1057b.f13617h;
        Drawable[] drawableArr = c1057b.f13616g;
        boolean z8 = false;
        for (int i9 = 0; i9 < i8; i9++) {
            Drawable drawable = drawableArr[i9];
            if (drawable != null) {
                boolean layoutDirection = drawable.setLayoutDirection(i);
                if (i9 == i5) {
                    z8 = layoutDirection;
                }
            }
        }
        c1057b.f13632x = i;
        return z8;
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean onLevelChange(int i) {
        Drawable drawable = this.f13651t;
        if (drawable != null) {
            return drawable.setLevel(i);
        }
        Drawable drawable2 = this.f13650s;
        if (drawable2 != null) {
            return drawable2.setLevel(i);
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:43:0x00cd  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x00d3  */
    @Override // android.graphics.drawable.Drawable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onStateChange(int[] iArr) {
        int iE;
        X1 c1056a;
        C1057b c1057b = this.f13644E;
        int iF = c1057b.f(iArr);
        if (iF < 0) {
            iF = c1057b.f(StateSet.WILD_CARD);
        }
        int i = this.f13654w;
        if (iF != i) {
            X1 x12 = this.f13645F;
            if (x12 == null) {
                this.f13645F = null;
                this.H = -1;
                this.f13646G = -1;
                C1057b c1057b2 = this.f13644E;
                int iE2 = c1057b2.e(i);
                iE = c1057b2.e(iF);
                if (iE == 0 && iE2 != 0) {
                    long j8 = ((long) iE) | (((long) iE2) << 32);
                    int iLongValue = (int) ((Long) c1057b2.f13608I.h(j8)).longValue();
                    if (iLongValue >= 0) {
                        boolean z8 = (((Long) c1057b2.f13608I.h(j8)).longValue() & 8589934592L) != 0;
                        h(iLongValue);
                        Object obj = this.f13650s;
                        if (obj instanceof AnimationDrawable) {
                            c1056a = new C1058c((AnimationDrawable) obj, (((Long) c1057b2.f13608I.h(j8)).longValue() & 4294967296L) != 0, z8);
                        } else if (obj instanceof d2.e) {
                            c1056a = new C1056a((d2.e) obj, 1);
                        } else {
                            if (obj instanceof Animatable) {
                                c1056a = new C1056a((Animatable) obj, 0);
                            }
                            if (h(iF)) {
                            }
                        }
                        c1056a.L();
                        this.f13645F = c1056a;
                        this.H = i;
                        this.f13646G = iF;
                        z = true;
                    }
                } else if (h(iF)) {
                    z = true;
                }
            } else {
                if (iF != this.f13646G) {
                    if (iF == this.H && x12.a()) {
                        x12.H();
                        this.f13646G = this.H;
                        this.H = iF;
                    } else {
                        i = this.f13646G;
                        x12.M();
                        this.f13645F = null;
                        this.H = -1;
                        this.f13646G = -1;
                        C1057b c1057b22 = this.f13644E;
                        int iE22 = c1057b22.e(i);
                        iE = c1057b22.e(iF);
                        if (iE == 0) {
                            if (h(iF)) {
                            }
                        }
                    }
                }
                z = true;
            }
        }
        Drawable drawable = this.f13650s;
        return drawable != null ? drawable.setState(iArr) | z : z;
    }

    @Override // android.graphics.drawable.Drawable.Callback
    public final void scheduleDrawable(Drawable drawable, Runnable runnable, long j8) {
        if (drawable != this.f13650s || getCallback() == null) {
            return;
        }
        getCallback().scheduleDrawable(this, runnable, j8);
    }

    @Override // android.graphics.drawable.Drawable
    public final void setAlpha(int i) {
        if (this.f13653v && this.f13652u == i) {
            return;
        }
        this.f13653v = true;
        this.f13652u = i;
        Drawable drawable = this.f13650s;
        if (drawable != null) {
            if (this.f13657z == 0) {
                drawable.setAlpha(i);
            } else {
                a(false);
            }
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void setAutoMirrored(boolean z8) {
        C1057b c1057b = this.f13648q;
        if (c1057b.f13602A != z8) {
            c1057b.f13602A = z8;
            Drawable drawable = this.f13650s;
            if (drawable != null) {
                drawable.setAutoMirrored(z8);
            }
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void setColorFilter(ColorFilter colorFilter) {
        C1057b c1057b = this.f13648q;
        c1057b.f13604C = true;
        if (c1057b.f13603B != colorFilter) {
            c1057b.f13603B = colorFilter;
            Drawable drawable = this.f13650s;
            if (drawable != null) {
                drawable.setColorFilter(colorFilter);
            }
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void setDither(boolean z8) {
        C1057b c1057b = this.f13648q;
        if (c1057b.f13631w != z8) {
            c1057b.f13631w = z8;
            Drawable drawable = this.f13650s;
            if (drawable != null) {
                drawable.setDither(z8);
            }
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void setHotspot(float f3, float f7) {
        Drawable drawable = this.f13650s;
        if (drawable != null) {
            drawable.setHotspot(f3, f7);
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void setHotspotBounds(int i, int i5, int i8, int i9) {
        Rect rect = this.f13649r;
        if (rect == null) {
            this.f13649r = new Rect(i, i5, i8, i9);
        } else {
            rect.set(i, i5, i8, i9);
        }
        Drawable drawable = this.f13650s;
        if (drawable != null) {
            drawable.setHotspotBounds(i, i5, i8, i9);
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void setTint(int i) {
        setTintList(ColorStateList.valueOf(i));
    }

    @Override // android.graphics.drawable.Drawable
    public final void setTintList(ColorStateList colorStateList) {
        C1057b c1057b = this.f13648q;
        c1057b.f13606F = true;
        if (c1057b.D != colorStateList) {
            c1057b.D = colorStateList;
            this.f13650s.setTintList(colorStateList);
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void setTintMode(PorterDuff.Mode mode) {
        C1057b c1057b = this.f13648q;
        c1057b.f13607G = true;
        if (c1057b.f13605E != mode) {
            c1057b.f13605E = mode;
            this.f13650s.setTintMode(mode);
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean setVisible(boolean z8, boolean z9) {
        boolean zJ = j(z8, z9);
        X1 x12 = this.f13645F;
        if (x12 != null && (zJ || z9)) {
            if (z8) {
                x12.L();
                return zJ;
            }
            jumpToCurrentState();
        }
        return zJ;
    }

    @Override // android.graphics.drawable.Drawable.Callback
    public final void unscheduleDrawable(Drawable drawable, Runnable runnable) {
        if (drawable != this.f13650s || getCallback() == null) {
            return;
        }
        getCallback().unscheduleDrawable(this, runnable);
    }
}
