package com.revenuecat.purchases.amazon;

import J4.c;
import com.revenuecat.purchases.common.BackendHelper;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import kotlin.jvm.internal.o;
import w4.k;
import x4.AbstractC3250p;
import x4.AbstractC3252r;

/* JADX INFO: loaded from: classes3.dex */
public final class AmazonBackend {
    private final BackendHelper backendHelper;
    private volatile Map<List<String>, List<k>> postAmazonReceiptCallbacks;

    public AmazonBackend(BackendHelper backendHelper) {
        o.h(backendHelper, "backendHelper");
        this.backendHelper = backendHelper;
        this.postAmazonReceiptCallbacks = new LinkedHashMap();
    }

    public final void getAmazonReceiptData(String receiptId, String storeUserID, c onSuccess, c onError) {
        o.h(receiptId, "receiptId");
        o.h(storeUserID, "storeUserID");
        o.h(onSuccess, "onSuccess");
        o.h(onError, "onError");
        List<String> listK = AbstractC3250p.K(new String[]{receiptId, storeUserID});
        AmazonBackend$getAmazonReceiptData$call$1 amazonBackend$getAmazonReceiptData$call$1 = new AmazonBackend$getAmazonReceiptData$call$1(this, storeUserID, receiptId, listK);
        k kVar = new k(onSuccess, onError);
        synchronized (this) {
            try {
                if (this.postAmazonReceiptCallbacks.containsKey(listK)) {
                    List<k> list = this.postAmazonReceiptCallbacks.get(listK);
                    o.e(list);
                    list.add(kVar);
                } else {
                    this.postAmazonReceiptCallbacks.put(listK, AbstractC3252r.C(kVar));
                    amazonBackend$getAmazonReceiptData$call$1.invoke();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final synchronized Map<List<String>, List<k>> getPostAmazonReceiptCallbacks() {
        return this.postAmazonReceiptCallbacks;
    }

    public final synchronized void setPostAmazonReceiptCallbacks(Map<List<String>, List<k>> map) {
        o.h(map, "<set-?>");
        this.postAmazonReceiptCallbacks = map;
    }
}
