@zonos/elements 1.3.136 → 1.3.137

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.
Files changed (140) hide show
  1. package/dist/cjs/{cart-0f32f556.js → cart-dea3242e.js} +75 -2
  2. package/dist/cjs/index.cjs.js +13 -10
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{paypal-fd50c7d5.js → paypal-729f9ed3.js} +1 -1
  5. package/dist/cjs/zonos-address_7.cjs.entry.js +1 -1
  6. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +21 -8
  7. package/dist/cjs/zonos-checkout.cjs.entry.js +76 -9
  8. package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
  9. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
  10. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
  11. package/dist/cjs/zonos-elements.cjs.js +1 -1
  12. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
  13. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  15. package/dist/cjs/zonos-notification_3.cjs.entry.js +2 -2
  16. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +19 -6
  17. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +76 -8
  18. package/dist/collection/components/store/checkout/stripe.js +15 -2
  19. package/dist/collection/components/store/translationStore/strings.arabic.js +3 -0
  20. package/dist/collection/components/store/translationStore/strings.base.js +3 -0
  21. package/dist/collection/components/store/translationStore/strings.chinese.js +3 -0
  22. package/dist/collection/components/store/translationStore/strings.danish.js +3 -0
  23. package/dist/collection/components/store/translationStore/strings.dutch.js +3 -0
  24. package/dist/collection/components/store/translationStore/strings.french.js +3 -0
  25. package/dist/collection/components/store/translationStore/strings.german.js +3 -0
  26. package/dist/collection/components/store/translationStore/strings.hebrew.js +3 -0
  27. package/dist/collection/components/store/translationStore/strings.indonesian.js +3 -0
  28. package/dist/collection/components/store/translationStore/strings.italian.js +3 -0
  29. package/dist/collection/components/store/translationStore/strings.japanese.js +3 -0
  30. package/dist/collection/components/store/translationStore/strings.korean.js +3 -0
  31. package/dist/collection/components/store/translationStore/strings.norwegian.js +3 -0
  32. package/dist/collection/components/store/translationStore/strings.polish.js +3 -0
  33. package/dist/collection/components/store/translationStore/strings.portuguese.js +3 -0
  34. package/dist/collection/components/store/translationStore/strings.russian.js +3 -0
  35. package/dist/collection/components/store/translationStore/strings.spanish.js +3 -0
  36. package/dist/collection/components/store/translationStore/strings.swedish.js +3 -0
  37. package/dist/collection/components/store/translationStore/strings.turkish.js +3 -0
  38. package/dist/collection/components/store/translationStore/strings.vietnamese.js +3 -0
  39. package/dist/collection/scripts/_zonosBase.js +6 -3
  40. package/dist/collection/types/generated/graphql.frontend.types.js +2 -3
  41. package/dist/collection/types/generated/graphql.internal.types.js +1 -0
  42. package/dist/esm/{cart-3e0e4d5c.js → cart-c15cb7dd.js} +76 -3
  43. package/dist/esm/index.js +13 -10
  44. package/dist/esm/loader.js +1 -1
  45. package/dist/esm/{paypal-b4af6cc0.js → paypal-de439a93.js} +1 -1
  46. package/dist/esm/zonos-address_7.entry.js +1 -1
  47. package/dist/esm/zonos-cart-items_13.entry.js +21 -8
  48. package/dist/esm/zonos-checkout.entry.js +77 -10
  49. package/dist/esm/zonos-controller.entry.js +1 -1
  50. package/dist/esm/zonos-country-flag.entry.js +1 -1
  51. package/dist/esm/zonos-country-select_4.entry.js +1 -1
  52. package/dist/esm/zonos-elements.js +1 -1
  53. package/dist/esm/zonos-hello-dialog.entry.js +1 -1
  54. package/dist/esm/zonos-hello.entry.js +1 -1
  55. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  56. package/dist/esm/zonos-notification_3.entry.js +2 -2
  57. package/dist/esm-es5/cart-c15cb7dd.js +1 -0
  58. package/dist/esm-es5/index.js +1 -1
  59. package/dist/esm-es5/loader.js +1 -1
  60. package/dist/esm-es5/{paypal-b4af6cc0.js → paypal-de439a93.js} +1 -1
  61. package/dist/esm-es5/zonos-address_7.entry.js +1 -1
  62. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  63. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  64. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  65. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  66. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  67. package/dist/esm-es5/zonos-elements.js +1 -1
  68. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  69. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  70. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  71. package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
  72. package/dist/scripts/index.js +1 -1
  73. package/dist/scripts/loadZonos.js +1 -1
  74. package/dist/scripts/zonos.js +1 -1
  75. package/dist/types/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.d.ts +1 -1
  76. package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +5 -0
  77. package/dist/types/components/store/translationStore/strings.arabic.d.ts +3 -0
  78. package/dist/types/components/store/translationStore/strings.base.d.ts +3 -0
  79. package/dist/types/components/store/translationStore/strings.chinese.d.ts +3 -0
  80. package/dist/types/components/store/translationStore/strings.danish.d.ts +3 -0
  81. package/dist/types/components/store/translationStore/strings.dutch.d.ts +3 -0
  82. package/dist/types/components/store/translationStore/strings.french.d.ts +3 -0
  83. package/dist/types/components/store/translationStore/strings.german.d.ts +3 -0
  84. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +3 -0
  85. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +3 -0
  86. package/dist/types/components/store/translationStore/strings.italian.d.ts +3 -0
  87. package/dist/types/components/store/translationStore/strings.japanese.d.ts +3 -0
  88. package/dist/types/components/store/translationStore/strings.korean.d.ts +3 -0
  89. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +3 -0
  90. package/dist/types/components/store/translationStore/strings.polish.d.ts +3 -0
  91. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +3 -0
  92. package/dist/types/components/store/translationStore/strings.russian.d.ts +3 -0
  93. package/dist/types/components/store/translationStore/strings.spanish.d.ts +3 -0
  94. package/dist/types/components/store/translationStore/strings.swedish.d.ts +3 -0
  95. package/dist/types/components/store/translationStore/strings.turkish.d.ts +3 -0
  96. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +3 -0
  97. package/dist/types/components/store/translationStore.d.ts +1 -1
  98. package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
  99. package/dist/types/types/generated/graphql.frontend.types.d.ts +3 -23
  100. package/dist/types/types/generated/graphql.frontend.types.ts +3 -36
  101. package/dist/types/types/generated/graphql.internal.types.d.ts +1 -0
  102. package/dist/types/types/generated/graphql.internal.types.ts +1 -0
  103. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  104. package/dist/zonos-elements/index.esm.js +1 -1
  105. package/dist/zonos-elements/{p-3f2ea446.entry.js → p-0867e94a.entry.js} +1 -1
  106. package/dist/zonos-elements/p-1af38265.system.js +1 -0
  107. package/dist/zonos-elements/{p-887b05eb.system.entry.js → p-1faa4294.system.entry.js} +1 -1
  108. package/dist/zonos-elements/p-2de631c4.system.entry.js +1 -0
  109. package/dist/zonos-elements/{p-49cecdf9.system.entry.js → p-3039f460.system.entry.js} +1 -1
  110. package/dist/zonos-elements/{p-3a5fb01a.system.entry.js → p-35ccf9d8.system.entry.js} +1 -1
  111. package/dist/zonos-elements/{p-c52a8369.system.entry.js → p-374680fd.system.entry.js} +1 -1
  112. package/dist/zonos-elements/{p-897c809a.entry.js → p-43ac026b.entry.js} +1 -1
  113. package/dist/zonos-elements/{p-6b8db2d3.entry.js → p-4aecf7fc.entry.js} +1 -1
  114. package/dist/zonos-elements/{p-37991f24.entry.js → p-51f8719d.entry.js} +1 -1
  115. package/dist/zonos-elements/{p-b6fea87a.entry.js → p-56e63659.entry.js} +1 -1
  116. package/dist/zonos-elements/p-611842b5.entry.js +1 -0
  117. package/dist/zonos-elements/{p-4b680c1e.system.entry.js → p-765ddab5.system.entry.js} +1 -1
  118. package/dist/zonos-elements/{p-85fbb5f0.entry.js → p-77b2acf4.entry.js} +1 -1
  119. package/dist/zonos-elements/p-7838aa96.entry.js +1 -0
  120. package/dist/zonos-elements/p-7c08bf7d.system.js +1 -0
  121. package/dist/zonos-elements/{p-a28f3298.system.entry.js → p-7eceaa3a.system.entry.js} +1 -1
  122. package/dist/zonos-elements/{p-05826697.system.entry.js → p-910c1247.system.entry.js} +1 -1
  123. package/dist/zonos-elements/{p-e1ac8cd8.js → p-938b2b70.js} +1 -1
  124. package/dist/zonos-elements/p-940e327f.system.entry.js +1 -0
  125. package/dist/zonos-elements/{p-e9db73d9.entry.js → p-a5d35e84.entry.js} +1 -1
  126. package/dist/zonos-elements/p-afa5c13c.js +1 -0
  127. package/dist/zonos-elements/{p-16e5df29.system.entry.js → p-c710bde9.system.entry.js} +1 -1
  128. package/dist/zonos-elements/p-c78dd680.system.js +1 -1
  129. package/dist/zonos-elements/{p-bec4d2c7.entry.js → p-cb6baa14.entry.js} +1 -1
  130. package/dist/zonos-elements/{p-18cb1aee.system.js → p-e9b39df1.system.js} +1 -1
  131. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  132. package/package.json +1 -1
  133. package/dist/esm-es5/cart-3e0e4d5c.js +0 -1
  134. package/dist/zonos-elements/p-69045ca3.js +0 -1
  135. package/dist/zonos-elements/p-af3ecd9d.system.entry.js +0 -1
  136. package/dist/zonos-elements/p-b776e39e.system.js +0 -1
  137. package/dist/zonos-elements/p-c8927b27.system.entry.js +0 -1
  138. package/dist/zonos-elements/p-caddd067.entry.js +0 -1
  139. package/dist/zonos-elements/p-e9862f66.entry.js +0 -1
  140. package/dist/zonos-elements/p-fa790aaf.system.js +0 -1
