package o; import android.os.Bundle; import androidx.savedstate.Recreator; import java.util.Iterator; import java.util.Map; import o.FNE; import o.InterfaceC16541pFg; import o.hFr; import o.wdQ; /* loaded from: classes.dex */ public final class FNE { private Recreator.LWm a; private boolean b; private boolean c; private final hFr d = new hFr<>(); private boolean e = true; private Bundle h; /* loaded from: classes.dex */ public interface IeS { void d(InterfaceC9254dgJ interfaceC9254dgJ); } /* loaded from: classes.dex */ public interface Sts { Bundle AK_(); } public final Bundle AH_(String str) { C14957gcv.e(str, ""); if (!this.c) { throw new IllegalStateException("You can consumeRestoredStateForKey only after super.onCreate of corresponding component".toString()); } Bundle bundle = this.h; if (bundle == null) { return null; } Bundle bundle2 = bundle != null ? bundle.getBundle(str) : null; Bundle bundle3 = this.h; if (bundle3 != null) { bundle3.remove(str); } Bundle bundle4 = this.h; if (bundle4 == null || bundle4.isEmpty()) { this.h = null; } return bundle2; } public final void a(String str, Sts sts) { C14957gcv.e(str, ""); C14957gcv.e(sts, ""); if (this.d.a(str, sts) != null) { throw new IllegalArgumentException("SavedStateProvider with the given key is already registered".toString()); } } public final Sts a(String str) { C14957gcv.e(str, ""); Iterator> it = this.d.iterator(); while (it.hasNext()) { Map.Entry next = it.next(); C14957gcv.c(next, ""); String key = next.getKey(); Sts value = next.getValue(); if (C14957gcv.b((Object) key, (Object) str)) { return value; } } return null; } public final void e(Class cls) { C14957gcv.e(cls, ""); if (!this.e) { throw new IllegalStateException("Can not perform this action after onSaveInstanceState".toString()); } Recreator.LWm lWm = this.a; if (lWm == null) { lWm = new Recreator.LWm(this); } this.a = lWm; try { cls.getDeclaredConstructor(new Class[0]); Recreator.LWm lWm2 = this.a; if (lWm2 != null) { String name = cls.getName(); C14957gcv.c((Object) name, ""); C14957gcv.e(name, ""); lWm2.d.add(name); } } catch (NoSuchMethodException e) { StringBuilder sb = new StringBuilder("Class "); sb.append(cls.getSimpleName()); sb.append(" must have default constructor in order to be automatically recreated"); throw new IllegalArgumentException(sb.toString(), e); } } public final void a(wdQ wdq) { C14957gcv.e(wdq, ""); if (!(!this.b)) { throw new IllegalStateException("SavedStateRegistry was already attached.".toString()); } wdq.e(new InterfaceC3451axm(this) { // from class: androidx.savedstate.SavedStateRegistry$$ExternalSyntheticLambda0 public final FNE d; @Override // o.InterfaceC3451axm public final void c(InterfaceC16541pFg interfaceC16541pFg, wdQ.HBt hBt) { FNE.e(this.d, interfaceC16541pFg, hBt); } { this.d = this; } }); this.b = true; } public final void AI_(Bundle bundle) { if (!this.b) { throw new IllegalStateException("You must call performAttach() before calling performRestore(Bundle).".toString()); } if (!(!this.c)) { throw new IllegalStateException("SavedStateRegistry was already restored.".toString()); } this.h = bundle != null ? bundle.getBundle("androidx.lifecycle.BundlableSavedStateRegistry.key") : null; this.c = true; } public final void AJ_(Bundle bundle) { C14957gcv.e(bundle, ""); Bundle bundle2 = new Bundle(); Bundle bundle3 = this.h; if (bundle3 != null) { bundle2.putAll(bundle3); } hFr hfr = this.d; hFr.IeS ieS = new hFr.IeS(hfr); hfr.c.put(ieS, Boolean.FALSE); C14957gcv.c(ieS, ""); hFr.IeS ieS2 = ieS; while (ieS2.hasNext()) { Map.Entry next = ieS2.next(); bundle2.putBundle((String) next.getKey(), ((Sts) next.getValue()).AK_()); } if (bundle2.isEmpty()) { return; } bundle.putBundle("androidx.lifecycle.BundlableSavedStateRegistry.key", bundle2); } /* loaded from: classes.dex */ static final class HBt { private HBt() { } public /* synthetic */ HBt(byte b) { this(); } } public static /* synthetic */ void e(FNE fne, InterfaceC16541pFg interfaceC16541pFg, wdQ.HBt hBt) { C14957gcv.e(fne, ""); C14957gcv.e(interfaceC16541pFg, ""); C14957gcv.e(hBt, ""); if (hBt == wdQ.HBt.ON_START) { fne.e = true; } else if (hBt == wdQ.HBt.ON_STOP) { fne.e = false; } } static { new HBt((byte) 0); } }