package o; import android.os.Binder; import android.os.Bundle; import android.os.IBinder; 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.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import o.FNE; /* loaded from: classes.dex */ public final class NER { public static final HBt c = new HBt(0); private static final Class[] d = {Boolean.TYPE, boolean[].class, Double.TYPE, double[].class, Integer.TYPE, int[].class, Long.TYPE, long[].class, String.class, String[].class, Binder.class, Bundle.class, Byte.TYPE, byte[].class, Character.TYPE, char[].class, CharSequence.class, CharSequence[].class, ArrayList.class, Float.TYPE, float[].class, Parcelable.class, Parcelable[].class, Serializable.class, Short.TYPE, short[].class, SparseArray.class, Size.class, SizeF.class}; private final Map> a; private final Map> b; public final FNE.Sts e; private final Map i; private final Map j; public NER(Map map) { C14957gcv.e(map, ""); LinkedHashMap linkedHashMap = new LinkedHashMap(); this.i = linkedHashMap; this.j = new LinkedHashMap(); this.b = new LinkedHashMap(); this.a = new LinkedHashMap(); this.e = new FNE.Sts(this) { // from class: o.vdi public final NER b; @Override // o.FNE.Sts public final Bundle AK_() { return NER.zw_(this.b); } { this.b = this; } }; linkedHashMap.putAll(map); } public NER() { this.i = new LinkedHashMap(); this.j = new LinkedHashMap(); this.b = new LinkedHashMap(); this.a = new LinkedHashMap(); this.e = new FNE.Sts(this) { // from class: o.vdi public final NER b; @Override // o.FNE.Sts public final Bundle AK_() { return NER.zw_(this.b); } { this.b = this; } }; } /* loaded from: classes.dex */ public static final class HBt { private HBt() { } public static NER zz_(Bundle bundle, Bundle bundle2) { if (bundle == null) { if (bundle2 == null) { return new NER(); } HashMap hashMap = new HashMap(); for (String str : bundle2.keySet()) { C14957gcv.c((Object) str, ""); hashMap.put(str, bundle2.get(str)); } return new NER(hashMap); } ArrayList parcelableArrayList = bundle.getParcelableArrayList("keys"); ArrayList parcelableArrayList2 = bundle.getParcelableArrayList("values"); if (parcelableArrayList == null || parcelableArrayList2 == null || parcelableArrayList.size() != parcelableArrayList2.size()) { throw new IllegalStateException("Invalid bundle passed as restored state".toString()); } LinkedHashMap linkedHashMap = new LinkedHashMap(); int size = parcelableArrayList.size(); for (int i = 0; i < size; i++) { Object obj = parcelableArrayList.get(i); if (obj == null) { throw new NullPointerException("null cannot be cast to non-null type kotlin.String"); } linkedHashMap.put((String) obj, parcelableArrayList2.get(i)); } return new NER(linkedHashMap); } public /* synthetic */ HBt(byte b) { this(); } } /* JADX WARN: Multi-variable type inference failed */ public static /* synthetic */ Bundle zw_(NER ner) { C14957gcv.e(ner, ""); Iterator it = C14856gaP.c(ner.j).entrySet().iterator(); while (true) { int i = 0; if (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String str = (String) entry.getKey(); Bundle AK_ = ((FNE.Sts) entry.getValue()).AK_(); C14957gcv.e(str, ""); if (AK_ != null) { Class[] clsArr = d; int length = clsArr.length; while (i < length) { Class cls = clsArr[i]; C14957gcv.e(cls); if (!cls.isInstance(AK_)) { i++; } } StringBuilder sb = new StringBuilder("Can't put value with type "); C14957gcv.e(AK_); sb.append(AK_.getClass()); sb.append(" into saved state"); throw new IllegalArgumentException(sb.toString()); } Object obj = ner.b.get(str); HeN heN = obj instanceof HeN ? (HeN) obj : null; if (heN != null) { heN.a((HeN) AK_); } else { ner.i.put(str, AK_); } ner.a.get(str); } else { Set keySet = ner.i.keySet(); ArrayList arrayList = new ArrayList(keySet.size()); ArrayList arrayList2 = new ArrayList(arrayList.size()); for (String str2 : keySet) { arrayList.add(str2); arrayList2.add(ner.i.get(str2)); } C13396fZU[] c13396fZUArr = {new C13396fZU("keys", arrayList), new C13396fZU("values", arrayList2)}; C14957gcv.e(c13396fZUArr, ""); Bundle bundle = new Bundle(2); while (i < 2) { C13396fZU c13396fZU = c13396fZUArr[i]; String str3 = (String) c13396fZU.d; B b = c13396fZU.e; if (b == 0) { bundle.putString(str3, null); } else if (b instanceof Boolean) { bundle.putBoolean(str3, ((Boolean) b).booleanValue()); } else if (b instanceof Byte) { bundle.putByte(str3, ((Number) b).byteValue()); } else if (b instanceof Character) { bundle.putChar(str3, ((Character) b).charValue()); } else if (b instanceof Double) { bundle.putDouble(str3, ((Number) b).doubleValue()); } else if (b instanceof Float) { bundle.putFloat(str3, ((Number) b).floatValue()); } else if (b instanceof Integer) { bundle.putInt(str3, ((Number) b).intValue()); } else if (b instanceof Long) { bundle.putLong(str3, ((Number) b).longValue()); } else if (b instanceof Short) { bundle.putShort(str3, ((Number) b).shortValue()); } else if (b instanceof Bundle) { bundle.putBundle(str3, (Bundle) b); } else if (b instanceof CharSequence) { bundle.putCharSequence(str3, (CharSequence) b); } else if (b instanceof Parcelable) { bundle.putParcelable(str3, (Parcelable) b); } else if (b instanceof boolean[]) { bundle.putBooleanArray(str3, (boolean[]) b); } else if (b instanceof byte[]) { bundle.putByteArray(str3, (byte[]) b); } else if (b instanceof char[]) { bundle.putCharArray(str3, (char[]) b); } else if (b instanceof double[]) { bundle.putDoubleArray(str3, (double[]) b); } else if (b instanceof float[]) { bundle.putFloatArray(str3, (float[]) b); } else if (b instanceof int[]) { bundle.putIntArray(str3, (int[]) b); } else if (b instanceof long[]) { bundle.putLongArray(str3, (long[]) b); } else if (b instanceof short[]) { bundle.putShortArray(str3, (short[]) b); } else if (b instanceof Object[]) { Class componentType = b.getClass().getComponentType(); C14957gcv.e(componentType); if (Parcelable.class.isAssignableFrom(componentType)) { C14957gcv.d(b, ""); bundle.putParcelableArray(str3, (Parcelable[]) b); } else if (String.class.isAssignableFrom(componentType)) { C14957gcv.d(b, ""); bundle.putStringArray(str3, (String[]) b); } else if (CharSequence.class.isAssignableFrom(componentType)) { C14957gcv.d(b, ""); bundle.putCharSequenceArray(str3, (CharSequence[]) b); } else if (Serializable.class.isAssignableFrom(componentType)) { bundle.putSerializable(str3, (Serializable) b); } else { String canonicalName = componentType.getCanonicalName(); StringBuilder sb2 = new StringBuilder("Illegal value array type "); sb2.append(canonicalName); sb2.append(" for key \""); sb2.append(str3); sb2.append('\"'); throw new IllegalArgumentException(sb2.toString()); } } else if (b instanceof Serializable) { bundle.putSerializable(str3, (Serializable) b); } else if (b instanceof IBinder) { Upe.qp_(bundle, str3, (IBinder) b); } else if (b instanceof Size) { C5910cCx.qq_(bundle, str3, (Size) b); } else if (b instanceof SizeF) { C5910cCx.qr_(bundle, str3, (SizeF) b); } else { String canonicalName2 = b.getClass().getCanonicalName(); StringBuilder sb3 = new StringBuilder("Illegal value type "); sb3.append(canonicalName2); sb3.append(" for key \""); sb3.append(str3); sb3.append('\"'); throw new IllegalArgumentException(sb3.toString()); } i++; } return bundle; } } } public static final NER zx_(Bundle bundle, Bundle bundle2) { return HBt.zz_(bundle, bundle2); } }