package h0;

import B0.RunnableC0014a;
import F5.C0115b;
import O1.C0225a;
import android.app.Application;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Bundle;
import androidx.lifecycle.C0518x;
import androidx.lifecycle.EnumC0509n;
import androidx.lifecycle.InterfaceC0505j;
import java.util.LinkedHashMap;
import r0.C1484c;

/* JADX INFO: loaded from: classes.dex */
public final class Y implements InterfaceC0505j, U1.e, androidx.lifecycle.a0 {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final ComponentCallbacksC1023x f13136q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final androidx.lifecycle.Z f13137r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final RunnableC0014a f13138s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public androidx.lifecycle.Y f13139t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public C0518x f13140u = null;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public C0225a f13141v = null;

    public Y(ComponentCallbacksC1023x componentCallbacksC1023x, androidx.lifecycle.Z z8, RunnableC0014a runnableC0014a) {
        this.f13136q = componentCallbacksC1023x;
        this.f13137r = z8;
        this.f13138s = runnableC0014a;
    }

    @Override // androidx.lifecycle.InterfaceC0516v
    public final O3.e C() {
        c();
        return this.f13140u;
    }

    @Override // androidx.lifecycle.InterfaceC0505j
    public final androidx.lifecycle.Y H() {
        Application application;
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13136q;
        androidx.lifecycle.Y yH = componentCallbacksC1023x.H();
        if (!yH.equals(componentCallbacksC1023x.f13288i0)) {
            this.f13139t = yH;
            return yH;
        }
        if (this.f13139t == null) {
            Context applicationContext = componentCallbacksC1023x.Z().getApplicationContext();
            while (true) {
                if (!(applicationContext instanceof ContextWrapper)) {
                    application = null;
                    break;
                }
                if (applicationContext instanceof Application) {
                    application = (Application) applicationContext;
                    break;
                }
                applicationContext = ((ContextWrapper) applicationContext).getBaseContext();
            }
            this.f13139t = new androidx.lifecycle.T(application, componentCallbacksC1023x, componentCallbacksC1023x.f13298v);
        }
        return this.f13139t;
    }

    @Override // androidx.lifecycle.InterfaceC0505j
    public final C1484c a() {
        Application application;
        ComponentCallbacksC1023x componentCallbacksC1023x = this.f13136q;
        Context applicationContext = componentCallbacksC1023x.Z().getApplicationContext();
        while (true) {
            if (!(applicationContext instanceof ContextWrapper)) {
                application = null;
                break;
            }
            if (applicationContext instanceof Application) {
                application = (Application) applicationContext;
                break;
            }
            applicationContext = ((ContextWrapper) applicationContext).getBaseContext();
        }
        C1484c c1484c = new C1484c(0);
        LinkedHashMap linkedHashMap = c1484c.f16348a;
        if (application != null) {
            linkedHashMap.put(androidx.lifecycle.X.f8819e, application);
        }
        linkedHashMap.put(androidx.lifecycle.P.f8797a, componentCallbacksC1023x);
        linkedHashMap.put(androidx.lifecycle.P.f8798b, this);
        Bundle bundle = componentCallbacksC1023x.f13298v;
        if (bundle != null) {
            linkedHashMap.put(androidx.lifecycle.P.f8799c, bundle);
        }
        return c1484c;
    }

    public final void b(EnumC0509n enumC0509n) {
        this.f13140u.H(enumC0509n);
    }

    public final void c() {
        if (this.f13140u == null) {
            this.f13140u = new C0518x(this);
            V1.a aVar = new V1.a(this, new C0115b(3, this));
            this.f13141v = new C0225a(aVar, 15);
            aVar.a();
            this.f13138s.run();
        }
    }

    @Override // U1.e
    public final C0225a h() {
        c();
        return (C0225a) this.f13141v.f5011s;
    }

    @Override // androidx.lifecycle.a0
    public final androidx.lifecycle.Z r() {
        c();
        return this.f13137r;
    }
}
