@tagadapay/plugin-sdk 3.1.12 → 3.1.24

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 (144) hide show
  1. package/build-cdn.js +397 -11
  2. package/dist/data/iso3166.d.ts +23 -33
  3. package/dist/data/iso3166.js +134 -198
  4. package/dist/data/languages.d.ts +5 -64
  5. package/dist/data/languages.js +23 -143
  6. package/dist/external-tracker.js +623 -3426
  7. package/dist/external-tracker.min.js +2 -25
  8. package/dist/external-tracker.min.js.map +4 -4
  9. package/dist/react/config/payment.d.ts +14 -4
  10. package/dist/react/config/payment.js +47 -9
  11. package/dist/react/hooks/useCheckout.d.ts +3 -0
  12. package/dist/react/hooks/useCheckout.js +4 -1
  13. package/dist/react/hooks/useISOData.js +1 -1
  14. package/dist/react/hooks/usePaymentPolling.d.ts +3 -3
  15. package/dist/react/hooks/usePluginConfig.js +9 -10
  16. package/dist/react/providers/TagadaProvider.js +1 -1
  17. package/dist/tagada-react-sdk-minimal.min.js +36 -0
  18. package/dist/tagada-react-sdk-minimal.min.js.map +7 -0
  19. package/dist/tagada-react-sdk.js +37821 -0
  20. package/dist/tagada-react-sdk.min.js +78 -0
  21. package/dist/tagada-react-sdk.min.js.map +7 -0
  22. package/dist/tagada-sdk.js +16044 -0
  23. package/dist/tagada-sdk.min.js +32 -0
  24. package/dist/tagada-sdk.min.js.map +7 -0
  25. package/dist/v2/cdn-react-minimal.d.ts +23 -0
  26. package/dist/v2/cdn-react-minimal.js +26 -0
  27. package/dist/v2/core/client.d.ts +4 -2
  28. package/dist/v2/core/client.js +5 -4
  29. package/dist/v2/core/config/environment.js +2 -1
  30. package/dist/v2/core/errors.d.ts +75 -0
  31. package/dist/v2/core/errors.js +104 -0
  32. package/dist/v2/core/funnelClient.d.ts +100 -10
  33. package/dist/v2/core/funnelClient.js +121 -27
  34. package/dist/v2/core/isoData.d.ts +4 -4
  35. package/dist/v2/core/isoData.js +7 -7
  36. package/dist/v2/core/pixelMapping.d.ts +49 -0
  37. package/dist/v2/core/pixelMapping.js +363 -0
  38. package/dist/v2/core/resources/apiClient.d.ts +2 -0
  39. package/dist/v2/core/resources/apiClient.js +52 -9
  40. package/dist/v2/core/resources/checkout.d.ts +99 -30
  41. package/dist/v2/core/resources/checkout.js +14 -0
  42. package/dist/v2/core/resources/customer.d.ts +20 -19
  43. package/dist/v2/core/resources/expressPaymentMethods.d.ts +1 -0
  44. package/dist/v2/core/resources/funnel.d.ts +17 -17
  45. package/dist/v2/core/resources/payments.d.ts +89 -13
  46. package/dist/v2/core/resources/payments.js +27 -9
  47. package/dist/v2/core/resources/postPurchases.d.ts +17 -0
  48. package/dist/v2/core/resources/postPurchases.js +20 -0
  49. package/dist/v2/core/types.d.ts +50 -12
  50. package/dist/v2/core/types.js +0 -3
  51. package/dist/v2/core/utils/checkout.d.ts +2 -2
  52. package/dist/v2/core/utils/checkout.js +7 -2
  53. package/dist/v2/core/utils/currency.d.ts +14 -0
  54. package/dist/v2/core/utils/currency.js +40 -0
  55. package/dist/v2/core/utils/deviceInfo.d.ts +0 -10
  56. package/dist/v2/core/utils/deviceInfo.js +152 -76
  57. package/dist/v2/core/utils/index.d.ts +1 -0
  58. package/dist/v2/core/utils/index.js +2 -0
  59. package/dist/v2/core/utils/order.d.ts +13 -9
  60. package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
  61. package/dist/v2/core/utils/pluginConfig.js +36 -12
  62. package/dist/v2/index.d.ts +6 -3
  63. package/dist/v2/index.js +4 -2
  64. package/dist/v2/react/components/FunnelScriptInjector.js +166 -77
  65. package/dist/v2/react/components/StripeExpressButton.d.ts +13 -0
  66. package/dist/v2/react/components/StripeExpressButton.js +171 -0
  67. package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
  68. package/dist/v2/react/components/WhopCheckout.js +237 -0
  69. package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +1 -1
  70. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.d.ts +14 -0
  71. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +181 -0
  72. package/dist/v2/react/hooks/payment-actions/useErrorAction.d.ts +9 -0
  73. package/dist/v2/react/hooks/payment-actions/useErrorAction.js +21 -0
  74. package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.d.ts +14 -0
  75. package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.js +187 -0
  76. package/dist/v2/react/hooks/payment-actions/useKessPayAction.d.ts +11 -0
  77. package/dist/v2/react/hooks/payment-actions/useKessPayAction.js +91 -0
  78. package/dist/v2/react/hooks/payment-actions/useMasterCardAction.d.ts +24 -0
  79. package/dist/v2/react/hooks/payment-actions/useMasterCardAction.js +221 -0
  80. package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.d.ts +15 -0
  81. package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.js +142 -0
  82. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.d.ts +3 -0
  83. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.js +31 -0
  84. package/dist/v2/react/hooks/payment-actions/useRedirectAction.d.ts +10 -0
  85. package/dist/v2/react/hooks/payment-actions/useRedirectAction.js +35 -0
  86. package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.d.ts +14 -0
  87. package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.js +192 -0
  88. package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.d.ts +14 -0
  89. package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.js +81 -0
  90. package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.d.ts +11 -0
  91. package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.js +84 -0
  92. package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.d.ts +14 -0
  93. package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.js +36 -0
  94. package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.d.ts +31 -0
  95. package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.js +212 -0
  96. package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.d.ts +14 -0
  97. package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.js +207 -0
  98. package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.d.ts +12 -0
  99. package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.js +101 -0
  100. package/dist/v2/react/hooks/useApplePayCheckout.js +8 -8
  101. package/dist/v2/react/hooks/useCheckoutQuery.d.ts +16 -0
  102. package/dist/v2/react/hooks/useCheckoutQuery.js +63 -10
  103. package/dist/v2/react/hooks/useFunnel.d.ts +15 -4
  104. package/dist/v2/react/hooks/useFunnel.js +8 -4
  105. package/dist/v2/react/hooks/useGeoLocation.d.ts +2 -1
  106. package/dist/v2/react/hooks/useGeoLocation.js +4 -2
  107. package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +2 -0
  108. package/dist/v2/react/hooks/useGoogleAutocomplete.js +29 -15
  109. package/dist/v2/react/hooks/useISOData.d.ts +2 -5
  110. package/dist/v2/react/hooks/useISOData.js +26 -27
  111. package/dist/v2/react/hooks/usePaymentPolling.d.ts +3 -3
  112. package/dist/v2/react/hooks/usePaymentQuery.d.ts +18 -5
  113. package/dist/v2/react/hooks/usePaymentQuery.js +63 -1015
  114. package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +3 -2
  115. package/dist/v2/react/hooks/usePaymentRetrieve.js +3 -1
  116. package/dist/v2/react/hooks/usePixelTracking.d.ts +5 -48
  117. package/dist/v2/react/hooks/usePixelTracking.js +283 -504
  118. package/dist/v2/react/hooks/usePostPurchasesQuery.js +34 -2
  119. package/dist/v2/react/hooks/useRemappableParams.d.ts +2 -6
  120. package/dist/v2/react/hooks/useRemappableParams.js +23 -23
  121. package/dist/v2/react/hooks/useSetPaymentMethod.d.ts +16 -0
  122. package/dist/v2/react/hooks/useSetPaymentMethod.js +33 -0
  123. package/dist/v2/react/hooks/useShippingRatesQuery.js +13 -5
  124. package/dist/v2/react/hooks/useStepConfig.d.ts +23 -6
  125. package/dist/v2/react/hooks/useStepConfig.js +14 -7
  126. package/dist/v2/react/hooks/useTranslation.js +23 -8
  127. package/dist/v2/react/hooks/useWhopPaymentPolling.d.ts +30 -0
  128. package/dist/v2/react/hooks/useWhopPaymentPolling.js +61 -0
  129. package/dist/v2/react/index.d.ts +15 -1
  130. package/dist/v2/react/index.js +7 -0
  131. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +3 -1
  132. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +12 -2
  133. package/dist/v2/react/providers/TagadaProvider.js +74 -5
  134. package/dist/v2/standalone/external-tracker.d.ts +52 -46
  135. package/dist/v2/standalone/external-tracker.js +205 -98
  136. package/dist/v2/standalone/index.d.ts +40 -0
  137. package/dist/v2/standalone/index.js +148 -1
  138. package/dist/v2/standalone/payment-service.d.ts +134 -0
  139. package/dist/v2/standalone/payment-service.js +928 -0
  140. package/package.json +6 -4
  141. package/dist/react/utils/__tests__/urlUtils.test.d.ts +0 -1
  142. package/dist/react/utils/__tests__/urlUtils.test.js +0 -189
  143. package/dist/v2/core/__tests__/pathRemapping.test.d.ts +0 -11
  144. package/dist/v2/core/__tests__/pathRemapping.test.js +0 -776
@@ -0,0 +1,32 @@
1
+ /**
2
+ * TagadaPay SDK v3.1.24
3
+ * CDN Bundle - Full standalone SDK for external/vanilla pages
4
+ * Usage: window.tgd.createTagadaClient(), window.tgd.formatMoney(), etc.
5
+ * @license MIT
6
+ */
7
+ "use strict";var TagadaSDKBundle=(()=>{var $d=Object.create;var Ft=Object.defineProperty,qd=Object.defineProperties,jd=Object.getOwnPropertyDescriptor,Hd=Object.getOwnPropertyDescriptors,Kd=Object.getOwnPropertyNames,Gi=Object.getOwnPropertySymbols,zd=Object.getPrototypeOf,Ji=Object.prototype.hasOwnProperty,Vd=Object.prototype.propertyIsEnumerable;var rt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Gd=t=>{throw TypeError(t)};var Wi=(t,e,n)=>e in t?Ft(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,w=(t,e)=>{for(var n in e||(e={}))Ji.call(e,n)&&Wi(t,n,e[n]);if(Gi)for(var n of Gi(e))Vd.call(e,n)&&Wi(t,n,e[n]);return t},N=(t,e)=>qd(t,Hd(e));var Oe=(t,e)=>()=>(t&&(e=t(t=0)),e);var R=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),st=(t,e)=>{for(var n in e)Ft(t,n,{get:e[n],enumerable:!0})},Yi=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Kd(e))!Ji.call(t,s)&&s!==n&&Ft(t,s,{get:()=>e[s],enumerable:!(r=jd(e,s))||r.enumerable});return t};var Xi=(t,e,n)=>(n=t!=null?$d(zd(t)):{},Yi(e||!t||!t.__esModule?Ft(n,"default",{value:t,enumerable:!0}):n,t)),ws=t=>Yi(Ft({},"__esModule",{value:!0}),t);var fe=function(t,e){this[0]=t,this[1]=e},ot=(t,e,n)=>{var r=(i,a,l,c)=>{try{var u=n[i](a),f=(a=u.value)instanceof fe,g=u.done;Promise.resolve(f?a[0]:a).then(m=>f?r(i==="return"?i:"next",a[1]?{done:m.done,value:m.value}:m,l,c):l({value:m,done:g})).catch(m=>r("throw",m,l,c))}catch(m){c(m)}},s=i=>o[i]=a=>new Promise((l,c)=>r(i,a,l,c)),o={};return n=n.apply(t,e),o[rt("asyncIterator")]=()=>o,s("next"),s("throw"),s("return"),o},Me=t=>{var e=t[rt("asyncIterator")],n=!1,r,s={};return e==null?(e=t[rt("iterator")](),r=o=>s[o]=i=>e[o](i)):(e=e.call(t),r=o=>s[o]=i=>{if(n){if(n=!1,o==="throw")throw i;return i}return n=!0,{done:!1,value:new fe(new Promise(a=>{var l=e[o](i);l instanceof Object||Gd("Object expected"),a(l)}),1)}}),s[rt("iterator")]=()=>s,r("next"),"throw"in e?r("throw"):s.throw=o=>{throw o},"return"in e&&r("return"),s},An=(t,e,n)=>(e=t[rt("asyncIterator")])?e.call(t):(t=t[rt("iterator")](),e={},n=(r,s)=>(s=t[r])&&(e[r]=o=>new Promise((i,a,l)=>(o=s.call(t,o),l=o.done,Promise.resolve(o.value).then(c=>i({value:c,done:l}),a)))),n("next"),n("return"),e);function Qi(t){var r;if(typeof document=="undefined")return null;let n="; ".concat(document.cookie).split("; ".concat(t,"="));return n.length===2&&((r=n.pop())==null?void 0:r.split(";").shift())||null}function ea(t="local"){let e=Zi[t];if(!e)return console.warn("Unknown environment: ".concat(t,". Falling back to local.")),{environment:"local",apiConfig:Zi.local};let n=null;if(typeof window!="undefined"&&(n=new URLSearchParams(window.location.search).get("tagadaClientBaseUrl"),!n))try{n=localStorage.getItem("tgd_client_base_url")||Qi("tgd_client_base_url")}catch(s){}return n?(console.log("[SDK] Using custom API base URL override: ".concat(n)),{environment:t,apiConfig:N(w({},e),{baseUrl:n})}):{environment:t,apiConfig:e}}function $t(){var s;if(console.log("[SDK] detectEnvironment() called"),typeof window=="undefined")return"local";let e=new URLSearchParams(window.location.search).get("tagadaClientEnv");if(e&&(e==="production"||e==="development"||e==="local"))return console.log("[SDK] Using explicit environment override: ".concat(e)),e;try{let o=localStorage.getItem("tgd_client_env")||Qi("tgd_client_env");if(o&&(o==="production"||o==="development"||o==="local"))return console.log("[SDK] Using persisted environment override: ".concat(o)),o}catch(o){}let n=window.location.hostname,r=window.location.href;if(console.log('[SDK] detectEnvironment() - hostname: "'.concat(n,'"')),n==="localhost"||n.startsWith("127.")||n.startsWith("192.168.")||n.startsWith("10.")||n.includes(".local")||n===""||n==="0.0.0.0"||n.includes("ngrok-free.dev")||n.includes("ngrok-free.app")||n.includes("ngrok.io")||n.includes("ngrok.app")||n.includes(".loclx.io")){if(console.log("[SDK] detectEnvironment() - returning LOCAL"),typeof window!="undefined"&&((s=window==null?void 0:window.__TAGADA_ENV__)!=null&&s.TAGADA_ENVIRONMENT)){let o=window.__TAGADA_ENV__.TAGADA_ENVIRONMENT.toLowerCase();if(o==="production"||o==="development"||o==="local")return console.log("[SDK] Local override detected: ".concat(o)),o}return"local"}return n==="app.tagadapay.com"||n.includes("tagadapay.com")||n.includes("yourproductiondomain.com")?"production":n==="app.tagadapay.dev"||n.includes("tagadapay.dev")||n.includes("vercel.app")||n.includes("netlify.app")||n.includes("surge.sh")||n.includes("github.io")||n.includes("herokuapp.com")||n.includes("railway.app")||r.includes("?env=dev")||r.includes("?dev=true")||r.includes("#dev")?"development":(console.warn("[SDK] Unknown domain: ".concat(n,", defaulting to production")),"production")}function qt(t=!1){return $t()!=="local"?!1:t&&typeof window!="undefined"?!window.location.hostname.includes(".cdn."):!0}var Zi,_n=Oe(()=>{"use strict";Zi={production:{baseUrl:"https://app.tagadapay.com",endpoints:{checkout:{sessionInit:"/api/v1/checkout/session/init",sessionInitAsync:"/api/v1/checkout/session/init-async",sessionStatus:"/api/v1/checkout/session/status",asyncStatus:"/api/public/v1/checkout/async-status"},customer:{profile:"/api/v1/customer/profile",session:"/api/v1/customer/session"},store:{config:"/api/v1/store/config"}}},development:{baseUrl:"https://app.tagadapay.dev",endpoints:{checkout:{sessionInit:"/api/v1/checkout/session/init",sessionInitAsync:"/api/v1/checkout/session/init-async",sessionStatus:"/api/v1/checkout/session/status",asyncStatus:"/api/public/v1/checkout/async-status"},customer:{profile:"/api/v1/customer/profile",session:"/api/v1/customer/session"},store:{config:"/api/v1/store/config"}}},local:{baseUrl:"http://app.localhost:3000",endpoints:{checkout:{sessionInit:"/api/v1/checkout/session/init",sessionInitAsync:"/api/v1/checkout/session/init-async",sessionStatus:"/api/v1/checkout/session/status",asyncStatus:"/api/public/v1/checkout/async-status"},customer:{profile:"/api/v1/customer/profile",session:"/api/v1/customer/session"},store:{config:"/api/v1/store/config"}}}}});var xn,In,Ss=Oe(()=>{"use strict";xn=(g=>(g.DIRECT_NAVIGATION="direct_navigation",g.BACK_NAVIGATION="back_navigation",g.CONTINUE_CLICKED="continue_clicked",g.BUTTON_CLICK="button_click",g.FORM_SUBMIT="form_submit",g.PAYMENT_SUCCESS="payment_success",g.PAYMENT_FAILED="payment_failed",g.OFFER_ACCEPTED="offer_accepted",g.OFFER_DECLINED="offer_declined",g.CART_UPDATED="cart_updated",g.CART_ITEM_ADDED="cart_item_added",g.CUSTOM="custom",g))(xn||{}),In=class{constructor(e){this.apiClient=e}async initialize(e){return this.apiClient.post("/api/v1/funnel/initialize",e)}async navigate(e){return this.apiClient.post("/api/v1/funnel/navigate",e)}async updateContext(e,n){return this.apiClient.patch("/api/v1/funnel/context/".concat(e),n)}async endSession(e){return this.apiClient.delete("/api/v1/funnel/session/".concat(e))}async getSession(e,n,r){let s=new URLSearchParams;n&&s.append("currentUrl",n),r&&s.append("includeDebugData","true");let o="/api/v1/funnel/session/".concat(e).concat(s.toString()?"?".concat(s):"");return this.apiClient.get(o)}}});var it,Es=Oe(()=>{"use strict";it=class{constructor(){this.listeners=new Set}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(e){this.listeners.forEach(n=>{try{n(e)}catch(r){console.error("Error in event listener:",r)}})}clear(){this.listeners.clear()}}});function he(t){if(typeof window!="undefined")try{let n=localStorage.getItem(On)!==t;localStorage.setItem(On,t),n&&window.dispatchEvent(new Event("storage"))}catch(e){console.error("Failed to save token to localStorage:",e)}}function jt(){if(typeof window!="undefined")try{return localStorage.getItem(On)}catch(t){return console.error("Failed to get token from localStorage:",t),null}return null}function at(){if(typeof window!="undefined")try{localStorage.removeItem(On)}catch(t){console.error("Failed to clear token from localStorage:",t)}}var On,ct=Oe(()=>{"use strict";On="cms_token"});function Ts(t){typeof document!="undefined"&&(document.cookie="".concat(Cs,"=").concat(t,"; path=/; max-age=2592000; SameSite=Lax"))}function kn(){if(typeof document=="undefined")return;let t=document.cookie.split("; ").find(e=>e.startsWith("".concat(Cs,"=")));return t?t.split("=")[1]:void 0}function Ht(){typeof document!="undefined"&&(document.cookie="".concat(Cs,"=; path=/; max-age=0"))}function Jd(){return!!kn()}function Yd(){var t;if(typeof document!="undefined")try{let e=document.cookie.split("; ").find(r=>r.startsWith("".concat(Wd,"=")));if(!e)return;let n=JSON.parse(decodeURIComponent(e.split("=")[1]));return(t=n==null?void 0:n.metadata)==null?void 0:t.funnelVariantId}catch(e){console.warn("Failed to parse sticky session for variant ID:",e);return}}var Cs,Wd,Dn=Oe(()=>{"use strict";Cs="tgd-funnel-session-id",Wd="tgd-session-id"});function lt(t){if(typeof window=="undefined")return null;try{return localStorage.getItem(t)}catch(e){return null}}function Nn(t,e){if(typeof window!="undefined")try{localStorage.setItem(t,e)}catch(n){}}function Kt(t){var r;if(typeof document=="undefined")return null;let n=document.cookie.split(";").find(s=>s.trim().startsWith("".concat(t,"=")));return n?(r=n.split("=")[1])==null?void 0:r.trim():null}function Rs(t,e,n=86400){if(typeof document!="undefined"){if(t==="tgd_draft"||t==="tgd-draft"){console.warn("\u{1F6E1}\uFE0F [SDK] Blocked attempt to set ".concat(t," as cookie - this should only be in localStorage"));return}document.cookie="".concat(t,"=").concat(e,"; path=/; max-age=").concat(n)}}function na(t){typeof document!="undefined"&&(document.cookie="".concat(t,"=; path=/; max-age=0"))}function Je(){if(typeof window=="undefined")return{};let t=new URLSearchParams(window.location.search),e,n=t.get("draft");if(n!==null)e=n==="true";else{let E=lt(F.DRAFT);E!==null&&(e=E==="true")}let r,s=t.get("funnelTracking");if(s!==null)r=s!=="false";else{let E=lt(F.FUNNEL_TRACKING)||Kt(F.FUNNEL_TRACKING);E!==null&&(r=E!=="false")}let o=t.get("token")||jt()||null,i=t.get("funnelSessionId")||null,a=t.get("funnelId")||null,l,c=t.get("funnelEnv");c&&(c==="staging"||c==="production")&&(l=c);let u=t.get("forceReset")==="true",f,g=t.get("tagadaClientEnv");if(g&&(g==="production"||g==="development"||g==="local"))f=g;else{let E=lt(F.CLIENT_ENV)||Kt(F.CLIENT_ENV);E&&(E==="production"||E==="development"||E==="local")&&(f=E)}let m,d=t.get("tagadaClientBaseUrl");if(d)m=d;else{let E=lt(F.CLIENT_BASE_URL)||Kt(F.CLIENT_BASE_URL);E&&(m=E)}let h,p=t.get("currency");if(p)h=p;else{let E=lt(F.CURRENCY)||Kt(F.CURRENCY);E&&(h=E)}let S,C=t.get("locale");if(C)S=C;else{let E=lt(F.LOCALE)||Kt(F.LOCALE);E&&(S=E)}return{forceReset:u,token:o,funnelSessionId:i,funnelId:a,draft:e,funnelTracking:r,funnelEnv:l,tagadaClientEnv:f,tagadaClientBaseUrl:m,currency:h,locale:S}}function zt(){var e;return(e=Je().draft)!=null?e:!1}function vs(t){if(typeof window!="undefined")if(t)Nn(F.DRAFT,"true");else try{localStorage.removeItem(F.DRAFT)}catch(e){}}function ra(t=!1){let e=null;typeof window!="undefined"&&(e=new URLSearchParams(window.location.search).get("token"));let n=Je(),r=n.forceReset||!1;if(!r&&!n.token)return ta(),!1;t&&(console.log("[SDK] Detected params:",n),console.log("[SDK] URL token (direct read):",e?e.substring(0,20)+"...":"none")),r&&(t&&console.log("[SDK] Force reset: Clearing all stored state"),at(),Ht(),typeof window!="undefined"&&window.localStorage&&Object.keys(localStorage).forEach(i=>{(i.startsWith("tagadapay_")||i.startsWith("tgd_"))&&(t&&console.log("[SDK] Clearing localStorage: ".concat(i)),localStorage.removeItem(i))}));let s=e||n.token;return s!=null?(t&&console.log("[SDK] Setting token from URL:",s.substring(0,20)+"..."),s===""||s==="null"?at():(he(s),t&&console.log("[SDK] \u2705 Token set in localStorage immediately after clear"))):r&&(t&&console.log("[SDK] Force reset mode (no token in URL)"),at()),ta(),n.funnelSessionId&&t&&console.log("[SDK] Using funnelSessionId from URL:",n.funnelSessionId),r}function ta(){if(typeof window=="undefined")return;let t=new URLSearchParams(window.location.search),e=t.get("draft");e!==null&&vs(e==="true");let n=t.get("funnelTracking");n!==null&&Xd(n!=="false");let r=t.get("tagadaClientEnv");r&&(r==="production"||r==="development"||r==="local")&&Zd(r);let s=t.get("tagadaClientBaseUrl");s&&Qd(s)}function Xd(t){if(typeof window=="undefined")return;let e=t?"true":"false";Nn(F.FUNNEL_TRACKING,e),Rs(F.FUNNEL_TRACKING,e,86400)}function Zd(t){typeof window!="undefined"&&(Nn(F.CLIENT_ENV,t),Rs(F.CLIENT_ENV,t,86400))}function sa(){if(typeof window!="undefined")try{localStorage.removeItem(F.CLIENT_ENV),na(F.CLIENT_ENV)}catch(t){}}function Qd(t){typeof window!="undefined"&&(Nn(F.CLIENT_BASE_URL,t),Rs(F.CLIENT_BASE_URL,t,86400))}function oa(){if(typeof window!="undefined")try{localStorage.removeItem(F.CLIENT_BASE_URL),na(F.CLIENT_BASE_URL)}catch(t){}}function ia(){var e;return(e=Je().funnelTracking)!=null?e:!0}var F,Ln=Oe(()=>{"use strict";ct();Dn();F={DRAFT:"tgd_draft",FUNNEL_TRACKING:"tgd_funnel_tracking",FORCE_RESET:"tgd_force_reset",CLIENT_ENV:"tgd_client_env",CLIENT_BASE_URL:"tgd_client_base_url",CURRENCY:"tgd_currency",LOCALE:"tgd_locale"}});var aa={};st(aa,{injectPreviewModeIndicator:()=>tf,isIndicatorInjected:()=>rf,removePreviewModeIndicator:()=>nf});function Ps(t){if(typeof window=="undefined"||typeof document=="undefined")return;let e=window.location.hostname,n=e.split("."),r=["",e,"."+e];for(let a=1;a<n.length;a++){let l=n.slice(a).join(".");r.push(l),r.push("."+l)}let s=window.location.pathname.split("/").filter(a=>a),o=["/"],i="";s.forEach(a=>{i+="/"+a,o.push(i)}),r.forEach(a=>{o.forEach(l=>{let c="".concat(t,"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=").concat(l),u=a?"; domain=".concat(a):"";document.cookie=c+u,document.cookie=c+u+"; secure",document.cookie=c+u+"; SameSite=None; secure",document.cookie=c+u+"; SameSite=Lax",document.cookie=c+u+"; SameSite=Strict"})})}function ef(){if(typeof window=="undefined"||!confirm("\u{1F6AA} Leave Preview Mode?\n\nThis will clear ALL cookies and localStorage (including Shopify session, cart, and preview settings) and reload the page.\n\nAre you sure?"))return;let e=new URL(window.location.href);["draft","funnelEnv","funnelTracking","tagadaClientEnv","tagadaClientBaseUrl","forceReset","funnelId","funnelSessionId","token"].forEach(o=>e.searchParams.delete(o)),window.history.replaceState({},"",e.href);try{let o=Object.getOwnPropertyDescriptor(Document.prototype,"cookie")||Object.getOwnPropertyDescriptor(HTMLDocument.prototype,"cookie");o&&o.set&&Object.defineProperty(document,"cookie",{configurable:!0,enumerable:!0,get:function(){return o.get?o.get.call(this):""},set:function(i){if(typeof i=="string"){let a=i.toLowerCase();if(a.includes("tgd_draft")||a.includes("tgd-draft")||a.includes("tgd.draft")||a.includes("tgddraft")){if(a.includes("max-age=0")||a.includes("expires=thu, 01 jan 1970")){o.set&&o.set.call(this,i);return}console.warn("\u{1F6E1}\uFE0F [TagadaPay] BLOCKED: tgd_draft should never be a cookie");return}}o.set&&o.set.call(this,i)}})}catch(o){console.warn("[TagadaPay] Could not install cookie blocker:",o)}if(window.localStorage)try{localStorage.removeItem("tgd_draft"),localStorage.removeItem("tgd_funnel_tracking"),localStorage.removeItem("tgd_client_env"),localStorage.removeItem("tgd_client_base_url"),localStorage.removeItem("cms_token")}catch(o){console.warn("[TagadaPay] Failed to clear some localStorage keys:",o)}at(),Ht(),sa(),oa(),window.localStorage&&localStorage.clear(),window.sessionStorage&&sessionStorage.clear(),["tgd-funnel-session-id","tgd_draft","tgd_funnel_tracking","tgd_client_env","tgd_client_base_url","cms_token","tagadapay_session"].forEach(o=>Ps(o)),["tgd-draft","tgd_draft","tgd.draft","tgddraft"].forEach(o=>Ps(o)),document.cookie&&document.cookie.split(";").forEach(i=>{let a=i.split("=")[0].trim();if(!a)return;let l=window.location.hostname,c=l.split("."),u=["",l,"."+l];for(let d=1;d<c.length;d++){let h=c.slice(d).join(".");u.push(h),u.push("."+h)}let f=window.location.pathname.split("/").filter(d=>d),g=["/"],m="";f.forEach(d=>{m+="/"+d,g.push(m)}),u.forEach(d=>{g.forEach(h=>{let p="".concat(a,"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=").concat(h),S=d?"; domain=".concat(d):"";document.cookie=p+S,document.cookie=p+S+"; secure",document.cookie=p+S+"; SameSite=None; secure",document.cookie=p+S+"; SameSite=Lax",document.cookie=p+S+"; SameSite=Strict",document.cookie=p+S+"; secure; SameSite=None",document.cookie=p+S+"; secure; SameSite=Lax",document.cookie=p+S+"; secure; SameSite=Strict"})})}),setTimeout(()=>{window.localStorage&&localStorage.length>0&&localStorage.clear(),Ps("tgd_draft"),typeof window.stop=="function"&&window.stop(),window.location.replace(e.href)},10)}function tf(){if(Bn||typeof window=="undefined"||typeof document=="undefined")return;let t=Je(),e=zt(),n=!ia(),r=!!(t.tagadaClientEnv||t.tagadaClientBaseUrl);if(!e&&!n&&!r)return;let s=document.createElement("div");s.id="tgd-preview-indicator",s.style.cssText='\n position: fixed;\n bottom: 16px;\n right: 16px;\n z-index: 999999;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n ';let o=document.createElement("div");o.style.cssText="\n background: ".concat(e?"#ff9500":"#007aff",";\n color: white;\n padding: 8px 12px;\n border-radius: 8px;\n font-size: 13px;\n font-weight: 600;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n cursor: pointer;\n transition: all 0.2s ease;\n display: flex;\n align-items: center;\n gap: 6px;\n "),o.innerHTML='\n <span style="font-size: 16px;">\u{1F50D}</span>\n <span>'.concat(e?"Preview Mode":"Dev Mode","</span>\n ");let i=document.createElement("div");i.style.cssText="\n position: absolute;\n bottom: calc(100% + 8px);\n right: 0;\n background: white;\n border: 1px solid #e5e5e5;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 12px;\n min-width: 250px;\n font-size: 12px;\n line-height: 1.5;\n display: none;\n ",i.style.paddingTop="20px";let a=document.createElement("div");a.style.cssText="\n position: absolute;\n bottom: 100%;\n left: 0;\n right: 0;\n height: 8px;\n display: none;\n ";let l='<div style="margin-bottom: 8px; font-weight: 600; color: #1d1d1f;">Current Environment</div>';l+='<div style="display: flex; flex-direction: column; gap: 6px;">',e&&(l+='\n <div style="display: flex; justify-content: space-between; color: #86868b;">\n <span>Draft Mode:</span>\n <span style="color: #ff9500; font-weight: 600;">ON</span>\n </div>\n '),n&&(l+='\n <div style="display: flex; justify-content: space-between; color: #86868b;">\n <span>Tracking:</span>\n <span style="color: #ff3b30; font-weight: 600;">DISABLED</span>\n </div>\n '),t.funnelEnv&&(l+='\n <div style="display: flex; justify-content: space-between; color: #86868b;">\n <span>Funnel Env:</span>\n <span style="color: #1d1d1f; font-weight: 600; font-family: monospace; font-size: 11px;">\n '.concat(t.funnelEnv,"\n </span>\n </div>\n ")),t.tagadaClientEnv&&(l+='\n <div style="display: flex; justify-content: space-between; color: #86868b;">\n <span>API Env:</span>\n <span style="color: #1d1d1f; font-weight: 600; font-family: monospace; font-size: 11px;">\n '.concat(t.tagadaClientEnv,"\n </span>\n </div>\n ")),t.tagadaClientBaseUrl&&(l+='\n <div style="color: #86868b;">\n <div style="margin-bottom: 4px;">API URL:</div>\n <div style="color: #1d1d1f; font-weight: 600; font-family: monospace; font-size: 10px; word-break: break-all; background: #f5f5f7; padding: 4px 6px; border-radius: 4px;">\n '.concat(t.tagadaClientBaseUrl,"\n </div>\n </div>\n ")),t.funnelId&&(l+='\n <div style="color: #86868b; margin-top: 4px; padding-top: 8px; border-top: 1px solid #e5e5e5;">\n <div style="margin-bottom: 4px;">Funnel ID:</div>\n <div style="color: #1d1d1f; font-family: monospace; font-size: 10px; word-break: break-all; background: #f5f5f7; padding: 4px 6px; border-radius: 4px;">\n '.concat(t.funnelId,"\n </div>\n </div>\n ")),l+="</div>",l+='\n <div style="margin-top: 12px; padding-top: 8px; border-top: 1px solid #e5e5e5; font-size: 11px; color: #86868b; text-align: center;">\n Add <code style="background: #f5f5f7; padding: 2px 4px; border-radius: 3px;">?forceReset=true</code> to reset\n </div>\n ',l+='\n <div style="margin-top: 12px; padding-top: 8px; border-top: 1px solid #e5e5e5;">\n <button id="tgd-leave-preview" style="\n background: #ff3b30;\n color: white;\n border: none;\n border-radius: 6px;\n padding: 10px 12px;\n font-size: 13px;\n font-weight: 600;\n cursor: pointer;\n transition: opacity 0.2s;\n width: 100%;\n ">\n \u{1F6AA} Leave Preview Mode\n </button>\n </div>\n ',i.innerHTML=l;let c=!1,u=()=>{c=!0,i.style.display="block",a.style.display="block"},f=()=>{c=!1,setTimeout(()=>{c||(i.style.display="none",a.style.display="none")},100)};o.addEventListener("mouseenter",u),o.addEventListener("mouseleave",f),a.addEventListener("mouseenter",u),a.addEventListener("mouseleave",f),i.addEventListener("mouseenter",u),i.addEventListener("mouseleave",f);let g=i.querySelector("#tgd-leave-preview");g&&(g.addEventListener("mouseenter",()=>{g.style.opacity="0.8"}),g.addEventListener("mouseleave",()=>{g.style.opacity="1"}),g.addEventListener("click",m=>{m.stopPropagation(),ef()})),s.appendChild(o),s.appendChild(a),s.appendChild(i),document.body.appendChild(s),ut=s,Bn=!0}function nf(){ut&&ut.parentNode&&(ut.parentNode.removeChild(ut),ut=null,Bn=!1)}function rf(){return Bn}var ut,Bn,ca=Oe(()=>{"use strict";Ln();ct();Dn();ut=null,Bn=!1});var ba={};st(ba,{FunnelClient:()=>Gt,TrackingProvider:()=>fa,findMethod:()=>ma,getAssignedOrderBumpOfferIds:()=>gf,getAssignedPaymentFlowId:()=>Wt,getAssignedPixels:()=>pf,getAssignedResources:()=>ya,getAssignedScripts:()=>ff,getAssignedStaticResources:()=>df,getAssignedStepConfig:()=>be,getAssignedUpsellOfferIds:()=>mf,getEnabledMethods:()=>pa,getExpressMethods:()=>ga,getExpressMethodsByProcessor:()=>sf,getLocalFunnelConfig:()=>ha,isMethodEnabled:()=>of,loadLocalFunnelConfig:()=>lf});function pa(t){return t?Object.values(t).filter(e=>e.enabled):[]}function ga(t){return pa(t).filter(e=>e.express)}function sf(t){let e={};for(let n of ga(t)){let r=n.processorId||n.integrationId||n.provider;e[r]||(e[r]=[]),e[r].push(n)}return e}function ma(t,e){if(t){for(let n of Object.values(t))if(n.method===e&&n.enabled)return n}}function of(t,e){return!!ma(t,e)}function af(){if(typeof window!="undefined"){if(window.__TGD_FUNNEL_ID__)return window.__TGD_FUNNEL_ID__;if(typeof document!="undefined"){let t=document.querySelector('meta[name="x-funnel-id"]');return(t==null?void 0:t.getAttribute("content"))||void 0}}}function Un(){if(typeof window!="undefined"){if(window.__TGD_FUNNEL_VARIANT_ID__)return window.__TGD_FUNNEL_VARIANT_ID__;if(typeof document!="undefined"){let t=document.querySelector('meta[name="x-funnel-variant-id"]');return(t==null?void 0:t.getAttribute("content"))||void 0}}}function Vt(){if(typeof window!="undefined"){if(window.__TGD_FUNNEL_STEP_ID__)return window.__TGD_FUNNEL_STEP_ID__;if(typeof document!="undefined"){let t=document.querySelector('meta[name="x-funnel-step-id"]');return(t==null?void 0:t.getAttribute("content"))||void 0}}}function ua(t){if(!t||typeof t!="string")return;let e=t.trim();if(!e)return;let n=[()=>JSON.parse(e),()=>JSON.parse(decodeURIComponent(e)),()=>JSON.parse(decodeURIComponent(decodeURIComponent(e)))];for(let r of n)try{let s=r();if(s&&typeof s=="object")return s}catch(s){}typeof console!="undefined"&&console.warn("[SDK] Failed to parse stepConfig:",e.substring(0,100))}function cf(){if(typeof window=="undefined")return!1;let t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t.endsWith(".localhost")&&!t.includes(".cdn.")}async function lf(){if(!cf())return null;if(ye!==void 0)return ye;if(As)return await new Promise(t=>setTimeout(t,100)),ye!=null?ye:null;As=!0;try{console.log("\u{1F6E0}\uFE0F [SDK] Loading local funnel config from /config/funnel.local.json...");let t=await fetch("/config/funnel.local.json");if(!t.ok)return console.log("\u{1F6E0}\uFE0F [SDK] funnel.local.json not found (this is fine in production)"),ye=null,null;let e=await t.json();return console.log("\u{1F6E0}\uFE0F [SDK] \u2705 Loaded local funnel config:",e),ye=e,e}catch(t){return console.log("\u{1F6E0}\uFE0F [SDK] funnel.local.json not available:",t),ye=null,null}finally{As=!1}}function ha(){return ye!=null?ye:null}function uf(t){let e=w(w({},t.staticResources),t.resources);return{payment:t.paymentFlowId?{paymentFlowId:t.paymentFlowId}:void 0,resources:Object.keys(e).length>0?e:void 0,scripts:t.scripts,pixels:t.pixels,orderBumps:t.orderBumps,upsellOffers:t.upsellOffers}}function be(){if(typeof window=="undefined")return;let t=ha();if(t)return console.log("\u{1F6E0}\uFE0F [SDK] Using local funnel.local.json (overrides injected)"),uf(t);let e=window.__TGD_STEP_CONFIG__;if(e){let n=ua(e);if(n)return n}if(typeof document!="undefined"){let n=document.querySelector('meta[name="x-step-config"]'),r=n==null?void 0:n.getAttribute("content");if(r){let s=ua(r);if(s)return s}}}function Wt(){var n,r;let t=be(),e=(n=t==null?void 0:t.paymentSetupConfig)==null?void 0:n.card;if(e!=null&&e.paymentFlowId)return e.paymentFlowId;if((r=t==null?void 0:t.payment)!=null&&r.paymentFlowId)return t.payment.paymentFlowId;if(typeof window!="undefined"){if(window.__TGD_PAYMENT_FLOW_ID__)return window.__TGD_PAYMENT_FLOW_ID__;if(typeof document!="undefined"){let s=document.querySelector('meta[name="x-payment-flow-id"]');return(s==null?void 0:s.getAttribute("content"))||void 0}}}function ya(){let t=be(),e=t==null?void 0:t.staticResources,n=t==null?void 0:t.resources;if(!(!e&&!n))return w(w({},e),n)}function df(){return ya()}function ff(t){let e=be();if(!(e!=null&&e.scripts))return;let n=e.scripts.filter(r=>r.enabled);return t&&(n=n.filter(r=>r.position===t||!r.position&&t==="head-end")),n.length>0?n:void 0}function da(t){let e="containerId"in t?"containerId":"pixelId",n=t[e];if(!n||!n.includes(";")&&!n.includes(","))return[t];let r=n.split(/[;,]/).map(s=>s.trim()).filter(s=>s.length>0);return r.length<=1?[t]:r.map(s=>N(w({},t),{[e]:s}))}function pf(){let t=be(),e=t==null?void 0:t.pixels;if(!e||typeof e!="object")return;let n={};for(let[r,s]of Object.entries(e))s&&(Array.isArray(s)?n[r]=s.flatMap(o=>da(o)):typeof s=="object"&&(n[r]=da(s)));return Object.keys(n).length>0?n:void 0}function gf(){let t=be();if(t!=null&&t.orderBumps&&t.orderBumps.mode==="custom")return t.orderBumps.enabledOfferIds}function mf(){let t=be();if(t!=null&&t.upsellOffers&&t.upsellOffers.mode==="custom")return t.upsellOffers.enabledUpsellIds}var la,fa,ye,As,Gt,dt=Oe(()=>{"use strict";_n();Ss();Es();Ln();Dn();la=()=>Promise.resolve().then(()=>(ca(),aa)).then(t=>t.injectPreviewModeIndicator()),fa=(o=>(o.FACEBOOK="facebook",o.TIKTOK="tiktok",o.SNAPCHAT="snapchat",o.PINTEREST="pinterest",o.GTM="gtm",o))(fa||{});As=!1;Gt=class{constructor(e){this.eventDispatcher=new it;this.isInitializing=!1;this.initializationAttempted=!1;this.config=e,this.resource=new In(e.apiClient),this.state={context:null,isLoading:!1,isInitialized:!1,isNavigating:!1,error:null,sessionError:null}}setConfig(e){this.config=w(w({},this.config),e)}subscribe(e){return this.eventDispatcher.subscribe(e)}getState(){return this.state}getDetectedSessionId(){var r;if((r=this.state.context)!=null&&r.sessionId)return this.state.context.sessionId;if(typeof window=="undefined")return null;let n=new URLSearchParams(window.location.search).get("funnelSessionId");return n||kn()||null}resetInitialization(){this.initializationAttempted=!1,this.isInitializing=!1,this.updateState({context:null,isInitialized:!1})}async autoInitialize(e,n,r){if(this.state.context)return this.state.context;if(this.isInitializing||this.initializationAttempted)return null;this.initializationAttempted=!0,this.isInitializing=!0,this.updateState({isLoading:!0,error:null});try{let s=this.getDetectedSessionId(),a=new URLSearchParams(typeof window!="undefined"?window.location.search:"").get("funnelId")||r,l=af(),c=Un(),u=Vt(),f=Je(),g=this.config.funnelId||l||a,m=this.config.stepId||u,d=typeof window!="undefined"?new URLSearchParams(window.location.search):null,h=d==null?void 0:d.get("funnelEnv");this.config.debugMode&&console.log("\u{1F680} [FunnelClient] Auto-initializing...",{existingSessionId:s,effectiveFunnelId:g,funnelVariantId:c,funnelStepId:m,draft:f.draft,funnelTracking:f.funnelTracking,funnelEnv:h,tagadaClientEnv:f.tagadaClientEnv,tagadaClientBaseUrl:f.tagadaClientBaseUrl,source:{funnelId:this.config.funnelId?"config":l?"injected":a?"url/prop":"none",stepId:this.config.stepId?"config":u?"injected":"none"}});let p=await this.resource.initialize({cmsSession:{customerId:e.customerId,sessionId:e.sessionId,storeId:n.id,accountId:n.accountId},funnelId:g,existingSessionId:s||void 0,currentUrl:typeof window!="undefined"?window.location.href:void 0,funnelVariantId:c,funnelStepId:m,draft:f.draft,funnelTracking:f.funnelTracking,funnelEnv:h||void 0,tagadaClientEnv:f.tagadaClientEnv,tagadaClientBaseUrl:f.tagadaClientBaseUrl,currency:f.currency,locale:f.locale});if(p.success&&p.context){let S=this.enrichContext(p.context);return this.handleSessionSuccess(S),la(),S}else throw new Error(p.error||"Failed to initialize funnel session")}catch(s){let o=s instanceof Error?s:new Error(String(s));throw this.updateState({error:o,isLoading:!1}),this.config.debugMode&&console.error("\u274C [FunnelClient] Init failed:",o),o}finally{this.isInitializing=!1}}async initialize(e,n,r,s){this.updateState({isLoading:!0,error:null});try{let o=Un(),i=Vt();this.config.debugMode&&(o&&console.log("\u{1F3AF} [FunnelClient] Detected A/B test variant:",o),i&&console.log("\u{1F3AF} [FunnelClient] Detected step ID:",i));let a=await this.resource.initialize({cmsSession:{customerId:e.customerId,sessionId:e.sessionId,storeId:n.id,accountId:n.accountId},funnelId:r,entryStepId:s,currentUrl:typeof window!="undefined"?window.location.href:void 0,funnelVariantId:o,funnelStepId:i});if(a.success&&a.context){let l=this.enrichContext(a.context);return this.handleSessionSuccess(l),la(),l}else throw new Error(a.error||"Failed to initialize")}catch(o){let i=o instanceof Error?o:new Error(String(o));throw this.updateState({error:i,isLoading:!1}),i}}async navigate(e,n){var r,s,o,i,a,l;if(n!=null&&n.waitForSession&&!((r=this.state.context)!=null&&r.sessionId)){this.config.debugMode&&console.log("\u23F3 [FunnelClient] Waiting for session before navigation...");let c=5e3,u=Date.now();for(;!((s=this.state.context)!=null&&s.sessionId)&&Date.now()-u<c;)await new Promise(f=>setTimeout(f,100));(o=this.state.context)!=null&&o.sessionId&&this.config.debugMode&&console.log("\u2705 [FunnelClient] Session ready, proceeding with navigation")}if(!((i=this.state.context)!=null&&i.sessionId))throw new Error("No active session");this.updateState({isNavigating:!0,isLoading:!0});try{let c=Un(),u=Vt(),f=typeof window!="undefined"?window.location.href:void 0;!u&&this.config.stepId&&(u=this.config.stepId,this.config.debugMode&&console.log("\u{1F50D} [FunnelClient.navigate] Using stepId from config (no injection):",u)),!c&&this.config.variantId&&(c=this.config.variantId,this.config.debugMode&&console.log("\u{1F50D} [FunnelClient.navigate] Using variantId from config (no injection):",c)),this.config.debugMode&&console.log("\u{1F50D} [FunnelClient.navigate] Sending to backend:",{sessionId:this.state.context.sessionId,currentUrl:f,funnelStepId:u||"(not found)",funnelVariantId:c||"(not found)",hasInjectedStepId:!!Vt(),hasInjectedVariantId:!!Un(),usedConfigFallback:!Vt()&&!!this.config.stepId,customerTags:(n==null?void 0:n.customerTags)||"(none)",deviceId:(n==null?void 0:n.deviceId)||"(none)"});let g=(n==null?void 0:n.fireAndForget)||!1,m=await this.resource.navigate({sessionId:this.state.context.sessionId,event:e,currentUrl:f,funnelStepId:u,funnelVariantId:c,fireAndForget:g,customerTags:n==null?void 0:n.customerTags,deviceId:n==null?void 0:n.deviceId});if(!m.success||!m.result)throw new Error(m.error||"Navigation failed");let d=m.result;if(d.queued)return this.updateState({isNavigating:!1,isLoading:!1}),d.sessionId&&d.sessionId!==((a=this.state.context)==null?void 0:a.sessionId)&&(this.config.debugMode&&console.log("\u{1F525} [FunnelClient] Session ID updated: ".concat((l=this.state.context)==null?void 0:l.sessionId," \u2192 ").concat(d.sessionId)),this.state.context&&(this.state.context.sessionId=d.sessionId)),this.config.debugMode&&console.log("\u{1F525} [FunnelClient] Navigation queued (fire-and-forget mode)"),d;let h=(n==null?void 0:n.autoRedirect)!==void 0?n.autoRedirect:this.config.autoRedirect!==!1;return this.updateState({isNavigating:!1,isLoading:!1}),h&&(d!=null&&d.url)&&typeof window!="undefined"&&(this.config.debugMode&&console.log("\u{1F680} [FunnelClient] Auto-redirecting to:",d.url,"(skipped session refresh - next page will initialize)"),window.location.href=d.url),d}catch(c){let u=c instanceof Error?c:new Error(String(c));throw this.updateState({error:u,isNavigating:!1,isLoading:!1}),u}}async goToStep(e,n){return this.navigate({type:"direct_navigation",data:{targetStepId:e}},n)}async refreshSession(){var e;if((e=this.state.context)!=null&&e.sessionId)try{let n=await this.resource.getSession(this.state.context.sessionId);if(n.success&&n.context){let r=this.enrichContext(n.context);return this.updateState({context:r,sessionError:null}),r}}catch(n){this.updateState({sessionError:n instanceof Error?n:new Error(String(n))})}}async updateContext(e){var n;if(!((n=this.state.context)!=null&&n.sessionId))throw new Error("No active session");this.updateState({isLoading:!0});try{let r=await this.resource.updateContext(this.state.context.sessionId,{contextUpdates:e});if(r.success)await this.refreshSession();else throw new Error(r.error||"Failed to update context")}finally{this.updateState({isLoading:!1})}}async endSession(){var e;if((e=this.state.context)!=null&&e.sessionId)try{await this.resource.endSession(this.state.context.sessionId)}finally{this.state.context=null,this.updateState({context:null,isInitialized:!1})}}updateState(e){this.state=w(w({},this.state),e),this.eventDispatcher.notify(this.state)}handleSessionSuccess(e){Ts(e.sessionId),this.updateState({context:e,isLoading:!1,isInitialized:!0,error:null,sessionError:null})}enrichContext(e){var i,a;if((((i=this.config.environment)==null?void 0:i.environment)||$t())!=="local")return e;let r=((a=this.config.pluginConfig)==null?void 0:a.staticResources)||{};if(Object.keys(r).length===0)return e;let s=e.static||{};return Object.keys(r).every(l=>s[l]===r[l])&&Object.keys(s).length===Object.keys(r).length?e:N(w({},e),{static:w(w({},r),s)})}}});var Ac=R(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.PathError=Te.TokenData=void 0;Te.parse=mo;Te.compile=ig;Te.match=cg;Te.pathToRegexp=Rc;Te.stringify=dg;var fo="/",po=t=>t,Cc=new RegExp("^[$_\\p{ID_Start}]$","u"),go=new RegExp("^[$\\u200c\\u200d\\p{ID_Continue}]$","u"),sg={"{":"{","}":"}","(":"(",")":")","[":"[","]":"]","+":"+","?":"?","!":"!"};function og(t){return t.replace(/[{}()\[\]+?!:*\\]/g,"\\$&")}function Ne(t){return t.replace(/[.+*?^${}()[\]|/\\]/g,"\\$&")}var lr=class{constructor(e,n){this.tokens=e,this.originalPath=n}};Te.TokenData=lr;var Qe=class extends TypeError{constructor(e,n){let r=e;n&&(r+=": ".concat(n)),r+="; visit https://git.new/pathToRegexpError for info",super(r),this.originalPath=n}};Te.PathError=Qe;function mo(t,e={}){let{encodePath:n=po}=e,r=[...t],s=[],o=0,i=0;function a(){let c="";if(Cc.test(r[o]))do c+=r[o++];while(go.test(r[o]));else if(r[o]==='"'){let u=o;for(;o++<r.length;){if(r[o]==='"'){o++,u=0;break}r[o]==="\\"&&o++,c+=r[o]}if(u)throw new Qe("Unterminated quote at index ".concat(u),t)}if(!c)throw new Qe("Missing parameter name at index ".concat(o),t);return c}for(;o<r.length;){let c=r[o],u=sg[c];u?s.push({type:u,index:o++,value:c}):c==="\\"?s.push({type:"escape",index:o++,value:r[o++]}):c===":"?s.push({type:"param",index:o++,value:a()}):c==="*"?s.push({type:"wildcard",index:o++,value:a()}):s.push({type:"char",index:o++,value:c})}s.push({type:"end",index:o,value:""});function l(c){let u=[];for(;;){let f=s[i++];if(f.type===c)break;if(f.type==="char"||f.type==="escape"){let g=f.value,m=s[i];for(;m.type==="char"||m.type==="escape";)g+=m.value,m=s[++i];u.push({type:"text",value:n(g)});continue}if(f.type==="param"||f.type==="wildcard"){u.push({type:f.type,name:f.value});continue}if(f.type==="{"){u.push({type:"group",tokens:l("}")});continue}throw new Qe("Unexpected ".concat(f.type," at index ").concat(f.index,", expected ").concat(c),t)}return u}return new lr(l("end"),t)}function ig(t,e={}){let{encode:n=encodeURIComponent,delimiter:r=fo}=e,s=typeof t=="object"?t:mo(t,e),o=Tc(s.tokens,r,n);return function(a={}){let[l,...c]=o(a);if(c.length)throw new TypeError("Missing parameters: ".concat(c.join(", ")));return l}}function Tc(t,e,n){let r=t.map(s=>ag(s,e,n));return s=>{let o=[""];for(let i of r){let[a,...l]=i(s);o[0]+=a,o.push(...l)}return o}}function ag(t,e,n){if(t.type==="text")return()=>[t.value];if(t.type==="group"){let s=Tc(t.tokens,e,n);return o=>{let[i,...a]=s(o);return a.length?[""]:[i]}}let r=n||po;return t.type==="wildcard"&&n!==!1?s=>{let o=s[t.name];if(o==null)return["",t.name];if(!Array.isArray(o)||o.length===0)throw new TypeError('Expected "'.concat(t.name,'" to be a non-empty array'));return[o.map((i,a)=>{if(typeof i!="string")throw new TypeError('Expected "'.concat(t.name,"/").concat(a,'" to be a string'));return r(i)}).join(e)]}:s=>{let o=s[t.name];if(o==null)return["",t.name];if(typeof o!="string")throw new TypeError('Expected "'.concat(t.name,'" to be a string'));return[r(o)]}}function cg(t,e={}){let{decode:n=decodeURIComponent,delimiter:r=fo}=e,{regexp:s,keys:o}=Rc(t,e),i=o.map(a=>n===!1?po:a.type==="param"?n:l=>l.split(r).map(n));return function(l){let c=s.exec(l);if(!c)return!1;let u=c[0],f=Object.create(null);for(let g=1;g<c.length;g++){if(c[g]===void 0)continue;let m=o[g-1],d=i[g-1];f[m.name]=d(c[g])}return{path:u,params:f}}}function Rc(t,e={}){let{delimiter:n=fo,end:r=!0,sensitive:s=!1,trailing:o=!0}=e,i=[],a=s?"":"i",l=[];for(let f of vc(t,[])){let g=typeof f=="object"?f:mo(f,e);for(let m of cr(g.tokens,0,[]))l.push(lg(m,n,i,g.originalPath))}let c="^(?:".concat(l.join("|"),")");return o&&(c+="(?:".concat(Ne(n),"$)?")),c+=r?"$":"(?=".concat(Ne(n),"|$)"),{regexp:new RegExp(c,a),keys:i}}function vc(t,e){if(Array.isArray(t))for(let n of t)vc(n,e);else e.push(t);return e}function*cr(t,e,n){if(e===t.length)return yield n;let r=t[e];if(r.type==="group")for(let s of cr(r.tokens,0,n.slice()))yield*Me(cr(t,e+1,s));else n.push(r);yield*Me(cr(t,e+1,n))}function lg(t,e,n,r){let s="",o="",i=!0;for(let a of t){if(a.type==="text"){s+=Ne(a.value),o+=a.value,i||(i=a.value.includes(e));continue}if(a.type==="param"||a.type==="wildcard"){if(!i&&!o)throw new Qe('Missing text before "'.concat(a.name,'" ').concat(a.type),r);a.type==="param"?s+="(".concat(ug(e,i?"":o),"+)"):s+="([\\s\\S]+)",n.push(a),o="",i=!1;continue}}return s}function ug(t,e){return e.length<2?t.length<2?"[^".concat(Ne(t+e),"]"):"(?:(?!".concat(Ne(t),")[^").concat(Ne(e),"])"):t.length<2?"(?:(?!".concat(Ne(e),")[^").concat(Ne(t),"])"):"(?:(?!".concat(Ne(e),"|").concat(Ne(t),")[\\s\\S])")}function Pc(t){let e="",n=0;function r(s){return fg(s)&&pg(t[n])?s:JSON.stringify(s)}for(;n<t.length;){let s=t[n++];if(s.type==="text"){e+=og(s.value);continue}if(s.type==="group"){e+="{".concat(Pc(s.tokens),"}");continue}if(s.type==="param"){e+=":".concat(r(s.name));continue}if(s.type==="wildcard"){e+="*".concat(r(s.name));continue}throw new TypeError("Unknown token type: ".concat(s.type))}return e}function dg(t){return Pc(t.tokens)}function fg(t){let[e,...n]=t;return Cc.test(e)&&n.every(r=>go.test(r))}function pg(t){return t&&t.type==="text"?!go.test(t.value[0]):!0}});var fr=R(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.WEB_ELEMENTS_VERSION=k.USER_AGENT_HEADER=k.USER_AGENT_CLIENT=k.MERGE_CONTENT_TYPE=k.DEFAULT_ELEMENTS_BASE_URL=k.DEFAULT_BASE_URL=k.DD_TOKEN=k.DD_GIT_SHA=k.CONTENT_TYPE_HEADER=k.CLIENT_USER_AGENT_HEADER=k.CLIENT_BASE_PATHS=k.CF_RAY_HEADER=k.BT_TRACE_ID_HEADER=k.BT_IDEMPOTENCY_KEY_HEADER=k.BT_EXPOSE_PROXY_RESPONSE_HEADER=k.BROWSER_LIST=k.API_KEY_HEADER=void 0;var yg="1.7.2";k.WEB_ELEMENTS_VERSION=yg;var bg="BT-API-KEY";k.API_KEY_HEADER=bg;var wg="bt-trace-id";k.BT_TRACE_ID_HEADER=wg;var Sg="cf-ray";k.CF_RAY_HEADER=Sg;var Eg="bt-idempotency-key";k.BT_IDEMPOTENCY_KEY_HEADER=Eg;var Cg="BT-EXPOSE-RAW-PROXY-RESPONSE";k.BT_EXPOSE_PROXY_RESPONSE_HEADER=Cg;var Tg="Content-Type";k.CONTENT_TYPE_HEADER=Tg;var Rg="application/merge-patch+json";k.MERGE_CONTENT_TYPE=Rg;var vg="User-Agent";k.USER_AGENT_HEADER=vg;var Pg="BT-CLIENT-USER-AGENT";k.CLIENT_USER_AGENT_HEADER=Pg;var Ag="BasisTheoryJS";k.USER_AGENT_CLIENT=Ag;var _g="https://api.basistheory.com";k.DEFAULT_BASE_URL=_g;var Ig="https://js.basistheory.com/hosted-elements";k.DEFAULT_ELEMENTS_BASE_URL=Ig;var xg="pub5f53501515584007899577554c4aeda6";k.DD_TOKEN=xg;var Og="b862d8e634020f77c61023ffeee4f0e01c36e871";k.DD_GIT_SHA=Og;var kg={tokens:"tokens",tokenize:"tokenize",applications:"applications",applicationKeys:"applications",applicationTemplates:"application-templates",tenants:"tenants/self",logs:"logs",reactorFormulas:"reactor-formulas",reactors:"reactors",permissions:"permissions",proxies:"proxies",proxy:"proxy",sessions:"sessions",threeds:"3ds",tokenIntents:"token-intents"};k.CLIENT_BASE_PATHS=kg;var Dg=[{browserName:"Firefox",browserUA:"Firefox"},{browserName:"SamsungBrowser",browserUA:"SamsungBrowser"},{browserName:"Opera",browserUA:"Opera"},{browserName:"Opera",browserUA:"OPR"},{browserName:"Microsoft Internet Explorer",browserUA:"Trident"},{browserName:"Microsoft Edge (Legacy)",browserUA:"Edge"},{browserName:"Microsoft Edge (Chromium)",browserUA:"Edg"},{browserName:"Google Chrome/Chromium",browserUA:"Chrome"},{browserName:"Safari",browserUA:"Safari"}];k.BROWSER_LIST=Dg});var ko=R((LR,yl)=>{"use strict";function Wc(t,e){return function(){return t.apply(e,arguments)}}var{toString:Ng}=Object.prototype,{getPrototypeOf:Po}=Object,{iterator:wr,toStringTag:Jc}=Symbol,Sr=(t=>e=>{let n=Ng.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ve=t=>(t=t.toLowerCase(),e=>Sr(e)===t),Er=t=>e=>typeof e===t,{isArray:Dt}=Array,xt=Er("undefined");function mn(t){return t!==null&&!xt(t)&&t.constructor!==null&&!xt(t.constructor)&&ae(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}var Yc=ve("ArrayBuffer");function Lg(t){let e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Yc(t.buffer),e}var Bg=Er("string"),ae=Er("function"),Xc=Er("number"),hn=t=>t!==null&&typeof t=="object",Ug=t=>t===!0||t===!1,gr=t=>{if(Sr(t)!=="object")return!1;let e=Po(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Jc in t)&&!(wr in t)},Mg=t=>{if(!hn(t)||mn(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch(e){return!1}},Fg=ve("Date"),$g=ve("File"),qg=ve("Blob"),jg=ve("FileList"),Hg=t=>hn(t)&&ae(t.pipe),Kg=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||ae(t.append)&&((e=Sr(t))==="formdata"||e==="object"&&ae(t.toString)&&t.toString()==="[object FormData]"))},zg=ve("URLSearchParams"),[Vg,Gg,Wg,Jg]=["ReadableStream","Request","Response","Headers"].map(ve),Yg=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function yn(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t=="undefined")return;let r,s;if(typeof t!="object"&&(t=[t]),Dt(t))for(r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else{if(mn(t))return;let o=n?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length,a;for(r=0;r<i;r++)a=o[r],e.call(null,t[a],a,t)}}function Zc(t,e){if(mn(t))return null;e=e.toLowerCase();let n=Object.keys(t),r=n.length,s;for(;r-- >0;)if(s=n[r],e===s.toLowerCase())return s;return null}var et=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,Qc=t=>!xt(t)&&t!==et;function So(){let{caseless:t,skipUndefined:e}=Qc(this)&&this||{},n={},r=(s,o)=>{let i=t&&Zc(n,o)||o;gr(n[i])&&gr(s)?n[i]=So(n[i],s):gr(s)?n[i]=So({},s):Dt(s)?n[i]=s.slice():(!e||!xt(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&yn(arguments[s],r);return n}var Xg=(t,e,n,{allOwnKeys:r}={})=>(yn(e,(s,o)=>{n&&ae(s)?t[o]=Wc(s,n):t[o]=s},{allOwnKeys:r}),t),Zg=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Qg=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},em=(t,e,n,r)=>{let s,o,i,a={};if(e=e||{},t==null)return e;do{for(s=Object.getOwnPropertyNames(t),o=s.length;o-- >0;)i=s[o],(!r||r(i,t,e))&&!a[i]&&(e[i]=t[i],a[i]=!0);t=n!==!1&&Po(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},tm=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;let r=t.indexOf(e,n);return r!==-1&&r===n},nm=t=>{if(!t)return null;if(Dt(t))return t;let e=t.length;if(!Xc(e))return null;let n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},rm=(t=>e=>t&&e instanceof t)(typeof Uint8Array!="undefined"&&Po(Uint8Array)),sm=(t,e)=>{let r=(t&&t[wr]).call(t),s;for(;(s=r.next())&&!s.done;){let o=s.value;e.call(t,o[0],o[1])}},om=(t,e)=>{let n,r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},im=ve("HTMLFormElement"),am=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),kc=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),cm=ve("RegExp"),el=(t,e)=>{let n=Object.getOwnPropertyDescriptors(t),r={};yn(n,(s,o)=>{let i;(i=e(s,o,t))!==!1&&(r[o]=i||s)}),Object.defineProperties(t,r)},lm=t=>{el(t,(e,n)=>{if(ae(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;let r=t[n];if(ae(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},um=(t,e)=>{let n={},r=s=>{s.forEach(o=>{n[o]=!0})};return Dt(t)?r(t):r(String(t).split(e)),n},dm=()=>{},fm=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function pm(t){return!!(t&&ae(t.append)&&t[Jc]==="FormData"&&t[wr])}var gm=t=>{let e=new Array(10),n=(r,s)=>{if(hn(r)){if(e.indexOf(r)>=0)return;if(mn(r))return r;if(!("toJSON"in r)){e[s]=r;let o=Dt(r)?[]:{};return yn(r,(i,a)=>{let l=n(i,s+1);!xt(l)&&(o[a]=l)}),e[s]=void 0,o}}return r};return n(t,0)},mm=ve("AsyncFunction"),hm=t=>t&&(hn(t)||ae(t))&&ae(t.then)&&ae(t.catch),tl=((t,e)=>t?setImmediate:e?((n,r)=>(et.addEventListener("message",({source:s,data:o})=>{s===et&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),et.postMessage(n,"*")}))("axios@".concat(Math.random()),[]):n=>setTimeout(n))(typeof setImmediate=="function",ae(et.postMessage)),ym=typeof queueMicrotask!="undefined"?queueMicrotask.bind(et):typeof process!="undefined"&&process.nextTick||tl,bm=t=>t!=null&&ae(t[wr]),b={isArray:Dt,isArrayBuffer:Yc,isBuffer:mn,isFormData:Kg,isArrayBufferView:Lg,isString:Bg,isNumber:Xc,isBoolean:Ug,isObject:hn,isPlainObject:gr,isEmptyObject:Mg,isReadableStream:Vg,isRequest:Gg,isResponse:Wg,isHeaders:Jg,isUndefined:xt,isDate:Fg,isFile:$g,isBlob:qg,isRegExp:cm,isFunction:ae,isStream:Hg,isURLSearchParams:zg,isTypedArray:rm,isFileList:jg,forEach:yn,merge:So,extend:Xg,trim:Yg,stripBOM:Zg,inherits:Qg,toFlatObject:em,kindOf:Sr,kindOfTest:ve,endsWith:tm,toArray:nm,forEachEntry:sm,matchAll:om,isHTMLForm:im,hasOwnProperty:kc,hasOwnProp:kc,reduceDescriptors:el,freezeMethods:lm,toObjectSet:um,toCamelCase:am,noop:dm,toFiniteNumber:fm,findKey:Zc,global:et,isContextDefined:Qc,isSpecCompliantForm:pm,toJSONObject:gm,isAsyncFn:mm,isThenable:hm,setImmediate:tl,asap:ym,isIterable:bm};function O(t,e,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}b.inherits(O,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:b.toJSONObject(this.config),code:this.code,status:this.status}}});var nl=O.prototype,rl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{rl[t]={value:t}});Object.defineProperties(O,rl);Object.defineProperty(nl,"isAxiosError",{value:!0});O.from=(t,e,n,r,s,o)=>{let i=Object.create(nl);b.toFlatObject(t,i,function(u){return u!==Error.prototype},c=>c!=="isAxiosError");let a=t&&t.message?t.message:"Error",l=e==null&&t?t.code:e;return O.call(i,a,l,n,r,s),t&&i.cause==null&&Object.defineProperty(i,"cause",{value:t,configurable:!0}),i.name=t&&t.name||"Error",o&&Object.assign(i,o),i};var wm=null;function Eo(t){return b.isPlainObject(t)||b.isArray(t)}function sl(t){return b.endsWith(t,"[]")?t.slice(0,-2):t}function Dc(t,e,n){return t?t.concat(e).map(function(s,o){return s=sl(s),!n&&o?"["+s+"]":s}).join(n?".":""):e}function Sm(t){return b.isArray(t)&&!t.some(Eo)}var Em=b.toFlatObject(b,{},null,function(e){return/^is[A-Z]/.test(e)});function Cr(t,e,n){if(!b.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=b.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,p){return!b.isUndefined(p[h])});let r=n.metaTokens,s=n.visitor||u,o=n.dots,i=n.indexes,l=(n.Blob||typeof Blob!="undefined"&&Blob)&&b.isSpecCompliantForm(e);if(!b.isFunction(s))throw new TypeError("visitor must be a function");function c(d){if(d===null)return"";if(b.isDate(d))return d.toISOString();if(b.isBoolean(d))return d.toString();if(!l&&b.isBlob(d))throw new O("Blob is not supported. Use a Buffer instead.");return b.isArrayBuffer(d)||b.isTypedArray(d)?l&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function u(d,h,p){let S=d;if(d&&!p&&typeof d=="object"){if(b.endsWith(h,"{}"))h=r?h:h.slice(0,-2),d=JSON.stringify(d);else if(b.isArray(d)&&Sm(d)||(b.isFileList(d)||b.endsWith(h,"[]"))&&(S=b.toArray(d)))return h=sl(h),S.forEach(function(E,T){!(b.isUndefined(E)||E===null)&&e.append(i===!0?Dc([h],T,o):i===null?h:h+"[]",c(E))}),!1}return Eo(d)?!0:(e.append(Dc(p,h,o),c(d)),!1)}let f=[],g=Object.assign(Em,{defaultVisitor:u,convertValue:c,isVisitable:Eo});function m(d,h){if(!b.isUndefined(d)){if(f.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(d),b.forEach(d,function(S,C){(!(b.isUndefined(S)||S===null)&&s.call(e,S,b.isString(C)?C.trim():C,h,g))===!0&&m(S,h?h.concat(C):[C])}),f.pop()}}if(!b.isObject(t))throw new TypeError("data must be an object");return m(t),e}function Nc(t){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function Ao(t,e){this._pairs=[],t&&Cr(t,this,e)}var ol=Ao.prototype;ol.append=function(e,n){this._pairs.push([e,n])};ol.toString=function(e){let n=e?function(r){return e.call(this,r,Nc)}:Nc;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Cm(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function il(t,e,n){if(!e)return t;let r=n&&n.encode||Cm;b.isFunction(n)&&(n={serialize:n});let s=n&&n.serialize,o;if(s?o=s(e,n):o=b.isURLSearchParams(e)?e.toString():new Ao(e,n).toString(r),o){let i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}var Co=class{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){b.forEach(this.handlers,function(r){r!==null&&e(r)})}},Lc=Co,al={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Tm=typeof URLSearchParams!="undefined"?URLSearchParams:Ao,Rm=typeof FormData!="undefined"?FormData:null,vm=typeof Blob!="undefined"?Blob:null,Pm={isBrowser:!0,classes:{URLSearchParams:Tm,FormData:Rm,Blob:vm},protocols:["http","https","file","blob","url","data"]},_o=typeof window!="undefined"&&typeof document!="undefined",To=typeof navigator=="object"&&navigator||void 0,Am=_o&&(!To||["ReactNative","NativeScript","NS"].indexOf(To.product)<0),_m=typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Im=_o&&window.location.href||"http://localhost",xm=Object.freeze({__proto__:null,hasBrowserEnv:_o,hasStandardBrowserWebWorkerEnv:_m,hasStandardBrowserEnv:Am,navigator:To,origin:Im}),Z=w(w({},xm),Pm);function Om(t,e){return Cr(t,new Z.classes.URLSearchParams,w({visitor:function(n,r,s,o){return Z.isNode&&b.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},e))}function km(t){return b.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Dm(t){let e={},n=Object.keys(t),r,s=n.length,o;for(r=0;r<s;r++)o=n[r],e[o]=t[o];return e}function cl(t){function e(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;let a=Number.isFinite(+i),l=o>=n.length;return i=!i&&b.isArray(s)?s.length:i,l?(b.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!a):((!s[i]||!b.isObject(s[i]))&&(s[i]=[]),e(n,r,s[i],o)&&b.isArray(s[i])&&(s[i]=Dm(s[i])),!a)}if(b.isFormData(t)&&b.isFunction(t.entries)){let n={};return b.forEachEntry(t,(r,s)=>{e(km(r),s,n,0)}),n}return null}function Nm(t,e,n){if(b.isString(t))try{return(e||JSON.parse)(t),b.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}var Io={transitional:al,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){let r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=b.isObject(e);if(o&&b.isHTMLForm(e)&&(e=new FormData(e)),b.isFormData(e))return s?JSON.stringify(cl(e)):e;if(b.isArrayBuffer(e)||b.isBuffer(e)||b.isStream(e)||b.isFile(e)||b.isBlob(e)||b.isReadableStream(e))return e;if(b.isArrayBufferView(e))return e.buffer;if(b.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Om(e,this.formSerializer).toString();if((a=b.isFileList(e))||r.indexOf("multipart/form-data")>-1){let l=this.env&&this.env.FormData;return Cr(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Nm(e)):e}],transformResponse:[function(e){let n=this.transitional||Io.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(b.isResponse(e)||b.isReadableStream(e))return e;if(e&&b.isString(e)&&(r&&!this.responseType||s)){let i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?O.from(a,O.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Z.classes.FormData,Blob:Z.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};b.forEach(["delete","get","head","post","put","patch"],t=>{Io.headers[t]={}});var xo=Io,Lm=b.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Bm=t=>{let e={},n,r,s;return t&&t.split("\n").forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||e[n]&&Lm[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e},Bc=Symbol("internals");function gn(t){return t&&String(t).trim().toLowerCase()}function mr(t){return t===!1||t==null?t:b.isArray(t)?t.map(mr):String(t)}function Um(t){let e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}var Mm=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function yo(t,e,n,r,s){if(b.isFunction(r))return r.call(this,e,n);if(s&&(e=n),!!b.isString(e)){if(b.isString(r))return e.indexOf(r)!==-1;if(b.isRegExp(r))return r.test(e)}}function Fm(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function $m(t,e){let n=b.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(s,o,i){return this[r].call(this,e,s,o,i)},configurable:!0})})}var Ot=class{constructor(e){e&&this.set(e)}set(e,n,r){let s=this;function o(a,l,c){let u=gn(l);if(!u)throw new Error("header name must be a non-empty string");let f=b.findKey(s,u);(!f||s[f]===void 0||c===!0||c===void 0&&s[f]!==!1)&&(s[f||l]=mr(a))}let i=(a,l)=>b.forEach(a,(c,u)=>o(c,u,l));if(b.isPlainObject(e)||e instanceof this.constructor)i(e,n);else if(b.isString(e)&&(e=e.trim())&&!Mm(e))i(Bm(e),n);else if(b.isObject(e)&&b.isIterable(e)){let a={},l,c;for(let u of e){if(!b.isArray(u))throw TypeError("Object iterator must return a key-value pair");a[c=u[0]]=(l=a[c])?b.isArray(l)?[...l,u[1]]:[l,u[1]]:u[1]}i(a,n)}else e!=null&&o(n,e,r);return this}get(e,n){if(e=gn(e),e){let r=b.findKey(this,e);if(r){let s=this[r];if(!n)return s;if(n===!0)return Um(s);if(b.isFunction(n))return n.call(this,s,r);if(b.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=gn(e),e){let r=b.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||yo(this,this[r],r,n)))}return!1}delete(e,n){let r=this,s=!1;function o(i){if(i=gn(i),i){let a=b.findKey(r,i);a&&(!n||yo(r,r[a],a,n))&&(delete r[a],s=!0)}}return b.isArray(e)?e.forEach(o):o(e),s}clear(e){let n=Object.keys(this),r=n.length,s=!1;for(;r--;){let o=n[r];(!e||yo(this,this[o],o,e,!0))&&(delete this[o],s=!0)}return s}normalize(e){let n=this,r={};return b.forEach(this,(s,o)=>{let i=b.findKey(r,o);if(i){n[i]=mr(s),delete n[o];return}let a=e?Fm(o):String(o).trim();a!==o&&delete n[o],n[a]=mr(s),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let n=Object.create(null);return b.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=e&&b.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){let r=new this(e);return n.forEach(s=>r.set(s)),r}static accessor(e){let r=(this[Bc]=this[Bc]={accessors:{}}).accessors,s=this.prototype;function o(i){let a=gn(i);r[a]||($m(s,i),r[a]=!0)}return b.isArray(e)?e.forEach(o):o(e),this}};Ot.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);b.reduceDescriptors(Ot.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}});b.freezeMethods(Ot);var Re=Ot;function bo(t,e){let n=this||xo,r=e||n,s=Re.from(r.headers),o=r.data;return b.forEach(t,function(a){o=a.call(n,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function ll(t){return!!(t&&t.__CANCEL__)}function Nt(t,e,n){O.call(this,t==null?"canceled":t,O.ERR_CANCELED,e,n),this.name="CanceledError"}b.inherits(Nt,O,{__CANCEL__:!0});function ul(t,e,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new O("Request failed with status code "+n.status,[O.ERR_BAD_REQUEST,O.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function qm(t){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function jm(t,e){t=t||10;let n=new Array(t),r=new Array(t),s=0,o=0,i;return e=e!==void 0?e:1e3,function(l){let c=Date.now(),u=r[o];i||(i=c),n[s]=l,r[s]=c;let f=o,g=0;for(;f!==s;)g+=n[f++],f=f%t;if(s=(s+1)%t,s===o&&(o=(o+1)%t),c-i<e)return;let m=u&&c-u;return m?Math.round(g*1e3/m):void 0}}function Hm(t,e){let n=0,r=1e3/e,s,o,i=(c,u=Date.now())=>{n=u,s=null,o&&(clearTimeout(o),o=null),t(...c)};return[(...c)=>{let u=Date.now(),f=u-n;f>=r?i(c,u):(s=c,o||(o=setTimeout(()=>{o=null,i(s)},r-f)))},()=>s&&i(s)]}var br=(t,e,n=3)=>{let r=0,s=jm(50,250);return Hm(o=>{let i=o.loaded,a=o.lengthComputable?o.total:void 0,l=i-r,c=s(l),u=i<=a;r=i;let f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&u?(a-i)/c:void 0,event:o,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(f)},n)},Uc=(t,e)=>{let n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},Mc=t=>(...e)=>b.asap(()=>t(...e)),Km=Z.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,Z.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(Z.origin),Z.navigator&&/(msie|trident)/i.test(Z.navigator.userAgent)):()=>!0,zm=Z.hasStandardBrowserEnv?{write(t,e,n,r,s,o,i){if(typeof document=="undefined")return;let a=["".concat(t,"=").concat(encodeURIComponent(e))];b.isNumber(n)&&a.push("expires=".concat(new Date(n).toUTCString())),b.isString(r)&&a.push("path=".concat(r)),b.isString(s)&&a.push("domain=".concat(s)),o===!0&&a.push("secure"),b.isString(i)&&a.push("SameSite=".concat(i)),document.cookie=a.join("; ")},read(t){if(typeof document=="undefined")return null;let e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Vm(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Gm(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function dl(t,e,n){let r=!Vm(e);return t&&(r||n==!1)?Gm(t,e):e}var Fc=t=>t instanceof Re?w({},t):t;function tt(t,e){e=e||{};let n={};function r(c,u,f,g){return b.isPlainObject(c)&&b.isPlainObject(u)?b.merge.call({caseless:g},c,u):b.isPlainObject(u)?b.merge({},u):b.isArray(u)?u.slice():u}function s(c,u,f,g){if(b.isUndefined(u)){if(!b.isUndefined(c))return r(void 0,c,f,g)}else return r(c,u,f,g)}function o(c,u){if(!b.isUndefined(u))return r(void 0,u)}function i(c,u){if(b.isUndefined(u)){if(!b.isUndefined(c))return r(void 0,c)}else return r(void 0,u)}function a(c,u,f){if(f in e)return r(c,u);if(f in t)return r(void 0,c)}let l={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,u,f)=>s(Fc(c),Fc(u),f,!0)};return b.forEach(Object.keys(w(w({},t),e)),function(u){let f=l[u]||s,g=f(t[u],e[u],u);b.isUndefined(g)&&f!==a||(n[u]=g)}),n}var fl=t=>{let e=tt({},t),{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:a}=e;if(e.headers=i=Re.from(i),e.url=il(dl(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),b.isFormData(n)){if(Z.hasStandardBrowserEnv||Z.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(b.isFunction(n.getHeaders)){let l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([u,f])=>{c.includes(u.toLowerCase())&&i.set(u,f)})}}if(Z.hasStandardBrowserEnv&&(r&&b.isFunction(r)&&(r=r(e)),r||r!==!1&&Km(e.url))){let l=s&&o&&zm.read(o);l&&i.set(s,l)}return e},Wm=typeof XMLHttpRequest!="undefined",Jm=Wm&&function(t){return new Promise(function(n,r){let s=fl(t),o=s.data,i=Re.from(s.headers).normalize(),{responseType:a,onUploadProgress:l,onDownloadProgress:c}=s,u,f,g,m,d;function h(){m&&m(),d&&d(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function S(){if(!p)return;let E=Re.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),P={data:!a||a==="text"||a==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:E,config:t,request:p};ul(function(A){n(A),h()},function(A){r(A),h()},P),p=null}"onloadend"in p?p.onloadend=S:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(S)},p.onabort=function(){p&&(r(new O("Request aborted",O.ECONNABORTED,t,p)),p=null)},p.onerror=function(T){let P=T&&T.message?T.message:"Network Error",I=new O(P,O.ERR_NETWORK,t,p);I.event=T||null,r(I),p=null},p.ontimeout=function(){let T=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded",P=s.transitional||al;s.timeoutErrorMessage&&(T=s.timeoutErrorMessage),r(new O(T,P.clarifyTimeoutError?O.ETIMEDOUT:O.ECONNABORTED,t,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&b.forEach(i.toJSON(),function(T,P){p.setRequestHeader(P,T)}),b.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),a&&a!=="json"&&(p.responseType=s.responseType),c&&([g,d]=br(c,!0),p.addEventListener("progress",g)),l&&p.upload&&([f,m]=br(l),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",m)),(s.cancelToken||s.signal)&&(u=E=>{p&&(r(!E||E.type?new Nt(null,t,p):E),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));let C=qm(s.url);if(C&&Z.protocols.indexOf(C)===-1){r(new O("Unsupported protocol "+C+":",O.ERR_BAD_REQUEST,t));return}p.send(o||null)})},Ym=(t,e)=>{let{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,s,o=function(c){if(!s){s=!0,a();let u=c instanceof Error?c:this.reason;r.abort(u instanceof O?u:new Nt(u instanceof Error?u.message:u))}},i=e&&setTimeout(()=>{i=null,o(new O("timeout ".concat(e," of ms exceeded"),O.ETIMEDOUT))},e),a=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),t=null)};t.forEach(c=>c.addEventListener("abort",o));let{signal:l}=r;return l.unsubscribe=()=>b.asap(a),l}},Xm=Ym,Zm=function*(t,e){let n=t.byteLength;if(!e||n<e){yield t;return}let r=0,s;for(;r<n;)s=r+e,yield t.slice(r,s),r=s},Qm=function(t,e){return ot(this,null,function*(){try{for(var n=An(eh(t)),r,s,o;r=!(s=yield new fe(n.next())).done;r=!1){let i=s.value;yield*Me(Zm(i,e))}}catch(s){o=[s]}finally{try{r&&(s=n.return)&&(yield new fe(s.call(n)))}finally{if(o)throw o[0]}}})},eh=function(t){return ot(this,null,function*(){if(t[Symbol.asyncIterator]){yield*Me(t);return}let e=t.getReader();try{for(;;){let{done:n,value:r}=yield new fe(e.read());if(n)break;yield r}}finally{yield new fe(e.cancel())}})},$c=(t,e,n,r)=>{let s=Qm(t,e),o=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{let{done:c,value:u}=await s.next();if(c){a(),l.close();return}let f=u.byteLength;if(n){let g=o+=f;n(g)}l.enqueue(new Uint8Array(u))}catch(c){throw a(c),c}},cancel(l){return a(l),s.return()}},{highWaterMark:2})},qc=64*1024,{isFunction:pr}=b,th=(({Request:t,Response:e})=>({Request:t,Response:e}))(b.global),{ReadableStream:jc,TextEncoder:Hc}=b.global,Kc=(t,...e)=>{try{return!!t(...e)}catch(n){return!1}},nh=t=>{t=b.merge.call({skipUndefined:!0},th,t);let{fetch:e,Request:n,Response:r}=t,s=e?pr(e):typeof fetch=="function",o=pr(n),i=pr(r);if(!s)return!1;let a=s&&pr(jc),l=s&&(typeof Hc=="function"?(d=>h=>d.encode(h))(new Hc):async d=>new Uint8Array(await new n(d).arrayBuffer())),c=o&&a&&Kc(()=>{let d=!1,h=new n(Z.origin,{body:new jc,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!h}),u=i&&a&&Kc(()=>b.isReadableStream(new r("").body)),f={stream:u&&(d=>d.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!f[d]&&(f[d]=(h,p)=>{let S=h&&h[d];if(S)return S.call(h);throw new O("Response type '".concat(d,"' is not supported"),O.ERR_NOT_SUPPORT,p)})});let g=async d=>{if(d==null)return 0;if(b.isBlob(d))return d.size;if(b.isSpecCompliantForm(d))return(await new n(Z.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(b.isArrayBufferView(d)||b.isArrayBuffer(d))return d.byteLength;if(b.isURLSearchParams(d)&&(d=d+""),b.isString(d))return(await l(d)).byteLength},m=async(d,h)=>{let p=b.toFiniteNumber(d.getContentLength());return p==null?g(h):p};return async d=>{let{url:h,method:p,data:S,signal:C,cancelToken:E,timeout:T,onDownloadProgress:P,onUploadProgress:I,responseType:A,headers:L,withCredentials:K="same-origin",fetchOptions:j}=fl(d),G=e||fetch;A=A?(A+"").toLowerCase():"text";let M=Xm([C,E&&E.toAbortSignal()],T),se=null,Y=M&&M.unsubscribe&&(()=>{M.unsubscribe()}),Ke;try{if(I&&c&&p!=="get"&&p!=="head"&&(Ke=await m(L,S))!==0){let B=new n(h,{method:"POST",body:S,duplex:"half"}),W;if(b.isFormData(S)&&(W=B.headers.get("content-type"))&&L.setContentType(W),B.body){let[ue,re]=Uc(Ke,br(Mc(I)));S=$c(B.body,qc,ue,re)}}b.isString(K)||(K=K?"include":"omit");let U=o&&"credentials"in n.prototype,ze=N(w({},j),{signal:M,method:p.toUpperCase(),headers:L.normalize().toJSON(),body:S,duplex:"half",credentials:U?K:void 0});se=o&&new n(h,ze);let x=await(o?G(se,j):G(h,ze)),ge=u&&(A==="stream"||A==="response");if(u&&(P||ge&&Y)){let B={};["status","statusText","headers"].forEach(me=>{B[me]=x[me]});let W=b.toFiniteNumber(x.headers.get("content-length")),[ue,re]=P&&Uc(W,br(Mc(P),!0))||[];x=new r($c(x.body,qc,ue,()=>{re&&re(),Y&&Y()}),B)}A=A||"text";let q=await f[b.findKey(f,A)||"text"](x,d);return!ge&&Y&&Y(),await new Promise((B,W)=>{ul(B,W,{data:q,headers:Re.from(x.headers),status:x.status,statusText:x.statusText,config:d,request:se})})}catch(U){throw Y&&Y(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new O("Network Error",O.ERR_NETWORK,d,se),{cause:U.cause||U}):O.from(U,U&&U.code,d,se)}}},rh=new Map,pl=t=>{let e=t&&t.env||{},{fetch:n,Request:r,Response:s}=e,o=[r,s,n],i=o.length,a=i,l,c,u=rh;for(;a--;)l=o[a],c=u.get(l),c===void 0&&u.set(l,c=a?new Map:nh(e)),u=c;return c};pl();var Oo={http:wm,xhr:Jm,fetch:{get:pl}};b.forEach(Oo,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(n){}Object.defineProperty(t,"adapterName",{value:e})}});var zc=t=>"- ".concat(t),sh=t=>b.isFunction(t)||t===null||t===!1;function oh(t,e){t=b.isArray(t)?t:[t];let{length:n}=t,r,s,o={};for(let i=0;i<n;i++){r=t[i];let a;if(s=r,!sh(r)&&(s=Oo[(a=String(r)).toLowerCase()],s===void 0))throw new O("Unknown adapter '".concat(a,"'"));if(s&&(b.isFunction(s)||(s=s.get(e))))break;o[a||"#"+i]=s}if(!s){let i=Object.entries(o).map(([l,c])=>"adapter ".concat(l," ")+(c===!1?"is not supported by the environment":"is not available in the build")),a=n?i.length>1?"since :\n"+i.map(zc).join("\n"):" "+zc(i[0]):"as no adapter specified";throw new O("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return s}var gl={getAdapter:oh,adapters:Oo};function wo(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Nt(null,t)}function Vc(t){return wo(t),t.headers=Re.from(t.headers),t.data=bo.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),gl.getAdapter(t.adapter||xo.adapter,t)(t).then(function(r){return wo(t),r.data=bo.call(t,t.transformResponse,r),r.headers=Re.from(r.headers),r},function(r){return ll(r)||(wo(t),r&&r.response&&(r.response.data=bo.call(t,t.transformResponse,r.response),r.response.headers=Re.from(r.response.headers))),Promise.reject(r)})}var ml="1.13.2",Tr={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Tr[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});var Gc={};Tr.transitional=function(e,n,r){function s(o,i){return"[Axios v"+ml+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,a)=>{if(e===!1)throw new O(s(i," has been removed"+(n?" in "+n:"")),O.ERR_DEPRECATED);return n&&!Gc[i]&&(Gc[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(o,i,a):!0}};Tr.spelling=function(e){return(n,r)=>(console.warn("".concat(r," is likely a misspelling of ").concat(e)),!0)};function ih(t,e,n){if(typeof t!="object")throw new O("options must be an object",O.ERR_BAD_OPTION_VALUE);let r=Object.keys(t),s=r.length;for(;s-- >0;){let o=r[s],i=e[o];if(i){let a=t[o],l=a===void 0||i(a,o,t);if(l!==!0)throw new O("option "+o+" must be "+l,O.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new O("Unknown option "+o,O.ERR_BAD_OPTION)}}var hr={assertOptions:ih,validators:Tr},Le=hr.validators,kt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Lc,response:new Lc}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;let o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+="\n"+o):r.stack=o}catch(i){}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=tt(this.defaults,n);let{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&hr.assertOptions(r,{silentJSONParsing:Le.transitional(Le.boolean),forcedJSONParsing:Le.transitional(Le.boolean),clarifyTimeoutError:Le.transitional(Le.boolean)},!1),s!=null&&(b.isFunction(s)?n.paramsSerializer={serialize:s}:hr.assertOptions(s,{encode:Le.function,serialize:Le.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),hr.assertOptions(n,{baseUrl:Le.spelling("baseURL"),withXsrfToken:Le.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&b.merge(o.common,o[n.method]);o&&b.forEach(["delete","get","head","post","put","patch","common"],d=>{delete o[d]}),n.headers=Re.concat(i,o);let a=[],l=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(l=l&&h.synchronous,a.unshift(h.fulfilled,h.rejected))});let c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let u,f=0,g;if(!l){let d=[Vc.bind(this),void 0];for(d.unshift(...a),d.push(...c),g=d.length,u=Promise.resolve(n);f<g;)u=u.then(d[f++],d[f++]);return u}g=a.length;let m=n;for(;f<g;){let d=a[f++],h=a[f++];try{m=d(m)}catch(p){h.call(this,p);break}}try{u=Vc.call(this,m)}catch(d){return Promise.reject(d)}for(f=0,g=c.length;f<g;)u=u.then(c[f++],c[f++]);return u}getUri(e){e=tt(this.defaults,e);let n=dl(e.baseURL,e.url,e.allowAbsoluteUrls);return il(n,e.params,e.paramsSerializer)}};b.forEach(["delete","get","head","options"],function(e){kt.prototype[e]=function(n,r){return this.request(tt(r||{},{method:e,url:n,data:(r||{}).data}))}});b.forEach(["post","put","patch"],function(e){function n(r){return function(o,i,a){return this.request(tt(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}kt.prototype[e]=n(),kt.prototype[e+"Form"]=n(!0)});var yr=kt,Ro=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});let r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o,i=new Promise(a=>{r.subscribe(a),o=a}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},e(function(o,i,a){r.reason||(r.reason=new Nt(o,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){let e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new t(function(s){e=s}),cancel:e}}},ah=Ro;function ch(t){return function(n){return t.apply(null,n)}}function lh(t){return b.isObject(t)&&t.isAxiosError===!0}var vo={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(vo).forEach(([t,e])=>{vo[e]=t});var uh=vo;function hl(t){let e=new yr(t),n=Wc(yr.prototype.request,e);return b.extend(n,yr.prototype,e,{allOwnKeys:!0}),b.extend(n,e,null,{allOwnKeys:!0}),n.create=function(s){return hl(tt(t,s))},n}var V=hl(xo);V.Axios=yr;V.CanceledError=Nt;V.CancelToken=ah;V.isCancel=ll;V.VERSION=ml;V.toFormData=Cr;V.AxiosError=O;V.Cancel=V.CanceledError;V.all=function(e){return Promise.all(e)};V.spread=ch;V.isAxiosError=lh;V.mergeConfig=tt;V.AxiosHeaders=Re;V.formToJSON=t=>cl(b.isHTMLForm(t)?new FormData(t):t);V.getAdapter=gl.getAdapter;V.HttpStatusCode=uh;V.default=V;yl.exports=V});var Lo=R((UR,No)=>{"use strict";var wl=t=>typeof t=="object"&&t!==null,Sl=Symbol("skip"),bl=t=>wl(t)&&!(t instanceof RegExp)&&!(t instanceof Error)&&!(t instanceof Date),Do=(t,e,n,r=new WeakMap)=>{if(n=w({deep:!1,target:{}},n),r.has(t))return r.get(t);r.set(t,n.target);let{target:s}=n;delete n.target;let o=i=>i.map(a=>bl(a)?Do(a,e,n,r):a);if(Array.isArray(t))return o(t);for(let[i,a]of Object.entries(t)){let l=e(i,a,t);if(l===Sl)continue;let[c,u,{shouldRecurse:f=!0}={}]=l;c!=="__proto__"&&(n.deep&&f&&bl(u)&&(u=Array.isArray(u)?o(u):Do(u,e,n,r)),s[c]=u)}return s};No.exports=(t,e,n)=>{if(!wl(t))throw new TypeError("Expected an object, got `".concat(t,"` (").concat(typeof t,")"));return Do(t,e,n)};No.exports.mapObjectSkip=Sl});var Cl=R((FR,Bo)=>{"use strict";var dh=t=>{let e=!1,n=!1,r=!1;for(let s=0;s<t.length;s++){let o=t[s];e&&/[a-zA-Z]/.test(o)&&o.toUpperCase()===o?(t=t.slice(0,s)+"-"+t.slice(s),e=!1,r=n,n=!0,s++):n&&r&&/[a-zA-Z]/.test(o)&&o.toLowerCase()===o?(t=t.slice(0,s-1)+"-"+t.slice(s-1),r=n,n=!1,e=!0):(e=o.toLowerCase()===o&&o.toUpperCase()!==o,r=n,n=o.toUpperCase()===o&&o.toLowerCase()!==o)}return t},El=(t,e)=>{if(!(typeof t=="string"||Array.isArray(t)))throw new TypeError("Expected the input to be `string | string[]`");e=Object.assign({pascalCase:!1},e);let n=s=>e.pascalCase?s.charAt(0).toUpperCase()+s.slice(1):s;return Array.isArray(t)?t=t.map(s=>s.trim()).filter(s=>s.length).join("-"):t=t.trim(),t.length===0?"":t.length===1?e.pascalCase?t.toUpperCase():t.toLowerCase():(t!==t.toLowerCase()&&(t=dh(t)),t=t.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(s,o)=>o.toUpperCase()).replace(/\d+(\w|$)/g,s=>s.toUpperCase()),n(t))};Bo.exports=El;Bo.exports.default=El});var Rl=R(($R,Tl)=>{"use strict";var Uo=class{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,n){this.cache.set(e,n),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){let n=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,n),n}}set(e,n){return this.cache.has(e)?this.cache.set(e,n):this._set(e,n),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e))return this.oldCache.get(e)}delete(e){let n=this.cache.delete(e);return n&&this._size--,this.oldCache.delete(e)||n}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache)yield e;for(let e of this.oldCache){let[n]=e;this.cache.has(n)||(yield e)}}get size(){let e=0;for(let n of this.oldCache.keys())this.cache.has(n)||e++;return this._size+e}};Tl.exports=Uo});var Il=R((qR,_l)=>{"use strict";var vl=Lo(),fh=Cl(),ph=Rl(),gh=(t,e)=>t.some(n=>typeof n=="string"?n===e:(n.lastIndex=0,n.test(e))),Mo=new ph({maxSize:1e5}),Pl=t=>typeof t=="object"&&t!==null&&!(t instanceof RegExp)&&!(t instanceof Error)&&!(t instanceof Date),Al=(t,e)=>{if(!Pl(t))return t;e=w({deep:!1,pascalCase:!1},e);let{exclude:n,pascalCase:r,stopPaths:s,deep:o}=e,i=new Set(s),a=l=>(c,u)=>{if(o&&Pl(u)){let f=l===void 0?c:"".concat(l,".").concat(c);i.has(f)||(u=vl(u,a(f)))}if(!(n&&gh(n,c))){let f=r?"".concat(c,"_"):c;if(Mo.has(f))c=Mo.get(f);else{let g=fh(c,{pascalCase:r});c.length<100&&Mo.set(f,g),c=g}}return[c,u]};return vl(t,a(void 0))};_l.exports=(t,e)=>Array.isArray(t)?Object.keys(t).map(n=>Al(t[n],e)):Al(t,e)});var Fo=R((HR,xl)=>{xl.exports=Fo()});var Ho={};st(Ho,{__addDisposableResource:()=>tu,__assign:()=>Rr,__asyncDelegator:()=>Gl,__asyncGenerator:()=>Vl,__asyncValues:()=>Wl,__await:()=>Lt,__awaiter:()=>$l,__classPrivateFieldGet:()=>Zl,__classPrivateFieldIn:()=>eu,__classPrivateFieldSet:()=>Ql,__createBinding:()=>Pr,__decorate:()=>Dl,__disposeResources:()=>nu,__esDecorate:()=>Ll,__exportStar:()=>jl,__extends:()=>Ol,__generator:()=>ql,__importDefault:()=>Xl,__importStar:()=>Yl,__makeTemplateObject:()=>Jl,__metadata:()=>Fl,__param:()=>Nl,__propKey:()=>Ul,__read:()=>jo,__rest:()=>kl,__rewriteRelativeImportExtension:()=>ru,__runInitializers:()=>Bl,__setFunctionName:()=>Ml,__spread:()=>Hl,__spreadArray:()=>zl,__spreadArrays:()=>Kl,__values:()=>vr,default:()=>yh});function Ol(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");$o(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function kl(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}function Dl(t,e,n,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,n):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(o=(s<3?i(o):s>3?i(e,n,o):i(e,n))||o);return s>3&&o&&Object.defineProperty(e,n,o),o}function Nl(t,e){return function(n,r){e(n,r,t)}}function Ll(t,e,n,r,s,o){function i(S){if(S!==void 0&&typeof S!="function")throw new TypeError("Function expected");return S}for(var a=r.kind,l=a==="getter"?"get":a==="setter"?"set":"value",c=!e&&t?r.static?t:t.prototype:null,u=e||(c?Object.getOwnPropertyDescriptor(c,r.name):{}),f,g=!1,m=n.length-1;m>=0;m--){var d={};for(var h in r)d[h]=h==="access"?{}:r[h];for(var h in r.access)d.access[h]=r.access[h];d.addInitializer=function(S){if(g)throw new TypeError("Cannot add initializers after decoration has completed");o.push(i(S||null))};var p=(0,n[m])(a==="accessor"?{get:u.get,set:u.set}:u[l],d);if(a==="accessor"){if(p===void 0)continue;if(p===null||typeof p!="object")throw new TypeError("Object expected");(f=i(p.get))&&(u.get=f),(f=i(p.set))&&(u.set=f),(f=i(p.init))&&s.unshift(f)}else(f=i(p))&&(a==="field"?s.unshift(f):u[l]=f)}c&&Object.defineProperty(c,r.name,u),g=!0}function Bl(t,e,n){for(var r=arguments.length>2,s=0;s<e.length;s++)n=r?e[s].call(t,n):e[s].call(t);return r?n:void 0}function Ul(t){return typeof t=="symbol"?t:"".concat(t)}function Ml(t,e,n){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:n?"".concat(n," ",e):e})}function Fl(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function $l(t,e,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{c(r.next(u))}catch(f){i(f)}}function l(u){try{c(r.throw(u))}catch(f){i(f)}}function c(u){u.done?o(u.value):s(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})}function ql(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(n=0)),n;)try{if(r=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,s=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],s=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function jl(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Pr(e,t,n)}function vr(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function jo(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Hl(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(jo(arguments[e]));return t}function Kl(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var r=Array(t),s=0,e=0;e<n;e++)for(var o=arguments[e],i=0,a=o.length;i<a;i++,s++)r[s]=o[i];return r}function zl(t,e,n){if(n||arguments.length===2)for(var r=0,s=e.length,o;r<s;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}function Lt(t){return this instanceof Lt?(this.v=t,this):new Lt(t)}function Vl(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(m){return function(d){return Promise.resolve(d).then(m,f)}}function a(m,d){r[m]&&(s[m]=function(h){return new Promise(function(p,S){o.push([m,h,p,S])>1||l(m,h)})},d&&(s[m]=d(s[m])))}function l(m,d){try{c(r[m](d))}catch(h){g(o[0][3],h)}}function c(m){m.value instanceof Lt?Promise.resolve(m.value.v).then(u,f):g(o[0][2],m)}function u(m){l("next",m)}function f(m){l("throw",m)}function g(m,d){m(d),o.shift(),o.length&&l(o[0][0],o[0][1])}}function Gl(t){var e,n;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,o){e[s]=t[s]?function(i){return(n=!n)?{value:Lt(t[s](i)),done:!1}:o?o(i):i}:o}}function Wl(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof vr=="function"?vr(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=t[o]&&function(i){return new Promise(function(a,l){i=t[o](i),s(a,l,i.done,i.value)})}}function s(o,i,a,l){Promise.resolve(l).then(function(c){o({value:c,done:a})},i)}}function Jl(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Yl(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n=qo(t),r=0;r<n.length;r++)n[r]!=="default"&&Pr(e,t,n[r]);return mh(e,t),e}function Xl(t){return t&&t.__esModule?t:{default:t}}function Zl(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)}function Ql(t,e,n,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(t,n):s?s.value=n:e.set(t,n),n}function eu(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function tu(t,e,n){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],n&&(s=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");s&&(r=function(){try{s.call(this)}catch(o){return Promise.reject(o)}}),t.stack.push({value:e,dispose:r,async:n})}else n&&t.stack.push({async:!0});return e}function nu(t){function e(o){t.error=t.hasError?new hh(o,t.error,"An error was suppressed during disposal."):o,t.hasError=!0}var n,r=0;function s(){for(;n=t.stack.pop();)try{if(!n.async&&r===1)return r=0,t.stack.push(n),Promise.resolve().then(s);if(n.dispose){var o=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(o).then(s,function(i){return e(i),s()})}else r|=1}catch(i){e(i)}if(r===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return s()}function ru(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,r,s,o,i){return r?e?".jsx":".js":s&&(!o||!i)?n:s+o+"."+i.toLowerCase()+"js"}):t}var $o,Rr,Pr,mh,qo,hh,yh,Ko=Oe(()=>{$o=function(t,e){return $o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},$o(t,e)};Rr=function(){return Rr=Object.assign||function(e){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},Rr.apply(this,arguments)};Pr=Object.create?function(t,e,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(e,n);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,s)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]};mh=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e},qo=function(t){return qo=Object.getOwnPropertyNames||function(e){var n=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[n.length]=r);return n},qo(t)};hh=typeof SuppressedError=="function"?SuppressedError:function(t,e,n){var r=new Error(n);return r.name="SuppressedError",r.error=t,r.suppressed=e,r};yh={__extends:Ol,__assign:Rr,__rest:kl,__decorate:Dl,__param:Nl,__esDecorate:Ll,__runInitializers:Bl,__propKey:Ul,__setFunctionName:Ml,__metadata:Fl,__awaiter:$l,__generator:ql,__createBinding:Pr,__exportStar:jl,__values:vr,__read:jo,__spread:Hl,__spreadArrays:Kl,__spreadArray:zl,__await:Lt,__asyncGenerator:Vl,__asyncDelegator:Gl,__asyncValues:Wl,__makeTemplateObject:Jl,__importStar:Yl,__importDefault:Xl,__classPrivateFieldGet:Zl,__classPrivateFieldSet:Ql,__classPrivateFieldIn:eu,__addDisposableResource:tu,__disposeResources:nu,__rewriteRelativeImportExtension:ru}});var su=R(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.lowerCase=Bt.localeLowerCase=void 0;var bh={tr:{regexp:/\u0130|\u0049|\u0049\u0307/g,map:{\u0130:"i",I:"\u0131",I\u0307:"i"}},az:{regexp:/\u0130/g,map:{\u0130:"i",I:"\u0131",I\u0307:"i"}},lt:{regexp:/\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,map:{I:"i\u0307",J:"j\u0307",\u012E:"\u012F\u0307",\u00CC:"i\u0307\u0300",\u00CD:"i\u0307\u0301",\u0128:"i\u0307\u0303"}}};function wh(t,e){var n=bh[e.toLowerCase()];return zo(n?t.replace(n.regexp,function(r){return n.map[r]}):t)}Bt.localeLowerCase=wh;function zo(t){return t.toLowerCase()}Bt.lowerCase=zo});var iu=R(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.noCase=void 0;var Sh=su(),Eh=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],Ch=/[^A-Z0-9]+/gi;function Th(t,e){e===void 0&&(e={});for(var n=e.splitRegexp,r=n===void 0?Eh:n,s=e.stripRegexp,o=s===void 0?Ch:s,i=e.transform,a=i===void 0?Sh.lowerCase:i,l=e.delimiter,c=l===void 0?" ":l,u=ou(ou(t,r,"$1\0$2"),o,"\0"),f=0,g=u.length;u.charAt(f)==="\0";)f++;for(;u.charAt(g-1)==="\0";)g--;return u.slice(f,g).split("\0").map(a).join(c)}Ar.noCase=Th;function ou(t,e,n){return e instanceof RegExp?t.replace(e,n):e.reduce(function(r,s){return r.replace(s,n)},t)}});var au=R(_r=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.dotCase=void 0;var Rh=(Ko(),ws(Ho)),vh=iu();function Ph(t,e){return e===void 0&&(e={}),vh.noCase(t,Rh.__assign({delimiter:"."},e))}_r.dotCase=Ph});var cu=R(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.snakeCase=void 0;var Ah=(Ko(),ws(Ho)),_h=au();function Ih(t,e){return e===void 0&&(e={}),_h.dotCase(t,Ah.__assign({delimiter:"_"},e))}Ir.snakeCase=Ih});var uu=R((WR,lu)=>{lu.exports=Dh;var xh=/\s/,Oh=/(_|-|\.|:)/,kh=/([a-z][A-Z]|[A-Z][a-z])/;function Dh(t){return xh.test(t)?t.toLowerCase():Oh.test(t)?(Lh(t)||t).toLowerCase():kh.test(t)?Uh(t).toLowerCase():t.toLowerCase()}var Nh=/[\W_]+(.|$)/g;function Lh(t){return t.replace(Nh,function(e,n){return n?" "+n:""})}var Bh=/(.)([A-Z]+)/g;function Uh(t){return t.replace(Bh,function(e,n,r){return n+" "+r.toLowerCase().split("").join(" ")})}});var fu=R((JR,du)=>{var Mh=uu();du.exports=Fh;function Fh(t){return Mh(t).replace(/[\W_]+(.|$)/g,function(e,n){return n?" "+n:""}).trim()}});var gu=R((YR,pu)=>{var $h=fu();pu.exports=qh;function qh(t){return $h(t).replace(/\s/g,"_")}});var hu=R((XR,mu)=>{"use strict";var jh=Lo(),Hh=gu();mu.exports=function(t,e){return e=Object.assign({deep:!0,exclude:[]},e),jh(t,function(n,r){return[Kh(e.exclude,n)?n:Hh(n),r]},e)};function Kh(t,e){return t.some(function(n){return typeof n=="string"?n===e:n.test(e)})}});var Go=R(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.BasisTheoryApiError=void 0;function zh(t){function e(){var n=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(n,Object.getPrototypeOf(this)),n}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}var Vo=class t extends zh(Error){constructor(e,n,r,s){super(e),this.status=n,this.data=r,this._debug=s,this.name="BasisTheoryApiError",Object.setPrototypeOf(this,t.prototype)}};xr.BasisTheoryApiError=Vo});var kr=R(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.logger=void 0;var yu=fr(),Vh=(()=>{let t="pubb96b84a13912504f4354f2d794ea4fab",e=!0,n=async(s,o,i={})=>{if(e)try{var a,l,c,u,f,g;let m;yu.DEFAULT_BASE_URL.includes("localhost")?m="local":yu.DEFAULT_BASE_URL.includes("dev")?m="dev":m="prod";let d=w({level:o,message:s,service:"js-sdk",env:m,referrer:(a=document)===null||a===void 0?void 0:a.referrer,origin:(l=window)===null||l===void 0||(c=l.location)===null||c===void 0?void 0:c.origin,url:(u=window)===null||u===void 0||(f=u.location)===null||f===void 0?void 0:f.href,userAgent:(g=navigator)===null||g===void 0?void 0:g.userAgent},i);await fetch("https://http-intake.logs.datadoghq.com/v1/input/".concat(t),{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"}})}catch(m){console.warn("There was an error sending telemetry.")}};return{setTelemetryEnabled:s=>{e=s},log:{error:(s,o={})=>n(s,"error",o),info:(s,o={})=>n(s,"info",o),warn:(s,o={})=>n(s,"warn",o)}}})();Or.logger=Vh});var Ut=R(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});v.transformTokenResponseCamelCase=v.transformTokenRequestSnakeCase=v.transformResponseCamelCase=v.transformRequestSnakeCase=v.transformReactorResponseCamelCase=v.transformReactorRequestSnakeCase=v.transformProxyResponseCamelCase=v.transformProxyRequestSnakeCase=v.proxyRaw=v.getRuntime=v.getQueryParams=v.getOSVersion=v.getBrowser=v.errorInterceptorDebug=v.errorInterceptor=v.debugTransform=v.dataExtractor=v.dataAndHeadersExtractor=v.createRequestConfig=v.concatResponseTransformerWithDefault=v.concatRequestTransformerWithDefault=v.buildUserAgentString=v.buildClientUserAgentString=v.assertInit=void 0;var wu=Dr(ko()),Be=Dr(Il()),bu=Dr(Fo()),Gh=cu(),bn=Dr(hu()),Wh=Go(),Pe=fr(),Jh=kr();function Dr(t){return t&&t.__esModule?t:{default:t}}var Yh=t=>{if(t==null)throw new Error("BasisTheory has not yet been properly initialized.");return t};v.assertInit=Yh;var Xh=t=>{if(typeof t!="undefined")return(0,bn.default)(t,{deep:!0})};v.transformRequestSnakeCase=Xh;var Zh=t=>t;v.proxyRaw=Zh;var Qh=t=>{if(typeof t!="undefined")return w(w({},(0,bn.default)(t,{deep:!0})),t.configuration!==void 0?{configuration:t.configuration}:{})};v.transformReactorRequestSnakeCase=Qh;var ey=t=>{if(typeof t!="undefined")return w(w({},(0,bn.default)(t,{deep:!0})),t.configuration!==void 0?{configuration:t.configuration}:{})};v.transformProxyRequestSnakeCase=ey;var ty=t=>{if(typeof t!="undefined")return w(w(w({},(0,bn.default)(t,{deep:!0})),t.data!==void 0?{data:t.data}:{}),t.metadata!==void 0?{metadata:t.metadata}:{})};v.transformTokenRequestSnakeCase=ty;var Yo=t=>t&&(t==null?void 0:t.pagination)!==void 0&&(t==null?void 0:t.data)!==void 0,ny=t=>{if(typeof t!="undefined")return Yo(t)?{data:t.data.map(r=>w(w(w({},(0,Be.default)(r,{deep:!0})),r.data!==void 0?{data:r.data}:{}),r.metadata!==void 0?{metadata:r.metadata}:{})),pagination:(0,Be.default)(t.pagination,{deep:!0})}:w(w(w({},(0,Be.default)(t,{deep:!0})),t.data!==void 0?{data:t.data}:{}),t.metadata!==void 0?{metadata:t.metadata}:{})};v.transformTokenResponseCamelCase=ny;var ry=t=>{if(typeof t!="undefined")return Yo(t)?{data:t.data.map(r=>w(w({},(0,Be.default)(r,{deep:!0})),r.configuration!==void 0?{configuration:r.configuration}:{})),pagination:(0,Be.default)(t.pagination,{deep:!0})}:w(w({},(0,Be.default)(t,{deep:!0})),t.configuration!==void 0?{configuration:t.configuration}:{})};v.transformReactorResponseCamelCase=ry;var sy=t=>{if(typeof t!="undefined")return Yo(t)?{data:t.data.map(r=>w(w({},(0,Be.default)(r,{deep:!0})),r.configuration!==void 0?{configuration:r.configuration}:{})),pagination:(0,Be.default)(t.pagination,{deep:!0})}:w(w({},(0,Be.default)(t,{deep:!0})),t.configuration!==void 0?{configuration:t.configuration}:{})};v.transformProxyResponseCamelCase=sy;var oy=t=>{if(typeof t!="undefined")return(0,Be.default)(t,{deep:!0})};v.transformResponseCamelCase=oy;var iy=t=>t==null?void 0:t.data;v.dataExtractor=iy;var ay=t=>({data:t==null?void 0:t.data,headers:t==null?void 0:t.headers});v.dataAndHeadersExtractor=ay;var Wo=t=>[t,...wu.default.defaults.transformRequest];v.concatRequestTransformerWithDefault=Wo;var Jo=t=>[...wu.default.defaults.transformResponse,t];v.concatResponseTransformerWithDefault=Jo;var cy=(t,e)=>{if(!t)return e?w(w({},e.transformRequest!==void 0?{transformRequest:Wo(e.transformRequest)}:{}),e.transformResponse!==void 0?{transformResponse:Jo(e.transformResponse)}:{}):void 0;let{apiKey:n,correlationId:r,idempotencyKey:s,query:o,headers:i}=t,a=n?{[Pe.API_KEY_HEADER]:n}:{},l=r?{[Pe.BT_TRACE_ID_HEADER]:r}:{},c=s?{[Pe.BT_IDEMPOTENCY_KEY_HEADER]:s}:{};return w(w(w({headers:w(w(w(w({},a),l),c),typeof i!="undefined"&&w({},i))},typeof o!="undefined"&&{params:o}),(e==null?void 0:e.transformRequest)!==void 0?{transformRequest:Wo(e.transformRequest)}:{}),(e==null?void 0:e.transformResponse)!==void 0?{transformResponse:Jo(e.transformResponse)}:{})};v.createRequestConfig=cy;var Su=(t,e)=>{var n,r,s,o,i,a,l,c,u,f,g,m,d,h,p;let S=(n=t==null||(r=t.response)===null||r===void 0?void 0:r.status)!==null&&n!==void 0?n:-1,C=t==null||(s=t.response)===null||s===void 0?void 0:s.data,E;if(e){var T,P,I,A;E={cfRay:t==null||(T=t.response)===null||T===void 0||(P=T.headers)===null||P===void 0?void 0:P[Pe.CF_RAY_HEADER],btTraceId:t==null||(I=t.response)===null||I===void 0||(A=I.headers)===null||A===void 0?void 0:A[Pe.BT_TRACE_ID_HEADER]}}let L=S>-1&&S<499?"warn":"error";throw Jh.logger.log[L]("Error when making ".concat(t==null||(o=t.config)===null||o===void 0||(i=o.method)===null||i===void 0?void 0:i.toUpperCase()," request to ").concat(t==null||(a=t.config)===null||a===void 0?void 0:a.baseURL," from the JS SDK"),{apiStatus:S,logType:"axiosError",logOrigin:"axiosErrorInterceptor",requestDetails:{url:t==null||(l=t.config)===null||l===void 0?void 0:l.baseURL,method:t==null||(c=t.config)===null||c===void 0||(u=c.method)===null||u===void 0?void 0:u.toUpperCase(),btUserAgent:t==null||(f=t.config)===null||f===void 0||(g=f.headers)===null||g===void 0?void 0:g[Pe.CLIENT_USER_AGENT_HEADER]},errorDetails:{code:t==null?void 0:t.code,name:t==null?void 0:t.name,stack:t==null?void 0:t.stack,headers:t==null||(m=t.response)===null||m===void 0?void 0:m.headers,message:t==null?void 0:t.message,status:t==null||(d=t.response)===null||d===void 0?void 0:d.status,statusText:t==null||(h=t.response)===null||h===void 0?void 0:h.statusText,data:t==null||(p=t.response)===null||p===void 0?void 0:p.data}}),new Wh.BasisTheoryApiError(t.message,S,C,E)},ly=t=>Su(t,!1);v.errorInterceptor=ly;var uy=t=>Su(t,!0);v.errorInterceptorDebug=uy;var dy=(t={})=>{let e=Object.keys(t);if(e.length){let n=new URLSearchParams,r=(s,o,i=!1)=>{let a=typeof o,l=i?s:(0,Gh.snakeCase)(s);(o===null||["boolean","number","string"].includes(a))&&n.append(l,o)};return e.forEach(s=>{let o=t[s];Array.isArray(o)?o.forEach(i=>{r(String(s),i)}):o&&typeof o=="object"?Object.keys(o).forEach(a=>{r("".concat(String(s),".").concat(a),o[a],!0)}):r(String(s),o)}),"?".concat(n.toString())}return""};v.getQueryParams=dy;var fy=t=>"(".concat(t.name||"","; ").concat(t.version||"","; ").concat(t.url||"",")"),py=t=>{let e="".concat(Pe.USER_AGENT_CLIENT,"/unknown");return t&&Object.keys(t||{}).length&&(e+=" ".concat(fy(t))),e};v.buildUserAgentString=py;var Eu=()=>{let{userAgent:t}=window.navigator,e="unknown",n=Pe.BROWSER_LIST.find(r=>t.includes(r.browserUA));if(n)try{e=t.split("".concat(n.browserUA,"/"))[1]}catch(r){e="unknown"}return"".concat((n==null?void 0:n.browserName)||"unknown","/").concat(e)};v.getBrowser=Eu;var Cu=()=>typeof window=="object"&&window.navigator.product==="ReactNative",Tu=()=>{if(Cu())return"ReactNative";if(typeof window=="undefined")try{return"".concat(bu.default.type(),"/").concat(bu.default.version())}catch(t){return"unknown"}try{let e=window.navigator.appVersion.match(new RegExp("\\(([^)]+)\\)","u"));return e&&e.length>1?e[1]:"unknown"}catch(t){return"unknown"}};v.getOSVersion=Tu;var Ru=()=>Cu()?"ReactNative":typeof window=="undefined"?"NodeJS/".concat(process.version):Eu();v.getRuntime=Ru;var gy=t=>{let e={client:Pe.USER_AGENT_CLIENT,clientVersion:"unknown",osVersion:Tu(),runtimeVersion:Ru(),application:{}};return t&&(e.application=t),JSON.stringify((0,bn.default)(e))};v.buildClientUserAgentString=gy;var my=(t,e)=>(e&&typeof t=="object"&&t!==void 0&&(t._debug=N(w({},t._debug),{cfRay:e[Pe.CF_RAY_HEADER],btTraceId:e[Pe.BT_TRACE_ID_HEADER]})),t);v.debugTransform=my});var vu=R(Nr=>{"use strict";Object.defineProperty(Nr,"__esModule",{value:!0});Nr.BasisTheoryValidationError=void 0;function hy(t){function e(){var n=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(n,Object.getPrototypeOf(this)),n}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}var Xo=class t extends hy(Error){constructor(e,n,r){super(e),this.details=n,this.validation=r,this.name="BasisTheoryValidationError",Object.setPrototypeOf(this,t.prototype)}};Nr.BasisTheoryValidationError=Xo});var Pu=R(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});Lr.HttpClientError=void 0;function yy(t){function e(){var n=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(n,Object.getPrototypeOf(this)),n}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}var Zo=class t extends yy(Error){constructor(e,n,r,s){super(e),this.name="HttpClientError",this.status=n,this.data=r,this.headers=s,Object.setPrototypeOf(this,t.prototype)}};Lr.HttpClientError=Zo});var Q=R(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});var Au={BasisTheoryApiError:!0,BasisTheoryValidationError:!0,HttpClientError:!0};Object.defineProperty(Ae,"BasisTheoryApiError",{enumerable:!0,get:function(){return by.BasisTheoryApiError}});Object.defineProperty(Ae,"BasisTheoryValidationError",{enumerable:!0,get:function(){return wy.BasisTheoryValidationError}});Object.defineProperty(Ae,"HttpClientError",{enumerable:!0,get:function(){return Sy.HttpClientError}});var Qo=fr();Object.keys(Qo).forEach(function(t){t==="default"||t==="__esModule"||Object.prototype.hasOwnProperty.call(Au,t)||t in Ae&&Ae[t]===Qo[t]||Object.defineProperty(Ae,t,{enumerable:!0,get:function(){return Qo[t]}})});var ei=Ut();Object.keys(ei).forEach(function(t){t==="default"||t==="__esModule"||Object.prototype.hasOwnProperty.call(Au,t)||t in Ae&&Ae[t]===ei[t]||Object.defineProperty(Ae,t,{enumerable:!0,get:function(){return ei[t]}})});var by=Go(),wy=vu(),Sy=Pu()});var _u=R(()=>{"use strict"});var Iu=R(Ur=>{"use strict";Object.defineProperty(Ur,"__esModule",{value:!0});Ur.BasisTheoryService=void 0;var Br=Ey(ko()),Ue=Q();function Ey(t){return t&&t.__esModule?t:{default:t}}var ti=class{constructor(e){let{apiKey:n,baseURL:r,transformRequest:s,transformResponse:o,appInfo:i,debug:a}=e;if(typeof Br.default=="string")throw new Error("basis-theory-js@1.77.0+ and basis-theory-react@1.12.1+ are not supported with CRA 5, go to https://github.com/Basis-Theory/basis-theory-js/issues/365#issuecomment-1662883062 for workarounds.");this.client=Br.default.create({baseURL:r,headers:w({[Ue.API_KEY_HEADER]:n,[Ue.CLIENT_USER_AGENT_HEADER]:(0,Ue.buildClientUserAgentString)(i)},typeof window=="undefined"&&{[Ue.USER_AGENT_HEADER]:(0,Ue.buildUserAgentString)(i)}),transformRequest:[].concat(s||Ue.transformRequestSnakeCase,Br.default.defaults.transformRequest),transformResponse:Br.default.defaults.transformResponse.concat(o||Ue.transformResponseCamelCase,a?Ue.debugTransform:[])}),this.client.interceptors.response.use(void 0,a?Ue.errorInterceptorDebug:Ue.errorInterceptor)}};Ur.BasisTheoryService=ti});var ee=R(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});var ni=_u();Object.keys(ni).forEach(function(t){t==="default"||t==="__esModule"||t in Ge&&Ge[t]===ni[t]||Object.defineProperty(Ge,t,{enumerable:!0,get:function(){return ni[t]}})});var ri=Iu();Object.keys(ri).forEach(function(t){t==="default"||t==="__esModule"||t in Ge&&Ge[t]===ri[t]||Object.defineProperty(Ge,t,{enumerable:!0,get:function(){return ri[t]}})})});var _e=R(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.CrudBuilder=void 0;var ce=Q(),Cy=t=>class extends t{create(n,r){return this.client.post("/",n,(0,ce.createRequestConfig)(r)).then(ce.dataExtractor)}},Ty=t=>class extends t{retrieve(n,r){return this.client.get(n,(0,ce.createRequestConfig)(r)).then(ce.dataExtractor)}},Ry=t=>class extends t{update(n,r,s){return this.client.put(n,r,(0,ce.createRequestConfig)(s)).then(ce.dataExtractor)}},vy=t=>class extends t{patch(n,r,s){let o=(0,ce.createRequestConfig)(s);return this.client.patch(n,r,N(w({},o),{headers:N(w({},(o==null?void 0:o.headers)||{}),{[ce.CONTENT_TYPE_HEADER]:ce.MERGE_CONTENT_TYPE})})).then(ce.dataExtractor)}},Py=t=>class extends t{async delete(n,r){await this.client.delete(n,(0,ce.createRequestConfig)(r))}},Ay=t=>class extends t{list(n={},r={}){let s="/".concat((0,ce.getQueryParams)(n));return this.client.get(s,(0,ce.createRequestConfig)(r)).then(ce.dataExtractor)}},si=class{constructor(e){this.BaseService=e}create(){return this.BaseService=Cy(this.BaseService),this}retrieve(){return this.BaseService=Ty(this.BaseService),this}update(){return this.BaseService=Ry(this.BaseService),this}patch(){return this.BaseService=vy(this.BaseService),this}delete(){return this.BaseService=Py(this.BaseService),this}list(){return this.BaseService=Ay(this.BaseService),this}build(){return this.BaseService}};Mr.CrudBuilder=si});var Ou=R(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.BasisTheoryApplicationTemplates=void 0;var xu=Q(),_y=ee(),Iy=_e(),xy=new Iy.CrudBuilder(class extends _y.BasisTheoryService{list(e){return this.client.get("/",(0,xu.createRequestConfig)(e)).then(xu.dataExtractor)}}).retrieve().build();Fr.BasisTheoryApplicationTemplates=xy});var ku=R(oi=>{"use strict";Object.defineProperty(oi,"__esModule",{value:!0});Object.defineProperty(oi,"BasisTheoryApplicationTemplates",{enumerable:!0,get:function(){return Oy.BasisTheoryApplicationTemplates}});var Oy=Ou()});var Du=R(qr=>{"use strict";Object.defineProperty(qr,"__esModule",{value:!0});qr.BasisTheoryApplicationKeys=void 0;var $r=Q(),ky=ee(),Dy=_e(),Ny=new Dy.CrudBuilder(class extends ky.BasisTheoryService{create(e){return this.client.post("".concat(e,"/keys")).then($r.dataExtractor)}get(e){return this.client.get("".concat(e,"/keys")).then($r.dataExtractor)}getById(e,n){return this.client.get("".concat(e,"/keys/").concat(n)).then($r.dataExtractor)}delete(e,n){return this.client.delete("".concat(e,"/keys/").concat(n)).then($r.dataExtractor)}}).build();qr.BasisTheoryApplicationKeys=Ny});var Nu=R(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});Object.defineProperty(ii,"BasisTheoryApplicationKeys",{enumerable:!0,get:function(){return Ly.BasisTheoryApplicationKeys}});var Ly=Du()});var Lu=R(Hr=>{"use strict";Object.defineProperty(Hr,"__esModule",{value:!0});Hr.BasisTheoryApplications=void 0;var jr=Q(),By=ee(),Uy=_e(),My=new Uy.CrudBuilder(class extends By.BasisTheoryService{getApplicationByKey(){return this.retrieveByKey()}retrieveByKey(e){return this.client.get("/key",(0,jr.createRequestConfig)(e)).then(jr.dataExtractor)}regenerateKey(e,n){return this.client.post("".concat(e,"/regenerate"),void 0,(0,jr.createRequestConfig)(n)).then(jr.dataExtractor)}}).create().retrieve().update().delete().list().build();Hr.BasisTheoryApplications=My});var ci=R(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});Object.defineProperty(ai,"BasisTheoryApplications",{enumerable:!0,get:function(){return Fy.BasisTheoryApplications}});var Fy=Lu()});var Bu=R(zr=>{"use strict";Object.defineProperty(zr,"__esModule",{value:!0});zr.BasisTheoryTokenize=void 0;var Kr=Q(),$y=ee(),li=class extends $y.BasisTheoryService{tokenize(e,n={}){return this.client.post("/",e,(0,Kr.createRequestConfig)(n,{transformRequest:Kr.proxyRaw,transformResponse:Kr.proxyRaw})).then(Kr.dataExtractor)}};zr.BasisTheoryTokenize=li});var Uu=R(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});Object.defineProperty(ui,"BasisTheoryTokenize",{enumerable:!0,get:function(){return qy.BasisTheoryTokenize}});var qy=Bu()});var Mu=R(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.delegateTokenize=void 0;var jy=Uu(),Hy=t=>class extends jy.BasisTheoryTokenize{tokenize(n,r){return t!=null&&t.hasElement(n)?t.tokenize(n,r):super.tokenize(n,r)}};Vr.delegateTokenize=Hy});var Fu=R(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.BasisTheoryTokens=void 0;var wn=Q(),Sn=Ut(),Ky=ee(),zy=_e(),Vy=new zy.CrudBuilder(class extends Ky.BasisTheoryService{constructor(e){let n=e;n.transformRequest=[].concat(Sn.transformTokenRequestSnakeCase,e.transformRequest||[]),n.transformResponse=[].concat(Sn.transformTokenResponseCamelCase,e.transformResponse||[]),super(n)}retrieve(e,n={}){let r="/".concat(e);return this.client.get(r,(0,wn.createRequestConfig)(n)).then(Sn.dataExtractor)}update(e,n,r={}){let s="/".concat(e),o=(0,wn.createRequestConfig)(r);return this.client.patch(s,n,N(w({},o),{headers:N(w({},(o==null?void 0:o.headers)||{}),{[wn.CONTENT_TYPE_HEADER]:wn.MERGE_CONTENT_TYPE})})).then(Sn.dataExtractor)}search(e,n){return this.client.post("/search",e,(0,wn.createRequestConfig)(n)).then(Sn.dataExtractor)}}).create().delete().list().build();Gr.BasisTheoryTokens=Vy});var fi=R(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});Object.defineProperty(di,"BasisTheoryTokens",{enumerable:!0,get:function(){return Gy.BasisTheoryTokens}});var Gy=Fu()});var $u=R(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.delegateTokens=void 0;var Wy=fi(),Jy=t=>class extends Wy.BasisTheoryTokens{create(n,r){return t!=null&&t.hasElement(n)?t.tokens.create(n,r):super.create(n,r)}update(n,r,s){return t!=null&&t.hasElement(r)?t.tokens.update(n,r,s):super.update(n,r,s)}retrieve(n,r){return t!==void 0?t.tokens.retrieve(n,r):super.retrieve(n,r)}};Wr.delegateTokens=Jy});var qu=R(Jr=>{"use strict";Object.defineProperty(Jr,"__esModule",{value:!0});Jr.BasisTheoryProxy=void 0;var qe=Q(),Yy=ee(),pi=class extends Yy.BasisTheoryService{get(e){return this.proxyRequest("get",e)}post(e){return this.proxyRequest("post",e)}put(e){return this.proxyRequest("put",e)}patch(e){return this.proxyRequest("patch",e)}delete(e){return this.proxyRequest("delete",e)}proxyRequest(e,n){var r;if(e==="post"||e==="put"||e==="patch"){var s,o;let i=n!=null&&n.includeResponseHeaders&&e==="post"?qe.dataAndHeadersExtractor:qe.dataExtractor;return this.client[e]((s=n==null?void 0:n.path)!==null&&s!==void 0?s:"",(o=n==null?void 0:n.body)!==null&&o!==void 0?o:void 0,(0,qe.createRequestConfig)(n,{transformRequest:qe.proxyRaw,transformResponse:qe.proxyRaw})).then(i)}return this.client[e]((r=n==null?void 0:n.path)!==null&&r!==void 0?r:"/",(0,qe.createRequestConfig)(n,{transformRequest:qe.proxyRaw,transformResponse:qe.proxyRaw})).then(qe.dataExtractor)}};Jr.BasisTheoryProxy=pi});var ju=R(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});var gi=qu();Object.keys(gi).forEach(function(t){t==="default"||t==="__esModule"||t in En&&En[t]===gi[t]||Object.defineProperty(En,t,{enumerable:!0,get:function(){return gi[t]}})})});var Hu=R(Yr=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:!0});Yr.delegateProxy=void 0;var Xy=ju(),Zy=t=>class extends Xy.BasisTheoryProxy{get(n){return t!==void 0?t.proxy.get(n):super.get(n)}post(n){return t!==void 0?t.proxy.post(n):super.post(n)}put(n){return t!==void 0?t.proxy.put(n):super.put(n)}patch(n){return t!==void 0?t.proxy.patch(n):super.patch(n)}delete(n){return t!==void 0?t.proxy.delete(n):super.delete(n)}};Yr.delegateProxy=Zy});var zu=R(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.BasisTheoryTokenIntents=void 0;var Ku=Q(),Qy=ee(),eb=_e(),tb=new eb.CrudBuilder(class extends Qy.BasisTheoryService{constructor(e){let n=e;n.transformRequest=[].concat(Ku.transformTokenRequestSnakeCase,e.transformRequest||[]),n.transformResponse=[].concat(Ku.transformTokenResponseCamelCase,e.transformResponse||[]),super(n)}}).create().delete().build();Xr.BasisTheoryTokenIntents=tb});var Vu=R(mi=>{"use strict";Object.defineProperty(mi,"__esModule",{value:!0});Object.defineProperty(mi,"BasisTheoryTokenIntents",{enumerable:!0,get:function(){return nb.BasisTheoryTokenIntents}});var nb=zu()});var Gu=R(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.delegateTokenIntents=void 0;var rb=Vu(),sb=t=>class extends rb.BasisTheoryTokenIntents{create(n,r){return t!=null&&t.hasElement(n)?t.tokenIntents.create(n,r):super.create(n,r)}};Zr.delegateTokenIntents=sb});var Wu=R(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});var hi=Mu();Object.keys(hi).forEach(function(t){t==="default"||t==="__esModule"||t in le&&le[t]===hi[t]||Object.defineProperty(le,t,{enumerable:!0,get:function(){return hi[t]}})});var yi=$u();Object.keys(yi).forEach(function(t){t==="default"||t==="__esModule"||t in le&&le[t]===yi[t]||Object.defineProperty(le,t,{enumerable:!0,get:function(){return yi[t]}})});var bi=Hu();Object.keys(bi).forEach(function(t){t==="default"||t==="__esModule"||t in le&&le[t]===bi[t]||Object.defineProperty(le,t,{enumerable:!0,get:function(){return bi[t]}})});var wi=Gu();Object.keys(wi).forEach(function(t){t==="default"||t==="__esModule"||t in le&&le[t]===wi[t]||Object.defineProperty(le,t,{enumerable:!0,get:function(){return wi[t]}})})});var Si=R(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.injectScript=Mt.findScript=void 0;var ob=t=>document.querySelector('script[src^="'.concat(t,'"]'));Mt.findScript=ob;var ib=t=>{let e=document.createElement("script");e.src=t;let n=document.head||document.body;if(!n)throw new Error("No <head> or <body> elements found in document.");return n.append(e),e};Mt.injectScript=ib});var Ei=R(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=X.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=X.ELEMENTS_SCRIPT_FAILED_TO_DELIVER=X.ELEMENTS_NOM_DOM_ERROR_MESSAGE=X.ELEMENTS_INIT_ERROR_MESSAGE=X.CARD_ICON_POSITIONS=X.CARD_BRANDS=X.AUTOCOMPLETE_VALUES=void 0;var ab="BasisTheory Elements was not properly initialized.";X.ELEMENTS_INIT_ERROR_MESSAGE=ab;var cb="Tried to load BasisTheoryElements in a non-DOM environment.";X.ELEMENTS_NOM_DOM_ERROR_MESSAGE=cb;var lb="Basis Theory Elements did not load properly. Check network tab for more details.";X.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=lb;var ub="Unable to load the Elements script. This may be due to network restrictions or browser extensions like ad blockers interfering with script loading. Check browser settings or network connection and try again.";X.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=ub;var db="Failed to deliver Elements script from Basis Theory. Check your network connection and try again or contact support@basistheory.com";X.ELEMENTS_SCRIPT_FAILED_TO_DELIVER=db;var fb=["visa","mastercard","american-express","discover","diners-club","jcb","unionpay","maestro","elo","hiper","hipercard","mir","unknown"];X.CARD_BRANDS=fb;var pb=["left","right","none"];X.CARD_ICON_POSITIONS=pb;var gb=["additional-name","address-level1","address-level2","address-level3","address-level4","address-line1","address-line2","address-line3","bday-day","bday-month","bday-year","bday","billing","cc-additional-name","cc-csc","cc-exp-month","cc-exp-year","cc-exp","cc-family-name","cc-given-name","cc-name","cc-number","cc-type","country-name","country","current-password","email","family-name","fax","given-name","home","honorific-prefix","honorific-suffix","language","mobile","name","new-password","nickname","off","on","one-time-code","organization-title","organization","page","postal-code","sex","shipping","street-address","tel-area-code","tel-country-code","tel-extension","tel-local-prefix","tel-local-suffix","tel-local","tel-national","tel","transaction-amount","transaction-currency","url","username","work"];X.AUTOCOMPLETE_VALUES=gb});var Yu=R(Qr=>{"use strict";Object.defineProperty(Qr,"__esModule",{value:!0});Qr.loadElements=void 0;var We=kr(),nt=Ei(),Ci=Si(),Ti,Ju=(t,e)=>new Promise((n,r)=>{let s=(0,Ci.findScript)(t);if(!s)s=(0,Ci.injectScript)(t);else{if(window.BasisTheoryElements){n(window.BasisTheoryElements);return}if(e>0){try{var o;(o=s)===null||o===void 0||o.remove()}catch(i){(async()=>await We.logger.log.error("Error removing script from DOM on retry attempt ".concat(e),{logType:"scriptRemovalError",logOrigin:"loadScript",retryCount:e,removalError:i}))(),r(new Error(nt.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE));return}s=(0,Ci.injectScript)(t)}}s.addEventListener("load",()=>{if(window.BasisTheoryElements){n(window.BasisTheoryElements);return}(async()=>await We.logger.log.error("Elements not found on window on load",{logType:"elementsNotFoundOnWindow",logOrigin:"loadScript",retryCount:e}))(),r(new Error(nt.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE))}),s.addEventListener("error",async i=>{if(await We.logger.log.error("Elements script onError event",{logType:"elementsScriptOnError",logOrigin:"loadScript",retryCount:e,event:{message:i==null?void 0:i.message,source:i==null?void 0:i.filename,lineno:i==null?void 0:i.lineno,colno:i==null?void 0:i.colno,error:i==null?void 0:i.error,target:i==null?void 0:i.target}}),e===0){Ju(t,e+1).then(n).catch(r);return}try{let l=await fetch(t),c,u;try{u=await l.text(),c=JSON.parse(u)}catch(f){var a;c=(a=u)!==null&&a!==void 0?a:""}if(!l.ok){await We.logger.log.error("Second attempt to load elements script failed, fetch failed with status: ".concat(l.status,"."),{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:e,fetchResult:"error",fetchResponse:c,fetchHeaders:l.headers,fetchStatusText:l.statusText}),r(new Error(nt.ELEMENTS_SCRIPT_FAILED_TO_DELIVER));return}await We.logger.log.error("Second attempt to load elements script failed, fetch success",{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:e,fetchResult:"success",fetchResponse:c,fetchHeaders:l.headers,fetchStatusText:l.statusText}),r(new Error(nt.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE));return}catch(l){await We.logger.log.error("Second attempt failed to load elements script failed, fetch network error.",{logType:"elementsScriptFetchError",logOrigin:"loadScript",retryCount:e,fetchResult:"error",fetchError:JSON.stringify(l!=null?l:"Unknown Error")}),r(new Error(nt.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE));return}})}),mb=t=>(Ti||(Ti=new Promise((e,n)=>{if(typeof window!="object"){(async()=>(await We.logger.log.warn(nt.ELEMENTS_NOM_DOM_ERROR_MESSAGE,{logType:"elementsNonDomError",logOrigin:"loadElements"}),n(new Error(nt.ELEMENTS_NOM_DOM_ERROR_MESSAGE))))();return}if(window.BasisTheoryElements){e(window.BasisTheoryElements);return}let r="https://js.basistheory.com/web-elements/1.5.0/client/index.js";if(typeof t!="undefined")try{r=new URL(t).toString().replace(new RegExp("\\/$","u"),"")}catch(s){throw(async()=>await We.logger.log.warn("Invalid format for the given Elements client url.",{logType:"invalidClientUrlError",logOrigin:"loadElements"}))(),new Error("Invalid format for the given Elements client url.")}Ju(r,0).then(e).catch(s=>{n(s)})})),Ti);Qr.loadElements=mb});var Xu=R(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});var Ri=Wu();Object.keys(Ri).forEach(function(t){t==="default"||t==="__esModule"||t in Ie&&Ie[t]===Ri[t]||Object.defineProperty(Ie,t,{enumerable:!0,get:function(){return Ri[t]}})});var vi=Si();Object.keys(vi).forEach(function(t){t==="default"||t==="__esModule"||t in Ie&&Ie[t]===vi[t]||Object.defineProperty(Ie,t,{enumerable:!0,get:function(){return vi[t]}})});var Pi=Yu();Object.keys(Pi).forEach(function(t){t==="default"||t==="__esModule"||t in Ie&&Ie[t]===Pi[t]||Object.defineProperty(Ie,t,{enumerable:!0,get:function(){return Pi[t]}})})});var Zu=R(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.BasisTheoryLogs=void 0;var hb=ee(),yb=_e(),bb=new yb.CrudBuilder(class extends hb.BasisTheoryService{}).list().build();es.BasisTheoryLogs=bb});var Qu=R(Ai=>{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0});Object.defineProperty(Ai,"BasisTheoryLogs",{enumerable:!0,get:function(){return wb.BasisTheoryLogs}});var wb=Zu()});var ed=R(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.BasisTheoryPermissions=void 0;var _i=Q(),Sb=ee(),Ii=class extends Sb.BasisTheoryService{list(e,n){let r="/".concat((0,_i.getQueryParams)(e));return this.client.get(r,(0,_i.createRequestConfig)(n)).then(_i.dataExtractor)}};ts.BasisTheoryPermissions=Ii});var td=R(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});Object.defineProperty(xi,"BasisTheoryPermissions",{enumerable:!0,get:function(){return Eb.BasisTheoryPermissions}});var Eb=ed()});var rd=R(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.BasisTheoryProxies=void 0;var nd=Ut(),Cb=ee(),Tb=_e(),Rb=new Tb.CrudBuilder(class extends Cb.BasisTheoryService{constructor(e){let n=w({},e);n.transformRequest=[].concat(nd.transformProxyRequestSnakeCase,e.transformRequest||[]),n.transformResponse=[].concat(nd.transformProxyResponseCamelCase,e.transformResponse||[]),super(n)}}).create().retrieve().update().patch().delete().list().build();ns.BasisTheoryProxies=Rb});var sd=R(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});var Oi=rd();Object.keys(Oi).forEach(function(t){t==="default"||t==="__esModule"||t in Cn&&Cn[t]===Oi[t]||Object.defineProperty(Cn,t,{enumerable:!0,get:function(){return Oi[t]}})})});var od=R(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.BasisTheoryReactorFormulas=void 0;var vb=ee(),Pb=_e(),Ab=new Pb.CrudBuilder(class extends vb.BasisTheoryService{}).create().retrieve().update().delete().list().build();rs.BasisTheoryReactorFormulas=Ab});var id=R(ki=>{"use strict";Object.defineProperty(ki,"__esModule",{value:!0});Object.defineProperty(ki,"BasisTheoryReactorFormulas",{enumerable:!0,get:function(){return _b.BasisTheoryReactorFormulas}});var _b=od()});var cd=R(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});os.BasisTheoryReactors=void 0;var ss=Q(),ad=Ut(),Ib=ee(),xb=_e(),Ob=new xb.CrudBuilder(class extends Ib.BasisTheoryService{constructor(e){let n=w({},e);n.transformRequest=[].concat(ad.transformReactorRequestSnakeCase,e.transformRequest||[]),n.transformResponse=[].concat(ad.transformReactorResponseCamelCase,e.transformResponse||[]),super(n)}react(e,n,r){return this.client.post("/".concat(e,"/react"),n,(0,ss.createRequestConfig)(r,{transformRequest:ss.proxyRaw,transformResponse:ss.proxyRaw})).then(ss.dataExtractor)}}).create().retrieve().update().patch().delete().list().build();os.BasisTheoryReactors=Ob});var ld=R(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Object.defineProperty(Di,"BasisTheoryReactors",{enumerable:!0,get:function(){return kb.BasisTheoryReactors}});var kb=cd()});var dd=R(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.BasisTheorySessions=void 0;var ud=Q(),is=Ut(),Db=ee(),Ni=class extends Db.BasisTheoryService{constructor(e){let n=w({},e);n.transformRequest=[].concat(is.transformProxyRequestSnakeCase,e.transformRequest||[]),n.transformResponse=[].concat(is.transformProxyResponseCamelCase,e.transformResponse||[]),super(n)}create(e={}){return this.client.post("/",void 0,(0,ud.createRequestConfig)(e)).then(is.dataExtractor)}authorize(e,n={}){return this.client.post("/authorize",e,(0,ud.createRequestConfig)(n)).then(is.dataExtractor)}};as.BasisTheorySessions=Ni});var fd=R(Li=>{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});Object.defineProperty(Li,"BasisTheorySessions",{enumerable:!0,get:function(){return Nb.BasisTheorySessions}});var Nb=dd()});var pd=R(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.BasisTheoryTenants=void 0;var H=Q(),Lb=ee(),Bb=_e(),Ub=new Bb.CrudBuilder(class extends Lb.BasisTheoryService{retrieve(e){return this.client.get("/",(0,H.createRequestConfig)(e)).then(H.dataExtractor)}update(e,n){return this.client.put("/",e,(0,H.createRequestConfig)(n)).then(H.dataExtractor)}async delete(e){await this.client.delete("/",(0,H.createRequestConfig)(e))}retrieveUsageReport(e){return this.client.get("/reports/usage",(0,H.createRequestConfig)(e)).then(H.dataExtractor)}createInvitation(e,n){return this.client.post("/invitations",e,(0,H.createRequestConfig)(n)).then(H.dataExtractor)}resendInvitation(e,n){return this.client.post("/invitations/".concat(e,"/resend"),{},(0,H.createRequestConfig)(n)).then(H.dataExtractor)}listInvitations(e,n){let r="/invitations".concat((0,H.getQueryParams)(e));return this.client.get(r,(0,H.createRequestConfig)(n)).then(H.dataExtractor)}retrieveInvitation(e,n){return this.client.get("/invitations/".concat(e),(0,H.createRequestConfig)(n)).then(H.dataExtractor)}async deleteInvitation(e,n){await this.client.delete("/invitations/".concat(e),(0,H.createRequestConfig)(n))}listMembers(e,n){let r="/members".concat((0,H.getQueryParams)(e));return this.client.get(r,(0,H.createRequestConfig)(n)).then(H.dataExtractor)}async deleteMember(e,n){await this.client.delete("/members/".concat(e),(0,H.createRequestConfig)(n))}}).build();cs.BasisTheoryTenants=Ub});var gd=R(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Object.defineProperty(Bi,"BasisTheoryTenants",{enumerable:!0,get:function(){return Mb.BasisTheoryTenants}});var Mb=pd()});var md=R(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.BasisTheoryThreeDS=void 0;var ls=Q(),Fb=ee(),Ui=class extends Fb.BasisTheoryService{createSession(e){return this.client.post("/sessions",e).then(ls.dataExtractor)}getSessionById(e){return this.client.get("/sessions/".concat(e)).then(ls.dataExtractor)}authenticateSession(e,n){return this.client.post("/sessions/".concat(e,"/authenticate"),n).then(ls.dataExtractor)}getChallengeResult(e){return this.client.get("/sessions/".concat(e,"/challenge-result")).then(ls.dataExtractor)}};us.BasisTheoryThreeDS=Ui});var hd=R(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});var Mi=md();Object.keys(Mi).forEach(function(t){t==="default"||t==="__esModule"||t in Tn&&Tn[t]===Mi[t]||Object.defineProperty(Tn,t,{enumerable:!0,get:function(){return Mi[t]}})})});var yd=R(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.BasisTheory=void 0;var $b=ku(),qb=Nu(),jb=ci(),D=Q(),Hb=kr(),Rn=Xu(),Kb=Ei(),zb=Qu(),Vb=td(),Gb=sd(),Wb=id(),Jb=ld(),Yb=fd(),Xb=gd(),Zb=hd();function Qb(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var ew={apiBaseUrl:D.DEFAULT_BASE_URL,elements:!1,disableTelemetry:!1,debug:!1,appInfo:{}},Fi=class{constructor(){Qb(this,"_initStatus","not-started")}async init(e,n={}){if(this._initStatus!=="not-started"&&this._initStatus!=="error")throw new Error("This BasisTheory instance has been already initialized.");this._initStatus="in-progress";try{this._initOptions=Object.freeze(w(w({},ew),n));let r=this._initOptions.apiBaseUrl;try{let o=new URL(this.initOptions.apiBaseUrl);o.hostname==="localhost"?o.protocol="http":o.protocol="https",r="".concat(o.toString().replace(new RegExp("\\/$","u"),""),"/")}catch(o){throw new Error("Invalid format for the given API base url.")}let s=this._initOptions.appInfo;this._initOptions.elements&&await this.loadElements(e),this._tokens=new((0,Rn.delegateTokens)(this._elements))({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.tokens,r).toString(),appInfo:s,debug:this._initOptions.debug}),this._tokenize=new((0,Rn.delegateTokenize)(this._elements))({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.tokenize,r).toString(),appInfo:s,debug:this._initOptions.debug}),this._applications=new jb.BasisTheoryApplications({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.applications,r).toString(),appInfo:s}),this._applicationKeys=new qb.BasisTheoryApplicationKeys({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.applicationKeys,r).toString(),appInfo:s}),this._applicationTemplates=new $b.BasisTheoryApplicationTemplates({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.applicationTemplates,r).toString(),appInfo:s}),this._tenants=new Xb.BasisTheoryTenants({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.tenants,r).toString(),appInfo:s}),this._logs=new zb.BasisTheoryLogs({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.logs,r).toString(),appInfo:s}),this._reactorFormulas=new Wb.BasisTheoryReactorFormulas({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.reactorFormulas,r).toString(),appInfo:s}),this._reactors=new Jb.BasisTheoryReactors({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.reactors,r).toString(),appInfo:s}),this._permissions=new Vb.BasisTheoryPermissions({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.permissions,r).toString(),appInfo:s}),this._proxies=new Gb.BasisTheoryProxies({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.proxies,r).toString(),appInfo:s}),this._proxy=new((0,Rn.delegateProxy)(this._elements))({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.proxy,r).toString(),appInfo:s,debug:this._initOptions.debug}),this._sessions=new Yb.BasisTheorySessions({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.sessions,r).toString(),appInfo:s,debug:this._initOptions.debug}),this._threeds=new Zb.BasisTheoryThreeDS({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.threeds,r).toString(),appInfo:s}),this._tokenIntents=new((0,Rn.delegateTokenIntents)(this._elements))({apiKey:e,baseURL:new URL(D.CLIENT_BASE_PATHS.tokenIntents,r).toString(),appInfo:s,debug:this._initOptions.debug}),n.disableTelemetry&&Hb.logger.setTelemetryEnabled(!1),this._initStatus="done"}catch(r){throw this._initStatus="error",r}return this}createElement(e,n){if(!this._elements)throw new Error(Kb.ELEMENTS_INIT_ERROR_MESSAGE);return this._elements.createElement(e,n)}tokenize(e,n){return(0,D.assertInit)(this._tokenize).tokenize(e,n)}async loadElements(e){let n;try{n=new URL(this.initOptions.elementsBaseUrl||D.DEFAULT_ELEMENTS_BASE_URL)}catch(l){throw new Error("Invalid format for the given Elements base url.")}let r=await(0,Rn.loadElements)(this.initOptions.elementsClientUrl),s=this.initOptions.elementsUseNgApi||!1,o=this.initOptions.elementsUseSameOriginApi||!1,i=this.initOptions.disableTelemetry||!1,a=this.initOptions.debug||!1;await r.init(e,n.toString().replace(new RegExp("\\/$","u"),""),s,o,i,a),this.elements=r}get initOptions(){return(0,D.assertInit)(this._initOptions)}get tokens(){return(0,D.assertInit)(this._tokens)}get applications(){return(0,D.assertInit)(this._applications)}get applicationKeys(){return(0,D.assertInit)(this._applicationKeys)}get applicationTemplates(){return(0,D.assertInit)(this._applicationTemplates)}get client(){if(this._elements){var e;return(e=this._elements)===null||e===void 0?void 0:e.client}console.error("Elements are not initialized. Either initialize elements or use a regular HTTP client if no elements are needed.")}get tenants(){return(0,D.assertInit)(this._tenants)}get logs(){return(0,D.assertInit)(this._logs)}get reactorFormulas(){return(0,D.assertInit)(this._reactorFormulas)}get reactors(){return(0,D.assertInit)(this._reactors)}get permissions(){return(0,D.assertInit)(this._permissions)}get proxies(){return(0,D.assertInit)(this._proxies)}get proxy(){return(0,D.assertInit)(this._proxy)}get sessions(){return(0,D.assertInit)(this._sessions)}get threeds(){return(0,D.assertInit)(this._threeds)}get tokenIntents(){return(0,D.assertInit)(this._tokenIntents)}get elements(){return(0,D.assertInit)(this._elements)}set elements(e){this._elements=e}};ds.BasisTheory=Fi});var bd=R(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});var ji={_instance:!0};de._instance=void 0;var fs=yd();Object.keys(fs).forEach(function(t){t==="default"||t==="__esModule"||Object.prototype.hasOwnProperty.call(ji,t)||t in de&&de[t]===fs[t]||Object.defineProperty(de,t,{enumerable:!0,get:function(){return fs[t]}})});var $i=ci();Object.keys($i).forEach(function(t){t==="default"||t==="__esModule"||Object.prototype.hasOwnProperty.call(ji,t)||t in de&&de[t]===$i[t]||Object.defineProperty(de,t,{enumerable:!0,get:function(){return $i[t]}})});var qi=fi();Object.keys(qi).forEach(function(t){t==="default"||t==="__esModule"||Object.prototype.hasOwnProperty.call(ji,t)||t in de&&de[t]===qi[t]||Object.defineProperty(de,t,{enumerable:!0,get:function(){return qi[t]}})});var tw=new fs.BasisTheory;de._instance=tw});var Ld={};st(Ld,{BasisTheory3ds:()=>Nd,sdkBaseUrl:()=>ys});function Ew(t){let{messageType:e,messageVersion:n,threeDSServerTransID:r,acsTransID:s,challengeWindowSize:o}=t;return typeof t=="object"&&t!==null&&typeof e=="string"&&typeof n=="string"&&typeof r=="string"&&typeof s=="string"&&Object.values(ms).includes(o)}var je,He,gs,nw,Td,rw,Rd,sw,ow,vd,iw,xe,ms,ps,aw,cw,lw,Pd,uw,Ad,_d,Id,wd,vn,xd,dw,Od,hs,kd,te,Hi,Dd,Sd,fw,Ed,Cd,pw,gw,mw,hw,yw,bw,ww,Sw,Cw,Tw,Rw,vw,ys,Nd,Bd=Oe(()=>{je={FRAME_CONTAINER_ID:"methodFrameContainer",IFRAME_NAME:"methodIframe",FORM_NAME:"threeDSMethodForm",INPUT_NAME:"threeDSMethodData"},He={FRAME_CONTAINER_ID:"challengeFrameContainer",IFRAME_NAME:"challengeIframe",FORM_NAME:"threeDSCReqForm"},gs={IFRAME:"iframe",REDIRECT:"redirect"},nw="BT-API-KEY",Td="BT-TRACE-ID",rw="https://api.basistheory.com",Rd="https://3ds.basistheory.com",sw="pages/method.html",ow="pages/challenge.html",vd=!1,iw=({disableTelemetry:t})=>{vd=t},xe=(()=>{let t="pubb96b84a13912504f4354f2d794ea4fab",e=async(n,r,s,o={})=>{if(vd)return;let i=N(w({application:"3ds-web",ddsource:"3ds-web",service:"3ds-web"},o),{level:r,message:r==="error"&&s?"".concat(n,": ").concat(s.message):n});try{if(!(await fetch("https://http-intake.logs.datadoghq.com/v1/input/".concat(t),{method:"POST",body:JSON.stringify(i),headers:{"Content-Type":"application/json"}})).ok)throw new Error("Network response was not ok")}catch(a){}};return{log:{error:(n,r,s)=>e(n,"error",r,s),info:(n,r)=>e(n,"info",void 0,r),warn:(n,r)=>e(n,"warn",void 0,r)}}})();(function(t){t.ONE="01",t.TWO="02",t.THREE="03",t.FOUR="04",t.FIVE="05"})(ms||(ms={}));ps=t=>t==null?"":JSON.stringify(t),aw=()=>{let t=[1,4,8,15,16,24,32,48],e=window.screen.colorDepth,n=t.filter(r=>r<=e);return n.length===0?t[0]:Math.max(...n)},cw=t=>t==null?void 0:t.split("-").slice(0,2).join("-"),lw=()=>({browserColorDepth:ps(aw()),browserJavascriptEnabled:!0,browserJavaEnabled:window.navigator.javaEnabled(),browserLanguage:cw(window.navigator.language),browserScreenHeight:ps(window.screen.height),browserScreenWidth:ps(window.screen.width),browserTZ:ps(new Date().getTimezoneOffset()),browserUserAgent:window.navigator.userAgent}),Pd=(t="05")=>{let n={"01":["250px","400px"],"02":["390px","400px"],"03":["500px","600px"],"04":["600px","400px"],"05":["100%","100%"]}[t];if(n)return n;{let r=new Error("Window size ".concat(t," is not supported"));throw xe.log.error("Unsupported window size",r),r}},uw=t=>!t||t instanceof HTMLElement,Ad=(t,e,n,r="0",s="0",o)=>{if(!uw(t)||!e||!n){let a="Unable to create iframe. Container must be a HTML element ".concat(JSON.stringify(t)," ").concat(e," ").concat(n);throw xe.log.error("Unable to create iframe",new Error),Error(a)}let i=document.createElement("iframe");return i.name=e,i.width=r,i.height=s,i.setAttribute("id",n),i.setAttribute("frameborder","0"),i.setAttribute("border","0"),o&&typeof o=="function"&&i.addEventListener("onload",o),t.appendChild(i),i},_d=(t,e,n)=>{let r=document.createElement("form");return r.name=t,r.action=e,r.method="POST",r.target=n,r},Id=(t,e)=>{let n=document.createElement("input");return n.name=t,n.value=e,n},wd=(t,e=!1)=>{let n;if(n=document.getElementById(t),n){n.innerHTML="",e&&n.setAttribute("style","display:none;");return}n=document.createElement("div"),n.id=t,e&&n.setAttribute("style","display:none;"),document.body.appendChild(n)},vn=t=>t==null?void 0:t.map(e=>{var n;return(n=document.getElementById(e))==null?void 0:n.remove()}),xd=(t,e)=>{let n=r=>typeof r=="string"?e(r):typeof r!="object"||r===null?r:Array.isArray(r)?r.map(n):Object.fromEntries(Object.entries(r).map(([s,o])=>[e(s),typeof o=="object"||Array.isArray(o)?n(o):o]));return n(t)},dw=t=>xd(t,e=>e.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase()),Od=t=>xd(t,e=>e.replace(/_./g,n=>n[1].toUpperCase())),hs=t=>btoa(JSON.stringify(t)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,""),kd=(()=>{let t,e;return{client:async(s,o,i,a)=>{if(!t)throw Error("Missing api key");e&&xe.log.info("Using custom api base url in 3DS SDK ".concat(e));let l={};return a&&(l[Td]=a),await fetch("".concat(e!=null?e:rw,"/3ds").concat(o),{method:s,body:JSON.stringify(i),headers:w({[nw]:t,"Content-Type":"application/json"},l)})},init:(s,o)=>{t=s,e=o}}})();(function(t){t.METHOD="method",t.CHALLENGE="challenge",t.METHOD_TIME_OUT="methodTimeout",t.START_METHOD_TIME_OUT="startMethodTimeout",t.ERROR="error"})(te||(te={}));Hi=t=>window.postMessage(t,"*"),Dd=t=>typeof t=="object"&&t!==null&&"isCompleted"in t&&typeof t.isCompleted=="boolean"&&"id"in t&&typeof t.id=="string"&&"type"in t&&Object.values(te).includes(t.type),Sd=t=>{var e;return(e={[te.CHALLENGE]:He.IFRAME_NAME,[te.METHOD]:je.IFRAME_NAME,[te.METHOD_TIME_OUT]:je.IFRAME_NAME,[te.ERROR]:"".concat(je.IFRAME_NAME,",").concat(He.IFRAME_NAME),[te.START_METHOD_TIME_OUT]:""}[t])==null?void 0:e.split(",")},fw=t=>{let e;return new Promise((n,r)=>{let s=o=>{var i,a,l,c;if(Dd(o.data)){if(o.data.type===te.ERROR)xe.log.error("Error occurred during session creation: ".concat((i=o==null?void 0:o.data)==null?void 0:i.details)),r(new Error("An error occurred during session creation: ".concat((a=o==null?void 0:o.data)==null?void 0:a.details))),vn(Sd((l=o.data)==null?void 0:l.type)),clearTimeout(e);else if(o.data.type===te.START_METHOD_TIME_OUT)e=setTimeout(()=>{Hi({id:o.data.id,type:te.METHOD_TIME_OUT,isCompleted:!1})},1e4);else if(o.data.type!==te.CHALLENGE){if(o.isTrusted){window.removeEventListener("message",s);let f=(g=>{let m=Od(t),d={id:g.data.id,cardBrand:m.cardBrand,correlationId:m.correlationId};return m.additionalCardBrands&&(d.additionalCardBrands=m.additionalCardBrands),d})(o);n(f),vn(Sd((c=o.data)==null?void 0:c.type)),clearTimeout(e)}}}};window.addEventListener("message",s)})},Ed={},Cd={"The card was not supported by any card schemes":"3DS is not supported for the provided card"},pw=t=>"errors"in t&&t.errors!==void 0&&typeof t.errors=="object"&&t.errors!==null,gw=t=>typeof t=="object"&&t!==null&&("title"in t||"status"in t||"detail"in t),mw=t=>{if(pw(t)){for(let e of Object.keys(t.errors))if(Cd[e])throw new Error(Cd[e])}else if(t.status===424&&t.error){let e=[];t.error.message&&e.push(t.error.message),t.error.details&&e.push("details: "+t.error.details);let n=e.length>0?e.join(" - "):t.title||"An unknown 3DS service error occurred";throw new Error(n)}else if(t.title&&Ed[t.title])throw new Error(Ed[t.title]);throw new Error(t.title||"An unknown error occurred")},hw=(t,e,n)=>{let r=hs({threeDSServerTransID:e,threeDSMethodNotificationURL:"".concat(n,"?mode=redirect")}),s=window.open("","threeDSMethodForm");if(!s){console.error("Popup blocked or unable to open the window.");return}let o=_d(je.FORM_NAME,t,"threeDSMethodForm");o.appendChild(Id(je.INPUT_NAME,r)),document.body.appendChild(o),o.submit();let i=window.setInterval(()=>{s.closed&&(clearInterval(i),Hi({isCompleted:!0,id:e,type:te.METHOD}))},500)},yw=(t,e,n)=>{let r=hs({threeDSServerTransID:e,threeDSMethodNotificationURL:n}),s=document.getElementById(je.FRAME_CONTAINER_ID),o=Ad(s,je.IFRAME_NAME,je.IFRAME_NAME,"0","0");o.src="".concat(ys,"/").concat(sw),o.onload=()=>{var i;(i=o.contentWindow)==null||i.postMessage({type:"startMethod",threeDSMethodURL:t,threeDSMethodData:r},"*")}},bw=async({tokenId:t,tokenIntentId:e,pan:n,skipMethodRequest:r=!1,methodRequestMode:s,challengeMode:o,correlationId:i})=>{var m;let a=[n,t,e].filter(d=>d!==void 0);if(a.length===0)throw new Error("One of pan, tokenId, or tokenIntentId is required.");if(a.length>1)throw new Error("Only one of pan, tokenId, or tokenIntentId should be provided.");let l=n?"pan":t?"tokenId":"tokenIntentId",c=n||t||e,u=lw(),f=await kd.client("POST","/sessions",dw({[l]:c,device:"browser",deviceInfo:u,webChallengeMode:o}),i);if(!f.ok){let d;try{d=await f.json()}catch(h){let p="Failed to parse error response. HTTP Status: ".concat(f.status);throw xe.log.error(p),new Error(p)}if(gw(d))mw(d);else{let h="An unknown error occurred while creating session. Status: ".concat(f.status,".");throw xe.log.error("".concat(h," Response: ").concat(JSON.stringify(d,null,2))),new Error(h)}}let g=Od(await f.json());return g.correlationId=((m=f.headers)==null?void 0:m.get(Td))||"",xe.log.info("3DS session response received with ID ".concat(g.id)),g.methodUrl&&!r&&(Hi({isCompleted:!1,id:g.id,type:te.START_METHOD_TIME_OUT}),s===gs.REDIRECT?hw(g.methodUrl,g.id,g.methodNotificationUrl):yw(g.methodUrl,g.id,g.methodNotificationUrl)),g},ww=async({tokenId:t,tokenIntentId:e,pan:n,skipMethodRequest:r=!1,methodRequestMode:s=gs.IFRAME,challengeMode:o=gs.IFRAME,correlationId:i=""})=>{let a=await bw({tokenId:t,tokenIntentId:e,pan:n,skipMethodRequest:r,methodRequestMode:s,challengeMode:o,correlationId:i}).catch(l=>Promise.reject(l.message));if(!a.methodUrl||r){let l={id:a.id,cardBrand:a.cardBrand};return a.additionalCardBrands&&(l.additionalCardBrands=a.additionalCardBrands),l}return await fw(a)},Sw=(t=6e4)=>{let e;return new Promise((n,r)=>{let s=o=>{var i,a;if(Dd(o.data))if(o.data.type===te.ERROR)xe.log.error("Error occurred during challenge: ".concat((i=o==null?void 0:o.data)==null?void 0:i.details)),r(new Error("An error occurred during challenge: ".concat((a=o==null?void 0:o.data)==null?void 0:a.details))),vn([He.IFRAME_NAME]),clearTimeout(t);else if(o.data.type===te.CHALLENGE){clearTimeout(e),window.removeEventListener("message",s);let c=(u=>({id:u.data.id,isCompleted:u.data.isCompleted,authenticationStatus:u.data.authenticationStatus}))(o);xe.log.info("".concat(o.data.type," notification received for session: ").concat(c.id)),n(c),vn([He.IFRAME_NAME])}else o.isTrusted};window.addEventListener("message",s),e=setTimeout(()=>{window.removeEventListener("message",s),r(new Error("Timed out waiting for a challenge response. Please try again.")),vn([He.IFRAME_NAME])},t)})};Cw=(t,e,n)=>{let r=document.getElementById(n!=null?n:He.FRAME_CONTAINER_ID),s=Pd(e.challengeWindowSize),o=hs(e),i=He.IFRAME_NAME,a=Ad(r,i,i,s[0],s[1]);a.src="".concat(ys,"/").concat(ow),a.onload=()=>{var l;(l=a.contentWindow)==null||l.postMessage({type:"startChallenge",acsURL:t,creq:o},"*")}},Tw=(t,e)=>{let n=Pd(e.challengeWindowSize);if(!window.open("","threeDSChallenge","width=".concat(n[0],",height=").concat(n[1])))throw new Error("Popup blocked or unable to open the window.");let s=hs(e),o=_d(He.FORM_NAME,t,"threeDSChallenge"),i=Id("creq",s);o.appendChild(i),document.body.appendChild(o),o.submit()},Rw=({sessionId:t,acsTransactionId:e,acsChallengeUrl:n,threeDSVersion:r,windowSize:s,mode:o,containerId:i})=>{if(!t)throw new Error("Session ID is required");let a={messageType:"CReq",messageVersion:r,threeDSServerTransID:t,acsTransID:e,challengeWindowSize:s!=null?s:ms.THREE};if(Ew(a))o===gs.REDIRECT?Tw(n,a):Cw(n,a,i);else{let l="Invalid challenge request payload for session: ".concat(t);return xe.log.error(l),Promise.reject(new Error(l))}return Promise.resolve({id:t})},vw=async({sessionId:t,acsTransactionId:e,acsChallengeUrl:n,threeDSVersion:r,windowSize:s,mode:o="iframe",timeout:i=6e4,containerId:a})=>(await Rw({sessionId:t,acsTransactionId:e,acsChallengeUrl:n,threeDSVersion:r,windowSize:s,mode:o,containerId:a}).catch(l=>Promise.reject(l.message)),Sw(i)),ys=Rd,Nd=(t,e)=>{var n,r;try{iw({disableTelemetry:(n=e==null?void 0:e.disableTelemetry)!=null?n:!1}),wd(je.FRAME_CONTAINER_ID,!0),wd(He.FRAME_CONTAINER_ID)}catch(s){xe.log.error("Unable to create iframe container",s)}return ys=(r=e==null?void 0:e.sdkBaseUrl)!=null?r:Rd,kd.init(t,e==null?void 0:e.apiBaseUrl),{createSession:ww,startChallenge:vw}};window.BasisTheory3ds=Nd});var kw={};st(kw,{ApiClient:()=>Ct,CheckoutResource:()=>tr,CheckoutUtils:()=>ao,CurrencyUtils:()=>fn,ExpressPaymentMethodsResource:()=>sr,FunnelActionType:()=>xn,GoogleAutocompleteCore:()=>_t,ISODataCore:()=>ar,OrderBumpUtils:()=>uo,OrderUtils:()=>io,OrdersResource:()=>rr,PaymentService:()=>bs,PaymentsResource:()=>Rt,PluginConfigUtils:()=>Zs,PostPurchasesUtils:()=>lo,ProductsUtils:()=>oo,PromotionsUtils:()=>co,ShippingRatesResource:()=>nr,StoreConfigResource:()=>vt,TagadaApiError:()=>Fe,TagadaAuthError:()=>St,TagadaCircuitBreakerError:()=>Et,TagadaClient:()=>un,TagadaError:()=>Ee,TagadaErrorCode:()=>pe,TagadaExternalTracker:()=>Pn,TagadaNetworkError:()=>wt,TagadaTracker:()=>Ki,TagadaValidationError:()=>Qn,ThreedsResource:()=>Pt,broadcastConfigUpdate:()=>tg,clearFunnelSessionCookie:()=>Ht,createRawPluginConfig:()=>lc,createTagadaClient:()=>zi,debounceConfigUpdate:()=>rg,formatMoney:()=>Qp,funnelQueryKeys:()=>eg,getAssignedPaymentFlowId:()=>Wt,getAssignedStepConfig:()=>be,getBasisTheoryApiKey:()=>xw,getBasisTheoryTenantId:()=>Ow,getFunnelSessionCookie:()=>kn,getFunnelVariantId:()=>Yd,getInternalPath:()=>pn,getPathInfo:()=>xc,getPluginConfig:()=>zp,hasFunnelSessionCookie:()=>Jd,injectStepConfigScripts:()=>Vi,isPathRemapped:()=>Ic,loadLocalConfig:()=>cc,loadPluginConfig:()=>Qs,matchRoute:()=>Oc,onConfigUpdate:()=>ng,sendConfigUpdate:()=>Ec,setFunnelSessionCookie:()=>Ts});_n();dt();function Jt(t,e){return function(){return t.apply(e,arguments)}}var{toString:hf}=Object.prototype,{getPrototypeOf:Is}=Object,{iterator:Fn,toStringTag:Sa}=Symbol,$n=(t=>e=>{let n=hf.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),we=t=>(t=t.toLowerCase(),e=>$n(e)===t),qn=t=>e=>typeof e===t,{isArray:pt}=Array,ft=qn("undefined");function Yt(t){return t!==null&&!ft(t)&&t.constructor!==null&&!ft(t.constructor)&&oe(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}var Ea=we("ArrayBuffer");function yf(t){let e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Ea(t.buffer),e}var bf=qn("string"),oe=qn("function"),Ca=qn("number"),Xt=t=>t!==null&&typeof t=="object",wf=t=>t===!0||t===!1,Mn=t=>{if($n(t)!=="object")return!1;let e=Is(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Sa in t)&&!(Fn in t)},Sf=t=>{if(!Xt(t)||Yt(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch(e){return!1}},Ef=we("Date"),Cf=we("File"),Tf=we("Blob"),Rf=we("FileList"),vf=t=>Xt(t)&&oe(t.pipe),Pf=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||oe(t.append)&&((e=$n(t))==="formdata"||e==="object"&&oe(t.toString)&&t.toString()==="[object FormData]"))},Af=we("URLSearchParams"),[_f,If,xf,Of]=["ReadableStream","Request","Response","Headers"].map(we),kf=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Zt(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t=="undefined")return;let r,s;if(typeof t!="object"&&(t=[t]),pt(t))for(r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else{if(Yt(t))return;let o=n?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length,a;for(r=0;r<i;r++)a=o[r],e.call(null,t[a],a,t)}}function Ta(t,e){if(Yt(t))return null;e=e.toLowerCase();let n=Object.keys(t),r=n.length,s;for(;r-- >0;)if(s=n[r],e===s.toLowerCase())return s;return null}var Ye=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,Ra=t=>!ft(t)&&t!==Ye;function _s(){let{caseless:t,skipUndefined:e}=Ra(this)&&this||{},n={},r=(s,o)=>{let i=t&&Ta(n,o)||o;Mn(n[i])&&Mn(s)?n[i]=_s(n[i],s):Mn(s)?n[i]=_s({},s):pt(s)?n[i]=s.slice():(!e||!ft(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&Zt(arguments[s],r);return n}var Df=(t,e,n,{allOwnKeys:r}={})=>(Zt(e,(s,o)=>{n&&oe(s)?t[o]=Jt(s,n):t[o]=s},{allOwnKeys:r}),t),Nf=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Lf=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},Bf=(t,e,n,r)=>{let s,o,i,a={};if(e=e||{},t==null)return e;do{for(s=Object.getOwnPropertyNames(t),o=s.length;o-- >0;)i=s[o],(!r||r(i,t,e))&&!a[i]&&(e[i]=t[i],a[i]=!0);t=n!==!1&&Is(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},Uf=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;let r=t.indexOf(e,n);return r!==-1&&r===n},Mf=t=>{if(!t)return null;if(pt(t))return t;let e=t.length;if(!Ca(e))return null;let n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},Ff=(t=>e=>t&&e instanceof t)(typeof Uint8Array!="undefined"&&Is(Uint8Array)),$f=(t,e)=>{let r=(t&&t[Fn]).call(t),s;for(;(s=r.next())&&!s.done;){let o=s.value;e.call(t,o[0],o[1])}},qf=(t,e)=>{let n,r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},jf=we("HTMLFormElement"),Hf=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),wa=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),Kf=we("RegExp"),va=(t,e)=>{let n=Object.getOwnPropertyDescriptors(t),r={};Zt(n,(s,o)=>{let i;(i=e(s,o,t))!==!1&&(r[o]=i||s)}),Object.defineProperties(t,r)},zf=t=>{va(t,(e,n)=>{if(oe(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;let r=t[n];if(oe(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Vf=(t,e)=>{let n={},r=s=>{s.forEach(o=>{n[o]=!0})};return pt(t)?r(t):r(String(t).split(e)),n},Gf=()=>{},Wf=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function Jf(t){return!!(t&&oe(t.append)&&t[Sa]==="FormData"&&t[Fn])}var Yf=t=>{let e=new Array(10),n=(r,s)=>{if(Xt(r)){if(e.indexOf(r)>=0)return;if(Yt(r))return r;if(!("toJSON"in r)){e[s]=r;let o=pt(r)?[]:{};return Zt(r,(i,a)=>{let l=n(i,s+1);!ft(l)&&(o[a]=l)}),e[s]=void 0,o}}return r};return n(t,0)},Xf=we("AsyncFunction"),Zf=t=>t&&(Xt(t)||oe(t))&&oe(t.then)&&oe(t.catch),Pa=((t,e)=>t?setImmediate:e?((n,r)=>(Ye.addEventListener("message",({source:s,data:o})=>{s===Ye&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),Ye.postMessage(n,"*")}))("axios@".concat(Math.random()),[]):n=>setTimeout(n))(typeof setImmediate=="function",oe(Ye.postMessage)),Qf=typeof queueMicrotask!="undefined"?queueMicrotask.bind(Ye):typeof process!="undefined"&&process.nextTick||Pa,ep=t=>t!=null&&oe(t[Fn]),y={isArray:pt,isArrayBuffer:Ea,isBuffer:Yt,isFormData:Pf,isArrayBufferView:yf,isString:bf,isNumber:Ca,isBoolean:wf,isObject:Xt,isPlainObject:Mn,isEmptyObject:Sf,isReadableStream:_f,isRequest:If,isResponse:xf,isHeaders:Of,isUndefined:ft,isDate:Ef,isFile:Cf,isBlob:Tf,isRegExp:Kf,isFunction:oe,isStream:vf,isURLSearchParams:Af,isTypedArray:Ff,isFileList:Rf,forEach:Zt,merge:_s,extend:Df,trim:kf,stripBOM:Nf,inherits:Lf,toFlatObject:Bf,kindOf:$n,kindOfTest:we,endsWith:Uf,toArray:Mf,forEachEntry:$f,matchAll:qf,isHTMLForm:jf,hasOwnProperty:wa,hasOwnProp:wa,reduceDescriptors:va,freezeMethods:zf,toObjectSet:Vf,toCamelCase:Hf,noop:Gf,toFiniteNumber:Wf,findKey:Ta,global:Ye,isContextDefined:Ra,isSpecCompliantForm:Jf,toJSONObject:Yf,isAsyncFn:Xf,isThenable:Zf,setImmediate:Pa,asap:Qf,isIterable:ep};function gt(t,e,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}y.inherits(gt,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:y.toJSONObject(this.config),code:this.code,status:this.status}}});var Aa=gt.prototype,_a={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{_a[t]={value:t}});Object.defineProperties(gt,_a);Object.defineProperty(Aa,"isAxiosError",{value:!0});gt.from=(t,e,n,r,s,o)=>{let i=Object.create(Aa);y.toFlatObject(t,i,function(u){return u!==Error.prototype},c=>c!=="isAxiosError");let a=t&&t.message?t.message:"Error",l=e==null&&t?t.code:e;return gt.call(i,a,l,n,r,s),t&&i.cause==null&&Object.defineProperty(i,"cause",{value:t,configurable:!0}),i.name=t&&t.name||"Error",o&&Object.assign(i,o),i};var _=gt;var jn=null;function xs(t){return y.isPlainObject(t)||y.isArray(t)}function xa(t){return y.endsWith(t,"[]")?t.slice(0,-2):t}function Ia(t,e,n){return t?t.concat(e).map(function(s,o){return s=xa(s),!n&&o?"["+s+"]":s}).join(n?".":""):e}function tp(t){return y.isArray(t)&&!t.some(xs)}var np=y.toFlatObject(y,{},null,function(e){return/^is[A-Z]/.test(e)});function rp(t,e,n){if(!y.isObject(t))throw new TypeError("target must be an object");e=e||new(jn||FormData),n=y.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,p){return!y.isUndefined(p[h])});let r=n.metaTokens,s=n.visitor||u,o=n.dots,i=n.indexes,l=(n.Blob||typeof Blob!="undefined"&&Blob)&&y.isSpecCompliantForm(e);if(!y.isFunction(s))throw new TypeError("visitor must be a function");function c(d){if(d===null)return"";if(y.isDate(d))return d.toISOString();if(y.isBoolean(d))return d.toString();if(!l&&y.isBlob(d))throw new _("Blob is not supported. Use a Buffer instead.");return y.isArrayBuffer(d)||y.isTypedArray(d)?l&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function u(d,h,p){let S=d;if(d&&!p&&typeof d=="object"){if(y.endsWith(h,"{}"))h=r?h:h.slice(0,-2),d=JSON.stringify(d);else if(y.isArray(d)&&tp(d)||(y.isFileList(d)||y.endsWith(h,"[]"))&&(S=y.toArray(d)))return h=xa(h),S.forEach(function(E,T){!(y.isUndefined(E)||E===null)&&e.append(i===!0?Ia([h],T,o):i===null?h:h+"[]",c(E))}),!1}return xs(d)?!0:(e.append(Ia(p,h,o),c(d)),!1)}let f=[],g=Object.assign(np,{defaultVisitor:u,convertValue:c,isVisitable:xs});function m(d,h){if(!y.isUndefined(d)){if(f.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(d),y.forEach(d,function(S,C){(!(y.isUndefined(S)||S===null)&&s.call(e,S,y.isString(C)?C.trim():C,h,g))===!0&&m(S,h?h.concat(C):[C])}),f.pop()}}if(!y.isObject(t))throw new TypeError("data must be an object");return m(t),e}var Ve=rp;function Oa(t){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function ka(t,e){this._pairs=[],t&&Ve(t,this,e)}var Da=ka.prototype;Da.append=function(e,n){this._pairs.push([e,n])};Da.toString=function(e){let n=e?function(r){return e.call(this,r,Oa)}:Oa;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};var Hn=ka;function sp(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Qt(t,e,n){if(!e)return t;let r=n&&n.encode||sp;y.isFunction(n)&&(n={serialize:n});let s=n&&n.serialize,o;if(s?o=s(e,n):o=y.isURLSearchParams(e)?e.toString():new Hn(e,n).toString(r),o){let i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}var Os=class{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){y.forEach(this.handlers,function(r){r!==null&&e(r)})}},ks=Os;var Kn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Na=typeof URLSearchParams!="undefined"?URLSearchParams:Hn;var La=typeof FormData!="undefined"?FormData:null;var Ba=typeof Blob!="undefined"?Blob:null;var Ua={isBrowser:!0,classes:{URLSearchParams:Na,FormData:La,Blob:Ba},protocols:["http","https","file","blob","url","data"]};var Ls={};st(Ls,{hasBrowserEnv:()=>Ns,hasStandardBrowserEnv:()=>op,hasStandardBrowserWebWorkerEnv:()=>ip,navigator:()=>Ds,origin:()=>ap});var Ns=typeof window!="undefined"&&typeof document!="undefined",Ds=typeof navigator=="object"&&navigator||void 0,op=Ns&&(!Ds||["ReactNative","NativeScript","NS"].indexOf(Ds.product)<0),ip=typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ap=Ns&&window.location.href||"http://localhost";var $=w(w({},Ls),Ua);function Bs(t,e){return Ve(t,new $.classes.URLSearchParams,w({visitor:function(n,r,s,o){return $.isNode&&y.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},e))}function cp(t){return y.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function lp(t){let e={},n=Object.keys(t),r,s=n.length,o;for(r=0;r<s;r++)o=n[r],e[o]=t[o];return e}function up(t){function e(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;let a=Number.isFinite(+i),l=o>=n.length;return i=!i&&y.isArray(s)?s.length:i,l?(y.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!a):((!s[i]||!y.isObject(s[i]))&&(s[i]=[]),e(n,r,s[i],o)&&y.isArray(s[i])&&(s[i]=lp(s[i])),!a)}if(y.isFormData(t)&&y.isFunction(t.entries)){let n={};return y.forEachEntry(t,(r,s)=>{e(cp(r),s,n,0)}),n}return null}var zn=up;function dp(t,e,n){if(y.isString(t))try{return(e||JSON.parse)(t),y.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}var Us={transitional:Kn,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){let r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=y.isObject(e);if(o&&y.isHTMLForm(e)&&(e=new FormData(e)),y.isFormData(e))return s?JSON.stringify(zn(e)):e;if(y.isArrayBuffer(e)||y.isBuffer(e)||y.isStream(e)||y.isFile(e)||y.isBlob(e)||y.isReadableStream(e))return e;if(y.isArrayBufferView(e))return e.buffer;if(y.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Bs(e,this.formSerializer).toString();if((a=y.isFileList(e))||r.indexOf("multipart/form-data")>-1){let l=this.env&&this.env.FormData;return Ve(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),dp(e)):e}],transformResponse:[function(e){let n=this.transitional||Us.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(y.isResponse(e)||y.isReadableStream(e))return e;if(e&&y.isString(e)&&(r&&!this.responseType||s)){let i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?_.from(a,_.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:$.classes.FormData,Blob:$.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};y.forEach(["delete","get","head","post","put","patch"],t=>{Us.headers[t]={}});var mt=Us;var fp=y.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Ma=t=>{let e={},n,r,s;return t&&t.split("\n").forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||e[n]&&fp[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e};var Fa=Symbol("internals");function en(t){return t&&String(t).trim().toLowerCase()}function Vn(t){return t===!1||t==null?t:y.isArray(t)?t.map(Vn):String(t)}function pp(t){let e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}var gp=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Ms(t,e,n,r,s){if(y.isFunction(r))return r.call(this,e,n);if(s&&(e=n),!!y.isString(e)){if(y.isString(r))return e.indexOf(r)!==-1;if(y.isRegExp(r))return r.test(e)}}function mp(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function hp(t,e){let n=y.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(s,o,i){return this[r].call(this,e,s,o,i)},configurable:!0})})}var ht=class{constructor(e){e&&this.set(e)}set(e,n,r){let s=this;function o(a,l,c){let u=en(l);if(!u)throw new Error("header name must be a non-empty string");let f=y.findKey(s,u);(!f||s[f]===void 0||c===!0||c===void 0&&s[f]!==!1)&&(s[f||l]=Vn(a))}let i=(a,l)=>y.forEach(a,(c,u)=>o(c,u,l));if(y.isPlainObject(e)||e instanceof this.constructor)i(e,n);else if(y.isString(e)&&(e=e.trim())&&!gp(e))i(Ma(e),n);else if(y.isObject(e)&&y.isIterable(e)){let a={},l,c;for(let u of e){if(!y.isArray(u))throw TypeError("Object iterator must return a key-value pair");a[c=u[0]]=(l=a[c])?y.isArray(l)?[...l,u[1]]:[l,u[1]]:u[1]}i(a,n)}else e!=null&&o(n,e,r);return this}get(e,n){if(e=en(e),e){let r=y.findKey(this,e);if(r){let s=this[r];if(!n)return s;if(n===!0)return pp(s);if(y.isFunction(n))return n.call(this,s,r);if(y.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=en(e),e){let r=y.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||Ms(this,this[r],r,n)))}return!1}delete(e,n){let r=this,s=!1;function o(i){if(i=en(i),i){let a=y.findKey(r,i);a&&(!n||Ms(r,r[a],a,n))&&(delete r[a],s=!0)}}return y.isArray(e)?e.forEach(o):o(e),s}clear(e){let n=Object.keys(this),r=n.length,s=!1;for(;r--;){let o=n[r];(!e||Ms(this,this[o],o,e,!0))&&(delete this[o],s=!0)}return s}normalize(e){let n=this,r={};return y.forEach(this,(s,o)=>{let i=y.findKey(r,o);if(i){n[i]=Vn(s),delete n[o];return}let a=e?mp(o):String(o).trim();a!==o&&delete n[o],n[a]=Vn(s),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let n=Object.create(null);return y.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=e&&y.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){let r=new this(e);return n.forEach(s=>r.set(s)),r}static accessor(e){let r=(this[Fa]=this[Fa]={accessors:{}}).accessors,s=this.prototype;function o(i){let a=en(i);r[a]||(hp(s,i),r[a]=!0)}return y.isArray(e)?e.forEach(o):o(e),this}};ht.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);y.reduceDescriptors(ht.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}});y.freezeMethods(ht);var J=ht;function tn(t,e){let n=this||mt,r=e||n,s=J.from(r.headers),o=r.data;return y.forEach(t,function(a){o=a.call(n,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function nn(t){return!!(t&&t.__CANCEL__)}function $a(t,e,n){_.call(this,t==null?"canceled":t,_.ERR_CANCELED,e,n),this.name="CanceledError"}y.inherits($a,_,{__CANCEL__:!0});var ke=$a;function rn(t,e,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new _("Request failed with status code "+n.status,[_.ERR_BAD_REQUEST,_.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Fs(t){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function yp(t,e){t=t||10;let n=new Array(t),r=new Array(t),s=0,o=0,i;return e=e!==void 0?e:1e3,function(l){let c=Date.now(),u=r[o];i||(i=c),n[s]=l,r[s]=c;let f=o,g=0;for(;f!==s;)g+=n[f++],f=f%t;if(s=(s+1)%t,s===o&&(o=(o+1)%t),c-i<e)return;let m=u&&c-u;return m?Math.round(g*1e3/m):void 0}}var qa=yp;function bp(t,e){let n=0,r=1e3/e,s,o,i=(c,u=Date.now())=>{n=u,s=null,o&&(clearTimeout(o),o=null),t(...c)};return[(...c)=>{let u=Date.now(),f=u-n;f>=r?i(c,u):(s=c,o||(o=setTimeout(()=>{o=null,i(s)},r-f)))},()=>s&&i(s)]}var ja=bp;var yt=(t,e,n=3)=>{let r=0,s=qa(50,250);return ja(o=>{let i=o.loaded,a=o.lengthComputable?o.total:void 0,l=i-r,c=s(l),u=i<=a;r=i;let f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&u?(a-i)/c:void 0,event:o,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(f)},n)},$s=(t,e)=>{let n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},qs=t=>(...e)=>y.asap(()=>t(...e));var Ha=$.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,$.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL($.origin),$.navigator&&/(msie|trident)/i.test($.navigator.userAgent)):()=>!0;var Ka=$.hasStandardBrowserEnv?{write(t,e,n,r,s,o,i){if(typeof document=="undefined")return;let a=["".concat(t,"=").concat(encodeURIComponent(e))];y.isNumber(n)&&a.push("expires=".concat(new Date(n).toUTCString())),y.isString(r)&&a.push("path=".concat(r)),y.isString(s)&&a.push("domain=".concat(s)),o===!0&&a.push("secure"),y.isString(i)&&a.push("SameSite=".concat(i)),document.cookie=a.join("; ")},read(t){if(typeof document=="undefined")return null;let e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function js(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Hs(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function sn(t,e,n){let r=!js(e);return t&&(r||n==!1)?Hs(t,e):e}var za=t=>t instanceof J?w({},t):t;function Se(t,e){e=e||{};let n={};function r(c,u,f,g){return y.isPlainObject(c)&&y.isPlainObject(u)?y.merge.call({caseless:g},c,u):y.isPlainObject(u)?y.merge({},u):y.isArray(u)?u.slice():u}function s(c,u,f,g){if(y.isUndefined(u)){if(!y.isUndefined(c))return r(void 0,c,f,g)}else return r(c,u,f,g)}function o(c,u){if(!y.isUndefined(u))return r(void 0,u)}function i(c,u){if(y.isUndefined(u)){if(!y.isUndefined(c))return r(void 0,c)}else return r(void 0,u)}function a(c,u,f){if(f in e)return r(c,u);if(f in t)return r(void 0,c)}let l={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,u,f)=>s(za(c),za(u),f,!0)};return y.forEach(Object.keys(w(w({},t),e)),function(u){let f=l[u]||s,g=f(t[u],e[u],u);y.isUndefined(g)&&f!==a||(n[u]=g)}),n}var Gn=t=>{let e=Se({},t),{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:a}=e;if(e.headers=i=J.from(i),e.url=Qt(sn(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),y.isFormData(n)){if($.hasStandardBrowserEnv||$.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(y.isFunction(n.getHeaders)){let l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([u,f])=>{c.includes(u.toLowerCase())&&i.set(u,f)})}}if($.hasStandardBrowserEnv&&(r&&y.isFunction(r)&&(r=r(e)),r||r!==!1&&Ha(e.url))){let l=s&&o&&Ka.read(o);l&&i.set(s,l)}return e};var wp=typeof XMLHttpRequest!="undefined",Va=wp&&function(t){return new Promise(function(n,r){let s=Gn(t),o=s.data,i=J.from(s.headers).normalize(),{responseType:a,onUploadProgress:l,onDownloadProgress:c}=s,u,f,g,m,d;function h(){m&&m(),d&&d(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function S(){if(!p)return;let E=J.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),P={data:!a||a==="text"||a==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:E,config:t,request:p};rn(function(A){n(A),h()},function(A){r(A),h()},P),p=null}"onloadend"in p?p.onloadend=S:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(S)},p.onabort=function(){p&&(r(new _("Request aborted",_.ECONNABORTED,t,p)),p=null)},p.onerror=function(T){let P=T&&T.message?T.message:"Network Error",I=new _(P,_.ERR_NETWORK,t,p);I.event=T||null,r(I),p=null},p.ontimeout=function(){let T=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded",P=s.transitional||Kn;s.timeoutErrorMessage&&(T=s.timeoutErrorMessage),r(new _(T,P.clarifyTimeoutError?_.ETIMEDOUT:_.ECONNABORTED,t,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&y.forEach(i.toJSON(),function(T,P){p.setRequestHeader(P,T)}),y.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),a&&a!=="json"&&(p.responseType=s.responseType),c&&([g,d]=yt(c,!0),p.addEventListener("progress",g)),l&&p.upload&&([f,m]=yt(l),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",m)),(s.cancelToken||s.signal)&&(u=E=>{p&&(r(!E||E.type?new ke(null,t,p):E),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));let C=Fs(s.url);if(C&&$.protocols.indexOf(C)===-1){r(new _("Unsupported protocol "+C+":",_.ERR_BAD_REQUEST,t));return}p.send(o||null)})};var Sp=(t,e)=>{let{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,s,o=function(c){if(!s){s=!0,a();let u=c instanceof Error?c:this.reason;r.abort(u instanceof _?u:new ke(u instanceof Error?u.message:u))}},i=e&&setTimeout(()=>{i=null,o(new _("timeout ".concat(e," of ms exceeded"),_.ETIMEDOUT))},e),a=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),t=null)};t.forEach(c=>c.addEventListener("abort",o));let{signal:l}=r;return l.unsubscribe=()=>y.asap(a),l}},Ga=Sp;var Ep=function*(t,e){let n=t.byteLength;if(!e||n<e){yield t;return}let r=0,s;for(;r<n;)s=r+e,yield t.slice(r,s),r=s},Cp=function(t,e){return ot(this,null,function*(){try{for(var n=An(Tp(t)),r,s,o;r=!(s=yield new fe(n.next())).done;r=!1){let i=s.value;yield*Me(Ep(i,e))}}catch(s){o=[s]}finally{try{r&&(s=n.return)&&(yield new fe(s.call(n)))}finally{if(o)throw o[0]}}})},Tp=function(t){return ot(this,null,function*(){if(t[Symbol.asyncIterator]){yield*Me(t);return}let e=t.getReader();try{for(;;){let{done:n,value:r}=yield new fe(e.read());if(n)break;yield r}}finally{yield new fe(e.cancel())}})},Ks=(t,e,n,r)=>{let s=Cp(t,e),o=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{let{done:c,value:u}=await s.next();if(c){a(),l.close();return}let f=u.byteLength;if(n){let g=o+=f;n(g)}l.enqueue(new Uint8Array(u))}catch(c){throw a(c),c}},cancel(l){return a(l),s.return()}},{highWaterMark:2})};var Wa=64*1024,{isFunction:Wn}=y,Rp=(({Request:t,Response:e})=>({Request:t,Response:e}))(y.global),{ReadableStream:Ja,TextEncoder:Ya}=y.global,Xa=(t,...e)=>{try{return!!t(...e)}catch(n){return!1}},vp=t=>{t=y.merge.call({skipUndefined:!0},Rp,t);let{fetch:e,Request:n,Response:r}=t,s=e?Wn(e):typeof fetch=="function",o=Wn(n),i=Wn(r);if(!s)return!1;let a=s&&Wn(Ja),l=s&&(typeof Ya=="function"?(d=>h=>d.encode(h))(new Ya):async d=>new Uint8Array(await new n(d).arrayBuffer())),c=o&&a&&Xa(()=>{let d=!1,h=new n($.origin,{body:new Ja,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!h}),u=i&&a&&Xa(()=>y.isReadableStream(new r("").body)),f={stream:u&&(d=>d.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!f[d]&&(f[d]=(h,p)=>{let S=h&&h[d];if(S)return S.call(h);throw new _("Response type '".concat(d,"' is not supported"),_.ERR_NOT_SUPPORT,p)})});let g=async d=>{if(d==null)return 0;if(y.isBlob(d))return d.size;if(y.isSpecCompliantForm(d))return(await new n($.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(y.isArrayBufferView(d)||y.isArrayBuffer(d))return d.byteLength;if(y.isURLSearchParams(d)&&(d=d+""),y.isString(d))return(await l(d)).byteLength},m=async(d,h)=>{let p=y.toFiniteNumber(d.getContentLength());return p==null?g(h):p};return async d=>{let{url:h,method:p,data:S,signal:C,cancelToken:E,timeout:T,onDownloadProgress:P,onUploadProgress:I,responseType:A,headers:L,withCredentials:K="same-origin",fetchOptions:j}=Gn(d),G=e||fetch;A=A?(A+"").toLowerCase():"text";let M=Ga([C,E&&E.toAbortSignal()],T),se=null,Y=M&&M.unsubscribe&&(()=>{M.unsubscribe()}),Ke;try{if(I&&c&&p!=="get"&&p!=="head"&&(Ke=await m(L,S))!==0){let B=new n(h,{method:"POST",body:S,duplex:"half"}),W;if(y.isFormData(S)&&(W=B.headers.get("content-type"))&&L.setContentType(W),B.body){let[ue,re]=$s(Ke,yt(qs(I)));S=Ks(B.body,Wa,ue,re)}}y.isString(K)||(K=K?"include":"omit");let U=o&&"credentials"in n.prototype,ze=N(w({},j),{signal:M,method:p.toUpperCase(),headers:L.normalize().toJSON(),body:S,duplex:"half",credentials:U?K:void 0});se=o&&new n(h,ze);let x=await(o?G(se,j):G(h,ze)),ge=u&&(A==="stream"||A==="response");if(u&&(P||ge&&Y)){let B={};["status","statusText","headers"].forEach(me=>{B[me]=x[me]});let W=y.toFiniteNumber(x.headers.get("content-length")),[ue,re]=P&&$s(W,yt(qs(P),!0))||[];x=new r(Ks(x.body,Wa,ue,()=>{re&&re(),Y&&Y()}),B)}A=A||"text";let q=await f[y.findKey(f,A)||"text"](x,d);return!ge&&Y&&Y(),await new Promise((B,W)=>{rn(B,W,{data:q,headers:J.from(x.headers),status:x.status,statusText:x.statusText,config:d,request:se})})}catch(U){throw Y&&Y(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new _("Network Error",_.ERR_NETWORK,d,se),{cause:U.cause||U}):_.from(U,U&&U.code,d,se)}}},Pp=new Map,zs=t=>{let e=t&&t.env||{},{fetch:n,Request:r,Response:s}=e,o=[r,s,n],i=o.length,a=i,l,c,u=Pp;for(;a--;)l=o[a],c=u.get(l),c===void 0&&u.set(l,c=a?new Map:vp(e)),u=c;return c},uC=zs();var Vs={http:jn,xhr:Va,fetch:{get:zs}};y.forEach(Vs,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(n){}Object.defineProperty(t,"adapterName",{value:e})}});var Za=t=>"- ".concat(t),_p=t=>y.isFunction(t)||t===null||t===!1;function Ip(t,e){t=y.isArray(t)?t:[t];let{length:n}=t,r,s,o={};for(let i=0;i<n;i++){r=t[i];let a;if(s=r,!_p(r)&&(s=Vs[(a=String(r)).toLowerCase()],s===void 0))throw new _("Unknown adapter '".concat(a,"'"));if(s&&(y.isFunction(s)||(s=s.get(e))))break;o[a||"#"+i]=s}if(!s){let i=Object.entries(o).map(([l,c])=>"adapter ".concat(l," ")+(c===!1?"is not supported by the environment":"is not available in the build")),a=n?i.length>1?"since :\n"+i.map(Za).join("\n"):" "+Za(i[0]):"as no adapter specified";throw new _("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return s}var Jn={getAdapter:Ip,adapters:Vs};function Gs(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new ke(null,t)}function Yn(t){return Gs(t),t.headers=J.from(t.headers),t.data=tn.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Jn.getAdapter(t.adapter||mt.adapter,t)(t).then(function(r){return Gs(t),r.data=tn.call(t,t.transformResponse,r),r.headers=J.from(r.headers),r},function(r){return nn(r)||(Gs(t),r&&r.response&&(r.response.data=tn.call(t,t.transformResponse,r.response),r.response.headers=J.from(r.response.headers))),Promise.reject(r)})}var Xn="1.13.2";var Zn={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Zn[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});var Qa={};Zn.transitional=function(e,n,r){function s(o,i){return"[Axios v"+Xn+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,a)=>{if(e===!1)throw new _(s(i," has been removed"+(n?" in "+n:"")),_.ERR_DEPRECATED);return n&&!Qa[i]&&(Qa[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(o,i,a):!0}};Zn.spelling=function(e){return(n,r)=>(console.warn("".concat(r," is likely a misspelling of ").concat(e)),!0)};function xp(t,e,n){if(typeof t!="object")throw new _("options must be an object",_.ERR_BAD_OPTION_VALUE);let r=Object.keys(t),s=r.length;for(;s-- >0;){let o=r[s],i=e[o];if(i){let a=t[o],l=a===void 0||i(a,o,t);if(l!==!0)throw new _("option "+o+" must be "+l,_.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new _("Unknown option "+o,_.ERR_BAD_OPTION)}}var on={assertOptions:xp,validators:Zn};var De=on.validators,bt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new ks,response:new ks}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;let o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+="\n"+o):r.stack=o}catch(i){}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=Se(this.defaults,n);let{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&on.assertOptions(r,{silentJSONParsing:De.transitional(De.boolean),forcedJSONParsing:De.transitional(De.boolean),clarifyTimeoutError:De.transitional(De.boolean)},!1),s!=null&&(y.isFunction(s)?n.paramsSerializer={serialize:s}:on.assertOptions(s,{encode:De.function,serialize:De.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),on.assertOptions(n,{baseUrl:De.spelling("baseURL"),withXsrfToken:De.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&y.merge(o.common,o[n.method]);o&&y.forEach(["delete","get","head","post","put","patch","common"],d=>{delete o[d]}),n.headers=J.concat(i,o);let a=[],l=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(l=l&&h.synchronous,a.unshift(h.fulfilled,h.rejected))});let c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let u,f=0,g;if(!l){let d=[Yn.bind(this),void 0];for(d.unshift(...a),d.push(...c),g=d.length,u=Promise.resolve(n);f<g;)u=u.then(d[f++],d[f++]);return u}g=a.length;let m=n;for(;f<g;){let d=a[f++],h=a[f++];try{m=d(m)}catch(p){h.call(this,p);break}}try{u=Yn.call(this,m)}catch(d){return Promise.reject(d)}for(f=0,g=c.length;f<g;)u=u.then(c[f++],c[f++]);return u}getUri(e){e=Se(this.defaults,e);let n=sn(e.baseURL,e.url,e.allowAbsoluteUrls);return Qt(n,e.params,e.paramsSerializer)}};y.forEach(["delete","get","head","options"],function(e){bt.prototype[e]=function(n,r){return this.request(Se(r||{},{method:e,url:n,data:(r||{}).data}))}});y.forEach(["post","put","patch"],function(e){function n(r){return function(o,i,a){return this.request(Se(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}bt.prototype[e]=n(),bt.prototype[e+"Form"]=n(!0)});var an=bt;var Ws=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});let r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o,i=new Promise(a=>{r.subscribe(a),o=a}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},e(function(o,i,a){r.reason||(r.reason=new ke(o,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){let e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new t(function(s){e=s}),cancel:e}}},ec=Ws;function Js(t){return function(n){return t.apply(null,n)}}function Ys(t){return y.isObject(t)&&t.isAxiosError===!0}var Xs={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Xs).forEach(([t,e])=>{Xs[e]=t});var tc=Xs;function nc(t){let e=new an(t),n=Jt(an.prototype.request,e);return y.extend(n,an.prototype,e,{allOwnKeys:!0}),y.extend(n,e,null,{allOwnKeys:!0}),n.create=function(s){return nc(Se(t,s))},n}var z=nc(mt);z.Axios=an;z.CanceledError=ke;z.CancelToken=ec;z.isCancel=nn;z.VERSION=Xn;z.toFormData=Ve;z.AxiosError=_;z.Cancel=z.CanceledError;z.all=function(e){return Promise.all(e)};z.spread=Js;z.isAxiosError=Ys;z.mergeConfig=Se;z.AxiosHeaders=J;z.formToJSON=t=>zn(y.isHTMLForm(t)?new FormData(t):t);z.getAdapter=Jn.getAdapter;z.HttpStatusCode=tc;z.default=z;var cn=z;var{Axios:cT,AxiosError:lT,CanceledError:uT,isCancel:dT,CancelToken:fT,VERSION:pT,all:gT,Cancel:mT,isAxiosError:hT,spread:yT,toFormData:bT,AxiosHeaders:wT,HttpStatusCode:ST,formToJSON:ET,getAdapter:CT,mergeConfig:TT}=cn;var pe={NETWORK_ERROR:"network_error",API_ERROR:"api_error",AUTH_REQUIRED:"auth_required",TOKEN_EXPIRED:"token_expired",NOT_FOUND:"not_found",VALIDATION_ERROR:"validation_error",CIRCUIT_BREAKER:"circuit_breaker",PAYMENT_FAILED:"payment_failed",CARD_DECLINED:"card_declined",SESSION_EXPIRED:"session_expired",RATE_LIMITED:"rate_limited",TIMEOUT:"timeout",UNKNOWN:"unknown"},Ee=class extends Error{constructor(e,n){var r;super(e),this.name="TagadaError",this.code=n.code,this.statusCode=n.statusCode,this.retryable=(r=n.retryable)!=null?r:!1,this.details=n.details,Object.setPrototypeOf(this,new.target.prototype)}},Fe=class extends Ee{constructor(e,n,r){var s,o;super(e,{code:(s=r==null?void 0:r.code)!=null?s:pe.API_ERROR,statusCode:n,retryable:(o=r==null?void 0:r.retryable)!=null?o:n>=500,details:r==null?void 0:r.details}),this.name="TagadaApiError"}},wt=class extends Ee{constructor(e="Network request failed"){super(e,{code:pe.NETWORK_ERROR,retryable:!0}),this.name="TagadaNetworkError"}},St=class extends Ee{constructor(e="Authentication required",n=401){super(e,{code:pe.AUTH_REQUIRED,statusCode:n,retryable:!1}),this.name="TagadaAuthError"}},Qn=class extends Ee{constructor(e,n){super(e,{code:pe.VALIDATION_ERROR,statusCode:400,retryable:!1,details:n}),this.name="TagadaValidationError"}},Et=class extends Ee{constructor(e){super(e,{code:pe.CIRCUIT_BREAKER,retryable:!1}),this.name="TagadaCircuitBreakerError"}};var Ct=class{constructor(e){this.currentToken=null;this.tokenProvider=null;this.requestHistory=new Map;this.WINDOW_MS=5e3;this.MAX_REQUESTS=30;this.axios=cn.create({baseURL:e.baseURL,timeout:e.timeout||6e4,headers:w({"Content-Type":"application/json"},e.headers)}),typeof setInterval!="undefined"&&setInterval(()=>this.cleanupHistory(),1e4),this.axios.interceptors.request.use(async n=>{var r,s;if(n.url)try{this.checkRequestLimit("".concat((r=n.method)==null?void 0:r.toUpperCase(),":").concat(n.url))}catch(o){return console.error("[SDK] \u{1F6D1} Request blocked by Circuit Breaker:",o),Promise.reject(o)}if(!n.skipAuth&&!this.currentToken&&this.tokenProvider)try{console.log("[SDK] Waiting for token...");let o=await this.tokenProvider();o&&(this.updateToken(o),n.headers["x-cms-token"]=o)}catch(o){console.error("[SDK] Failed to get token from provider:",o)}return!n.skipAuth&&this.currentToken&&(n.headers["x-cms-token"]=this.currentToken),console.log("[SDK] Making ".concat((s=n.method)==null?void 0:s.toUpperCase()," request to: ").concat(n.baseURL||"").concat(n.url)),n},n=>(console.error("[SDK] Request error:",n),Promise.reject(n instanceof Error?n:new Error(String(n))))),this.axios.interceptors.response.use(n=>n,n=>(console.error("[SDK] Response error:",n.message),n instanceof Ee?Promise.reject(n):cn.isAxiosError(n)?Promise.reject(this.toTagadaError(n)):Promise.reject(n instanceof Error?n:new Error(String(n)))))}setTokenProvider(e){this.tokenProvider=e}async get(e,n){return(await this.axios.get(e,n)).data}async post(e,n,r){return(await this.axios.post(e,n,r)).data}async put(e,n,r){return(await this.axios.put(e,n,r)).data}async patch(e,n,r){return(await this.axios.patch(e,n,r)).data}async delete(e,n){return(await this.axios.delete(e,n)).data}setHeader(e,n){this.axios.defaults.headers.common[e]=n}removeHeader(e){delete this.axios.defaults.headers.common[e]}updateToken(e){this.currentToken=e,e?this.setHeader("x-cms-token",e):(this.removeHeader("x-cms-token"),console.log("[SDK] Token removed from ApiClient"))}getCurrentToken(){return this.currentToken}updateConfig(e){e.baseURL&&(this.axios.defaults.baseURL=e.baseURL),e.timeout&&(this.axios.defaults.timeout=e.timeout),e.headers&&Object.assign(this.axios.defaults.headers.common,e.headers),console.log("[SDK] ApiClient configuration updated")}checkRequestLimit(e){let n=Date.now(),r=this.requestHistory.get(e);if(!r){this.requestHistory.set(e,{count:1,firstRequestTime:n});return}if(n-r.firstRequestTime>this.WINDOW_MS){this.requestHistory.set(e,{count:1,firstRequestTime:n});return}if(r.count++,r.count>this.MAX_REQUESTS)throw new Et("Circuit Breaker: Too many requests to ".concat(e," (").concat(r.count," in ").concat(this.WINDOW_MS,"ms)"))}cleanupHistory(){let e=Date.now();for(let[n,r]of this.requestHistory.entries())e-r.firstRequestTime>this.WINDOW_MS&&this.requestHistory.delete(n)}toTagadaError(e){var o,i,a,l,c;let n=(o=e.response)==null?void 0:o.status,r=(i=e.response)==null?void 0:i.data,s=(l=(a=r==null?void 0:r.message)!=null?a:r==null?void 0:r.error)!=null?l:e.message;return e.response?n===401||n===403?new St(s,n):n===429?new Fe(s,429,{code:pe.RATE_LIMITED,retryable:!0}):n===404?new Fe(s,404,{code:pe.NOT_FOUND,retryable:!1}):new Fe(s,n!=null?n:0,{code:(c=r==null?void 0:r.code)!=null?c:pe.API_ERROR,details:r,retryable:(n!=null?n:0)>=500}):e.code==="ECONNABORTED"?new Fe("Request timed out",0,{code:pe.TIMEOUT,retryable:!0}):new wt(s)}};function Op(){return{width:window.screen.width,height:window.screen.height}}function kp(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return"UTC"}}function rc(){try{return navigator.language||"en-US"}catch(t){return"en-US"}}var Xe=typeof navigator!="undefined"?navigator.userAgent:"";function Ce(t,...e){for(let n of e){let r=t.match(n);if(r)return r}return null}function Dp(t){let e=[[/EdgA?\/([\d.]+)/i,"Edge"],[/OPR\/([\d.]+)/i,"Opera"],[/Brave\/([\d.]+)/i,"Brave"],[/Vivaldi\/([\d.]+)/i,"Vivaldi"],[/SamsungBrowser\/([\d.]+)/i,"Samsung Internet"],[/UCBrowser\/([\d.]+)/i,"UC Browser"],[/Firefox\/([\d.]+)/i,"Firefox"],[/CriOS\/([\d.]+)/i,"Chrome"],[/FxiOS\/([\d.]+)/i,"Firefox"],[/Chrome\/([\d.]+)/i,"Chrome"],[/Version\/([\d.]+).*Safari/i,"Safari"],[/Safari\/([\d.]+)/i,"Safari"]];for(let[n,r]of e){let s=t.match(n);if(s){let o=s[1]||"";return{name:r,version:o,major:o.split(".")[0]||""}}}return{name:"",version:"",major:""}}function Np(t){let e=Ce(t,/Windows NT ([\d.]+)/i)||Ce(t,/Mac OS X ([\d_.]+)/i)||Ce(t,/Android ([\d.]+)/i)||Ce(t,/iPhone OS ([\d_]+)/i)||Ce(t,/iPad.*OS ([\d_]+)/i)||Ce(t,/CrOS[\w ]*\/([\d.]+)/i)||Ce(t,/Linux/i);if(!e)return{name:"",version:""};let n=e[0],r=(e[1]||"").replace(/_/g,".");return/Windows/i.test(n)?{name:"Windows",version:{"10.0":"10","6.3":"8.1","6.2":"8","6.1":"7","6.0":"Vista","5.1":"XP"}[r]||r}:/Mac OS X/i.test(n)?{name:"macOS",version:r}:/Android/i.test(n)?{name:"Android",version:r}:/iPhone|iPad/i.test(n)?{name:"iOS",version:r}:/CrOS/i.test(n)?{name:"Chrome OS",version:r}:/Linux/i.test(n)?{name:"Linux",version:""}:{name:"",version:""}}function Lp(t){var e;if(/iPad/i.test(t))return{type:"tablet",vendor:"Apple",model:"iPad"};if(/iPhone/i.test(t))return{type:"mobile",vendor:"Apple",model:"iPhone"};if(/iPod/i.test(t))return{type:"mobile",vendor:"Apple",model:"iPod"};if(/Android/i.test(t)){let n=t.match(/Android[\s\d.]+;\s*([^)]+?)(?:\s+Build)/i);return{type:/Mobile/i.test(t)?"mobile":"tablet",model:(e=n==null?void 0:n[1])==null?void 0:e.trim()}}}function Bp(t){let e=Ce(t,/AppleWebKit\/([\d.]+)/i)||Ce(t,/Gecko\/([\d.]+)/i)||Ce(t,/Trident\/([\d.]+)/i)||Ce(t,/Presto\/([\d.]+)/i);if(!e)return{name:"",version:""};let n=e[0],r=e[1]||"";return/AppleWebKit/i.test(n)?{name:"WebKit",version:r}:/Gecko/i.test(n)?{name:"Gecko",version:r}:/Trident/i.test(n)?{name:"Trident",version:r}:/Presto/i.test(n)?{name:"Presto",version:r}:{name:"",version:""}}function Up(t){return/x86_64|x64|amd64|Win64/i.test(t)?{architecture:"amd64"}:/ia32|x86/i.test(t)?{architecture:"ia32"}:/aarch64|arm64/i.test(t)?{architecture:"arm64"}:/arm/i.test(t)?{architecture:"arm"}:{architecture:""}}function Mp(){return navigator.webdriver?!0:/bot|crawl|spider|slurp|Googlebot|bingbot|yandex|baidu|duckduck|facebookexternalhit|Twitterbot|linkedinbot|embedly|quora|pinterest|redditbot|Slackbot|Discordbot|WhatsApp|TelegramBot|Applebot/i.test(Xe)}function Fp(t){return/Chrome|Chromium|Edge|Brave|Opera|Vivaldi|Arc/i.test(t)}function $p(){return window.matchMedia("(display-mode: standalone)").matches||navigator.standalone===!0}function qp(t){return/mac/i.test(t)?navigator.maxTouchPoints>0:!1}function sc(){if(typeof window=="undefined")return{userAgent:{name:"",browser:{major:"",name:"",version:""},os:{name:"",version:""},device:void 0,engine:{name:"",version:""},cpu:{architecture:""}},screenResolution:{width:0,height:0},timeZone:"UTC",flags:{isBot:!1,isChromeFamily:!1,isStandalonePWA:!1,isAppleSilicon:!1}};let t=Dp(Xe),e=Np(Xe),n=Lp(Xe),r=Bp(Xe),s=Up(Xe),o;try{o={isBot:Mp(),isChromeFamily:Fp(t.name),isStandalonePWA:$p(),isAppleSilicon:qp(e.name)}}catch(i){o={isBot:!1,isChromeFamily:!1,isStandalonePWA:!1,isAppleSilicon:!1}}return{userAgent:{name:Xe,browser:t,os:e,device:n,engine:r,cpu:s},screenResolution:Op(),timeZone:kp(),flags:o}}function oc(){if(typeof window=="undefined")return{};let t=new URLSearchParams(window.location.search);return{locale:t.get("locale")||void 0,currency:t.get("currency")||void 0,utmSource:t.get("utm_source")||void 0,utmMedium:t.get("utm_medium")||void 0,utmCampaign:t.get("utm_campaign")||void 0}}var er=class{constructor(){this.listeners=new Map}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>this.off(e,n)}off(e,n){this.listeners.has(e)&&this.listeners.get(e).delete(n)}async emit(e,n){if(this.listeners.has(e)){let r=Array.from(this.listeners.get(e));await Promise.all(r.map(s=>{try{return Promise.resolve(s(n))}catch(o){return console.error('[EventBus] Error in listener for event "'.concat(e,'":'),o),Promise.resolve()}}))}}clear(){this.listeners.clear()}};Es();function ln(t){try{let e=t.split(".");if(e.length!==3)return console.error("Invalid JWT token format"),null;let n=e[1],r=n+"=".repeat((4-n.length%4)%4),s=atob(r),o=JSON.parse(s);return o.exp&&Date.now()>=o.exp*1e3?(console.warn("JWT token is expired"),null):{sessionId:o.sessionId,storeId:o.storeId,accountId:o.accountId,customerId:o.customerId,role:o.role,isValid:!0,isLoading:!1}}catch(e){return console.error("Failed to decode JWT token:",e),null}}function ic(t){try{let e=t.split(".");if(e.length!==3)return!0;let n=e[1],r=n+"=".repeat((4-n.length%4)%4),s=atob(r),o=JSON.parse(s);return o.exp?Date.now()>=o.exp*1e3:!1}catch(e){return console.error("Failed to check token expiration:",e),!0}}_n();var Tt={},jp=["","VITE_","REACT_APP_","NEXT_PUBLIC_"];function $e(t,e=jp){var n,r,s;for(let o of e){let i=o?"".concat(o).concat(t):t;if(typeof process!="undefined"&&((n=process==null?void 0:process.env)!=null&&n[i]))return console.log("process.env[".concat(i,"]"),process.env[i]),process.env[i];if(typeof Tt!="undefined"&&((r=Tt==null?void 0:Tt.env)!=null&&r[i]))return console.log("import.meta.env[".concat(i,"]"),Tt.env[i]),Tt.env[i];if(typeof window!="undefined"&&((s=window==null?void 0:window.__TAGADA_ENV__)!=null&&s[i]))return console.log("window.__TAGADA_ENV__[".concat(i,"]"),window.__TAGADA_ENV__[i]),window.__TAGADA_ENV__[i]}}var Hp=async(t="default")=>{try{if(($e("TAGADA_ENV")||$e("TAGADA_ENVIRONMENT"))==="production"||!qt(!0))return null;let n=await fetch("/.local.json");if(!n.ok)return null;let r=await n.json(),s={},o=!1;try{let a=await fetch("/config/".concat(t,".tgd.json"));a.ok||(a=await fetch("/config/".concat(t,".json"))),a.ok&&(s=await a.json(),o=!0)}catch(a){}if(!o&&t!=="default"){console.warn("\u26A0\uFE0F Config variant '".concat(t,"' not found, falling back to 'default'"));try{let a=await fetch("/config/default.tgd.json");a.ok||(a=await fetch("/config/default.json")),a.ok&&(s=await a.json(),o=!0,console.log("\u2705 Fallback to 'default' config successful"))}catch(a){}}o||console.warn(t==="default"?"\u26A0\uFE0F No 'default' config found. Create /config/default.tgd.json":"\u26A0\uFE0F Neither '".concat(t,"' nor 'default' config found. Create /config/default.tgd.json"));let i={storeId:r.storeId,accountId:r.accountId,basePath:r.basePath,config:s};return console.log("\u{1F6E0}\uFE0F Using local development plugin config:",i),i}catch(e){return null}},Kp=async()=>{try{if(($e("TAGADA_ENV")||$e("TAGADA_ENVIRONMENT"))==="production"||!qt(!0))return null;try{console.log("\u{1F6E0}\uFE0F [V2] Attempting to load /config/funnel.local.json...");let r=await fetch("/config/funnel.local.json");if(r.ok){let s=await r.json();console.log("\u{1F6E0}\uFE0F [V2] \u2705 Loaded local funnel config (NEW format):",s);let{loadLocalFunnelConfig:o}=await Promise.resolve().then(()=>(dt(),ba));if(await o(),s.staticResources){let i={};for(let[a,l]of Object.entries(s.staticResources))i[a]={id:l};return i}return null}}catch(r){console.log("\u{1F6E0}\uFE0F [V2] funnel.local.json not found, trying legacy format...")}console.log("\u{1F6E0}\uFE0F [V2] Attempting to load /config/resources.static.json (legacy)...");let e=await fetch("/config/resources.static.json");if(!e.ok)return console.log("\u{1F6E0}\uFE0F [V2] No local static resources found"),null;let n=await e.json();return console.log("\u{1F6E0}\uFE0F [V2] \u2705 Loaded legacy static resources:",n),n}catch(t){return console.error("\u{1F6E0}\uFE0F [V2] \u274C Error loading static resources:",t),null}},Ze=t=>{if(typeof document=="undefined")return;let e=document.querySelector('meta[name="'.concat(t,'"]'));return(e==null?void 0:e.getAttribute("content"))||void 0},ac=()=>{if(typeof window!="undefined"&&window.__TAGADA_PLUGIN_CONFIG__)return window.__TAGADA_PLUGIN_CONFIG__;try{let t=Ze("x-plugin-config");if(t)return JSON.parse(decodeURIComponent(t))}catch(t){}return{}};function zp(){if(typeof document=="undefined")return{basePath:"/",config:{}};let t=Ze("x-plugin-store-id"),e=Ze("x-plugin-account-id"),n=Ze("x-plugin-base-path")||"/",r=ac();return{storeId:t,accountId:e,basePath:n,config:r}}var Vp=async()=>{try{if(typeof document=="undefined")return null;let t=Ze("x-plugin-store-id"),e=Ze("x-plugin-account-id");if(!t)return null;let n=Ze("x-plugin-base-path")||"/",r=ac();e||console.warn("\u26A0\uFE0F Plugin config: Account ID not found in meta tags");let s={storeId:t,accountId:e,basePath:n,config:r};return console.log("\u{1F680} [HIGHEST PRIORITY] Plugin config loaded from meta tags (runtime injected config):",{storeId:t,accountId:e,basePath:n,configKeys:Object.keys(r),configSize:JSON.stringify(r).length}),s}catch(t){return console.warn("\u26A0\uFE0F Error loading production config from meta tags:",t),null}},Qs=async(t="default",e)=>{var i,a;console.log("\u{1F527} [V2] loadPluginConfig called with variant:",t);let n=await Kp(),r=await Vp();if(r){let l=N(w({},r),{staticResources:n!=null?n:void 0});return console.log("\u2705 [V2] Using INJECTED config from meta tags (HIGHEST PRIORITY)"),l}if(e){let l={storeId:e.storeId,accountId:e.accountId,basePath:(i=e.basePath)!=null?i:"/",config:(a=e.config)!=null?a:{},staticResources:n!=null?n:void 0};return console.log("\u2705 [V2] Using raw config parameter (PRIORITY 2)"),l}let s=await lc();if(s){let l=N(w({},s),{staticResources:n!=null?n:void 0});return console.log("\u2705 [V2] Using environment variables config (PRIORITY 3 - build time)"),l}let o=await Hp(t);if(o){let l=N(w({},o),{staticResources:n!=null?n:void 0});return console.log("\u2705 [V2] Using local dev config files (PRIORITY 4)"),l}return console.warn("\u26A0\uFE0F [V2] No plugin config found - using defaults"),{basePath:"/",config:{},staticResources:n!=null?n:void 0}};async function cc(t="default",e){try{if(!qt())return null;if(e)return e;let n=["/config/".concat(t,".config.json"),"/config/".concat(t,".tgd.json"),"/config/".concat(t,".json")];for(let r of n)try{let s=await fetch(r);if(s.ok)return await s.json()}catch(s){continue}return console.warn("\u26A0\uFE0F [loadLocalConfig] No config found for '".concat(t,"'")),null}catch(n){return console.error("[loadLocalConfig] Error loading config:",n),null}}async function lc(){try{if(!qt())return;let t=$e("TAGADA_STORE_ID"),e=$e("TAGADA_ACCOUNT_ID"),n=$e("TAGADA_BASE_PATH"),r=$e("TAGADA_CONFIG_NAME");if(!t||!e)return;let s=await cc(r);if(!s)return;let o={storeId:t,accountId:e,basePath:n||"/",config:s};return console.log("\u{1F6E0}\uFE0F [createRawPluginConfig] Using environment variables (build-time config):",{hasStoreId:!!o.storeId,hasAccountId:!!o.accountId,basePath:o.basePath,hasConfig:!!o.config}),o}catch(t){console.error("[createRawPluginConfig] Error creating config:",t);return}}var Zs=class{static getPluginConfig(e,n){return{storeId:(e==null?void 0:e.storeId)||(n==null?void 0:n.storeId),accountId:(e==null?void 0:e.accountId)||(n==null?void 0:n.accountId),basePath:(e==null?void 0:e.basePath)||(n==null?void 0:n.basePath)||"/",config:(e==null?void 0:e.config)||{}}}static validateConfig(e){return!!(e.storeId&&e.accountId)}};Ln();ct();ct();var eo=new Map,to=new Set;function Gp(){return typeof window=="undefined"?null:new URLSearchParams(window.location.search).get("authCode")}async function uc(t,e,n,r=!1){if(to.has(t))throw r&&console.log("[AuthHandoff] Code already resolved, skipping duplicate request"),new Error("Auth code already resolved");let s=eo.get(t);if(s)return r&&console.log("[AuthHandoff] Resolution already in progress, waiting for existing request"),s;r&&console.log("[AuthHandoff] Resolving authCode:",t.substring(0,15)+"...");let o=(async()=>{try{let i=await fetch("".concat(n,"/api/v1/cms/auth/resolve-handoff"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:t,storeId:e})});if(!i.ok){let l=await i.json().catch(()=>({message:"Unknown error"}));throw new Error(l.message||"Failed to resolve auth handoff: ".concat(i.status))}let a=await i.json();return r&&console.log("[AuthHandoff] \u2705 Resolved successfully:",{customerId:a.customer.id,role:a.customer.role,hasContext:Object.keys(a.context).length>0}),r&&console.log("[AuthHandoff] Storing new token (overriding existing)"),he(a.token),Wp(r),to.add(t),a}catch(i){throw console.error("[AuthHandoff] \u274C Failed to resolve:",i),i}finally{eo.delete(t)}})();return eo.set(t,o),o}function Wp(t=!1){if(typeof window=="undefined")return;let e=new URL(window.location.href);e.searchParams.has("authCode")&&(e.searchParams.delete("authCode"),window.history.replaceState({},"",e.pathname+e.search+e.hash),t&&console.log("[AuthHandoff] Cleaned authCode from URL"))}function dc(){let t=Gp();return!(!t||!t.startsWith("ah_")||to.has(t))}var un=class{constructor(e={}){this.bus=new er;this.eventDispatcher=new it;this.tokenPromise=null;this.tokenResolver=null;this.isInitializingSession=!1;this.lastSessionInitError=null;this.sessionInitRetryCount=0;this.MAX_SESSION_INIT_RETRIES=3;var a,l,c,u;this.config=e,this.instanceId=Math.random().toString(36).substr(2,9),this.boundHandleStorageChange=this.handleStorageChange.bind(this),this.boundHandlePageshow=f=>{if(f.persisted)if(this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Page restored from BFcache (back button), re-initializing funnel...")),this.funnel&&this.state.session&&this.state.store){this.funnel.resetInitialization();let g=this.getAccountId(),d=new URLSearchParams(typeof window!="undefined"?window.location.search:"").get("funnelId")||void 0;this.funnel.autoInitialize({customerId:this.state.session.customerId,sessionId:this.state.session.sessionId},{id:this.state.store.id,accountId:g},d).catch(h=>{console.error("[TagadaClient] Funnel re-initialization failed:",h)})}else this.sessionInitRetryCount=0,this.initialize()},console.log("[TagadaClient ".concat(this.instanceId,"] Initializing...")),console.log("[TagadaClient ".concat(this.instanceId,"] Config:"),{debugMode:e.debugMode,hasRawPluginConfig:!!e.rawPluginConfig,rawPluginConfig:e.rawPluginConfig,features:e.features}),ra(this.config.debugMode)&&this.config.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Preview mode active - state cleared"));let r=this.resolveEnvironment(),s=ea(r);e.customApiConfig&&(s=N(w(w({},s),e.customApiConfig),{apiConfig:w(w({},s.apiConfig),e.customApiConfig.apiConfig)}),this.config.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Applied custom API config:"),s.apiConfig.baseUrl)),this.state={auth:{isAuthenticated:!1,isLoading:!1,customer:null,session:null},session:null,customer:null,locale:{locale:"en-US",language:"en",region:"US",messages:{}},currency:{code:"USD",symbol:"$",name:"US Dollar"},store:null,environment:s,isLoading:!0,isInitialized:!1,isSessionInitialized:!1,pluginConfig:{basePath:"/",config:{}},pluginConfigLoading:!0,debugMode:(a=e.debugMode)!=null?a:r!=="production",token:null},console.log("[TagadaClient ".concat(this.instanceId,"] Initial state:"),{pluginConfigLoading:this.state.pluginConfigLoading,hasRawPluginConfig:!!e.rawPluginConfig}),this.apiClient=new Ct({baseURL:s.apiConfig.baseUrl});let o=(l=e.features)==null?void 0:l.funnel;if(o!==!1){let f=typeof o=="object"?o:{};this.funnel=new Gt({apiClient:this.apiClient,debugMode:this.state.debugMode,pluginConfig:this.state.pluginConfig,environment:this.state.environment,autoRedirect:f.autoRedirect,funnelId:(c=e.rawPluginConfig)==null?void 0:c.funnelId,stepId:(u=e.rawPluginConfig)==null?void 0:u.stepId})}this.apiClient.setTokenProvider(this.waitForToken.bind(this)),typeof window!="undefined"&&(window.addEventListener("storage",this.boundHandleStorageChange),window.addEventListener("pageshow",this.boundHandlePageshow)),this.setupConfigHotReload(),this.initialize()}destroy(){typeof window!="undefined"&&(window.removeEventListener("storage",this.boundHandleStorageChange),window.removeEventListener("pageshow",this.boundHandlePageshow)),this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Destroyed")),this.eventDispatcher.clear(),this.bus.clear()}handleStorageChange(){if(jt()===this.state.token){this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Token unchanged (ignoring event)"));return}if(this.isInitializingSession){this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Session initialization in progress, skipping storage change"));return}if(this.sessionInitRetryCount>=this.MAX_SESSION_INIT_RETRIES&&this.lastSessionInitError){this.state.debugMode&&console.error("[TagadaClient ".concat(this.instanceId,"] Max session init retries reached, giving up"),this.lastSessionInitError);return}this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Storage changed, re-initializing token...")),this.initializeToken()}subscribe(e){return this.eventDispatcher.subscribe(e)}getState(){return this.state}updateState(e){this.state=w(w({},this.state),e),this.eventDispatcher.notify(this.state)}resolveEnvironment(){return this.config.environment?this.config.environment:$t()}async initialize(){try{await this.initializePluginConfig(),this.state.pluginConfig.storeId?await this.initializeToken():(console.warn("[TagadaClient] No store ID found in plugin config. Skipping token initialization."),this.updateState({isLoading:!1,isInitialized:!0}))}catch(e){console.error("[TagadaClient] Initialization failed:",e),this.updateState({isLoading:!1,isInitialized:!0})}}async initializePluginConfig(){if(console.log("[TagadaClient ".concat(this.instanceId,"] initializePluginConfig called"),{pluginConfigLoading:this.state.pluginConfigLoading,hasRawPluginConfig:!!this.config.rawPluginConfig}),!this.state.pluginConfigLoading){console.log("[TagadaClient ".concat(this.instanceId,"] Plugin config already loading or loaded, skipping..."));return}try{let e=this.config.localConfig||"default";console.log("[TagadaClient ".concat(this.instanceId,"] Loading plugin config with variant: ").concat(e));let n=await Qs(e,this.config.rawPluginConfig);console.log("[TagadaClient ".concat(this.instanceId,"] Plugin config loaded:"),n),this.updateState({pluginConfig:n,pluginConfigLoading:!1}),this.funnel&&this.funnel.setConfig({pluginConfig:n,environment:this.state.environment})}catch(e){console.error("[TagadaClient] Failed to load plugin config:",e),this.updateState({pluginConfig:{basePath:"/",config:{}},pluginConfigLoading:!1})}}async initializeToken(){var e;if(dc()){let n=this.state.pluginConfig.storeId;if(!n)return console.error("[TagadaClient] Cannot resolve authCode: storeId not found in config"),this.fallbackToNormalFlow();console.log("[TagadaClient ".concat(this.instanceId,"] \u{1F510} Cross-domain auth detected, resolving..."));try{let r=new URLSearchParams(window.location.search).get("authCode");if(!r)return this.fallbackToNormalFlow();let s=await uc(r,n,this.state.environment.apiConfig.baseUrl,this.state.debugMode);console.log("[TagadaClient ".concat(this.instanceId,"] \u2705 Auth handoff resolved:"),{customerId:s.customer.id,role:s.customer.role,hasContext:Object.keys(s.context).length>0}),this.setToken(s.token);let o=ln(s.token);o?(this.updateState({session:o}),await this.initializeSession(o),(e=s.context)!=null&&e.funnelSessionId&&this.funnel&&this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Restoring funnel session from handoff context:"),s.context.funnelSessionId)):(console.error("[TagadaClient] Failed to decode token from handoff"),this.updateState({isInitialized:!0,isLoading:!1}));return}catch(r){console.error("[TagadaClient ".concat(this.instanceId,"] \u274C Auth handoff failed, falling back to normal flow:"),r)}}await this.fallbackToNormalFlow()}async fallbackToNormalFlow(){let n=new URLSearchParams(typeof window!="undefined"?window.location.search:"").get("token");n&&(this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] \u{1F512} URL token detected, setting immediately to prevent race condition")),this.apiClient.updateToken(n),he(n));let r=jt();console.log("[TagadaClient ".concat(this.instanceId,"] Initializing token (normal flow)..."),{hasExistingToken:!!r,hasQueryToken:!!n,storeId:this.state.pluginConfig.storeId});let s=null,o=!1;if(n?(s=n,o=!0):r&&!ic(r)&&(s=r),s){this.setToken(s),o&&(this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Persisting query token to storage...")),he(s));let i=ln(s);i?(this.updateState({session:i}),await this.initializeSession(i)):(console.error("[TagadaClient] Failed to decode token"),this.updateState({isInitialized:!0,isLoading:!1}))}else{let i=this.state.pluginConfig.storeId;console.log("[TagadaClient ".concat(this.instanceId,"] No existing token, creating anonymous token..."),{hasStoreId:!!i,storeId:i}),i?await this.createAnonymousToken(i):(console.warn("[TagadaClient ".concat(this.instanceId,"] No storeId in plugin config, skipping anonymous token creation")),this.updateState({isInitialized:!0,isLoading:!1}))}}setToken(e){this.apiClient.updateToken(e),this.updateState({token:e}),this.tokenResolver&&(this.tokenResolver(e),this.tokenPromise=null,this.tokenResolver=null)}waitForToken(){return this.apiClient.getCurrentToken()?Promise.resolve(this.apiClient.getCurrentToken()):(this.tokenPromise||(this.tokenPromise=new Promise(e=>{this.tokenResolver=e})),this.tokenPromise)}async createAnonymousToken(e){if(typeof window!="undefined"){let r=new URLSearchParams(window.location.search).get("token");if(r){this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] \u{1F512} URL has token, skipping anonymous token creation")),this.setToken(r),he(r);let s=ln(r);s&&(this.updateState({session:s}),await this.initializeSession(s));return}}if(this.isInitializingSession){this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Session initialization in progress, skipping anonymous token creation"));return}try{let n=zt();this.state.debugMode&&console.log("[TagadaClient] Creating anonymous token for store:",e,{draft:n});let r=await this.apiClient.post("/api/v1/cms/session/anonymous",{storeId:e,role:"anonymous",draft:n},{skipAuth:!0});this.setToken(r.token),he(r.token);let s=ln(r.token);s&&(this.updateState({session:s}),await this.initializeSession(s)),this.updateState({isSessionInitialized:!0})}catch(n){console.error("[TagadaClient] Failed to create anonymous token:",n),this.updateState({isInitialized:!0,isLoading:!1})}}async initializeSession(e){var n,r,s,o,i,a,l,c,u,f,g;if(this.isInitializingSession){this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Session initialization already in progress, skipping"));return}this.isInitializingSession=!0;try{this.state.debugMode&&console.log("[TagadaClient ".concat(this.instanceId,"] Initializing session..."),{sessionId:e.sessionId});let m=await sc(),d=oc(),h=rc(),p=zt(),S=new URLSearchParams(window.location.search).get("draft");S!==null&&vs(S==="true");let C={storeId:e.storeId,accountId:e.accountId,customerId:e.customerId,role:e.role,browserLocale:h,queryLocale:d.locale,queryCurrency:d.currency,utmSource:d.utmSource,utmMedium:d.utmMedium,utmCampaign:d.utmCampaign,browser:m.userAgent.browser.name,browserVersion:m.userAgent.browser.version,os:m.userAgent.os.name,osVersion:m.userAgent.os.version,deviceType:(n=m.userAgent.device)==null?void 0:n.type,deviceModel:(r=m.userAgent.device)==null?void 0:r.model,deviceVendor:(s=m.userAgent.device)==null?void 0:s.vendor,userAgent:m.userAgent.name,engineName:m.userAgent.engine.name,engineVersion:m.userAgent.engine.version,cpuArchitecture:m.userAgent.cpu.architecture,isBot:(i=(o=m.flags)==null?void 0:o.isBot)!=null?i:!1,isChromeFamily:(l=(a=m.flags)==null?void 0:a.isChromeFamily)!=null?l:!1,isStandalonePWA:(u=(c=m.flags)==null?void 0:c.isStandalonePWA)!=null?u:!1,isAppleSilicon:(g=(f=m.flags)==null?void 0:f.isAppleSilicon)!=null?g:!1,screenWidth:m.screenResolution.width,screenHeight:m.screenResolution.height,timeZone:m.timeZone,draft:p,fetchMessages:!1},E=await this.apiClient.post("/api/v1/cms/session/v2/init",C);this.lastSessionInitError=null,this.sessionInitRetryCount=0,this.updateSessionState(E,e),this.updateState({isInitialized:!0,isSessionInitialized:!0,isLoading:!1}),this.state.debugMode&&console.log("[TagadaClient] Session initialized successfully")}catch(m){this.lastSessionInitError=m,this.sessionInitRetryCount++,console.error("[TagadaClient] Error initializing session (attempt ".concat(this.sessionInitRetryCount,"/").concat(this.MAX_SESSION_INIT_RETRIES,"):"),m),this.updateState({isInitialized:!0,isLoading:!1})}finally{this.isInitializingSession=!1}}updateSessionState(e,n){var i,a,l,c,u,f,g,m,d,h;if(e.store){let p=e.store,S=N(w({},e.store),{accountId:p.accountId||((i=this.state.pluginConfig)==null?void 0:i.accountId)||n.accountId||"",presentmentCurrencies:p.presentmentCurrencies||[e.store.currency||"USD"],chargeCurrencies:p.chargeCurrencies||[e.store.currency||"USD"]});this.updateState({store:S})}if(e.locale){let p={locale:e.locale,language:e.locale.split("-")[0],region:(a=e.locale.split("-")[1])!=null?a:"US",messages:(l=e.messages)!=null?l:{}};this.updateState({locale:p})}if(e.store){let p={code:e.store.currency,symbol:this.getCurrencySymbol(e.store.currency),name:this.getCurrencyName(e.store.currency)};this.updateState({currency:p})}let r={isAuthenticated:(u=(c=e.customer)==null?void 0:c.isAuthenticated)!=null?u:!1,isLoading:!1,customer:(f=e.customer)!=null?f:null,session:n};this.updateState({customer:(g=e.customer)!=null?g:null,auth:r});let s=(m=this.config.features)==null?void 0:m.funnel,o=typeof s=="object"&&s.skipAutoInit;if(this.funnel&&!o&&n.customerId&&((d=e.store)!=null&&d.id)){let p=e.store.accountId||((h=this.state.pluginConfig)==null?void 0:h.accountId)||n.accountId||"";if(p){let C=new URLSearchParams(typeof window!="undefined"?window.location.search:"").get("funnelId")||void 0;this.state.debugMode&&console.log("[TagadaClient] Auto-initializing funnel...",{customerId:n.customerId,storeId:e.store.id,accountId:p,funnelId:C||"auto-detect"}),this.funnel.autoInitialize({customerId:n.customerId,sessionId:n.sessionId},{id:e.store.id,accountId:p},C).catch(E=>{console.error("[TagadaClient] Funnel auto-initialization failed:",E)})}else console.warn("[TagadaClient] Cannot auto-initialize funnel: accountId is missing")}}getCurrencySymbol(e){return{USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5",CAD:"C$",AUD:"A$"}[e]||e}getCurrencyName(e){return{USD:"US Dollar",EUR:"Euro",GBP:"British Pound",JPY:"Japanese Yen",CAD:"Canadian Dollar",AUD:"Australian Dollar"}[e]||e}getAccountId(){var e,n,r;return((e=this.state.store)==null?void 0:e.accountId)||((n=this.state.pluginConfig)==null?void 0:n.accountId)||((r=this.state.session)==null?void 0:r.accountId)||""}updatePluginConfig(e){this.state.debugMode&&console.log("[TagadaClient] Hot-reloading config:",e);let n=w(w({},this.state.pluginConfig.config),e);this.updateState({pluginConfig:N(w({},this.state.pluginConfig),{config:n})}),this.bus.emit("CONFIG_UPDATED",n),this.state.debugMode&&console.log("[TagadaClient] Config updated successfully")}setupConfigHotReload(){if(typeof window=="undefined")return;let e=n=>{var r,s;if(((r=n.data)==null?void 0:r.type)==="TAGADAPAY_CONFIG_UPDATE"){let{config:o}=n.data;this.state.debugMode&&console.log("[TagadaClient] Received config update from parent:",o),this.updatePluginConfig(o)}else if(((s=n.data)==null?void 0:s.type)==="APPLY_STYLES_TO_ELEMENT"){let{elementId:o,styles:i}=n.data;this.state.debugMode&&console.log("[TagadaClient] Received style application request:",{elementId:o,styles:i}),this.applyStylesToElement(o,i)}};window.addEventListener("message",e),this.state.debugMode&&console.log("[TagadaClient] Config hot-reload and style manipulation listeners enabled")}applyStylesToElement(e,n){if(typeof document=="undefined")return;let r="tagada-editor-highlight",s=document.getElementById(r);s&&s.remove();let o=f=>{var E;let m=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]).has(f.tagName.toLowerCase()),d=f;if(m){let T=f.parentElement;if((T==null?void 0:T.getAttribute("data-tagada-highlight-wrapper"))==="true"&&T instanceof HTMLElement)d=T;else{let I=document.createElement("div");I.setAttribute("data-tagada-highlight-wrapper","true");let A=window.getComputedStyle(f),L=A.display;if(L==="inline"?I.style.display="inline-block":I.style.display=L,I.style.position="relative",L==="inline"||L.includes("inline")){let j=A.verticalAlign;j&&j!=="baseline"&&(I.style.verticalAlign=j)}["width","height","minWidth","minHeight","maxWidth","maxHeight","flex","flexGrow","flexShrink","flexBasis","gridColumn","gridRow","gridColumnStart","gridColumnEnd","gridRowStart","gridRowEnd","gridArea","alignSelf","justifySelf","boxSizing","gap","rowGap","columnGap","order","aspectRatio"].forEach(j=>{let G=j.replace(/([A-Z])/g,"-$1").toLowerCase(),M=A.getPropertyValue(G);M&&M.trim()!==""&&(j==="flex"&&M!=="none"&&M!=="0 1 auto"?I.style.flex=M:j==="boxSizing"?I.style.boxSizing=M:I.style.setProperty(G,M))}),f.style&&["width","height","min-width","min-height","max-width","max-height","flex","flex-grow","flex-shrink","flex-basis","grid-column","grid-row","grid-column-start","grid-column-end","grid-row-start","grid-row-end","grid-area","align-self","justify-self","box-sizing","gap","row-gap","column-gap","order","aspect-ratio"].forEach(G=>{let M=f.style.getPropertyValue(G);M&&I.style.setProperty(G,M)}),(E=f.parentNode)==null||E.insertBefore(I,f),I.appendChild(f),d=I}}let h=getComputedStyle(m?f:d);(d.style.position==="static"||!d.style.position)&&(d.style.position="relative");let p=document.createElement("div");p.id=r,p.style.position="absolute",p.style.inset="0",p.style.pointerEvents="none",p.style.zIndex="9999",p.style.boxSizing="border-box",p.style.background="none",p.style.border="none",p.style.outline="none",p.style.margin="0",p.style.padding="0";let S=h.borderRadius;S&&(p.style.borderRadius=S),d.appendChild(p);let C=n||{boxShadow:"0 0 0 2px rgb(239 68 68)"};if(Object.entries(C).forEach(([T,P])=>{let I=T.includes("-")?T.replace(/-([a-z])/g,(A,L)=>L.toUpperCase()):T;T.includes("-")?p.style.setProperty(T,P):p.style[I]=P}),f.scrollIntoView({behavior:"smooth",block:"center"}),this.state.debugMode){let T=Object.entries(C).map(([P,I])=>"".concat(P,": ").concat(I)).join("; ");console.log("[TagadaClient] Applied styles to highlight div of element #".concat(e,":"),T)}},i=5,a=1e3,l=0,c=f=>{let g=window.getComputedStyle(f);return g.display==="none"||g.visibility==="hidden"||g.opacity==="0"||f.hidden||f.offsetWidth===0||f.offsetHeight===0},u=()=>{let f=document.querySelectorAll('[editor-id~="'.concat(e,'"]'));if(f.length===0){if(l+=1,l>=i){this.state.debugMode&&console.warn('[TagadaClient] Element with editor-id containing "'.concat(e,'" not found after ').concat(i," attempts"));return}this.state.debugMode&&console.warn('[TagadaClient] Element with editor-id containing "'.concat(e,'" not found (attempt ').concat(l,"/").concat(i,"), retrying in ").concat(a/1e3,"s")),setTimeout(u,a);return}let g=null;if(f.length===1)g=f[0];else{for(let m=0;m<f.length;m++)if(!c(f[m])){g=f[m];break}g||(g=f[0])}g&&o(g)};u()}};var tr=class{constructor(e){this.apiClient=e}async initCheckout(e){return this.apiClient.post("/api/v1/checkout/session/init",e)}async initCheckoutAsync(e){return this.apiClient.post("/api/v1/checkout/session/init-async",e)}async preloadCheckout(e,n){let r=e.funnelSessionId;!r&&n&&(r=n()||void 0);let s=typeof e.navigationEvent=="string"?{type:e.navigationEvent}:e.navigationEvent,o=N(w(w(w({},e),r&&{funnelSessionId:r}),s&&{navigationEvent:s}),{currentUrl:e.currentUrl||(typeof window!="undefined"?window.location.href:void 0)});return this.apiClient.post("/api/v1/checkout/session/preload",o)}async checkAsyncStatus(e){return this.apiClient.get("/api/public/v1/checkout/async-status/".concat(e))}async getCheckout(e,n){let r=new URLSearchParams;n&&r.set("currency",n),r.set("skipAsyncWait","false");let s="/api/v1/checkout-sessions/".concat(e,"/v2").concat(r.toString()?"?".concat(r.toString()):"");return this.apiClient.get(s)}async getCheckoutRaw(e,n){let r=new URLSearchParams;n&&r.set("currency",n),r.set("skipAsyncWait","true");let s="/api/v1/checkout-sessions/".concat(e,"/v2").concat(r.toString()?"?".concat(r.toString()):"");return this.apiClient.get(s)}async updateAddress(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/address"),{data:n})}async setCheckoutInfo(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/checkout-info"),{shippingAddress:n.shippingAddress,billingAddress:n.differentBillingAddress?n.billingAddress:n.shippingAddress,differentBillingAddress:n.differentBillingAddress||!1})}async applyPromotionCode(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/promotions/apply"),{code:n})}async removePromotion(e,n){return this.apiClient.delete("/api/v1/checkout-sessions/".concat(e,"/promotions/").concat(n))}async getAppliedPromotions(e){return this.apiClient.get("/api/v1/checkout-sessions/".concat(e,"/promotions"))}async replaceSessionLineItems(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/line-items"),{lineItems:n})}async updateLineItems(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/line-items"),{lineItems:n})}async addLineItems(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/line-items/add"),{lineItems:n})}async removeLineItems(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/line-items/remove"),{lineItems:n})}async setItemQuantity(e,n,r,s){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/line-items/set-quantity"),{variantId:n,quantity:r,priceId:s})}async toggleOrderBump(e,n,r){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/toggle-order-bump"),{orderBumpOfferId:n,selected:r})}async updateCustomer(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/customer"),n)}async updateCustomerAndSessionInfo(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/customer-and-session-info"),n)}async previewCheckoutSession(e){return this.apiClient.post("/api/v1/checkout-sessions/preview",e)}async setPaymentMethod(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/payment-method"),{paymentMethodName:n})}};dt();var fc={production:{tenantId:"b1636929-db11-4b01-b2c2-6a97b3444061",publicKey:"key_prod_us_pub_PNMB2AiaECJ463K6QAPNU6"},test:{tenantId:"99821999-faf5-4427-a92c-9267cb930540",publicKey:"key_test_us_pub_VExdfbFQARn821iqP8zNaq"}};function no(t){let e=t?fc.production:fc.test;return{tenantId:e.tenantId,apiKey:e.publicKey}}function pc(){if(typeof window=="undefined")return!1;let t=window.location.hostname;return t.includes("app-dev.tagadapay.com")||t.includes("cdn-dev.tagadapay.com")?!1:t.includes("tagadapay.com")?!0:!(t.includes("tagadapay.dev")||t==="localhost"||t.startsWith("127.")||t.startsWith("192.168.")||t.startsWith("10.")||t.includes(".local")||t===""||t==="0.0.0.0"||t.includes("ngrok")||t.includes(".loclx.io")||t.includes("vercel.app")||t.includes("netlify.app"))}function dn(){return no(pc()).apiKey}function gc(){return no(pc()).tenantId}var nr=class{constructor(e){this.apiClient=e}async getShippingRates(e){return this.apiClient.get("/api/v1/checkout-sessions/".concat(e,"/shipping-rates"))}async setShippingRate(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/shipping-rate"),{shippingRateId:n})}async previewShippingRates(e,n){let r=new URLSearchParams({countryCode:n.countryCode});return n.stateCode&&r.set("stateCode",n.stateCode),this.apiClient.get("/api/v1/checkout-sessions/".concat(e,"/shipping-rates/preview?").concat(r.toString()))}};var Rt=class{constructor(e){this.apiClient=e}async createPaymentInstrument(e){return this.apiClient.post("/api/v1/payment/create-payment-instrument",{paymentInstrumentData:e})}async createCardPaymentInstrument(e,n){var l,c;if(!e)throw new Error("Payment processor not initialized");console.log("Creating card payment instrument");let r=await e.tokens.create({type:"card",data:w({cvc:n.cvc,number:Number(n.cardNumber.replace(/\s+/g,""))},this.getCardMonthAndYear(n.expiryDate)),metadata:{nonSensitiveField:"nonSensitiveValue"}}),{expiration_month:s,expiration_year:o}=this.getCardMonthAndYear(n.expiryDate),i={type:r.type,card:{maskedCardNumber:(c=(l=r.enrichments)==null?void 0:l.cardDetails)!=null&&c.bin?"".concat(r.enrichments.cardDetails.bin,"****").concat(r.enrichments.cardDetails.last4):n.cardNumber.replace(/\d(?=\d{4})/g,"*"),expirationMonth:s,expirationYear:o},token:r.id},a=await this.apiClient.post("/api/v1/payment/create-payment-instrument",{paymentInstrumentData:i});return console.log("Payment instrument created:",a),a}async createApplePayPaymentInstrument(e,n){if(!e)throw new Error("Payment processor not initialized");if(!n.id)throw new Error("Apple Pay token is missing");let r={type:"apple_pay",token:n.id,dpanType:n.type,card:{bin:n.card.bin,last4:n.card.last4,expirationMonth:n.card.expiration_month,expirationYear:n.card.expiration_year,brand:n.card.brand}};return await this.apiClient.post("/api/v1/payment/create-payment-instrument",{paymentInstrumentData:r})}async createGooglePayPaymentInstrument(e,n){var o;if(!e)throw new Error("Payment processor not initialized");if(!n.id)throw new Error("Google Pay token is missing");let r={type:"google_pay",token:n.id,dpanType:n.type,card:{bin:n.card.bin,last4:n.card.last4,expirationMonth:n.card.expiration_month,expirationYear:n.card.expiration_year,brand:n.card.brand},authMethod:(o=n==null?void 0:n.details)==null?void 0:o.auth_method};return await this.apiClient.post("/api/v1/payment/create-payment-instrument",{paymentInstrumentData:r})}async createApmPaymentInstrument(e){console.log("Creating APM payment instrument:",e);let n={type:"apm",provider:e.provider,paymentMethod:e.paymentMethod,processorId:e.processorId},r=await this.apiClient.post("/api/v1/payment/create-payment-instrument",{paymentInstrumentData:n});return console.log("APM payment instrument created:",r),r}getCardMonthAndYear(e){let[n,r]=e.split("/"),s=new Date().getFullYear(),o=Math.floor(s/100)*100,i=Number(r)+o;return{expiration_month:Number(n),expiration_year:i}}async processPaymentDirect(e,n,r,s={}){console.log("[PaymentsResource] processPaymentDirect START",s.paymentFlowId?"(flow: ".concat(s.paymentFlowId,")"):""),console.log("[PaymentsResource] Full options object:",JSON.stringify(s,null,2)),console.log("[PaymentsResource] processorId:",s.processorId,"paymentMethod:",s.paymentMethod);try{let o=w(w(w(w(w(w(w({checkoutSessionId:e,paymentInstrumentId:n},r&&{threedsSessionId:r}),s.initiatedBy&&{initiatedBy:s.initiatedBy}),s.source&&{source:s.source}),s.paymentFlowId&&{paymentFlowId:s.paymentFlowId}),s.processorId&&{processorId:s.processorId}),s.paymentMethod&&{paymentMethod:s.paymentMethod}),s.isExpress&&{isExpress:s.isExpress});console.log("[PaymentsResource] Request body being sent:",JSON.stringify(o,null,2));let i=await this.apiClient.post("/api/public/v1/checkout/pay-v2",o);return console.log("[PaymentsResource] processPaymentDirect SUCCESS:",i),i}catch(o){throw console.error("[PaymentsResource] processPaymentDirect ERROR:",o),o}}async getCardPaymentInstruments(){return this.apiClient.get("/api/v1/payment-instruments/customer")}async markPaymentActionProcessed(e){return this.apiClient.post("/api/v1/payments/require-action/processed",{paymentId:e})}async getPaymentStatus(e){return this.apiClient.get("/api/v1/payments/".concat(e))}async retrievePayment(e){return this.apiClient.post("/api/v1/payments/retrieve",{paymentId:e})}async saveRadarSession(e){return this.apiClient.post("/api/v1/radar-sessions",e)}async completePaymentAfterAction(e){return this.apiClient.post("/api/v1/payments/complete-after-3ds",{paymentId:e})}async updateThreedsStatus(e){return this.apiClient.post("/api/v1/threeds/status",e)}};var rr=class{constructor(e){this.apiClient=e}async getOrder(e){let n=await this.apiClient.get("/api/v1/orders/".concat(e));if(typeof n=="object"&&n!==null&&"success"in n&&n.success===!1)throw new Error(n.error||"Failed to fetch order");let r=typeof n=="object"&&n!==null&&"order"in n?n.order:n;if(!r)throw new Error("Order not found");return r}async createOrder(e){return this.apiClient.post("/api/v1/orders",{checkoutSessionId:e})}async updateOrderStatus(e,n){return this.apiClient.patch("/api/v1/orders/".concat(e,"/status"),{status:n})}async addOrderItems(e,n){return this.apiClient.post("/api/v1/orders/".concat(e,"/items"),{items:n})}async getOrderLineItems(e){return(await this.getOrder(e)).items||[]}};var sr=class{constructor(e){this.apiClient=e}async getPaymentMethods(e){return this.apiClient.get("/api/v1/payment-methods?checkoutSessionId=".concat(encodeURIComponent(e)))}async updateCheckoutSessionAddress(e,n){return this.apiClient.post("/api/v1/checkout-sessions/".concat(e,"/address"),n)}async updateCustomerEmail(e,n){return this.apiClient.post("/api/v1/customers/".concat(e),n)}};var vt=class{constructor(e){this.apiClient=e}async getStoreConfig(e){return await this.apiClient.get("/api/v1/checkout/config?storeId=".concat(e))}};var Pt=class{constructor(e){this.apiClient=e}async createSession(e){return this.apiClient.post("/api/v1/threeds/create-session",e)}};var mc="https://cvwnizdbugpz6jwk.public.blob.vercel-storage.com/geodata/v1";var At=new Map,or=new Map,ro=new Map,so=new Map;async function Jp(t){let e=At.get(t);if(e)return e;let n=ro.get(t);return n||(n=(async()=>{let r="".concat(mc,"/").concat(t,"/countries.json"),s=await fetch(r);if(!s.ok)throw new Error("Geodata fetch failed: ".concat(r," (").concat(s.status,")"));let o=await s.json();return At.set(t,o),ro.delete(t),o})(),ro.set(t,n),n)}async function Yp(t){let e=or.get(t);if(e)return e;let n=so.get(t);return n||(n=(async()=>{let r="".concat(mc,"/").concat(t,"/regions.json"),s=await fetch(r);if(!s.ok)throw new Error("Geodata fetch failed: ".concat(r," (").concat(s.status,")"));let o=await s.json();return or.set(t,o),so.delete(t),o})(),so.set(t,n),n)}function Xp(t){return At.get(t)||At.get("en")||{}}function Zp(t){return or.get(t)||or.get("en")||{}}async function ir(t="en"){await Promise.all([Jp(t),Yp(t)])}var hc=(t="en")=>{let e=Xp(t);return Object.entries(e).map(([n,r])=>({code:n,name:r.n,iso3:r.i3,numeric:r.nu,uniqueKey:"country-".concat(n)})).sort((n,r)=>n.name.localeCompare(r.name))},yc=(t,e="en")=>{let r=Zp(e)[t];return r?r.map(([s,o],i)=>({code:s,name:o,countryCode:t,uniqueKey:"state-".concat(t,"-").concat(s,"-").concat(i)})).sort((s,o)=>s.name.localeCompare(o.name)):[]};function bc(t){return At.has(t)}function wc(){return[...At.keys()]}async function Sc(t){await ir(t)}typeof globalThis!="undefined"&&typeof fetch!="undefined"&&ir("en").catch(()=>{});var ar=class{static getCountriesData(e="en"){try{let n=hc(e),r={};return n.forEach(s=>{r[s.code]={iso:s.code,iso3:s.iso3||"",numeric:s.numeric||0,name:s.name}}),r}catch(n){return console.error("Failed to load ISO data for language: ".concat(e),n),{}}}static getRegions(e,n="en"){try{return yc(e,n).map(s=>({iso:s.code,name:s.name}))}catch(r){return[]}}static findRegion(e,n,r="en"){var o;return(o=this.getRegions(e,r).find(i=>i.iso===n))!=null?o:null}static mapGoogleToISO(e,n,r,s="en"){let o=this.getRegions(r,s);if(o.length===0)return null;let i=o.find(a=>a.iso===e);return i||(i=o.find(a=>a.name.toLowerCase()===e.toLowerCase()),i)||(i=o.find(a=>a.name.toLowerCase()===n.toLowerCase()),i)?i:(i=o.find(a=>a.name.toLowerCase().includes(n.toLowerCase())||n.toLowerCase().includes(a.name.toLowerCase())),i!=null?i:null)}static isLanguageRegistered(e){return bc(e)}static getRegisteredLanguages(){return wc()}static async importLanguage(e){return Sc(e)}static async ensureLoaded(e="en"){return ir(e)}static getAvailableLanguages(){return["en","ru","de","fr","es","zh","hi","pt","ja","ar","it","he"]}};var _t=class{static initialize(e){var n,r;this.apiKey=e,typeof window!="undefined"&&((r=(n=window.google)==null?void 0:n.maps)!=null&&r.places)&&(this.service=new window.google.maps.places.AutocompleteService)}static async searchPlaces(e,n={}){return!this.service||!e.trim()?[]:new Promise((r,s)=>{this.service.getPlacePredictions({input:e,types:n.types||["address"],componentRestrictions:n.componentRestrictions},(o,i)=>{var a,l,c;i===((c=(l=(a=window.google)==null?void 0:a.maps)==null?void 0:l.places)==null?void 0:c.PlacesServiceStatus.OK)&&o?r(o):r([])})})}static async getPlaceDetails(e){var n,r;return typeof window=="undefined"||!((r=(n=window.google)==null?void 0:n.maps)!=null&&r.places)?null:new Promise((s,o)=>{new window.google.maps.places.PlacesService(document.createElement("div")).getDetails({placeId:e,fields:["place_id","formatted_address","address_components","geometry"]},(a,l)=>{var c,u,f;l===((f=(u=(c=window.google)==null?void 0:c.maps)==null?void 0:u.places)==null?void 0:f.PlacesServiceStatus.OK)&&a?s(a):s(null)})})}static extractAddressComponents(e){let n={};for(let r of e.address_components){let s=r.types;s.includes("street_number")?n.streetNumber=r.long_name:s.includes("route")?n.route=r.long_name:s.includes("locality")?(n.city=r.long_name,n.locality=r.long_name):s.includes("administrative_area_level_2")?(n.administrativeAreaLevel2=r.short_name,n.administrativeAreaLevel2Long=r.long_name,n.city||(n.city=r.long_name,n.locality=r.long_name)):s.includes("administrative_area_level_1")?(n.state=r.long_name,n.administrativeAreaLevel1=r.short_name,n.administrativeAreaLevel1Long=r.long_name):s.includes("postal_code")?n.postalCode=r.long_name:s.includes("country")&&(n.country=r.long_name,n.countryCode=r.short_name,n.iso=r.short_name)}return!n.administrativeAreaLevel1&&n.administrativeAreaLevel2&&(n.state=n.administrativeAreaLevel2Long||n.administrativeAreaLevel2,n.administrativeAreaLevel1=n.administrativeAreaLevel2,n.administrativeAreaLevel1Long=n.administrativeAreaLevel2Long),n}};_t.apiKey=null,_t.service=null;Ss();var oo=class{static findVariant(e,n){for(let r of e){let s=r.variants.find(o=>o.id===n);if(s)return s}return null}static getVariantPrice(e,n="USD"){let r=e.prices.find(o=>o.currency===n);if(r)return r;let s=e.prices.find(o=>o.default);return s||e.prices[0]||null}static getAllVariants(e){let n=[];for(let r of e)if(r.variants)for(let s of r.variants)n.push({product:r,variant:s});return n}static filterVariants(e,n){let r=[];for(let s of e)if(s.variants)for(let o of s.variants)n(o,s)&&r.push({product:s,variant:o});return r}};var io=class{static getOrderLineItems(e){return e.items||[]}static getOrderTotal(e){return e.paidAmount||0}static getOrderStatus(e){return e.status||"unknown"}static isOrderCompleted(e){return e.status==="completed"||e.status==="fulfilled"}static isOrderPending(e){return e.status==="pending"||e.status==="processing"}static isOrderCancelled(e){return e.status==="cancelled"||e.status==="refunded"}};function Qp(t,e="USD",n="en-US"){let r=fn.getDecimalPlaces(e),s;r===0?s=t/100:s=t/Math.pow(10,r);try{return new Intl.NumberFormat(n,{style:"currency",currency:e,minimumFractionDigits:r,maximumFractionDigits:r}).format(s)}catch(o){let i=fn.getCurrencySymbol(e);return"".concat(i).concat(s.toFixed(r))}}var fn=class{static getCurrency(e,n="USD"){var s,o,i;let r;return typeof(e==null?void 0:e.currency)=="string"?r=e.currency:(s=e==null?void 0:e.currency)!=null&&s.code?r=e.currency.code:(i=(o=e==null?void 0:e.store)==null?void 0:o.presentmentCurrencies)!=null&&i[0]?r=e.store.presentmentCurrencies[0]:r=n,{code:r,symbol:this.getCurrencySymbol(r),name:this.getCurrencyName(r),decimalPlaces:this.getDecimalPlaces(r)}}static getCurrencySymbol(e){return{USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5",CAD:"C$",AUD:"A$",CHF:"CHF",CNY:"\xA5",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"z\u0142",CZK:"K\u010D",HUF:"Ft",RON:"lei",BGN:"\u043B\u0432",HRK:"kn",RUB:"\u20BD",UAH:"\u20B4",TRY:"\u20BA",BRL:"R$",ARS:"$",CLP:"$",COP:"$",MXN:"$",PEN:"S/",UYU:"$U",VEF:"Bs",ZAR:"R",EGP:"\xA3",MAD:"\u062F.\u0645.",TND:"\u062F.\u062A",DZD:"\u062F.\u062C",LYD:"\u0644.\u062F",NGN:"\u20A6",GHS:"\u20B5",KES:"KSh",UGX:"USh",TZS:"TSh",ETB:"Br",ZMW:"ZK",BWP:"P",SZL:"L",LSL:"L",NAD:"N$",MUR:"\u20A8",SCR:"\u20A8",KWD:"\u062F.\u0643",BHD:"\u062F.\u0628",QAR:"\u0631.\u0642",AED:"\u062F.\u0625",OMR:"\u0631.\u0639.",YER:"\uFDFC",SAR:"\u0631.\u0633",JOD:"\u062F.\u0627",LBP:"\u0644.\u0644",ILS:"\u20AA",INR:"\u20B9",PKR:"\u20A8",BDT:"\u09F3",LKR:"\u20A8",NPR:"\u20A8",AFN:"\u060B",KZT:"\u20B8",UZS:"\u043B\u0432",KGS:"\u043B\u0432",TJS:"SM",TMT:"T",AZN:"\u20BC",GEL:"\u20BE",AMD:"\u058F",KRW:"\u20A9",THB:"\u0E3F",VND:"\u20AB",IDR:"Rp",MYR:"RM",SGD:"S$",PHP:"\u20B1",TWD:"NT$",HKD:"HK$",MOP:"MOP$",BND:"B$",LAK:"\u20AD",KHR:"\u17DB",MMK:"K",BOB:"Bs",PYG:"\u20B2",GTQ:"Q",HNL:"L",NIO:"C$",CRC:"\u20A1",PAB:"B/.",DOP:"RD$",JMD:"J$",TTD:"TT$",BBD:"Bds$",XCD:"EC$",AWG:"\u0192",ANG:"\u0192",SRD:"$",GYD:"G$",VES:"Bs.S",VED:"Bs.D"}[e]||e}static getCurrencyName(e){return{USD:"US Dollar",EUR:"Euro",GBP:"British Pound",JPY:"Japanese Yen",CAD:"Canadian Dollar",AUD:"Australian Dollar",CHF:"Swiss Franc",CNY:"Chinese Yuan",SEK:"Swedish Krona",NOK:"Norwegian Krone",DKK:"Danish Krone",PLN:"Polish Zloty",CZK:"Czech Koruna",HUF:"Hungarian Forint",RON:"Romanian Leu",BGN:"Bulgarian Lev",HRK:"Croatian Kuna",RUB:"Russian Ruble",UAH:"Ukrainian Hryvnia",TRY:"Turkish Lira",BRL:"Brazilian Real",ARS:"Argentine Peso",CLP:"Chilean Peso",COP:"Colombian Peso",MXN:"Mexican Peso",PEN:"Peruvian Sol",UYU:"Uruguayan Peso",VEF:"Venezuelan Bolivar",ZAR:"South African Rand",EGP:"Egyptian Pound",MAD:"Moroccan Dirham",TND:"Tunisian Dinar",DZD:"Algerian Dinar",LYD:"Libyan Dinar",NGN:"Nigerian Naira",GHS:"Ghanaian Cedi",KES:"Kenyan Shilling",UGX:"Ugandan Shilling",TZS:"Tanzanian Shilling",ETB:"Ethiopian Birr",ZMW:"Zambian Kwacha",BWP:"Botswana Pula",SZL:"Swazi Lilangeni",LSL:"Lesotho Loti",NAD:"Namibian Dollar",MUR:"Mauritian Rupee",SCR:"Seychellois Rupee",KWD:"Kuwaiti Dinar",BHD:"Bahraini Dinar",QAR:"Qatari Riyal",AED:"UAE Dirham",OMR:"Omani Rial",YER:"Yemeni Rial",SAR:"Saudi Riyal",JOD:"Jordanian Dinar",LBP:"Lebanese Pound",ILS:"Israeli Shekel",INR:"Indian Rupee",PKR:"Pakistani Rupee",BDT:"Bangladeshi Taka",LKR:"Sri Lankan Rupee",NPR:"Nepalese Rupee",AFN:"Afghan Afghani",KZT:"Kazakhstani Tenge",UZS:"Uzbekistani Som",KGS:"Kyrgyzstani Som",TJS:"Tajikistani Somoni",TMT:"Turkmenistani Manat",AZN:"Azerbaijani Manat",GEL:"Georgian Lari",AMD:"Armenian Dram",KRW:"South Korean Won",THB:"Thai Baht",VND:"Vietnamese Dong",IDR:"Indonesian Rupiah",MYR:"Malaysian Ringgit",SGD:"Singapore Dollar",PHP:"Philippine Peso",TWD:"Taiwan Dollar",HKD:"Hong Kong Dollar",MOP:"Macanese Pataca",BND:"Brunei Dollar",LAK:"Lao Kip",KHR:"Cambodian Riel",MMK:"Myanmar Kyat",BOB:"Bolivian Boliviano",PYG:"Paraguayan Guarani",GTQ:"Guatemalan Quetzal",HNL:"Honduran Lempira",NIO:"Nicaraguan Cordoba",CRC:"Costa Rican Colon",PAB:"Panamanian Balboa",DOP:"Dominican Peso",JMD:"Jamaican Dollar",TTD:"Trinidad and Tobago Dollar",BBD:"Barbadian Dollar",XCD:"East Caribbean Dollar",AWG:"Aruban Florin",ANG:"Netherlands Antillean Guilder",SRD:"Surinamese Dollar",GYD:"Guyanese Dollar",VES:"Venezuelan Bolivar Soberano",VED:"Venezuelan Bolivar Digital"}[e]||e}static getDecimalPlaces(e){var r;return(r={JPY:0,KRW:0,VND:0,IDR:0,LAK:0,KHR:0,MMK:0,PYG:0,VEF:0,VES:0,VED:0}[e])!=null?r:2}};var ao=class{static getCheckoutSessionId(e){var n;return((n=e.checkoutSession)==null?void 0:n.id)||""}static getLineItems(e){var r;let n=(r=e.checkoutSession)==null?void 0:r.lineItems;return Array.isArray(n)?n:[]}static getTotal(e){var r;let n=(r=e.checkoutSession)==null?void 0:r.totalPrice;return typeof n=="number"?n:0}static isClubMember(e){return e.customerIsClubMember||!1}};var co=class{static isValidPromotion(e){return!!(e.id&&e.name)}static getPromotionType(e){return e.type||"unknown"}static hasRules(e){return!!(e.rules&&e.rules.length>0)}static hasActions(e){return!!(e.actions&&e.actions.length>0)}};var lo=class{static isValidOffer(e){return!!(e.id&&e.summaries&&e.summaries.length>0)}static getOfferTotal(e){var n,r;return((r=(n=e.summaries)==null?void 0:n[0])==null?void 0:r.totalAmount)||0}static getOfferAdjustedTotal(e){var n,r;return((r=(n=e.summaries)==null?void 0:n[0])==null?void 0:r.totalAdjustedAmount)||0}static hasItems(e){return!!(e.offerLineItems&&e.offerLineItems.length>0)}static getOfferCurrency(e){var n,r;return((r=(n=e.summaries)==null?void 0:n[0])==null?void 0:r.currency)||"USD"}static getOfferTitle(e,n="en"){var r,s;return((r=e.titleTrans)==null?void 0:r[n])||((s=e.titleTrans)==null?void 0:s.en)||"Offer ".concat(e.id)}};var uo=class{static isValidOffer(e){return!!(e.id&&e.name&&e.price>0)}static toggleSelection(e){return N(w({},e),{isSelected:!e.isSelected})}static calculatePreview(e,n=0){let r=n+e.price,s=e.isSelected?r:n;return{offer:e,totalAmount:r,adjustedAmount:s}}static getSelectedOffers(e){return e.filter(n=>n.isSelected)}static getSelectedTotal(e){return e.filter(n=>n.isSelected).reduce((n,r)=>n+r.price,0)}};var eg={session:t=>["funnel","session",t],allSessions:()=>["funnel","sessions"],funnelMeta:t=>["funnel","meta",t]};function Ec(t,e,n="*"){let r={type:"TAGADAPAY_CONFIG_UPDATE",config:e,timestamp:Date.now()};t.postMessage(r,n)}function tg(t,e="iframe"){if(typeof document=="undefined")return;let n=document.querySelectorAll(e);n.forEach(r=>{r.contentWindow&&Ec(r.contentWindow,t)}),console.log("[ConfigHotReload] Broadcasted config update to ".concat(n.length," iframe(s)"))}function ng(t){if(typeof window=="undefined")return()=>{};let e=n=>{var r;((r=n.data)==null?void 0:r.type)==="TAGADAPAY_CONFIG_UPDATE"&&t(n.data.config)};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}function rg(t,e=150){let n=null;return r=>{n&&clearTimeout(n),n=setTimeout(()=>{t(r),n=null},e)}}var ho=Xi(Ac()),ie,It=typeof window!="undefined"&&typeof document!="undefined",gg=It?history.pushState.bind(history):null,mg=It?history.replaceState.bind(history):null;function ur(){ie=void 0}It&&(window.addEventListener("popstate",ur),window.addEventListener("hashchange",ur),history.pushState=function(...t){return ur(),gg.apply(this,t)},history.replaceState=function(...t){return ur(),mg.apply(this,t)});function pn(){if(!It)return null;if(ie!==void 0)return console.log("[TagadaPay SDK] \u{1F4E6} Returning cached internal path:",ie),ie;console.log("[TagadaPay SDK] \u{1F50D} getInternalPath() called for:",window.location.pathname);try{let t=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"||window.location.hostname.endsWith(".localhost");if(console.log("[TagadaPay SDK] \u{1F3E0} isLocalhost:",t),t){let i=new URLSearchParams(window.location.search).get("__remap");if(console.log("[TagadaPay SDK] \u{1F50D} Query parameter __remap:",i),i)return ie=i,i;try{let a=localStorage.getItem("tagadapay-remap");if(console.log("[TagadaPay SDK] \u{1F50D} localStorage tagadapay-remap:",a),a)try{let l=JSON.parse(a);if(console.log("[TagadaPay SDK] \u{1F4DD} Parsed remap config:",l),l.externalPath&&l.internalPath){let c=window.location.pathname;console.log("[TagadaPay SDK] \u{1F50D} Checking if",c,"matches pattern",l.externalPath);let f=(0,ho.match)(l.externalPath,{decode:decodeURIComponent,end:!0})(c);return console.log("[TagadaPay SDK] \u{1F3AF} Match result:",f),f!==!1?(ie=l.internalPath,console.log("[TagadaPay SDK] \u2705 Path remap: ".concat(l.externalPath," \u2192 ").concat(l.internalPath)),console.log("[TagadaPay SDK] \u2705 Current URL ".concat(c," matches external pattern")),console.log("[TagadaPay SDK] \u{1F4E6} Caching and returning:",l.internalPath),l.internalPath):(console.log("[TagadaPay SDK] \u274C Current URL ".concat(c," does NOT match external pattern ").concat(l.externalPath)),ie=null,null)}else console.log("[TagadaPay SDK] \u26A0\uFE0F Parsed config missing externalPath or internalPath")}catch(l){return console.log("[TagadaPay SDK] \u26A0\uFE0F Failed to parse as JSON, using legacy format:",l),ie=a,a}else console.log("[TagadaPay SDK] \u{1F4ED} No localStorage tagadapay-remap found")}catch(a){console.log("[TagadaPay SDK] \u274C localStorage error:",a)}}let e=document.querySelector('meta[name="tagadapay-path-remap"]');if(e)try{let o=e.getAttribute("content");if(o){let i=decodeURIComponent(o),a=JSON.parse(i);if(a.internal)return console.log("[TagadaPay SDK] \u2705 Got internal path from full remap config:",a.internal),ie=a.internal,a.internal}}catch(o){console.error("[TagadaPay SDK] Error parsing full remap config:",o)}let n=document.querySelector('meta[name="x-plugin-internal-path"]');if(!n)return console.log("[TagadaPay SDK] \u2139\uFE0F No path remap meta tags found"),ie=null,null;let r=n.getAttribute("content");if(!r||r.trim()==="")return ie=null,null;let s=r.trim();return s.startsWith("/")?(console.log("[TagadaPay SDK] \u2705 Got internal path from legacy meta tag:",s),ie=s,s):(ie=null,null)}catch(t){return ie=null,null}}function Ic(){return pn()!==null}function xc(){if(!It)throw new Error("[TagadaPay SDK] getPathInfo() cannot be called in SSR context");try{let t=window.location.pathname,e=pn(),n=new URLSearchParams(window.location.search),r=window.location.hash.replace(/^#/,"");return{externalPath:t,internalPath:e,isRemapped:e!==null,fullUrl:window.location.href,query:n,hash:r}}catch(t){return{externalPath:"/",internalPath:null,isRemapped:!1,fullUrl:"",query:new URLSearchParams,hash:""}}}function dr(t,e){try{if(t===e)return{matched:!0,params:{}};if(!(e.includes(":")||e.includes("*")||e.includes("{")))return{matched:t===e,params:{}};let s=(0,ho.match)(e,{decode:decodeURIComponent,end:!0})(t);if(s===!1)return{matched:!1,params:{}};let o={};return typeof s=="object"&&s.params&&Object.keys(s.params).forEach(i=>{let a=s.params[i];o[i]=Array.isArray(a)?a.join("/"):String(a)}),{matched:!0,params:o}}catch(n){return{matched:t===e,params:{}}}}function hg(t,e,n){let r=_c(e),s=_c(n);if(r.length===0||r.length!==s.length)return t;let o={};return r.forEach((i,a)=>{let l=s[a],c=t[i];c!==void 0&&(o[l]=c)}),o}function _c(t){let e=t.match(/:([a-zA-Z0-9_]+)/g);return e?e.map(n=>n.substring(1)):[]}function Oc(t){if(typeof t!="string")throw new Error("[TagadaPay SDK] internalPath must be a string, got ".concat(typeof t));if(t.trim()==="")throw new Error("[TagadaPay SDK] internalPath cannot be empty");if(!t.startsWith("/"))throw new Error('[TagadaPay SDK] internalPath must start with /, got "'.concat(t,'"'));if(!It)return{matched:!1,params:{}};try{let e=window.location.pathname,n=pn();if(n){if(!dr(n,t).matched)return{matched:!1,params:{}};let s=null;if(typeof localStorage!="undefined")try{let i=localStorage.getItem("tagadapay-remap");if(i){let a=JSON.parse(i);a.externalPath&&a.internalPath===n&&(s=a.externalPath)}}catch(i){}if(!s&&typeof document!="undefined"){console.log("[TagadaPay SDK] \u{1F50D} Checking for production path remap meta tag...");let i=document.querySelector('meta[name="tagadapay-path-remap"]');if(i)try{let a=i.getAttribute("content");if(console.log("[TagadaPay SDK] \u{1F4C4} Found meta tag content (encoded):",(a==null?void 0:a.substring(0,100))+"..."),a){let l=decodeURIComponent(a);console.log("[TagadaPay SDK] \u{1F4C4} Decoded content:",l);let c=JSON.parse(l);console.log("[TagadaPay SDK] \u{1F4E6} Parsed remap config:",c),console.log("[TagadaPay SDK] \u{1F50D} Checking if internal path matches:",{parsedInternal:c.internal,remappedInternalPath:n}),c.external&&c.internal===n?(s=c.external,console.log("[TagadaPay SDK] \u2705 Using external pattern from meta tag:",s)):console.log("[TagadaPay SDK] \u26A0\uFE0F Internal path mismatch - not using meta tag config")}}catch(a){console.error("[TagadaPay SDK] \u274C Error parsing path remap meta tag:",a)}else console.log("[TagadaPay SDK] \u274C No tagadapay-path-remap meta tag found")}if(s){let i=dr(e,s);if(i.matched){console.log("[TagadaPay SDK] \u{1F504} Mapping params from external to internal pattern"),console.log("[TagadaPay SDK] External params:",i.params),console.log("[TagadaPay SDK] External pattern:",s),console.log("[TagadaPay SDK] Internal pattern:",t);let a=hg(i.params,s,t);return console.log("[TagadaPay SDK] Mapped params:",a),{matched:!0,params:a}}}return{matched:!0,params:dr(e,t).params}}return dr(e,t)}catch(e){return{matched:!1,params:{}}}}dt();dt();var bs=class{constructor(e){this.callbacks={};this.basisTheory=null;this.btInitPromise=null;this.bt3dsClass=null;this.bt3dsInitPromise=null;this.storeConfig=null;this.storeConfigPromise=null;this.pollTimer=null;this.pollAttempts=0;this.isPollingActive=!1;this.redirectReturnProcessed=!1;this.paymentsResource=new Rt(e.apiClient),this.threedsResource=new Pt(e.apiClient),this.storeConfigResource=new vt(e.apiClient),this.storeId=e.storeId}get payments(){return this.paymentsResource}setCallbacks(e){this.callbacks=e}warmup(){this.initBasisTheory(),this.initBt3ds(),this.storeId&&this.fetchStoreConfig()}destroy(){this.stopPolling(),this.basisTheory=null,this.btInitPromise=null,this.bt3dsClass=null,this.bt3dsInitPromise=null,this.storeConfig=null,this.storeConfigPromise=null}initBasisTheory(){return this.basisTheory?Promise.resolve(this.basisTheory):this.btInitPromise?this.btInitPromise:(this.btInitPromise=(async()=>{try{let e=dn(),{BasisTheory:n}=await Promise.resolve().then(()=>Xi(bd())),r=await new n().init(e,{elements:!1});return this.basisTheory=r,console.log("[PaymentService] BasisTheory initialized"),this.basisTheory}catch(e){return console.error("[PaymentService] BasisTheory init failed:",e),null}})(),this.btInitPromise)}getBtApiKey(){return dn()}initBt3ds(){return this.bt3dsClass?Promise.resolve(this.bt3dsClass):this.bt3dsInitPromise?this.bt3dsInitPromise:(this.bt3dsInitPromise=(async()=>{try{let{BasisTheory3ds:e}=await Promise.resolve().then(()=>(Bd(),Ld));return this.bt3dsClass=e,console.log("[PaymentService] BasisTheory 3DS loaded"),this.bt3dsClass}catch(e){return console.error("[PaymentService] BasisTheory 3DS load failed:",e),null}})(),this.bt3dsInitPromise)}fetchStoreConfig(){return this.storeConfig?Promise.resolve(this.storeConfig):this.storeConfigPromise?this.storeConfigPromise:this.storeId?(this.storeConfigPromise=(async()=>{try{return this.storeConfig=await this.storeConfigResource.getStoreConfig(this.storeId),this.storeConfig}catch(e){return null}})(),this.storeConfigPromise):Promise.resolve(null)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.isPollingActive=!1,this.pollAttempts=0}startPolling(e,n,r=20,s=1500){this.stopPolling(),this.isPollingActive=!0,this.pollAttempts=0,console.log("[PaymentService] Starting payment polling:",e);let o=async()=>{var i;if(this.isPollingActive){this.pollAttempts++;try{let a=await this.paymentsResource.getPaymentStatus(e);if(console.log("[PaymentService] Poll #".concat(this.pollAttempts,": ").concat(a.status," / ").concat(a.subStatus)),!this.isPollingActive)return;if(a.status==="succeeded"||a.status==="pending"&&a.subStatus==="authorized"){this.stopPolling(),n.onSuccess(a);return}if(a.requireAction!=="none"&&a.requireActionData&&!a.requireActionData.processed){this.stopPolling(),(i=n.onRequireAction)==null||i.call(n,a);return}if(a.status!=="succeeded"&&a.status!=="pending"){this.stopPolling(),n.onFailure(a.status||"Payment failed");return}this.pollAttempts>=r&&(this.stopPolling(),n.onFailure("Payment verification timeout"))}catch(a){this.pollAttempts>=3&&(this.stopPolling(),n.onFailure("Payment verification failed due to network errors"))}}};o(),this.pollTimer=setInterval(()=>void o(),s)}async processAndHandle(e,n,r,s){var a,l,c,u,f,g,m,d;let o=Wt(),i=await this.paymentsResource.processPaymentDirect(e,n,r,{initiatedBy:(s==null?void 0:s.initiatedBy)||"customer",source:(s==null?void 0:s.source)||"checkout",paymentFlowId:o,processorId:s==null?void 0:s.processorId,paymentMethod:s==null?void 0:s.paymentMethod});return console.log("[PaymentService] Payment response:",{paymentId:(a=i.payment)==null?void 0:a.id,status:(l=i.payment)==null?void 0:l.status,requireAction:(c=i.payment)==null?void 0:c.requireAction}),(g=(f=this.callbacks).onCurrentPaymentId)==null||g.call(f,((u=i.payment)==null?void 0:u.id)||null),i.payment.requireAction!=="none"?(await this.handlePaymentAction(i.payment),{success:!0,payment:i.payment,order:i.order,redirecting:!0}):i.payment.status==="succeeded"?((d=(m=this.callbacks).onProcessing)==null||d.call(m,!1),{success:!0,payment:i.payment,order:i.order}):new Promise(h=>{this.startPolling(i.payment.id,{onSuccess:p=>{var S,C;(C=(S=this.callbacks).onProcessing)==null||C.call(S,!1),h({success:!0,payment:p,order:i.order})},onFailure:p=>{var S,C,E,T;(C=(S=this.callbacks).onError)==null||C.call(S,p),(T=(E=this.callbacks).onProcessing)==null||T.call(E,!1),h({success:!1,error:p})},onRequireAction:p=>{this.handlePaymentAction(p)}})})}async handleResumedPayment(e){var n,r,s,o,i,a,l,c,u,f,g,m;if(e.status==="declined"||e.status==="failed"){let d=((n=e.error)==null?void 0:n.message)||((r=e.error)==null?void 0:r.processorMessage)||"Payment declined";(o=(s=this.callbacks).onError)==null||o.call(s,d),(a=(i=this.callbacks).onProcessing)==null||a.call(i,!1),(c=(l=this.callbacks).onFailure)==null||c.call(l,d);return}if(e.status==="succeeded"){(f=(u=this.callbacks).onProcessing)==null||f.call(u,!1),(m=(g=this.callbacks).onSuccess)==null||m.call(g,e);return}if(e.requireAction!=="none"&&e.requireActionData){await this.handlePaymentAction(e);return}this.startPolling(e.id,{onSuccess:d=>{var h,p,S,C;(p=(h=this.callbacks).onProcessing)==null||p.call(h,!1),(C=(S=this.callbacks).onSuccess)==null||C.call(S,d)},onFailure:d=>{var h,p,S,C;(p=(h=this.callbacks).onError)==null||p.call(h,d),(C=(S=this.callbacks).onProcessing)==null||C.call(S,!1)},onRequireAction:d=>{this.handlePaymentAction(d)}})}async handlePaymentAction(e){var r,s,o,i,a,l,c,u,f,g,m,d,h;if(e.requireAction==="none"||(r=e.requireActionData)!=null&&r.processed)return;let n=e.requireActionData;if(n){try{await this.paymentsResource.markPaymentActionProcessed(e.id)}catch(p){}switch(n.type){case"redirect":case"redirect_to_payment":case"processor_auth":{let p=((o=(s=n.metadata)==null?void 0:s.redirect)==null?void 0:o.redirectUrl)||n.redirectUrl||n.url;p?(console.log("[PaymentService] Redirecting:",p),window.location.href=p):e.status==="succeeded"&&((a=(i=this.callbacks).onProcessing)==null||a.call(i,!1),(c=(l=this.callbacks).onSuccess)==null||c.call(l,e));break}case"threeds_auth":{let p=(u=n.metadata)==null?void 0:u.threedsSession;p!=null&&p.acsChallengeUrl&&(console.log("[PaymentService] 3DS challenge redirect:",p.acsChallengeUrl),window.location.href=p.acsChallengeUrl);break}case"error":{let p=n.message||"Payment action failed";(g=(f=this.callbacks).onError)==null||g.call(f,p),(d=(m=this.callbacks).onProcessing)==null||d.call(m,!1);break}case"kesspay_auth":this.handleKessPayAuth(n);break;case"trustflow_auth":this.handleTrustFlowAuth(n);break;case"finix_radar":await this.handleFinixRadar(e,n);break;case"stripe_radar":await this.handleStripeRadar(e,n);break;case"radar":((h=n.metadata)==null?void 0:h.provider)==="airwallex"&&await this.handleAirwallexRadar(e,n);break;case"mastercard_auth":await this.handleMasterCardAuth(e,n);break;default:{console.log("[PaymentService] Unhandled action, starting polling:",n.type),this.startPolling(e.id,{onSuccess:p=>{var S,C,E,T;(C=(S=this.callbacks).onProcessing)==null||C.call(S,!1),(T=(E=this.callbacks).onSuccess)==null||T.call(E,p)},onFailure:p=>{var S,C,E,T;(C=(S=this.callbacks).onError)==null||C.call(S,p),(T=(E=this.callbacks).onProcessing)==null||T.call(E,!1)},onRequireAction:p=>{this.handlePaymentAction(p)}});break}}}}handleKessPayAuth(e){var r,s,o,i,a,l,c,u,f,g,m;let n=(r=e==null?void 0:e.metadata)==null?void 0:r.threeds;if(!(n!=null&&n.challengeHtml)){(o=(s=this.callbacks).onError)==null||o.call(s,"Missing KessPay 3DS challenge HTML"),(a=(i=this.callbacks).onProcessing)==null||a.call(i,!1);return}try{(c=(l=this.callbacks).onProcessing)==null||c.call(l,!1);let d=document.implementation.createHTMLDocument("KessPay 3DS");d.body.innerHTML=n.challengeHtml;let h=d.querySelector("form");if(h){let p=document.createElement("form");p.method=h.method||"POST",p.action=h.action||"",p.style.display="none",h.querySelectorAll("input").forEach(S=>{let C=document.createElement("input");C.type=S.type,C.name=S.name,C.value=S.value,p.appendChild(C)}),document.body.appendChild(p),p.submit()}else document.open(),document.write(n.challengeHtml),document.close()}catch(d){(f=(u=this.callbacks).onError)==null||f.call(u,d instanceof Error?d.message:"KessPay 3DS failed"),(m=(g=this.callbacks).onProcessing)==null||m.call(g,!1)}}handleTrustFlowAuth(e){var r,s,o,i,a,l,c,u,f,g,m;let n=(r=e==null?void 0:e.metadata)==null?void 0:r.trustflow;if(!(n!=null&&n.appId)||!(n!=null&&n.txnId)||!(n!=null&&n.hash)){(o=(s=this.callbacks).onError)==null||o.call(s,"Missing Trust Flow 3DS data"),(a=(i=this.callbacks).onProcessing)==null||a.call(i,!1);return}try{(c=(l=this.callbacks).onProcessing)==null||c.call(l,!1);let d=document.createElement("form");d.method="POST",d.action=n.captureUrl,d.style.display="none";for(let[h,p]of[["APP_ID",n.appId],["TXN_ID",n.txnId],["HASH",n.hash]]){let S=document.createElement("input");S.type="hidden",S.name=h,S.value=p,d.appendChild(S)}document.body.appendChild(d),d.submit()}catch(d){(f=(u=this.callbacks).onError)==null||f.call(u,d instanceof Error?d.message:"Trust Flow 3DS failed"),(m=(g=this.callbacks).onProcessing)==null||m.call(g,!1)}}async handleFinixRadar(e,n){var s,o,i,a,l,c,u,f,g;let r=(s=n.metadata)==null?void 0:s.radar;if(!r){(i=(o=this.callbacks).onError)==null||i.call(o,"Finix radar config missing"),(l=(a=this.callbacks).onProcessing)==null||l.call(a,!1);return}try{await this.loadScript("https://js.finix.com/v/1/finix.js",()=>{var h;return typeof((h=window.Finix)==null?void 0:h.Auth)=="function"});let m=await new Promise((h,p)=>{let S=setTimeout(()=>p(new Error("Timeout waiting for Finix Auth")),1e4),C=window.Finix.Auth(r.environment,r.merchantId,()=>{clearTimeout(S);let T=C.getSessionKey();T?h(T):p(new Error("No Finix session key"))}),E=C.getSessionKey();E&&(clearTimeout(S),h(E))});await this.paymentsResource.saveRadarSession({orderId:r.orderId,finixRadarSessionId:m,finixRadarSessionData:{sessionKey:m,merchantId:r.merchantId,environment:r.environment,createdAt:new Date().toISOString()}});let d=await this.paymentsResource.completePaymentAfterAction(e.id);await this.handleResumedPayment(d)}catch(m){(u=(c=this.callbacks).onError)==null||u.call(c,m instanceof Error?m.message:"Finix radar failed"),(g=(f=this.callbacks).onProcessing)==null||g.call(f,!1)}}async handleStripeRadar(e,n){var s,o,i,a,l,c,u,f,g;let r=(s=n.metadata)==null?void 0:s.radar;if(!(r!=null&&r.publishableKey)){(i=(o=this.callbacks).onError)==null||i.call(o,"Stripe radar config missing"),(l=(a=this.callbacks).onProcessing)==null||l.call(a,!1);return}try{await this.loadScript("https://js.stripe.com/v3/",()=>typeof window.Stripe=="function");let d=await window.Stripe(r.publishableKey).createRadarSession();if(d.error)throw new Error(d.error.message||"Failed to create Radar session");if(!d.radarSession)throw new Error("No radar session returned from Stripe");await this.paymentsResource.saveRadarSession({orderId:r.orderId,stripeRadarSessionId:d.radarSession.id,stripeRadarSessionData:d.radarSession});let h=await this.paymentsResource.completePaymentAfterAction(e.id);await this.handleResumedPayment(h)}catch(m){(u=(c=this.callbacks).onError)==null||u.call(c,m instanceof Error?m.message:"Stripe radar failed"),(g=(f=this.callbacks).onProcessing)==null||g.call(f,!1)}}async handleAirwallexRadar(e,n){var i,a,l,c,u,f,g,m,d,h,p;let r=((i=n.metadata)==null?void 0:i.isTest)||!1,s=(a=e.order)==null?void 0:a.id,o=(l=e.order)==null?void 0:l.checkoutSessionId;if(!s||!o){(u=(c=this.callbacks).onError)==null||u.call(c,"Missing order info for Airwallex radar"),(g=(f=this.callbacks).onProcessing)==null||g.call(f,!1);return}try{let S=crypto.randomUUID(),C=document.getElementById("airwallex-fraud-api");if(C)C.setAttribute("data-order-session-id",S);else{let T=r?"https://static-demo.airwallex.com":"https://static.airwallex.com",P=document.createElement("script");P.type="text/javascript",P.async=!0,P.id="airwallex-fraud-api",P.setAttribute("data-order-session-id",S),P.src="".concat(T,"/webapp/fraud/device-fingerprint/index.js"),await new Promise((I,A)=>{P.onload=()=>I(),P.onerror=()=>A(new Error("Failed to load Airwallex fraud script")),document.body.appendChild(P)})}await this.paymentsResource.saveRadarSession({checkoutSessionId:o,orderId:s,airwallexRadarSessionId:S});let E=await this.paymentsResource.completePaymentAfterAction(e.id);await this.handleResumedPayment(E)}catch(S){(d=(m=this.callbacks).onError)==null||d.call(m,S instanceof Error?S.message:"Airwallex radar failed"),(p=(h=this.callbacks).onProcessing)==null||p.call(h,!1)}}async handleMasterCardAuth(e,n){var s,o,i,a,l,c,u,f,g,m,d,h,p,S;let r=(s=n==null?void 0:n.metadata)==null?void 0:s.threeds;if(!(r!=null&&r.sessionId)||!(r!=null&&r.merchantId)){(i=(o=this.callbacks).onError)==null||i.call(o,"Missing MasterCard 3DS data"),(l=(a=this.callbacks).onProcessing)==null||l.call(a,!1);return}try{(u=(c=this.callbacks).onProcessing)==null||u.call(c,!1),await this.loadScript(r.scriptUrl,()=>!!window.ThreeDS);let C="mastercard-3ds-container",E=document.getElementById(C);E||(E=document.createElement("div"),E.id=C,E.style.cssText="position:absolute;top:-9999px;left:-9999px;width:1px;height:1px;overflow:hidden",document.body.appendChild(E)),await new Promise((A,L)=>{window.ThreeDS.configure({merchantId:r.merchantId,sessionId:r.sessionId,containerId:C,callback:()=>{window.ThreeDS.isConfigured()?A():L(new Error("ThreeDS configuration failed"))},configuration:{userLanguage:"en-US",wsVersion:r.version?parseInt(r.version,10):72}})});let T=await new Promise(A=>{window.ThreeDS.authenticatePayer(r.orderId,r.transactionId,A)}),P=(T==null?void 0:T.htmlRedirectCode)||((m=(g=(f=T==null?void 0:T.restApiResponse)==null?void 0:f.authentication)==null?void 0:g.redirect)==null?void 0:m.html);if(P){let A=document.implementation.createHTMLDocument("MasterCard 3DS");A.body.innerHTML=P;let L=A.querySelector("form");if(L){let K=document.createElement("form");K.method=L.method||"POST",K.action=L.action||"",K.style.display="none",L.querySelectorAll("input").forEach(j=>{let G=document.createElement("input");G.type=j.type,G.name=j.name,G.value=j.value,K.appendChild(G)}),document.body.appendChild(K),K.submit()}else document.open(),document.write(P),document.close()}else if(r.paymentId){let A=await this.paymentsResource.completePaymentAfterAction(r.paymentId);await this.handleResumedPayment(A)}let I=document.getElementById(C);I&&I.remove()}catch(C){(h=(d=this.callbacks).onError)==null||h.call(d,C instanceof Error?C.message:"MasterCard 3DS failed"),(S=(p=this.callbacks).onProcessing)==null||S.call(p,!1)}}async loadScript(e,n){if(typeof window=="undefined"||n())return;if(document.querySelector('script[src="'.concat(e,'"]'))){await this.waitFor(n,1e4);return}let s=document.createElement("script");s.src=e,s.async=!0,await new Promise((o,i)=>{s.onload=()=>o(),s.onerror=()=>i(new Error("Failed to load script: ".concat(e))),document.head.appendChild(s)})}waitFor(e,n){return new Promise((r,s)=>{if(e()){r();return}let o=setTimeout(()=>s(new Error("Timeout")),n),i=()=>{e()?(clearTimeout(o),r()):setTimeout(i,100)};i()})}detectRedirectReturn(){return typeof window=="undefined"||this.redirectReturnProcessed?!1:this.detectAirwallex3dsReturn()?!0:this.detectGenericRedirectReturn()}detectGenericRedirectReturn(){var i,a,l,c,u,f;let e=new URLSearchParams(window.location.search),n=e.get("paymentAction"),r=e.get("paymentActionStatus"),s=e.get("paymentId");return e.get("mode")==="retrieve"||n!=="requireAction"||r!=="completed"||!s?!1:(console.log("[PaymentService] Generic redirect return detected:",s),this.redirectReturnProcessed=!0,(a=(i=this.callbacks).onProcessing)==null||a.call(i,!0),(c=(l=this.callbacks).onCurrentPaymentId)==null||c.call(l,s),(f=(u=this.callbacks).onRedirectReturn)==null||f.call(u,s),this.startPolling(s,{onSuccess:g=>{var m,d,h,p;(d=(m=this.callbacks).onProcessing)==null||d.call(m,!1),this.cleanPaymentUrlParams(),(p=(h=this.callbacks).onSuccess)==null||p.call(h,g)},onFailure:g=>{var m,d,h,p;(d=(m=this.callbacks).onError)==null||d.call(m,g),(p=(h=this.callbacks).onProcessing)==null||p.call(h,!1),this.cleanPaymentUrlParams()},onRequireAction:g=>{this.handlePaymentAction(g)}}),!0)}detectAirwallex3dsReturn(){var a,l,c,u;let e=new URLSearchParams(window.location.search),n=e.get("paymentId"),r=e.get("payment_intent_id"),s=e.get("succeeded"),o=e.get("processorType");return!(r||s!==null)||o!=="airwallex"||!n?!1:(console.log("[PaymentService] Airwallex 3DS return detected:",n),this.redirectReturnProcessed=!0,(l=(a=this.callbacks).onProcessing)==null||l.call(a,!0),(u=(c=this.callbacks).onCurrentPaymentId)==null||u.call(c,n),this.handleAirwallex3dsRedirectReturn(n,r,s),!0)}async handleAirwallex3dsRedirectReturn(e,n,r){var o,i,a,l,c,u,f,g,m,d,h,p,S,C,E,T,P,I,A,L,K,j,G,M,se,Y,Ke,U,ze;let s=()=>{let x=new URLSearchParams(window.location.search);["payment_intent_id","succeeded","processorType","paymentId","paymentAction","paymentActionStatus","error_code","error_message","mode"].forEach(q=>x.delete(q));let ge=x.toString()?"".concat(window.location.pathname,"?").concat(x.toString()):window.location.pathname;window.history.replaceState({},document.title,ge)};if(r==="true")try{await this.paymentsResource.updateThreedsStatus({paymentId:e,status:"succeeded",paymentIntentId:n||""}),s();let x=await this.paymentsResource.retrievePayment(e),ge=((o=x==null?void 0:x.retrieveResult)==null?void 0:o.status)||(x==null?void 0:x.status);if((i=x==null?void 0:x.retrieveResult)!=null&&i.success&&ge==="succeeded"){let q=await this.paymentsResource.getPaymentStatus(e);(l=(a=this.callbacks).onProcessing)==null||l.call(a,!1),(u=(c=this.callbacks).onSuccess)==null||u.call(c,q)}else if(ge==="declined"||ge==="error"){let q=((f=x==null?void 0:x.retrieveResult)==null?void 0:f.message)||(x==null?void 0:x.message)||"Payment failed";(m=(g=this.callbacks).onError)==null||m.call(g,q),(h=(d=this.callbacks).onProcessing)==null||h.call(d,!1)}else{let q=await this.paymentsResource.getPaymentStatus(e);if(q.status==="declined"||q.status==="failed"){let B=((p=q.error)==null?void 0:p.message)||((S=q.error)==null?void 0:S.processorMessage)||"Payment declined";(E=(C=this.callbacks).onError)==null||E.call(C,B),(P=(T=this.callbacks).onProcessing)==null||P.call(T,!1)}else q.status==="succeeded"||q.status==="pending"&&q.subStatus==="authorized"?((A=(I=this.callbacks).onProcessing)==null||A.call(I,!1),(K=(L=this.callbacks).onSuccess)==null||K.call(L,q)):q.requireAction!=="none"&&q.requireActionData&&!q.requireActionData.processed?this.handlePaymentAction(q):this.startPolling(e,{onSuccess:B=>{var W,ue,re,me;(ue=(W=this.callbacks).onProcessing)==null||ue.call(W,!1),(me=(re=this.callbacks).onSuccess)==null||me.call(re,B)},onFailure:B=>{var W,ue,re,me;(ue=(W=this.callbacks).onError)==null||ue.call(W,B),(me=(re=this.callbacks).onProcessing)==null||me.call(re,!1)},onRequireAction:B=>{this.handlePaymentAction(B)}})}}catch(x){(G=(j=this.callbacks).onError)==null||G.call(j,x instanceof Error?x.message:"Failed to process Airwallex 3DS"),(se=(M=this.callbacks).onProcessing)==null||se.call(M,!1)}else{let x=new URLSearchParams(window.location.search).get("error_message")||"Authentication failed";(Ke=(Y=this.callbacks).onError)==null||Ke.call(Y,x),(ze=(U=this.callbacks).onProcessing)==null||ze.call(U,!1),s()}}cleanPaymentUrlParams(){if(typeof window=="undefined")return;let e=new URLSearchParams(window.location.search);["paymentAction","paymentActionStatus","paymentId","payment_intent","payment_intent_client_secret","source_type","redirect_status"].forEach(r=>e.delete(r));let n=e.toString()?"".concat(window.location.pathname,"?").concat(e.toString()):window.location.pathname;window.history.replaceState({},document.title,n)}async createCardPaymentInstrument(e){let n=await this.initBasisTheory();return this.paymentsResource.createCardPaymentInstrument(n!=null?n:void 0,e)}async createApplePayPaymentInstrument(e){let n=await this.initBasisTheory();return this.paymentsResource.createApplePayPaymentInstrument(n!=null?n:void 0,e)}async createGooglePayPaymentInstrument(e){let n=await this.initBasisTheory();return this.paymentsResource.createGooglePayPaymentInstrument(n!=null?n:void 0,e)}async getCardPaymentInstruments(){return this.paymentsResource.getCardPaymentInstruments()}async createThreedsSession(e){let n=await this.initBt3ds();if(!n)throw new Error("BasisTheory 3DS not loaded");let s=await n(this.getBtApiKey()).createSession({tokenId:e.token});return this.threedsResource.createSession({provider:"basis_theory",sessionData:s,paymentInstrumentId:e.id})}async processCardPayment(e,n){var r,s,o,i,a,l,c,u,f;(s=(r=this.callbacks).onProcessing)==null||s.call(r,!0),(i=(o=this.callbacks).onError)==null||i.call(o,null);try{let g=await this.createCardPaymentInstrument({cardNumber:n.cardNumber,expiryDate:n.expiryDate,cvc:n.cvc});if(!(g!=null&&g.id))throw new Error("Failed to create payment instrument");let m,d=await this.fetchStoreConfig();if((a=d==null?void 0:d.computed)!=null&&a.threedsEnabled)try{m=(await this.createThreedsSession(g)).id}catch(h){}return await this.processAndHandle(e,g.id,m)}catch(g){let m=g instanceof Error?g.message:String(g);return(c=(l=this.callbacks).onError)==null||c.call(l,m),(f=(u=this.callbacks).onProcessing)==null||f.call(u,!1),{success:!1,error:m}}}async processApplePayPayment(e,n){var r,s,o,i,a,l,c,u;(s=(r=this.callbacks).onProcessing)==null||s.call(r,!0),(i=(o=this.callbacks).onError)==null||i.call(o,null);try{let f=await this.createApplePayPaymentInstrument(n);return await this.processAndHandle(e,f.id)}catch(f){let g=f instanceof Error?f.message:String(f);return(l=(a=this.callbacks).onError)==null||l.call(a,g),(u=(c=this.callbacks).onProcessing)==null||u.call(c,!1),{success:!1,error:g}}}async processGooglePayPayment(e,n){var r,s,o,i,a,l,c,u;(s=(r=this.callbacks).onProcessing)==null||s.call(r,!0),(i=(o=this.callbacks).onError)==null||i.call(o,null);try{let f=await this.createGooglePayPaymentInstrument(n);return await this.processAndHandle(e,f.id)}catch(f){let g=f instanceof Error?f.message:String(f);return(l=(a=this.callbacks).onError)==null||l.call(a,g),(u=(c=this.callbacks).onProcessing)==null||u.call(c,!1),{success:!1,error:g}}}async processPaymentWithInstrument(e,n){var r,s,o,i,a,l,c,u;(s=(r=this.callbacks).onProcessing)==null||s.call(r,!0),(i=(o=this.callbacks).onError)==null||i.call(o,null);try{return await this.processAndHandle(e,n)}catch(f){let g=f instanceof Error?f.message:String(f);return(l=(a=this.callbacks).onError)==null||l.call(a,g),(u=(c=this.callbacks).onProcessing)==null||u.call(c,!1),{success:!1,error:g}}}async processApmPayment(e,n){var r,s,o,i,a,l,c,u;(s=(r=this.callbacks).onProcessing)==null||s.call(r,!0),(i=(o=this.callbacks).onError)==null||i.call(o,null);try{return await this.processAndHandle(e,"",void 0,{processorId:n.processorId,paymentMethod:n.paymentMethod,initiatedBy:n.initiatedBy,source:n.source})}catch(f){let g=f instanceof Error?f.message:String(f);return(l=(a=this.callbacks).onError)==null||l.call(a,g),(u=(c=this.callbacks).onProcessing)==null||u.call(c,!1),{success:!1,error:g}}}};ct();var Ud="1.0.0";function Md(t){return typeof window=="undefined"?null:new URLSearchParams(window.location.search).get(t)}function ne(t,...e){t&&console.log("[TagadaTracker]",...e)}function Fd(...t){console.warn("[TagadaTracker]",...t)}function Pw(t){if(!t.storeId||typeof t.storeId!="string")throw new Error("TagadaTracker: storeId is required and must be a non-empty string.");if(!t.accountId||typeof t.accountId!="string")throw new Error("TagadaTracker: accountId is required and must be a non-empty string.");if(!t.stepId||typeof t.stepId!="string")throw new Error("TagadaTracker: stepId is required and must be a non-empty string.");if(t.apiBaseUrl)try{new URL(t.apiBaseUrl)}catch(e){throw new Error('TagadaTracker: apiBaseUrl is not a valid URL: "'.concat(t.apiBaseUrl,'"'))}}async function Aw(t,e,n){let r;for(let s=0;s<=e;s++)try{return await t()}catch(o){if(r=o instanceof Error?o:new Error(String(o)),s<e){let i=Math.min(1e3*2**s,8e3);ne(n,"Retry ".concat(s+1,"/").concat(e," in ").concat(i,"ms...")),await new Promise(a=>setTimeout(a,i))}}throw r}var Pn=class{constructor(){this.config=null;this.client=null;this.initialized=!1;this.initializing=!1;this.unsubscribe=null;this.version=Ud}async init(e){var r,s;if(this.initialized)return ne(e.debug||!1,"Already initialized \u2014 returning existing session."),this.getSession();if(this.initializing)return ne(e.debug||!1,"Initialization in progress \u2014 skipping duplicate call."),null;this.initializing=!0,this.config=w({debug:!1},e);let n=this.config.debug;try{Pw(this.config)}catch(o){this.initializing=!1;let i=o instanceof Error?o:new Error(String(o));if(this.config.onError)return this.config.onError(i),null;throw i}ne(n,"\u{1F680} Initializing external tracker v".concat(Ud),{storeId:e.storeId,accountId:e.accountId,stepId:e.stepId,funnelId:e.funnelId});try{let o=Md("token");o&&(he(o),ne(n,"\u{1F511} Bootstrapped token from URL")),this.client=zi({debugMode:n,features:{funnel:{skipAutoInit:!0}},rawPluginConfig:{storeId:this.config.storeId,accountId:this.config.accountId},customApiConfig:this.config.apiBaseUrl?{apiConfig:{baseUrl:this.config.apiBaseUrl.trim()}}:void 0}),await this.waitForClientReady();let i=await Aw(()=>this.initializeFunnel(),2,n);ne(n,"\u2705 Session initialized:",i),this.initialized=!0;let a=this.getSession();return a&&((s=(r=this.config).onReady)==null||s.call(r,a)),a}catch(o){let i=o instanceof Error?o:new Error(String(o));if(ne(n,"\u274C Initialization failed:",i),this.config.onError)return this.config.onError(i),null;throw i}finally{this.initializing=!1}}getSession(){var n,r;if(!((r=(n=this.client)==null?void 0:n.funnel)!=null&&r.state.context))return null;let e=this.client.funnel.state.context;return{sessionId:e.sessionId,customerId:e.customerId,storeId:e.storeId,funnelId:e.funnelId,currentStepId:e.currentStepId,cmsToken:this.client.state.token||void 0}}isReady(){var e,n;return this.initialized&&!!((n=(e=this.client)==null?void 0:e.funnel)!=null&&n.state.context)}async navigate(e){if(!this.isReady())throw new Error("TagadaTracker: not initialized. Call init() first.");ne(this.config.debug,"\u{1F680} Navigating:",e);let n=e.autoRedirect!==!1;try{let r=await this.client.funnel.navigate({type:e.eventType,data:e.eventData||{}},{autoRedirect:!1});return r!=null&&r.url?(ne(this.config.debug,"\u2705 Navigation result:",r.url),n&&typeof window!="undefined"&&(window.location.href=e.returnUrl||r.url),{url:r.url}):null}catch(r){throw ne(this.config.debug,"\u274C Navigation failed:",r),r}}async trackEvent(e){if(!this.isReady()){Fd("trackEvent called before init \u2014 event dropped:",e.name);return}ne(this.config.debug,"\u{1F4CA} Tracking event:",e.name,e.data);try{await this.client.funnel.navigate({type:e.name,data:e.data||{}},{autoRedirect:!1})}catch(n){ne(this.config.debug,"\u26A0\uFE0F Event tracking failed (non-critical):",e.name)}}getCustomerId(){var e,n,r,s,o;return((n=(e=this.client)==null?void 0:e.state.auth.customer)==null?void 0:n.id)||((o=(s=(r=this.client)==null?void 0:r.funnel)==null?void 0:s.state.context)==null?void 0:o.customerId)||null}getFunnelSessionId(){var e,n,r;return((r=(n=(e=this.client)==null?void 0:e.funnel)==null?void 0:n.state.context)==null?void 0:r.sessionId)||null}buildUrl(e,n){let r=this.getSession();if(!r)return e;let s=new URL(e,typeof window!="undefined"?window.location.origin:void 0);return s.searchParams.set("funnelSessionId",r.sessionId),r.cmsToken&&s.searchParams.set("token",r.cmsToken),r.funnelId&&s.searchParams.set("funnelId",r.funnelId),s.searchParams.set("storeId",r.storeId),n&&Object.entries(n).forEach(([o,i])=>{s.searchParams.set(o,i)}),s.toString()}getClient(){return this.client}async reset(e){var s,o;if(!this.client||!this.config)throw new Error("TagadaTracker: not initialized. Call init() first.");ne(this.config.debug,"\u{1F504} Resetting to step:",e),this.config.stepId=e;let n=await this.initializeFunnel(),r=this.getSession();return r&&((o=(s=this.config).onReady)==null||o.call(s,r)),r}destroy(){var e,n;this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.client&&((n=(e=this.client).destroy)==null||n.call(e)),this.client=null,this.config=null,this.initialized=!1,this.initializing=!1,ne(!1,"\u{1F5D1}\uFE0F Tracker destroyed")}async waitForClientReady(){if(this.client)return new Promise(e=>{var s;if((s=this.client)!=null&&s.state.isInitialized){e();return}let n=!1,r=setTimeout(()=>{var o;n||(n=!0,ne(((o=this.config)==null?void 0:o.debug)||!1,"\u23F1\uFE0F Client ready timeout \u2014 proceeding"),e())},1e4);this.unsubscribe=this.client.subscribe(()=>{var o;!n&&((o=this.client)!=null&&o.state.isInitialized)&&(n=!0,clearTimeout(r),e())})})}async initializeFunnel(){var i,a,l;if(!((i=this.client)!=null&&i.funnel))return null;let e=(a=this.client.state.auth.customer)==null?void 0:a.id,n=(l=this.client.state.auth.session)==null?void 0:l.sessionId;!e&&!n&&Fd("No auth session available \u2014 funnel init may fail.");let r={customerId:e||"anon_placeholder",sessionId:n||"sess_placeholder"},s={id:this.config.storeId,accountId:this.config.accountId},o=this.config.stepId;return ne(this.config.debug,"\u{1F50D} Initializing funnel at step:",o),this.client.funnel.initialize(r,s,this.config.funnelId||Md("funnelId")||void 0,o)}},Ki=new Pn;typeof window!="undefined"&&(window.TagadaTracker=Ki);function _w(){if(typeof window=="undefined"||typeof document=="undefined")return[];let t=be();return t!=null&&t.scripts?t.scripts.filter(e=>e.enabled):[]}function Iw(t,e){let n=t.position||"body-end",r="tagada-stepconfig-script-".concat(e);if(document.getElementById(r))return;let s=t.content.trim(),o=s.match(/^<script[^>]*>([\s\S]*)<\/script>$/i);if(o&&(s=o[1].trim()),!s)return;let i="(function() {\n try {\n // Script: "+t.name+"\n"+s+'\n } catch (error) {\n console.error("[TagadaPay] StepConfig script error:", error);\n }\n})();',a=document.createElement("script");switch(a.id=r,a.setAttribute("data-tagada-stepconfig-script","true"),a.setAttribute("data-script-name",t.name),a.textContent=i,n){case"head-start":document.head.firstChild?document.head.insertBefore(a,document.head.firstChild):document.head.appendChild(a);break;case"head-end":document.head.appendChild(a);break;case"body-start":document.body.firstChild?document.body.insertBefore(a,document.body.firstChild):document.body.appendChild(a);break;case"body-end":default:document.body.appendChild(a);break}}function Vi(){let t=_w();t.length!==0&&t.forEach((e,n)=>{Iw(e,n)})}if(typeof window!="undefined"&&typeof document!="undefined"){let t=()=>{document.body?Vi():document.addEventListener("DOMContentLoaded",Vi,{once:!0})};"requestIdleCallback"in window?window.requestIdleCallback(t,{timeout:100}):setTimeout(t,0)}function zi(t={}){return new un(t)}function xw(){return dn()}function Ow(){return gc()}return ws(kw);})();
8
+ /*! Bundled license information:
9
+
10
+ axios/dist/browser/axios.cjs:
11
+ (*! Axios v1.13.2 Copyright (c) 2025 Matt Zabriskie and contributors *)
12
+ */
13
+ // Expose SDK under window.tgd namespace (clean, single global)
14
+ if (typeof window !== 'undefined' && TagadaSDKBundle) {
15
+ window.tgd = window.tgd || {};
16
+ // Core
17
+ window.tgd.createTagadaClient = TagadaSDKBundle.createTagadaClient;
18
+ // Config utilities
19
+ window.tgd.getPluginConfig = TagadaSDKBundle.getPluginConfig;
20
+ window.tgd.loadPluginConfig = TagadaSDKBundle.loadPluginConfig;
21
+ // Hot reload
22
+ window.tgd.onConfigUpdate = TagadaSDKBundle.onConfigUpdate;
23
+ window.tgd.sendConfigUpdate = TagadaSDKBundle.sendConfigUpdate;
24
+ window.tgd.broadcastConfigUpdate = TagadaSDKBundle.broadcastConfigUpdate;
25
+ // Currency
26
+ window.tgd.formatMoney = TagadaSDKBundle.formatMoney;
27
+ // Script injection (auto-runs on load, but can be manually called)
28
+ window.tgd.injectStepConfigScripts = TagadaSDKBundle.injectStepConfigScripts;
29
+ // Full bundle reference
30
+ window.tgd.sdk = TagadaSDKBundle;
31
+ }
32
+ //# sourceMappingURL=tagada-sdk.min.js.map