package m4;

import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.concurrent.atomic.AtomicReference;
import k4.AbstractC2384C;
import k4.AbstractC2397j;
import k4.C2394g;
import k4.C2407u;

/* JADX INFO: loaded from: classes3.dex */
public final class P0 extends AbstractC2384C {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final String f20719b;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ S0 f20721d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final AtomicReference f20718a = new AtomicReference(S0.f20760j0);

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final M0 f20720c = new M0(this);

    public P0(S0 s02, String str) {
        this.f20721d = s02;
        A4.g.o(str, "authority");
        this.f20719b = str;
    }

    @Override // k4.AbstractC2384C
    public final AbstractC2397j l(k4.i0 i0Var, C2394g c2394g) {
        AtomicReference atomicReference = this.f20718a;
        Object obj = atomicReference.get();
        D0 d02 = S0.f20760j0;
        if (obj != d02) {
            return s(i0Var, c2394g);
        }
        S0 s02 = this.f20721d;
        s02.f20800m.execute(new N0(this, 2));
        if (atomicReference.get() != d02) {
            return s(i0Var, c2394g);
        }
        if (s02.f20768G.get()) {
            return new H(2);
        }
        O0 o02 = new O0(this, C2407u.b(), i0Var, c2394g);
        s02.f20800m.execute(new E(this, o02));
        return o02;
    }

    public final AbstractC2397j s(k4.i0 i0Var, C2394g c2394g) {
        k4.H h5 = (k4.H) this.f20718a.get();
        M0 m02 = this.f20720c;
        if (h5 == null) {
            return m02.l(i0Var, c2394g);
        }
        if (!(h5 instanceof X0)) {
            return new I0(h5, m02, this.f20721d.f20796h, i0Var, c2394g);
        }
        Y0 y02 = ((X0) h5).f20909b;
        y02.getClass();
        W0 w02 = (W0) y02.f20915b.get(i0Var.f19879b);
        if (w02 == null) {
            w02 = (W0) y02.f20916c.get(i0Var.f19880c);
        }
        if (w02 == null) {
            w02 = y02.f20914a;
        }
        if (w02 != null) {
            c2394g = c2394g.c(W0.f20895g, w02);
        }
        return m02.l(i0Var, c2394g);
    }

    public final void t(k4.H h5) {
        LinkedHashSet linkedHashSet;
        AtomicReference atomicReference = this.f20718a;
        k4.H h6 = (k4.H) atomicReference.get();
        atomicReference.set(h5);
        if (h6 != S0.f20760j0 || (linkedHashSet = this.f20721d.f20763B) == null) {
            return;
        }
        Iterator it = linkedHashSet.iterator();
        while (it.hasNext()) {
            ((O0) it.next()).d();
        }
    }
}
