package defpackage;

import android.os.Bundle;
import android.os.DeadObjectException;
import android.text.TextUtils;
import android.util.Log;
import ar.tvplayer.core.data.network.parse.ʽˈˋ;
import ar.tvplayer.core.domain.ˏːˆ;
import j$.util.Objects;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: renamed from: ˑᵸˉᵳ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class CallableC2147 implements Callable {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final /* synthetic */ C2780 f8521;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final /* synthetic */ Object f8522;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final /* synthetic */ int f8523;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final /* synthetic */ Object f8524;

    public /* synthetic */ CallableC2147(C2780 c2780, Object obj, Object obj2, int i) {
        this.f8523 = i;
        this.f8521 = c2780;
        this.f8522 = obj;
        this.f8524 = obj2;
    }

    public CallableC2147(C2780 c2780, InterfaceC2480 interfaceC2480, String str) {
        this.f8523 = 3;
        this.f8524 = interfaceC2480;
        this.f8522 = str;
        Objects.requireNonNull(c2780);
        this.f8521 = c2780;
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    private final Object m5663() {
        InterfaceC1506 interfaceC1506;
        C2780 c2780 = this.f8521;
        ʽˈˋ r1 = (ʽˈˋ) this.f8522;
        C2571 c2571 = (C2571) this.f8524;
        try {
            if (!c2780.m6726(ᵸᵺᵜ.ᵝᵶ)) {
                c2780.m6734(2, 3, AbstractC4228.f16126);
                boolean z = ˏːˆ.ᵲᵶᵳˈ;
                return null;
            }
            if (TextUtils.isEmpty(c2571.f9935)) {
                int i = AbstractC2252.f8911;
                Log.isLoggable("BillingClient", 5);
                c2780.m6734(26, 3, AbstractC4228.f16128);
                boolean z2 = ˏːˆ.ᵲᵶᵳˈ;
                return null;
            }
            if (!c2780.f10673) {
                c2780.m6734(27, 3, AbstractC4228.f16127);
                boolean z3 = ˏːˆ.ᵲᵶᵳˈ;
                return null;
            }
            synchronized (c2780.f10680) {
                interfaceC1506 = c2780.f10701;
            }
            if (interfaceC1506 == null) {
                c2780.m6715(r1, AbstractC4228.f16126, 107, null);
                return null;
            }
            String packageName = c2780.f10698.getPackageName();
            String str = c2571.f9935;
            String str2 = c2780.f10686;
            long jLongValue = c2780.f10674.longValue();
            int i2 = AbstractC2252.f8911;
            Bundle bundle = new Bundle();
            AbstractC2252.m5865(bundle, str2, jLongValue);
            Bundle bundleM10302 = ((C4987) interfaceC1506).m10302(packageName, str, bundle);
            AbstractC4228.m9200(AbstractC2252.m5869("BillingClient", bundleM10302), AbstractC2252.m5873("BillingClient", bundleM10302));
            boolean z4 = ˏːˆ.ᵲᵶᵳˈ;
            return null;
        } catch (DeadObjectException e) {
            c2780.m6715(r1, AbstractC4228.f16126, 28, e);
            return null;
        } catch (Exception e2) {
            c2780.m6715(r1, AbstractC4228.f16117, 28, e2);
            return null;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:25:0x00ae, code lost:
    
        r0 = r1.m6728(defpackage.AbstractC4228.f16126, 107, r4);
     */
    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private final Object m5664() {
        C1404 c1404;
        int i;
        InterfaceC1506 interfaceC1506;
        AbstractC1707 abstractC1707;
        ArrayList arrayList;
        C2780 c2780 = this.f8521;
        InterfaceC1621 interfaceC1621 = (InterfaceC1621) this.f8522;
        ᵢʒʡᵟ r0 = (ᵢʒʡᵟ) this.f8524;
        Exception exc = null;
        if (!c2780.m6726(ᵸᵺᵜ.ᵝᵶ)) {
            C1591 c1591 = AbstractC4228.f16126;
            c2780.m6734(2, 7, c1591);
            C0092 c0092 = AbstractC1707.f6825;
            interfaceC1621.m4473(c1591, new C5401(C4767.f18145));
            return null;
        }
        if (!c2780.f10675) {
            int i2 = AbstractC2252.f8911;
            Log.isLoggable("BillingClient", 5);
            C1591 c15912 = AbstractC4228.f16121;
            c2780.m6734(20, 7, c15912);
            C0092 c00922 = AbstractC1707.f6825;
            interfaceC1621.m4473(c15912, new C5401(C4767.f18145));
            return null;
        }
        ArrayList arrayList2 = new ArrayList();
        ArrayList arrayList3 = new ArrayList();
        int i3 = 0;
        String str = ((C5050) ((AbstractC1707) r0.ᵜᵪʾ).get(0)).f19091;
        AbstractC1707 abstractC17072 = (AbstractC1707) r0.ᵜᵪʾ;
        int size = abstractC17072.size();
        int i4 = 0;
        while (true) {
            if (i4 >= size) {
                c1404 = new C1404(0, "", arrayList2, arrayList3);
                break;
            }
            int i5 = i4 + 20;
            ArrayList arrayList4 = new ArrayList(abstractC17072.subList(i4, i5 > size ? size : i5));
            ArrayList<String> arrayList5 = new ArrayList<>();
            int size2 = arrayList4.size();
            for (int i6 = i3; i6 < size2; i6++) {
                arrayList5.add(((C5050) arrayList4.get(i6)).f19092);
            }
            Bundle bundle = new Bundle();
            bundle.putStringArrayList("ITEM_ID_LIST", arrayList5);
            bundle.putString("playBillingLibraryVersion", c2780.f10684);
            try {
                synchronized (c2780.f10680) {
                    try {
                        interfaceC1506 = c2780.f10701;
                    } finally {
                        th = th;
                        i = 43;
                        while (true) {
                            try {
                            } catch (Throwable th) {
                                th = th;
                            }
                        }
                    }
                }
                if (interfaceC1506 == null) {
                    break;
                }
                if (c2780.f10685) {
                    c2780.f10679.getClass();
                }
                c2780.m6732();
                c2780.m6732();
                c2780.m6732();
                c2780.m6732();
                int i7 = size;
                ArrayList arrayList6 = arrayList4;
                try {
                    Bundle bundleM10301 = ((C4987) interfaceC1506).m10301(true != c2780.f10683 ? 17 : 20, c2780.f10698.getPackageName(), str, bundle, AbstractC2252.m5871(c2780.f10686, arrayList4, new ᵨᵡᵱ(16), c2780.f10674.longValue()));
                    if (bundleM10301 == null) {
                        c1404 = c2780.m6728(AbstractC4228.f16125, 44, null);
                        break;
                    }
                    if (bundleM10301.containsKey("DETAILS_LIST")) {
                        ArrayList<String> stringArrayList = bundleM10301.getStringArrayList("DETAILS_LIST");
                        if (stringArrayList == null) {
                            c1404 = c2780.m6728(AbstractC4228.f16125, 46, null);
                            break;
                        }
                        ArrayList arrayList7 = new ArrayList();
                        int size3 = stringArrayList.size();
                        for (int i8 = 0; i8 < size3; i8++) {
                            try {
                                C1434 c1434 = new C1434(stringArrayList.get(i8));
                                AbstractC2252.m5870("BillingClient", "Got product details: ".concat(c1434.toString()));
                                arrayList7.add(c1434);
                            } catch (JSONException e) {
                                c1404 = c2780.m6728(AbstractC4228.m9200(6, "Error trying to decode SkuDetails."), 47, e);
                            }
                        }
                        ArrayList<String> stringArrayList2 = bundleM10301.getStringArrayList("UNFETCHED_PRODUCT_LIST");
                        new ArrayList();
                        try {
                            ArrayList arrayList8 = new ArrayList();
                            if (stringArrayList2 != null) {
                                int size4 = stringArrayList2.size();
                                int i9 = 0;
                                while (i9 < size4) {
                                    String str2 = stringArrayList2.get(i9);
                                    i9++;
                                    C0696 c0696 = new C0696(str2);
                                    AbstractC2252.m5870("BillingClient", "Got unfetchedProduct: ".concat(c0696.toString()));
                                    arrayList8.add(c0696);
                                }
                            } else {
                                int size5 = arrayList6.size();
                                int i10 = 0;
                                while (i10 < size5) {
                                    Object obj = arrayList6.get(i10);
                                    i10++;
                                    C5050 c5050 = (C5050) obj;
                                    int size6 = arrayList7.size();
                                    int i11 = 0;
                                    while (true) {
                                        if (i11 >= size6) {
                                            abstractC1707 = abstractC17072;
                                            arrayList = arrayList6;
                                            arrayList8.add(new C0696(new JSONObject().put("productId", c5050.f19092).put("type", c5050.f19091).put("statusCode", 0).toString()));
                                            break;
                                        }
                                        Object obj2 = arrayList7.get(i11);
                                        i11++;
                                        C1434 c14342 = (C1434) obj2;
                                        abstractC1707 = abstractC17072;
                                        arrayList = arrayList6;
                                        if (!c5050.f19092.equals(c14342.f5862) || !c5050.f19091.equals(c14342.f5866)) {
                                            abstractC17072 = abstractC1707;
                                            arrayList6 = arrayList;
                                        }
                                    }
                                    abstractC17072 = abstractC1707;
                                    arrayList6 = arrayList;
                                }
                            }
                            AbstractC1707 abstractC17073 = abstractC17072;
                            arrayList2.addAll(arrayList7);
                            arrayList3.addAll(arrayList8);
                            i4 = i5;
                            size = i7;
                            abstractC17072 = abstractC17073;
                            exc = null;
                            i3 = 0;
                        } catch (JSONException e2) {
                            c1404 = c2780.m6728(AbstractC4228.m9200(6, "Error trying to decode SkuDetails."), 47, e2);
                        }
                    } else {
                        int iM5869 = AbstractC2252.m5869("BillingClient", bundleM10301);
                        String strM5873 = AbstractC2252.m5873("BillingClient", bundleM10301);
                        if (iM5869 != 0) {
                            C1591 c1591M9200 = AbstractC4228.m9200(iM5869, strM5873);
                            ᵱˉˈ.ˁʢᵛ(iM5869, "getSkuDetails() failed for queryProductDetailsAsync. Response code: ");
                            c1404 = c2780.m6728(c1591M9200, 23, null);
                        } else {
                            c1404 = c2780.m6728(AbstractC4228.m9200(6, strM5873), 45, null);
                        }
                    }
                } catch (DeadObjectException e3) {
                    e = e3;
                    c1404 = c2780.m6728(AbstractC4228.f16126, i, e);
                } catch (Exception e4) {
                    e = e4;
                    c1404 = c2780.m6728(AbstractC4228.f16117, i, e);
                }
            } catch (DeadObjectException e5) {
                e = e5;
                i = 43;
            } catch (Exception e6) {
                e = e6;
                i = 43;
            }
        }
        interfaceC1621.m4473(AbstractC4228.m9200(c1404.f5808, (String) c1404.f5809), new C5401((ArrayList) c1404.f5807));
        return null;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    private final Object m5665() {
        Bundle bundleM5867;
        InterfaceC1506 interfaceC1506;
        C2780 c2780 = this.f8521;
        String str = (String) this.f8522;
        String str2 = (String) this.f8524;
        try {
            synchronized (c2780.f10680) {
                interfaceC1506 = c2780.f10701;
            }
            if (interfaceC1506 == null) {
                return AbstractC2252.m5867(AbstractC4228.f16126, 107);
            }
            return ((C4987) interfaceC1506).m10298(c2780.f10698.getPackageName(), str, str2);
        } catch (DeadObjectException e) {
            C1591 c1591 = AbstractC4228.f16126;
            String strM8522 = AbstractC3817.m8522(e);
            bundleM5867 = AbstractC2252.m5867(c1591, 5);
            if (strM8522 != null) {
                bundleM5867.putString("ADDITIONAL_LOG_DETAILS", strM8522);
            }
            return bundleM5867;
        } catch (Exception e2) {
            C1591 c15912 = AbstractC4228.f16117;
            String strM85222 = AbstractC3817.m8522(e2);
            bundleM5867 = AbstractC2252.m5867(c15912, 5);
            if (strM85222 != null) {
                bundleM5867.putString("ADDITIONAL_LOG_DETAILS", strM85222);
            }
            return bundleM5867;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:22:0x009a, code lost:
    
        r17 = r3;
     */
    /* JADX WARN: Removed duplicated region for block: B:100:0x0239  */
    /* JADX WARN: Removed duplicated region for block: B:101:0x023d  */
    /* JADX WARN: Removed duplicated region for block: B:120:0x015b A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:67:0x0161  */
    @Override // java.util.concurrent.Callable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object call() throws Throwable {
        Exception exc;
        ʽᵺᴵ r0;
        List list;
        InterfaceC1506 interfaceC1506;
        C1591 c1591M3754;
        int i;
        switch (this.f8523) {
            case 0:
                return m5665();
            case 1:
                return m5663();
            case 2:
                return m5664();
            default:
                C2780 c2780 = this.f8521;
                Exception exc2 = null;
                int i2 = 9;
                if (c2780.m6726(ᵸᵺᵜ.ᵝᵶ)) {
                    String str = (String) this.f8522;
                    int i3 = 5;
                    if (!TextUtils.isEmpty(str)) {
                        AbstractC2252.m5870("BillingClient", "Querying owned items, item type: ".concat(String.valueOf(str)));
                        ArrayList arrayList = new ArrayList();
                        boolean z = c2780.f10673;
                        c2780.f10679.getClass();
                        c2780.f10679.getClass();
                        long jLongValue = c2780.f10674.longValue();
                        Bundle bundle = new Bundle();
                        AbstractC2252.m5865(bundle, c2780.f10686, jLongValue);
                        int i4 = 1;
                        if (z) {
                            bundle.putBoolean("enablePendingPurchases", true);
                        }
                        String string = null;
                        while (true) {
                            try {
                                synchronized (c2780.f10680) {
                                    try {
                                        interfaceC1506 = c2780.f10701;
                                        break;
                                    } catch (Throwable th) {
                                        th = th;
                                        exc = exc2;
                                        while (true) {
                                            try {
                                                try {
                                                    throw th;
                                                } catch (DeadObjectException e) {
                                                    e = e;
                                                    r0 = c2780.m6733(AbstractC4228.f16126, 52, e);
                                                    list = (List) r0.ᵜᵪʾ;
                                                    InterfaceC2480 interfaceC2480 = (InterfaceC2480) this.f8524;
                                                    C1591 c1591 = (C1591) r0.ᵔᵖᵹᵫ;
                                                    if (list != null) {
                                                    }
                                                } catch (Exception e2) {
                                                    e = e2;
                                                    r0 = c2780.m6733(AbstractC4228.f16117, 52, e);
                                                    list = (List) r0.ᵜᵪʾ;
                                                    InterfaceC2480 interfaceC24802 = (InterfaceC2480) this.f8524;
                                                    C1591 c15912 = (C1591) r0.ᵔᵖᵹᵫ;
                                                    if (list != null) {
                                                    }
                                                }
                                            } catch (Throwable th2) {
                                                th = th2;
                                            }
                                        }
                                    }
                                }
                                if (interfaceC1506 == null) {
                                    r0 = c2780.m6733(AbstractC4228.f16126, 107, exc2);
                                    break;
                                } else {
                                    Bundle bundleM10304 = c2780.f10673 ? ((C4987) interfaceC1506).m10304(c2780.f10690 ? 26 : c2780.f10700 ? 24 : c2780.f10685 ? 19 : i2, c2780.f10698.getPackageName(), str, string, bundle) : ((C4987) interfaceC1506).m10305(c2780.f10698.getPackageName(), str, string);
                                    C1591 c15913 = AbstractC4228.f16117;
                                    if (bundleM10304 == null) {
                                        Log.isLoggable("BillingClient", i3);
                                        i = 54;
                                    } else {
                                        int iM5869 = AbstractC2252.m5869("BillingClient", bundleM10304);
                                        String strM5873 = AbstractC2252.m5873("BillingClient", bundleM10304);
                                        C1260 c1260M4435 = C1591.m4435();
                                        c1260M4435.f5308 = iM5869;
                                        c1260M4435.f5307 = strM5873;
                                        c1591M3754 = c1260M4435.m3754();
                                        if (iM5869 != 0) {
                                            Log.isLoggable("BillingClient", i3);
                                            i = 23;
                                        } else if (bundleM10304.containsKey("INAPP_PURCHASE_ITEM_LIST") && bundleM10304.containsKey("INAPP_PURCHASE_DATA_LIST") && bundleM10304.containsKey("INAPP_DATA_SIGNATURE_LIST")) {
                                            ArrayList<String> stringArrayList = bundleM10304.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                                            ArrayList<String> stringArrayList2 = bundleM10304.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
                                            ArrayList<String> stringArrayList3 = bundleM10304.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
                                            if (stringArrayList == null) {
                                                Log.isLoggable("BillingClient", i3);
                                                i = 56;
                                            } else if (stringArrayList2 == null) {
                                                Log.isLoggable("BillingClient", i3);
                                                i = 57;
                                            } else if (stringArrayList3 == null) {
                                                Log.isLoggable("BillingClient", i3);
                                                i = 58;
                                            } else {
                                                c1591M3754 = AbstractC4228.f16131;
                                                i = i4;
                                            }
                                        } else {
                                            Log.isLoggable("BillingClient", i3);
                                            i = 55;
                                        }
                                        if (c1591M3754 == AbstractC4228.f16131) {
                                            r0 = c2780.m6733(c1591M3754, i, exc2);
                                            break;
                                        } else {
                                            ArrayList<String> stringArrayList4 = bundleM10304.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                                            ArrayList<String> stringArrayList5 = bundleM10304.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
                                            ArrayList<String> stringArrayList6 = bundleM10304.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
                                            exc = exc2;
                                            boolean z2 = false;
                                            for (int i5 = 0; i5 < stringArrayList5.size(); i5++) {
                                                String str2 = stringArrayList5.get(i5);
                                                String str3 = stringArrayList6.get(i5);
                                                AbstractC2252.m5870("BillingClient", "Sku is owned: ".concat(String.valueOf(stringArrayList4.get(i5))));
                                                try {
                                                    C5526 c5526 = new C5526(str2, str3);
                                                    c2780.f10695.isEmpty();
                                                    JSONObject jSONObject = c5526.f20854;
                                                    if (TextUtils.isEmpty(jSONObject.optString("token", jSONObject.optString("purchaseToken")))) {
                                                        i3 = 5;
                                                        Log.isLoggable("BillingClient", 5);
                                                        z2 = true;
                                                    } else {
                                                        i3 = 5;
                                                    }
                                                    arrayList.add(c5526);
                                                } catch (JSONException e3) {
                                                    r0 = c2780.m6733(AbstractC4228.f16117, 51, e3);
                                                }
                                            }
                                            if (z2) {
                                                i2 = 9;
                                                c2780.m6734(26, 9, c15913);
                                            } else {
                                                i2 = 9;
                                            }
                                            string = bundleM10304.getString("INAPP_CONTINUATION_TOKEN");
                                            AbstractC2252.m5870("BillingClient", "Continuation token: ".concat(String.valueOf(string)));
                                            if (TextUtils.isEmpty(string)) {
                                                r0 = new ʽᵺᴵ(AbstractC4228.f16131, 11, arrayList);
                                            } else {
                                                exc2 = exc;
                                                i4 = 1;
                                            }
                                        }
                                    }
                                    c1591M3754 = c15913;
                                    if (c1591M3754 == AbstractC4228.f16131) {
                                    }
                                }
                            } catch (DeadObjectException e4) {
                                e = e4;
                                exc = exc2;
                            } catch (Exception e5) {
                                e = e5;
                                exc = exc2;
                            }
                        }
                        list = (List) r0.ᵜᵪʾ;
                        InterfaceC2480 interfaceC248022 = (InterfaceC2480) this.f8524;
                        C1591 c159122 = (C1591) r0.ᵔᵖᵹᵫ;
                        if (list != null) {
                            interfaceC248022.m6225(c159122, list);
                            return exc;
                        }
                        C0092 c0092 = AbstractC1707.f6825;
                        interfaceC248022.m6225(c159122, C4767.f18145);
                        return exc;
                    }
                    int i6 = AbstractC2252.f8911;
                    Log.isLoggable("BillingClient", 5);
                    C1591 c15914 = AbstractC4228.f16122;
                    c2780.m6734(50, 9, c15914);
                    InterfaceC2480 interfaceC24803 = (InterfaceC2480) this.f8524;
                    C0092 c00922 = AbstractC1707.f6825;
                    interfaceC24803.m6225(c15914, C4767.f18145);
                } else {
                    C1591 c15915 = AbstractC4228.f16126;
                    c2780.m6734(2, 9, c15915);
                    InterfaceC2480 interfaceC24804 = (InterfaceC2480) this.f8524;
                    C0092 c00923 = AbstractC1707.f6825;
                    interfaceC24804.m6225(c15915, C4767.f18145);
                }
                return null;
        }
    }
}
