@paypercut/checkout-js 1.3.0 → 1.4.0

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.d.ts CHANGED
@@ -488,7 +488,7 @@ interface PaypercutOptions {
488
488
  hostedCheckoutUrl?: string;
489
489
  /** Internal builds only. Production builds ignore this override. */
490
490
  apiUrl?: string;
491
- /** Internal builds only. Ignored by production builds. */
491
+ /** Enables the optional Developer Assistant integration tool. Defaults to false. */
492
492
  developerAssistant?: boolean;
493
493
  }
494
494
  /** Browser-side intent prepared by one Elements group. */
package/dist/index.mjs CHANGED
@@ -100,6 +100,8 @@ class Emitter {
100
100
  }
101
101
  }
102
102
 
103
+ const SDK_VERSION = "1.4.0";
104
+
103
105
  /**
104
106
  * Build-time configuration
105
107
  *
@@ -111,8 +113,7 @@ class Emitter {
111
113
  * Production configuration (for merchants)
112
114
  */
113
115
  const productionConfig = {
114
- version: "1.3.0",
115
- mode: 'production',
116
+ version: SDK_VERSION,
116
117
  defaultCheckoutOrigin: 'https://buy.paypercut.io',
117
118
  defaultApiOrigin: 'https://api.paypercut.io',
118
119
  defaultVaultApiUrl: 'https://api.basistheory.com',
@@ -2446,6 +2447,7 @@ const ElementsControllerCommandType = {
2446
2447
  CancelComponentSubmission: 'PAYPERCUT_ELEMENTS_CONTROLLER_CANCEL_COMPONENT_SUBMISSION',
2447
2448
  AttachActionChannel: 'PAYPERCUT_ELEMENTS_CONTROLLER_ATTACH_ACTION_CHANNEL',
2448
2449
  UpdateOptions: 'PAYPERCUT_ELEMENTS_CONTROLLER_UPDATE_OPTIONS',
2450
+ DiscoverDeveloperPresets: 'PAYPERCUT_ELEMENTS_CONTROLLER_DISCOVER_DEVELOPER_PRESETS',
2449
2451
  ApplyDeveloperPreset: 'PAYPERCUT_ELEMENTS_CONTROLLER_APPLY_DEVELOPER_PRESET',
2450
2452
  ApplePayCapabilities: 'PAYPERCUT_ELEMENTS_CONTROLLER_APPLE_PAY_CAPABILITIES',
2451
2453
  ApplePayValidateMerchant: 'PAYPERCUT_ELEMENTS_CONTROLLER_APPLE_PAY_VALIDATE_MERCHANT',
@@ -2967,144 +2969,147 @@ const isDeveloperPreset = (value) => isRecord$2(value) &&
2967
2969
  /^\d{4}$/.test(value.last4) &&
2968
2970
  ['success', 'challenge', 'warning', 'danger'].includes(String(value.tone));
2969
2971
 
2970
- const LIGHT_VARIABLES = {
2971
- colorPrimary: '#0570de',
2972
- colorPrimaryText: '#ffffff',
2973
- colorBackground: '#ffffff',
2974
- colorSurface: '#ffffff',
2975
- colorText: '#2b2d2f',
2976
- colorTextSecondary: '#6a6c6f',
2977
- colorTextPlaceholder: '#737474',
2978
- colorDanger: '#cc1818',
2979
- colorSuccess: '#30b130',
2980
- colorWarning: '#e69e2c',
2981
- colorBorder: '#d7dde0',
2982
- colorFocus: '#0570de',
2983
- colorMuted: '#f2f4f5',
2984
- fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
2985
- fontSizeBase: '16px',
2986
- fontWeightNormal: '400',
2987
- fontWeightMedium: '500',
2988
- lineHeight: '1.5',
2989
- spacingUnit: '4px',
2990
- gridColumnSpacing: '12px',
2991
- gridRowSpacing: '12px',
2992
- labelSpacing: '6px',
2993
- borderRadius: '4px',
2994
- buttonBorderRadius: '4px',
2995
- buttonExpressCheckoutBorderRadius: '4px',
2996
- buttonPadding: '12px',
2997
- };
2998
- const DARK_VARIABLES = {
2999
- ...LIGHT_VARIABLES,
3000
- colorBackground: '#15171c',
3001
- colorSurface: '#1d2027',
3002
- colorText: '#f3f4f6',
3003
- colorTextSecondary: '#aeb7c7',
3004
- colorTextPlaceholder: '#8f99aa',
3005
- colorBorder: '#3a404b',
3006
- colorFocus: '#7db7ff',
3007
- colorMuted: '#252932',
3008
- };
3009
- const VARIABLE_NAMES = new Set(Object.keys(LIGHT_VARIABLES));
3010
- const PUBLIC_VARIABLE_REFERENCE = /var\(\s*--([A-Za-z][A-Za-z0-9]*)\s*\)/g;
3011
- function resolveCardFieldAppearance(appearance) {
3012
- const theme = appearance?.theme ?? 'light';
3013
- const themeVariables = theme === 'dark' ? DARK_VARIABLES : LIGHT_VARIABLES;
3014
- const overrides = Object.fromEntries(Object.entries(appearance?.variables ?? {}).filter(([name, value]) => VARIABLE_NAMES.has(name) && typeof value === 'string'));
3015
- return {
3016
- theme,
3017
- disableAnimations: appearance?.disableAnimations ?? false,
3018
- variables: {
3019
- ...themeVariables,
3020
- ...overrides,
3021
- },
3022
- };
2972
+ const DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT = 'paypercut-developer-assistance.iife.min.js';
2973
+ const DEVELOPER_ASSISTANCE_MODULE_ARTIFACT = 'developer-assistance.mjs';
2974
+ const DEVELOPER_ASSISTANCE_LOAD_DIAGNOSTIC = '[Paypercut Elements] developer_assistance_load_failed: Developer Assistant is unavailable. The SDK and Elements continue to work.';
2975
+ const IIFE_ARTIFACT_PATH = /\/paypercut-checkout(?:-dev)?\.iife\.min\.js$/;
2976
+ // Rollup rewrites import.meta.url for CommonJS and classic-script bundles, so
2977
+ // this remains the URL of the exact core artifact that owns the registration
2978
+ // boundary in every supported format.
2979
+ const coreArtifactUrl = typeof __filename === 'string' ? fileUrlFor(__filename) : import.meta.url;
2980
+ const classicScriptUrl = typeof document === 'undefined' ? null : (document.currentScript?.getAttribute('src') ?? null);
2981
+ let loadRequested = false;
2982
+ function requestDeveloperAssistance(isInstalled) {
2983
+ if (loadRequested || isInstalled())
2984
+ return;
2985
+ loadRequested = true;
2986
+ if (!canLoadDeveloperAssistance()) {
2987
+ warnDeveloperAssistanceUnavailable();
2988
+ return;
2989
+ }
2990
+ void Promise.resolve()
2991
+ .then(loadDeveloperAssistance)
2992
+ .then(() => {
2993
+ if (!isInstalled())
2994
+ throw new Error();
2995
+ })
2996
+ .catch(warnDeveloperAssistanceUnavailable);
3023
2997
  }
3024
- /** Resolve one semantic public rule to concrete provider/DOM style values. */
3025
- function resolveCardFieldAppearanceRule(appearance, selector) {
3026
- const rule = appearance?.rules?.[selector];
3027
- if (!rule)
3028
- return {};
3029
- const variables = resolveCardFieldAppearance(appearance).variables;
3030
- return Object.fromEntries(Object.entries(rule).flatMap(([property, value]) => {
3031
- if (typeof value !== 'string' || !isSafeElementsAppearanceValue(value))
3032
- return [];
3033
- return [
3034
- [
3035
- property,
3036
- value.replace(PUBLIC_VARIABLE_REFERENCE, (match, name) => name in variables ? variables[name] : match),
3037
- ],
3038
- ];
3039
- }));
2998
+ function warnDeveloperAssistanceUnavailable() {
2999
+ console.warn(DEVELOPER_ASSISTANCE_LOAD_DIAGNOSTIC);
3040
3000
  }
3041
- /**
3042
- * Compile the secure Basis Theory input style from the Hosted Checkout token
3043
- * baseline. Provider fields cannot inherit merchant-document CSS, so every
3044
- * public token and variable reference is resolved before crossing the provider
3045
- * boundary. Physical end-adornment separation is owned by CardFieldSurface.
3046
- */
3047
- function createBasisTheoryCardFieldStyle(appearance, presentation) {
3048
- const variables = resolveCardFieldAppearance(appearance).variables;
3049
- const inputRule = resolveCardFieldAppearanceRule(appearance, '.Input');
3050
- const invalidRule = resolveCardFieldAppearanceRule(appearance, '.Input--invalid');
3051
- const inputBackgroundColor = inputRule.backgroundColor ?? variables.colorSurface;
3052
- const inputColor = inputRule.color ?? variables.colorText;
3053
- const invalidBackgroundColor = invalidRule.backgroundColor ?? inputBackgroundColor;
3054
- const invalidColor = invalidRule.color ?? inputColor;
3055
- const chromeIosAttributeAutofill = typeof navigator !== 'undefined' && /\bCriOS\//.test(navigator.userAgent);
3056
- const providerStateValue = (value) => chromeIosAttributeAutofill ? `${value} !important` : value;
3001
+ function canLoadDeveloperAssistance() {
3002
+ return (typeof document !== 'undefined' &&
3003
+ typeof document.createElement === 'function' &&
3004
+ Boolean(document.head || document.documentElement));
3005
+ }
3006
+ function loadDeveloperAssistance() {
3007
+ if (classicScriptUrl || isClassicScriptArtifact(coreArtifactUrl)) {
3008
+ return loadClassicScript(resolveBrowserArtifactUrl(coreArtifactUrl));
3009
+ }
3010
+ const moduleUrl = new URL(DEVELOPER_ASSISTANCE_MODULE_ARTIFACT, coreArtifactUrl).href;
3011
+ return import(/* @vite-ignore */ moduleUrl);
3012
+ }
3013
+ function fileUrlFor(filename) {
3014
+ const normalized = filename.replace(/\\/g, '/');
3015
+ return new URL(`file://${normalized.startsWith('/') ? '' : '/'}${normalized}`).href;
3016
+ }
3017
+ function resolveBrowserArtifactUrl(coreUrl) {
3018
+ const url = new URL(coreUrl);
3019
+ if (IIFE_ARTIFACT_PATH.test(url.pathname)) {
3020
+ return new URL(DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT, url).href;
3021
+ }
3022
+ if (/\.js$/.test(url.pathname)) {
3023
+ url.pathname = url.pathname.replace(/[^/]+$/, DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT);
3024
+ }
3025
+ else if (/\/cdn\/?$/.test(url.pathname)) {
3026
+ url.pathname = url.pathname.replace(/\/cdn\/?$/, `/dist/${DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT}`);
3027
+ }
3028
+ else {
3029
+ url.pathname = `${url.pathname.replace(/\/$/, '')}/dist/${DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT}`;
3030
+ }
3031
+ url.search = '';
3032
+ url.hash = '';
3033
+ return url.href;
3034
+ }
3035
+ function isClassicScriptArtifact(url) {
3036
+ try {
3037
+ return IIFE_ARTIFACT_PATH.test(new URL(url).pathname);
3038
+ }
3039
+ catch {
3040
+ return false;
3041
+ }
3042
+ }
3043
+ function loadClassicScript(src) {
3044
+ return new Promise((resolve, reject) => {
3045
+ const script = document.createElement('script');
3046
+ script.async = true;
3047
+ script.src = src;
3048
+ script.addEventListener('load', () => resolve(), { once: true });
3049
+ script.addEventListener('error', () => reject(new Error()), { once: true });
3050
+ (document.head || document.documentElement).appendChild(script);
3051
+ });
3052
+ }
3053
+
3054
+ const registryKey = Symbol.for('paypercut.checkout-js.developer-assistance');
3055
+ function getRegistry() {
3056
+ const globals = globalThis;
3057
+ globals[registryKey] ?? (globals[registryKey] = {
3058
+ coreVersions: new Set(),
3059
+ provider: null,
3060
+ registrations: new Set(),
3061
+ });
3062
+ return globals[registryKey];
3063
+ }
3064
+ function announceDeveloperAssistantCore() {
3065
+ const registry = getRegistry();
3066
+ if (registry.provider && registry.provider.version !== SDK_VERSION) {
3067
+ for (const entry of registry.registrations) {
3068
+ safelyUnregister(entry);
3069
+ }
3070
+ registry.provider = null;
3071
+ }
3072
+ registry.coreVersions.add(SDK_VERSION);
3073
+ }
3074
+ function safelyUnregister(entry) {
3075
+ try {
3076
+ entry.delegate?.unregister();
3077
+ }
3078
+ catch {
3079
+ // Developer Assistance is optional and must not interrupt owner teardown.
3080
+ }
3081
+ entry.delegate = null;
3082
+ }
3083
+ function registerDeveloperAssistantTarget(target) {
3084
+ const registry = getRegistry();
3085
+ announceDeveloperAssistantCore();
3086
+ const entry = { target, delegate: null, registered: true };
3087
+ registry.registrations.add(entry);
3088
+ requestDeveloperAssistance(() => registry.provider?.version === SDK_VERSION);
3089
+ if (registry.provider?.version === SDK_VERSION) {
3090
+ try {
3091
+ entry.delegate = registry.provider.register(target);
3092
+ }
3093
+ catch {
3094
+ // Developer Assistance is optional. A registration failure must not
3095
+ // interrupt the Element lifecycle or payment flow.
3096
+ }
3097
+ }
3057
3098
  return {
3058
- base: {
3059
- // Basis Theory v2 derives its high-specificity browser-autofill paint
3060
- // from the active state's color and backgroundColor. An explicitly
3061
- // opaque surface prevents Chrome/WebKit's native blue fill from showing
3062
- // through only the provider iframe while the SDK-owned badge lane keeps
3063
- // the configured surface color.
3064
- backgroundColor: inputBackgroundColor,
3065
- color: inputColor,
3066
- fontFamily: variables.fontFamily,
3067
- fontSize: variables.fontSizeBase,
3068
- fontWeight: variables.fontWeightNormal,
3069
- lineHeight: variables.lineHeight,
3070
- // The provider is clipped to its own physical region when card brands
3071
- // are visible. Keep ordinary input padding here so provider- or
3072
- // extension-owned controls can use that region's far-right edge.
3073
- padding: !presentation
3074
- ? '12px'
3075
- : presentation.floatingLabels
3076
- ? presentation.floatingLabelActive
3077
- ? '23px 12px 9px 12px'
3078
- : '16px 12px 16px 12px'
3079
- : '12px',
3080
- '::placeholder': {
3081
- color: variables.colorTextPlaceholder,
3082
- },
3083
- ':disabled': {
3084
- backgroundColor: inputBackgroundColor,
3085
- },
3086
- ...inputRule,
3099
+ unregister() {
3100
+ if (!entry.registered)
3101
+ return;
3102
+ entry.registered = false;
3103
+ registry.registrations.delete(entry);
3104
+ safelyUnregister(entry);
3087
3105
  },
3088
- empty: {
3089
- // Chrome on iOS injects a later `[chrome-autofilled]` rule with an
3090
- // !important blue background inside each secure provider iframe. Basis
3091
- // Theory v2 filters custom attribute selectors, but its empty/invalid/
3092
- // complete state rules are deliberately class-qualified three times.
3093
- // On CriOS only, matching importance lets those supported state rules
3094
- // outrank Chrome without disabling native saved-card autofill.
3095
- backgroundColor: providerStateValue(inputBackgroundColor),
3096
- color: providerStateValue(inputColor),
3106
+ refresh() {
3107
+ if (entry.registered)
3108
+ entry.delegate?.refresh();
3097
3109
  },
3098
- invalid: {
3099
- // Paypercut owns the visible validation treatment. Provider text remains
3100
- // neutral while incomplete input is being edited.
3101
- ...invalidRule,
3102
- backgroundColor: providerStateValue(invalidBackgroundColor),
3103
- color: providerStateValue(invalidColor),
3104
- },
3105
- complete: {
3106
- backgroundColor: providerStateValue(inputBackgroundColor),
3107
- color: providerStateValue(inputColor),
3110
+ collapse() {
3111
+ if (entry.registered)
3112
+ entry.delegate?.collapse();
3108
3113
  },
3109
3114
  };
3110
3115
  }
@@ -4850,12 +4855,40 @@ class CardElementImpl {
4850
4855
  pending.resolve();
4851
4856
  }
4852
4857
  registerDeveloperPresets(presets) {
4853
- {
4854
- return;
4855
- }
4858
+ if (this.group.getClientOptions().developerAssistant !== true) {
4859
+ return;
4860
+ }
4861
+ if (this.developerAssistant) {
4862
+ // Hosted Card republishes the same authorized catalog after an Appearance
4863
+ // replacement. Keep the existing target and controls alive so the pending
4864
+ // request can release its lock and restore focus on the original control.
4865
+ this.developerAssistant.refresh();
4866
+ return;
4867
+ }
4868
+ this.developerAssistant = registerDeveloperAssistantTarget({
4869
+ id: `${this.group.controllerId}:${this.componentId}`,
4870
+ configurationIdentity: this.group.configurationIdentity,
4871
+ appearanceScopeId: this.group.controllerId,
4872
+ presets,
4873
+ isAvailable: () => this.canApplyDeveloperPreset(),
4874
+ isAppearanceAvailable: () => this.isMounted(),
4875
+ appearancePreviewClearsTestData: () => true,
4876
+ canPreview: () => this.group.isAppearancePreviewAvailable(),
4877
+ applyPreset: (presetId) => this.applyDeveloperPreset(presetId),
4878
+ getAppearance: () => this.group.getAppearance(),
4879
+ updateAppearance: (appearance) => this.group.updateAppearance(appearance),
4880
+ replaceAppearance: (appearance) => this.group.replaceAppearance(appearance),
4881
+ prepareAppearance: (appearance) => this.group.prepareAppearance(appearance),
4882
+ prepareAppearanceReplacement: (appearance) => this.group.prepareAppearanceReplacement(appearance),
4883
+ });
4856
4884
  }
4857
4885
  canApplyDeveloperPreset() {
4858
- return (config.mode === 'internal');
4886
+ return (this.group.getClientOptions().developerAssistant === true &&
4887
+ this.ready &&
4888
+ !this.destroyed &&
4889
+ !this.group.hasPaymentMethodSubmissionState(this.componentId) &&
4890
+ !this.group.hasCompletedPaymentMethodSubmission(this.componentId) &&
4891
+ !this.pendingDeveloperPreset);
4859
4892
  }
4860
4893
  applyDeveloperPreset(presetId) {
4861
4894
  if (!this.canApplyDeveloperPreset()) {
@@ -5184,7 +5217,7 @@ class ExpressCheckoutElementImpl {
5184
5217
  this.group.updateExpressCheckoutComponent(this.componentId, this.componentRevision, this.getComponentOptions());
5185
5218
  }
5186
5219
  getComponentOptions() {
5187
- return structuredCloneSafe(this.options);
5220
+ return structuredCloneSafe(this.pendingPreview?.nextOptions ?? this.options);
5188
5221
  }
5189
5222
  isMounted() {
5190
5223
  return this.mounted && !this.destroyed;
@@ -5626,9 +5659,26 @@ class ExpressCheckoutElementImpl {
5626
5659
  };
5627
5660
  }
5628
5661
  registerDeveloperAssistant() {
5629
- {
5630
- return;
5631
- }
5662
+ if (this.group.getClientOptions().developerAssistant !== true) {
5663
+ return;
5664
+ }
5665
+ this.developerAssistant = registerDeveloperAssistantTarget({
5666
+ id: `${this.group.controllerId}:${this.componentId}:express-checkout`,
5667
+ configurationIdentity: this.group.configurationIdentity,
5668
+ appearanceScopeId: this.group.controllerId,
5669
+ componentDisplayScopeId: this.componentId,
5670
+ isAvailable: () => true,
5671
+ isAppearanceAvailable: () => this.isMounted(),
5672
+ canPreview: () => this.group.isAppearancePreviewAvailable(),
5673
+ getAppearance: () => this.group.getAppearance(),
5674
+ updateAppearance: (appearance) => this.group.updateAppearance(appearance),
5675
+ replaceAppearance: (appearance) => this.group.replaceAppearance(appearance),
5676
+ prepareAppearance: (appearance) => this.group.prepareAppearance(appearance),
5677
+ prepareAppearanceReplacement: (appearance) => this.group.prepareAppearanceReplacement(appearance),
5678
+ getComponentDisplayOptions: () => developerDisplayOptions(this.options),
5679
+ updateComponentDisplayOptions: (options) => this.updateDeveloperDisplayOptions(options),
5680
+ replaceComponentDisplayOptions: (options) => this.replaceDeveloperDisplayOptions(options),
5681
+ });
5632
5682
  }
5633
5683
  onWindowMessage(event) {
5634
5684
  if (this.destroyed ||
@@ -6455,6 +6505,16 @@ const OPTION_KEYS = new Set([
6455
6505
  'lineItems',
6456
6506
  'shippingRates',
6457
6507
  ]);
6508
+ function developerDisplayOptions(options) {
6509
+ return structuredCloneSafe({
6510
+ ...(options.paymentMethods ? { paymentMethods: options.paymentMethods } : {}),
6511
+ ...(options.layout ? { layout: options.layout } : {}),
6512
+ ...(options.buttonType ? { buttonType: options.buttonType } : {}),
6513
+ ...(options.buttonTheme ? { buttonTheme: options.buttonTheme } : {}),
6514
+ ...(options.buttonHeight !== undefined ? { buttonHeight: options.buttonHeight } : {}),
6515
+ ...(options.buttonRadius !== undefined ? { buttonRadius: options.buttonRadius } : {}),
6516
+ });
6517
+ }
6458
6518
  function mergeDeveloperDisplayOptions(current, update) {
6459
6519
  return {
6460
6520
  ...current,
@@ -7325,6 +7385,148 @@ class ElementsWalletAttemptOverlay {
7325
7385
  }
7326
7386
  }
7327
7387
 
7388
+ const LIGHT_VARIABLES = {
7389
+ colorPrimary: '#0570de',
7390
+ colorPrimaryText: '#ffffff',
7391
+ colorBackground: '#ffffff',
7392
+ colorSurface: '#ffffff',
7393
+ colorText: '#2b2d2f',
7394
+ colorTextSecondary: '#6a6c6f',
7395
+ colorTextPlaceholder: '#737474',
7396
+ colorDanger: '#cc1818',
7397
+ colorSuccess: '#30b130',
7398
+ colorWarning: '#e69e2c',
7399
+ colorBorder: '#d7dde0',
7400
+ colorFocus: '#0570de',
7401
+ colorMuted: '#f2f4f5',
7402
+ fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
7403
+ fontSizeBase: '16px',
7404
+ fontWeightNormal: '400',
7405
+ fontWeightMedium: '500',
7406
+ lineHeight: '1.5',
7407
+ spacingUnit: '4px',
7408
+ gridColumnSpacing: '12px',
7409
+ gridRowSpacing: '12px',
7410
+ labelSpacing: '6px',
7411
+ borderRadius: '4px',
7412
+ buttonBorderRadius: '4px',
7413
+ buttonExpressCheckoutBorderRadius: '4px',
7414
+ buttonPadding: '12px',
7415
+ };
7416
+ const DARK_VARIABLES = {
7417
+ ...LIGHT_VARIABLES,
7418
+ colorBackground: '#15171c',
7419
+ colorSurface: '#1d2027',
7420
+ colorText: '#f3f4f6',
7421
+ colorTextSecondary: '#aeb7c7',
7422
+ colorTextPlaceholder: '#8f99aa',
7423
+ colorBorder: '#3a404b',
7424
+ colorFocus: '#7db7ff',
7425
+ colorMuted: '#252932',
7426
+ };
7427
+ const VARIABLE_NAMES = new Set(Object.keys(LIGHT_VARIABLES));
7428
+ const PUBLIC_VARIABLE_REFERENCE = /var\(\s*--([A-Za-z][A-Za-z0-9]*)\s*\)/g;
7429
+ function resolveCardFieldAppearance(appearance) {
7430
+ const theme = appearance?.theme ?? 'light';
7431
+ const themeVariables = theme === 'dark' ? DARK_VARIABLES : LIGHT_VARIABLES;
7432
+ const overrides = Object.fromEntries(Object.entries(appearance?.variables ?? {}).filter(([name, value]) => VARIABLE_NAMES.has(name) && typeof value === 'string'));
7433
+ return {
7434
+ theme,
7435
+ disableAnimations: appearance?.disableAnimations ?? false,
7436
+ variables: {
7437
+ ...themeVariables,
7438
+ ...overrides,
7439
+ },
7440
+ };
7441
+ }
7442
+ /** Resolve one semantic public rule to concrete provider/DOM style values. */
7443
+ function resolveCardFieldAppearanceRule(appearance, selector) {
7444
+ const rule = appearance?.rules?.[selector];
7445
+ if (!rule)
7446
+ return {};
7447
+ const variables = resolveCardFieldAppearance(appearance).variables;
7448
+ return Object.fromEntries(Object.entries(rule).flatMap(([property, value]) => {
7449
+ if (typeof value !== 'string' || !isSafeElementsAppearanceValue(value))
7450
+ return [];
7451
+ return [
7452
+ [
7453
+ property,
7454
+ value.replace(PUBLIC_VARIABLE_REFERENCE, (match, name) => name in variables ? variables[name] : match),
7455
+ ],
7456
+ ];
7457
+ }));
7458
+ }
7459
+ /**
7460
+ * Compile the secure Basis Theory input style from the Hosted Checkout token
7461
+ * baseline. Provider fields cannot inherit merchant-document CSS, so every
7462
+ * public token and variable reference is resolved before crossing the provider
7463
+ * boundary. Physical end-adornment separation is owned by CardFieldSurface.
7464
+ */
7465
+ function createBasisTheoryCardFieldStyle(appearance, presentation) {
7466
+ const variables = resolveCardFieldAppearance(appearance).variables;
7467
+ const inputRule = resolveCardFieldAppearanceRule(appearance, '.Input');
7468
+ const invalidRule = resolveCardFieldAppearanceRule(appearance, '.Input--invalid');
7469
+ const inputBackgroundColor = inputRule.backgroundColor ?? variables.colorSurface;
7470
+ const inputColor = inputRule.color ?? variables.colorText;
7471
+ const invalidBackgroundColor = invalidRule.backgroundColor ?? inputBackgroundColor;
7472
+ const invalidColor = invalidRule.color ?? inputColor;
7473
+ const chromeIosAttributeAutofill = typeof navigator !== 'undefined' && /\bCriOS\//.test(navigator.userAgent);
7474
+ const providerStateValue = (value) => chromeIosAttributeAutofill ? `${value} !important` : value;
7475
+ return {
7476
+ base: {
7477
+ // Basis Theory v2 derives its high-specificity browser-autofill paint
7478
+ // from the active state's color and backgroundColor. An explicitly
7479
+ // opaque surface prevents Chrome/WebKit's native blue fill from showing
7480
+ // through only the provider iframe while the SDK-owned badge lane keeps
7481
+ // the configured surface color.
7482
+ backgroundColor: inputBackgroundColor,
7483
+ color: inputColor,
7484
+ fontFamily: variables.fontFamily,
7485
+ fontSize: variables.fontSizeBase,
7486
+ fontWeight: variables.fontWeightNormal,
7487
+ lineHeight: variables.lineHeight,
7488
+ // The provider is clipped to its own physical region when card brands
7489
+ // are visible. Keep ordinary input padding here so provider- or
7490
+ // extension-owned controls can use that region's far-right edge.
7491
+ padding: !presentation
7492
+ ? '12px'
7493
+ : presentation.floatingLabels
7494
+ ? presentation.floatingLabelActive
7495
+ ? '23px 12px 9px 12px'
7496
+ : '16px 12px 16px 12px'
7497
+ : '12px',
7498
+ '::placeholder': {
7499
+ color: variables.colorTextPlaceholder,
7500
+ },
7501
+ ':disabled': {
7502
+ backgroundColor: inputBackgroundColor,
7503
+ },
7504
+ ...inputRule,
7505
+ },
7506
+ empty: {
7507
+ // Chrome on iOS injects a later `[chrome-autofilled]` rule with an
7508
+ // !important blue background inside each secure provider iframe. Basis
7509
+ // Theory v2 filters custom attribute selectors, but its empty/invalid/
7510
+ // complete state rules are deliberately class-qualified three times.
7511
+ // On CriOS only, matching importance lets those supported state rules
7512
+ // outrank Chrome without disabling native saved-card autofill.
7513
+ backgroundColor: providerStateValue(inputBackgroundColor),
7514
+ color: providerStateValue(inputColor),
7515
+ },
7516
+ invalid: {
7517
+ // Paypercut owns the visible validation treatment. Provider text remains
7518
+ // neutral while incomplete input is being edited.
7519
+ ...invalidRule,
7520
+ backgroundColor: providerStateValue(invalidBackgroundColor),
7521
+ color: providerStateValue(invalidColor),
7522
+ },
7523
+ complete: {
7524
+ backgroundColor: providerStateValue(inputBackgroundColor),
7525
+ color: providerStateValue(inputColor),
7526
+ },
7527
+ };
7528
+ }
7529
+
7328
7530
  const CARD_BRAND_BADGE_WIDTH_PX = 48;
7329
7531
  const CARD_BRAND_BADGE_HEIGHT_PX = 28;
7330
7532
  const INVALID_CARD_BADGE_WIDTH_PX = 36;
@@ -10393,7 +10595,7 @@ class CardCollectionRuntime {
10393
10595
  this.cancelPendingAppearancePreview(error);
10394
10596
  }
10395
10597
  supportsDeveloperPresets() {
10396
- return config.mode === 'internal';
10598
+ return this.bootstrap?.livemode === false;
10397
10599
  }
10398
10600
  announceAppearanceCommit() {
10399
10601
  if (this.destroyed)
@@ -11613,7 +11815,16 @@ class ElementsGroupImpl {
11613
11815
  this.postControl(message);
11614
11816
  }
11615
11817
  discoverDeveloperPresets(componentId) {
11616
- return;
11818
+ if (this.clientOptions.developerAssistant !== true)
11819
+ return;
11820
+ const message = {
11821
+ channel: ELEMENTS_COMPONENT_CHANNEL,
11822
+ type: ElementsControllerCommandType.DiscoverDeveloperPresets,
11823
+ controllerId: this.controllerId,
11824
+ componentId,
11825
+ componentType: 'card',
11826
+ };
11827
+ this.postControl(message);
11617
11828
  }
11618
11829
  applyDeveloperPreset(componentId, requestId, presetId) {
11619
11830
  const message = {
@@ -11765,7 +11976,7 @@ class ElementsGroupImpl {
11765
11976
  const update = normalizeUpdateOptions(options, this.appearance, this.amount);
11766
11977
  const appearanceWasRequested = options.appearance !== undefined;
11767
11978
  const appearancePreviewEnabled = this.elementsOptions.appearanceUpdates === 'remount' ||
11768
- (config.mode === 'internal');
11979
+ this.clientOptions.developerAssistant === true;
11769
11980
  const hasMountedPaymentAppearanceTarget = this.hasMountedCardFields() ||
11770
11981
  this.getMountedCardElements().length > 0 ||
11771
11982
  this.getMountedExpressCheckoutElements().length > 0;
@@ -12061,9 +12272,29 @@ class ElementsGroupImpl {
12061
12272
  }
12062
12273
  ensureSplitCardDeveloperAssistant() {
12063
12274
  if (this.splitCardDeveloperAssistant ||
12064
- config.mode !== 'internal') {
12065
- return;
12066
- }
12275
+ this.clientOptions.developerAssistant !== true ||
12276
+ this.cardFields.size === 0 ||
12277
+ !this.cardCollectionRuntime.supportsDeveloperPresets() ||
12278
+ typeof window === 'undefined' ||
12279
+ typeof document === 'undefined') {
12280
+ return;
12281
+ }
12282
+ this.splitCardDeveloperAssistant = registerDeveloperAssistantTarget({
12283
+ id: `${this.controllerId}:split-card-fields`,
12284
+ configurationIdentity: this.configurationIdentity,
12285
+ appearanceScopeId: this.controllerId,
12286
+ presetSource: 'split-card',
12287
+ isAvailable: () => !this.destroyed && this.cardCollectionRuntime.canApplyDeveloperPreset(),
12288
+ isAppearanceAvailable: () => !this.destroyed && this.hasMountedCardFields(),
12289
+ appearancePreviewClearsTestData: () => true,
12290
+ canPreview: () => this.isAppearancePreviewAvailable(),
12291
+ applyCardValue: (value) => this.cardCollectionRuntime.applyDeveloperPreset(value),
12292
+ getAppearance: () => this.getAppearance(),
12293
+ updateAppearance: (appearance) => this.updateAppearance(appearance),
12294
+ replaceAppearance: (appearance) => this.replaceAppearance(appearance),
12295
+ prepareAppearance: (appearance) => this.prepareAppearance(appearance),
12296
+ prepareAppearanceReplacement: (appearance) => this.prepareAppearanceReplacement(appearance),
12297
+ });
12067
12298
  }
12068
12299
  unregisterSplitCardDeveloperAssistant() {
12069
12300
  this.splitCardDeveloperAssistant?.unregister();
@@ -12735,6 +12966,7 @@ class PaymentConfirmationCoordinator {
12735
12966
  }
12736
12967
  }
12737
12968
 
12969
+ announceDeveloperAssistantCore();
12738
12970
  const MAX_PAYMENT_METHOD_BILLING_CACHE_SIZE = 16;
12739
12971
  const MAX_PUBLISHABLE_KEY_LENGTH = 512;
12740
12972
  const MAX_CREATE_PAYMENT_METHOD_OPTION_KEYS = 2;