package b.l;

import android.annotation.SuppressLint;
import android.os.Bundle;
import androidx.savedstate.Recreator;

/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"RestrictedApi"})
public final class a {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Bundle f1307b;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Recreator.a f1309d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public b.c.a.b.b<String, b> f1306a = new b.c.a.b.b<>();

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f1310e = true;

    /* JADX INFO: renamed from: b.l.a$a, reason: collision with other inner class name */
    public interface InterfaceC0024a {
        void a(c cVar);
    }

    public interface b {
        Bundle a();
    }

    public Bundle a(String str) {
        if (!this.f1308c) {
            throw new IllegalStateException("You can consumeRestoredStateForKey only after super.onCreate of corresponding component");
        }
        Bundle bundle = this.f1307b;
        if (bundle == null) {
            return null;
        }
        Bundle bundle2 = bundle.getBundle(str);
        this.f1307b.remove(str);
        if (this.f1307b.isEmpty()) {
            this.f1307b = null;
        }
        return bundle2;
    }

    public void b(String str, b bVar) {
        if (this.f1306a.d(str, bVar) != null) {
            throw new IllegalArgumentException("SavedStateProvider with the given key is already registered");
        }
    }

    public void c(Class<? extends InterfaceC0024a> cls) {
        if (!this.f1310e) {
            throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
        }
        if (this.f1309d == null) {
            this.f1309d = new Recreator.a(this);
        }
        try {
            cls.getDeclaredConstructor(new Class[0]);
            Recreator.a aVar = this.f1309d;
            aVar.f191a.add(cls.getName());
        } catch (NoSuchMethodException e2) {
            StringBuilder sbD = c.a.a.a.a.d("Class");
            sbD.append(cls.getSimpleName());
            sbD.append(" must have default constructor in order to be automatically recreated");
            throw new IllegalArgumentException(sbD.toString(), e2);
        }
    }
}
