package ca.canadapost.core.common.customView;

import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.firebase.messaging.Constants;
import java.util.List;
import kotlin.Metadata;

@Metadata(d1 = {"\u0000P\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0015\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\r\n\u0002\b\u0014\n\u0002\u0010\u000b\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0007\u0018\u0000 A2\u00020\u0001:\u00017B1\b\u0007\u0012\u0006\u0010:\u001a\u000209\u0012\n\b\u0002\u0010<\u001a\u0004\u0018\u00010;\u0012\b\b\u0002\u0010=\u001a\u00020\u0004\u0012\b\b\u0002\u0010>\u001a\u00020\u0004¢\u0006\u0004\b?\u0010@J\b\u0010\u0003\u001a\u00020\u0002H\u0002J\u0010\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0005\u001a\u00020\u0004H\u0014R\u0014\u0010\u000b\u001a\u00020\b8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\t\u0010\nR\u0014\u0010\u000f\u001a\u00020\f8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\r\u0010\u000eR\u0014\u0010\u0011\u001a\u00020\f8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0010\u0010\u000eR\u0014\u0010\u0013\u001a\u00020\f8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0012\u0010\u000eR\u0014\u0010\u0017\u001a\u00020\u00148\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0015\u0010\u0016R\u0014\u0010\u0019\u001a\u00020\u00148\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0018\u0010\u0016R.\u0010\"\u001a\u0004\u0018\u00010\u001a2\b\u0010\u001b\u001a\u0004\u0018\u00010\u001a8\u0006@FX\u0086\u000e¢\u0006\u0012\n\u0004\b\u001c\u0010\u001d\u001a\u0004\b\u001e\u0010\u001f\"\u0004\b \u0010!R.\u0010&\u001a\u0004\u0018\u00010\u001a2\b\u0010\u001b\u001a\u0004\u0018\u00010\u001a8\u0006@FX\u0086\u000e¢\u0006\u0012\n\u0004\b#\u0010\u001d\u001a\u0004\b$\u0010\u001f\"\u0004\b%\u0010!R.\u0010*\u001a\u0004\u0018\u00010\u001a2\b\u0010\u001b\u001a\u0004\u0018\u00010\u001a8\u0006@FX\u0086\u000e¢\u0006\u0012\n\u0004\b'\u0010\u001d\u001a\u0004\b(\u0010\u001f\"\u0004\b)\u0010!R.\u0010.\u001a\u0004\u0018\u00010\u001a2\b\u0010\u001b\u001a\u0004\u0018\u00010\u001a8\u0006@FX\u0086\u000e¢\u0006\u0012\n\u0004\b+\u0010\u001d\u001a\u0004\b,\u0010\u001f\"\u0004\b-\u0010!R*\u00106\u001a\u00020/2\u0006\u0010\u001b\u001a\u00020/8\u0006@FX\u0086\u000e¢\u0006\u0012\n\u0004\b0\u00101\u001a\u0004\b2\u00103\"\u0004\b4\u00105R\u0014\u00108\u001a\u00020/8BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b7\u00103¨\u0006B"}, d2 = {"Lca/canadapost/core/common/customView/CpcCardView;", "Landroid/widget/LinearLayout;", "Lrm/n0;", "b", "", "extraSpace", "", "onCreateDrawableState", "Landroid/view/ViewGroup;", "p", "Landroid/view/ViewGroup;", "container", "Landroid/widget/TextView;", "q", "Landroid/widget/TextView;", "titleView", "r", "descriptionView", "s", "subTextView", "Landroid/widget/ImageView;", "t", "Landroid/widget/ImageView;", "arrowImg", "u", "errorImg", "", "value", "v", "Ljava/lang/CharSequence;", "getTitle", "()Ljava/lang/CharSequence;", "setTitle", "(Ljava/lang/CharSequence;)V", "title", "w", "getDescription", "setDescription", "description", "x", "getInfo", "setInfo", "info", "y", "getError", "setError", Constants.IPC_BUNDLE_KEY_SEND_ERROR, "", "z", "Z", "getActionable", "()Z", "setActionable", "(Z)V", "actionable", "a", "isError", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "defStyle", "defStyleRes", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;II)V", "A", "core_common_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes.dex */
public final class CpcCardView extends LinearLayout {
    public static final int B = 8;
    private static final int[] C;

    /* renamed from: p, reason: collision with root package name and from kotlin metadata */
    private final ViewGroup container;

    /* renamed from: q, reason: collision with root package name and from kotlin metadata */
    private final TextView titleView;

    /* renamed from: r, reason: collision with root package name and from kotlin metadata */
    private final TextView descriptionView;

    /* renamed from: s, reason: collision with root package name and from kotlin metadata */
    private final TextView subTextView;

    /* renamed from: t, reason: collision with root package name and from kotlin metadata */
    private final ImageView arrowImg;

    /* renamed from: u, reason: collision with root package name and from kotlin metadata */
    private final ImageView errorImg;

    /* renamed from: v, reason: collision with root package name and from kotlin metadata */
    private CharSequence title;

    /* renamed from: w, reason: collision with root package name and from kotlin metadata */
    private CharSequence description;

    /* renamed from: x, reason: collision with root package name and from kotlin metadata */
    private CharSequence info;

    /* renamed from: y, reason: collision with root package name and from kotlin metadata */
    private CharSequence error;

    /* renamed from: z, reason: collision with root package name and from kotlin metadata */
    private boolean actionable;

    static {
        List e10;
        int[] R0;
        e10 = sm.t.e(Integer.valueOf(h7.e.f20958a));
        R0 = sm.c0.R0(e10);
        C = R0;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public CpcCardView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0, 0, 12, null);
        kotlin.jvm.internal.t.g(context, "context");
    }

    private final boolean a() {
        CharSequence charSequence = this.error;
        return !(charSequence == null || charSequence.length() == 0);
    }

    /* JADX WARN: Code restructure failed: missing block: B:11:0x0027, code lost:
    
        if ((r1 == null || r1.length() == 0) == false) goto L16;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private final void b() {
        int i10 = 8;
        this.errorImg.setVisibility(a() ? 0 : 8);
        TextView textView = this.subTextView;
        if (!a()) {
            CharSequence charSequence = this.info;
        }
        i10 = 0;
        textView.setVisibility(i10);
        this.subTextView.setText(a() ? this.error : this.info);
        refreshDrawableState();
    }

    public final boolean getActionable() {
        return this.actionable;
    }

    public final CharSequence getDescription() {
        return this.description;
    }

    public final CharSequence getError() {
        return this.error;
    }

    public final CharSequence getInfo() {
        return this.info;
    }

    public final CharSequence getTitle() {
        return this.title;
    }

    @Override // android.view.ViewGroup, android.view.View
    protected int[] onCreateDrawableState(int extraSpace) {
        if (!a()) {
            int[] onCreateDrawableState = super.onCreateDrawableState(extraSpace);
            kotlin.jvm.internal.t.f(onCreateDrawableState, "onCreateDrawableState(...)");
            return onCreateDrawableState;
        }
        int[] iArr = C;
        int[] onCreateDrawableState2 = super.onCreateDrawableState(extraSpace + iArr.length);
        kotlin.jvm.internal.t.f(onCreateDrawableState2, "onCreateDrawableState(...)");
        View.mergeDrawableStates(onCreateDrawableState2, iArr);
        return onCreateDrawableState2;
    }

    public final void setActionable(boolean z10) {
        this.actionable = z10;
        this.arrowImg.setVisibility(z10 ? 0 : 8);
        if (!this.actionable) {
            this.container.setForeground(new ColorDrawable(R.color.transparent));
            return;
        }
        TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(new int[]{h7.e.f20959b});
        kotlin.jvm.internal.t.f(obtainStyledAttributes, "obtainStyledAttributes(...)");
        this.container.setForeground(obtainStyledAttributes.getDrawable(0));
        obtainStyledAttributes.recycle();
    }

    public final void setDescription(CharSequence charSequence) {
        this.description = charSequence;
        this.descriptionView.setText(charSequence);
    }

    public final void setError(CharSequence charSequence) {
        this.error = charSequence;
        b();
    }

    public final void setInfo(CharSequence charSequence) {
        this.info = charSequence;
        b();
    }

    public final void setTitle(CharSequence charSequence) {
        this.title = charSequence;
        this.titleView.setText(charSequence);
    }

    public /* synthetic */ CpcCardView(Context context, AttributeSet attributeSet, int i10, int i11, int i12, kotlin.jvm.internal.k kVar) {
        this(context, (i12 & 2) != 0 ? null : attributeSet, (i12 & 4) != 0 ? 0 : i10, (i12 & 8) != 0 ? 0 : i11);
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public CpcCardView(Context context, AttributeSet attributeSet, int i10, int i11) {
        super(context, attributeSet, i10, i11);
        kotlin.jvm.internal.t.g(context, "context");
        this.title = "";
        this.description = "";
        this.info = "";
        this.error = "";
        View inflate = LayoutInflater.from(context).inflate(h7.j.f21091f, this);
        View findViewById = inflate.findViewById(h7.i.f21068r);
        kotlin.jvm.internal.t.f(findViewById, "findViewById(...)");
        this.container = (ViewGroup) findViewById;
        View findViewById2 = inflate.findViewById(h7.i.L0);
        kotlin.jvm.internal.t.f(findViewById2, "findViewById(...)");
        this.titleView = (TextView) findViewById2;
        View findViewById3 = inflate.findViewById(h7.i.f21082y);
        kotlin.jvm.internal.t.f(findViewById3, "findViewById(...)");
        this.descriptionView = (TextView) findViewById3;
        View findViewById4 = inflate.findViewById(h7.i.F0);
        kotlin.jvm.internal.t.f(findViewById4, "findViewById(...)");
        this.subTextView = (TextView) findViewById4;
        View findViewById5 = inflate.findViewById(h7.i.f21042e);
        kotlin.jvm.internal.t.f(findViewById5, "findViewById(...)");
        this.arrowImg = (ImageView) findViewById5;
        View findViewById6 = inflate.findViewById(h7.i.A);
        kotlin.jvm.internal.t.f(findViewById6, "findViewById(...)");
        this.errorImg = (ImageView) findViewById6;
        if (attributeSet != null) {
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, h7.n.Y, 0, 0);
            kotlin.jvm.internal.t.f(obtainStyledAttributes, "obtainStyledAttributes(...)");
            String string = obtainStyledAttributes.getString(h7.n.f21264d0);
            if (string != null) {
                setTitle(string);
            }
            String string2 = obtainStyledAttributes.getString(h7.n.f21249a0);
            if (string2 != null) {
                setDescription(string2);
            }
            String string3 = obtainStyledAttributes.getString(h7.n.f21259c0);
            if (string3 != null) {
                setInfo(string3);
            }
            String string4 = obtainStyledAttributes.getString(h7.n.f21254b0);
            if (string4 != null) {
                setError(string4);
            }
            setActionable(obtainStyledAttributes.getBoolean(h7.n.Z, false));
            obtainStyledAttributes.recycle();
        }
    }
}
