//#region ../../payments/display/src/brands.ts
const PAYMENT_ICON_BASE_URL = "https://assets.fluid.app/images/payment_icons";
const GENERIC_PAYMENT_ICON_URL = `${PAYMENT_ICON_BASE_URL}/generic.svg`;
const CARD_BRANDS = new Set([
	"visa",
	"mastercard",
	"amex",
	"discover",
	"jcb",
	"maestro"
]);
const WALLET_BRANDS = new Set([
	"apple_pay",
	"google_pay",
	"samsung_pay"
]);
const SUPPORTED_WALLET_BADGE_BRANDS = new Set(["apple_pay", "google_pay"]);
const CARD_BRAND_NAME = {
	visa: "Visa",
	mastercard: "Mastercard",
	amex: "American Express",
	discover: "Discover",
	jcb: "JCB",
	maestro: "Maestro"
};
const WALLET_BRAND_NAME = {
	apple_pay: "Apple Pay",
	google_pay: "Google Pay",
	samsung_pay: "Samsung Pay"
};
const APM_BRAND_NAME = {
	paypal: "PayPal",
	venmo: "Venmo",
	klarna: "Klarna",
	affirm: "Affirm",
	afterpay: "Afterpay",
	bread: "Bread",
	skrill: "Skrill",
	ideal: "iDEAL",
	bancontact: "Bancontact",
	eps: "EPS",
	blik: "BLIK",
	trustly: "Trustly",
	oxxo: "OXXO",
	pix: "Pix",
	yape: "Yape",
	satispay: "Satispay",
	alipay: "Alipay",
	unionpay: "UnionPay",
	gcash: "GCash",
	grabpay: "GrabPay",
	maya: "Maya",
	upi: "UPI"
};
const BRAND_ALIASES = {
	visa: "visa",
	mastercard: "mastercard",
	master: "mastercard",
	"master card": "mastercard",
	mc: "mastercard",
	amex: "amex",
	"american express": "amex",
	americanexpress: "amex",
	discover: "discover",
	disc: "discover",
	jcb: "jcb",
	maestro: "maestro",
	"international maestro": "maestro",
	"uk maestro": "maestro",
	paypal: "paypal",
	venmo: "venmo",
	"apple pay": "apple_pay",
	applepay: "apple_pay",
	"google pay": "google_pay",
	googlepay: "google_pay",
	"samsung pay": "samsung_pay",
	samsungpay: "samsung_pay",
	klarna: "klarna",
	affirm: "affirm",
	afterpay: "afterpay",
	clearpay: "afterpay",
	bread: "bread",
	skrill: "skrill",
	ideal: "ideal",
	bancontact: "bancontact",
	eps: "eps",
	blik: "blik",
	trustly: "trustly",
	oxxo: "oxxo",
	pix: "pix",
	yape: "yape",
	satispay: "satispay",
	alipay: "alipay",
	unionpay: "unionpay",
	gcash: "gcash",
	grabpay: "grabpay",
	maya: "maya",
	paymaya: "maya",
	upi: "upi",
	"upi india": "upi"
};
const BRAND_ASSET_SLUG = {
	visa: "visa",
	mastercard: "master",
	amex: "american_express",
	discover: "discover",
	jcb: "jcb",
	maestro: "maestro",
	apple_pay: "apple_pay",
	google_pay: "google_pay",
	samsung_pay: "samsung_pay",
	paypal: "paypal",
	venmo: "venmo",
	klarna: "klarna",
	affirm: "affirm",
	afterpay: "afterpay",
	bread: "bread",
	skrill: "skrill",
	ideal: "ideal",
	bancontact: "bancontact",
	eps: "eps",
	blik: "blik",
	trustly: "trustly",
	oxxo: "oxxo",
	pix: "pix",
	yape: "yape",
	satispay: "satispay",
	alipay: "alipay",
	unionpay: "unionpay",
	gcash: "gcash",
	grabpay: "grabpay",
	maya: "maya",
	upi: "upi"
};
function normalizeBrand(raw) {
	const key = normalizeBrandKey(raw);
	if (!key) return null;
	return BRAND_ALIASES[key] ?? null;
}
function brandIconUrl(brand) {
	const canonical = normalizeBrand(brand);
	if (!canonical) return GENERIC_PAYMENT_ICON_URL;
	return `${PAYMENT_ICON_BASE_URL}/${BRAND_ASSET_SLUG[canonical]}.svg`;
}
function getPaymentBrandName(brand) {
	const canonical = normalizeBrand(brand);
	if (!canonical) return null;
	const cardBrand = normalizeCardBrand(canonical);
	if (cardBrand) return CARD_BRAND_NAME[cardBrand];
	const walletBrand = normalizeWalletBrand(canonical);
	if (walletBrand) return WALLET_BRAND_NAME[walletBrand];
	const apmBrand = normalizeApmBrand(canonical);
	return apmBrand ? APM_BRAND_NAME[apmBrand] : null;
}
function apmBrandName(raw) {
	const canonical = normalizeApmBrand(raw);
	return canonical ? APM_BRAND_NAME[canonical] : null;
}
function normalizeCardBrand(brand) {
	const canonical = normalizeBrand(brand);
	return canonical != null && CARD_BRANDS.has(canonical) ? canonical : null;
}
function normalizeWalletBrand(brand) {
	const canonical = normalizeBrand(brand);
	return canonical != null && WALLET_BRANDS.has(canonical) ? canonical : null;
}
function normalizeSupportedWalletBadgeBrand(brand) {
	const canonical = normalizeBrand(brand);
	return canonical != null && SUPPORTED_WALLET_BADGE_BRANDS.has(canonical) ? canonical : null;
}
function normalizeApmBrand(brand) {
	const canonical = normalizeBrand(brand);
	return canonical != null && canonical in APM_BRAND_NAME ? canonical : null;
}
function isGenericCardLabel(value) {
	const key = normalizeBrandKey(value)?.replace(/\s+/g, "_");
	return key === "card" || key === "credit_card";
}
function normalizeBrandKey(raw) {
	const key = raw?.trim().toLowerCase().replace(/[_-]+/g, " ").replace(/\s+/g, " ");
	return key ? key : null;
}
//#endregion
//#region ../../payments/display/src/display.ts
const APM_IDENTIFIER_CLASS = {
	paypal: "email",
	venmo: "handle",
	upi: "handle",
	ideal: "bank",
	bancontact: "bank",
	eps: "bank",
	klarna: "none",
	affirm: "none",
	afterpay: "none",
	bread: "none",
	skrill: "email",
	blik: "none",
	trustly: "none",
	oxxo: "none",
	pix: "none",
	yape: "none",
	satispay: "none",
	alipay: "none",
	unionpay: "none",
	gcash: "none",
	grabpay: "none",
	maya: "none"
};
const DEFAULT_PAYMENT_ALT = "Payment method";
const MASK_DOT = "•";
const PAYMENT_TYPE_LABELS = {
	card: "Credit Card",
	credit_card: "Credit Card",
	paypal: "PayPal",
	braintree_paypal: "PayPal",
	apple_pay: "Apple Pay",
	google_pay: "Google Pay",
	affirm: "Affirm",
	klarna: "Klarna",
	bread: "Bread",
	iap: "In-App Purchase",
	citcon: "Citcon",
	ppro: "PPRO",
	dlocal: "dLocal",
	droplet: "Droplet"
};
function normalizePaymentDescriptor(value) {
	return value?.replace(/([a-z])([A-Z])/g, "$1 $2").trim().toLowerCase().replace(/[_-]+/g, " ").replace(/\s+/g, " ") || null;
}
function isCardPaymentDescriptor(value) {
	const descriptor = normalizePaymentDescriptor(value);
	return descriptor === "card" || descriptor === "credit card";
}
function paymentDescriptorLabel(...values) {
	for (const value of values) {
		const normalized = normalizePaymentDescriptor(value);
		if (!normalized) continue;
		return PAYMENT_TYPE_LABELS[normalized.replace(/\s+/g, "_")] ?? value?.trim() ?? null;
	}
	return null;
}
function maskCardNumber(lastFour, brand) {
	const tail = trimToNull(lastFour) ?? "••••";
	if (normalizeBrand(brand) === "amex") return `•••• •••••• •${tail}`;
	return `•••• •••• •••• ${tail}`;
}
function cardDisplayLabel(lastFour, brand) {
	const labelBrand = trimToNull(brand);
	const mask = maskCardNumber(lastFour, labelBrand);
	if (labelBrand && normalizeBrand(labelBrand) == null && !isGenericCardLabel(labelBrand)) return `${labelBrand} ${mask}`;
	return mask;
}
function maskedCardLabelSegments(label) {
	const value = trimToNull(label);
	if (!value) return null;
	const segments = [];
	let hasDots = false;
	const parts = value.split(/\s+/);
	for (const [index, part] of parts.entries()) {
		if (!/^[•\d]+$/.test(part)) return null;
		if (index > 0) segments.push({ kind: "gap" });
		let dotCount = 0;
		while (part[dotCount] === MASK_DOT) dotCount += 1;
		const remainder = part.slice(dotCount);
		if (remainder.includes(MASK_DOT)) return null;
		if (dotCount > 0) {
			hasDots = true;
			segments.push({
				kind: "dots",
				count: dotCount
			});
		}
		if (remainder) segments.push({
			kind: "text",
			value: remainder
		});
	}
	return hasDots ? segments : null;
}
function maskEmail(email) {
	const normalizedEmail = trimToNull(email);
	if (!normalizedEmail) return null;
	const at = normalizedEmail.indexOf("@");
	if (at <= 0) return normalizedEmail;
	const local = normalizedEmail.slice(0, at);
	const domain = normalizedEmail.slice(at);
	if (local.length <= 2) return `${local[0] ?? ""}••${domain}`;
	const dots = "•".repeat(Math.min(local.length - 2, 6));
	return `${local[0]}${dots}${local[local.length - 1]}${domain}`;
}
function apmIdentifier(paymentMethod) {
	const brand = normalizeApmBrand(paymentMethod.brand ?? paymentMethod.fallbackLabel);
	switch (brand != null ? APM_IDENTIFIER_CLASS[brand] : "none") {
		case "email": return maskEmail(paymentMethod.emailAddress);
		case "handle": return trimToNull(paymentMethod.accountHandle);
		case "bank": return bankIdentifier(paymentMethod);
		case "none": return null;
	}
}
function nonCardDisplayLabel(paymentMethod) {
	return apmIdentifier(paymentMethod) ?? apmBrandName(paymentMethod.brand ?? paymentMethod.fallbackLabel) ?? getPaymentBrandName(paymentMethod.brand ?? paymentMethod.fallbackLabel) ?? trimToNull(paymentMethod.fallbackLabel) ?? DEFAULT_PAYMENT_ALT;
}
function resolvePaymentLogo({ brand, logoUrl, alt }) {
	const canonical = normalizeBrand(brand);
	const fallbackUrl = trimToNull(logoUrl) ?? GENERIC_PAYMENT_ICON_URL;
	return {
		primaryUrl: canonical ? brandIconUrl(canonical) : fallbackUrl,
		fallbackUrl: canonical ? fallbackUrl : GENERIC_PAYMENT_ICON_URL,
		alt: trimToNull(alt) ?? getPaymentBrandName(brand) ?? trimToNull(brand) ?? DEFAULT_PAYMENT_ALT,
		brand: canonical
	};
}
function resolveWalletBadge(walletBrand) {
	const brand = normalizeSupportedWalletBadgeBrand(walletBrand);
	if (!brand) return null;
	return {
		brand,
		label: getPaymentBrandName(brand) ?? DEFAULT_PAYMENT_ALT
	};
}
function resolvePaymentMethodDisplay(paymentMethod) {
	if (paymentMethod.kind === "card") {
		const label = cardDisplayLabel(paymentMethod.last4, paymentMethod.brand);
		const logo = resolvePaymentLogo({
			brand: paymentMethod.brand,
			logoUrl: paymentMethod.logoUrl,
			alt: getPaymentBrandName(paymentMethod.brand) ?? "Card"
		});
		const walletBadge = resolveWalletBadge(paymentMethod.walletBrand);
		return {
			kind: "card",
			label,
			logo,
			brand: logo.brand,
			walletBadge,
			accessibilityLabel: formatAccessibilityLabel(logo.alt, label)
		};
	}
	const brand = paymentMethod.brand ?? paymentMethod.fallbackLabel;
	const label = nonCardDisplayLabel(paymentMethod);
	const logo = resolvePaymentLogo({
		brand,
		logoUrl: paymentMethod.logoUrl,
		alt: getPaymentBrandName(brand) ?? paymentMethod.fallbackLabel
	});
	return {
		kind: "non_card",
		label,
		logo,
		brand: logo.brand,
		walletBadge: null,
		accessibilityLabel: formatAccessibilityLabel(logo.alt, label)
	};
}
function bankIdentifier(paymentMethod) {
	const bankName = trimToNull(paymentMethod.bankName);
	const accountLast4 = trimToNull(paymentMethod.accountLast4);
	const maskedAccount = accountLast4 ? `••${accountLast4}` : null;
	if (bankName && maskedAccount) return `${bankName} ${maskedAccount}`;
	return bankName ?? maskedAccount;
}
function formatAccessibilityLabel(alt, label) {
	return alt === label ? label : `${alt} ${label}`;
}
function trimToNull(value) {
	const trimmed = value?.trim();
	return trimmed ? trimmed : null;
}
//#endregion
Object.defineProperty(exports, "GENERIC_PAYMENT_ICON_URL", {
	enumerable: true,
	get: function() {
		return GENERIC_PAYMENT_ICON_URL;
	}
});
Object.defineProperty(exports, "brandIconUrl", {
	enumerable: true,
	get: function() {
		return brandIconUrl;
	}
});
Object.defineProperty(exports, "isCardPaymentDescriptor", {
	enumerable: true,
	get: function() {
		return isCardPaymentDescriptor;
	}
});
Object.defineProperty(exports, "maskCardNumber", {
	enumerable: true,
	get: function() {
		return maskCardNumber;
	}
});
Object.defineProperty(exports, "maskedCardLabelSegments", {
	enumerable: true,
	get: function() {
		return maskedCardLabelSegments;
	}
});
Object.defineProperty(exports, "normalizeCardBrand", {
	enumerable: true,
	get: function() {
		return normalizeCardBrand;
	}
});
Object.defineProperty(exports, "normalizePaymentDescriptor", {
	enumerable: true,
	get: function() {
		return normalizePaymentDescriptor;
	}
});
Object.defineProperty(exports, "paymentDescriptorLabel", {
	enumerable: true,
	get: function() {
		return paymentDescriptorLabel;
	}
});
Object.defineProperty(exports, "resolvePaymentLogo", {
	enumerable: true,
	get: function() {
		return resolvePaymentLogo;
	}
});
Object.defineProperty(exports, "resolvePaymentMethodDisplay", {
	enumerable: true,
	get: function() {
		return resolvePaymentMethodDisplay;
	}
});

//# sourceMappingURL=display-tXE9ewkB.cjs.map