var ApplePaySessionStatus;
(function (ApplePaySessionStatus) {
    ApplePaySessionStatus["STATUS_SUCCESS"] = "STATUS_SUCCESS";
    ApplePaySessionStatus["STATUS_FAILURE"] = "STATUS_FAILURE";
})(ApplePaySessionStatus || (ApplePaySessionStatus = {}));
var ApplePayButtonType;
(function (ApplePayButtonType) {
    ApplePayButtonType["PLAIN"] = "plain";
    ApplePayButtonType["BUY"] = "buy";
    ApplePayButtonType["SET_UP"] = "set-up";
    ApplePayButtonType["DONATE"] = "donate";
    ApplePayButtonType["CHECK_OUT"] = "check-out";
    ApplePayButtonType["BOOK"] = "book";
    ApplePayButtonType["SUBSCRIBE"] = "subscribe";
})(ApplePayButtonType || (ApplePayButtonType = {}));
var ApplePayButtonStyle;
(function (ApplePayButtonStyle) {
    ApplePayButtonStyle["BLACK"] = "black";
    ApplePayButtonStyle["WHITE"] = "white";
    ApplePayButtonStyle["WHITE_OUTLINE"] = "white-outline";
})(ApplePayButtonStyle || (ApplePayButtonStyle = {}));
var ApplePayMerchantCapability;
(function (ApplePayMerchantCapability) {
    ApplePayMerchantCapability["SUPPORTS_3DS"] = "supports3DS";
    ApplePayMerchantCapability["SUPPORTS_EMV"] = "supportsEMV";
    ApplePayMerchantCapability["SUPPORTS_CREDIT"] = "supportsCredit";
    ApplePayMerchantCapability["SUPPORTS_DEBIT"] = "supportsDebit";
})(ApplePayMerchantCapability || (ApplePayMerchantCapability = {}));
class ApplePayConfig {
    constructor(data) {
        this.merchantIdentifier = data.merchantIdentifier;
        this.displayName = data.displayName;
        this.initiative = data.initiative;
        this.initiativeContext = data.initiativeContext;
        this.buttonType = data.buttonType || ApplePayButtonType.PLAIN;
        this.buttonStyle = data.buttonStyle || ApplePayButtonStyle.BLACK;
        this.buttonLocale = data.buttonLocale || 'en-US';
    }
    get isValid() {
        return !!(this.merchantIdentifier &&
            this.displayName &&
            this.initiative &&
            this.initiativeContext);
    }
}
class ApplePayPaymentRequest {
    constructor(data) {
        this.countryCode = data.countryCode;
        this.currencyCode = data.currencyCode;
        this.merchantCapabilities = data.merchantCapabilities;
        this.supportedNetworks = data.supportedNetworks;
        this.total = data.total;
        this.lineItems = data.lineItems;
        this.shippingMethods = data.shippingMethods;
        this.applicationData = data.applicationData;
        this.supportedCountries = data.supportedCountries;
    }
    get isValid() {
        var _a, _b, _c, _d;
        return !!(this.countryCode &&
            this.currencyCode &&
            ((_a = this.merchantCapabilities) === null || _a === void 0 ? void 0 : _a.length) &&
            ((_b = this.supportedNetworks) === null || _b === void 0 ? void 0 : _b.length) &&
            ((_c = this.total) === null || _c === void 0 ? void 0 : _c.label) &&
            ((_d = this.total) === null || _d === void 0 ? void 0 : _d.amount));
    }
}
class ApplePayHelpers {
    static isApplePaySupported() {
        var _a;
        return (typeof window !== 'undefined' &&
            'ApplePaySession' in window &&
            ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.supportsVersion(3)));
    }
    static canMakePayments() {
        var _a;
        if (!this.isApplePaySupported()) {
            return false;
        }
        return ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.canMakePayments()) || false;
    }
    static async canMakePaymentsWithActiveCard(merchantIdentifier) {
        var _a;
        if (!this.isApplePaySupported()) {
            return false;
        }
        try {
            return ((await ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.canMakePaymentsWithActiveCard(merchantIdentifier))) || false);
        }
        catch (error) {
            console.error('Error checking Apple Pay active card:', error);
            return false;
        }
    }
    static formatAmount(amount) {
        return (amount / 100).toFixed(2);
    }
    static parseAmount(amount) {
        return Math.round(parseFloat(amount) * 100);
    }
    static createLineItem(label, amount, type = 'final') {
        return {
            label,
            amount: this.formatAmount(amount),
            type,
        };
    }
    static getDefaultSupportedNetworks() {
        return ['amex', 'discover', 'masterCard', 'visa'];
    }
    static getDefaultMerchantCapabilities() {
        return [
            ApplePayMerchantCapability.SUPPORTS_3DS,
            ApplePayMerchantCapability.SUPPORTS_EMV,
            ApplePayMerchantCapability.SUPPORTS_CREDIT,
            ApplePayMerchantCapability.SUPPORTS_DEBIT,
        ];
    }
}

export { ApplePayConfig as A, ApplePayHelpers as a, ApplePayPaymentRequest as b, ApplePaySessionStatus as c, ApplePayButtonStyle as d, ApplePayButtonType as e, ApplePayMerchantCapability as f };
