package o;

import android.os.Bundle;
import java.util.Arrays;
import java.util.Map;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.l40, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1735l40 {
    public final C1830m40 a;
    public final C1640k40 b;

    public C1735l40(C1830m40 c1830m40) {
        this.a = c1830m40;
        this.b = new C1640k40(c1830m40);
    }

    public final void a(Bundle bundle) {
        C1830m40 c1830m40 = this.a;
        InterfaceC1925n40 interfaceC1925n40 = c1830m40.a;
        if (!c1830m40.e) {
            c1830m40.a();
        }
        if (interfaceC1925n40.getLifecycle().b().a(VK.f372o)) {
            throw new IllegalStateException(("performRestore cannot be called when owner is " + interfaceC1925n40.getLifecycle().b()).toString());
        }
        if (c1830m40.g) {
            throw new IllegalStateException("SavedStateRegistry was already restored.");
        }
        Bundle bundleF = null;
        if (bundle != null && bundle.containsKey("androidx.lifecycle.BundlableSavedStateRegistry.key")) {
            bundleF = Co0.F("androidx.lifecycle.BundlableSavedStateRegistry.key", bundle);
        }
        c1830m40.f = bundleF;
        c1830m40.g = true;
    }

    public final void b(Bundle bundle) {
        C1830m40 c1830m40 = this.a;
        Bundle bundleF = AbstractC0940cn0.f((C3001yV[]) Arrays.copyOf(new C3001yV[0], 0));
        Bundle bundle2 = c1830m40.f;
        if (bundle2 != null) {
            bundleF.putAll(bundle2);
        }
        synchronized (c1830m40.c) {
            for (Map.Entry entry : c1830m40.d.entrySet()) {
                bundleF.putBundle((String) entry.getKey(), ((InterfaceC1545j40) entry.getValue()).a());
            }
        }
        if (bundleF.isEmpty()) {
            return;
        }
        bundle.putBundle("androidx.lifecycle.BundlableSavedStateRegistry.key", bundleF);
    }
}
