package androidx.lifecycle;

import android.os.Looper;
import j.C2301a;
import java.util.Map;
import k.C2367c;
import k.C2368d;
import k.C2370f;

/* JADX INFO: loaded from: classes.dex */
public abstract class E {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public static final Object f12086k = new Object();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Object f12087a = new Object();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final C2370f f12088b = new C2370f();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f12089c = 0;

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public volatile Object f12091e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public volatile Object f12092f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f12093g;

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final A f12096j;

    public E() {
        Object obj = f12086k;
        this.f12092f = obj;
        this.f12096j = new A(this);
        this.f12091e = obj;
        this.f12093g = -1;
    }

    public static void a(String str) {
        C2301a.Y().f19425n.getClass();
        if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
            throw new IllegalStateException(Z0.o.o("Cannot invoke ", str, " on a background thread"));
        }
    }

    public final void b(D d6) {
        if (d6.f12083b) {
            if (!d6.e()) {
                d6.b(false);
                return;
            }
            int i6 = d6.f12084c;
            int i7 = this.f12093g;
            if (i6 >= i7) {
                return;
            }
            d6.f12084c = i7;
            d6.f12082a.a(this.f12091e);
        }
    }

    public final void c(D d6) {
        if (this.f12094h) {
            this.f12095i = true;
            return;
        }
        this.f12094h = true;
        do {
            this.f12095i = false;
            if (d6 != null) {
                b(d6);
                d6 = null;
            } else {
                C2370f c2370f = this.f12088b;
                c2370f.getClass();
                C2368d c2368d = new C2368d(c2370f);
                c2370f.f19615c.put(c2368d, Boolean.FALSE);
                while (c2368d.hasNext()) {
                    b((D) ((Map.Entry) c2368d.next()).getValue());
                    if (this.f12095i) {
                        break;
                    }
                }
            }
        } while (this.f12095i);
        this.f12094h = false;
    }

    public final void d(InterfaceC1113w interfaceC1113w, G g6) {
        Object obj;
        a("observe");
        if (interfaceC1113w.getLifecycle().getCurrentState() == EnumC1108q.f12180a) {
            return;
        }
        C c6 = new C(this, interfaceC1113w, g6);
        C2370f c2370f = this.f12088b;
        C2367c c2367cE = c2370f.e(g6);
        if (c2367cE != null) {
            obj = c2367cE.f19607b;
        } else {
            C2367c c2367c = new C2367c(g6, c6);
            c2370f.f19616d++;
            C2367c c2367c2 = c2370f.f19614b;
            if (c2367c2 == null) {
                c2370f.f19613a = c2367c;
                c2370f.f19614b = c2367c;
            } else {
                c2367c2.f19608c = c2367c;
                c2367c.f19609d = c2367c2;
                c2370f.f19614b = c2367c;
            }
            obj = null;
        }
        D d6 = (D) obj;
        if (d6 != null && !d6.d(interfaceC1113w)) {
            throw new IllegalArgumentException("Cannot add the same observer with different lifecycles");
        }
        if (d6 != null) {
            return;
        }
        interfaceC1113w.getLifecycle().addObserver(c6);
    }

    public void e() {
    }

    public void f() {
    }

    public void g(G g6) {
        a("removeObserver");
        D d6 = (D) this.f12088b.g(g6);
        if (d6 == null) {
            return;
        }
        d6.c();
        d6.b(false);
    }

    public abstract void h(Object obj);
}
