package defpackage;

import android.os.Looper;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.common.api.UnsupportedApiCallException;
import com.google.common.util.concurrent.ListenableFuture;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicReferenceArray;

/* renamed from: ˋﹶʣᵘ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C1557 implements InterfaceC4273, InterfaceC3610, InterfaceC4607 {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public Object f6204;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public Object f6205;

    public /* synthetic */ C1557(Object obj) {
        this.f6204 = obj;
    }

    public /* synthetic */ C1557(Object obj, Object obj2) {
        this.f6205 = obj;
        this.f6204 = obj2;
    }

    public /* synthetic */ C1557(Object obj, Object obj2, boolean z) {
        this.f6204 = obj;
        this.f6205 = obj2;
    }

    public C1557(C2954 c2954, int i) {
        this.f6204 = c2954;
        this.f6205 = new AtomicReferenceArray(i);
    }

    @Override // defpackage.InterfaceC4607
    public ListenableFuture call() {
        C3953 c3953 = (C3953) this.f6204;
        RunnableC5529 runnableC5529M4194 = c3953.f14926.m4194("Initialize ".concat(String.valueOf(c3953.f14924)));
        try {
            synchronized (c3953.f14920) {
                try {
                    if (((List) this.f6205) == null) {
                        this.f6205 = c3953.f14923;
                        c3953.f14923 = Collections.EMPTY_LIST;
                    }
                } catch (Throwable th) {
                    throw th;
                }
            }
            ArrayList arrayList = new ArrayList(((List) this.f6205).size());
            C2301 c2301 = new C2301((C3953) this.f6204);
            Iterator it = ((List) this.f6205).iterator();
            while (it.hasNext()) {
                try {
                    arrayList.add(((InterfaceC1293) it.next()).apply(c2301));
                } catch (Exception e) {
                    arrayList.add(AbstractC2725.m6767(e));
                }
            }
            AbstractC2692 abstractC2692M6693 = AbstractC2692.m6693(arrayList);
            CallableC3631 callableC3631 = new CallableC3631(4, this);
            C3960 c3960 = new C3960(abstractC2692M6693, true);
            c3960.f14940 = new C3643(c3960, callableC3631);
            c3960.m8762();
            runnableC5529M4194.m11147(c3960);
            runnableC5529M4194.close();
            return c3960;
        } catch (Throwable th2) {
            try {
                runnableC5529M4194.close();
            } catch (Throwable th3) {
                th2.addSuppressed(th3);
            }
            throw th2;
        }
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public void m4518(ArrayList arrayList) {
        OutputStream outputStream = (OutputStream) ᵯˉˋ.ᵨᵳʝ(arrayList);
        if (outputStream instanceof C4003) {
            this.f6204 = (C4003) outputStream;
            this.f6205 = (OutputStream) arrayList.get(0);
        }
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public void m4519(C0030 c0030, C1601 c1601) {
        C4484 c4484 = new C4484(c1601);
        TreeMap treeMap = (TreeMap) this.f6205;
        for (Integer num : treeMap.keySet()) {
            C4587 c4587M9734 = ((C4587) c1601.f6355).clone();
            InterfaceC0401 interfaceC0401Mo1546 = ((C3456) treeMap.get(num)).mo1546(c0030, Collections.singletonList(c4484));
            int i = interfaceC0401Mo1546 instanceof C0845 ? ᵭʝʜ.ˁˑᵰ(((C0845) interfaceC0401Mo1546).f3878.doubleValue()) : -1;
            if (i == 2 || i == -1) {
                c1601.f6355 = c4587M9734;
            }
        }
        TreeMap treeMap2 = (TreeMap) this.f6204;
        Iterator it = treeMap2.keySet().iterator();
        while (it.hasNext()) {
            InterfaceC0401 interfaceC0401Mo15462 = ((C3456) treeMap2.get((Integer) it.next())).mo1546(c0030, Collections.singletonList(c4484));
            if (interfaceC0401Mo15462 instanceof C0845) {
                ᵭʝʜ.ˁˑᵰ(((C0845) interfaceC0401Mo15462).f3878.doubleValue());
            }
        }
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public AbstractC4400 m4520(long j, int i, String str) {
        AtomicReferenceArray atomicReferenceArray = (AtomicReferenceArray) this.f6205;
        AbstractC4400 abstractC4400 = (AbstractC4400) atomicReferenceArray.get(i);
        if (abstractC4400 != null) {
            return abstractC4400;
        }
        C5278 c5278 = new C5278(str, (C0262) ((C2954) this.f6204).f11438, j);
        while (!atomicReferenceArray.compareAndSet(i, null, c5278)) {
            if (atomicReferenceArray.get(i) != null) {
                AbstractC4400 abstractC44002 = (AbstractC4400) atomicReferenceArray.get(i);
                abstractC44002.getClass();
                return abstractC44002;
            }
        }
        return c5278;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public void m4521(C4997 c4997, int i) {
        ((C0030) this.f6204).m1023(new RunnableC2769((C1812) this.f6205, c4997, false, i));
    }

    @Override // defpackage.InterfaceC3610
    /* renamed from: ᵝᵵᵺ */
    public Object mo1888(C3921 c3921) {
        boolean z = c3921.m8707() instanceof UnsupportedApiCallException;
        C2426 c2426 = (C2426) this.f6204;
        C2182 c2182 = (C2182) this.f6205;
        if (z) {
            return c2182.m5832(c2426.m6204());
        }
        if (c3921.m8707() instanceof ApiException) {
            ApiException apiException = (ApiException) c3921.m8707();
            apiException.getClass();
            if (apiException.f1016.f1020 == 29514) {
                return c2182.m5832(c2426.m6204());
            }
        }
        return c3921;
    }

    @Override // defpackage.InterfaceC4273
    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public void mo4522(C3297 c3297) {
        AbstractC1845.m5207("BillingClient", "Reconnection finished with result: " + c3297.f12347);
        try {
            ((C4861) this.f6205).m10185(c3297);
        } catch (Throwable unused) {
            AbstractC1845.m5213("BillingClient");
        }
        C3768 c3768 = (C3768) this.f6204;
        if (c3768.f14076 != null) {
            Runnable runnable = new ﹶᴵ(this, 7, c3297);
            if (Looper.myLooper() == Looper.getMainLooper()) {
                runnable.run();
            } else {
                c3768.f14056.post(runnable);
            }
        }
    }

    @Override // defpackage.InterfaceC4273
    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public void mo4523() {
        AbstractC1845.m5207("BillingClient", "Reconnection attempt failed.");
        try {
            ((C4861) this.f6205).m10185(AbstractC5497.f20622);
        } catch (Throwable unused) {
            AbstractC1845.m5213("BillingClient");
        }
        C3768 c3768 = (C3768) this.f6204;
        if (c3768.f14076 != null) {
            RunnableC5339 runnableC5339 = new RunnableC5339(3, this);
            if (Looper.myLooper() == Looper.getMainLooper()) {
                runnableC5339.run();
            } else {
                c3768.f14056.post(runnableC5339);
            }
        }
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public AbstractC4400 m4524(int i, String str, String str2) {
        AtomicReferenceArray atomicReferenceArray = (AtomicReferenceArray) this.f6205;
        AbstractC4400 abstractC4400 = (AbstractC4400) atomicReferenceArray.get(i);
        if (abstractC4400 != null) {
            return abstractC4400;
        }
        C0193 c0193 = new C0193(str, (C0262) ((C2954) this.f6204).f11438, str2);
        while (!atomicReferenceArray.compareAndSet(i, null, c0193)) {
            if (atomicReferenceArray.get(i) != null) {
                AbstractC4400 abstractC44002 = (AbstractC4400) atomicReferenceArray.get(i);
                abstractC44002.getClass();
                return abstractC44002;
            }
        }
        return c0193;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public AbstractC4400 m4525(int i, String str, boolean z) {
        AtomicReferenceArray atomicReferenceArray = (AtomicReferenceArray) this.f6205;
        AbstractC4400 abstractC4400 = (AbstractC4400) atomicReferenceArray.get(i);
        if (abstractC4400 != null) {
            return abstractC4400;
        }
        C3913 c3913M7228 = ((C2954) this.f6204).m7228(str, z);
        while (!atomicReferenceArray.compareAndSet(i, null, c3913M7228)) {
            if (atomicReferenceArray.get(i) != null) {
                AbstractC4400 abstractC44002 = (AbstractC4400) atomicReferenceArray.get(i);
                abstractC44002.getClass();
                return abstractC44002;
            }
        }
        return c3913M7228;
    }
}