@@ -79,6 +79,7 @@ export const featureAspectKeyEnum = {
79
79
  NewPayoutReport: 'new_payout_report',
80
80
  PageAuditor: 'page_auditor',
81
81
  PromptExplorer: 'prompt_explorer',
82
+ RulesUiCreate: 'rules_ui_create',
82
83
  SupportTicketSystem: 'support_ticket_system',
83
84
  TeamAuditor: 'team_auditor',
84
85
  } as const;
@@ -110,6 +111,7 @@ export const featureAudienceNameEnum = {
110
111
  PrincipalEngineer: 'principal_engineer',
111
112
  ProServeHead: 'pro_serve_head',
112
113
  ProductManager: 'product_manager',
114
+ RulesUiCreateMerchant: 'rules_ui_create_merchant',
113
115
  SupportTicketMerchants: 'support_ticket_merchants',
114
116
  TechLead: 'tech_lead',
115
117
  } as const;
@@ -561,30 +563,9 @@ export type FailToGetQuoteErrorsQuery = {
561
563
  };
562
564
  };
563
565
 
564
- export type FailedToGetOrderQuery = {
565
- error_event_aggregate: {
566
- aggregate: { count: number } | null;
567
- nodes: Array<{
568
- allLogs: Record<string, unknown> | Record<string, unknown>[] | null;
569
- createdAt: string;
570
- endpoint: string;
571
- errors: Record<string, unknown> | Record<string, unknown>[];
572
- id: number;
573
- metadata: Record<string, unknown> | Record<string, unknown>[] | null;
574
- publicCredential:
575
- | Record<string, unknown>
576
- | Record<string, unknown>[]
577
- | null;
578
- requestPayload: Record<string, unknown> | Record<string, unknown>[];
579
- responseBody: Record<string, unknown> | Record<string, unknown>[] | null;
580
- status: number;
581
- }>;
582
- };
583
- };
584
-
585
566
  export type LocaleCountryMessagesQuery = {
586
567
  locale_countryCodesPage: Array<{
587
- countryCodes: Array<string>;
568
+ countryCodes: Array<string> | null;
588
569
  countryCodesPageMessageLinks: Array<{
589
570
  id: number;
590
571
  message: {
@@ -968,20 +949,6 @@ export function getSdk(
968
949
  'query',
969
950
  );
970
951
  },
971
- failedToGetOrder(
972
- variables?: { [x: string]: never },
973
- requestHeaders?: GraphQLClientRequestHeaders,
974
- ): Promise<FailedToGetOrderQuery> {
975
- return withWrapper(
976
- wrappedRequestHeaders =>
977
- client.request<FailedToGetOrderQuery>('', variables, {
978
- ...requestHeaders,
979
- ...wrappedRequestHeaders,
980
- }),
981
- 'failedToGetOrder',
982
- 'query',
983
- );
984
- },
985
952
  getAudienceByAspectKey(
986
953
  variables?: { [x: string]: never },
987
954
  requestHeaders?: GraphQLClientRequestHeaders,
@@ -1385,6 +1385,7 @@ export declare const emailTemplateStatus: {
1385
1385
  export type EmailTemplateStatus = (typeof emailTemplateStatus)[keyof typeof emailTemplateStatus];
1386
1386
  export declare const emailTemplateType: {
1387
1387
  readonly AbandonedCart: "ABANDONED_CART";
1388
+ readonly AccountOrderReceipt: "ACCOUNT_ORDER_RECEIPT";
1388
1389
  readonly CatalogExport: "CATALOG_EXPORT";
1389
1390
  readonly ClassificationExport: "CLASSIFICATION_EXPORT";
1390
1391
  readonly Custom: "CUSTOM";
@@ -1610,6 +1610,7 @@ export type EmailTemplateStatus =
1610
1610
  (typeof emailTemplateStatus)[keyof typeof emailTemplateStatus];
1611
1611
  export const emailTemplateType = {
1612
1612
  AbandonedCart: 'ABANDONED_CART',
1613
+ AccountOrderReceipt: 'ACCOUNT_ORDER_RECEIPT',
1613
1614
  CatalogExport: 'CATALOG_EXPORT',
1614
1615
  ClassificationExport: 'CLASSIFICATION_EXPORT',
1615
1616
  Custom: 'CUSTOM',
@@ -1 +1 @@
1
- <svg color="var(--zonos-elements-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--zonos-elements-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
1
+ <svg color="var(--zonos-elements-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--zonos-elements-red-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
@@ -1 +1 @@
1
- import{l as e,h as n,a as o}from"./p-860e46ab.js";import{s as t,c as s}from"./p-b7307c61.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b7307c61.js";const r=["jsdelivr","cdnjs","unpkg","vercel"],i="jsdelivr",l=e=>{const n=r.indexOf(e);return r[n+1]||null},a=()=>{const n=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||n)return null;const o=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),t="https://v1.3.136.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const s=`https://${o}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${s}' for loading elements script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),s},u="https://js.stripe.com/v3",m=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,w="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let p=null;const f=Promise.resolve().then((()=>{return e=null,null!==p||(p=new Promise(((n,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(w),window.Stripe)n(window.Stripe);else try{let s=(()=>{const e=document.querySelectorAll(`script[src^="${u}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&m.test(o.src))return o}return null})();s&&e?console.warn(w):s||(s=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",t=document.createElement("script");t.src=`${u}${n}`;const s=document.head||document.body;return s?(s.appendChild(t),t):(o("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==s||s.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):t(new Error("Stripe.js not available"))})),null==s||s.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else n(null)}))),p;var e}));let h=!1;var v;f.catch((e=>{h||console.warn(e)}));const y=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),z="https://v1.3.136.js.zonos.com",j=y||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.136",S="https://rsms.me",g="https://fonts.googleapis.com",O=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class b{}v=b,b.doneInit=!1,b.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),b.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),b._paypalMockResponse=null,b.isBigCommerce=!1,b.releaseDate="1733241504089",b.isLegacyCheckout=!1,b.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",b.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),b.isNpm=!0,b.zonosQaUrl=null,b.zonosQaUrlApi=null,b.version="v1.3.136",b.modeAlerted=!1,b.cartData=null,b.paypal=null,b.getCurrentTimestamp=()=>(new Date).getTime(),b.zonosController=null,b.init=async r=>{const{appearance:i,checkoutSettings:c,currencyConverter:l,helloSettings:d,onCountryChange:u,overrideCurrencyFormat:m,storeId:w,zonosApiKey:p}=r;if(v.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!v.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${v.version}) ======`),v.zonosApiKey=p,v.storeId=w,v.isNpm){e("====== ZONOS LOADING FROM NPM ======");const s=a();if(s&&!window.isZonosPreview){e(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${s} ======`,"info");const n=document.createElement("script");return n.src=`${s}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=v.isNpm,window.Zonos.isBigCommerce=v.isBigCommerce,window.Zonos.isLegacyCheckout=v.isLegacyCheckout,window.Zonos.init(r)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${s}`)})),void(window.isZonosPreview=!0)}if(!p&&!v.cartId)return void o("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!v.cartData&&v.cartId){e("Initialize cart data");const n=await t(v.cartId);if(!n)return void o("Failed to get cart data");v.cartData=n.cartData,v.zonosApiKey=n.zonosApiKey}const i=await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return null;if(e("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return e("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:s}=await n("/api/get-test-public-credential");if(t.length||!s)return o("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const r=s.publicCredential;return r?(e(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(o("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();i&&(v.zonosApiKey=i)}if(v.cartId&&v.cartData){e("Cart data is available, inject hidden button and trigger checkout");const n=document.createElement("button");n.style.display="none",n.id=`${s}`,document.body.appendChild(n)}e("init zonos"),v.injectZonosCdn(),v.injectZonosCss(),v.injectFonts(),v.injectController({config:{appearance:i,checkoutSettings:c,currencyConverter:l,helloSettings:d,onCountryChange:u,overrideCurrencyFormat:m}}),v.doneInit=!0}},b.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},b.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},b.showNotification=e=>{var n;null===(n=v.zonosController)||void 0===n||n.showNotification(e)},b.updateOrganizationName=e=>{var n;null===(n=v.zonosController)||void 0===n||n.updateOrganizationName(e)},b.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},b.injectController=({config:n})=>{var t;if(document.querySelector("zonos-controller"))return;if(null===(t=n.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const e=n.checkoutSettings.placeOrderButtonSelector;v.disablePlaceOrderButtons({config:n,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{v.disablePlaceOrderButtons({config:n,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=n,s.zonosApiKey=v.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async n=>{const{detail:t}=n;e("loading Stripe");const r=await(async(...e)=>{h=!0;const n=Date.now();return f.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(t.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):o("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),v.zonosController=s,e("Zonos controller injected!")},b.injectScript=({cdnType:n,isModule:t,theRestUrl:s})=>{const r=`${v.getZonosUrl(n)}/${s}`;if(document.querySelector(`script[src="${r}"]`))return void e(`Zonos script "${r}" already exists in the document`,"warn");const i=document.head||document.body,c=document.createElement("script");t?c.type="module":c.noModule=!0,c.src=r,c.crossOrigin="anonymous",c.onerror=()=>{o(`Failed to load ${c.src}`);const e=l(n);e&&v.injectScript({cdnType:e,isModule:t,theRestUrl:s})},i.appendChild(c)},b.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return j;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.136";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.136";case"vercel":return z}};return v.isNpm&&a()||n()},b.injectZonosCdn=()=>{v.injectScript({cdnType:i,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),v.injectScript({cdnType:i,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},b.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const t=v.getZonosUrl(e),s=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${z}/`,s.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${n}`,i.onerror=()=>{o(`Failed to load ${i.href}`);const t=l(e);t&&v.injectStylesheet({cdnType:t,theRestUrl:n})},s.appendChild(i)},b.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(v.injectStylesheet({cdnType:i,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},b.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${S}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!O.test(o.href))return o}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=S,n.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${S}/inter/inter.css`,n.appendChild(t),e("Zonos font injected!")},b.setupGoogleFont=e=>{var n;null===(n=v.zonosController)||void 0===n||n.setupGoogleFont(e)},b.injectSupportGoogleFont=n=>{var o;e(`[FONT] injecting ${n}`);const t=null===(o=n.match(/family=(.*?):/))||void 0===o?void 0:o[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${g}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=g,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${t} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=n,s.appendChild(r),e(`[FONT] ${t} font injected!`)};export{b as Zonos}
1
+ import{l as e,h as n,a as t}from"./p-860e46ab.js";import{s as o,c as s}from"./p-b7307c61.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b7307c61.js";const r=["jsdelivr","cdnjs","unpkg","vercel"],i="jsdelivr",l=e=>{const n=r.indexOf(e);return r[n+1]||null},a=()=>{const n=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||n)return null;const t=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.137.js.zonos.com";if(!t&&(o.includes("test.")||o.includes("test-")))return o;if(!t&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const s=`https://${t}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${s}' for loading elements script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,t=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),s},u="https://js.stripe.com/v3",m=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,w="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let p=null;const f=Promise.resolve().then((()=>{return e=null,null!==p||(p=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(w),window.Stripe)n(window.Stripe);else try{let s=(()=>{const e=document.querySelectorAll(`script[src^="${u}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&m.test(t.src))return t}return null})();s&&e?console.warn(w):s||(s=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${u}${n}`;const s=document.head||document.body;return s?(s.appendChild(o),o):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==s||s.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==s||s.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),p;var e}));let h=!1;var v;f.catch((e=>{h||console.warn(e)}));const y=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),o=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:o,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?n:null})(),z="https://v1.3.137.js.zonos.com",j=y||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.137",S="https://rsms.me",g="https://fonts.googleapis.com",O=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class b{}v=b,b.doneInit=!1,b.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),b.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),b._paypalMockResponse=null,b.isBigCommerce=!1,b.releaseDate="1733521585949",b.isLegacyCheckout=!1,b.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",b.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),b.isNpm=!0,b.zonosQaUrl=null,b.zonosQaUrlApi=null,b.version="v1.3.137",b.modeAlerted=!1,b.cartData=null,b.paypal=null,b.getCurrentTimestamp=()=>(new Date).getTime(),b.zonosController=null,b.init=async r=>{const{appearance:i,checkoutSettings:c,currencyConverter:l,helloSettings:d,onCountryChange:u,overrideCurrencyFormat:m,storeId:w,zonosApiKey:p}=r;if(v.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),v.doneInit)return;if(e(`====== ZONOS DEBUG MODE: on (${v.version}) ======`),v.zonosApiKey=p,v.storeId=w,v.isNpm){e("====== ZONOS LOADING FROM NPM ======");const s=a();if(s&&!window.isZonosPreview){e(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${s} ======`,"info");const n=document.createElement("script");return n.src=`${s}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=v.isNpm,window.Zonos.isBigCommerce=v.isBigCommerce,window.Zonos.isLegacyCheckout=v.isLegacyCheckout,window.Zonos.init(r)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${s}`)})),void(window.isZonosPreview=!0)}if(!p&&!v.cartId)return void t("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!v.cartData&&v.cartId){e("Initialize cart data");const n=await o(v.cartId);if(!n)return void t("Failed to get cart data");v.cartData=n.cartData,v.zonosApiKey=n.zonosApiKey}const i=await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return null;if(e("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return e("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:s}=await n("/api/get-test-public-credential");if(o.length||!s)return t("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const r=s.publicCredential;return r?(e(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(t("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();i&&(v.zonosApiKey=i)}const f=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(v.cartId&&v.cartData||f){e("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const n=document.createElement("button");n.style.display="none",n.id=`${s}`,document.body.appendChild(n)}e("init zonos"),v.injectZonosCdn(),v.injectZonosCss(),v.injectFonts(),v.injectController({config:{appearance:i,checkoutSettings:c,currencyConverter:l,helloSettings:d,onCountryChange:u,overrideCurrencyFormat:m}}),v.doneInit=!0},b.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},b.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},b.showNotification=e=>{var n;null===(n=v.zonosController)||void 0===n||n.showNotification(e)},b.updateOrganizationName=e=>{var n;null===(n=v.zonosController)||void 0===n||n.updateOrganizationName(e)},b.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:t,placeOrderButtonSelector:o})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&o){const n=document.querySelectorAll(o),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&t&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},b.injectController=({config:n})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=n.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const e=n.checkoutSettings.placeOrderButtonSelector;v.disablePlaceOrderButtons({config:n,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{v.disablePlaceOrderButtons({config:n,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=n,s.zonosApiKey=v.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async n=>{const{detail:o}=n;e("loading Stripe");const r=await(async(...e)=>{h=!0;const n=Date.now();return f.then((t=>((e,n,t)=>{if(null===e)return null;const o=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(o,t),o})(t,e,n)))})(o.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),v.zonosController=s,e("Zonos controller injected!")},b.injectScript=({cdnType:n,isModule:o,theRestUrl:s})=>{const r=`${v.getZonosUrl(n)}/${s}`;if(document.querySelector(`script[src="${r}"]`))return void e(`Zonos script "${r}" already exists in the document`,"warn");const i=document.head||document.body,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=r,c.crossOrigin="anonymous",c.onerror=()=>{t(`Failed to load ${c.src}`);const e=l(n);e&&v.injectScript({cdnType:e,isModule:o,theRestUrl:s})},i.appendChild(c)},b.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return j;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.137";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.137";case"vercel":return z}};return v.isNpm&&a()||n()},b.injectZonosCdn=()=>{v.injectScript({cdnType:i,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),v.injectScript({cdnType:i,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},b.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=v.getZonosUrl(e),s=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${z}/`,s.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${o}/${n}`,i.onerror=()=>{t(`Failed to load ${i.href}`);const o=l(e);o&&v.injectStylesheet({cdnType:o,theRestUrl:n})},s.appendChild(i)},b.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(v.injectStylesheet({cdnType:i,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},b.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${S}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&!O.test(t.href))return t}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,t=document.createElement("link");t.rel="preconnect",t.href=S,n.appendChild(t);const o=document.createElement("link");o.rel="stylesheet",o.href=`${S}/inter/inter.css`,n.appendChild(o),e("Zonos font injected!")},b.setupGoogleFont=e=>{var n;null===(n=v.zonosController)||void 0===n||n.setupGoogleFont(e)},b.injectSupportGoogleFont=n=>{var t;e(`[FONT] injecting ${n}`);const o=null===(t=n.match(/family=(.*?):/))||void 0===t?void 0:t[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${g}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=g,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${o} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=n,s.appendChild(r),e(`[FONT] ${o} font injected!`)};export{b as Zonos}
@@ -1 +1 @@
1
- import{r as o,c as t,h as n,H as e}from"./p-5b7da777.js";import{B as i,j as s,C as r,d as a,a as c}from"./p-69045ca3.js";import{z as l,b as d,d as h}from"./p-edc16f69.js";import{h as u,a as f,l as m}from"./p-860e46ab.js";import"./p-10d6fe23.js";import"./p-d10ffd69.js";const p=o=>{const t=document.querySelector(o);if(!document.querySelector("zonos-hello")&&t){const o=document.createElement("zonos-hello");return t.appendChild(o),!0}return!1},w=o=>{switch(o){case"BOTTOM_RIGHT":default:return"bottom-right";case"BOTTOM_LEFT":return"bottom-left";case"TOP_LEFT":return"top-left";case"TOP_RIGHT":return"top-right"}},v=({position:o="bottom-right"})=>{const t=".zonos--hello-mobile-wrapper";if(document.querySelector(t))return t;const n=document.createElement("div");return n.className="zonos--hello-mobile-wrapper",n.style.position="fixed","top-right"===o&&(n.style.top="72px",n.style.right="24px"),"top-left"===o&&(n.style.top="72px",n.style.left="24px"),"bottom-right"===o&&(n.style.bottom="72px",n.style.right="24px"),"bottom-left"===o&&(n.style.bottom="72px",n.style.left="24px"),n.style.zIndex="2147483007",document.body.appendChild(n),t},b=async o=>{if(window.Zonos.isLegacyCheckout)return void m("Hello is disabled when isLegacyCheckout","info");const{anchorElementSelector:t}=o;let n=t;if(!o.anchorElementSelector&&o.desktopLocation){const o=v({position:"bottom-right"});n=o}if(n&&i(n)){if(m("Hello init complete"),!p(n)){const t=new MutationObserver((()=>{p(n)&&t.disconnect()}));t.observe(document.body,{childList:!0,subtree:!0}),setTimeout((()=>{p(n)}),1e3),setTimeout((()=>{if(o.notFoundElementFallback){m(`Hello anchor selector ${o.anchorElementSelector} not found after 3 seconds, falling back to 'notFoundElementFallback': ${o.notFoundElementFallback}`,"info");const t=v({position:w(o.notFoundElementFallback)});p(t)}}),3e3)}}else f(`Selector anchorElementSelector "${o.anchorElementSelector}" is not a valid selector.`)},y=class{constructor(n){o(this,n),this.paypalInitEvent=t(this,"paypalInitEvent",7),this.stripeInitEvent=t(this,"stripeInitEvent",7),this.config=void 0,this.zonosApiKey=void 0}async initCheckoutElement(o){var t;o?(s.stripe=o,((t=l.checkoutSettings).placeOrderButtonSelector||window.Zonos.cartData)&&(!t.placeOrderButtonSelector||i(t.placeOrderButtonSelector)?(()=>{if(!document.querySelector("zonos-checkout")){const o=document.createElement("zonos-checkout");document.body.appendChild(o)}})():f(`Selector checkoutButtonAnchor "${t.placeOrderButtonSelector}" is not a valid selector`)),m("init checkout element")):m("Stripe is not loaded yet - cannot init checkout element","warn")}initZonosNotification(){if(document.querySelector("zonos-notification"))return;const o=document.createElement("zonos-notification");document.body.appendChild(o)}async setupGoogleFont(o){var t,n;const e=o||h();if("Inter"===e){if(!o)return;m("[FONT] Just applied Inter , but no need to inject since we already inject Inter on start","warn"),l.appearance=Object.assign(Object.assign({},l.appearance),{fontFamily:o})}const i=new URLSearchParams;i.set("family",e);const{errors:s,json:r}=await u(`/api/zonos-elements/get-font-detail?${i.toString()}`);if(s.length>0)return m(`Failed to load font ${e}`,"warn"),void(l.appearance=Object.assign(Object.assign({},l.appearance),{fontFamily:"Inter"}));const a=null==r?void 0:r.fontUrl;a&&(null===(n=(t=window.Zonos).injectSupportGoogleFont)||void 0===n||n.call(t,a)),o&&(m(`[FONT] ${o} font override applied`),l.appearance=Object.assign(Object.assign({},l.appearance),{fontFamily:o}))}handleLocationChange(){b(l.helloSettings)}initHistoryListener(){const o=history.pushState;history.pushState=function(){return window.dispatchEvent(new window.Event("pushstate")),window.dispatchEvent(new window.Event("locationchange")),o.apply(this,arguments)};const t=history.replaceState;history.replaceState=function(){return window.dispatchEvent(new window.Event("replacestate")),window.dispatchEvent(new window.Event("locationchange")),t.apply(this,arguments)}}async componentWillLoad(){this.initHistoryListener(),l.zonosApiKey=this.zonosApiKey,(async()=>{var o,t;const{errors:n,json:e,zonosMode:i}=await(async()=>{const{errors:o,json:t,zonosMode:n}=await u("/api/zonos-elements/zonos-settings");return o.length?(f("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:o,json:null,zonosMode:n}):{errors:[],json:t,zonosMode:n}})();if("403"===(null===(o=n[0])||void 0===o?void 0:o.type.toString()))return void m("Failed to load zonos settings. This domain may not have access","warn");this.initZonosNotification();const s=Object.assign(Object.assign({},this.config),{appearance:Object.assign(Object.assign({},this.config.appearance),{logoUrl:(()=>{var o,t,n;return window.Zonos.isLegacyCheckout?(null===(o=null==e?void 0:e.appearanceSettings)||void 0===o?void 0:o.logoUrl)||(null===(t=this.config.appearance)||void 0===t?void 0:t.logoUrl):null===(n=this.config.appearance)||void 0===n?void 0:n.logoUrl})()}),checkoutSettings:this.config.checkoutSettings?Object.assign(Object.assign({},this.config.checkoutSettings),{subscriptionStatus:void 0}):void 0});d({overrideSettings:s,zonosSettings:e}),l.zonosMode=i,this.setupGoogleFont(),"DISABLED"===l.helloSettings.visibilityStatus&&m("=== Hello is disabled by store owner ===","warn"),l.helloSettings&&"ENABLED"===l.helloSettings.visibilityStatus&&(m("Initializing hello"),b(l.helloSettings)),await r();const a=(null===(t=null==e?void 0:e.checkoutSettings)||void 0===t?void 0:t.externalServiceTokens.find((o=>"STRIPE_PUBLISHABLE_TOKEN"===o.type)))||null;if(a&&this.stripeInitEvent)return"INACTIVE"===l.checkoutSettings.subscriptionStatus?(m('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn"),void m("zonos controller loaded")):"DISABLED"===l.checkoutSettings.visibilityStatus?(m("=== Checkout is disabled by store owner ===","warn"),void m("zonos controller loaded")):void this.stripeInitEvent.emit({publishableKey:a.token});m("Checkout failed to load -- missing publishable key","warn")})()}async showNotification(o){const t=document.querySelector("zonos-notification");t?t.showNotification(o):m("Failed to show notification - zonos-notification not found","warn")}async reset(){a.checkoutSessionId=null,s.clientSecret=null}async overrideConfig(o){d({overrideSettings:o,zonosSettings:null})}async overrideCountry(o){m(`Override country code to ${o}`),c(o)}async getAppearanceSetting(){return l.appearance}async updateOrganizationName(o){l.organizationName=o}render(){return n(e,{key:"465ac6979654a38581aef4bdde509c5e57f34a74",class:"zonos--elements"})}};y.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{visibility:hidden;opacity:0;height:0}";export{y as zonos_controller}
1
+ import{r as o,c as t,h as n,H as e}from"./p-5b7da777.js";import{C as i,f as s,D as r,e as a,a as c}from"./p-afa5c13c.js";import{z as l,b as d,d as h}from"./p-edc16f69.js";import{h as u,a as f,l as m}from"./p-860e46ab.js";import"./p-10d6fe23.js";import"./p-d10ffd69.js";const p=o=>{const t=document.querySelector(o);if(!document.querySelector("zonos-hello")&&t){const o=document.createElement("zonos-hello");return t.appendChild(o),!0}return!1},w=o=>{switch(o){case"BOTTOM_RIGHT":default:return"bottom-right";case"BOTTOM_LEFT":return"bottom-left";case"TOP_LEFT":return"top-left";case"TOP_RIGHT":return"top-right"}},v=({position:o="bottom-right"})=>{const t=".zonos--hello-mobile-wrapper";if(document.querySelector(t))return t;const n=document.createElement("div");return n.className="zonos--hello-mobile-wrapper",n.style.position="fixed","top-right"===o&&(n.style.top="72px",n.style.right="24px"),"top-left"===o&&(n.style.top="72px",n.style.left="24px"),"bottom-right"===o&&(n.style.bottom="72px",n.style.right="24px"),"bottom-left"===o&&(n.style.bottom="72px",n.style.left="24px"),n.style.zIndex="2147483007",document.body.appendChild(n),t},b=async o=>{if(window.Zonos.isLegacyCheckout)return void m("Hello is disabled when isLegacyCheckout","info");const{anchorElementSelector:t}=o;let n=t;if(!o.anchorElementSelector&&o.desktopLocation){const o=v({position:"bottom-right"});n=o}if(n&&i(n)){if(m("Hello init complete"),!p(n)){const t=new MutationObserver((()=>{p(n)&&t.disconnect()}));t.observe(document.body,{childList:!0,subtree:!0}),setTimeout((()=>{p(n)}),1e3),setTimeout((()=>{if(o.notFoundElementFallback){m(`Hello anchor selector ${o.anchorElementSelector} not found after 3 seconds, falling back to 'notFoundElementFallback': ${o.notFoundElementFallback}`,"info");const t=v({position:w(o.notFoundElementFallback)});p(t)}}),3e3)}}else f(`Selector anchorElementSelector "${o.anchorElementSelector}" is not a valid selector.`)},y=class{constructor(n){o(this,n),this.paypalInitEvent=t(this,"paypalInitEvent",7),this.stripeInitEvent=t(this,"stripeInitEvent",7),this.config=void 0,this.zonosApiKey=void 0}async initCheckoutElement(o){var t;o?(s.stripe=o,((t=l.checkoutSettings).placeOrderButtonSelector||window.Zonos.cartData)&&(!t.placeOrderButtonSelector||i(t.placeOrderButtonSelector)?(()=>{if(!document.querySelector("zonos-checkout")){const o=document.createElement("zonos-checkout");document.body.appendChild(o)}})():f(`Selector checkoutButtonAnchor "${t.placeOrderButtonSelector}" is not a valid selector`)),m("init checkout element")):m("Stripe is not loaded yet - cannot init checkout element","warn")}initZonosNotification(){if(document.querySelector("zonos-notification"))return;const o=document.createElement("zonos-notification");document.body.appendChild(o)}async setupGoogleFont(o){var t,n;const e=o||h();if("Inter"===e){if(!o)return;m("[FONT] Just applied Inter , but no need to inject since we already inject Inter on start","warn"),l.appearance=Object.assign(Object.assign({},l.appearance),{fontFamily:o})}const i=new URLSearchParams;i.set("family",e);const{errors:s,json:r}=await u(`/api/zonos-elements/get-font-detail?${i.toString()}`);if(s.length>0)return m(`Failed to load font ${e}`,"warn"),void(l.appearance=Object.assign(Object.assign({},l.appearance),{fontFamily:"Inter"}));const a=null==r?void 0:r.fontUrl;a&&(null===(n=(t=window.Zonos).injectSupportGoogleFont)||void 0===n||n.call(t,a)),o&&(m(`[FONT] ${o} font override applied`),l.appearance=Object.assign(Object.assign({},l.appearance),{fontFamily:o}))}handleLocationChange(){b(l.helloSettings)}initHistoryListener(){const o=history.pushState;history.pushState=function(){return window.dispatchEvent(new window.Event("pushstate")),window.dispatchEvent(new window.Event("locationchange")),o.apply(this,arguments)};const t=history.replaceState;history.replaceState=function(){return window.dispatchEvent(new window.Event("replacestate")),window.dispatchEvent(new window.Event("locationchange")),t.apply(this,arguments)}}async componentWillLoad(){this.initHistoryListener(),l.zonosApiKey=this.zonosApiKey,(async()=>{var o,t;const{errors:n,json:e,zonosMode:i}=await(async()=>{const{errors:o,json:t,zonosMode:n}=await u("/api/zonos-elements/zonos-settings");return o.length?(f("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:o,json:null,zonosMode:n}):{errors:[],json:t,zonosMode:n}})();if("403"===(null===(o=n[0])||void 0===o?void 0:o.type.toString()))return void m("Failed to load zonos settings. This domain may not have access","warn");this.initZonosNotification();const s=Object.assign(Object.assign({},this.config),{appearance:Object.assign(Object.assign({},this.config.appearance),{logoUrl:(()=>{var o,t,n;return window.Zonos.isLegacyCheckout?(null===(o=null==e?void 0:e.appearanceSettings)||void 0===o?void 0:o.logoUrl)||(null===(t=this.config.appearance)||void 0===t?void 0:t.logoUrl):null===(n=this.config.appearance)||void 0===n?void 0:n.logoUrl})()}),checkoutSettings:this.config.checkoutSettings?Object.assign(Object.assign({},this.config.checkoutSettings),{subscriptionStatus:void 0}):void 0});d({overrideSettings:s,zonosSettings:e}),l.zonosMode=i,this.setupGoogleFont(),"DISABLED"===l.helloSettings.visibilityStatus&&m("=== Hello is disabled by store owner ===","warn"),l.helloSettings&&"ENABLED"===l.helloSettings.visibilityStatus&&(m("Initializing hello"),b(l.helloSettings)),await r();const a=(null===(t=null==e?void 0:e.checkoutSettings)||void 0===t?void 0:t.externalServiceTokens.find((o=>"STRIPE_PUBLISHABLE_TOKEN"===o.type)))||null;if(a&&this.stripeInitEvent)return"INACTIVE"===l.checkoutSettings.subscriptionStatus?(m('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn"),void m("zonos controller loaded")):"DISABLED"===l.checkoutSettings.visibilityStatus?(m("=== Checkout is disabled by store owner ===","warn"),void m("zonos controller loaded")):void this.stripeInitEvent.emit({publishableKey:a.token});m("Checkout failed to load -- missing publishable key","warn")})()}async showNotification(o){const t=document.querySelector("zonos-notification");t?t.showNotification(o):m("Failed to show notification - zonos-notification not found","warn")}async reset(){a.checkoutSessionId=null,s.clientSecret=null}async overrideConfig(o){d({overrideSettings:o,zonosSettings:null})}async overrideCountry(o){m(`Override country code to ${o}`),c(o)}async getAppearanceSetting(){return l.appearance}async updateOrganizationName(o){l.organizationName=o}render(){return n(e,{key:"465ac6979654a38581aef4bdde509c5e57f34a74",class:"zonos--elements"})}};y.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{visibility:hidden;opacity:0;height:0}";export{y as zonos_controller}