@flopay/shared 0.5.19 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +78 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +142 -29
- package/dist/index.d.ts +142 -29
- package/dist/index.mjs +75 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,8 @@ __export(index_exports, {
|
|
|
44
44
|
apiError: () => apiError,
|
|
45
45
|
authenticationError: () => authenticationError,
|
|
46
46
|
buildCheckoutDisplayData: () => buildCheckoutDisplayData,
|
|
47
|
+
buildItemPayload: () => buildItemPayload,
|
|
48
|
+
buildSubscriptionPayload: () => buildSubscriptionPayload,
|
|
47
49
|
configureFlopay: () => configureFlopay,
|
|
48
50
|
getConfiguredBillingApiUrl: () => getConfiguredBillingApiUrl,
|
|
49
51
|
getCountryByCode: () => getCountryByCode,
|
|
@@ -62,6 +64,7 @@ __export(index_exports, {
|
|
|
62
64
|
resolveAVSConfig: () => resolveAVSConfig,
|
|
63
65
|
resolveBillingApiUrl: () => resolveBillingApiUrl,
|
|
64
66
|
resolveButtonsLayoutTheme: () => resolveButtonsLayoutTheme,
|
|
67
|
+
resolveSessionCurrency: () => resolveSessionCurrency,
|
|
65
68
|
validationError: () => validationError
|
|
66
69
|
});
|
|
67
70
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -113,7 +116,7 @@ function getFloPayEnvironment() {
|
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
// src/constants.ts
|
|
116
|
-
var SDK_VERSION = "0.
|
|
119
|
+
var SDK_VERSION = "1.0.2";
|
|
117
120
|
var BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
|
|
118
121
|
var BILLING_API_URL_PRODUCTION = "https://api.flopay.com";
|
|
119
122
|
var DEFAULT_API_BASE_URL = BILLING_API_URL_STAGING;
|
|
@@ -766,16 +769,80 @@ function getStateFromPostalCode(country, postalCode) {
|
|
|
766
769
|
}
|
|
767
770
|
}
|
|
768
771
|
|
|
772
|
+
// src/checkout-payload.ts
|
|
773
|
+
function nonBlank(value) {
|
|
774
|
+
if (typeof value !== "string") return void 0;
|
|
775
|
+
const trimmed = value.trim();
|
|
776
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
777
|
+
}
|
|
778
|
+
function resolveSessionCurrency(sessionCurrency, items, subscriptions) {
|
|
779
|
+
const session = nonBlank(sessionCurrency);
|
|
780
|
+
if (session) return session;
|
|
781
|
+
for (const item of items ?? []) {
|
|
782
|
+
const c = nonBlank(item.currency);
|
|
783
|
+
if (c) return c;
|
|
784
|
+
}
|
|
785
|
+
for (const sub of subscriptions ?? []) {
|
|
786
|
+
const c = nonBlank(sub.currency);
|
|
787
|
+
if (c) return c;
|
|
788
|
+
}
|
|
789
|
+
return "USD";
|
|
790
|
+
}
|
|
791
|
+
function buildItemPayload(item, sessionCurrency) {
|
|
792
|
+
const code = nonBlank(item.code) ?? nonBlank(item.providerItemId);
|
|
793
|
+
if (!code) {
|
|
794
|
+
throw new Error("CheckoutItem requires either `code` or the deprecated `providerItemId`.");
|
|
795
|
+
}
|
|
796
|
+
const itemName = nonBlank(item.itemName) ?? nonBlank(item.providerItemName) ?? null;
|
|
797
|
+
const payload = {
|
|
798
|
+
code,
|
|
799
|
+
providerItemId: nonBlank(item.providerItemId) ?? code,
|
|
800
|
+
itemName,
|
|
801
|
+
providerItemName: nonBlank(item.providerItemName) ?? itemName,
|
|
802
|
+
quantity: item.quantity ?? 1,
|
|
803
|
+
totalAmount: item.totalAmount,
|
|
804
|
+
overrideAmount: item.overrideAmount ?? null,
|
|
805
|
+
currency: nonBlank(item.currency) ?? sessionCurrency
|
|
806
|
+
};
|
|
807
|
+
if (item.metadata) {
|
|
808
|
+
payload["metadata"] = item.metadata;
|
|
809
|
+
}
|
|
810
|
+
return payload;
|
|
811
|
+
}
|
|
812
|
+
function buildSubscriptionPayload(subscription, sessionCurrency) {
|
|
813
|
+
const code = nonBlank(subscription.code) ?? nonBlank(subscription.providerPlanId);
|
|
814
|
+
if (!code) {
|
|
815
|
+
throw new Error(
|
|
816
|
+
"CheckoutSubscription requires either `code` or the deprecated `providerPlanId`."
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
const subscriptionName = nonBlank(subscription.subscriptionName) ?? nonBlank(subscription.providerPlanName) ?? null;
|
|
820
|
+
const payload = {
|
|
821
|
+
code,
|
|
822
|
+
providerPlanId: nonBlank(subscription.providerPlanId) ?? code,
|
|
823
|
+
subscriptionName,
|
|
824
|
+
providerPlanName: nonBlank(subscription.providerPlanName) ?? subscriptionName,
|
|
825
|
+
quantity: subscription.quantity ?? 1,
|
|
826
|
+
totalAmount: subscription.totalAmount,
|
|
827
|
+
overrideAmount: subscription.overrideAmount ?? null,
|
|
828
|
+
currency: nonBlank(subscription.currency) ?? sessionCurrency
|
|
829
|
+
};
|
|
830
|
+
if (subscription.metadata) {
|
|
831
|
+
payload["metadata"] = subscription.metadata;
|
|
832
|
+
}
|
|
833
|
+
return payload;
|
|
834
|
+
}
|
|
835
|
+
|
|
769
836
|
// src/display.ts
|
|
770
|
-
function buildCheckoutDisplayData(session) {
|
|
837
|
+
function buildCheckoutDisplayData(session, options = {}) {
|
|
771
838
|
const itemsList = [];
|
|
772
|
-
let currency = "USD";
|
|
773
839
|
const subscriptions = session.subscriptions ?? [];
|
|
774
840
|
const items = session.items ?? [];
|
|
841
|
+
const currency = resolveSessionCurrency(session.currency, items, subscriptions).toUpperCase();
|
|
775
842
|
for (const sub of subscriptions) {
|
|
776
|
-
const originalPrice = sub.totalAmount;
|
|
843
|
+
const originalPrice = sub.totalAmount ?? 0;
|
|
777
844
|
const discountedPrice = sub.overrideAmount ?? originalPrice;
|
|
778
|
-
let name = sub.providerPlanName || "Subscription";
|
|
845
|
+
let name = sub.subscriptionName || sub.providerPlanName || sub.code || "Subscription";
|
|
779
846
|
if (name === "4-WEEK PLAN" && discountedPrice <= 1) {
|
|
780
847
|
name = "7-DAY TRIAL: FULL ACCESS";
|
|
781
848
|
}
|
|
@@ -785,20 +852,18 @@ function buildCheckoutDisplayData(session) {
|
|
|
785
852
|
price: discountedPrice,
|
|
786
853
|
originalPrice
|
|
787
854
|
});
|
|
788
|
-
if (sub.currency) currency = sub.currency.toUpperCase();
|
|
789
855
|
}
|
|
790
|
-
const hideItems = subscriptions.length > 0 && items.length > 0;
|
|
856
|
+
const hideItems = options.hideBundledItems === true && subscriptions.length > 0 && items.length > 0;
|
|
791
857
|
if (!hideItems) {
|
|
792
858
|
for (const item of items) {
|
|
793
|
-
const originalPrice = item.totalAmount;
|
|
859
|
+
const originalPrice = item.totalAmount ?? 0;
|
|
794
860
|
const discountedPrice = item.overrideAmount ?? originalPrice;
|
|
795
861
|
itemsList.push({
|
|
796
|
-
name: item.providerItemName || "Item",
|
|
862
|
+
name: item.itemName || item.providerItemName || item.code || "Item",
|
|
797
863
|
quantity: item.quantity,
|
|
798
864
|
price: discountedPrice,
|
|
799
865
|
originalPrice
|
|
800
866
|
});
|
|
801
|
-
if (item.currency) currency = item.currency.toUpperCase();
|
|
802
867
|
}
|
|
803
868
|
}
|
|
804
869
|
if (itemsList.length === 0) {
|
|
@@ -808,7 +873,6 @@ function buildCheckoutDisplayData(session) {
|
|
|
808
873
|
price: session.amount / 100,
|
|
809
874
|
originalPrice: session.amount / 100
|
|
810
875
|
});
|
|
811
|
-
currency = session.currency?.toUpperCase() ?? "USD";
|
|
812
876
|
}
|
|
813
877
|
const originalTotal = itemsList.reduce((sum, i) => sum + i.originalPrice * i.quantity, 0);
|
|
814
878
|
const total = itemsList.reduce((sum, i) => sum + i.price * i.quantity, 0);
|
|
@@ -860,6 +924,8 @@ function isValidSecretKey(key) {
|
|
|
860
924
|
apiError,
|
|
861
925
|
authenticationError,
|
|
862
926
|
buildCheckoutDisplayData,
|
|
927
|
+
buildItemPayload,
|
|
928
|
+
buildSubscriptionPayload,
|
|
863
929
|
configureFlopay,
|
|
864
930
|
getConfiguredBillingApiUrl,
|
|
865
931
|
getCountryByCode,
|
|
@@ -878,6 +944,7 @@ function isValidSecretKey(key) {
|
|
|
878
944
|
resolveAVSConfig,
|
|
879
945
|
resolveBillingApiUrl,
|
|
880
946
|
resolveButtonsLayoutTheme,
|
|
947
|
+
resolveSessionCurrency,
|
|
881
948
|
validationError
|
|
882
949
|
});
|
|
883
950
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/config.ts","../src/constants.ts","../src/postal-code-lookup.ts","../src/display.ts","../src/validation.ts"],"sourcesContent":["// Types\nexport type {\n FloPayThemeVariables,\n FloPayAppearance,\n Customer,\n RecurringInterval,\n PriceData,\n LineItem,\n CheckoutMode,\n CheckoutSession,\n CheckoutSessionItem,\n CheckoutSessionSubscription,\n PaymentResult,\n ConfirmPaymentParams,\n CreatePaymentMethodResult,\n ConfirmCardPaymentParams,\n ConfirmCardPaymentResult,\n ElementType,\n ElementChangeEvent,\n ElementOptions,\n MountedElement,\n FloPayConfig,\n PaymentProviderAdapter,\n BillingProvider,\n TokenizedBody,\n CheckoutProcessError,\n CheckoutProcessingPending,\n CheckoutModeKind,\n NormalizedCheckoutSession,\n CheckoutItem,\n CheckoutSubscription,\n CheckoutAccount,\n TagsData,\n CreateSessionParams,\n CheckoutSessionResult,\n ProcessPaymentParams,\n CreateCustomerParams,\n UpdateCustomerParams,\n WebhookEvent,\n CurrencyInfo,\n CountryOption,\n ButtonsLayoutStyles,\n ButtonsLayoutTheme,\n AVSFieldConfig,\n InlineSessionParams,\n InlineSessionDraft,\n InlineSessionPatch,\n BeforeButtonClickEvent,\n CheckoutButtonMethod,\n DeclineEvent,\n BillingDetails,\n} from './types.js';\n\n// Errors\nexport {\n FloPayError,\n validationError,\n apiError,\n authenticationError,\n rateLimitError,\n networkError,\n} from './errors.js';\nexport type { FloPayErrorType } from './errors.js';\n\n// Configuration\nexport { configureFlopay, getConfiguredBillingApiUrl, getFloPayEnvironment } from './config.js';\nexport type { FloPayEnvironment } from './config.js';\n\n// Constants\nexport {\n SDK_VERSION,\n DEFAULT_API_BASE_URL,\n DEFAULT_API_VERSION,\n BILLING_API_URL,\n BILLING_API_URL_STAGING,\n BILLING_API_URL_PRODUCTION,\n resolveBillingApiUrl,\n DEFAULT_APPEARANCE,\n FLAT_APPEARANCE,\n NIGHT_APPEARANCE,\n ELEMENT_TYPES,\n SUPPORTED_CARD_BRANDS,\n CURRENCY_MAP,\n DEFAULT_CURRENCY,\n BUTTONS_LAYOUT_DEFAULT,\n BUTTONS_LAYOUT_MINIMAL,\n BUTTONS_LAYOUT_ROUNDED,\n BUTTONS_LAYOUT_DARK,\n resolveButtonsLayoutTheme,\n getPostalCodeLabel,\n COUNTRY_OPTIONS,\n getCountryByCode,\n resolveAVSConfig,\n isAVSFieldVisible,\n isAVSEnabled,\n US_STATES,\n CA_PROVINCES,\n getStateOptions,\n getStateLabel,\n type StateOption,\n} from './constants.js';\n\n// Postal code lookups\nexport { getStateFromPostalCode } from './postal-code-lookup.js';\n\n// Display helpers\nexport { buildCheckoutDisplayData } from './display.js';\nexport type { DisplayLineItem, CheckoutDisplayData } from './display.js';\n\n// Validation helpers\nexport {\n getCurrencyByCountry,\n isValidPublishableKey,\n isValidSecretKey,\n} from './validation.js';\n","/** Discriminated error types returned by the FloPay SDK. */\nexport type FloPayErrorType =\n | 'validation_error'\n | 'api_error'\n | 'authentication_error'\n | 'rate_limit_error'\n | 'network_error';\n\n/**\n * Custom error class for all FloPay SDK errors.\n *\n * Extends the native `Error` and adds structured fields that mirror\n * Stripe-style error responses for familiarity.\n */\nexport class FloPayError extends Error {\n readonly type: FloPayErrorType;\n readonly code?: string;\n readonly declineCode?: string;\n readonly param?: string;\n readonly statusCode?: number;\n\n constructor(\n message: string,\n type: FloPayErrorType,\n options?: { code?: string; declineCode?: string; param?: string; statusCode?: number },\n ) {\n super(message);\n this.name = 'FloPayError';\n this.type = type;\n this.code = options?.code;\n this.declineCode = options?.declineCode;\n this.param = options?.param;\n this.statusCode = options?.statusCode;\n\n // Restore prototype chain (required when extending built-ins)\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Error Factories\n// ---------------------------------------------------------------------------\n\n/** Create a validation error (e.g. missing required field). */\nexport function validationError(\n message: string,\n param?: string,\n): FloPayError {\n return new FloPayError(message, 'validation_error', { param });\n}\n\n/** Create an API error (e.g. upstream provider returned an error). */\nexport function apiError(\n message: string,\n code?: string,\n statusCode?: number,\n): FloPayError {\n return new FloPayError(message, 'api_error', { code, statusCode });\n}\n\n/** Create an authentication error (e.g. invalid publishable key). */\nexport function authenticationError(message: string): FloPayError {\n return new FloPayError(message, 'authentication_error');\n}\n\n/** Create a rate limit error. */\nexport function rateLimitError(message: string): FloPayError {\n return new FloPayError(message, 'rate_limit_error');\n}\n\n/** Create a network error (e.g. fetch failed). */\nexport function networkError(message: string): FloPayError {\n return new FloPayError(message, 'network_error');\n}\n","/** FloPay environment — determines which billing API URL is used. */\nexport type FloPayEnvironment = 'staging' | 'production' | 'local';\n\nconst ENV_URL_MAP: Record<FloPayEnvironment, string> = {\n local: 'https://flo.ngrok.pro',\n staging: 'https://api.stage.flopay.com',\n production: 'https://api.flopay.com',\n};\n\nlet globalEnvironment: FloPayEnvironment = 'staging';\n\n/**\n * Configure the FloPay SDK globally. Call once at app startup.\n *\n * The environment determines which billing API URL is used for all\n * FloPay operations (session creation, payment processing, etc.).\n *\n * @example\n * ```ts\n * import { configureFlopay } from '@flopay/shared';\n *\n * // In production\n * configureFlopay({ environment: 'production' });\n *\n * // In staging/development\n * configureFlopay({ environment: 'staging' });\n * ```\n *\n * Alternatively, set the `NEXT_PUBLIC_FLOPAY_ENV` environment variable\n * to `'staging'` or `'production'` — the SDK reads it automatically.\n */\nexport function configureFlopay(config: { environment: FloPayEnvironment }): void {\n globalEnvironment = config.environment;\n}\n\n/** Get the billing API URL for the currently configured environment. */\nexport function getConfiguredBillingApiUrl(): string {\n return ENV_URL_MAP[globalEnvironment];\n}\n\n/** Get the current configured environment. */\nexport function getFloPayEnvironment(): FloPayEnvironment {\n return globalEnvironment;\n}\n","import type { AVSFieldConfig, ButtonsLayoutStyles, ButtonsLayoutTheme, CountryOption, CurrencyInfo, FloPayAppearance } from './types.js';\n\nimport type { FloPayEnvironment } from './config.js';\nimport { getConfiguredBillingApiUrl } from './config.js';\n\n// ---------------------------------------------------------------------------\n// SDK Version & API\n// ---------------------------------------------------------------------------\n\n/** Current SDK version. */\nexport const SDK_VERSION = '0.5.19';\n\n/** Billing API URL for staging environment. */\nexport const BILLING_API_URL_STAGING = 'https://api.stage.flopay.com';\n\n/** Billing API URL for production environment. */\nexport const BILLING_API_URL_PRODUCTION = 'https://api.flopay.com';\n\n/** Default FloPay API base URL (used by @flopay/node). Alias for staging. */\nexport const DEFAULT_API_BASE_URL = BILLING_API_URL_STAGING;\n\n/** Default billing API base URL. Alias for staging — prefer `resolveBillingApiUrl()`. */\nexport const BILLING_API_URL = BILLING_API_URL_STAGING;\n\n/**\n * Resolve the billing API URL from available configuration.\n *\n * Priority:\n * 1. Explicit `billingApiUrl` (prop/param override)\n * 2. `NEXT_PUBLIC_FLOPAY_ENV` environment variable (`'staging'` | `'production'`)\n * 3. `configureFlopay()` global environment setting\n * 4. Fallback: staging URL\n *\n * @example\n * ```ts\n * import { resolveBillingApiUrl } from '@flopay/shared';\n *\n * // Reads from env var or configureFlopay() — no args needed\n * const url = resolveBillingApiUrl();\n *\n * // Explicit override takes priority\n * const url = resolveBillingApiUrl('https://custom.example.com');\n * ```\n */\nexport function resolveBillingApiUrl(billingApiUrl?: string): string {\n if (billingApiUrl) return billingApiUrl;\n\n // Environment variable (works in Next.js and bundlers that inline process.env)\n if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_FLOPAY_ENV) {\n const env = process.env.NEXT_PUBLIC_FLOPAY_ENV as FloPayEnvironment;\n if (env === 'production') return BILLING_API_URL_PRODUCTION;\n return BILLING_API_URL_STAGING;\n }\n\n // Global config from configureFlopay()\n return getConfiguredBillingApiUrl();\n}\n\n/** Default API version header value. */\nexport const DEFAULT_API_VERSION = '2024-01-01';\n\n// ---------------------------------------------------------------------------\n// Default Themes\n// ---------------------------------------------------------------------------\n\n/** The default appearance applied when no custom appearance is provided. */\nexport const DEFAULT_APPEARANCE: FloPayAppearance = {\n theme: 'default',\n variables: {\n colorPrimary: '#4A49FF',\n colorBackground: '#FFFFFF',\n colorText: '#262833',\n colorDanger: '#DF1B41',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n/** Flat theme — minimal borders and shadows. */\nexport const FLAT_APPEARANCE: FloPayAppearance = {\n theme: 'flat',\n variables: {\n ...DEFAULT_APPEARANCE.variables,\n borderRadius: '4px',\n },\n};\n\n/** Night theme — dark background. */\nexport const NIGHT_APPEARANCE: FloPayAppearance = {\n theme: 'night',\n variables: {\n colorPrimary: '#7B7BFF',\n colorBackground: '#1A1A2E',\n colorText: '#E0E0E0',\n colorDanger: '#FF6B6B',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n// ---------------------------------------------------------------------------\n// Buttons Layout Theme Presets\n// ---------------------------------------------------------------------------\n\n/** Default buttons layout — white card button, neutral borders. */\nexport const BUTTONS_LAYOUT_DEFAULT: ButtonsLayoutStyles = {};\n\n/** Minimal buttons layout — borderless, subtle hover. */\nexport const BUTTONS_LAYOUT_MINIMAL: ButtonsLayoutStyles = {\n cardButton: {\n border: 'none',\n backgroundColor: '#f9fafb',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#f9fafb',\n border: 'none',\n },\n cardInputBorder: '#e5e7eb',\n backButtonIcon: {\n backgroundColor: '#e5e7eb',\n },\n submitButton: {\n borderRadius: '6px',\n },\n};\n\n/** Rounded buttons layout — large border radius, soft shadows. */\nexport const BUTTONS_LAYOUT_ROUNDED: ButtonsLayoutStyles = {\n cardButton: {\n borderRadius: '9999px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 1px 3px rgba(0,0,0,0.06)',\n },\n cardFormContainer: {\n borderRadius: '16px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 2px 8px rgba(0,0,0,0.06)',\n },\n cardInputBorder: '#d1d5db',\n submitButton: {\n borderRadius: '9999px',\n },\n backButtonIcon: {\n backgroundColor: '#f3f4f6',\n },\n};\n\n/** Dark buttons layout — dark backgrounds, light text. */\nexport const BUTTONS_LAYOUT_DARK: ButtonsLayoutStyles = {\n cardButton: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n border: '1px solid #374151',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#111827',\n border: '1px solid #374151',\n },\n cardInputBorder: '#4b5563',\n cardInputColor: '#f9fafb',\n cardInputPlaceholderColor: '#6b7280',\n cardInputBackground: '#1f2937',\n nameInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n backButton: {\n color: '#9ca3af',\n },\n backButtonIcon: {\n backgroundColor: '#374151',\n },\n submitButton: {\n backgroundColor: '#6366f1',\n },\n title: {\n color: '#f9fafb',\n },\n countrySelect: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n zipInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n};\n\n/** Resolve a buttons layout theme name to its style preset. */\nexport function resolveButtonsLayoutTheme(theme?: ButtonsLayoutTheme): ButtonsLayoutStyles {\n switch (theme) {\n case 'minimal': return BUTTONS_LAYOUT_MINIMAL;\n case 'rounded': return BUTTONS_LAYOUT_ROUNDED;\n case 'dark': return BUTTONS_LAYOUT_DARK;\n default: return BUTTONS_LAYOUT_DEFAULT;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Supported Element Types\n// ---------------------------------------------------------------------------\n\n/** All supported element type identifiers. */\nexport const ELEMENT_TYPES = [\n 'payment',\n 'card',\n 'cardNumber',\n 'cardExpiry',\n 'cardCvc',\n 'address',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Supported Card Brands\n// ---------------------------------------------------------------------------\n\nexport const SUPPORTED_CARD_BRANDS = [\n 'visa',\n 'mastercard',\n 'mastercard_debit',\n 'amex',\n 'discover',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Currency Mapping (from checkout project)\n// ---------------------------------------------------------------------------\n\n/** Country code to currency information mapping. */\nexport const CURRENCY_MAP: Record<string, CurrencyInfo> = {\n // EUR (VAT applies)\n AT: { currency: 'EUR', symbol: '\\u20AC', country: 'Austria', countryCode: 'AT', tax: 1 },\n BE: { currency: 'EUR', symbol: '\\u20AC', country: 'Belgium', countryCode: 'BE', tax: 1 },\n CY: { currency: 'EUR', symbol: '\\u20AC', country: 'Cyprus', countryCode: 'CY', tax: 1 },\n DE: { currency: 'EUR', symbol: '\\u20AC', country: 'Germany', countryCode: 'DE', tax: 1 },\n EE: { currency: 'EUR', symbol: '\\u20AC', country: 'Estonia', countryCode: 'EE', tax: 1 },\n ES: { currency: 'EUR', symbol: '\\u20AC', country: 'Spain', countryCode: 'ES', tax: 1 },\n FI: { currency: 'EUR', symbol: '\\u20AC', country: 'Finland', countryCode: 'FI', tax: 1 },\n FR: { currency: 'EUR', symbol: '\\u20AC', country: 'France', countryCode: 'FR', tax: 1 },\n GR: { currency: 'EUR', symbol: '\\u20AC', country: 'Greece', countryCode: 'GR', tax: 1 },\n HR: { currency: 'EUR', symbol: '\\u20AC', country: 'Croatia', countryCode: 'HR', tax: 1 },\n IE: { currency: 'EUR', symbol: '\\u20AC', country: 'Ireland', countryCode: 'IE', tax: 1 },\n IT: { currency: 'EUR', symbol: '\\u20AC', country: 'Italy', countryCode: 'IT', tax: 1 },\n LT: { currency: 'EUR', symbol: '\\u20AC', country: 'Lithuania', countryCode: 'LT', tax: 1 },\n LU: { currency: 'EUR', symbol: '\\u20AC', country: 'Luxembourg', countryCode: 'LU', tax: 1 },\n LV: { currency: 'EUR', symbol: '\\u20AC', country: 'Latvia', countryCode: 'LV', tax: 1 },\n MT: { currency: 'EUR', symbol: '\\u20AC', country: 'Malta', countryCode: 'MT', tax: 1 },\n NL: { currency: 'EUR', symbol: '\\u20AC', country: 'Netherlands', countryCode: 'NL', tax: 1 },\n PT: { currency: 'EUR', symbol: '\\u20AC', country: 'Portugal', countryCode: 'PT', tax: 1 },\n SI: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovenia', countryCode: 'SI', tax: 1 },\n SK: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovakia', countryCode: 'SK', tax: 1 },\n BG: { currency: 'EUR', symbol: '\\u20AC', country: 'Bulgaria', countryCode: 'BG', tax: 1 },\n RO: { currency: 'EUR', symbol: '\\u20AC', country: 'Romania', countryCode: 'RO', tax: 1 },\n CZ: { currency: 'EUR', symbol: '\\u20AC', country: 'Czech Republic', countryCode: 'CZ', tax: 1 },\n SE: { currency: 'EUR', symbol: '\\u20AC', country: 'Sweden', countryCode: 'SE', tax: 1 },\n DK: { currency: 'EUR', symbol: '\\u20AC', country: 'Denmark', countryCode: 'DK', tax: 1 },\n PL: { currency: 'EUR', symbol: '\\u20AC', country: 'Poland', countryCode: 'PL', tax: 1 },\n HU: { currency: 'EUR', symbol: '\\u20AC', country: 'Hungary', countryCode: 'HU', tax: 1 },\n // GBP (VAT applies)\n GB: { currency: 'GBP', symbol: '\\u00A3', country: 'United Kingdom', countryCode: 'GB', tax: 1 },\n // USD (no VAT)\n US: { currency: 'USD', symbol: '$', country: 'United States', countryCode: 'US', tax: 0 },\n // CAD (no VAT)\n CA: { currency: 'CAD', symbol: 'CA$', country: 'Canada', countryCode: 'CA', tax: 0 },\n // NZD (no VAT)\n NZ: { currency: 'NZD', symbol: 'NZ$', country: 'New Zealand', countryCode: 'NZ', tax: 0 },\n // AUD (no VAT)\n AU: { currency: 'AUD', symbol: 'AU$', country: 'Australia', countryCode: 'AU', tax: 0 },\n};\n\n/** Default currency info when country is unknown. */\nexport const DEFAULT_CURRENCY: CurrencyInfo = {\n currency: 'USD',\n symbol: '$',\n country: 'United States',\n countryCode: 'US',\n tax: 0,\n};\n\n// ---------------------------------------------------------------------------\n// Postal Code Labels\n// ---------------------------------------------------------------------------\n\n/** Returns the correct postal code label for a country code (ISO 3166-1 alpha-2). */\nexport function getPostalCodeLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'ZIP Code';\n case 'GB': return 'Postcode';\n case 'CA': return 'Postal Code';\n case 'AU':\n case 'NZ': return 'Postcode';\n case 'IE': return 'Eircode';\n default: return 'Postal Code';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Country List (ISO 3166-1 alpha-2)\n// ---------------------------------------------------------------------------\n\nconst regionNames = new Intl.DisplayNames(['en'], { type: 'region' });\n\nfunction codeToFlag(code: string): string {\n return [...code.toUpperCase()]\n .map((c) => String.fromCodePoint(0x1f1e6 - 65 + c.charCodeAt(0)))\n .join('');\n}\n\n/** Priority countries shown first in dropdowns. */\nconst PRIORITY_CODES = ['US', 'GB', 'CA', 'AU', 'NZ', 'IE', 'DE', 'FR'];\n\nconst ALL_CODES = [\n 'AD', 'AE', 'AF', 'AG', 'AL', 'AM', 'AO', 'AR', 'AT', 'AU',\n 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ',\n 'BN', 'BO', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CD',\n 'CF', 'CG', 'CH', 'CI', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU',\n 'CV', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC',\n 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FM', 'FR', 'GA',\n 'GB', 'GD', 'GE', 'GH', 'GM', 'GN', 'GQ', 'GR', 'GT', 'GW',\n 'GY', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IQ',\n 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI',\n 'KM', 'KN', 'KR', 'KW', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK',\n 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME',\n 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MR', 'MT', 'MU', 'MV',\n 'MW', 'MX', 'MY', 'MZ', 'NA', 'NE', 'NG', 'NI', 'NL', 'NO',\n 'NP', 'NR', 'NZ', 'OM', 'PA', 'PE', 'PG', 'PH', 'PK', 'PL',\n 'PT', 'PW', 'PY', 'QA', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB',\n 'SC', 'SD', 'SE', 'SG', 'SI', 'SK', 'SL', 'SM', 'SN', 'SO',\n 'SR', 'SS', 'ST', 'SV', 'SY', 'SZ', 'TD', 'TG', 'TH', 'TJ',\n 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA',\n 'UG', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VN', 'VU', 'WS',\n 'XK', 'YE', 'ZA', 'ZM', 'ZW',\n] as const;\n\nfunction buildCountryOption(code: string): CountryOption {\n return { code, name: regionNames.of(code) ?? code, flag: codeToFlag(code) };\n}\n\nconst prioritySet = new Set(PRIORITY_CODES);\nconst rest = ALL_CODES.filter((c) => !prioritySet.has(c));\n\n/** All countries for dropdown select, priority countries first. */\nexport const COUNTRY_OPTIONS: CountryOption[] = [\n ...PRIORITY_CODES.map(buildCountryOption),\n ...rest.map(buildCountryOption),\n];\n\n/** Look up a country option by ISO 3166-1 alpha-2 code. */\nexport function getCountryByCode(code: string): CountryOption | undefined {\n return COUNTRY_OPTIONS.find((c) => c.code === code);\n}\n\n// ---------------------------------------------------------------------------\n// AVS Configuration Helpers\n// ---------------------------------------------------------------------------\n\n/** Default AVS config when `enableAVS: true` (backward compatible — country + postal code). */\nconst DEFAULT_AVS_CONFIG: AVSFieldConfig = {\n country: true,\n postal_code: true,\n};\n\n/**\n * Normalize `enableAVS` to a resolved config object.\n * - `false` / `undefined` → `null` (AVS disabled)\n * - `true` → default config (country + postal_code)\n * - `AVSFieldConfig` → returned as-is\n */\nexport function resolveAVSConfig(enableAVS?: boolean | AVSFieldConfig): AVSFieldConfig | null {\n if (!enableAVS) return null;\n if (enableAVS === true) return DEFAULT_AVS_CONFIG;\n return enableAVS;\n}\n\n/**\n * Check if an AVS field should be visible for the given country.\n * - `undefined` / `false` → hidden\n * - `true` → visible for all countries\n * - `string[]` → visible only for listed country codes\n */\nexport function isAVSFieldVisible(\n field: boolean | string[] | undefined,\n country: string,\n): boolean {\n if (field === undefined || field === false) return false;\n if (field === true) return true;\n const normalizedCountry = country.trim().toUpperCase();\n return field.some((code) => code.trim().toUpperCase() === normalizedCountry);\n}\n\n/** Returns true if any AVS field is meaningfully configured (at least one field is truthy). */\nexport function isAVSEnabled(enableAVS?: boolean | AVSFieldConfig): boolean {\n const config = resolveAVSConfig(enableAVS);\n if (!config) return false;\n return Object.values(config).some(\n (v) => v === true || (Array.isArray(v) && v.length > 0),\n );\n}\n\n// ---------------------------------------------------------------------------\n// US States & CA Provinces\n// ---------------------------------------------------------------------------\n\nexport interface StateOption {\n code: string;\n name: string;\n}\n\nexport const US_STATES: StateOption[] = [\n { code: 'AL', name: 'Alabama' },\n { code: 'AK', name: 'Alaska' },\n { code: 'AZ', name: 'Arizona' },\n { code: 'AR', name: 'Arkansas' },\n { code: 'CA', name: 'California' },\n { code: 'CO', name: 'Colorado' },\n { code: 'CT', name: 'Connecticut' },\n { code: 'DE', name: 'Delaware' },\n { code: 'DC', name: 'District of Columbia' },\n { code: 'FL', name: 'Florida' },\n { code: 'GA', name: 'Georgia' },\n { code: 'HI', name: 'Hawaii' },\n { code: 'ID', name: 'Idaho' },\n { code: 'IL', name: 'Illinois' },\n { code: 'IN', name: 'Indiana' },\n { code: 'IA', name: 'Iowa' },\n { code: 'KS', name: 'Kansas' },\n { code: 'KY', name: 'Kentucky' },\n { code: 'LA', name: 'Louisiana' },\n { code: 'ME', name: 'Maine' },\n { code: 'MD', name: 'Maryland' },\n { code: 'MA', name: 'Massachusetts' },\n { code: 'MI', name: 'Michigan' },\n { code: 'MN', name: 'Minnesota' },\n { code: 'MS', name: 'Mississippi' },\n { code: 'MO', name: 'Missouri' },\n { code: 'MT', name: 'Montana' },\n { code: 'NE', name: 'Nebraska' },\n { code: 'NV', name: 'Nevada' },\n { code: 'NH', name: 'New Hampshire' },\n { code: 'NJ', name: 'New Jersey' },\n { code: 'NM', name: 'New Mexico' },\n { code: 'NY', name: 'New York' },\n { code: 'NC', name: 'North Carolina' },\n { code: 'ND', name: 'North Dakota' },\n { code: 'OH', name: 'Ohio' },\n { code: 'OK', name: 'Oklahoma' },\n { code: 'OR', name: 'Oregon' },\n { code: 'PA', name: 'Pennsylvania' },\n { code: 'RI', name: 'Rhode Island' },\n { code: 'SC', name: 'South Carolina' },\n { code: 'SD', name: 'South Dakota' },\n { code: 'TN', name: 'Tennessee' },\n { code: 'TX', name: 'Texas' },\n { code: 'UT', name: 'Utah' },\n { code: 'VT', name: 'Vermont' },\n { code: 'VA', name: 'Virginia' },\n { code: 'WA', name: 'Washington' },\n { code: 'WV', name: 'West Virginia' },\n { code: 'WI', name: 'Wisconsin' },\n { code: 'WY', name: 'Wyoming' },\n];\n\nexport const CA_PROVINCES: StateOption[] = [\n { code: 'AB', name: 'Alberta' },\n { code: 'BC', name: 'British Columbia' },\n { code: 'MB', name: 'Manitoba' },\n { code: 'NB', name: 'New Brunswick' },\n { code: 'NL', name: 'Newfoundland and Labrador' },\n { code: 'NS', name: 'Nova Scotia' },\n { code: 'NT', name: 'Northwest Territories' },\n { code: 'NU', name: 'Nunavut' },\n { code: 'ON', name: 'Ontario' },\n { code: 'PE', name: 'Prince Edward Island' },\n { code: 'QC', name: 'Quebec' },\n { code: 'SK', name: 'Saskatchewan' },\n { code: 'YT', name: 'Yukon' },\n];\n\n/**\n * Get state/province options for a country.\n * Returns a list for US and CA, or `null` for countries where a free-text input is appropriate.\n */\nexport function getStateOptions(country: string): StateOption[] | null {\n switch (country.toUpperCase()) {\n case 'US': return US_STATES;\n case 'CA': return CA_PROVINCES;\n default: return null;\n }\n}\n\n/** Returns the appropriate label for the state/province field based on country. */\nexport function getStateLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'State';\n case 'CA': return 'Province';\n case 'GB': return 'County';\n case 'AU': return 'State / Territory';\n default: return 'State / Province / Region';\n }\n}\n","/**\n * Postal-code → state derivation for AVS.\n *\n * Used when the form configuration shows `address_line_1` but hides the\n * `state` input — we still want to populate `billing_details.address.state`\n * so Stripe Radar gets a richer address signal. Currently supports US and CA;\n * other countries return `null` (caller should fall back to omitting state).\n */\n\n/**\n * US 3-digit ZIP-prefix ranges → state code (USPS Sectional Center Facility).\n * Sourced from the public USPS SCF table. Each entry is `[startPrefix, endPrefix, stateCode]`,\n * inclusive on both ends. Coverage is contiguous within a state; gaps in the table\n * (e.g. unused 3-digit prefixes) are intentional and resolve to `null`.\n */\nconst US_ZIP_PREFIX_RANGES: ReadonlyArray<readonly [number, number, string]> = [\n [5, 5, 'NY'],\n [10, 27, 'MA'],\n [28, 29, 'RI'],\n [30, 38, 'NH'],\n [39, 49, 'ME'],\n [50, 59, 'VT'],\n [60, 69, 'CT'],\n [70, 89, 'NJ'],\n [100, 149, 'NY'],\n [150, 196, 'PA'],\n [197, 199, 'DE'],\n [200, 205, 'DC'],\n [206, 219, 'MD'],\n [220, 246, 'VA'],\n [247, 268, 'WV'],\n [270, 289, 'NC'],\n [290, 299, 'SC'],\n [300, 319, 'GA'],\n [320, 349, 'FL'],\n [350, 369, 'AL'],\n [370, 385, 'TN'],\n [386, 397, 'MS'],\n [398, 399, 'GA'],\n [400, 427, 'KY'],\n [430, 459, 'OH'],\n [460, 479, 'IN'],\n [480, 499, 'MI'],\n [500, 528, 'IA'],\n [530, 549, 'WI'],\n [550, 567, 'MN'],\n [570, 577, 'SD'],\n [580, 588, 'ND'],\n [590, 599, 'MT'],\n [600, 629, 'IL'],\n [630, 658, 'MO'],\n [660, 679, 'KS'],\n [680, 693, 'NE'],\n [700, 714, 'LA'],\n [716, 729, 'AR'],\n [730, 749, 'OK'],\n [750, 799, 'TX'],\n [800, 816, 'CO'],\n [820, 831, 'WY'],\n [832, 838, 'ID'],\n [840, 847, 'UT'],\n [850, 865, 'AZ'],\n [870, 884, 'NM'],\n [889, 898, 'NV'],\n [900, 961, 'CA'],\n [967, 968, 'HI'],\n [970, 979, 'OR'],\n [980, 994, 'WA'],\n [995, 999, 'AK'],\n];\n\n/**\n * CA postal-code first letter → province code (Forward Sortation Area).\n * The first letter of every Canadian postal code identifies the province\n * uniquely, except `X` which is shared by Northwest Territories and Nunavut\n * — we resolve it to `NT` because the volume strongly favours NT.\n */\nconst CA_FSA_FIRST_LETTER_TO_PROVINCE: Readonly<Record<string, string>> = {\n A: 'NL',\n B: 'NS',\n C: 'PE',\n E: 'NB',\n G: 'QC',\n H: 'QC',\n J: 'QC',\n K: 'ON',\n L: 'ON',\n M: 'ON',\n N: 'ON',\n P: 'ON',\n R: 'MB',\n S: 'SK',\n T: 'AB',\n V: 'BC',\n X: 'NT',\n Y: 'YT',\n};\n\nfunction deriveUsState(zip: string): string | null {\n const digits = zip.replace(/\\D/g, '');\n if (digits.length < 5) return null;\n const prefix = Number.parseInt(digits.slice(0, 3), 10);\n if (!Number.isFinite(prefix)) return null;\n\n for (const [start, end, code] of US_ZIP_PREFIX_RANGES) {\n if (prefix >= start && prefix <= end) return code;\n }\n return null;\n}\n\nfunction deriveCaProvince(postalCode: string): string | null {\n const compact = postalCode.replace(/\\s+/g, '').toUpperCase();\n if (!/^[A-Z]\\d[A-Z]\\d[A-Z]\\d$/.test(compact)) return null;\n const firstLetter = compact[0] ?? '';\n return CA_FSA_FIRST_LETTER_TO_PROVINCE[firstLetter] ?? null;\n}\n\n/**\n * Resolve a state / province code from a postal code for the given country.\n *\n * - US: 5-digit ZIP → 2-letter USPS state code (uses 3-digit prefix table).\n * - CA: A1A 1A1 → 2-letter ISO 3166-2:CA province code (first-letter mapping).\n * - All other countries: `null`.\n *\n * Returns `null` when the postal code is malformed or falls in an unmapped\n * range. Callers should treat `null` as \"skip — don't derive\".\n */\nexport function getStateFromPostalCode(\n country: string,\n postalCode: string,\n): string | null {\n if (!country || !postalCode) return null;\n const normalizedCountry = country.trim().toUpperCase();\n const normalizedZip = postalCode.trim();\n if (!normalizedZip) return null;\n\n switch (normalizedCountry) {\n case 'US':\n return deriveUsState(normalizedZip);\n case 'CA':\n return deriveCaProvince(normalizedZip);\n default:\n return null;\n }\n}\n","import type { CheckoutSession } from './types.js';\n\n/** A single line item formatted for display in the checkout UI. */\nexport interface DisplayLineItem {\n name: string;\n quantity: number;\n /** Price per unit in the session's currency (major units, e.g. 24.95). */\n price: number;\n /** Original price per unit before any discount (major units). */\n originalPrice: number;\n}\n\n/** Computed display data for rendering an order summary. */\nexport interface CheckoutDisplayData {\n /** Individual items/subscriptions with names, prices, and quantities. */\n items: DisplayLineItem[];\n /** ISO 4217 currency code (uppercase). */\n currency: string;\n /** Total amount due after discounts (major units, e.g. 24.95). */\n total: number;\n /** Sum of original prices before discounts (major units). */\n originalTotal: number;\n /** Total savings (originalTotal - total), clamped to >= 0. */\n totalSave: number;\n /** Discount percentage (0–100). */\n discountPercent: number;\n}\n\n/**\n * Builds display data from a `CheckoutSession` for rendering an order summary.\n *\n * Matches the display logic in checkout/CheckoutModal exactly:\n * - Subscriptions are always shown\n * - Items are hidden when the session has both subscriptions AND items\n * - `overrideAmount` (when not null/undefined) is the discounted price\n * - Plan name \"4-WEEK PLAN\" with price <= 1 is renamed to \"7-DAY TRIAL: FULL ACCESS\"\n * - Discount percentage and savings are computed from the difference\n *\n * All amounts are in **major currency units** (dollars, not cents).\n *\n * @example\n * ```ts\n * import { buildCheckoutDisplayData } from '@flopay/shared';\n *\n * const display = buildCheckoutDisplayData(session);\n * // display.items → [{ name: 'Starter', price: 24.95, originalPrice: 24.95, quantity: 1 }]\n * // display.total → 24.95\n * // display.currency → 'EUR'\n * ```\n */\nexport function buildCheckoutDisplayData(session: CheckoutSession): CheckoutDisplayData {\n const itemsList: DisplayLineItem[] = [];\n let currency = 'USD';\n\n const subscriptions = session.subscriptions ?? [];\n const items = session.items ?? [];\n\n // Subscriptions\n for (const sub of subscriptions) {\n const originalPrice = sub.totalAmount;\n const discountedPrice = sub.overrideAmount ?? originalPrice;\n\n // Match checkout/CheckoutModal: rename \"4-WEEK PLAN\" to \"7-DAY TRIAL: FULL ACCESS\"\n // when the discounted price is $1 or less\n let name = sub.providerPlanName || 'Subscription';\n if (name === '4-WEEK PLAN' && discountedPrice <= 1) {\n name = '7-DAY TRIAL: FULL ACCESS';\n }\n\n itemsList.push({\n name,\n quantity: sub.quantity,\n price: discountedPrice,\n originalPrice,\n });\n\n if (sub.currency) currency = sub.currency.toUpperCase();\n }\n\n // Items — hidden when session has both subscriptions and items\n // (matches checkout/CheckoutModal: hideItems logic)\n const hideItems = subscriptions.length > 0 && items.length > 0;\n\n if (!hideItems) {\n for (const item of items) {\n const originalPrice = item.totalAmount;\n const discountedPrice = item.overrideAmount ?? originalPrice;\n\n itemsList.push({\n name: item.providerItemName || 'Item',\n quantity: item.quantity,\n price: discountedPrice,\n originalPrice,\n });\n\n if (item.currency) currency = item.currency.toUpperCase();\n }\n }\n\n // Fallback if session has no items/subscriptions\n if (itemsList.length === 0) {\n itemsList.push({\n name: 'Purchase',\n quantity: 1,\n price: session.amount / 100,\n originalPrice: session.amount / 100,\n });\n currency = session.currency?.toUpperCase() ?? 'USD';\n }\n\n const originalTotal = itemsList.reduce((sum, i) => sum + i.originalPrice * i.quantity, 0);\n const total = itemsList.reduce((sum, i) => sum + i.price * i.quantity, 0);\n const totalSave = Math.max(0, originalTotal - total);\n const discountPercent = originalTotal > 0\n ? Math.round((totalSave / originalTotal) * 100)\n : 0;\n\n return {\n items: itemsList,\n currency,\n total,\n originalTotal,\n totalSave,\n discountPercent,\n };\n}\n","import type { CurrencyInfo } from './types.js';\nimport { CURRENCY_MAP, DEFAULT_CURRENCY } from './constants.js';\n\n/**\n * Look up currency information by ISO 3166-1 alpha-2 country code.\n * Falls back to USD when the country is not in the map.\n */\nexport function getCurrencyByCountry(countryCode: string): CurrencyInfo {\n return CURRENCY_MAP[countryCode.toUpperCase()] ?? DEFAULT_CURRENCY;\n}\n\n/** Returns `true` if the string looks like a Stripe publishable key. */\nexport function isValidPublishableKey(key: string): boolean {\n return /^pk_(test|live)_[A-Za-z0-9]+$/.test(key);\n}\n\n/** Returns `true` if the string looks like a Stripe secret key. */\nexport function isValidSecretKey(key: string): boolean {\n return /^sk_(test|live)_[A-Za-z0-9]+$/.test(key);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAOrC,YACE,SACA,MACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,OAAO,SAAS;AACrB,SAAK,cAAc,SAAS;AAC5B,SAAK,QAAQ,SAAS;AACtB,SAAK,aAAa,SAAS;AAG3B,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAOO,SAAS,gBACd,SACA,OACa;AACb,SAAO,IAAI,YAAY,SAAS,oBAAoB,EAAE,MAAM,CAAC;AAC/D;AAGO,SAAS,SACd,SACA,MAC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A,MACxB,eAAe,QAAQ,SAAS;AAAA,IAClC,CAAC;AACD,eAAW,QAAQ,UAAU,YAAY,KAAK;AAAA,EAChD;AAEA,QAAM,gBAAgB,UAAU,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,gBAAgB,EAAE,UAAU,CAAC;AACxF,QAAM,QAAQ,UAAU,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC;AACxE,QAAM,YAAY,KAAK,IAAI,GAAG,gBAAgB,KAAK;AACnD,QAAM,kBAAkB,gBAAgB,IACpC,KAAK,MAAO,YAAY,gBAAiB,GAAG,IAC5C;AAEJ,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ACtHO,SAAS,qBAAqB,aAAmC;AACtE,SAAO,aAAa,YAAY,YAAY,CAAC,KAAK;AACpD;AAGO,SAAS,sBAAsB,KAAsB;AAC1D,SAAO,gCAAgC,KAAK,GAAG;AACjD;AAGO,SAAS,iBAAiB,KAAsB;AACrD,SAAO,gCAAgC,KAAK,GAAG;AACjD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/config.ts","../src/constants.ts","../src/postal-code-lookup.ts","../src/checkout-payload.ts","../src/display.ts","../src/validation.ts"],"sourcesContent":["// Types\nexport type {\n FloPayThemeVariables,\n FloPayAppearance,\n Customer,\n RecurringInterval,\n PriceData,\n LineItem,\n CheckoutMode,\n CheckoutSession,\n CheckoutSessionItem,\n CheckoutSessionSubscription,\n PaymentResult,\n ConfirmPaymentParams,\n CreatePaymentMethodResult,\n ConfirmCardPaymentParams,\n ConfirmCardPaymentResult,\n ElementType,\n ElementChangeEvent,\n ElementOptions,\n MountedElement,\n FloPayConfig,\n PaymentProviderAdapter,\n BillingProvider,\n TokenizedBody,\n CheckoutProcessError,\n CheckoutProcessingPending,\n CheckoutModeKind,\n NormalizedCheckoutSession,\n CheckoutItem,\n CheckoutSubscription,\n CheckoutAccount,\n TagsData,\n CreateSessionParams,\n CheckoutSessionResult,\n ProcessPaymentParams,\n CreateCustomerParams,\n UpdateCustomerParams,\n WebhookEvent,\n CurrencyInfo,\n CountryOption,\n ButtonsLayoutStyles,\n ButtonsLayoutTheme,\n AVSFieldConfig,\n InlineSessionParams,\n InlineSessionDraft,\n InlineSessionPatch,\n BeforeButtonClickEvent,\n CheckoutButtonMethod,\n DeclineEvent,\n BillingDetails,\n} from './types.js';\n\n// Errors\nexport {\n FloPayError,\n validationError,\n apiError,\n authenticationError,\n rateLimitError,\n networkError,\n} from './errors.js';\nexport type { FloPayErrorType } from './errors.js';\n\n// Configuration\nexport { configureFlopay, getConfiguredBillingApiUrl, getFloPayEnvironment } from './config.js';\nexport type { FloPayEnvironment } from './config.js';\n\n// Constants\nexport {\n SDK_VERSION,\n DEFAULT_API_BASE_URL,\n DEFAULT_API_VERSION,\n BILLING_API_URL,\n BILLING_API_URL_STAGING,\n BILLING_API_URL_PRODUCTION,\n resolveBillingApiUrl,\n DEFAULT_APPEARANCE,\n FLAT_APPEARANCE,\n NIGHT_APPEARANCE,\n ELEMENT_TYPES,\n SUPPORTED_CARD_BRANDS,\n CURRENCY_MAP,\n DEFAULT_CURRENCY,\n BUTTONS_LAYOUT_DEFAULT,\n BUTTONS_LAYOUT_MINIMAL,\n BUTTONS_LAYOUT_ROUNDED,\n BUTTONS_LAYOUT_DARK,\n resolveButtonsLayoutTheme,\n getPostalCodeLabel,\n COUNTRY_OPTIONS,\n getCountryByCode,\n resolveAVSConfig,\n isAVSFieldVisible,\n isAVSEnabled,\n US_STATES,\n CA_PROVINCES,\n getStateOptions,\n getStateLabel,\n type StateOption,\n} from './constants.js';\n\n// Postal code lookups\nexport { getStateFromPostalCode } from './postal-code-lookup.js';\n\n// Display helpers\nexport { buildCheckoutDisplayData } from './display.js';\nexport type {\n DisplayLineItem,\n CheckoutDisplayData,\n BuildCheckoutDisplayDataOptions,\n} from './display.js';\n\n// Checkout payload helpers\nexport {\n resolveSessionCurrency,\n buildItemPayload,\n buildSubscriptionPayload,\n} from './checkout-payload.js';\n\n// Validation helpers\nexport {\n getCurrencyByCountry,\n isValidPublishableKey,\n isValidSecretKey,\n} from './validation.js';\n","/** Discriminated error types returned by the FloPay SDK. */\nexport type FloPayErrorType =\n | 'validation_error'\n | 'api_error'\n | 'authentication_error'\n | 'rate_limit_error'\n | 'network_error';\n\n/**\n * Custom error class for all FloPay SDK errors.\n *\n * Extends the native `Error` and adds structured fields that mirror\n * Stripe-style error responses for familiarity.\n */\nexport class FloPayError extends Error {\n readonly type: FloPayErrorType;\n readonly code?: string;\n readonly declineCode?: string;\n readonly param?: string;\n readonly statusCode?: number;\n\n constructor(\n message: string,\n type: FloPayErrorType,\n options?: { code?: string; declineCode?: string; param?: string; statusCode?: number },\n ) {\n super(message);\n this.name = 'FloPayError';\n this.type = type;\n this.code = options?.code;\n this.declineCode = options?.declineCode;\n this.param = options?.param;\n this.statusCode = options?.statusCode;\n\n // Restore prototype chain (required when extending built-ins)\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Error Factories\n// ---------------------------------------------------------------------------\n\n/** Create a validation error (e.g. missing required field). */\nexport function validationError(\n message: string,\n param?: string,\n): FloPayError {\n return new FloPayError(message, 'validation_error', { param });\n}\n\n/** Create an API error (e.g. upstream provider returned an error). */\nexport function apiError(\n message: string,\n code?: string,\n statusCode?: number,\n): FloPayError {\n return new FloPayError(message, 'api_error', { code, statusCode });\n}\n\n/** Create an authentication error (e.g. invalid publishable key). */\nexport function authenticationError(message: string): FloPayError {\n return new FloPayError(message, 'authentication_error');\n}\n\n/** Create a rate limit error. */\nexport function rateLimitError(message: string): FloPayError {\n return new FloPayError(message, 'rate_limit_error');\n}\n\n/** Create a network error (e.g. fetch failed). */\nexport function networkError(message: string): FloPayError {\n return new FloPayError(message, 'network_error');\n}\n","/** FloPay environment — determines which billing API URL is used. */\nexport type FloPayEnvironment = 'staging' | 'production' | 'local';\n\nconst ENV_URL_MAP: Record<FloPayEnvironment, string> = {\n local: 'https://flo.ngrok.pro',\n staging: 'https://api.stage.flopay.com',\n production: 'https://api.flopay.com',\n};\n\nlet globalEnvironment: FloPayEnvironment = 'staging';\n\n/**\n * Configure the FloPay SDK globally. Call once at app startup.\n *\n * The environment determines which billing API URL is used for all\n * FloPay operations (session creation, payment processing, etc.).\n *\n * @example\n * ```ts\n * import { configureFlopay } from '@flopay/shared';\n *\n * // In production\n * configureFlopay({ environment: 'production' });\n *\n * // In staging/development\n * configureFlopay({ environment: 'staging' });\n * ```\n *\n * Alternatively, set the `NEXT_PUBLIC_FLOPAY_ENV` environment variable\n * to `'staging'` or `'production'` — the SDK reads it automatically.\n */\nexport function configureFlopay(config: { environment: FloPayEnvironment }): void {\n globalEnvironment = config.environment;\n}\n\n/** Get the billing API URL for the currently configured environment. */\nexport function getConfiguredBillingApiUrl(): string {\n return ENV_URL_MAP[globalEnvironment];\n}\n\n/** Get the current configured environment. */\nexport function getFloPayEnvironment(): FloPayEnvironment {\n return globalEnvironment;\n}\n","import type { AVSFieldConfig, ButtonsLayoutStyles, ButtonsLayoutTheme, CountryOption, CurrencyInfo, FloPayAppearance } from './types.js';\n\nimport type { FloPayEnvironment } from './config.js';\nimport { getConfiguredBillingApiUrl } from './config.js';\n\n// ---------------------------------------------------------------------------\n// SDK Version & API\n// ---------------------------------------------------------------------------\n\n/** Current SDK version. */\nexport const SDK_VERSION = '1.0.2';\n\n/** Billing API URL for staging environment. */\nexport const BILLING_API_URL_STAGING = 'https://api.stage.flopay.com';\n\n/** Billing API URL for production environment. */\nexport const BILLING_API_URL_PRODUCTION = 'https://api.flopay.com';\n\n/** Default FloPay API base URL (used by @flopay/node). Alias for staging. */\nexport const DEFAULT_API_BASE_URL = BILLING_API_URL_STAGING;\n\n/** Default billing API base URL. Alias for staging — prefer `resolveBillingApiUrl()`. */\nexport const BILLING_API_URL = BILLING_API_URL_STAGING;\n\n/**\n * Resolve the billing API URL from available configuration.\n *\n * Priority:\n * 1. Explicit `billingApiUrl` (prop/param override)\n * 2. `NEXT_PUBLIC_FLOPAY_ENV` environment variable (`'staging'` | `'production'`)\n * 3. `configureFlopay()` global environment setting\n * 4. Fallback: staging URL\n *\n * @example\n * ```ts\n * import { resolveBillingApiUrl } from '@flopay/shared';\n *\n * // Reads from env var or configureFlopay() — no args needed\n * const url = resolveBillingApiUrl();\n *\n * // Explicit override takes priority\n * const url = resolveBillingApiUrl('https://custom.example.com');\n * ```\n */\nexport function resolveBillingApiUrl(billingApiUrl?: string): string {\n if (billingApiUrl) return billingApiUrl;\n\n // Environment variable (works in Next.js and bundlers that inline process.env)\n if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_FLOPAY_ENV) {\n const env = process.env.NEXT_PUBLIC_FLOPAY_ENV as FloPayEnvironment;\n if (env === 'production') return BILLING_API_URL_PRODUCTION;\n return BILLING_API_URL_STAGING;\n }\n\n // Global config from configureFlopay()\n return getConfiguredBillingApiUrl();\n}\n\n/** Default API version header value. */\nexport const DEFAULT_API_VERSION = '2024-01-01';\n\n// ---------------------------------------------------------------------------\n// Default Themes\n// ---------------------------------------------------------------------------\n\n/** The default appearance applied when no custom appearance is provided. */\nexport const DEFAULT_APPEARANCE: FloPayAppearance = {\n theme: 'default',\n variables: {\n colorPrimary: '#4A49FF',\n colorBackground: '#FFFFFF',\n colorText: '#262833',\n colorDanger: '#DF1B41',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n/** Flat theme — minimal borders and shadows. */\nexport const FLAT_APPEARANCE: FloPayAppearance = {\n theme: 'flat',\n variables: {\n ...DEFAULT_APPEARANCE.variables,\n borderRadius: '4px',\n },\n};\n\n/** Night theme — dark background. */\nexport const NIGHT_APPEARANCE: FloPayAppearance = {\n theme: 'night',\n variables: {\n colorPrimary: '#7B7BFF',\n colorBackground: '#1A1A2E',\n colorText: '#E0E0E0',\n colorDanger: '#FF6B6B',\n borderRadius: '8px',\n fontFamily: 'Poppins, system-ui, sans-serif',\n fontSizeBase: '16px',\n spacingUnit: '4px',\n },\n};\n\n// ---------------------------------------------------------------------------\n// Buttons Layout Theme Presets\n// ---------------------------------------------------------------------------\n\n/** Default buttons layout — white card button, neutral borders. */\nexport const BUTTONS_LAYOUT_DEFAULT: ButtonsLayoutStyles = {};\n\n/** Minimal buttons layout — borderless, subtle hover. */\nexport const BUTTONS_LAYOUT_MINIMAL: ButtonsLayoutStyles = {\n cardButton: {\n border: 'none',\n backgroundColor: '#f9fafb',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#f9fafb',\n border: 'none',\n },\n cardInputBorder: '#e5e7eb',\n backButtonIcon: {\n backgroundColor: '#e5e7eb',\n },\n submitButton: {\n borderRadius: '6px',\n },\n};\n\n/** Rounded buttons layout — large border radius, soft shadows. */\nexport const BUTTONS_LAYOUT_ROUNDED: ButtonsLayoutStyles = {\n cardButton: {\n borderRadius: '9999px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 1px 3px rgba(0,0,0,0.06)',\n },\n cardFormContainer: {\n borderRadius: '16px',\n border: '1px solid #e5e7eb',\n boxShadow: '0 2px 8px rgba(0,0,0,0.06)',\n },\n cardInputBorder: '#d1d5db',\n submitButton: {\n borderRadius: '9999px',\n },\n backButtonIcon: {\n backgroundColor: '#f3f4f6',\n },\n};\n\n/** Dark buttons layout — dark backgrounds, light text. */\nexport const BUTTONS_LAYOUT_DARK: ButtonsLayoutStyles = {\n cardButton: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n border: '1px solid #374151',\n boxShadow: 'none',\n },\n cardFormContainer: {\n backgroundColor: '#111827',\n border: '1px solid #374151',\n },\n cardInputBorder: '#4b5563',\n cardInputColor: '#f9fafb',\n cardInputPlaceholderColor: '#6b7280',\n cardInputBackground: '#1f2937',\n nameInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n backButton: {\n color: '#9ca3af',\n },\n backButtonIcon: {\n backgroundColor: '#374151',\n },\n submitButton: {\n backgroundColor: '#6366f1',\n },\n title: {\n color: '#f9fafb',\n },\n countrySelect: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n zipInput: {\n backgroundColor: '#1f2937',\n color: '#f9fafb',\n },\n};\n\n/** Resolve a buttons layout theme name to its style preset. */\nexport function resolveButtonsLayoutTheme(theme?: ButtonsLayoutTheme): ButtonsLayoutStyles {\n switch (theme) {\n case 'minimal': return BUTTONS_LAYOUT_MINIMAL;\n case 'rounded': return BUTTONS_LAYOUT_ROUNDED;\n case 'dark': return BUTTONS_LAYOUT_DARK;\n default: return BUTTONS_LAYOUT_DEFAULT;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Supported Element Types\n// ---------------------------------------------------------------------------\n\n/** All supported element type identifiers. */\nexport const ELEMENT_TYPES = [\n 'payment',\n 'card',\n 'cardNumber',\n 'cardExpiry',\n 'cardCvc',\n 'address',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Supported Card Brands\n// ---------------------------------------------------------------------------\n\nexport const SUPPORTED_CARD_BRANDS = [\n 'visa',\n 'mastercard',\n 'mastercard_debit',\n 'amex',\n 'discover',\n] as const;\n\n// ---------------------------------------------------------------------------\n// Currency Mapping (from checkout project)\n// ---------------------------------------------------------------------------\n\n/** Country code to currency information mapping. */\nexport const CURRENCY_MAP: Record<string, CurrencyInfo> = {\n // EUR (VAT applies)\n AT: { currency: 'EUR', symbol: '\\u20AC', country: 'Austria', countryCode: 'AT', tax: 1 },\n BE: { currency: 'EUR', symbol: '\\u20AC', country: 'Belgium', countryCode: 'BE', tax: 1 },\n CY: { currency: 'EUR', symbol: '\\u20AC', country: 'Cyprus', countryCode: 'CY', tax: 1 },\n DE: { currency: 'EUR', symbol: '\\u20AC', country: 'Germany', countryCode: 'DE', tax: 1 },\n EE: { currency: 'EUR', symbol: '\\u20AC', country: 'Estonia', countryCode: 'EE', tax: 1 },\n ES: { currency: 'EUR', symbol: '\\u20AC', country: 'Spain', countryCode: 'ES', tax: 1 },\n FI: { currency: 'EUR', symbol: '\\u20AC', country: 'Finland', countryCode: 'FI', tax: 1 },\n FR: { currency: 'EUR', symbol: '\\u20AC', country: 'France', countryCode: 'FR', tax: 1 },\n GR: { currency: 'EUR', symbol: '\\u20AC', country: 'Greece', countryCode: 'GR', tax: 1 },\n HR: { currency: 'EUR', symbol: '\\u20AC', country: 'Croatia', countryCode: 'HR', tax: 1 },\n IE: { currency: 'EUR', symbol: '\\u20AC', country: 'Ireland', countryCode: 'IE', tax: 1 },\n IT: { currency: 'EUR', symbol: '\\u20AC', country: 'Italy', countryCode: 'IT', tax: 1 },\n LT: { currency: 'EUR', symbol: '\\u20AC', country: 'Lithuania', countryCode: 'LT', tax: 1 },\n LU: { currency: 'EUR', symbol: '\\u20AC', country: 'Luxembourg', countryCode: 'LU', tax: 1 },\n LV: { currency: 'EUR', symbol: '\\u20AC', country: 'Latvia', countryCode: 'LV', tax: 1 },\n MT: { currency: 'EUR', symbol: '\\u20AC', country: 'Malta', countryCode: 'MT', tax: 1 },\n NL: { currency: 'EUR', symbol: '\\u20AC', country: 'Netherlands', countryCode: 'NL', tax: 1 },\n PT: { currency: 'EUR', symbol: '\\u20AC', country: 'Portugal', countryCode: 'PT', tax: 1 },\n SI: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovenia', countryCode: 'SI', tax: 1 },\n SK: { currency: 'EUR', symbol: '\\u20AC', country: 'Slovakia', countryCode: 'SK', tax: 1 },\n BG: { currency: 'EUR', symbol: '\\u20AC', country: 'Bulgaria', countryCode: 'BG', tax: 1 },\n RO: { currency: 'EUR', symbol: '\\u20AC', country: 'Romania', countryCode: 'RO', tax: 1 },\n CZ: { currency: 'EUR', symbol: '\\u20AC', country: 'Czech Republic', countryCode: 'CZ', tax: 1 },\n SE: { currency: 'EUR', symbol: '\\u20AC', country: 'Sweden', countryCode: 'SE', tax: 1 },\n DK: { currency: 'EUR', symbol: '\\u20AC', country: 'Denmark', countryCode: 'DK', tax: 1 },\n PL: { currency: 'EUR', symbol: '\\u20AC', country: 'Poland', countryCode: 'PL', tax: 1 },\n HU: { currency: 'EUR', symbol: '\\u20AC', country: 'Hungary', countryCode: 'HU', tax: 1 },\n // GBP (VAT applies)\n GB: { currency: 'GBP', symbol: '\\u00A3', country: 'United Kingdom', countryCode: 'GB', tax: 1 },\n // USD (no VAT)\n US: { currency: 'USD', symbol: '$', country: 'United States', countryCode: 'US', tax: 0 },\n // CAD (no VAT)\n CA: { currency: 'CAD', symbol: 'CA$', country: 'Canada', countryCode: 'CA', tax: 0 },\n // NZD (no VAT)\n NZ: { currency: 'NZD', symbol: 'NZ$', country: 'New Zealand', countryCode: 'NZ', tax: 0 },\n // AUD (no VAT)\n AU: { currency: 'AUD', symbol: 'AU$', country: 'Australia', countryCode: 'AU', tax: 0 },\n};\n\n/** Default currency info when country is unknown. */\nexport const DEFAULT_CURRENCY: CurrencyInfo = {\n currency: 'USD',\n symbol: '$',\n country: 'United States',\n countryCode: 'US',\n tax: 0,\n};\n\n// ---------------------------------------------------------------------------\n// Postal Code Labels\n// ---------------------------------------------------------------------------\n\n/** Returns the correct postal code label for a country code (ISO 3166-1 alpha-2). */\nexport function getPostalCodeLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'ZIP Code';\n case 'GB': return 'Postcode';\n case 'CA': return 'Postal Code';\n case 'AU':\n case 'NZ': return 'Postcode';\n case 'IE': return 'Eircode';\n default: return 'Postal Code';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Country List (ISO 3166-1 alpha-2)\n// ---------------------------------------------------------------------------\n\nconst regionNames = new Intl.DisplayNames(['en'], { type: 'region' });\n\nfunction codeToFlag(code: string): string {\n return [...code.toUpperCase()]\n .map((c) => String.fromCodePoint(0x1f1e6 - 65 + c.charCodeAt(0)))\n .join('');\n}\n\n/** Priority countries shown first in dropdowns. */\nconst PRIORITY_CODES = ['US', 'GB', 'CA', 'AU', 'NZ', 'IE', 'DE', 'FR'];\n\nconst ALL_CODES = [\n 'AD', 'AE', 'AF', 'AG', 'AL', 'AM', 'AO', 'AR', 'AT', 'AU',\n 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ',\n 'BN', 'BO', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CD',\n 'CF', 'CG', 'CH', 'CI', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU',\n 'CV', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC',\n 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FM', 'FR', 'GA',\n 'GB', 'GD', 'GE', 'GH', 'GM', 'GN', 'GQ', 'GR', 'GT', 'GW',\n 'GY', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IQ',\n 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI',\n 'KM', 'KN', 'KR', 'KW', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK',\n 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME',\n 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MR', 'MT', 'MU', 'MV',\n 'MW', 'MX', 'MY', 'MZ', 'NA', 'NE', 'NG', 'NI', 'NL', 'NO',\n 'NP', 'NR', 'NZ', 'OM', 'PA', 'PE', 'PG', 'PH', 'PK', 'PL',\n 'PT', 'PW', 'PY', 'QA', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB',\n 'SC', 'SD', 'SE', 'SG', 'SI', 'SK', 'SL', 'SM', 'SN', 'SO',\n 'SR', 'SS', 'ST', 'SV', 'SY', 'SZ', 'TD', 'TG', 'TH', 'TJ',\n 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA',\n 'UG', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VN', 'VU', 'WS',\n 'XK', 'YE', 'ZA', 'ZM', 'ZW',\n] as const;\n\nfunction buildCountryOption(code: string): CountryOption {\n return { code, name: regionNames.of(code) ?? code, flag: codeToFlag(code) };\n}\n\nconst prioritySet = new Set(PRIORITY_CODES);\nconst rest = ALL_CODES.filter((c) => !prioritySet.has(c));\n\n/** All countries for dropdown select, priority countries first. */\nexport const COUNTRY_OPTIONS: CountryOption[] = [\n ...PRIORITY_CODES.map(buildCountryOption),\n ...rest.map(buildCountryOption),\n];\n\n/** Look up a country option by ISO 3166-1 alpha-2 code. */\nexport function getCountryByCode(code: string): CountryOption | undefined {\n return COUNTRY_OPTIONS.find((c) => c.code === code);\n}\n\n// ---------------------------------------------------------------------------\n// AVS Configuration Helpers\n// ---------------------------------------------------------------------------\n\n/** Default AVS config when `enableAVS: true` (backward compatible — country + postal code). */\nconst DEFAULT_AVS_CONFIG: AVSFieldConfig = {\n country: true,\n postal_code: true,\n};\n\n/**\n * Normalize `enableAVS` to a resolved config object.\n * - `false` / `undefined` → `null` (AVS disabled)\n * - `true` → default config (country + postal_code)\n * - `AVSFieldConfig` → returned as-is\n */\nexport function resolveAVSConfig(enableAVS?: boolean | AVSFieldConfig): AVSFieldConfig | null {\n if (!enableAVS) return null;\n if (enableAVS === true) return DEFAULT_AVS_CONFIG;\n return enableAVS;\n}\n\n/**\n * Check if an AVS field should be visible for the given country.\n * - `undefined` / `false` → hidden\n * - `true` → visible for all countries\n * - `string[]` → visible only for listed country codes\n */\nexport function isAVSFieldVisible(\n field: boolean | string[] | undefined,\n country: string,\n): boolean {\n if (field === undefined || field === false) return false;\n if (field === true) return true;\n const normalizedCountry = country.trim().toUpperCase();\n return field.some((code) => code.trim().toUpperCase() === normalizedCountry);\n}\n\n/** Returns true if any AVS field is meaningfully configured (at least one field is truthy). */\nexport function isAVSEnabled(enableAVS?: boolean | AVSFieldConfig): boolean {\n const config = resolveAVSConfig(enableAVS);\n if (!config) return false;\n return Object.values(config).some(\n (v) => v === true || (Array.isArray(v) && v.length > 0),\n );\n}\n\n// ---------------------------------------------------------------------------\n// US States & CA Provinces\n// ---------------------------------------------------------------------------\n\nexport interface StateOption {\n code: string;\n name: string;\n}\n\nexport const US_STATES: StateOption[] = [\n { code: 'AL', name: 'Alabama' },\n { code: 'AK', name: 'Alaska' },\n { code: 'AZ', name: 'Arizona' },\n { code: 'AR', name: 'Arkansas' },\n { code: 'CA', name: 'California' },\n { code: 'CO', name: 'Colorado' },\n { code: 'CT', name: 'Connecticut' },\n { code: 'DE', name: 'Delaware' },\n { code: 'DC', name: 'District of Columbia' },\n { code: 'FL', name: 'Florida' },\n { code: 'GA', name: 'Georgia' },\n { code: 'HI', name: 'Hawaii' },\n { code: 'ID', name: 'Idaho' },\n { code: 'IL', name: 'Illinois' },\n { code: 'IN', name: 'Indiana' },\n { code: 'IA', name: 'Iowa' },\n { code: 'KS', name: 'Kansas' },\n { code: 'KY', name: 'Kentucky' },\n { code: 'LA', name: 'Louisiana' },\n { code: 'ME', name: 'Maine' },\n { code: 'MD', name: 'Maryland' },\n { code: 'MA', name: 'Massachusetts' },\n { code: 'MI', name: 'Michigan' },\n { code: 'MN', name: 'Minnesota' },\n { code: 'MS', name: 'Mississippi' },\n { code: 'MO', name: 'Missouri' },\n { code: 'MT', name: 'Montana' },\n { code: 'NE', name: 'Nebraska' },\n { code: 'NV', name: 'Nevada' },\n { code: 'NH', name: 'New Hampshire' },\n { code: 'NJ', name: 'New Jersey' },\n { code: 'NM', name: 'New Mexico' },\n { code: 'NY', name: 'New York' },\n { code: 'NC', name: 'North Carolina' },\n { code: 'ND', name: 'North Dakota' },\n { code: 'OH', name: 'Ohio' },\n { code: 'OK', name: 'Oklahoma' },\n { code: 'OR', name: 'Oregon' },\n { code: 'PA', name: 'Pennsylvania' },\n { code: 'RI', name: 'Rhode Island' },\n { code: 'SC', name: 'South Carolina' },\n { code: 'SD', name: 'South Dakota' },\n { code: 'TN', name: 'Tennessee' },\n { code: 'TX', name: 'Texas' },\n { code: 'UT', name: 'Utah' },\n { code: 'VT', name: 'Vermont' },\n { code: 'VA', name: 'Virginia' },\n { code: 'WA', name: 'Washington' },\n { code: 'WV', name: 'West Virginia' },\n { code: 'WI', name: 'Wisconsin' },\n { code: 'WY', name: 'Wyoming' },\n];\n\nexport const CA_PROVINCES: StateOption[] = [\n { code: 'AB', name: 'Alberta' },\n { code: 'BC', name: 'British Columbia' },\n { code: 'MB', name: 'Manitoba' },\n { code: 'NB', name: 'New Brunswick' },\n { code: 'NL', name: 'Newfoundland and Labrador' },\n { code: 'NS', name: 'Nova Scotia' },\n { code: 'NT', name: 'Northwest Territories' },\n { code: 'NU', name: 'Nunavut' },\n { code: 'ON', name: 'Ontario' },\n { code: 'PE', name: 'Prince Edward Island' },\n { code: 'QC', name: 'Quebec' },\n { code: 'SK', name: 'Saskatchewan' },\n { code: 'YT', name: 'Yukon' },\n];\n\n/**\n * Get state/province options for a country.\n * Returns a list for US and CA, or `null` for countries where a free-text input is appropriate.\n */\nexport function getStateOptions(country: string): StateOption[] | null {\n switch (country.toUpperCase()) {\n case 'US': return US_STATES;\n case 'CA': return CA_PROVINCES;\n default: return null;\n }\n}\n\n/** Returns the appropriate label for the state/province field based on country. */\nexport function getStateLabel(countryCode: string): string {\n switch (countryCode.toUpperCase()) {\n case 'US': return 'State';\n case 'CA': return 'Province';\n case 'GB': return 'County';\n case 'AU': return 'State / Territory';\n default: return 'State / Province / Region';\n }\n}\n","/**\n * Postal-code → state derivation for AVS.\n *\n * Used when the form configuration shows `address_line_1` but hides the\n * `state` input — we still want to populate `billing_details.address.state`\n * so Stripe Radar gets a richer address signal. Currently supports US and CA;\n * other countries return `null` (caller should fall back to omitting state).\n */\n\n/**\n * US 3-digit ZIP-prefix ranges → state code (USPS Sectional Center Facility).\n * Sourced from the public USPS SCF table. Each entry is `[startPrefix, endPrefix, stateCode]`,\n * inclusive on both ends. Coverage is contiguous within a state; gaps in the table\n * (e.g. unused 3-digit prefixes) are intentional and resolve to `null`.\n */\nconst US_ZIP_PREFIX_RANGES: ReadonlyArray<readonly [number, number, string]> = [\n [5, 5, 'NY'],\n [10, 27, 'MA'],\n [28, 29, 'RI'],\n [30, 38, 'NH'],\n [39, 49, 'ME'],\n [50, 59, 'VT'],\n [60, 69, 'CT'],\n [70, 89, 'NJ'],\n [100, 149, 'NY'],\n [150, 196, 'PA'],\n [197, 199, 'DE'],\n [200, 205, 'DC'],\n [206, 219, 'MD'],\n [220, 246, 'VA'],\n [247, 268, 'WV'],\n [270, 289, 'NC'],\n [290, 299, 'SC'],\n [300, 319, 'GA'],\n [320, 349, 'FL'],\n [350, 369, 'AL'],\n [370, 385, 'TN'],\n [386, 397, 'MS'],\n [398, 399, 'GA'],\n [400, 427, 'KY'],\n [430, 459, 'OH'],\n [460, 479, 'IN'],\n [480, 499, 'MI'],\n [500, 528, 'IA'],\n [530, 549, 'WI'],\n [550, 567, 'MN'],\n [570, 577, 'SD'],\n [580, 588, 'ND'],\n [590, 599, 'MT'],\n [600, 629, 'IL'],\n [630, 658, 'MO'],\n [660, 679, 'KS'],\n [680, 693, 'NE'],\n [700, 714, 'LA'],\n [716, 729, 'AR'],\n [730, 749, 'OK'],\n [750, 799, 'TX'],\n [800, 816, 'CO'],\n [820, 831, 'WY'],\n [832, 838, 'ID'],\n [840, 847, 'UT'],\n [850, 865, 'AZ'],\n [870, 884, 'NM'],\n [889, 898, 'NV'],\n [900, 961, 'CA'],\n [967, 968, 'HI'],\n [970, 979, 'OR'],\n [980, 994, 'WA'],\n [995, 999, 'AK'],\n];\n\n/**\n * CA postal-code first letter → province code (Forward Sortation Area).\n * The first letter of every Canadian postal code identifies the province\n * uniquely, except `X` which is shared by Northwest Territories and Nunavut\n * — we resolve it to `NT` because the volume strongly favours NT.\n */\nconst CA_FSA_FIRST_LETTER_TO_PROVINCE: Readonly<Record<string, string>> = {\n A: 'NL',\n B: 'NS',\n C: 'PE',\n E: 'NB',\n G: 'QC',\n H: 'QC',\n J: 'QC',\n K: 'ON',\n L: 'ON',\n M: 'ON',\n N: 'ON',\n P: 'ON',\n R: 'MB',\n S: 'SK',\n T: 'AB',\n V: 'BC',\n X: 'NT',\n Y: 'YT',\n};\n\nfunction deriveUsState(zip: string): string | null {\n const digits = zip.replace(/\\D/g, '');\n if (digits.length < 5) return null;\n const prefix = Number.parseInt(digits.slice(0, 3), 10);\n if (!Number.isFinite(prefix)) return null;\n\n for (const [start, end, code] of US_ZIP_PREFIX_RANGES) {\n if (prefix >= start && prefix <= end) return code;\n }\n return null;\n}\n\nfunction deriveCaProvince(postalCode: string): string | null {\n const compact = postalCode.replace(/\\s+/g, '').toUpperCase();\n if (!/^[A-Z]\\d[A-Z]\\d[A-Z]\\d$/.test(compact)) return null;\n const firstLetter = compact[0] ?? '';\n return CA_FSA_FIRST_LETTER_TO_PROVINCE[firstLetter] ?? null;\n}\n\n/**\n * Resolve a state / province code from a postal code for the given country.\n *\n * - US: 5-digit ZIP → 2-letter USPS state code (uses 3-digit prefix table).\n * - CA: A1A 1A1 → 2-letter ISO 3166-2:CA province code (first-letter mapping).\n * - All other countries: `null`.\n *\n * Returns `null` when the postal code is malformed or falls in an unmapped\n * range. Callers should treat `null` as \"skip — don't derive\".\n */\nexport function getStateFromPostalCode(\n country: string,\n postalCode: string,\n): string | null {\n if (!country || !postalCode) return null;\n const normalizedCountry = country.trim().toUpperCase();\n const normalizedZip = postalCode.trim();\n if (!normalizedZip) return null;\n\n switch (normalizedCountry) {\n case 'US':\n return deriveUsState(normalizedZip);\n case 'CA':\n return deriveCaProvince(normalizedZip);\n default:\n return null;\n }\n}\n","import type { CheckoutItem, CheckoutSubscription } from './types.js';\n\n/**\n * Return the trimmed string when it has at least one non-whitespace character,\n * otherwise undefined. Used so that empty and whitespace-only inputs flow\n * through the same fallback chain as `undefined`.\n */\nfunction nonBlank(value: string | null | undefined): string | undefined {\n if (typeof value !== 'string') return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\n/**\n * Resolve the session-level currency, honoring the documented fallback:\n * `session.currency ?? items[*].currency ?? subscriptions[*].currency`.\n *\n * Returns the first non-blank currency found, or 'USD' when nothing is set.\n * Empty and whitespace-only strings are treated as unset so they do not\n * bypass the fallback chain.\n */\nexport function resolveSessionCurrency(\n sessionCurrency: string | undefined,\n items: ReadonlyArray<{ currency?: string }> | undefined,\n subscriptions: ReadonlyArray<{ currency?: string }> | undefined,\n): string {\n const session = nonBlank(sessionCurrency);\n if (session) return session;\n for (const item of items ?? []) {\n const c = nonBlank(item.currency);\n if (c) return c;\n }\n for (const sub of subscriptions ?? []) {\n const c = nonBlank(sub.currency);\n if (c) return c;\n }\n return 'USD';\n}\n\n/**\n * Build the request payload for a single item.\n *\n * Sends the new `code` field alongside the deprecated `providerItemId`,\n * `providerItemName`, `totalAmount`, and `overrideAmount` fields so that\n * both new and old backend versions accept the same request body.\n */\nexport function buildItemPayload(\n item: CheckoutItem,\n sessionCurrency: string,\n): Record<string, unknown> {\n const code = nonBlank(item.code) ?? nonBlank(item.providerItemId);\n if (!code) {\n throw new Error('CheckoutItem requires either `code` or the deprecated `providerItemId`.');\n }\n const itemName = nonBlank(item.itemName) ?? nonBlank(item.providerItemName) ?? null;\n\n const payload: Record<string, unknown> = {\n code,\n providerItemId: nonBlank(item.providerItemId) ?? code,\n itemName,\n providerItemName: nonBlank(item.providerItemName) ?? itemName,\n quantity: item.quantity ?? 1,\n totalAmount: item.totalAmount,\n overrideAmount: item.overrideAmount ?? null,\n currency: nonBlank(item.currency) ?? sessionCurrency,\n };\n\n if (item.metadata) {\n payload['metadata'] = item.metadata;\n }\n\n return payload;\n}\n\n/**\n * Build the request payload for a single subscription.\n *\n * Sends the new `code` field alongside the deprecated `providerPlanId`,\n * `providerPlanName`, `totalAmount`, and `overrideAmount` fields for\n * backward compatibility.\n */\nexport function buildSubscriptionPayload(\n subscription: CheckoutSubscription,\n sessionCurrency: string,\n): Record<string, unknown> {\n const code = nonBlank(subscription.code) ?? nonBlank(subscription.providerPlanId);\n if (!code) {\n throw new Error(\n 'CheckoutSubscription requires either `code` or the deprecated `providerPlanId`.',\n );\n }\n const subscriptionName =\n nonBlank(subscription.subscriptionName) ?? nonBlank(subscription.providerPlanName) ?? null;\n\n const payload: Record<string, unknown> = {\n code,\n providerPlanId: nonBlank(subscription.providerPlanId) ?? code,\n subscriptionName,\n providerPlanName: nonBlank(subscription.providerPlanName) ?? subscriptionName,\n quantity: subscription.quantity ?? 1,\n totalAmount: subscription.totalAmount,\n overrideAmount: subscription.overrideAmount ?? null,\n currency: nonBlank(subscription.currency) ?? sessionCurrency,\n };\n\n if (subscription.metadata) {\n payload['metadata'] = subscription.metadata;\n }\n\n return payload;\n}\n","import { resolveSessionCurrency } from './checkout-payload.js';\nimport type { CheckoutSession } from './types.js';\n\n/** A single line item formatted for display in the checkout UI. */\nexport interface DisplayLineItem {\n name: string;\n quantity: number;\n /** Price per unit in the session's currency (major units, e.g. 24.95). */\n price: number;\n /** Original price per unit before any discount (major units). */\n originalPrice: number;\n}\n\n/** Computed display data for rendering an order summary. */\nexport interface CheckoutDisplayData {\n /** Individual items/subscriptions with names, prices, and quantities. */\n items: DisplayLineItem[];\n /** ISO 4217 currency code (uppercase). */\n currency: string;\n /** Total amount due after discounts (major units, e.g. 24.95). */\n total: number;\n /** Sum of original prices before discounts (major units). */\n originalTotal: number;\n /** Total savings (originalTotal - total), clamped to >= 0. */\n totalSave: number;\n /** Discount percentage (0–100). */\n discountPercent: number;\n}\n\n/** Options for {@link buildCheckoutDisplayData}. */\nexport interface BuildCheckoutDisplayDataOptions {\n /**\n * When `true`, items are hidden from the order summary if the session also\n * contains subscriptions (matches the legacy checkout/CheckoutModal\n * behavior). Defaults to `false` — items are always shown.\n */\n hideBundledItems?: boolean;\n}\n\n/**\n * Builds display data from a `CheckoutSession` for rendering an order summary.\n *\n * - Subscriptions are always shown\n * - Items are shown by default; pass `{ hideBundledItems: true }` to suppress\n * them when the session also contains subscriptions (legacy behavior)\n * - `overrideAmount` (when not null/undefined) is the discounted price\n * - Plan name \"4-WEEK PLAN\" with price <= 1 is renamed to \"7-DAY TRIAL: FULL ACCESS\"\n * - Discount percentage and savings are computed from the difference\n *\n * All amounts are in **major currency units** (dollars, not cents).\n *\n * @example\n * ```ts\n * import { buildCheckoutDisplayData } from '@flopay/shared';\n *\n * const display = buildCheckoutDisplayData(session);\n * // display.items → [{ name: 'Starter', price: 24.95, originalPrice: 24.95, quantity: 1 }]\n * // display.total → 24.95\n * // display.currency → 'EUR'\n * ```\n */\nexport function buildCheckoutDisplayData(\n session: CheckoutSession,\n options: BuildCheckoutDisplayDataOptions = {},\n): CheckoutDisplayData {\n const itemsList: DisplayLineItem[] = [];\n\n const subscriptions = session.subscriptions ?? [];\n const items = session.items ?? [];\n\n // Resolve currency once: session > first item > first subscription > USD.\n const currency = resolveSessionCurrency(session.currency, items, subscriptions).toUpperCase();\n\n // Subscriptions\n for (const sub of subscriptions) {\n const originalPrice = sub.totalAmount ?? 0;\n const discountedPrice = sub.overrideAmount ?? originalPrice;\n\n // Match checkout/CheckoutModal: rename \"4-WEEK PLAN\" to \"7-DAY TRIAL: FULL ACCESS\"\n // when the discounted price is $1 or less\n let name = sub.subscriptionName || sub.providerPlanName || sub.code || 'Subscription';\n if (name === '4-WEEK PLAN' && discountedPrice <= 1) {\n name = '7-DAY TRIAL: FULL ACCESS';\n }\n\n itemsList.push({\n name,\n quantity: sub.quantity,\n price: discountedPrice,\n originalPrice,\n });\n }\n\n // Items are shown by default. Opt-in `hideBundledItems` hides them when\n // the session also contains subscriptions (legacy checkout/CheckoutModal\n // behavior).\n const hideItems =\n options.hideBundledItems === true\n && subscriptions.length > 0\n && items.length > 0;\n\n if (!hideItems) {\n for (const item of items) {\n const originalPrice = item.totalAmount ?? 0;\n const discountedPrice = item.overrideAmount ?? originalPrice;\n\n itemsList.push({\n name: item.itemName || item.providerItemName || item.code || 'Item',\n quantity: item.quantity,\n price: discountedPrice,\n originalPrice,\n });\n }\n }\n\n // Fallback if session has no items/subscriptions\n if (itemsList.length === 0) {\n itemsList.push({\n name: 'Purchase',\n quantity: 1,\n price: session.amount / 100,\n originalPrice: session.amount / 100,\n });\n }\n\n const originalTotal = itemsList.reduce((sum, i) => sum + i.originalPrice * i.quantity, 0);\n const total = itemsList.reduce((sum, i) => sum + i.price * i.quantity, 0);\n const totalSave = Math.max(0, originalTotal - total);\n const discountPercent = originalTotal > 0\n ? Math.round((totalSave / originalTotal) * 100)\n : 0;\n\n return {\n items: itemsList,\n currency,\n total,\n originalTotal,\n totalSave,\n discountPercent,\n };\n}\n","import type { CurrencyInfo } from './types.js';\nimport { CURRENCY_MAP, DEFAULT_CURRENCY } from './constants.js';\n\n/**\n * Look up currency information by ISO 3166-1 alpha-2 country code.\n * Falls back to USD when the country is not in the map.\n */\nexport function getCurrencyByCountry(countryCode: string): CurrencyInfo {\n return CURRENCY_MAP[countryCode.toUpperCase()] ?? DEFAULT_CURRENCY;\n}\n\n/** Returns `true` if the string looks like a Stripe publishable key. */\nexport function isValidPublishableKey(key: string): boolean {\n return /^pk_(test|live)_[A-Za-z0-9]+$/.test(key);\n}\n\n/** Returns `true` if the string looks like a Stripe secret key. */\nexport function isValidSecretKey(key: string): boolean {\n return /^sk_(test|live)_[A-Za-z0-9]+$/.test(key);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAOrC,YACE,SACA,MACA,SACA;AACA,UAAM,OAAO;AACb,SAAK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