package androidx.lifecycle;

import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Size;
import android.util.SizeF;
import android.util.SparseArray;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import p006b1.C0481i;
import p009c1.C0518w;
import p011d0.C0604g;
import p039m1.C1468e;
import p039m1.C1470g;
import p065v0.C1755c;
import p066v1.InterfaceC1763a;

/* renamed from: androidx.lifecycle.y */
/* loaded from: classes.dex */
public final class C0453y {

    /* renamed from: f */
    public static final C0454a f1665f = new C0454a(null);

    /* renamed from: g */
    public static final Class<? extends Object>[] f1666g;

    /* renamed from: a */
    public final Map<String, Object> f1667a = new LinkedHashMap();

    /* renamed from: b */
    public final Map<String, C1755c.InterfaceC1758c> f1668b = new LinkedHashMap();

    /* renamed from: c */
    public final Map<String, Object> f1669c = new LinkedHashMap();

    /* renamed from: d */
    public final Map<String, InterfaceC1763a<Object>> f1670d = new LinkedHashMap();

    /* renamed from: e */
    public final C1755c.InterfaceC1758c f1671e = new C1755c.InterfaceC1758c() { // from class: androidx.lifecycle.x
        @Override // p065v0.C1755c.InterfaceC1758c
        /* renamed from: a */
        public final Bundle mo461a() {
            Bundle m3645d;
            m3645d = C0453y.m3645d(C0453y.this);
            return m3645d;
        }
    };

    /* renamed from: androidx.lifecycle.y$a */
    /* loaded from: classes.dex */
    public static final class C0454a {
        public C0454a() {
        }

        public /* synthetic */ C0454a(C1468e c1468e) {
            this();
        }

        /* renamed from: a */
        public final boolean m3643a(Object obj) {
            Class[] clsArr;
            if (obj == null) {
                return true;
            }
            for (Class cls : C0453y.f1666g) {
                C1470g.m1295b(cls);
                if (cls.isInstance(obj)) {
                    return true;
                }
            }
            return false;
        }
    }

    static {
        Class<? extends Object>[] clsArr = new Class[29];
        clsArr[0] = Boolean.TYPE;
        clsArr[1] = boolean[].class;
        clsArr[2] = Double.TYPE;
        clsArr[3] = double[].class;
        Class<SizeF> cls = Integer.TYPE;
        clsArr[4] = cls;
        clsArr[5] = int[].class;
        clsArr[6] = Long.TYPE;
        clsArr[7] = long[].class;
        clsArr[8] = String.class;
        clsArr[9] = String[].class;
        clsArr[10] = Binder.class;
        clsArr[11] = Bundle.class;
        clsArr[12] = Byte.TYPE;
        clsArr[13] = byte[].class;
        clsArr[14] = Character.TYPE;
        clsArr[15] = char[].class;
        clsArr[16] = CharSequence.class;
        clsArr[17] = CharSequence[].class;
        clsArr[18] = ArrayList.class;
        clsArr[19] = Float.TYPE;
        clsArr[20] = float[].class;
        clsArr[21] = Parcelable.class;
        clsArr[22] = Parcelable[].class;
        clsArr[23] = Serializable.class;
        clsArr[24] = Short.TYPE;
        clsArr[25] = short[].class;
        clsArr[26] = SparseArray.class;
        int i = Build.VERSION.SDK_INT;
        clsArr[27] = i >= 21 ? Size.class : cls;
        if (i >= 21) {
            cls = SizeF.class;
        }
        clsArr[28] = cls;
        f1666g = clsArr;
    }

    /* renamed from: d */
    public static final Bundle m3645d(C0453y c0453y) {
        C1470g.m1292e(c0453y, "this$0");
        for (Map.Entry entry : C0518w.m3573i(c0453y.f1668b).entrySet()) {
            c0453y.m3644e((String) entry.getKey(), ((C1755c.InterfaceC1758c) entry.getValue()).mo461a());
        }
        Set<String> keySet = c0453y.f1667a.keySet();
        ArrayList arrayList = new ArrayList(keySet.size());
        ArrayList arrayList2 = new ArrayList(arrayList.size());
        for (String str : keySet) {
            arrayList.add(str);
            arrayList2.add(c0453y.f1667a.get(str));
        }
        return C0604g.m3282a(C0481i.m3620a("keys", arrayList), C0481i.m3620a("values", arrayList2));
    }

    /* renamed from: c */
    public final C1755c.InterfaceC1758c m3646c() {
        return this.f1671e;
    }

    /* renamed from: e */
    public final <T> void m3644e(String str, T t) {
        C1470g.m1292e(str, "key");
        if (!f1665f.m3643a(t)) {
            StringBuilder sb = new StringBuilder();
            sb.append("Can't put value with type ");
            C1470g.m1295b(t);
            sb.append(t.getClass());
            sb.append(" into saved state");
            throw new IllegalArgumentException(sb.toString());
        }
        Object obj = this.f1669c.get(str);
        C0440r c0440r = obj instanceof C0440r ? (C0440r) obj : null;
        if (c0440r != null) {
            c0440r.mo701h(t);
        } else {
            this.f1667a.put(str, t);
        }
        InterfaceC1763a<Object> interfaceC1763a = this.f1670d.get(str);
        if (interfaceC1763a == null) {
            return;
        }
        interfaceC1763a.setValue(t);
    }
}