package com.revenuecat.purchases.google;

import C0.B;
import I2.C;
import I2.C0317a;
import I2.C0340y;
import I2.C0341z;
import T.p;
import com.google.android.gms.internal.play_billing.zzbt;
import com.revenuecat.purchases.LogHandler;
import com.revenuecat.purchases.common.LogWrapperKt;
import java.util.ArrayList;
import java.util.Set;
import kotlin.jvm.internal.o;
import x4.AbstractC3253s;

/* JADX INFO: loaded from: classes3.dex */
public final class BillingClientParamBuildersKt {
    public static final C0341z buildQueryProductDetailsParams(String str, Set<String> productIds) throws QueryProductDetailsParamsBuilderException {
        o.h(str, "<this>");
        o.h(productIds, "productIds");
        Set<String> set = productIds;
        ArrayList arrayList = new ArrayList(AbstractC3253s.G(set, 10));
        for (String str2 : set) {
            p pVar = new p(11, false);
            pVar.f6345b = str2;
            pVar.f6346c = str;
            if ("first_party".equals(str)) {
                throw new IllegalArgumentException("Serialized doc id must be provided for first party products.");
            }
            if (((String) pVar.f6345b) == null) {
                throw new IllegalArgumentException("Product id must be provided.");
            }
            arrayList.add(new C0340y(pVar));
        }
        try {
            B b5 = new B(10, false);
            b5.v(arrayList);
            if (((zzbt) b5.f506b) != null) {
                return new C0341z(b5);
            }
            throw new IllegalArgumentException("Product list must be set to a non empty list.");
        } catch (ExceptionInInitializerError e6) {
            LogHandler currentLogHandler = LogWrapperKt.getCurrentLogHandler();
            StringBuilder sb = new StringBuilder("Error while building QueryProductDetailsParams in Billing client: ");
            sb.append(e6.getMessage());
            sb.append(". Caused by: ");
            Throwable cause = e6.getCause();
            sb.append(cause != null ? cause.getMessage() : null);
            currentLogHandler.e("[Purchases] - ERROR", sb.toString(), e6);
            throw new QueryProductDetailsParamsBuilderException("Error while building QueryProductDetailsParams in Billing client", e6.getCause());
        }
    }

    public static final I2.B buildQueryPurchaseHistoryParams(String str) {
        o.h(str, "<this>");
        if (str.equals("inapp") ? true : str.equals("subs")) {
            return new I2.B();
        }
        return null;
    }

    public static final C buildQueryPurchasesParams(String str) {
        o.h(str, "<this>");
        if (!(str.equals("inapp") ? true : str.equals("subs"))) {
            return null;
        }
        C0317a c0317a = new C0317a(2);
        c0317a.f2580b = str;
        return new C(c0317a);
    }
}
