rebill-web-components-sdk 1.8.36 → 1.8.37

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 (88) hide show
  1. package/dist/cjs/apm-checkout_19.cjs.entry.js +2 -2
  2. package/dist/cjs/card-identification_5.cjs.entry.js +2 -2
  3. package/dist/cjs/{config-ClgjQet_.js → config-Wx7Bi6_T.js} +3 -3
  4. package/dist/cjs/config-Wx7Bi6_T.js.map +1 -0
  5. package/dist/cjs/discount-coupon_2.cjs.entry.js +2 -2
  6. package/dist/cjs/index-C-VTnc0I.js.map +1 -1
  7. package/dist/cjs/{index-BCzOaoSU.js → index-D4-MOr9h.js} +3 -3
  8. package/dist/cjs/{index-BCzOaoSU.js.map → index-D4-MOr9h.js.map} +1 -1
  9. package/dist/cjs/index.cjs.js +1 -1
  10. package/dist/cjs/otp-component_7.cjs.entry.js +2 -2
  11. package/dist/cjs/rebill-checkout.cjs.entry.js +2 -2
  12. package/dist/cjs/rebill-renewal.cjs.entry.js +2 -2
  13. package/dist/collection/api/config.js +1 -1
  14. package/dist/collection/api/config.js.map +1 -1
  15. package/dist/components/apm-checkout.js +1 -1
  16. package/dist/components/card-fields-wrapper.js +1 -1
  17. package/dist/components/card-identification.js +1 -1
  18. package/dist/components/card-iframe.js +1 -1
  19. package/dist/components/discount-coupon.js +1 -1
  20. package/dist/components/index.js +2 -2
  21. package/dist/components/otp-component.js +1 -1
  22. package/dist/components/{p-BjaEn-3m.js → p-2qMho_xL.js} +3 -3
  23. package/dist/{esm/config-BuNv9JwG.js.map → components/p-2qMho_xL.js.map} +1 -1
  24. package/dist/components/p-8BpuJ_V5.js.map +1 -1
  25. package/dist/components/{p-DvgE3hKC.js → p-B-3lImmb.js} +3 -3
  26. package/dist/components/{p-DvgE3hKC.js.map → p-B-3lImmb.js.map} +1 -1
  27. package/dist/components/{p-D5TXI2Hb.js → p-BD1NqdR9.js} +3 -3
  28. package/dist/components/{p-D5TXI2Hb.js.map → p-BD1NqdR9.js.map} +1 -1
  29. package/dist/components/{p-VskO2WrV.js → p-Be6Svr7E.js} +3 -3
  30. package/dist/components/{p-VskO2WrV.js.map → p-Be6Svr7E.js.map} +1 -1
  31. package/dist/components/{p-DDVDLDRI.js → p-Bel0mbz7.js} +3 -3
  32. package/dist/components/{p-DDVDLDRI.js.map → p-Bel0mbz7.js.map} +1 -1
  33. package/dist/components/{p-CmKAtNPq.js → p-BlD-dFYd.js} +3 -3
  34. package/dist/components/{p-CmKAtNPq.js.map → p-BlD-dFYd.js.map} +1 -1
  35. package/dist/components/{p-Dk10IZbR.js → p-CQS1pU-N.js} +3 -3
  36. package/dist/components/{p-Dk10IZbR.js.map → p-CQS1pU-N.js.map} +1 -1
  37. package/dist/components/{p-B4_i6BFO.js → p-CyKDtSI2.js} +3 -3
  38. package/dist/components/{p-B4_i6BFO.js.map → p-CyKDtSI2.js.map} +1 -1
  39. package/dist/components/{p-Bln3wBD6.js → p-DZRApK5D.js} +5 -5
  40. package/dist/components/{p-Bln3wBD6.js.map → p-DZRApK5D.js.map} +1 -1
  41. package/dist/components/{p-DPpE0kdy.js → p-D_lNAXr_.js} +4 -4
  42. package/dist/components/{p-DPpE0kdy.js.map → p-D_lNAXr_.js.map} +1 -1
  43. package/dist/components/{p-OSC_8G2_.js → p-c7IoEGtU.js} +3 -3
  44. package/dist/components/{p-OSC_8G2_.js.map → p-c7IoEGtU.js.map} +1 -1
  45. package/dist/components/{p-Dh-yfb0D.js → p-hdBb2rTT.js} +3 -3
  46. package/dist/components/{p-Dh-yfb0D.js.map → p-hdBb2rTT.js.map} +1 -1
  47. package/dist/components/{p-BJUr_-ZO.js → p-kh0HdPk5.js} +3 -3
  48. package/dist/components/{p-BJUr_-ZO.js.map → p-kh0HdPk5.js.map} +1 -1
  49. package/dist/components/payment-method-selector.js +1 -1
  50. package/dist/components/rebill-address.js +1 -1
  51. package/dist/components/rebill-checkout.js +11 -11
  52. package/dist/components/rebill-renewal.js +9 -9
  53. package/dist/components/rebill-summary.js +1 -1
  54. package/dist/components/renewal-summary.js +1 -1
  55. package/dist/components/user-information.js +1 -1
  56. package/dist/esm/apm-checkout_19.entry.js +2 -2
  57. package/dist/esm/card-identification_5.entry.js +2 -2
  58. package/dist/esm/{config-BuNv9JwG.js → config-CnVJ8ACO.js} +3 -3
  59. package/dist/{cjs/config-ClgjQet_.js.map → esm/config-CnVJ8ACO.js.map} +1 -1
  60. package/dist/esm/discount-coupon_2.entry.js +2 -2
  61. package/dist/esm/{index-BOj-Hiz8.js → index-8R_YGXw4.js} +3 -3
  62. package/dist/esm/{index-BOj-Hiz8.js.map → index-8R_YGXw4.js.map} +1 -1
  63. package/dist/esm/index-D8cwEAmw.js.map +1 -1
  64. package/dist/esm/index.js +2 -2
  65. package/dist/esm/otp-component_7.entry.js +2 -2
  66. package/dist/esm/rebill-checkout.entry.js +2 -2
  67. package/dist/esm/rebill-renewal.entry.js +2 -2
  68. package/dist/rebill-web-components-sdk/index.esm.js +1 -1
  69. package/dist/rebill-web-components-sdk/{p-28d04513.entry.js → p-2ddabd39.entry.js} +2 -2
  70. package/dist/rebill-web-components-sdk/{p-736d2bdc.entry.js → p-3d02e7e9.entry.js} +2 -2
  71. package/dist/rebill-web-components-sdk/{p-9b146258.entry.js → p-405ab8da.entry.js} +2 -2
  72. package/dist/rebill-web-components-sdk/{p-D339jHg4.js → p-B5khCLtC.js} +2 -2
  73. package/dist/rebill-web-components-sdk/{p-D339jHg4.js.map → p-B5khCLtC.js.map} +1 -1
  74. package/dist/rebill-web-components-sdk/{p-CTo1s54i.js → p-D2_UL7f8.js} +4 -4
  75. package/dist/rebill-web-components-sdk/{p-CTo1s54i.js.map → p-D2_UL7f8.js.map} +1 -1
  76. package/dist/rebill-web-components-sdk/p-D8cwEAmw.js.map +1 -1
  77. package/dist/rebill-web-components-sdk/{p-392fb691.entry.js → p-b8613f04.entry.js} +2 -2
  78. package/dist/rebill-web-components-sdk/{p-852bb04c.entry.js → p-d016b0d6.entry.js} +2 -2
  79. package/dist/rebill-web-components-sdk/{p-8bf5ce94.entry.js → p-ee460f6c.entry.js} +2 -2
  80. package/dist/rebill-web-components-sdk/rebill-web-components-sdk.esm.js +1 -1
  81. package/package.json +1 -1
  82. package/dist/components/p-BjaEn-3m.js.map +0 -1
  83. /package/dist/rebill-web-components-sdk/{p-28d04513.entry.js.map → p-2ddabd39.entry.js.map} +0 -0
  84. /package/dist/rebill-web-components-sdk/{p-736d2bdc.entry.js.map → p-3d02e7e9.entry.js.map} +0 -0
  85. /package/dist/rebill-web-components-sdk/{p-9b146258.entry.js.map → p-405ab8da.entry.js.map} +0 -0
  86. /package/dist/rebill-web-components-sdk/{p-392fb691.entry.js.map → p-b8613f04.entry.js.map} +0 -0
  87. /package/dist/rebill-web-components-sdk/{p-852bb04c.entry.js.map → p-d016b0d6.entry.js.map} +0 -0
  88. /package/dist/rebill-web-components-sdk/{p-8bf5ce94.entry.js.map → p-ee460f6c.entry.js.map} +0 -0
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { i as initializeSDK } from './config-BuNv9JwG.js';
2
- export { g as getAPIConfig, a as getCurrentEnvironment, b as isDebugMode } from './config-BuNv9JwG.js';
1
+ import { i as initializeSDK } from './config-CnVJ8ACO.js';
2
+ export { g as getAPIConfig, a as getCurrentEnvironment, b as isDebugMode } from './config-CnVJ8ACO.js';
3
3
  import { s as setAssetsURL, C as CDN_ASSETS_URL } from './assets-C5OYI4I6.js';
4
4
  export { g as getAssetURL } from './assets-C5OYI4I6.js';
5
5
  export { a as setAssetPath } from './index-D8cwEAmw.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, g as getElement, c as createEvent, H as Host } from './index-D8cwEAmw.js';
2
- import { a as api } from './index-BOj-Hiz8.js';
2
+ import { a as api } from './index-8R_YGXw4.js';
3
3
  import { I as I18nService, c as PLAN_FREQUENCY_ENUM, s as state, b as SESSION_ITEM_TYPE_ENUM, f as formatAmount, d as SESSION_DISCOUNT_TYPE_ENUM, e as instance, a as SessionStore, P as PAYMENT_METHOD_ENUM } from './i18n.service-D2TBhbJY.js';
4
4
  import { C as COLORS_ENUM } from './color-class-mapper-DA598vBj.js';
5
5
  import { c as copyToClipboard, a as createCountdownTimer } from './clipboard-BIOWiROZ.js';
@@ -9,7 +9,7 @@ import { g as getAssetURL } from './assets-C5OYI4I6.js';
9
9
  import { g as getCountryPaymentMethods, P as PDFGenerator } from './pdf-generator-C-r7lzNo.js';
10
10
  import { f as formatDateTime } from './date-formatter-BdUTG_fl.js';
11
11
  import './_commonjsHelpers-E-ZsRS8r.js';
12
- import './config-BuNv9JwG.js';
12
+ import './config-CnVJ8ACO.js';
13
13
 
14
14
  const u = (n, t, e) => {
15
15
  const i = document.createElement(n), [s, a] = Array.isArray(t) ? [void 0, t] : [t, e];
@@ -1,13 +1,13 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-D8cwEAmw.js';
2
2
  import { c as create$6 } from './index.esm-CRUbzQx9.js';
3
- import { a as api } from './index-BOj-Hiz8.js';
3
+ import { a as api } from './index-8R_YGXw4.js';
4
4
  import { m as mapRequiredFields, g as generateIdempotencyKey, P as PaymentMessageE, C as CheckoutStatusE, i as isFieldRequired, a as PaymentErrorMapper, b as getFieldValues } from './required-fields-mappers-NegWz-xH.js';
5
5
  import { s as state, S as SESSION_TYPE_ENUM, I as I18nService, a as SessionStore, i as initializeI18nWithSessionLanguage, P as PAYMENT_METHOD_ENUM, o as onChange, b as SESSION_ITEM_TYPE_ENUM } from './i18n.service-D2TBhbJY.js';
6
6
  import { S as STATUS_REQ_CHECKOUT_APM } from './status-req-checkout-apm.enum-vsLqF4hk.js';
7
7
  import { B as BREAKPOINT_ENUM, g as getBreakpoint, i as isBreakpointBelow } from './breakpoint-Do_vNuMa.js';
8
8
  import { P as PaymentMethodMapper, G as GoogleMapsService } from './google-maps.service-dvv8xcZ_.js';
9
9
  import './_commonjsHelpers-E-ZsRS8r.js';
10
- import './config-BuNv9JwG.js';
10
+ import './config-CnVJ8ACO.js';
11
11
 
12
12
  /**
13
13
  * Default display configuration with all sections enabled
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-D8cwEAmw.js';
2
2
  import { c as create$6 } from './index.esm-CRUbzQx9.js';
3
- import { a as api } from './index-BOj-Hiz8.js';
3
+ import { a as api } from './index-8R_YGXw4.js';
4
4
  import { m as mapRequiredFields, i as isFieldRequired, g as generateIdempotencyKey, C as CheckoutStatusE, a as PaymentErrorMapper, b as getFieldValues } from './required-fields-mappers-NegWz-xH.js';
5
5
  import { P as PAYMENT_METHOD_ENUM, I as I18nService } from './i18n.service-D2TBhbJY.js';
6
6
  import { P as PaymentMethodMapper, G as GoogleMapsService, a as PaymentMethodNameE } from './google-maps.service-dvv8xcZ_.js';
@@ -8,7 +8,7 @@ import { r as renewalState, R as RenewalStore, o as onChange } from './renewal.s
8
8
  import { B as BREAKPOINT_ENUM, g as getBreakpoint, i as isBreakpointBelow } from './breakpoint-Do_vNuMa.js';
9
9
  import { C as COLORS_ENUM } from './color-class-mapper-DA598vBj.js';
10
10
  import './_commonjsHelpers-E-ZsRS8r.js';
11
- import './config-BuNv9JwG.js';
11
+ import './config-CnVJ8ACO.js';
12
12
 
13
13
  const getRequiredFields = async (currency, method, organizationId) => {
14
14
  const requiredFieldsResponse = await api.checkout.getRequiredFields({
@@ -1,2 +1,2 @@
1
- import{i as e}from"./p-D339jHg4.js";export{g as getAPIConfig,a as getCurrentEnvironment,b as isDebugMode}from"./p-D339jHg4.js";import{s as o,C as n}from"./p-C5OYI4I6.js";export{g as getAssetURL}from"./p-C5OYI4I6.js";export{a as setAssetPath}from"./p-D8cwEAmw.js";const s=(s={})=>{if(s.environment){const e=["development","staging","production"];if(!e.includes(s.environment)){throw new Error(`Invalid environment "${s.environment}". Must be one of: ${e.join(", ")}`)}}if(s.assetsUrl){o(s.assetsUrl);if(s.debug!==false){console.log(`📦 Assets URL configured: ${s.assetsUrl}`)}}else if(s.debug!==false){console.log(`📦 Using CDN for assets: ${n}`)}e(s);if(s.debug!==false){console.log("✅ Rebill SDK initialized successfully")}};const t={forProduction:(e=false)=>{s({environment:"production",debug:e})},forStaging:(e=true)=>{s({environment:"staging",debug:e})},forDevelopment:(e=true)=>{s({environment:"development",debug:e})}};const i=(e,o)=>import("./p-B2kbOjsN.js").then((({defineCustomElements:s})=>{if(o?.resourcesUrl){if(typeof window!=="undefined"){window.__REBILL_SDK_ASSETS_URL__=o.resourcesUrl}return s(e,o)}if(typeof window!=="undefined"){window.__REBILL_SDK_ASSETS_URL__=n}return s(e)}));export{t as RebillSDK,i as defineCustomElementsWithAssets,s as initializeRebillSDK,o as setAssetsURL};
1
+ import{i as e}from"./p-B5khCLtC.js";export{g as getAPIConfig,a as getCurrentEnvironment,b as isDebugMode}from"./p-B5khCLtC.js";import{s as o,C as n}from"./p-C5OYI4I6.js";export{g as getAssetURL}from"./p-C5OYI4I6.js";export{a as setAssetPath}from"./p-D8cwEAmw.js";const s=(s={})=>{if(s.environment){const e=["development","staging","production"];if(!e.includes(s.environment)){throw new Error(`Invalid environment "${s.environment}". Must be one of: ${e.join(", ")}`)}}if(s.assetsUrl){o(s.assetsUrl);if(s.debug!==false){console.log(`📦 Assets URL configured: ${s.assetsUrl}`)}}else if(s.debug!==false){console.log(`📦 Using CDN for assets: ${n}`)}e(s);if(s.debug!==false){console.log("✅ Rebill SDK initialized successfully")}};const t={forProduction:(e=false)=>{s({environment:"production",debug:e})},forStaging:(e=true)=>{s({environment:"staging",debug:e})},forDevelopment:(e=true)=>{s({environment:"development",debug:e})}};const i=(e,o)=>import("./p-B2kbOjsN.js").then((({defineCustomElements:s})=>{if(o?.resourcesUrl){if(typeof window!=="undefined"){window.__REBILL_SDK_ASSETS_URL__=o.resourcesUrl}return s(e,o)}if(typeof window!=="undefined"){window.__REBILL_SDK_ASSETS_URL__=n}return s(e)}));export{t as RebillSDK,i as defineCustomElementsWithAssets,s as initializeRebillSDK,o as setAssetsURL};
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1,2 +1,2 @@
1
- import{r as e,h as r,c as o,g as t}from"./p-D8cwEAmw.js";import{a as i}from"./p-CTo1s54i.js";import{I as l,s,e as a,a as n,o as c}from"./p-DkbFAMha.js";import{r as d,o as b,R as h}from"./p-BOVs95c7.js";import{g as p}from"./p-D339jHg4.js";import{c as f,d as u,E as m,e as g,b as y}from"./p-wvcrPcSK.js";import{C as x}from"./p-DA598vBj.js";import"./p-E-ZsRS8r.js";const v=class{constructor(r){e(this,r)}documentTypes=[];country="";currentLanguage=l.getCurrentLanguage();documentTypeError="";documentNumberError="";disabled=false;loadDocumentTypes=async()=>{const e=d.isInitialized?d.data?.price?.country:s?.data?.pricing?.country;if(e&&e!==this.country){try{const r=await i.data.getDocumentTypes(e);this.documentTypes=r.data;this.country=e}catch(e){console.error("Error loading document types:",e)}}};async componentWillLoad(){a.on("languageChanged",this.handleLanguageChange);n.onChange("data",(()=>{if(!d.isInitialized){this.loadDocumentTypes()}}));b("data",(()=>{if(d.isInitialized){this.loadDocumentTypes()}}));await this.loadDocumentTypes()}handleInputChange=e=>{const{id:r,value:o}=e.detail;if(d.isInitialized){h.setUserIdentification({[r]:o})}else{n.setUserInformation({[r]:o})}};disconnectedCallback(){a.off("languageChanged",this.handleLanguageChange)}handleLanguageChange=()=>{this.currentLanguage=l.getCurrentLanguage()};render(){const e=this.documentTypeError||this.documentNumberError;const o=this.documentTypes.map((e=>({label:e.value,value:e.value})));return r(r.Fragment,null,r("rebill-input-combo",{key:"075b874873f297d3e2e72e54625db2d5cc49c619","select-id":"documentType","input-id":"documentNumber","on-input":this.handleInputChange,"select-placeholder":l.translate("document.typePlaceholder"),"input-placeholder":l.translate("document.numberPlaceholder"),error:l.translate(e),options:o,disabled:this.disabled}))}};const k=class{constructor(r){e(this,r)}customCSS;iframeLoaded=false;currentLang=s.currentLocale;initialLang=s.currentLocale;iframeHeight="100px";getIframeURL(){const e=p().iframeURL;const r=new URL(e);r.searchParams.set("lang",this.initialLang);if(d.data?.subscription?.customerId&&d.token){r.searchParams.set("customerId",d.data.subscription.customerId);r.searchParams.set("token",d.token)}return r.toString()}iframeRef;unsubscribeCurrentLocaleStore;unsubscribeDataStore;unsubscribeRenewalStore;postInitialDataToIframe(){if(d.isInitialized){if(d.data?.organization?.id){this.postOrganizationIdToIframe(d.data.organization.id)}this.postLanguageToIframe();this.postTotalPriceToIframe();this.postCurrencyToIframe();this.postCustomerIdToIframe();this.postTokenToIframe();this.postItemTypeToIframe()}else{if(s.data?.organization?.id){this.postOrganizationIdToIframe(s.data.organization.id)}if(s?.currentLocale){this.postLanguageToIframe()}this.postTotalPriceToIframe();this.postCurrencyToIframe();this.postCustomerIdToIframe();this.postTokenToIframe();this.postItemTypeToIframe()}this.postCustomCSSToIframe()}postTotalPriceToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow){let e;if(d.isInitialized){e=d.data?.price?.amount||0}else{e=s.data?.pricing?.totalWithoutInstallment||0}this.iframeRef.contentWindow.postMessage({type:"SET_TOTAL_PRICE",payload:{total:e}},"*")}}postCustomerIdToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow&&d.data?.subscription?.customerId){this.iframeRef.contentWindow.postMessage({type:"SET_CUSTOMER_ID",payload:{customerId:d.data.subscription.customerId}},"*")}else if(this.iframeRef&&this.iframeRef.contentWindow&&s.data.customerId){this.iframeRef.contentWindow.postMessage({type:"SET_CUSTOMER_ID",payload:{customerId:s.data.customerId}},"*")}}postLanguageToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow){this.iframeRef.contentWindow.postMessage({type:"SET_LANGUAGE",payload:{lang:this.currentLang}},"*")}}postOrganizationIdToIframe(e){if(!!this.iframeRef&&!!this.iframeRef.contentWindow){this.iframeRef.contentWindow.postMessage({type:"SET_ORGANIZATION_ID",payload:{organizationId:e}},"*")}}postTokenToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow&&d.token){this.iframeRef.contentWindow.postMessage({type:"SET_TOKEN",payload:{token:d.token}},"*")}else if(this.iframeRef&&this.iframeRef.contentWindow&&s.data.accessToken){this.iframeRef.contentWindow.postMessage({type:"SET_TOKEN",payload:{token:s.data.accessToken}},"*")}}postItemTypeToIframe(){if(!this.iframeRef||!this.iframeRef.contentWindow){return}if(d.isInitialized&&d.data?.subscription?.type){this.iframeRef.contentWindow.postMessage({type:"SET_ITEM_TYPE",payload:{itemType:d.data.subscription.type}},"*")}else if(s.data?.itemInformation?.type){this.iframeRef.contentWindow.postMessage({type:"SET_ITEM_TYPE",payload:{itemType:s.data.itemInformation.type}},"*")}}postCurrencyToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow){let e;if(d.isInitialized){e=d.data?.price?.currency||""}else{e=s.data?.pricing?.currency||""}if(e){this.iframeRef.contentWindow.postMessage({type:"SET_CURRENCY",payload:{currency:e}},"*")}}}postCustomCSSToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow&&this.customCSS){this.iframeRef.contentWindow.postMessage({type:"SET_CUSTOM_CSS",payload:{css:this.customCSS}},"*")}}postClearCustomerIdToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow&&(!s.data.customerId||!s.data.accessToken)){this.iframeRef.contentWindow.postMessage({type:"CLEAR_CUSTOMER_ID_AND_TOKEN"},"*")}}componentWillLoad(){this.initialLang=s.currentLocale;this.unsubscribeCurrentLocaleStore=c("currentLocale",(()=>{this.currentLang=s.currentLocale;this.postLanguageToIframe()}));this.unsubscribeDataStore=c("data",(()=>{if(!d.isInitialized){if(s.data?.organization?.id){this.postOrganizationIdToIframe(s.data.organization.id)}if(s.data?.pricing?.totalWithoutInstallment!==undefined&&s.data?.pricing?.totalWithoutInstallment!==null){this.postTotalPriceToIframe()}this.postCurrencyToIframe();this.postCustomerIdToIframe();this.postTokenToIframe();this.postItemTypeToIframe();this.postClearCustomerIdToIframe()}}));this.unsubscribeRenewalStore=b("data",(()=>{if(d.isInitialized){if(d.data?.organization?.id){this.postOrganizationIdToIframe(d.data.organization.id)}if(d.data?.price?.amount!==undefined){this.postTotalPriceToIframe()}this.postCurrencyToIframe();this.postCustomerIdToIframe();this.postTokenToIframe();this.postItemTypeToIframe()}}));setTimeout((()=>{this.postInitialDataToIframe()}),1e3)}componentWillUpdate(){if(this.iframeLoaded){this.postCustomCSSToIframe()}}componentDidLoad(){window.addEventListener("message",this.handleIframeMessage)}disconnectedCallback(){if(this.unsubscribeCurrentLocaleStore)this.unsubscribeCurrentLocaleStore();if(this.unsubscribeDataStore)this.unsubscribeDataStore();if(this.unsubscribeRenewalStore)this.unsubscribeRenewalStore();window.removeEventListener("message",this.handleIframeMessage)}handleIframeLoad=()=>{this.iframeLoaded=true;this.postLanguageToIframe();if(d.isInitialized){if(d.data?.organization?.id){this.postOrganizationIdToIframe(d.data.organization.id)}this.postCurrencyToIframe();this.postCustomerIdToIframe();this.postTokenToIframe();this.postItemTypeToIframe()}this.postCustomCSSToIframe();setTimeout((()=>{this.postInitialDataToIframe()}),500)};handleIframeMessage=e=>{if(e.data&&e.data.type==="IFRAME_HEIGHT"&&e.data.payload&&typeof e.data.payload.height==="number"){this.iframeHeight=`${e.data.payload.height}px`}if(e.data&&e.data.type==="FORM_STATE"){if(d.isInitialized){if(!e.data.payload?.complete){h.setCardId(null);h.setCardTokenId(null)}}else if(s.isInitialized){if(!e.data.payload?.complete){n.setCardId(null);n.setCardTokenId(null)}}}if(e.data&&e.data.type==="INSTALLMENTS"&&e.data.payload){if(d.isInitialized){h.setCardInformation(e.data.payload)}else{n.setCardInformation(e.data.payload)}}if(e.data&&e.data.type==="CARD_TOKENIZED"){if(d.isInitialized){h.setCardTokenId(e.data?.payload?.token)}else if(s.isInitialized){n.setCardTokenId(e.data?.payload?.token)}}if(e.data&&e.data.type==="CARD_ID"){if(d.isInitialized){h.setCardId(e.data.payload?.id)}else if(s.isInitialized){n.setCardId(e.data.payload?.id)}}if(e.data&&e.data.type==="SAVE_CARD"){if(s.isInitialized){n.setSaveCard(e.data.payload?.saveCard)}}if(e.data&&e.data.type==="FETCHING_INSTALLMENTS"){const r=e.data.payload?.fetching||false;if(d.isInitialized){h.setFetchingInstallments(r)}else if(s.isInitialized){n.setFetchingInstallments(r)}}if(e.data&&e.data.type==="NEW_CARD_MODE"){const r=e.data.payload?.mode;if(r&&(r==="input"||r==="select")){if(d.isInitialized){h.setCardMode(r)}else if(s.isInitialized){n.setCardMode(r)}}}};render(){return r("div",{key:"21cee6426b31b15e214272bed3b893a89cfebdc3",style:{width:"100%",height:this.iframeHeight,position:"relative",overflow:"hidden"}},!this.iframeLoaded&&r("card-skeleton",{key:"66bbb20d750975f5e6a15a72c55f21ac209c9a10"}),r("iframe",{key:"8f9c689ea04b5b88511cbcc69b792454460b2a48",ref:e=>this.iframeRef=e,src:this.getIframeURL(),style:{width:"100%",height:"100%",border:"none",overflow:"hidden"},title:"Card Payment Component",allow:"payment",onLoad:this.handleIframeLoad}))}};const w=":root{--rebill-color-primary:#3b82f6;--rebill-color-primary-light:rgba(59, 130, 246, 0.1);--rebill-color-primary-hover:#2563eb;--rebill-color-primary-dark:#001131;--rebill-color-primary-dark-text:#000000;--rebill-color-primary-dark-hover:#001c4a;--rebill-color-primary-dark-light:rgba(0, 17, 49, 0.1);--rebill-color-error:#ef4444;--rebill-color-error-background:#fef2f2;--rebill-color-error-light:rgba(239, 68, 68, 0.1);--rebill-color-error-dark:#6f101b;--rebill-color-background:#ffffff;--rebill-color-background-left:#fafafa;--rebill-color-background-right:#f4f5f6;--rebill-color-background-secondary:#f7f8fa;--rebill-color-border:#ebedef;--rebill-color-timeline-connector:#c4c8cf;--rebill-color-neutrals-700:#58616e;--rebill-color-neutrals-500:#9ca3af;--rebill-color-border-primary:#e4e4e7;--rebill-color-text-primary:#3b4049;--rebill-color-text-secondary:#6b7280;--rebill-color-grey-700:#7d7d7d;--rebill-color-text-secondary-light:#a1a1aa;--rebill-color-text-on-primary:#ffffff;--rebill-color-disabled:#9ca3af;--rebill-color-shadow:rgba(0, 0, 0, 0.1);--rebill-color-green:#10b981;--rebill-color-green-text:#257c67;--rebill-color-green-light:rgba(183, 233, 221, 0.15);--rebill-color-green-light-2:rgba(183, 233, 221, 1);--rebill-color-info-background:#d5e4ff;--rebill-color-info-border:#0156f6;--rebill-color-info-text:#172b85;--rebill-color-background-secondary-light:#f7f8fa;--rebill-breakpoint-mobile:768px;--rebill-breakpoint-tablet:1024px;--rebill-breakpoint-desktop:1025px;--rebill-color-orange:#ff9400;--rebill-color-black:#1e2025;--rebill-color-grey-300:#3b4049;--rebill-color-grey-100:#aeaeae}.qr-container,.qr-image,.qr-image svg,.qr-image img,[class*='qr-'],[class*='success'],[class*='receipt']{transition:none !important;animation:none !important;will-change:auto !important}button:active,button:focus,button:hover{isolation:isolate}.iframe-skeleton{display:flex;flex-direction:column;gap:16px}.input-skeleton{width:100%;height:40px;background:var(--rebill-color-border-primary);border-radius:8px;border:1px solid var(--rebill-color-border-primary)}";const T=class{constructor(r){e(this,r)}render(){return r("div",{key:"76c432f43c597f9ff92b949c16d70b1b6840e378",class:"iframe-skeleton"},r("div",{key:"9c77a9eeda10a23004890c934f30f8d25be7fbf1",class:"input-skeleton"}),r("div",{key:"d26032fe4bbb41dd0107e9fa5d8bd041da401351",class:"input-skeleton"}))}};T.style=w;const I=".input-container{display:flex;flex-direction:column}.input-label{font-size:0.875rem;color:var(--rebill-color-text-primary);font-weight:500;margin-bottom:0.375rem}.input-label.disabled{cursor:not-allowed}.input-element{border-radius:var(--input-group-inner-border-radius, 8px);border:1.5px solid var(--rebill-color-border);padding:10px 14px;font-size:0.875rem;color:var(--rebill-color-text-primary);outline:none;transition:border-color 0.2s;background:var(--rebill-color-background);height:38.33px;box-sizing:border-box}.input-element.input-error{border-color:var(--rebill-color-error)}.input-element:disabled{background-color:var(--rebill-color-background);border-color:var(--rebill-color-disabled);color:var(--rebill-color-text-secondary);cursor:not-allowed;opacity:0.7}select.input-element{padding:10px 30px 10px 14px;appearance:none;cursor:pointer}select.input-element:disabled{cursor:not-allowed}.input-element:focus{border-color:var(--rebill-color-primary)}.input-element:disabled:focus{border-color:var(--rebill-color-disabled)}.input-element::placeholder{color:var(--rebill-color-text-secondary-light);font-size:0.875rem;opacity:1}.select-wrapper.disabled .select-icon{color:var(--rebill-color-disabled)}.error-message{color:var(--rebill-color-error);font-size:0.75rem;margin-top:0.375rem}@media screen and (max-width: 768px){.input-element{font-size:1rem}.input-element::placeholder{font-size:1rem}}:host{display:block;width:100%;box-sizing:border-box}.combo-wrapper{display:flex;align-items:stretch;width:100%;height:38.33px;border-radius:var(--input-group-inner-border-radius, 8px);border:1.5px solid var(--rebill-color-border);background:var(--rebill-color-background);transition:border-color 0.2s;position:relative;box-sizing:border-box}.combo-wrapper:focus-within{border-color:var(--rebill-color-primary);box-shadow:0 0 0 2px var(--rebill-color-primary-light)}.combo-wrapper.error{border-color:var(--rebill-color-error)}.combo-wrapper.disabled{background-color:var(--rebill-color-background);border-color:var(--rebill-color-disabled);color:var(--rebill-color-text-secondary);cursor:not-allowed;opacity:0.7}.select-section{position:relative;flex-shrink:0;min-width:80px;display:flex;align-items:center}.select-combo-trigger{width:100%;height:100%;padding:0 30px 0 14px;font-size:0.875rem;font-weight:normal;color:var(--rebill-color-text-primary);background:transparent;border:none;outline:none;cursor:pointer;display:flex;align-items:center;justify-content:space-between;user-select:none;box-sizing:border-box;position:relative;transition:border-color 0.2s}.select-combo-trigger:focus{outline:none}.select-combo-trigger:hover:not(.disabled){border-color:var(--rebill-color-primary)}.select-combo-trigger.placeholder .select-value{color:var(--rebill-color-text-secondary-light)}.combo-wrapper.disabled .select-combo-trigger{cursor:not-allowed;color:var(--rebill-color-text-secondary)}.select-value{flex:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-section .icon-wrapper{position:absolute;right:0.75rem;top:50%;transform:translateY(-50%);display:flex;align-items:center;justify-content:center;height:20px;width:20px}.select-icon{color:var(--rebill-color-text-secondary);transition:transform 0.2s ease;transform-origin:50% 50%;display:block}.combo-wrapper.disabled .select-icon{color:var(--rebill-color-disabled)}.select-dropdown{position:absolute;top:100%;left:0;right:0;z-index:1000;background-color:var(--rebill-color-background);border:1px solid var(--rebill-color-border);border-radius:0.375rem;box-shadow:0 4px 6px -1px rgba(0, 0, 0, 0.1),\n 0 2px 4px -1px rgba(0, 0, 0, 0.06);margin-top:0.25rem;max-height:200px;overflow-y:auto;animation:slideDown 0.15s ease-out;box-sizing:border-box;width:100%}.select-option{padding:0.75rem;font-size:0.875rem;color:var(--rebill-color-text-primary);cursor:pointer;border-bottom:1px solid var(--rebill-color-border);transition:background-color 0.15s ease}.select-option:last-child{border-bottom:none}.select-option:hover,.select-option.highlighted{background-color:#f0f9ff}.select-option.selected{background-color:var(--rebill-color-primary);color:white}.select-option.selected:hover,.select-option.selected.highlighted{background-color:var(--rebill-color-primary)}.select-dropdown::-webkit-scrollbar{width:6px}.select-dropdown::-webkit-scrollbar-track{background:transparent}.select-dropdown::-webkit-scrollbar-thumb{background-color:var(--rebill-color-border);border-radius:3px}.select-dropdown::-webkit-scrollbar-thumb:hover{background-color:var(--rebill-color-text-secondary)}.combo-divider{width:1px;background-color:var(--rebill-color-border);margin:0;flex-shrink:0}.input-section{flex:1;min-width:0;display:flex;align-items:center}.combo-input{width:100%;height:100%;padding:0 14px;font-size:0.875rem;color:var(--rebill-color-text-primary);background:transparent;border:none;outline:none;box-sizing:border-box}.combo-input:focus{outline:none}.combo-input::placeholder{color:var(--rebill-color-text-secondary-light);font-size:0.875rem;opacity:1}.combo-wrapper.disabled .combo-input{color:var(--rebill-color-text-secondary);cursor:not-allowed}.combo-wrapper.disabled .combo-input::placeholder{color:var(--rebill-color-text-secondary)}@keyframes slideDown{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}@keyframes slideUp{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.select-dropdown::-webkit-scrollbar{width:6px}.select-dropdown::-webkit-scrollbar-track{background:transparent}.select-dropdown::-webkit-scrollbar-thumb{background-color:var(--rebill-color-border);border-radius:3px}.select-dropdown::-webkit-scrollbar-thumb:hover{background-color:var(--rebill-color-text-secondary)}@media screen and (max-width: 768px){.select-combo-trigger{font-size:1rem}.select-option{font-size:1rem}.combo-input{font-size:1rem}.combo-input::placeholder{font-size:1rem}}";const E=class{constructor(r){e(this,r);this.blur=o(this,"blur");this.selectChange=o(this,"selectChange");this.input=o(this,"input")}dropdownRef;triggerRef;label="";options=[];selectValue="";inputValue="";inputPlaceholder="";selectPlaceholder="";error="";selectId="";inputId="";disabled=false;selectWidth="120px";isOpen=false;highlightedIndex=-1;componentId="";blur;selectChange;input;componentWillLoad(){this.componentId=this.selectId||`combo-${Math.random().toString(36).substr(2,9)}`}handleFormChange(e){const r=e.detail;if(r){if(this.selectId&&this.selectId in r){const e=r[this.selectId];if(typeof e==="string"){this.selectValue=e}}if(this.inputId&&this.inputId in r){const e=r[this.inputId];if(typeof e==="string"){this.inputValue=e}}}}handleCloseAllSelects(e){if(e.detail!==this.componentId){this.closeDropdown()}}handleDocumentClick(e){if(this.dropdownRef&&this.triggerRef&&!this.dropdownRef.contains(e.target)&&!this.triggerRef.contains(e.target)){this.closeDropdown()}}toggleDropdown=()=>{if(this.disabled)return;const e=this.isOpen;this.isOpen=!this.isOpen;if(this.isOpen){if(!e){document.dispatchEvent(new CustomEvent("closeAllSelects",{detail:this.componentId}))}this.highlightedIndex=this.options.findIndex((e=>e.value===this.selectValue));if(this.highlightedIndex===-1){this.highlightedIndex=0}}};openDropdown=()=>{if(this.disabled)return;document.dispatchEvent(new CustomEvent("closeAllSelects",{detail:this.componentId}));this.isOpen=true;this.highlightedIndex=this.options.findIndex((e=>e.value===this.selectValue));if(this.highlightedIndex===-1){this.highlightedIndex=0}};closeDropdown=()=>{this.isOpen=false;this.highlightedIndex=-1};selectOption=e=>{if(this.disabled)return;this.selectValue=e.value;this.closeDropdown();this.input.emit({id:this.selectId,value:this.selectValue})};onInputChange=e=>{if(this.disabled)return;const r=e.target;this.inputValue=r.value;this.input.emit({id:this.inputId,value:this.inputValue})};onSelectBlur=()=>{this.blur.emit({id:this.selectId,value:this.selectValue})};onInputBlur=()=>{const e=this.inputValue.trim();if(e!==this.inputValue){this.inputValue=e;this.input.emit({id:this.inputId,value:this.inputValue})}this.blur.emit({id:this.inputId,value:this.inputValue})};handleKeyDown=e=>{if(this.disabled)return;switch(e.key){case"Enter":case" ":e.preventDefault();if(this.isOpen&&this.highlightedIndex>=0){this.selectOption(this.options[this.highlightedIndex])}else{this.toggleDropdown()}break;case"Escape":e.preventDefault();this.closeDropdown();break;case"ArrowDown":e.preventDefault();if(!this.isOpen){this.openDropdown()}else{this.highlightedIndex=Math.min(this.highlightedIndex+1,this.options.length-1)}break;case"ArrowUp":e.preventDefault();if(this.isOpen){this.highlightedIndex=Math.max(this.highlightedIndex-1,0)}break}};getSelectedOptionLabel=()=>{const e=this.options.find((e=>e.value===this.selectValue));return e?e.label:this.selectPlaceholder};render(){const e=this.getSelectedOptionLabel();const o=this.selectValue!=="";return r("div",{key:"f30fb3ed1389a6e12f1d923e132498fe2f44fe6c",class:"input-container"},this.label&&r("label",{key:"73a36d44f468a4a6783782db056c402e6f31d0d4",class:`input-label ${this.disabled?"disabled":""}`},this.label),r("div",{key:"c283fb595144d44c0b9dc7ea7b21cbc14b296860",class:`input-combo-wrapper combo-wrapper ${this.disabled?"disabled":""} ${this.error?"error":""}`},r("div",{key:"9c1e8ea00d44d4cecd8a7e1eef3507135c021984",class:"select-section",style:{width:this.selectWidth}},r("div",{key:"42f65608af44f4ce777f3811b19a6a5d965f980d",ref:e=>this.triggerRef=e,class:`input-combo-select select-combo-trigger ${!o?"placeholder":""}`,onClick:this.toggleDropdown,onKeyDown:this.handleKeyDown,onBlur:this.onSelectBlur,tabIndex:this.disabled?-1:0,role:"combobox","aria-expanded":this.isOpen.toString(),"aria-haspopup":"listbox"},r("span",{key:"1b7402f39e8edfb2857b89339b44d352168053c3",class:"select-value"},e),r("div",{key:"9521467fd6b4844aa8eef664e05fdd2fffa93084",class:"icon-wrapper"},r("rebill-icon",{key:"3ca69faf99c23aa869b4f30d86d4ec3e27dbc87a",name:"chevron-up-down",size:"20px",class:"select-icon"}))),this.isOpen&&r("div",{key:"90c3696f5950268b273a166459bde04567097e72",ref:e=>this.dropdownRef=e,class:"select-dropdown",role:"listbox"},this.options.map(((e,o)=>r("div",{class:`select-option ${this.selectValue===e.value?"selected":""} ${this.highlightedIndex===o?"highlighted":""}`,onClick:()=>this.selectOption(e),role:"option","aria-selected":this.selectValue===e.value?"true":"false"},e.label))))),r("div",{key:"dba779de6a18058418e90354d022110b7b1484df",class:"combo-divider"}),r("div",{key:"8f9bb471e5c7803a322510a4eda20b145159203e",class:"input-section"},r("input",{key:"90542af1e1f10e137b1ab711a689fdbfdd46223e",type:"text",class:"input-combo-element combo-input",placeholder:this.inputPlaceholder,value:this.inputValue,onInput:this.onInputChange,onBlur:this.onInputBlur,disabled:this.disabled}))),this.error&&r("span",{key:"46c579be0ba230af0cb3d813d209fa51b8a35774",class:"error-message"},this.error))}};E.style=I;const C="";const S=class{constructor(r){e(this,r)}get el(){return t(this)}error;currentValue=null;isDisabled=false;value=null;placeholder=null;handleInstallments=e=>{if(this.isDisabled){const e=new CustomEvent("input",{detail:{id:"installments",value:"",disabled:true},bubbles:true});this.el.dispatchEvent(e);return}this.currentValue=e.detail.value;n.setSelectedInstallment(e.detail.value)};componentWillLoad(){n.onChange("data",(()=>{this.isDisabled=!s.data.cardInformation?.installments?.isAvailableInstallments;this.placeholder=!s.data.cardInformation?.installments?.isAvailableInstallments?f(s.data.pricing?.currency):u(s.data.pricing?.currency);this.value=this.isDisabled?"":this.value;if(this.isDisabled){const e=new CustomEvent("input",{detail:{id:"installments",value:"",disabled:true},bubbles:true});this.el.dispatchEvent(e)}}))}render(){return r("div",{key:"a7e2147789a5664d4b5857c86652c85f78a88872"},r("rebill-input-select",{key:this.isDisabled.toString(),id:"installments",variant:"outlined",value:this.value,options:s.data.cardInformation?.installments?.installments.map((e=>({label:g(e.installment,y(e.installmentAmount),s.data.pricing?.currency,e.cft,e.model),value:e?.installment?.toString()})))||[],loading:s.data.fetchingInstallments,placeholder:this.placeholder,disabled:this.isDisabled,"on-input":this.handleInstallments,error:l.translate(this.error)}),s.data.cardInformation?.installments?.installments.find((e=>e.installment===s.data.cardInformation?.installments?.selectedInstallment?.installment))?.model===m.CUSTOMER_FINANCED&&r("rebill-typography",{key:"77b18f5f22cf47c79a6a2f30655117f4aaa60987",variant:"italic",color:x.SECONDARY},l.translate("installments.interest")))}};S.style=C;export{v as card_identification,k as card_iframe,T as card_skeleton,E as rebill_input_combo,S as rebill_installments};
2
- //# sourceMappingURL=p-28d04513.entry.js.map
1
+ import{r as e,h as r,c as o,g as t}from"./p-D8cwEAmw.js";import{a as i}from"./p-D2_UL7f8.js";import{I as l,s,e as a,a as n,o as c}from"./p-DkbFAMha.js";import{r as d,o as b,R as h}from"./p-BOVs95c7.js";import{g as p}from"./p-B5khCLtC.js";import{c as f,d as u,E as m,e as g,b as y}from"./p-wvcrPcSK.js";import{C as x}from"./p-DA598vBj.js";import"./p-E-ZsRS8r.js";const v=class{constructor(r){e(this,r)}documentTypes=[];country="";currentLanguage=l.getCurrentLanguage();documentTypeError="";documentNumberError="";disabled=false;loadDocumentTypes=async()=>{const e=d.isInitialized?d.data?.price?.country:s?.data?.pricing?.country;if(e&&e!==this.country){try{const r=await i.data.getDocumentTypes(e);this.documentTypes=r.data;this.country=e}catch(e){console.error("Error loading document types:",e)}}};async componentWillLoad(){a.on("languageChanged",this.handleLanguageChange);n.onChange("data",(()=>{if(!d.isInitialized){this.loadDocumentTypes()}}));b("data",(()=>{if(d.isInitialized){this.loadDocumentTypes()}}));await this.loadDocumentTypes()}handleInputChange=e=>{const{id:r,value:o}=e.detail;if(d.isInitialized){h.setUserIdentification({[r]:o})}else{n.setUserInformation({[r]:o})}};disconnectedCallback(){a.off("languageChanged",this.handleLanguageChange)}handleLanguageChange=()=>{this.currentLanguage=l.getCurrentLanguage()};render(){const e=this.documentTypeError||this.documentNumberError;const o=this.documentTypes.map((e=>({label:e.value,value:e.value})));return r(r.Fragment,null,r("rebill-input-combo",{key:"075b874873f297d3e2e72e54625db2d5cc49c619","select-id":"documentType","input-id":"documentNumber","on-input":this.handleInputChange,"select-placeholder":l.translate("document.typePlaceholder"),"input-placeholder":l.translate("document.numberPlaceholder"),error:l.translate(e),options:o,disabled:this.disabled}))}};const k=class{constructor(r){e(this,r)}customCSS;iframeLoaded=false;currentLang=s.currentLocale;initialLang=s.currentLocale;iframeHeight="100px";getIframeURL(){const e=p().iframeURL;const r=new URL(e);r.searchParams.set("lang",this.initialLang);if(d.data?.subscription?.customerId&&d.token){r.searchParams.set("customerId",d.data.subscription.customerId);r.searchParams.set("token",d.token)}return r.toString()}iframeRef;unsubscribeCurrentLocaleStore;unsubscribeDataStore;unsubscribeRenewalStore;postInitialDataToIframe(){if(d.isInitialized){if(d.data?.organization?.id){this.postOrganizationIdToIframe(d.data.organization.id)}this.postLanguageToIframe();this.postTotalPriceToIframe();this.postCurrencyToIframe();this.postCustomerIdToIframe();this.postTokenToIframe();this.postItemTypeToIframe()}else{if(s.data?.organization?.id){this.postOrganizationIdToIframe(s.data.organization.id)}if(s?.currentLocale){this.postLanguageToIframe()}this.postTotalPriceToIframe();this.postCurrencyToIframe();this.postCustomerIdToIframe();this.postTokenToIframe();this.postItemTypeToIframe()}this.postCustomCSSToIframe()}postTotalPriceToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow){let e;if(d.isInitialized){e=d.data?.price?.amount||0}else{e=s.data?.pricing?.totalWithoutInstallment||0}this.iframeRef.contentWindow.postMessage({type:"SET_TOTAL_PRICE",payload:{total:e}},"*")}}postCustomerIdToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow&&d.data?.subscription?.customerId){this.iframeRef.contentWindow.postMessage({type:"SET_CUSTOMER_ID",payload:{customerId:d.data.subscription.customerId}},"*")}else if(this.iframeRef&&this.iframeRef.contentWindow&&s.data.customerId){this.iframeRef.contentWindow.postMessage({type:"SET_CUSTOMER_ID",payload:{customerId:s.data.customerId}},"*")}}postLanguageToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow){this.iframeRef.contentWindow.postMessage({type:"SET_LANGUAGE",payload:{lang:this.currentLang}},"*")}}postOrganizationIdToIframe(e){if(!!this.iframeRef&&!!this.iframeRef.contentWindow){this.iframeRef.contentWindow.postMessage({type:"SET_ORGANIZATION_ID",payload:{organizationId:e}},"*")}}postTokenToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow&&d.token){this.iframeRef.contentWindow.postMessage({type:"SET_TOKEN",payload:{token:d.token}},"*")}else if(this.iframeRef&&this.iframeRef.contentWindow&&s.data.accessToken){this.iframeRef.contentWindow.postMessage({type:"SET_TOKEN",payload:{token:s.data.accessToken}},"*")}}postItemTypeToIframe(){if(!this.iframeRef||!this.iframeRef.contentWindow){return}if(d.isInitialized&&d.data?.subscription?.type){this.iframeRef.contentWindow.postMessage({type:"SET_ITEM_TYPE",payload:{itemType:d.data.subscription.type}},"*")}else if(s.data?.itemInformation?.type){this.iframeRef.contentWindow.postMessage({type:"SET_ITEM_TYPE",payload:{itemType:s.data.itemInformation.type}},"*")}}postCurrencyToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow){let e;if(d.isInitialized){e=d.data?.price?.currency||""}else{e=s.data?.pricing?.currency||""}if(e){this.iframeRef.contentWindow.postMessage({type:"SET_CURRENCY",payload:{currency:e}},"*")}}}postCustomCSSToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow&&this.customCSS){this.iframeRef.contentWindow.postMessage({type:"SET_CUSTOM_CSS",payload:{css:this.customCSS}},"*")}}postClearCustomerIdToIframe(){if(this.iframeRef&&this.iframeRef.contentWindow&&(!s.data.customerId||!s.data.accessToken)){this.iframeRef.contentWindow.postMessage({type:"CLEAR_CUSTOMER_ID_AND_TOKEN"},"*")}}componentWillLoad(){this.initialLang=s.currentLocale;this.unsubscribeCurrentLocaleStore=c("currentLocale",(()=>{this.currentLang=s.currentLocale;this.postLanguageToIframe()}));this.unsubscribeDataStore=c("data",(()=>{if(!d.isInitialized){if(s.data?.organization?.id){this.postOrganizationIdToIframe(s.data.organization.id)}if(s.data?.pricing?.totalWithoutInstallment!==undefined&&s.data?.pricing?.totalWithoutInstallment!==null){this.postTotalPriceToIframe()}this.postCurrencyToIframe();this.postCustomerIdToIframe();this.postTokenToIframe();this.postItemTypeToIframe();this.postClearCustomerIdToIframe()}}));this.unsubscribeRenewalStore=b("data",(()=>{if(d.isInitialized){if(d.data?.organization?.id){this.postOrganizationIdToIframe(d.data.organization.id)}if(d.data?.price?.amount!==undefined){this.postTotalPriceToIframe()}this.postCurrencyToIframe();this.postCustomerIdToIframe();this.postTokenToIframe();this.postItemTypeToIframe()}}));setTimeout((()=>{this.postInitialDataToIframe()}),1e3)}componentWillUpdate(){if(this.iframeLoaded){this.postCustomCSSToIframe()}}componentDidLoad(){window.addEventListener("message",this.handleIframeMessage)}disconnectedCallback(){if(this.unsubscribeCurrentLocaleStore)this.unsubscribeCurrentLocaleStore();if(this.unsubscribeDataStore)this.unsubscribeDataStore();if(this.unsubscribeRenewalStore)this.unsubscribeRenewalStore();window.removeEventListener("message",this.handleIframeMessage)}handleIframeLoad=()=>{this.iframeLoaded=true;this.postLanguageToIframe();if(d.isInitialized){if(d.data?.organization?.id){this.postOrganizationIdToIframe(d.data.organization.id)}this.postCurrencyToIframe();this.postCustomerIdToIframe();this.postTokenToIframe();this.postItemTypeToIframe()}this.postCustomCSSToIframe();setTimeout((()=>{this.postInitialDataToIframe()}),500)};handleIframeMessage=e=>{if(e.data&&e.data.type==="IFRAME_HEIGHT"&&e.data.payload&&typeof e.data.payload.height==="number"){this.iframeHeight=`${e.data.payload.height}px`}if(e.data&&e.data.type==="FORM_STATE"){if(d.isInitialized){if(!e.data.payload?.complete){h.setCardId(null);h.setCardTokenId(null)}}else if(s.isInitialized){if(!e.data.payload?.complete){n.setCardId(null);n.setCardTokenId(null)}}}if(e.data&&e.data.type==="INSTALLMENTS"&&e.data.payload){if(d.isInitialized){h.setCardInformation(e.data.payload)}else{n.setCardInformation(e.data.payload)}}if(e.data&&e.data.type==="CARD_TOKENIZED"){if(d.isInitialized){h.setCardTokenId(e.data?.payload?.token)}else if(s.isInitialized){n.setCardTokenId(e.data?.payload?.token)}}if(e.data&&e.data.type==="CARD_ID"){if(d.isInitialized){h.setCardId(e.data.payload?.id)}else if(s.isInitialized){n.setCardId(e.data.payload?.id)}}if(e.data&&e.data.type==="SAVE_CARD"){if(s.isInitialized){n.setSaveCard(e.data.payload?.saveCard)}}if(e.data&&e.data.type==="FETCHING_INSTALLMENTS"){const r=e.data.payload?.fetching||false;if(d.isInitialized){h.setFetchingInstallments(r)}else if(s.isInitialized){n.setFetchingInstallments(r)}}if(e.data&&e.data.type==="NEW_CARD_MODE"){const r=e.data.payload?.mode;if(r&&(r==="input"||r==="select")){if(d.isInitialized){h.setCardMode(r)}else if(s.isInitialized){n.setCardMode(r)}}}};render(){return r("div",{key:"21cee6426b31b15e214272bed3b893a89cfebdc3",style:{width:"100%",height:this.iframeHeight,position:"relative",overflow:"hidden"}},!this.iframeLoaded&&r("card-skeleton",{key:"66bbb20d750975f5e6a15a72c55f21ac209c9a10"}),r("iframe",{key:"8f9c689ea04b5b88511cbcc69b792454460b2a48",ref:e=>this.iframeRef=e,src:this.getIframeURL(),style:{width:"100%",height:"100%",border:"none",overflow:"hidden"},title:"Card Payment Component",allow:"payment",onLoad:this.handleIframeLoad}))}};const w=":root{--rebill-color-primary:#3b82f6;--rebill-color-primary-light:rgba(59, 130, 246, 0.1);--rebill-color-primary-hover:#2563eb;--rebill-color-primary-dark:#001131;--rebill-color-primary-dark-text:#000000;--rebill-color-primary-dark-hover:#001c4a;--rebill-color-primary-dark-light:rgba(0, 17, 49, 0.1);--rebill-color-error:#ef4444;--rebill-color-error-background:#fef2f2;--rebill-color-error-light:rgba(239, 68, 68, 0.1);--rebill-color-error-dark:#6f101b;--rebill-color-background:#ffffff;--rebill-color-background-left:#fafafa;--rebill-color-background-right:#f4f5f6;--rebill-color-background-secondary:#f7f8fa;--rebill-color-border:#ebedef;--rebill-color-timeline-connector:#c4c8cf;--rebill-color-neutrals-700:#58616e;--rebill-color-neutrals-500:#9ca3af;--rebill-color-border-primary:#e4e4e7;--rebill-color-text-primary:#3b4049;--rebill-color-text-secondary:#6b7280;--rebill-color-grey-700:#7d7d7d;--rebill-color-text-secondary-light:#a1a1aa;--rebill-color-text-on-primary:#ffffff;--rebill-color-disabled:#9ca3af;--rebill-color-shadow:rgba(0, 0, 0, 0.1);--rebill-color-green:#10b981;--rebill-color-green-text:#257c67;--rebill-color-green-light:rgba(183, 233, 221, 0.15);--rebill-color-green-light-2:rgba(183, 233, 221, 1);--rebill-color-info-background:#d5e4ff;--rebill-color-info-border:#0156f6;--rebill-color-info-text:#172b85;--rebill-color-background-secondary-light:#f7f8fa;--rebill-breakpoint-mobile:768px;--rebill-breakpoint-tablet:1024px;--rebill-breakpoint-desktop:1025px;--rebill-color-orange:#ff9400;--rebill-color-black:#1e2025;--rebill-color-grey-300:#3b4049;--rebill-color-grey-100:#aeaeae}.qr-container,.qr-image,.qr-image svg,.qr-image img,[class*='qr-'],[class*='success'],[class*='receipt']{transition:none !important;animation:none !important;will-change:auto !important}button:active,button:focus,button:hover{isolation:isolate}.iframe-skeleton{display:flex;flex-direction:column;gap:16px}.input-skeleton{width:100%;height:40px;background:var(--rebill-color-border-primary);border-radius:8px;border:1px solid var(--rebill-color-border-primary)}";const T=class{constructor(r){e(this,r)}render(){return r("div",{key:"76c432f43c597f9ff92b949c16d70b1b6840e378",class:"iframe-skeleton"},r("div",{key:"9c77a9eeda10a23004890c934f30f8d25be7fbf1",class:"input-skeleton"}),r("div",{key:"d26032fe4bbb41dd0107e9fa5d8bd041da401351",class:"input-skeleton"}))}};T.style=w;const I=".input-container{display:flex;flex-direction:column}.input-label{font-size:0.875rem;color:var(--rebill-color-text-primary);font-weight:500;margin-bottom:0.375rem}.input-label.disabled{cursor:not-allowed}.input-element{border-radius:var(--input-group-inner-border-radius, 8px);border:1.5px solid var(--rebill-color-border);padding:10px 14px;font-size:0.875rem;color:var(--rebill-color-text-primary);outline:none;transition:border-color 0.2s;background:var(--rebill-color-background);height:38.33px;box-sizing:border-box}.input-element.input-error{border-color:var(--rebill-color-error)}.input-element:disabled{background-color:var(--rebill-color-background);border-color:var(--rebill-color-disabled);color:var(--rebill-color-text-secondary);cursor:not-allowed;opacity:0.7}select.input-element{padding:10px 30px 10px 14px;appearance:none;cursor:pointer}select.input-element:disabled{cursor:not-allowed}.input-element:focus{border-color:var(--rebill-color-primary)}.input-element:disabled:focus{border-color:var(--rebill-color-disabled)}.input-element::placeholder{color:var(--rebill-color-text-secondary-light);font-size:0.875rem;opacity:1}.select-wrapper.disabled .select-icon{color:var(--rebill-color-disabled)}.error-message{color:var(--rebill-color-error);font-size:0.75rem;margin-top:0.375rem}@media screen and (max-width: 768px){.input-element{font-size:1rem}.input-element::placeholder{font-size:1rem}}:host{display:block;width:100%;box-sizing:border-box}.combo-wrapper{display:flex;align-items:stretch;width:100%;height:38.33px;border-radius:var(--input-group-inner-border-radius, 8px);border:1.5px solid var(--rebill-color-border);background:var(--rebill-color-background);transition:border-color 0.2s;position:relative;box-sizing:border-box}.combo-wrapper:focus-within{border-color:var(--rebill-color-primary);box-shadow:0 0 0 2px var(--rebill-color-primary-light)}.combo-wrapper.error{border-color:var(--rebill-color-error)}.combo-wrapper.disabled{background-color:var(--rebill-color-background);border-color:var(--rebill-color-disabled);color:var(--rebill-color-text-secondary);cursor:not-allowed;opacity:0.7}.select-section{position:relative;flex-shrink:0;min-width:80px;display:flex;align-items:center}.select-combo-trigger{width:100%;height:100%;padding:0 30px 0 14px;font-size:0.875rem;font-weight:normal;color:var(--rebill-color-text-primary);background:transparent;border:none;outline:none;cursor:pointer;display:flex;align-items:center;justify-content:space-between;user-select:none;box-sizing:border-box;position:relative;transition:border-color 0.2s}.select-combo-trigger:focus{outline:none}.select-combo-trigger:hover:not(.disabled){border-color:var(--rebill-color-primary)}.select-combo-trigger.placeholder .select-value{color:var(--rebill-color-text-secondary-light)}.combo-wrapper.disabled .select-combo-trigger{cursor:not-allowed;color:var(--rebill-color-text-secondary)}.select-value{flex:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-section .icon-wrapper{position:absolute;right:0.75rem;top:50%;transform:translateY(-50%);display:flex;align-items:center;justify-content:center;height:20px;width:20px}.select-icon{color:var(--rebill-color-text-secondary);transition:transform 0.2s ease;transform-origin:50% 50%;display:block}.combo-wrapper.disabled .select-icon{color:var(--rebill-color-disabled)}.select-dropdown{position:absolute;top:100%;left:0;right:0;z-index:1000;background-color:var(--rebill-color-background);border:1px solid var(--rebill-color-border);border-radius:0.375rem;box-shadow:0 4px 6px -1px rgba(0, 0, 0, 0.1),\n 0 2px 4px -1px rgba(0, 0, 0, 0.06);margin-top:0.25rem;max-height:200px;overflow-y:auto;animation:slideDown 0.15s ease-out;box-sizing:border-box;width:100%}.select-option{padding:0.75rem;font-size:0.875rem;color:var(--rebill-color-text-primary);cursor:pointer;border-bottom:1px solid var(--rebill-color-border);transition:background-color 0.15s ease}.select-option:last-child{border-bottom:none}.select-option:hover,.select-option.highlighted{background-color:#f0f9ff}.select-option.selected{background-color:var(--rebill-color-primary);color:white}.select-option.selected:hover,.select-option.selected.highlighted{background-color:var(--rebill-color-primary)}.select-dropdown::-webkit-scrollbar{width:6px}.select-dropdown::-webkit-scrollbar-track{background:transparent}.select-dropdown::-webkit-scrollbar-thumb{background-color:var(--rebill-color-border);border-radius:3px}.select-dropdown::-webkit-scrollbar-thumb:hover{background-color:var(--rebill-color-text-secondary)}.combo-divider{width:1px;background-color:var(--rebill-color-border);margin:0;flex-shrink:0}.input-section{flex:1;min-width:0;display:flex;align-items:center}.combo-input{width:100%;height:100%;padding:0 14px;font-size:0.875rem;color:var(--rebill-color-text-primary);background:transparent;border:none;outline:none;box-sizing:border-box}.combo-input:focus{outline:none}.combo-input::placeholder{color:var(--rebill-color-text-secondary-light);font-size:0.875rem;opacity:1}.combo-wrapper.disabled .combo-input{color:var(--rebill-color-text-secondary);cursor:not-allowed}.combo-wrapper.disabled .combo-input::placeholder{color:var(--rebill-color-text-secondary)}@keyframes slideDown{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}@keyframes slideUp{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.select-dropdown::-webkit-scrollbar{width:6px}.select-dropdown::-webkit-scrollbar-track{background:transparent}.select-dropdown::-webkit-scrollbar-thumb{background-color:var(--rebill-color-border);border-radius:3px}.select-dropdown::-webkit-scrollbar-thumb:hover{background-color:var(--rebill-color-text-secondary)}@media screen and (max-width: 768px){.select-combo-trigger{font-size:1rem}.select-option{font-size:1rem}.combo-input{font-size:1rem}.combo-input::placeholder{font-size:1rem}}";const E=class{constructor(r){e(this,r);this.blur=o(this,"blur");this.selectChange=o(this,"selectChange");this.input=o(this,"input")}dropdownRef;triggerRef;label="";options=[];selectValue="";inputValue="";inputPlaceholder="";selectPlaceholder="";error="";selectId="";inputId="";disabled=false;selectWidth="120px";isOpen=false;highlightedIndex=-1;componentId="";blur;selectChange;input;componentWillLoad(){this.componentId=this.selectId||`combo-${Math.random().toString(36).substr(2,9)}`}handleFormChange(e){const r=e.detail;if(r){if(this.selectId&&this.selectId in r){const e=r[this.selectId];if(typeof e==="string"){this.selectValue=e}}if(this.inputId&&this.inputId in r){const e=r[this.inputId];if(typeof e==="string"){this.inputValue=e}}}}handleCloseAllSelects(e){if(e.detail!==this.componentId){this.closeDropdown()}}handleDocumentClick(e){if(this.dropdownRef&&this.triggerRef&&!this.dropdownRef.contains(e.target)&&!this.triggerRef.contains(e.target)){this.closeDropdown()}}toggleDropdown=()=>{if(this.disabled)return;const e=this.isOpen;this.isOpen=!this.isOpen;if(this.isOpen){if(!e){document.dispatchEvent(new CustomEvent("closeAllSelects",{detail:this.componentId}))}this.highlightedIndex=this.options.findIndex((e=>e.value===this.selectValue));if(this.highlightedIndex===-1){this.highlightedIndex=0}}};openDropdown=()=>{if(this.disabled)return;document.dispatchEvent(new CustomEvent("closeAllSelects",{detail:this.componentId}));this.isOpen=true;this.highlightedIndex=this.options.findIndex((e=>e.value===this.selectValue));if(this.highlightedIndex===-1){this.highlightedIndex=0}};closeDropdown=()=>{this.isOpen=false;this.highlightedIndex=-1};selectOption=e=>{if(this.disabled)return;this.selectValue=e.value;this.closeDropdown();this.input.emit({id:this.selectId,value:this.selectValue})};onInputChange=e=>{if(this.disabled)return;const r=e.target;this.inputValue=r.value;this.input.emit({id:this.inputId,value:this.inputValue})};onSelectBlur=()=>{this.blur.emit({id:this.selectId,value:this.selectValue})};onInputBlur=()=>{const e=this.inputValue.trim();if(e!==this.inputValue){this.inputValue=e;this.input.emit({id:this.inputId,value:this.inputValue})}this.blur.emit({id:this.inputId,value:this.inputValue})};handleKeyDown=e=>{if(this.disabled)return;switch(e.key){case"Enter":case" ":e.preventDefault();if(this.isOpen&&this.highlightedIndex>=0){this.selectOption(this.options[this.highlightedIndex])}else{this.toggleDropdown()}break;case"Escape":e.preventDefault();this.closeDropdown();break;case"ArrowDown":e.preventDefault();if(!this.isOpen){this.openDropdown()}else{this.highlightedIndex=Math.min(this.highlightedIndex+1,this.options.length-1)}break;case"ArrowUp":e.preventDefault();if(this.isOpen){this.highlightedIndex=Math.max(this.highlightedIndex-1,0)}break}};getSelectedOptionLabel=()=>{const e=this.options.find((e=>e.value===this.selectValue));return e?e.label:this.selectPlaceholder};render(){const e=this.getSelectedOptionLabel();const o=this.selectValue!=="";return r("div",{key:"f30fb3ed1389a6e12f1d923e132498fe2f44fe6c",class:"input-container"},this.label&&r("label",{key:"73a36d44f468a4a6783782db056c402e6f31d0d4",class:`input-label ${this.disabled?"disabled":""}`},this.label),r("div",{key:"c283fb595144d44c0b9dc7ea7b21cbc14b296860",class:`input-combo-wrapper combo-wrapper ${this.disabled?"disabled":""} ${this.error?"error":""}`},r("div",{key:"9c1e8ea00d44d4cecd8a7e1eef3507135c021984",class:"select-section",style:{width:this.selectWidth}},r("div",{key:"42f65608af44f4ce777f3811b19a6a5d965f980d",ref:e=>this.triggerRef=e,class:`input-combo-select select-combo-trigger ${!o?"placeholder":""}`,onClick:this.toggleDropdown,onKeyDown:this.handleKeyDown,onBlur:this.onSelectBlur,tabIndex:this.disabled?-1:0,role:"combobox","aria-expanded":this.isOpen.toString(),"aria-haspopup":"listbox"},r("span",{key:"1b7402f39e8edfb2857b89339b44d352168053c3",class:"select-value"},e),r("div",{key:"9521467fd6b4844aa8eef664e05fdd2fffa93084",class:"icon-wrapper"},r("rebill-icon",{key:"3ca69faf99c23aa869b4f30d86d4ec3e27dbc87a",name:"chevron-up-down",size:"20px",class:"select-icon"}))),this.isOpen&&r("div",{key:"90c3696f5950268b273a166459bde04567097e72",ref:e=>this.dropdownRef=e,class:"select-dropdown",role:"listbox"},this.options.map(((e,o)=>r("div",{class:`select-option ${this.selectValue===e.value?"selected":""} ${this.highlightedIndex===o?"highlighted":""}`,onClick:()=>this.selectOption(e),role:"option","aria-selected":this.selectValue===e.value?"true":"false"},e.label))))),r("div",{key:"dba779de6a18058418e90354d022110b7b1484df",class:"combo-divider"}),r("div",{key:"8f9bb471e5c7803a322510a4eda20b145159203e",class:"input-section"},r("input",{key:"90542af1e1f10e137b1ab711a689fdbfdd46223e",type:"text",class:"input-combo-element combo-input",placeholder:this.inputPlaceholder,value:this.inputValue,onInput:this.onInputChange,onBlur:this.onInputBlur,disabled:this.disabled}))),this.error&&r("span",{key:"46c579be0ba230af0cb3d813d209fa51b8a35774",class:"error-message"},this.error))}};E.style=I;const C="";const S=class{constructor(r){e(this,r)}get el(){return t(this)}error;currentValue=null;isDisabled=false;value=null;placeholder=null;handleInstallments=e=>{if(this.isDisabled){const e=new CustomEvent("input",{detail:{id:"installments",value:"",disabled:true},bubbles:true});this.el.dispatchEvent(e);return}this.currentValue=e.detail.value;n.setSelectedInstallment(e.detail.value)};componentWillLoad(){n.onChange("data",(()=>{this.isDisabled=!s.data.cardInformation?.installments?.isAvailableInstallments;this.placeholder=!s.data.cardInformation?.installments?.isAvailableInstallments?f(s.data.pricing?.currency):u(s.data.pricing?.currency);this.value=this.isDisabled?"":this.value;if(this.isDisabled){const e=new CustomEvent("input",{detail:{id:"installments",value:"",disabled:true},bubbles:true});this.el.dispatchEvent(e)}}))}render(){return r("div",{key:"a7e2147789a5664d4b5857c86652c85f78a88872"},r("rebill-input-select",{key:this.isDisabled.toString(),id:"installments",variant:"outlined",value:this.value,options:s.data.cardInformation?.installments?.installments.map((e=>({label:g(e.installment,y(e.installmentAmount),s.data.pricing?.currency,e.cft,e.model),value:e?.installment?.toString()})))||[],loading:s.data.fetchingInstallments,placeholder:this.placeholder,disabled:this.isDisabled,"on-input":this.handleInstallments,error:l.translate(this.error)}),s.data.cardInformation?.installments?.installments.find((e=>e.installment===s.data.cardInformation?.installments?.selectedInstallment?.installment))?.model===m.CUSTOMER_FINANCED&&r("rebill-typography",{key:"77b18f5f22cf47c79a6a2f30655117f4aaa60987",variant:"italic",color:x.SECONDARY},l.translate("installments.interest")))}};S.style=C;export{v as card_identification,k as card_iframe,T as card_skeleton,E as rebill_input_combo,S as rebill_installments};
2
+ //# sourceMappingURL=p-2ddabd39.entry.js.map
@@ -1,2 +1,2 @@
1
- import{r as e,c as t,h as i}from"./p-D8cwEAmw.js";import{c as r}from"./p-MMCcKmy_.js";import{a as o}from"./p-CTo1s54i.js";import{m as n,i as a,g as s,C as l,a as c,b as d}from"./p-DDA1jPBc.js";import{P as h,I as m}from"./p-DkbFAMha.js";import{P as u,G as p,a as f}from"./p-CrUPzbxi.js";import{r as b,R as y,o as g}from"./p-BOVs95c7.js";import{B as x,g as w,i as k}from"./p-Do_vNuMa.js";import{C as v}from"./p-DA598vBj.js";import"./p-E-ZsRS8r.js";import"./p-D339jHg4.js";const C=async(e,t,i)=>{const r=await o.checkout.getRequiredFields({currency:e,method:t},i);return{fields:n(r.data),original:r.data}};const D=async()=>{const e=[...new Set(b.data.paymentMethods.map((e=>e.type)))];const t=e.map((async e=>{try{const t=u.mapToAPMPaymentMethod(e,b.data.price.country);const i=await C(b.data.price.currency,t,b.data.organization.id);return{paymentMethod:e,...i}}catch(t){console.error(`Error getting required fields for ${e}:`,t);return{paymentMethod:e,fields:[],original:[]}}}));const i=await Promise.all(t);const r={};i.forEach((e=>{r[e.paymentMethod]={fields:e.fields,original:e.original}}));return r};const q=(e,t)=>{const i=t[e];if(i){return i}else{return{fields:[],original:[]}}};const M=":root{--rebill-color-primary:#3b82f6;--rebill-color-primary-light:rgba(59, 130, 246, 0.1);--rebill-color-primary-hover:#2563eb;--rebill-color-primary-dark:#001131;--rebill-color-primary-dark-text:#000000;--rebill-color-primary-dark-hover:#001c4a;--rebill-color-primary-dark-light:rgba(0, 17, 49, 0.1);--rebill-color-error:#ef4444;--rebill-color-error-background:#fef2f2;--rebill-color-error-light:rgba(239, 68, 68, 0.1);--rebill-color-error-dark:#6f101b;--rebill-color-background:#ffffff;--rebill-color-background-left:#fafafa;--rebill-color-background-right:#f4f5f6;--rebill-color-background-secondary:#f7f8fa;--rebill-color-border:#ebedef;--rebill-color-timeline-connector:#c4c8cf;--rebill-color-neutrals-700:#58616e;--rebill-color-neutrals-500:#9ca3af;--rebill-color-border-primary:#e4e4e7;--rebill-color-text-primary:#3b4049;--rebill-color-text-secondary:#6b7280;--rebill-color-grey-700:#7d7d7d;--rebill-color-text-secondary-light:#a1a1aa;--rebill-color-text-on-primary:#ffffff;--rebill-color-disabled:#9ca3af;--rebill-color-shadow:rgba(0, 0, 0, 0.1);--rebill-color-green:#10b981;--rebill-color-green-text:#257c67;--rebill-color-green-light:rgba(183, 233, 221, 0.15);--rebill-color-green-light-2:rgba(183, 233, 221, 1);--rebill-color-info-background:#d5e4ff;--rebill-color-info-border:#0156f6;--rebill-color-info-text:#172b85;--rebill-color-background-secondary-light:#f7f8fa;--rebill-breakpoint-mobile:768px;--rebill-breakpoint-tablet:1024px;--rebill-breakpoint-desktop:1025px;--rebill-color-orange:#ff9400;--rebill-color-black:#1e2025;--rebill-color-grey-300:#3b4049;--rebill-color-grey-100:#aeaeae}.qr-container,.qr-image,.qr-image svg,.qr-image img,[class*='qr-'],[class*='success'],[class*='receipt']{transition:none !important;animation:none !important;will-change:auto !important}button:active,button:focus,button:hover{isolation:isolate}@media (max-width: 1024px){.rebill-checkout-renewal{flex-direction:column;gap:0;justify-content:flex-start;background:var(--rebill-color-background);padding:20px}.right-section .left-section{width:100%;height:100%;background:var(--rebill-color-background)}.checkout-form-section{display:flex;flex-direction:column;justify-content:flex-start;gap:24px;height:100%;margin-top:24px}.otp-container{display:flex;flex-direction:column;justify-content:flex-start;gap:24px}}@media (min-width: 1025px){.rebill-checkout-renewal{width:100vw;min-height:100vh;display:flex;flex-direction:row;justify-content:center;overflow-y:auto}.left-section{display:flex;width:60%;background:var(--rebill-color-background-left);justify-content:space-around}.right-section{display:flex;padding-top:72px;width:40%;background:var(--rebill-color-background-right);position:sticky;top:0;justify-content:center}.checkout-form-section{display:flex;flex-direction:column;justify-content:flex-start;margin-bottom:36px;margin-top:24px;gap:32px}.left-section-container{max-width:450px;min-width:450px;margin:2.5rem 2rem 1.5rem 2rem;display:flex;flex-direction:column}.checkout-summary-section{max-width:450px;min-width:350px;margin:0rem 2rem;background:var(--rebill-color-background-right);display:flex;flex-direction:column;justify-content:flex-start;width:100%}.checkout-form-section user-information,.checkout-form-section payment-method-selector,.checkout-form-section rebill-address,.checkout-summary-section rebill-summary{width:100%}.pac-container{border-radius:4px;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1);border:1px solid #e0e0e0;margin-top:4px;font-family:inherit}.pac-item{padding:10px 12px;cursor:pointer;border-top:none}.pac-item:first-child{border-top:none}.pac-item:hover{background-color:#f5f5f5}.pac-item-query{font-weight:500}.pac-icon{display:none}}.payment-button-container{display:flex;flex-direction:column;gap:16px;margin-bottom:16px}.animated-component{transition:all 0.3s ease-in-out;overflow:visible}.fade-in{animation:fadeIn 0.4s ease-in-out}.slide-in{animation:slideIn 0.5s ease-out}@keyframes fadeIn{from{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes slideIn{from{opacity:0;transform:translateX(-20px);max-height:0}to{opacity:1;transform:translateX(0);max-height:450px}}.animated-component.hide{animation:fadeOut 0.3s ease-in-out forwards}@keyframes fadeOut{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(20px)}}rebill-mode-sandbox{position:fixed;bottom:50px;left:50%;transform:translateX(-50%);z-index:1000}@media (max-width: 1024px){rebill-test-mode-chip{bottom:46px}}@media (min-width: 1025px){rebill-test-mode-chip{bottom:46px}}.mode-sandbox-mobile-container{display:flex;align-items:center;width:100%;padding:0;margin:0;box-sizing:border-box}@media (min-width: 1451px){.left-section-container{min-width:450px;margin:2.5rem 5rem 1.5rem 5rem}.checkout-summary-section{min-width:450px;margin:0rem 5rem}}";const j=class{constructor(i){e(this,i);this.success=t(this,"success");this.paymentError=t(this,"paymentError");this.paymentMethodSelected=t(this,"paymentMethodSelected")}renewalData;renewalToken;currentPaymentMethod=h.CARD;isSubmitting=false;isCardSubmitting=false;isCardSuccess=false;errorMessage=null;breakpoint=x.DESKTOP;errorPaymentCard=false;errorPaymentAPM=false;initialData={};checkoutResponse=null;currentApmPaymentMethod=null;countries=[];allRequiredFields={};currentRequiredFields=[];errorCardInvalid=false;cardMode="select";success;paymentError;paymentMethodSelected;validationSchema={phoneNumber:r().when([],{is:()=>a("phoneNumber",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.phoneRequired"),otherwise:e=>e.notRequired()}),"billing-country":r().when([],{is:()=>a("billing-country",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.countryRequired"),otherwise:e=>e.notRequired()}),"billing-state":r().when([],{is:()=>a("billing-state",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.stateRequired"),otherwise:e=>e.notRequired()}),"billing-address":r().when([],{is:()=>a("billing-address",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.addressRequired"),otherwise:e=>e.notRequired()}),"billing-city":r().when([],{is:()=>a("billing-city",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.cityRequired"),otherwise:e=>e.notRequired()}),"billing-zip":r().when([],{is:()=>a("billing-zip",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.zipRequired"),otherwise:e=>e.notRequired()}),bankId:r().when([],{is:()=>a("bankId",this.currentRequiredFields),then:e=>e.required("validation.bankRequired"),otherwise:e=>e.notRequired()}),documentType:r().when([],{is:()=>a("documentType",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.documentTypeRequired"),otherwise:e=>e.notRequired()}),documentNumber:r().when([],{is:()=>a("documentNumber",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.documentNumberRequired").min(7,"validation.documentInvalid"),otherwise:e=>e.notRequired()})};resizeHandler=()=>{this.breakpoint=w(window.innerWidth)};async componentWillLoad(){this.resizeHandler();window.addEventListener("resize",this.resizeHandler);const e=typeof this.renewalData==="string"?JSON.parse(this.renewalData):this.renewalData;y.initializeRenewal({...e,token:this.renewalToken});p.loadGoogleMapsScript();try{const e=await o.data.getCountries();this.countries=e.data}catch(e){console.error("Error loading countries:",e)}try{this.allRequiredFields=await D()}catch(e){console.error("Error loading required fields:",e)}if(b.data.paymentMethods.length>0){let e=null;if(b.data.subscription?.paymentMethod){const t=b.data.subscription.paymentMethod.toLowerCase();const i=t==="card"?h.CARD:t==="bank_transfer"?h.BANK_TRANSFER:null;if(i){const t=b.data.paymentMethods.some((e=>e.type===i));if(t){e=i}}}if(!e){e=b.data.paymentMethods[0].type}this.currentPaymentMethod=e;y.setSelectedPaymentMethod(e);if(e!==h.CARD){this.cardMode="input";y.setCardMode("input")}try{this.currentRequiredFields=q(e,this.allRequiredFields).fields}catch(e){console.error("Error getting required fields for method:",e)}await this.initializeFingerprint(e)}this.initialData=this.getInitialData();g("cardMode",(()=>{this.cardMode=b.cardMode}))}disconnectedCallback(){window.removeEventListener("resize",this.resizeHandler)}async handlePaymentMethodSelected(e){e.stopPropagation();if(this.currentPaymentMethod===e.detail){return}this.currentPaymentMethod=e.detail;y.setSelectedPaymentMethod(this.currentPaymentMethod);if(this.currentPaymentMethod!==h.CARD){this.cardMode="input";y.setCardMode("input")}try{this.currentRequiredFields=q(this.currentPaymentMethod,this.allRequiredFields).fields}catch(e){console.error("Error getting required fields for method:",e)}await this.initializeFingerprint(this.currentPaymentMethod);this.paymentMethodSelected.emit(e.detail)}async initializeFingerprint(e){if(e===h.CARD&&!b.deviceId){try{const e=crypto.randomUUID();const t=await o.fingerPrint.getFingerPrint(e);y.setDeviceId(e);const i=t.result.script;const r=document.createElement("script");r.innerHTML=i;document.body.appendChild(r)}catch(e){console.error("Failed to initialize fingerprint:",e)}}}handleBankSelected(e){e.stopPropagation();y.setSelectedBankId(e.detail)}handleCardSelected(e){const{card:t,cvv:i}=e.detail;y.setSelectedCard(t);y.setCvv(i||"")}get currentPaymentError(){if(this.currentPaymentMethod===h.CARD){return this.errorPaymentCard}else if(this.currentPaymentMethod===h.CASH||this.currentPaymentMethod===h.BANK_TRANSFER){return this.errorPaymentAPM}return false}async handleSubmit(e){if(this.isSubmitting){return}if(this.currentPaymentMethod===h.CARD){await this.handleCardRenewal(e)}else{await this.handleAPMRenewal(e)}}async handleCardRenewal(e){const t=e?.detail||this.getInitialData();if(!b.data.cardId&&!b.data.cardTokenId){this.errorCardInvalid=true;return}if(!b.data.cardInformation&&!b.data.cardId){this.errorCardInvalid=true;return}this.errorCardInvalid=false;this.isSubmitting=true;this.isCardSubmitting=true;y.setLoading(true);try{const e={transaction:{quantity:1},...b.data.cardId&&{cardId:b.data.cardId},...b.data.cardTokenId&&{cardTokenId:b.data.cardTokenId},customAttributes:{...b.deviceId&&{deviceId:b.deviceId}},...this.cardMode==="input"&&{customer:{firstName:t.fullName?.split(" ")[0]||b.data.subscription.customerName?.split(" ")[0],lastName:t.fullName?.split(" ").slice(1).join(" ")||b.data.subscription.customerName?.split(" ").slice(1).join(" "),email:t.email||b.data.subscription.customerEmail,phone:{countryCode:t.countryCodePhoneNumber||"",number:t.phoneNumber||""}},billingDetails:{address:{lineOne:t["billing-address"]||"",city:t["billing-city"]||"",state:t["billing-state"]||"",country:t["billing-country"]||"",zipCode:t["billing-zip"]||""},identification:{type:t.documentType||"",value:t.documentNumber||""}}}};const i=s();const r=await o.checkout.createCardCheckoutRequest(b.data.id,i,e,b.token);this.isSubmitting=false;this.isCardSubmitting=false;y.setLoading(false);y.setCheckoutResponse(r.data);if(r.data.result?.status.toUpperCase()===l.APPROVED){this.isCardSuccess=true}else{this.isCardSuccess=false;this.errorPaymentCard=true;this.errorMessage={message:r.data.error?.error?.message}}}catch(e){this.isSubmitting=false;this.isCardSubmitting=false;y.setLoading(false);this.errorPaymentCard=true;this.errorMessage={message:e.data?.error?.message}}}async handleAPMRenewal(e){this.isSubmitting=true;y.setLoading(true);try{const t=u.mapToAPMPaymentMethod(this.currentPaymentMethod,b.data.price.country);const i=e?.detail||this.getFormData();const r={address:{country:i["billing-country"],state:i["billing-state"]||"",city:i["billing-city"]||"",zipCode:i["billing-zip"]||"",lineOne:i["billing-address"]||""},identification:{type:i.documentType||"dni",value:i.documentNumber||""}};const n={transaction:{quantity:1},method:t,billingDetails:r,redirect:{approved:window.location.origin+"/renewal/success",rejected:window.location.origin+"/renewal/failure"},paymentMetadata:{orderId:b.data.id,source:"renewal-web"},customAttributes:{bank:i.bankId||""},...t!==f.CO_TRANSFERENCE_PSE&&{targetCurrency:b.data.price.currency}};n.customer={firstName:i.fullName?.split(" ")[0]||b.data.subscription.customerName.split(" ")[0]||"",lastName:i.fullName?.split(" ").slice(1).join(" ")||b.data.subscription.customerName.split(" ").slice(1).join(" ")||"",email:i.email||b.data.subscription.customerEmail,phone:{countryCode:i.countryCodePhoneNumber||"",number:i.phoneNumber||""}};const a=s();const c=await o.checkout.createAPMCheckoutRequest(b.data.id,a,n);this.isSubmitting=false;y.setLoading(false);y.setCheckoutResponse(c.data);this.checkoutResponse=c.data;if(c.data.result?.status.toUpperCase()===l.APPROVED){this.isCardSuccess=true}else{this.paymentError.emit(c.data);y.setCheckoutResponse(c.data);this.errorPaymentAPM=true;this.errorMessage={alertTitle:c.data?.error?.message,message:c.data.error?.message}}}catch(e){this.isSubmitting=false;y.setLoading(false);this.paymentError.emit(e);this.errorPaymentAPM=true;this.errorMessage={alertTitle:e.data?.error?.message,message:e.data?.error?.message}}}getFormData=()=>this.initialData;getInitialData=()=>({email:b.data.subscription.customerEmail,fullName:b.data.subscription.customerName,card:"","billing-country":"","billing-state":"","billing-address":"","billing-city":"","billing-zip":"",bankId:"",phoneNumber:"",countryCodePhoneNumber:"",documentType:"",documentNumber:""});hasPrefilledAddress=()=>{const e=["billing-country","billing-state","billing-address","billing-city","billing-zip"];return e.some((e=>{const t=this.initialData[e];return t&&t.trim()!==""}))};getPaymentDate=()=>{const e=b.form.checkoutResponse;if(!e)return"";if("date"in e){return e.date}return""};getReferenceNumber=()=>{const e=b.form.checkoutResponse;if(!e)return"";if("traceId"in e){return e.traceId}return""};render(){if(!b.isInitialized){return i("div",{class:"loading"},m.translate("renewal.loading"))}const e=e=>i("renewal-summary",{totalAmount:b.data.price.amount,subTotalAmount:b.data.subscription.subTotalAmount,currency:b.data.price.currency,subscriptionTitle:b.data.subscription.name[0]?.text||"Subscription",subscriptionAmount:b.data.subscription.amount,nextChargeDate:b.data.subscription.nextChargeDate,frequency:b.data.subscription.frequency,couponCode:b.data.price.couponCode,discountAmount:b.data.price.discountedAmount,discountPercentage:b.data.price.discountPercentage,...e});return i(i.Fragment,null,i("rebill-processing-payment",{style:{display:this.isCardSubmitting?"block":"none"}}),this.isCardSuccess?i("renewal-success-page",{typePaymentMethod:this.currentPaymentMethod,paymentDate:this.getPaymentDate(),referenceNumber:this.getReferenceNumber(),cardLastFour:b.data.subscription.cardLastFour,country:b.data.price.country,paymentMethodName:u.mapToAPMPaymentMethod(this.currentPaymentMethod,b.data?.price?.country),bank:b.form?.selectedBankId||""}):i("rebill-checkout-form",{style:{display:this.isCardSubmitting||this.isCardSuccess?"none":"block"},validationSchema:this.validationSchema,initialData:this.initialData,onSubmit:e=>this.handleSubmit(e),renderForm:({submit:t,formData:r,errors:o})=>i("div",{class:"rebill-checkout-renewal"},i("div",{class:"left-section"},i("div",{class:"left-section-container"},i("organization-logo",{organization:b.data.organization}),i("div",{class:"checkout-form-section"},i("user-information-static",{userInfo:{customerName:b.data.subscription.customerName,customerEmail:b.data.subscription.customerEmail}}),k(this.breakpoint,x.DESKTOP)&&e({displayedComponents:"header"}),k(this.breakpoint,x.DESKTOP)&&e({displayedComponents:"details"}),i("div",{style:{display:"flex",flexDirection:"column",gap:"32px"}},i("payment-method-selector",{enabledPaymentMethods:[...new Set(b.data.paymentMethods.map((e=>e.type)))],defaultSelected:this.currentPaymentMethod,errorComponent:{showErrorComponent:this.currentPaymentError,alertTitle:c.getErrorTitle(this.currentPaymentMethod,b.data.price.country,this.errorMessage?.alertTitle),message:c.getErrorMessage(this.errorMessage?.message,this.currentPaymentMethod,b.data.price.country)},cardError:{showCardInvalid:this.errorCardInvalid,type:null},country:b.data.price.country,documentTypeError:o?.documentType,documentNumberError:o?.documentNumber,showDocument:this.cardMode==="input"&&(a("documentType",this.currentRequiredFields)||a("documentNumber",this.currentRequiredFields))}),this.currentPaymentMethod!==h.CARD&&b.data.subscription?.paymentMethod===h.CARD&&i("rebill-alert",{type:"info",message:m.translate("renewal.paymentMethodAlert",{cardLastFour:b.data?.subscription?.cardLastFour||"****"}),icon:"calendar-edit",variant:"outlined",colorIcon:v.PRIMARY}),this.cardMode==="input"&&a("bankId",this.currentRequiredFields)&&i("div",{class:"animated-component fade-in"},i("rebill-bank-selector",{banks:d("bank",this.allRequiredFields[this.currentPaymentMethod]?.original)||[],defaultSelectedBankId:r.bankId||"",error:o?.bankId}))),this.cardMode==="input"&&(a("billing-country",this.currentRequiredFields)||a("billing-state",this.currentRequiredFields)||a("billing-address",this.currentRequiredFields)||a("billing-city",this.currentRequiredFields)||a("billing-zip",this.currentRequiredFields))&&i("div",{class:"animated-component slide-in"},i("rebill-address",{countryOptions:this.countries.map((e=>({label:e.country,value:e.isoCountryCode}))),billingView:this.hasPrefilledAddress()?"form":"search",errors:{"billing-country":o["billing-country"],"billing-state":o["billing-state"],"billing-address":o["billing-address"],"billing-city":o["billing-city"],"billing-zip":o["billing-zip"]}})),this.cardMode==="input"&&a("phoneNumber",this.currentRequiredFields)&&i("div",{class:"animated-component fade-in"},i("user-information-phone",{error:o?.phoneNumber})),this.checkoutResponse?.result&&(this.currentPaymentMethod===h.CASH||this.currentPaymentMethod===h.BANK_TRANSFER)&&i("apm-checkout",{paymentMethod:this.currentPaymentMethod,referenceId:this.currentPaymentMethod===h.CASH?this.checkoutResponse.result.data.referenceId:undefined,qrCodeData:this.currentPaymentMethod===h.BANK_TRANSFER?this.checkoutResponse.result.data.qrCode:undefined,providerName:b.data.organization?.name||"",expirationDate:(()=>{const e=new Date;e.setDate(e.getDate()+30);return e.toISOString()})(),country:b.data.price.country,redirectUrl:this.checkoutResponse.result.data.url}),k(this.breakpoint,x.DESKTOP)&&e({displayedComponents:"summary"}),i("div",{style:{display:"flex",flexDirection:"column",gap:"16px"}},i("payment-button",{paymentMethod:this.currentPaymentMethod,isLoading:this.isSubmitting,isRenewal:true,trialPeriodDays:b.data.subscription.trialPeriodDays,redirectUrl:!!this.checkoutResponse?.result?.data?.url,timeToRedirect:5e3,country:b.data.price.country,isDisabled:b.fetchingInstallments,onSubmit:()=>t()}),i("rebill-alert",{type:"secure",variant:"variant-secure",icon:"lock-outline",message:m.translate("otp.secureMessage")}))),i("rebill-footer",{style:{marginTop:k(this.breakpoint,x.DESKTOP)?"24px":"auto"}}))),!k(this.breakpoint,x.DESKTOP)&&i("div",{class:"right-section"},i("div",{class:"checkout-summary-section"},e({displayedComponents:["header","details","summary"]}))))}))}};j.style=M;export{j as rebill_renewal};
2
- //# sourceMappingURL=p-736d2bdc.entry.js.map
1
+ import{r as e,c as t,h as i}from"./p-D8cwEAmw.js";import{c as r}from"./p-MMCcKmy_.js";import{a as o}from"./p-D2_UL7f8.js";import{m as n,i as a,g as s,C as l,a as c,b as d}from"./p-DDA1jPBc.js";import{P as h,I as m}from"./p-DkbFAMha.js";import{P as u,G as p,a as f}from"./p-CrUPzbxi.js";import{r as b,R as y,o as g}from"./p-BOVs95c7.js";import{B as x,g as w,i as k}from"./p-Do_vNuMa.js";import{C as v}from"./p-DA598vBj.js";import"./p-E-ZsRS8r.js";import"./p-B5khCLtC.js";const C=async(e,t,i)=>{const r=await o.checkout.getRequiredFields({currency:e,method:t},i);return{fields:n(r.data),original:r.data}};const D=async()=>{const e=[...new Set(b.data.paymentMethods.map((e=>e.type)))];const t=e.map((async e=>{try{const t=u.mapToAPMPaymentMethod(e,b.data.price.country);const i=await C(b.data.price.currency,t,b.data.organization.id);return{paymentMethod:e,...i}}catch(t){console.error(`Error getting required fields for ${e}:`,t);return{paymentMethod:e,fields:[],original:[]}}}));const i=await Promise.all(t);const r={};i.forEach((e=>{r[e.paymentMethod]={fields:e.fields,original:e.original}}));return r};const q=(e,t)=>{const i=t[e];if(i){return i}else{return{fields:[],original:[]}}};const M=":root{--rebill-color-primary:#3b82f6;--rebill-color-primary-light:rgba(59, 130, 246, 0.1);--rebill-color-primary-hover:#2563eb;--rebill-color-primary-dark:#001131;--rebill-color-primary-dark-text:#000000;--rebill-color-primary-dark-hover:#001c4a;--rebill-color-primary-dark-light:rgba(0, 17, 49, 0.1);--rebill-color-error:#ef4444;--rebill-color-error-background:#fef2f2;--rebill-color-error-light:rgba(239, 68, 68, 0.1);--rebill-color-error-dark:#6f101b;--rebill-color-background:#ffffff;--rebill-color-background-left:#fafafa;--rebill-color-background-right:#f4f5f6;--rebill-color-background-secondary:#f7f8fa;--rebill-color-border:#ebedef;--rebill-color-timeline-connector:#c4c8cf;--rebill-color-neutrals-700:#58616e;--rebill-color-neutrals-500:#9ca3af;--rebill-color-border-primary:#e4e4e7;--rebill-color-text-primary:#3b4049;--rebill-color-text-secondary:#6b7280;--rebill-color-grey-700:#7d7d7d;--rebill-color-text-secondary-light:#a1a1aa;--rebill-color-text-on-primary:#ffffff;--rebill-color-disabled:#9ca3af;--rebill-color-shadow:rgba(0, 0, 0, 0.1);--rebill-color-green:#10b981;--rebill-color-green-text:#257c67;--rebill-color-green-light:rgba(183, 233, 221, 0.15);--rebill-color-green-light-2:rgba(183, 233, 221, 1);--rebill-color-info-background:#d5e4ff;--rebill-color-info-border:#0156f6;--rebill-color-info-text:#172b85;--rebill-color-background-secondary-light:#f7f8fa;--rebill-breakpoint-mobile:768px;--rebill-breakpoint-tablet:1024px;--rebill-breakpoint-desktop:1025px;--rebill-color-orange:#ff9400;--rebill-color-black:#1e2025;--rebill-color-grey-300:#3b4049;--rebill-color-grey-100:#aeaeae}.qr-container,.qr-image,.qr-image svg,.qr-image img,[class*='qr-'],[class*='success'],[class*='receipt']{transition:none !important;animation:none !important;will-change:auto !important}button:active,button:focus,button:hover{isolation:isolate}@media (max-width: 1024px){.rebill-checkout-renewal{flex-direction:column;gap:0;justify-content:flex-start;background:var(--rebill-color-background);padding:20px}.right-section .left-section{width:100%;height:100%;background:var(--rebill-color-background)}.checkout-form-section{display:flex;flex-direction:column;justify-content:flex-start;gap:24px;height:100%;margin-top:24px}.otp-container{display:flex;flex-direction:column;justify-content:flex-start;gap:24px}}@media (min-width: 1025px){.rebill-checkout-renewal{width:100vw;min-height:100vh;display:flex;flex-direction:row;justify-content:center;overflow-y:auto}.left-section{display:flex;width:60%;background:var(--rebill-color-background-left);justify-content:space-around}.right-section{display:flex;padding-top:72px;width:40%;background:var(--rebill-color-background-right);position:sticky;top:0;justify-content:center}.checkout-form-section{display:flex;flex-direction:column;justify-content:flex-start;margin-bottom:36px;margin-top:24px;gap:32px}.left-section-container{max-width:450px;min-width:450px;margin:2.5rem 2rem 1.5rem 2rem;display:flex;flex-direction:column}.checkout-summary-section{max-width:450px;min-width:350px;margin:0rem 2rem;background:var(--rebill-color-background-right);display:flex;flex-direction:column;justify-content:flex-start;width:100%}.checkout-form-section user-information,.checkout-form-section payment-method-selector,.checkout-form-section rebill-address,.checkout-summary-section rebill-summary{width:100%}.pac-container{border-radius:4px;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1);border:1px solid #e0e0e0;margin-top:4px;font-family:inherit}.pac-item{padding:10px 12px;cursor:pointer;border-top:none}.pac-item:first-child{border-top:none}.pac-item:hover{background-color:#f5f5f5}.pac-item-query{font-weight:500}.pac-icon{display:none}}.payment-button-container{display:flex;flex-direction:column;gap:16px;margin-bottom:16px}.animated-component{transition:all 0.3s ease-in-out;overflow:visible}.fade-in{animation:fadeIn 0.4s ease-in-out}.slide-in{animation:slideIn 0.5s ease-out}@keyframes fadeIn{from{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes slideIn{from{opacity:0;transform:translateX(-20px);max-height:0}to{opacity:1;transform:translateX(0);max-height:450px}}.animated-component.hide{animation:fadeOut 0.3s ease-in-out forwards}@keyframes fadeOut{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(20px)}}rebill-mode-sandbox{position:fixed;bottom:50px;left:50%;transform:translateX(-50%);z-index:1000}@media (max-width: 1024px){rebill-test-mode-chip{bottom:46px}}@media (min-width: 1025px){rebill-test-mode-chip{bottom:46px}}.mode-sandbox-mobile-container{display:flex;align-items:center;width:100%;padding:0;margin:0;box-sizing:border-box}@media (min-width: 1451px){.left-section-container{min-width:450px;margin:2.5rem 5rem 1.5rem 5rem}.checkout-summary-section{min-width:450px;margin:0rem 5rem}}";const N=class{constructor(i){e(this,i);this.success=t(this,"success");this.paymentError=t(this,"paymentError");this.paymentMethodSelected=t(this,"paymentMethodSelected")}renewalData;renewalToken;currentPaymentMethod=h.CARD;isSubmitting=false;isCardSubmitting=false;isCardSuccess=false;errorMessage=null;breakpoint=x.DESKTOP;errorPaymentCard=false;errorPaymentAPM=false;initialData={};checkoutResponse=null;currentApmPaymentMethod=null;countries=[];allRequiredFields={};currentRequiredFields=[];errorCardInvalid=false;cardMode="select";success;paymentError;paymentMethodSelected;validationSchema={phoneNumber:r().when([],{is:()=>a("phoneNumber",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.phoneRequired"),otherwise:e=>e.notRequired()}),"billing-country":r().when([],{is:()=>a("billing-country",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.countryRequired"),otherwise:e=>e.notRequired()}),"billing-state":r().when([],{is:()=>a("billing-state",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.stateRequired"),otherwise:e=>e.notRequired()}),"billing-address":r().when([],{is:()=>a("billing-address",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.addressRequired"),otherwise:e=>e.notRequired()}),"billing-city":r().when([],{is:()=>a("billing-city",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.cityRequired"),otherwise:e=>e.notRequired()}),"billing-zip":r().when([],{is:()=>a("billing-zip",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.zipRequired"),otherwise:e=>e.notRequired()}),bankId:r().when([],{is:()=>a("bankId",this.currentRequiredFields),then:e=>e.required("validation.bankRequired"),otherwise:e=>e.notRequired()}),documentType:r().when([],{is:()=>a("documentType",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.documentTypeRequired"),otherwise:e=>e.notRequired()}),documentNumber:r().when([],{is:()=>a("documentNumber",this.currentRequiredFields)&&this.cardMode==="input",then:e=>e.required("validation.documentNumberRequired").min(7,"validation.documentInvalid"),otherwise:e=>e.notRequired()})};resizeHandler=()=>{this.breakpoint=w(window.innerWidth)};async componentWillLoad(){this.resizeHandler();window.addEventListener("resize",this.resizeHandler);const e=typeof this.renewalData==="string"?JSON.parse(this.renewalData):this.renewalData;y.initializeRenewal({...e,token:this.renewalToken});p.loadGoogleMapsScript();try{const e=await o.data.getCountries();this.countries=e.data}catch(e){console.error("Error loading countries:",e)}try{this.allRequiredFields=await D()}catch(e){console.error("Error loading required fields:",e)}if(b.data.paymentMethods.length>0){let e=null;if(b.data.subscription?.paymentMethod){const t=b.data.subscription.paymentMethod.toLowerCase();const i=t==="card"?h.CARD:t==="bank_transfer"?h.BANK_TRANSFER:null;if(i){const t=b.data.paymentMethods.some((e=>e.type===i));if(t){e=i}}}if(!e){e=b.data.paymentMethods[0].type}this.currentPaymentMethod=e;y.setSelectedPaymentMethod(e);if(e!==h.CARD){this.cardMode="input";y.setCardMode("input")}try{this.currentRequiredFields=q(e,this.allRequiredFields).fields}catch(e){console.error("Error getting required fields for method:",e)}await this.initializeFingerprint(e)}this.initialData=this.getInitialData();g("cardMode",(()=>{this.cardMode=b.cardMode}))}disconnectedCallback(){window.removeEventListener("resize",this.resizeHandler)}async handlePaymentMethodSelected(e){e.stopPropagation();if(this.currentPaymentMethod===e.detail){return}this.currentPaymentMethod=e.detail;y.setSelectedPaymentMethod(this.currentPaymentMethod);if(this.currentPaymentMethod!==h.CARD){this.cardMode="input";y.setCardMode("input")}try{this.currentRequiredFields=q(this.currentPaymentMethod,this.allRequiredFields).fields}catch(e){console.error("Error getting required fields for method:",e)}await this.initializeFingerprint(this.currentPaymentMethod);this.paymentMethodSelected.emit(e.detail)}async initializeFingerprint(e){if(e===h.CARD&&!b.deviceId){try{const e=crypto.randomUUID();const t=await o.fingerPrint.getFingerPrint(e);y.setDeviceId(e);const i=t.result.script;const r=document.createElement("script");r.innerHTML=i;document.body.appendChild(r)}catch(e){console.error("Failed to initialize fingerprint:",e)}}}handleBankSelected(e){e.stopPropagation();y.setSelectedBankId(e.detail)}handleCardSelected(e){const{card:t,cvv:i}=e.detail;y.setSelectedCard(t);y.setCvv(i||"")}get currentPaymentError(){if(this.currentPaymentMethod===h.CARD){return this.errorPaymentCard}else if(this.currentPaymentMethod===h.CASH||this.currentPaymentMethod===h.BANK_TRANSFER){return this.errorPaymentAPM}return false}async handleSubmit(e){if(this.isSubmitting){return}if(this.currentPaymentMethod===h.CARD){await this.handleCardRenewal(e)}else{await this.handleAPMRenewal(e)}}async handleCardRenewal(e){const t=e?.detail||this.getInitialData();if(!b.data.cardId&&!b.data.cardTokenId){this.errorCardInvalid=true;return}if(!b.data.cardInformation&&!b.data.cardId){this.errorCardInvalid=true;return}this.errorCardInvalid=false;this.isSubmitting=true;this.isCardSubmitting=true;y.setLoading(true);try{const e={transaction:{quantity:1},...b.data.cardId&&{cardId:b.data.cardId},...b.data.cardTokenId&&{cardTokenId:b.data.cardTokenId},customAttributes:{...b.deviceId&&{deviceId:b.deviceId}},...this.cardMode==="input"&&{customer:{firstName:t.fullName?.split(" ")[0]||b.data.subscription.customerName?.split(" ")[0],lastName:t.fullName?.split(" ").slice(1).join(" ")||b.data.subscription.customerName?.split(" ").slice(1).join(" "),email:t.email||b.data.subscription.customerEmail,phone:{countryCode:t.countryCodePhoneNumber||"",number:t.phoneNumber||""}},billingDetails:{address:{lineOne:t["billing-address"]||"",city:t["billing-city"]||"",state:t["billing-state"]||"",country:t["billing-country"]||"",zipCode:t["billing-zip"]||""},identification:{type:t.documentType||"",value:t.documentNumber||""}}}};const i=s();const r=await o.checkout.createCardCheckoutRequest(b.data.id,i,e,b.token);this.isSubmitting=false;this.isCardSubmitting=false;y.setLoading(false);y.setCheckoutResponse(r.data);if(r.data.result?.status.toUpperCase()===l.APPROVED){this.isCardSuccess=true}else{this.isCardSuccess=false;this.errorPaymentCard=true;this.errorMessage={message:r.data.error?.error?.message}}}catch(e){this.isSubmitting=false;this.isCardSubmitting=false;y.setLoading(false);this.errorPaymentCard=true;this.errorMessage={message:e.data?.error?.message}}}async handleAPMRenewal(e){this.isSubmitting=true;y.setLoading(true);try{const t=u.mapToAPMPaymentMethod(this.currentPaymentMethod,b.data.price.country);const i=e?.detail||this.getFormData();const r={address:{country:i["billing-country"],state:i["billing-state"]||"",city:i["billing-city"]||"",zipCode:i["billing-zip"]||"",lineOne:i["billing-address"]||""},identification:{type:i.documentType||"dni",value:i.documentNumber||""}};const n={transaction:{quantity:1},method:t,billingDetails:r,redirect:{approved:window.location.origin+"/renewal/success",rejected:window.location.origin+"/renewal/failure"},paymentMetadata:{orderId:b.data.id,source:"renewal-web"},customAttributes:{bank:i.bankId||""},...t!==f.CO_TRANSFERENCE_PSE&&{targetCurrency:b.data.price.currency}};n.customer={firstName:i.fullName?.split(" ")[0]||b.data.subscription.customerName.split(" ")[0]||"",lastName:i.fullName?.split(" ").slice(1).join(" ")||b.data.subscription.customerName.split(" ").slice(1).join(" ")||"",email:i.email||b.data.subscription.customerEmail,phone:{countryCode:i.countryCodePhoneNumber||"",number:i.phoneNumber||""}};const a=s();const c=await o.checkout.createAPMCheckoutRequest(b.data.id,a,n);this.isSubmitting=false;y.setLoading(false);y.setCheckoutResponse(c.data);this.checkoutResponse=c.data;if(c.data.result?.status.toUpperCase()===l.APPROVED){this.isCardSuccess=true}else{this.paymentError.emit(c.data);y.setCheckoutResponse(c.data);this.errorPaymentAPM=true;this.errorMessage={alertTitle:c.data?.error?.message,message:c.data.error?.message}}}catch(e){this.isSubmitting=false;y.setLoading(false);this.paymentError.emit(e);this.errorPaymentAPM=true;this.errorMessage={alertTitle:e.data?.error?.message,message:e.data?.error?.message}}}getFormData=()=>this.initialData;getInitialData=()=>({email:b.data.subscription.customerEmail,fullName:b.data.subscription.customerName,card:"","billing-country":"","billing-state":"","billing-address":"","billing-city":"","billing-zip":"",bankId:"",phoneNumber:"",countryCodePhoneNumber:"",documentType:"",documentNumber:""});hasPrefilledAddress=()=>{const e=["billing-country","billing-state","billing-address","billing-city","billing-zip"];return e.some((e=>{const t=this.initialData[e];return t&&t.trim()!==""}))};getPaymentDate=()=>{const e=b.form.checkoutResponse;if(!e)return"";if("date"in e){return e.date}return""};getReferenceNumber=()=>{const e=b.form.checkoutResponse;if(!e)return"";if("traceId"in e){return e.traceId}return""};render(){if(!b.isInitialized){return i("div",{class:"loading"},m.translate("renewal.loading"))}const e=e=>i("renewal-summary",{totalAmount:b.data.price.amount,subTotalAmount:b.data.subscription.subTotalAmount,currency:b.data.price.currency,subscriptionTitle:b.data.subscription.name[0]?.text||"Subscription",subscriptionAmount:b.data.subscription.amount,nextChargeDate:b.data.subscription.nextChargeDate,frequency:b.data.subscription.frequency,couponCode:b.data.price.couponCode,discountAmount:b.data.price.discountedAmount,discountPercentage:b.data.price.discountPercentage,...e});return i(i.Fragment,null,i("rebill-processing-payment",{style:{display:this.isCardSubmitting?"block":"none"}}),this.isCardSuccess?i("renewal-success-page",{typePaymentMethod:this.currentPaymentMethod,paymentDate:this.getPaymentDate(),referenceNumber:this.getReferenceNumber(),cardLastFour:b.data.subscription.cardLastFour,country:b.data.price.country,paymentMethodName:u.mapToAPMPaymentMethod(this.currentPaymentMethod,b.data?.price?.country),bank:b.form?.selectedBankId||""}):i("rebill-checkout-form",{style:{display:this.isCardSubmitting||this.isCardSuccess?"none":"block"},validationSchema:this.validationSchema,initialData:this.initialData,onSubmit:e=>this.handleSubmit(e),renderForm:({submit:t,formData:r,errors:o})=>i("div",{class:"rebill-checkout-renewal"},i("div",{class:"left-section"},i("div",{class:"left-section-container"},i("organization-logo",{organization:b.data.organization}),i("div",{class:"checkout-form-section"},i("user-information-static",{userInfo:{customerName:b.data.subscription.customerName,customerEmail:b.data.subscription.customerEmail}}),k(this.breakpoint,x.DESKTOP)&&e({displayedComponents:"header"}),k(this.breakpoint,x.DESKTOP)&&e({displayedComponents:"details"}),i("div",{style:{display:"flex",flexDirection:"column",gap:"32px"}},i("payment-method-selector",{enabledPaymentMethods:[...new Set(b.data.paymentMethods.map((e=>e.type)))],defaultSelected:this.currentPaymentMethod,errorComponent:{showErrorComponent:this.currentPaymentError,alertTitle:c.getErrorTitle(this.currentPaymentMethod,b.data.price.country,this.errorMessage?.alertTitle),message:c.getErrorMessage(this.errorMessage?.message,this.currentPaymentMethod,b.data.price.country)},cardError:{showCardInvalid:this.errorCardInvalid,type:null},country:b.data.price.country,documentTypeError:o?.documentType,documentNumberError:o?.documentNumber,showDocument:this.cardMode==="input"&&(a("documentType",this.currentRequiredFields)||a("documentNumber",this.currentRequiredFields))}),this.currentPaymentMethod!==h.CARD&&b.data.subscription?.paymentMethod===h.CARD&&i("rebill-alert",{type:"info",message:m.translate("renewal.paymentMethodAlert",{cardLastFour:b.data?.subscription?.cardLastFour||"****"}),icon:"calendar-edit",variant:"outlined",colorIcon:v.PRIMARY}),this.cardMode==="input"&&a("bankId",this.currentRequiredFields)&&i("div",{class:"animated-component fade-in"},i("rebill-bank-selector",{banks:d("bank",this.allRequiredFields[this.currentPaymentMethod]?.original)||[],defaultSelectedBankId:r.bankId||"",error:o?.bankId}))),this.cardMode==="input"&&(a("billing-country",this.currentRequiredFields)||a("billing-state",this.currentRequiredFields)||a("billing-address",this.currentRequiredFields)||a("billing-city",this.currentRequiredFields)||a("billing-zip",this.currentRequiredFields))&&i("div",{class:"animated-component slide-in"},i("rebill-address",{countryOptions:this.countries.map((e=>({label:e.country,value:e.isoCountryCode}))),billingView:this.hasPrefilledAddress()?"form":"search",errors:{"billing-country":o["billing-country"],"billing-state":o["billing-state"],"billing-address":o["billing-address"],"billing-city":o["billing-city"],"billing-zip":o["billing-zip"]}})),this.cardMode==="input"&&a("phoneNumber",this.currentRequiredFields)&&i("div",{class:"animated-component fade-in"},i("user-information-phone",{error:o?.phoneNumber})),this.checkoutResponse?.result&&(this.currentPaymentMethod===h.CASH||this.currentPaymentMethod===h.BANK_TRANSFER)&&i("apm-checkout",{paymentMethod:this.currentPaymentMethod,referenceId:this.currentPaymentMethod===h.CASH?this.checkoutResponse.result.data.referenceId:undefined,qrCodeData:this.currentPaymentMethod===h.BANK_TRANSFER?this.checkoutResponse.result.data.qrCode:undefined,providerName:b.data.organization?.name||"",expirationDate:(()=>{const e=new Date;e.setDate(e.getDate()+30);return e.toISOString()})(),country:b.data.price.country,redirectUrl:this.checkoutResponse.result.data.url}),k(this.breakpoint,x.DESKTOP)&&e({displayedComponents:"summary"}),i("div",{style:{display:"flex",flexDirection:"column",gap:"16px"}},i("payment-button",{paymentMethod:this.currentPaymentMethod,isLoading:this.isSubmitting,isRenewal:true,trialPeriodDays:b.data.subscription.trialPeriodDays,redirectUrl:!!this.checkoutResponse?.result?.data?.url,timeToRedirect:5e3,country:b.data.price.country,isDisabled:b.fetchingInstallments,onSubmit:()=>t()}),i("rebill-alert",{type:"secure",variant:"variant-secure",icon:"lock-outline",message:m.translate("otp.secureMessage")}))),i("rebill-footer",{style:{marginTop:k(this.breakpoint,x.DESKTOP)?"24px":"auto"}}))),!k(this.breakpoint,x.DESKTOP)&&i("div",{class:"right-section"},i("div",{class:"checkout-summary-section"},e({displayedComponents:["header","details","summary"]}))))}))}};N.style=M;export{N as rebill_renewal};
2
+ //# sourceMappingURL=p-3d02e7e9.entry.js.map
@@ -1,2 +1,2 @@
1
- import{r as t,c as i,h as e}from"./p-D8cwEAmw.js";import{c as s}from"./p-MMCcKmy_.js";import{a as n}from"./p-CTo1s54i.js";import{m as a,g as o,P as r,C as l,i as c,a as h,b as d}from"./p-DDA1jPBc.js";import{s as u,S as m,I as p,a as f,i as y,P as b,o as g,b as w}from"./p-DkbFAMha.js";import{S as k}from"./p-vsLqF4hk.js";import{B as x,g as v,i as C}from"./p-Do_vNuMa.js";import{P as I,G as P}from"./p-CrUPzbxi.js";import"./p-E-ZsRS8r.js";import"./p-D339jHg4.js";const S={checkoutSummary:true,submitButton:true,billingAddress:true,customerInformation:true,discountCode:true,logo:true,footer:true,sandboxMode:true,processingPayment:true,successPage:true,errorMessage:true};var M;(function(t){t["BAMBOO"]="bamboo_payment";t["FISERV"]="fiserv";t["KUSHKI"]="kushki";t["PAYWAY"]="payway";t["DOCK"]="dock";t["KLAP"]="klap";t["MOVII"]="movii";t["STRIPE"]="stripe";t["DECIDIR"]="decidir"})(M||(M={}));const N=async(t,i,e)=>{const s=await n.checkout.getRequiredFields({currency:t,method:i},e);return{fields:a(s.data),original:s.data}};const j=async()=>{const t=u.data?.itemInformation?.paymentMethods;const i=t.map((async t=>{try{const i=I.mapToAPMPaymentMethod(t,u.data?.pricing?.country);const e=await N(u.data.pricing.currency,i,u.data.organization.id);return{paymentMethod:t,...e}}catch(i){console.error(`Error getting required fields for ${t}:`,i);return{paymentMethod:t,fields:[],original:[]}}}));const e=await Promise.all(i);const s={};e.forEach((t=>{s[t.paymentMethod]={fields:t.fields,original:t.original}}));return s};const D=(t,i)=>{const e=i[t];if(e){return e}else{return{fields:[],original:[]}}};const R=t=>typeof t==="string"?JSON.parse(t):t;const T=t=>R(t);const z=()=>"190.188.127.250";const A=async({publicKey:t,instantProduct:i,instantPlan:e})=>{const s=R(i?i:e);const a=await n.sessions.createSDKInstantSessionRequest(s,o(),z(),t);const r={...a.data,...a.data.plan&&{plan:{...a.data.plan,description:s.description||[]}},...a.data.product&&{product:{...a.data.product,description:s.description||[]}}};const l=r;return l};const q=async({publicKey:t,productId:i,planId:e})=>{const s=await n.sessions.createSDKItemSessionRequest({...i?{productId:i}:{},...e?{planId:e}:{},idempotencyKey:o(),deviceId:"123123123",clientIP:z(),publicKey:t});const a=s.data;return a};const E=async({publicKey:t,checkoutLandingSession:i,instantProduct:e,instantPlan:s,productId:n,planId:a})=>{if(i){const t=await T(i);return{session:t,type:m.CHECKOUT_LANDING}}if(e||s){const i=await A({publicKey:t,instantProduct:e,instantPlan:s});return{session:i,type:m.INSTANT}}if(n||a){const i=await q({publicKey:t,productId:n,planId:a});return{session:i,type:m.SDK_ITEM}}};const F="@media (max-width: 1024px){.rebill-checkout{width:100%;flex-direction:column;gap:0;justify-content:flex-start;background:var(--rebill-color-background);padding:20px}.right-section-checkout .left-section{width:100%;height:100%;background:var(--rebill-color-background)}.checkout-form-section{display:flex;flex-direction:column;justify-content:flex-start;gap:24px;height:100%}.otp-container{display:flex;flex-direction:column;justify-content:flex-start;gap:24px}.rebill-checkout.full-width-layout .left-section{width:100%}.rebill-checkout.full-width-layout .left-section-container{max-width:none;width:100%}}@media (min-width: 1025px){.rebill-checkout{width:100%;min-height:600px;display:flex;flex-direction:row;justify-content:center;overflow-y:auto}.left-section{display:flex;width:60%;background:var(--rebill-color-background-left);justify-content:space-around}.right-section-checkout{display:flex;padding-top:72px;width:40%;background:var(--rebill-color-background-right);position:sticky;top:0;justify-content:center}.checkout-form-section{display:flex;flex-direction:column;justify-content:flex-start;margin-bottom:36px;gap:32px}.left-section-container{max-width:450px;min-width:450px;margin:2.5rem 2rem 1.5rem 2rem;display:flex;flex-direction:column}.checkout-summary-section{max-width:450px;min-width:350px;margin:0rem 2rem;background:var(--rebill-color-background-right);display:flex;flex-direction:column;justify-content:flex-start;width:100%}.checkout-form-section user-information,.checkout-form-section payment-method-selector,.checkout-form-section rebill-address,.checkout-summary-section rebill-summary{width:100%}.rebill-checkout.full-width-layout .left-section{width:100%;justify-content:stretch}.rebill-checkout.full-width-layout .left-section-container{max-width:none;min-width:auto;width:100%;margin:2.5rem 2rem 1.5rem 2rem}.pac-container{border-radius:4px;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1);border:1px solid #e0e0e0;margin-top:4px;font-family:inherit}.pac-item{padding:10px 12px;cursor:pointer;border-top:none}.pac-item:first-child{border-top:none}.pac-item:hover{background-color:#f5f5f5}.pac-item-query{font-weight:500}.pac-icon{display:none}}.payment-button-container{display:flex;flex-direction:column;gap:16px;margin-bottom:16px}.animated-component{transition:all 0.3s ease-in-out;overflow:visible}.fade-in{animation:fadeIn 0.4s ease-in-out}.slide-in{animation:slideIn 0.5s ease-out}@keyframes fadeIn{from{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes slideIn{from{opacity:0;transform:translateX(-20px);max-height:0}to{opacity:1;transform:translateX(0);max-height:450px}}.animated-component.hide{animation:fadeOut 0.3s ease-in-out forwards}@keyframes fadeOut{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(20px)}}rebill-mode-sandbox{position:fixed;bottom:50px;left:50%;transform:translateX(-50%);z-index:1000}@media (max-width: 1024px){rebill-test-mode-chip{bottom:46px}}@media (min-width: 1025px){rebill-test-mode-chip{bottom:46px}}.mode-sandbox-mobile-container{display:flex;align-items:center;width:100%;padding:0;margin:0;box-sizing:border-box}@media (min-width: 1451px){.left-section-container{min-width:450px;margin:2.5rem 5rem 1.5rem 5rem}.checkout-summary-section{min-width:450px;margin:0rem 5rem}}";const O=class{constructor(e){t(this,e);this.error=i(this,"error");this.success=i(this,"success");this.successRedirect=i(this,"successRedirect");this.formChange=i(this,"formChange");this.paymentMethodSelected=i(this,"paymentMethodSelected")}productId;planId;publicKey;instantProduct;instantPlan;display;customerInformation;oneClickCheckout=true;css;language;async handleLanguageChange(t,i){if(t&&t!==i){try{await p.changeLanguage(t);f.changeLanguage(t);console.log(`[RebillCheckout] Language changed from ${i} to ${t}`)}catch(t){console.error("[RebillCheckout] Failed to change language:",t)}}}error;success;successRedirect;formChange;checkoutLandingSession;externalPayment;rejectedPaymentCard=false;rejectedPaymentAPM=false;countries=[];currentPaymentMethod;checkoutResponse=null;isSubmitting=false;isCardSubmitting=false;isCardSuccess=false;isAPMSubmitting=false;isAPMSuccess=false;storedCheckoutResults=new Map;alertErrorKeys=null;currentApmPaymentMethod=null;breakpoint=x.DESKTOP;showRefreshModal=false;cardError={showCardInvalid:false,type:null};initialData={};allRequiredFields={};currentRequiredFields=[];customerExists=false;showOtp=false;otpVerified=false;responseCheckoutCard=null;cardMode=null;formElement;emailDebounceTimeout=null;injectedStyleElement=null;get displayConfig(){if(!this.display){return S}if(typeof this.display==="string"){try{const t=JSON.parse(this.display);return{...S,...t}}catch(t){console.warn("Invalid display configuration string, using defaults:",t);return S}}return{...S,...this.display}}get parsedCustomerInformation(){if(!this.customerInformation){return null}if(typeof this.customerInformation==="string"){try{return JSON.parse(this.customerInformation)}catch(t){console.warn("Invalid customerInformation configuration string, ignoring:",t);return null}}return this.customerInformation}get filteredPaymentMethods(){const t=u.data?.itemInformation?.paymentMethods||[];const i=this.displayConfig.excludePaymentMethods;if(!i||i.length===0){return t}return t.filter((t=>!i.includes(t)))}getCombinedUserData(t={}){const i=u.data.userInformation;const e=this.parsedCustomerInformation;return{email:t?.email||e?.email||i.email,fullName:t?.fullName||e?.fullName||i.fullName,countryCodePhoneNumber:t?.countryCodePhoneNumber||e?.phoneNumber?.countryCode||e?.countryCode||i.countryCode,phoneNumber:t?.phoneNumber||e?.phoneNumber?.number||i.phoneNumber,documentType:t?.documentType||e?.documentType||i.documentType,documentNumber:t?.documentNumber||e?.documentNumber||i.documentNumber,"billing-country":t?.["billing-country"]||e?.address?.billingAddress?.country||i.address?.billingAddress?.country,"billing-state":t?.["billing-state"]||e?.address?.billingAddress?.state||i.address?.billingAddress?.state,"billing-address":t?.["billing-address"]||e?.address?.billingAddress?.address||i.address?.billingAddress?.address,"billing-city":t?.["billing-city"]||e?.address?.billingAddress?.city||i.address?.billingAddress?.city,"billing-zip":t?.["billing-zip"]||e?.address?.billingAddress?.zip||i.address?.billingAddress?.zip}}injectCustomCSS(){if(!this.css){return}this.cleanupInjectedCSS();const t=`rebill-checkout-css-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;if(this.css.startsWith("http://")||this.css.startsWith("https://")||this.css.startsWith("//")){const i=document.createElement("link");i.rel="stylesheet";i.href=this.css;i.id=t;i.setAttribute("data-rebill-injected","true");document.head.appendChild(i);this.injectedStyleElement=i}else{const i=document.createElement("style");i.id=t;i.setAttribute("data-rebill-injected","true");i.textContent=this.css;document.head.appendChild(i);this.injectedStyleElement=i}}cleanupInjectedCSS(){if(this.injectedStyleElement){try{this.injectedStyleElement.remove()}catch(t){console.warn("Error removing injected CSS:",t)}this.injectedStyleElement=null}}timeToRedirectAPM=5e3;resizeHandler=()=>{const t=v(window.innerWidth);if(t!==this.breakpoint){this.breakpoint=t}};disconnectedCallback(){window.removeEventListener("resize",this.resizeHandler);if(this.emailDebounceTimeout){clearTimeout(this.emailDebounceTimeout);this.emailDebounceTimeout=null}this.cleanupInjectedCSS()}async componentWillLoad(){try{this.resizeHandler();window.addEventListener("resize",this.resizeHandler);this.injectCustomCSS();if(this.language){await p.changeLanguage(this.language)}else{y()}const{session:t,type:i}=await E({publicKey:this.publicKey,checkoutLandingSession:this.checkoutLandingSession,instantProduct:this.instantProduct,instantPlan:this.instantPlan,productId:this.productId,planId:this.planId});f.initializeSession({session:t,type:i,payment:typeof this.externalPayment==="string"?JSON.parse(this.externalPayment):this.externalPayment});if(u.sessionRefreshed){this.showRefreshModal=true}P.loadGoogleMapsScript();const e=await n.data.getCountries();this.countries=e.data;if(this.parsedCustomerInformation){f.setUserInformation(this.parsedCustomerInformation)}this.initialData=this.getInitialData();this.allRequiredFields=await j();if(this.filteredPaymentMethods.length>0){if(u.data.paymentStatus===r.REJECTED||u.data.paymentStatus===r.APPROVED&&this.filteredPaymentMethods.includes(b.BANK_TRANSFER)){const t=this.filteredPaymentMethods.find((t=>t===b.BANK_TRANSFER));if(t){this.changePaymentMethod(t);f.setPaymentMethodSelected(t)}}else{this.changePaymentMethod(this.filteredPaymentMethods[0])}}if(this.oneClickCheckout){n.customers.exists({email:u.data?.prefilledData?.email},this.publicKey).then((t=>{this.customerExists=t.data.exists}))}this.cardMode=u.cardMode;g("cardMode",(()=>{this.cardMode=u.cardMode}))}catch(t){console.error("Error initializing checkout:",t)}}componentWillUpdate(){this.injectCustomCSS()}async changePaymentMethod(t){if(t!==this.currentPaymentMethod&&this.filteredPaymentMethods.includes(t)){if(this.checkoutResponse){this.checkoutResponse=null;f.clearCheckoutResponse()}this.currentPaymentMethod=t;f.setPaymentMethodSelected(t);if(t!==b.CARD){this.cardMode="input";f.setCardMode("input")}this.isSubmitting=false;this.currentApmPaymentMethod=I.mapToAPMPaymentMethod(t,u.data?.pricing?.country);if(t!==b.CASH&&t!==b.BANK_TRANSFER){this.checkoutResponse=null;f.clearCheckoutResponse()}else{this.checkoutResponse=null;f.clearCheckoutResponse()}this.paymentMethodSelected.emit(t);try{this.currentRequiredFields=D(t,this.allRequiredFields).fields;const i=await n.sessions.updateCurrentSessionPaymentMethod(u.data.sessionId,{paymentMethodName:I.mapToAPMPaymentMethod(t,u.data.pricing.country),paymentMethodType:t,currency:u.data.pricing.currency});f.setProviderKey(i.providerKey);if(i.providerKey===M.DECIDIR||u.data.providerKey===M.DECIDIR){const t=crypto.randomUUID();const i=await n.fingerPrint.getFingerPrint(t);u.deviceId=t;const e=i.result.script;const s=document.createElement("script");s.innerHTML=e;document.body.appendChild(s)}}catch(t){console.error("Failed to update payment method or get required fields:",t)}}}get currentPaymentError(){if(this.currentPaymentMethod===b.CARD){return this.rejectedPaymentCard}else if(this.currentPaymentMethod===b.CASH||this.currentPaymentMethod===b.BANK_TRANSFER){return this.rejectedPaymentAPM}return false}paymentMethodSelected;async handlePaymentMethodSelected(t){t.stopPropagation();const i=t.detail;this.changePaymentMethod(i);if(this.formElement){this.formElement.resetValidation()}}async handleSubmit(t){if(this.isSubmitting){return}this.rejectedPaymentCard=false;this.rejectedPaymentAPM=false;if(this.currentPaymentMethod===b.CARD){this.handleSubmitCard(t)}else if(this.currentPaymentMethod===b.CASH||this.currentPaymentMethod===b.BANK_TRANSFER){this.handleSubmitAPM(t)}}handleFormChange(t){const i=t.detail;let e=true;let s={};if(this.formElement?.errors){s=this.formElement.errors;e=Object.keys(s).length===0}this.formChange.emit({data:i,isValid:e,errors:Object.keys(s).length>0?s:undefined})}async handleSubmitCard(t){const i=t.detail;const e=this.getCombinedUserData(i);if(!u.data.cardTokenId&&!u.data.cardId){this.cardError={showCardInvalid:true,type:"card_error"};return}if(!u.data.cardInformation&&!u.data.cardId){this.cardError={showCardInvalid:true,type:"tokenization_error"};return}this.cardError={showCardInvalid:false,type:null};const s={transaction:{quantity:1,...u.data.discount.couponCode&&{couponCode:u.data.discount.couponCode}},installments:Number(i.installments||u.data.cardInformation?.installments?.selectedInstallment?.installment),...u.data.cardTokenId&&{cardTokenId:u.data.cardTokenId,...u.data?.itemInformation?.type!==w.PLAN&&{saveCard:u.saveCard}},...u.data.cardId&&{cardId:u.data.cardId},...(!this.otpVerified||this.cardMode==="input")&&{customer:{firstName:e.fullName?.split(" ")[0],lastName:e.fullName?.split(" ").slice(1).join(" "),email:e.email,phone:{countryCode:e.countryCodePhoneNumber,number:e.phoneNumber}}},billingDetails:{address:{lineOne:e["billing-address"],city:e["billing-city"],state:e["billing-state"],country:e["billing-country"],zipCode:e["billing-zip"]},identification:{type:e.documentType,value:e.documentNumber}},customAttributes:{...u.deviceId&&{deviceId:u.deviceId}},...u.metadata&&{paymentMetadata:u.metadata}};const a=o();this.isSubmitting=true;this.isCardSubmitting=true;try{const t=await n.checkout.createCardCheckoutRequest(u.data.sessionId,a,s,u.data.accessToken||undefined);f.setCheckoutResponse(t.data);this.responseCheckoutCard=t.data;if(t.data.result?.status.toUpperCase()===l.APPROVED){this.isCardSuccess=true;f.setPaymentStatus(r.APPROVED);this.success.emit({paymentMethod:this.currentPaymentMethod,data:t.data});u.data.cardInformation.lastFour=t.data.result?.cardLastFour}else{this.error.emit({paymentMethod:this.currentPaymentMethod,data:t.data});f.setCheckoutResponse(t.data);this.rejectedPaymentCard=true;this.alertErrorKeys={message:t.data.result?.statusDetail.toLowerCase()??t.data.error?.error?.message?.toLowerCase()}}}catch(t){this.error.emit({paymentMethod:this.currentPaymentMethod,data:t.data});f.setCheckoutResponse(t.data);this.responseCheckoutCard=t.data;this.rejectedPaymentCard=true;this.alertErrorKeys={message:t.data?.error?.type?.toLowerCase()??t.data?.result?.statusDetail?.toLowerCase()}}finally{this.isSubmitting=false;this.isCardSubmitting=false}}async handleSubmitAPM(t){if(this.currentPaymentMethod!==b.CASH&&this.currentPaymentMethod!==b.BANK_TRANSFER){return}this.isSubmitting=true;const i=t.detail;const e=this.getCombinedUserData(i);try{const t={address:{country:e["billing-country"]||"",state:e["billing-state"]||"",city:e["billing-city"]||"",zipCode:e["billing-zip"]||"",lineOne:e["billing-address"]||""},identification:{type:e.documentType,value:e.documentNumber}};const s=this.currentApmPaymentMethod||I.mapToAPMPaymentMethod(this.currentPaymentMethod,u.data?.pricing?.country);const a={transaction:{quantity:1,...u.data.discount.couponCode&&{couponCode:u.data.discount.couponCode}},method:s,billingDetails:t,redirect:{approved:window.location.origin+"/payment/success",rejected:window.location.origin+"/payment/failure"},paymentMetadata:u.metadata,customAttributes:{bank:i.bankId||u.data?.bankId?.code}};{a.customer={firstName:e.fullName?.split(" ")[0]||"",lastName:e.fullName?.split(" ").slice(1).join(" ")||"",email:e.email,phone:{countryCode:e.countryCodePhoneNumber||"",number:e.phoneNumber||""}}}const r=o();const l=await n.checkout.createAPMCheckoutRequest(u.data.sessionId,r,a);this.isSubmitting=false;this.checkoutResponse=l.data;this.storedCheckoutResults.set(this.currentPaymentMethod,l.data);if(l.data?.date){u.data.paymentDate=l.data.date;u.createdAt=l.data.date}if(l.data?.traceId){u.data.paymentReference=l.data.traceId}}catch(t){this.isSubmitting=false;this.checkoutResponse=t.data;this.alertErrorKeys={message:t.data?.error?.type?.toLowerCase()??t.data?.result?.statusDetail?.toLowerCase()};this.rejectedPaymentAPM=true}}async submit(){if(this.formElement&&typeof this.formElement.submit==="function"){this.formElement.submit()}else{await this.handleSubmit({detail:{}})}}handlePaymentStatusChange=t=>{if(t.isCompleted){if(t.status===k.APPROVED){f.setPaymentStatus(r.APPROVED);this.success.emit({paymentMethod:this.currentPaymentMethod,data:this.checkoutResponse})}else if(t.status===k.REJECTED){f.setPaymentStatus(r.REJECTED);this.alertErrorKeys={alertTitle:r.APM_ERROR_GENERIC,message:r.APM_MESSAGE_ERROR}}}};async handleInputChange(t){if(t?.detail?.id==="email"&&this.oneClickCheckout){if(this.emailDebounceTimeout){clearTimeout(this.emailDebounceTimeout)}if(!t.detail.value||t.detail.value.trim()===""){this.customerExists=false;f.clearCustomerIdAndToken();return}this.emailDebounceTimeout=setTimeout((async()=>{try{const t=await n.customers.exists({email:u.data.userInformation.email},this.publicKey);this.customerExists=t.data.exists}catch(t){this.customerExists=false}}),500)}}validationSchema={email:s().when([],{is:()=>!this.otpVerified,then:t=>t.email("validation.emailInvalid").matches(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,"validation.emailInvalid").required("validation.emailRequired"),otherwise:t=>t.notRequired()}),fullName:s().when([],{is:()=>!this.otpVerified,then:t=>t.required("validation.fullNameRequired").matches(/^[a-zA-ZÀ-ÿ\u00f1\u00d1\s]{2,}\s+[a-zA-ZÀ-ÿ\u00f1\u00d1\s]{2,}$/,"validation.fullNameInvalid"),otherwise:t=>t.notRequired()}),isValidPhoneNumber:s().when([],{is:()=>c("phoneNumber",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.equals(["true"],"validation.phoneRequired"),otherwise:t=>t.notRequired()}),"billing-country":s().when([],{is:()=>c("billing-country",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.countryRequired"),otherwise:t=>t.notRequired()}),"billing-state":s().when([],{is:()=>c("billing-state",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.stateRequired"),otherwise:t=>t.notRequired()}),"billing-address":s().when([],{is:()=>c("billing-address",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.addressRequired"),otherwise:t=>t.notRequired()}),"billing-city":s().when([],{is:()=>c("billing-city",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.cityRequired"),otherwise:t=>t.notRequired()}),"billing-zip":s().when([],{is:()=>c("billing-zip",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.zipRequired"),otherwise:t=>t.notRequired()}),bankId:s().when([],{is:()=>c("bankId",this.currentRequiredFields),then:t=>t.required("validation.bankRequired"),otherwise:t=>t.notRequired()}),installments:s().when([],{is:()=>this.currentPaymentMethod===b.CARD&&u.data.cardInformation.installments.isAvailableInstallments&&u.data.cardInformation?.installments?.installments.length>0&&u.data.itemInformation.type!==w.PLAN,then:t=>t.required("validation.installmentsRequired"),otherwise:t=>t.notRequired()}),documentType:s().when([],{is:()=>c("documentType",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.documentTypeRequired"),otherwise:t=>t.notRequired()}),documentNumber:s().when([],{is:()=>c("documentNumber",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.documentNumberRequired").min(7,"validation.documentInvalid"),otherwise:t=>t.notRequired()})};getInitialData=()=>({email:u.data.userInformation.email||"",fullName:u.data.userInformation.fullName||"",phoneNumber:u.data.userInformation.phoneNumber?.number||"",countryCodePhoneNumber:u.data.userInformation.countryCode||"",documentType:"",documentNumber:"","billing-country":u.data.userInformation.address?.billingAddress?.country||"","billing-state":u.data.userInformation?.address?.billingAddress?.state||"","billing-address":u.data.userInformation?.address?.billingAddress?.address||"","billing-city":u.data.userInformation?.address?.billingAddress?.city||"","billing-zip":u.data.userInformation?.address?.billingAddress?.zip||"",bankId:u.data.bankId?.code||"",card:"",installments:u.data.cardInformation?.installments?.selectedInstallment?.installment?.toString()||""});hasPrefilledAddress=()=>{const t=["billing-country","billing-state","billing-address","billing-city","billing-zip"];return t.some((t=>{const i=this.initialData[t];return i&&i.trim()!==""}))};get isQrCodeVisible(){return!!this.checkoutResponse?.result?.data?.qrCode}get isBankTransferVisible(){return!!this.checkoutResponse?.result?.data?.account&&!!this.checkoutResponse?.result?.data?.bankName&&!!this.checkoutResponse?.result?.data?.reference}isPaymentApproved=()=>{if(u.data.paymentStatus===r.APPROVED){return true}return false};handleRebillAccountClick(t){this.showOtp=t.detail}handleReturnForm(t){this.showOtp=t.detail;f.clearCustomerIdAndToken()}handleSignOut(){this.showOtp=false;this.otpVerified=false;if(!u?.data?.prefilledData?.email){this.customerExists=false}f.clearCustomerIdAndToken();f.clearUserInformation();this.cardError={showCardInvalid:false,type:null};this.alertErrorKeys=null;this.rejectedPaymentCard=false;this.rejectedPaymentAPM=false}handleCodeVerified(){this.otpVerified=true;this.showOtp=false;this.rejectedPaymentCard=false;this.alertErrorKeys=null;this.cardError={showCardInvalid:false,type:null};if(this.formElement){this.formElement.resetValidation()}}isPaymentRejected(){return u.data.paymentStatus===r.REJECTED&&this.currentPaymentMethod===b.BANK_TRANSFER}render(){const t=this.countries.map((t=>({label:t.country,value:t.isoCountryCode})));const i=(t={})=>e("rebill-summary",{key:"698d9a1b5eeee59f9e4b9762bedcedd4818a059e",totalAmount:u.data.pricing.total,currency:u.data.pricing.currency,itemTitle:u._session?.getTitle(),itemDescription:u._session?.getDescription(),itemAmount:u.data.pricing.subtotal,subtotal:u.data.pricing.subtotal,allowCoupon:u._session?.getAllowCoupon(this.displayConfig),currentBreakpoint:this.breakpoint,planFrequency:u._session?.getPlanFrequency(),planFrequencyCount:u._session?.getPlanFrequencyCount(),discountType:u.data.discount.discountType,discountedPercentage:u.data.discount.discountedPercentage,discountDuration:u.data.discount.discountDuration,discountAmount:u.data.discount.discountAmount,...t});return u.isInitialized&&e(e.Fragment,null,this.showRefreshModal&&e("rebill-modal-overlay",{key:"6a0d7aab67c17d0fc60bb30103e04ddc6903c2cc"}),this.displayConfig.processingPayment&&e("rebill-processing-payment",{key:"4dbf0982819ef2b65752a53654fc5a0c3c858875",style:{display:this.isCardSubmitting?"block":"none"}}),this.displayConfig.successPage&&this.isPaymentApproved()&&u.isInitialized?e("success-page",{typePaymentMethod:u.data.paymentMethodSelected,paymentMethodName:I.mapToAPMPaymentMethod(u.data.paymentMethodSelected||u.data.payment?.paymentMethodType,u.data?.pricing?.country),country:u.data?.pricing?.country,bank:u.data.payment?.paymentMethodMetadata?.bank||u.data.payment?.paymentMethodMetadata?.bank,cardLastFour:this.responseCheckoutCard?.result?.cardLastFour||u.data.cardInformation?.lastFour,paymentDate:u.data.paymentDate||this.responseCheckoutCard?.date||u.data.payment?.createdAt||this.checkoutResponse?.result?.data?.createdAt,referenceNumber:u.data.paymentReference||u.data.payment?.traceId||this.responseCheckoutCard?.traceId,onSuccessRedirect:t=>{this.successRedirect.emit(t.detail)},trialPeriodDays:u.data?.itemInformation?.trial?.trialPeriodDays,debitDay:u.data?.itemInformation?.debitDay,planAmount:u.data?.pricing?.planAmount}):e(e.Fragment,null,this.displayConfig.sandboxMode&&u.isSandbox&&u.data.sessionType===m.CHECKOUT_LANDING&&C(this.breakpoint,x.DESKTOP)&&e("div",{class:"mode-sandbox-mobile-container",style:{display:this.isCardSubmitting||this.isCardSuccess?"none":"block"}},e("rebill-mode-sandbox-mobile",null)),e("rebill-checkout-form",{ref:t=>this.formElement=t,style:{display:this.isCardSubmitting||this.isCardSuccess?"none":"block"},validationSchema:this.validationSchema,initialData:this.initialData,onSubmit:t=>this.handleSubmit(t),onChange:t=>this.handleFormChange(t),renderForm:({submit:s,formData:n,errors:a})=>{const o=!this.isCardSuccess&&this.checkoutResponse?.result&&(this.currentPaymentMethod===b.CASH||this.currentPaymentMethod===b.BANK_TRANSFER);return e("div",{class:`rebill-checkout ${!this.displayConfig.checkoutSummary?"full-width-layout":""}`},e("div",{class:"left-section"},e("div",{class:"left-section-container"},this.displayConfig.logo&&e("organization-logo",{organization:u.data.organization}),e("div",{class:"otp-container",style:{display:this.showOtp?"block":"none"}},e("otp-component",null)),e("div",{style:{display:this.showOtp?"none":"block"}},e("div",{class:"checkout-form-section"},this.displayConfig.checkoutSummary&&e("div",{class:"summary-mobile-tablet",style:{display:C(this.breakpoint,x.DESKTOP)?"block":"none"}},i({displayedComponents:["totalAmount","discount","timelineFreeTrial","timelineDebitDay","itemDetails"]})),!this.otpVerified&&this.displayConfig.customerInformation&&e("user-information",{customerExists:this.customerExists,disabled:this.isSubmitting,errors:{email:a.email,fullName:a.fullName}}),this.otpVerified&&this.displayConfig.customerInformation&&e("user-information-static",{variant:"otp",userInfo:{customerName:u.data.userInformation.fullName?.split(" ")[0],customerEmail:u.data.userInformation.email}}),e("div",{style:{display:"flex",flexDirection:"column",gap:"16px"}},e("payment-method-selector",{enabledPaymentMethods:this.filteredPaymentMethods,defaultSelected:this.currentPaymentMethod,disabled:this.isSubmitting,errorComponent:{showErrorComponent:this.displayConfig.errorMessage&&(this.currentPaymentError||this.isPaymentRejected()),alertTitle:h.getErrorTitle(this.currentPaymentMethod,u.data?.pricing?.country||"",this.alertErrorKeys?.alertTitle),message:h.getErrorMessage(this.alertErrorKeys?.message,this.currentPaymentMethod,u.data?.pricing?.country)},country:u.data?.pricing?.country,installmentsError:a.installments,showDocument:(!this.otpVerified||this.otpVerified&&this.cardMode==="input")&&!o&&!this.isQrCodeVisible&&(c("documentNumber",this.currentRequiredFields)||c("documentType",this.currentRequiredFields)),documentTypeError:a.documentType,documentNumberError:a.documentNumber,cardError:this.cardError,customCSS:this.css}),!o&&(()=>{const t=c("bankId",this.currentRequiredFields);return t})()&&e("div",{class:"animated-component fade-in"},e("rebill-bank-selector",{banks:d("bank",this.allRequiredFields[this.currentPaymentMethod].original)||[],defaultSelectedBankId:n.bankId||"",error:a?.bankId,disabled:this.isSubmitting}))),!o&&(!this.otpVerified||this.cardMode==="input")&&e(e.Fragment,null,this.displayConfig.billingAddress&&(c("billing-country",this.currentRequiredFields)||c("billing-state",this.currentRequiredFields)||c("billing-address",this.currentRequiredFields)||c("billing-city",this.currentRequiredFields)||c("billing-zip",this.currentRequiredFields))&&e("div",{class:"animated-component slide-in"},e("rebill-address",{disabled:this.isSubmitting,countryOptions:t,billingView:this.hasPrefilledAddress()?"form":"search",errors:{"billing-country":a["billing-country"],"billing-state":a["billing-state"],"billing-address":a["billing-address"],"billing-city":a["billing-city"],"billing-zip":a["billing-zip"]}})),this.displayConfig.customerInformation&&c("phoneNumber",this.currentRequiredFields)&&e("div",{class:"animated-component fade-in"},e("user-information-phone",{disabled:this.isSubmitting,error:a?.phoneNumber,countryCode:u.data.userInformation?.countryCode||u.data.country}))),o&&e("apm-checkout",{paymentMethod:this.currentPaymentMethod,referenceId:this.currentPaymentMethod===b.CASH?this.checkoutResponse?.result?.data?.referenceId:undefined,qrCodeData:this.currentPaymentMethod===b.BANK_TRANSFER?this.checkoutResponse?.result?.data?.qrCode:undefined,code:this.currentPaymentMethod===b.BANK_TRANSFER?this.checkoutResponse?.result?.data?.code:undefined,checkoutRequestId:this.checkoutResponse?.result?.checkoutRequestId,providerName:u.data.providerKey,expirationDate:(()=>{const t=new Date;t.setDate(t.getDate()+30);return t.toISOString()})(),onPaymentStatusChange:t=>this.handlePaymentStatusChange(t.detail),country:u.data?.pricing?.country,redirectUrl:this.checkoutResponse?.result?.data?.url,timeToRedirect:this.timeToRedirectAPM,bearerToken:this.checkoutResponse?.result?.data?.bearerToken,bankTransferData:this.checkoutResponse?.result?.data?.account&&this.checkoutResponse?.result?.data?.bankName&&this.checkoutResponse?.result?.data?.reference?{account:this.checkoutResponse.result.data.account,bankName:this.checkoutResponse.result.data.bankName,reference:this.checkoutResponse.result.data.reference}:undefined}),this.displayConfig.checkoutSummary&&e("div",{class:"summary-price-details",style:{display:C(this.breakpoint,x.DESKTOP)?"block":"none"}},i({displayedComponents:["priceDetails"]})),this.displayConfig.submitButton&&!(o&&(this.isQrCodeVisible||this.isBankTransferVisible))&&e("div",{class:"payment-button-container"},e("payment-button",{paymentMethod:this.currentPaymentMethod,isLoading:this.isSubmitting,trialPeriodDays:u.data?.itemInformation?.trial?.trialPeriodDays,onSubmit:()=>{s()},redirectUrl:!!this.checkoutResponse?.result?.data?.url,timeToRedirect:this.timeToRedirectAPM,isDisabled:u.data.fetchingInstallments,country:u.data?.pricing?.country}),e("rebill-alert",{type:"secure",variant:"variant-secure",icon:"lock-outline",message:p.translate("otp.secureMessage")}))),this.displayConfig.sandboxMode&&u.isSandbox&&u.data.sessionType===m.CHECKOUT_LANDING&&!C(this.breakpoint,x.DESKTOP)&&e("rebill-mode-sandbox",null)),this.displayConfig.footer&&e("rebill-footer",{style:{marginTop:C(this.breakpoint,x.DESKTOP)?"24px":"auto"}}))),this.displayConfig.checkoutSummary&&e("div",{class:"right-section-checkout"},e("div",{class:"checkout-summary-section"},e("div",{class:"summary-desktop",style:{display:!C(this.breakpoint,x.DESKTOP)?"block":"none"}},i()))))}})))}static get watchers(){return{language:["handleLanguageChange"]}}};O.style=F;export{O as rebill_checkout};
2
- //# sourceMappingURL=p-9b146258.entry.js.map
1
+ import{r as t,c as i,h as e}from"./p-D8cwEAmw.js";import{c as s}from"./p-MMCcKmy_.js";import{a as n}from"./p-D2_UL7f8.js";import{m as a,g as o,P as r,C as l,i as c,a as h,b as d}from"./p-DDA1jPBc.js";import{s as u,S as m,I as p,a as f,i as y,P as b,o as g,b as w}from"./p-DkbFAMha.js";import{S as k}from"./p-vsLqF4hk.js";import{B as x,g as v,i as C}from"./p-Do_vNuMa.js";import{P as I,G as P}from"./p-CrUPzbxi.js";import"./p-E-ZsRS8r.js";import"./p-B5khCLtC.js";const S={checkoutSummary:true,submitButton:true,billingAddress:true,customerInformation:true,discountCode:true,logo:true,footer:true,sandboxMode:true,processingPayment:true,successPage:true,errorMessage:true};var M;(function(t){t["BAMBOO"]="bamboo_payment";t["FISERV"]="fiserv";t["KUSHKI"]="kushki";t["PAYWAY"]="payway";t["DOCK"]="dock";t["KLAP"]="klap";t["MOVII"]="movii";t["STRIPE"]="stripe";t["DECIDIR"]="decidir"})(M||(M={}));const N=async(t,i,e)=>{const s=await n.checkout.getRequiredFields({currency:t,method:i},e);return{fields:a(s.data),original:s.data}};const j=async()=>{const t=u.data?.itemInformation?.paymentMethods;const i=t.map((async t=>{try{const i=I.mapToAPMPaymentMethod(t,u.data?.pricing?.country);const e=await N(u.data.pricing.currency,i,u.data.organization.id);return{paymentMethod:t,...e}}catch(i){console.error(`Error getting required fields for ${t}:`,i);return{paymentMethod:t,fields:[],original:[]}}}));const e=await Promise.all(i);const s={};e.forEach((t=>{s[t.paymentMethod]={fields:t.fields,original:t.original}}));return s};const D=(t,i)=>{const e=i[t];if(e){return e}else{return{fields:[],original:[]}}};const R=t=>typeof t==="string"?JSON.parse(t):t;const z=t=>R(t);const A=()=>"190.188.127.250";const T=async({publicKey:t,instantProduct:i,instantPlan:e})=>{const s=R(i?i:e);const a=await n.sessions.createSDKInstantSessionRequest(s,o(),A(),t);const r={...a.data,...a.data.plan&&{plan:{...a.data.plan,description:s.description||[]}},...a.data.product&&{product:{...a.data.product,description:s.description||[]}}};const l=r;return l};const q=async({publicKey:t,productId:i,planId:e})=>{const s=await n.sessions.createSDKItemSessionRequest({...i?{productId:i}:{},...e?{planId:e}:{},idempotencyKey:o(),deviceId:"123123123",clientIP:A(),publicKey:t});const a=s.data;return a};const E=async({publicKey:t,checkoutLandingSession:i,instantProduct:e,instantPlan:s,productId:n,planId:a})=>{if(i){const t=await z(i);return{session:t,type:m.CHECKOUT_LANDING}}if(e||s){const i=await T({publicKey:t,instantProduct:e,instantPlan:s});return{session:i,type:m.INSTANT}}if(n||a){const i=await q({publicKey:t,productId:n,planId:a});return{session:i,type:m.SDK_ITEM}}};const F="@media (max-width: 1024px){.rebill-checkout{width:100%;flex-direction:column;gap:0;justify-content:flex-start;background:var(--rebill-color-background);padding:20px}.right-section-checkout .left-section{width:100%;height:100%;background:var(--rebill-color-background)}.checkout-form-section{display:flex;flex-direction:column;justify-content:flex-start;gap:24px;height:100%}.otp-container{display:flex;flex-direction:column;justify-content:flex-start;gap:24px}.rebill-checkout.full-width-layout .left-section{width:100%}.rebill-checkout.full-width-layout .left-section-container{max-width:none;width:100%}}@media (min-width: 1025px){.rebill-checkout{width:100%;min-height:600px;display:flex;flex-direction:row;justify-content:center;overflow-y:auto}.left-section{display:flex;width:60%;background:var(--rebill-color-background-left);justify-content:space-around}.right-section-checkout{display:flex;padding-top:72px;width:40%;background:var(--rebill-color-background-right);position:sticky;top:0;justify-content:center}.checkout-form-section{display:flex;flex-direction:column;justify-content:flex-start;margin-bottom:36px;gap:32px}.left-section-container{max-width:450px;min-width:450px;margin:2.5rem 2rem 1.5rem 2rem;display:flex;flex-direction:column}.checkout-summary-section{max-width:450px;min-width:350px;margin:0rem 2rem;background:var(--rebill-color-background-right);display:flex;flex-direction:column;justify-content:flex-start;width:100%}.checkout-form-section user-information,.checkout-form-section payment-method-selector,.checkout-form-section rebill-address,.checkout-summary-section rebill-summary{width:100%}.rebill-checkout.full-width-layout .left-section{width:100%;justify-content:stretch}.rebill-checkout.full-width-layout .left-section-container{max-width:none;min-width:auto;width:100%;margin:2.5rem 2rem 1.5rem 2rem}.pac-container{border-radius:4px;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1);border:1px solid #e0e0e0;margin-top:4px;font-family:inherit}.pac-item{padding:10px 12px;cursor:pointer;border-top:none}.pac-item:first-child{border-top:none}.pac-item:hover{background-color:#f5f5f5}.pac-item-query{font-weight:500}.pac-icon{display:none}}.payment-button-container{display:flex;flex-direction:column;gap:16px;margin-bottom:16px}.animated-component{transition:all 0.3s ease-in-out;overflow:visible}.fade-in{animation:fadeIn 0.4s ease-in-out}.slide-in{animation:slideIn 0.5s ease-out}@keyframes fadeIn{from{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes slideIn{from{opacity:0;transform:translateX(-20px);max-height:0}to{opacity:1;transform:translateX(0);max-height:450px}}.animated-component.hide{animation:fadeOut 0.3s ease-in-out forwards}@keyframes fadeOut{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(20px)}}rebill-mode-sandbox{position:fixed;bottom:50px;left:50%;transform:translateX(-50%);z-index:1000}@media (max-width: 1024px){rebill-test-mode-chip{bottom:46px}}@media (min-width: 1025px){rebill-test-mode-chip{bottom:46px}}.mode-sandbox-mobile-container{display:flex;align-items:center;width:100%;padding:0;margin:0;box-sizing:border-box}@media (min-width: 1451px){.left-section-container{min-width:450px;margin:2.5rem 5rem 1.5rem 5rem}.checkout-summary-section{min-width:450px;margin:0rem 5rem}}";const O=class{constructor(e){t(this,e);this.error=i(this,"error");this.success=i(this,"success");this.successRedirect=i(this,"successRedirect");this.formChange=i(this,"formChange");this.paymentMethodSelected=i(this,"paymentMethodSelected")}productId;planId;publicKey;instantProduct;instantPlan;display;customerInformation;oneClickCheckout=true;css;language;async handleLanguageChange(t,i){if(t&&t!==i){try{await p.changeLanguage(t);f.changeLanguage(t);console.log(`[RebillCheckout] Language changed from ${i} to ${t}`)}catch(t){console.error("[RebillCheckout] Failed to change language:",t)}}}error;success;successRedirect;formChange;checkoutLandingSession;externalPayment;rejectedPaymentCard=false;rejectedPaymentAPM=false;countries=[];currentPaymentMethod;checkoutResponse=null;isSubmitting=false;isCardSubmitting=false;isCardSuccess=false;isAPMSubmitting=false;isAPMSuccess=false;storedCheckoutResults=new Map;alertErrorKeys=null;currentApmPaymentMethod=null;breakpoint=x.DESKTOP;showRefreshModal=false;cardError={showCardInvalid:false,type:null};initialData={};allRequiredFields={};currentRequiredFields=[];customerExists=false;showOtp=false;otpVerified=false;responseCheckoutCard=null;cardMode=null;formElement;emailDebounceTimeout=null;injectedStyleElement=null;get displayConfig(){if(!this.display){return S}if(typeof this.display==="string"){try{const t=JSON.parse(this.display);return{...S,...t}}catch(t){console.warn("Invalid display configuration string, using defaults:",t);return S}}return{...S,...this.display}}get parsedCustomerInformation(){if(!this.customerInformation){return null}if(typeof this.customerInformation==="string"){try{return JSON.parse(this.customerInformation)}catch(t){console.warn("Invalid customerInformation configuration string, ignoring:",t);return null}}return this.customerInformation}get filteredPaymentMethods(){const t=u.data?.itemInformation?.paymentMethods||[];const i=this.displayConfig.excludePaymentMethods;if(!i||i.length===0){return t}return t.filter((t=>!i.includes(t)))}getCombinedUserData(t={}){const i=u.data.userInformation;const e=this.parsedCustomerInformation;return{email:t?.email||e?.email||i.email,fullName:t?.fullName||e?.fullName||i.fullName,countryCodePhoneNumber:t?.countryCodePhoneNumber||e?.phoneNumber?.countryCode||e?.countryCode||i.countryCode,phoneNumber:t?.phoneNumber||e?.phoneNumber?.number||i.phoneNumber,documentType:t?.documentType||e?.documentType||i.documentType,documentNumber:t?.documentNumber||e?.documentNumber||i.documentNumber,"billing-country":t?.["billing-country"]||e?.address?.billingAddress?.country||i.address?.billingAddress?.country,"billing-state":t?.["billing-state"]||e?.address?.billingAddress?.state||i.address?.billingAddress?.state,"billing-address":t?.["billing-address"]||e?.address?.billingAddress?.address||i.address?.billingAddress?.address,"billing-city":t?.["billing-city"]||e?.address?.billingAddress?.city||i.address?.billingAddress?.city,"billing-zip":t?.["billing-zip"]||e?.address?.billingAddress?.zip||i.address?.billingAddress?.zip}}injectCustomCSS(){if(!this.css){return}this.cleanupInjectedCSS();const t=`rebill-checkout-css-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;if(this.css.startsWith("http://")||this.css.startsWith("https://")||this.css.startsWith("//")){const i=document.createElement("link");i.rel="stylesheet";i.href=this.css;i.id=t;i.setAttribute("data-rebill-injected","true");document.head.appendChild(i);this.injectedStyleElement=i}else{const i=document.createElement("style");i.id=t;i.setAttribute("data-rebill-injected","true");i.textContent=this.css;document.head.appendChild(i);this.injectedStyleElement=i}}cleanupInjectedCSS(){if(this.injectedStyleElement){try{this.injectedStyleElement.remove()}catch(t){console.warn("Error removing injected CSS:",t)}this.injectedStyleElement=null}}timeToRedirectAPM=5e3;resizeHandler=()=>{const t=v(window.innerWidth);if(t!==this.breakpoint){this.breakpoint=t}};disconnectedCallback(){window.removeEventListener("resize",this.resizeHandler);if(this.emailDebounceTimeout){clearTimeout(this.emailDebounceTimeout);this.emailDebounceTimeout=null}this.cleanupInjectedCSS()}async componentWillLoad(){try{this.resizeHandler();window.addEventListener("resize",this.resizeHandler);this.injectCustomCSS();if(this.language){await p.changeLanguage(this.language)}else{y()}const{session:t,type:i}=await E({publicKey:this.publicKey,checkoutLandingSession:this.checkoutLandingSession,instantProduct:this.instantProduct,instantPlan:this.instantPlan,productId:this.productId,planId:this.planId});f.initializeSession({session:t,type:i,payment:typeof this.externalPayment==="string"?JSON.parse(this.externalPayment):this.externalPayment});if(u.sessionRefreshed){this.showRefreshModal=true}P.loadGoogleMapsScript();const e=await n.data.getCountries();this.countries=e.data;if(this.parsedCustomerInformation){f.setUserInformation(this.parsedCustomerInformation)}this.initialData=this.getInitialData();this.allRequiredFields=await j();if(this.filteredPaymentMethods.length>0){if(u.data.paymentStatus===r.REJECTED||u.data.paymentStatus===r.APPROVED&&this.filteredPaymentMethods.includes(b.BANK_TRANSFER)){const t=this.filteredPaymentMethods.find((t=>t===b.BANK_TRANSFER));if(t){this.changePaymentMethod(t);f.setPaymentMethodSelected(t)}}else{this.changePaymentMethod(this.filteredPaymentMethods[0])}}if(this.oneClickCheckout){n.customers.exists({email:u.data?.prefilledData?.email},this.publicKey).then((t=>{this.customerExists=t.data.exists}))}this.cardMode=u.cardMode;g("cardMode",(()=>{this.cardMode=u.cardMode}))}catch(t){console.error("Error initializing checkout:",t)}}componentWillUpdate(){this.injectCustomCSS()}async changePaymentMethod(t){if(t!==this.currentPaymentMethod&&this.filteredPaymentMethods.includes(t)){if(this.checkoutResponse){this.checkoutResponse=null;f.clearCheckoutResponse()}this.currentPaymentMethod=t;f.setPaymentMethodSelected(t);if(t!==b.CARD){this.cardMode="input";f.setCardMode("input")}this.isSubmitting=false;this.currentApmPaymentMethod=I.mapToAPMPaymentMethod(t,u.data?.pricing?.country);if(t!==b.CASH&&t!==b.BANK_TRANSFER){this.checkoutResponse=null;f.clearCheckoutResponse()}else{this.checkoutResponse=null;f.clearCheckoutResponse()}this.paymentMethodSelected.emit(t);try{this.currentRequiredFields=D(t,this.allRequiredFields).fields;const i=await n.sessions.updateCurrentSessionPaymentMethod(u.data.sessionId,{paymentMethodName:I.mapToAPMPaymentMethod(t,u.data.pricing.country),paymentMethodType:t,currency:u.data.pricing.currency});f.setProviderKey(i.providerKey);if(i.providerKey===M.DECIDIR||u.data.providerKey===M.DECIDIR){const t=crypto.randomUUID();const i=await n.fingerPrint.getFingerPrint(t);u.deviceId=t;const e=i.result.script;const s=document.createElement("script");s.innerHTML=e;document.body.appendChild(s)}}catch(t){console.error("Failed to update payment method or get required fields:",t)}}}get currentPaymentError(){if(this.currentPaymentMethod===b.CARD){return this.rejectedPaymentCard}else if(this.currentPaymentMethod===b.CASH||this.currentPaymentMethod===b.BANK_TRANSFER){return this.rejectedPaymentAPM}return false}paymentMethodSelected;async handlePaymentMethodSelected(t){t.stopPropagation();const i=t.detail;this.changePaymentMethod(i);if(this.formElement){this.formElement.resetValidation()}}async handleSubmit(t){if(this.isSubmitting){return}this.rejectedPaymentCard=false;this.rejectedPaymentAPM=false;if(this.currentPaymentMethod===b.CARD){this.handleSubmitCard(t)}else if(this.currentPaymentMethod===b.CASH||this.currentPaymentMethod===b.BANK_TRANSFER){this.handleSubmitAPM(t)}}handleFormChange(t){const i=t.detail;let e=true;let s={};if(this.formElement?.errors){s=this.formElement.errors;e=Object.keys(s).length===0}this.formChange.emit({data:i,isValid:e,errors:Object.keys(s).length>0?s:undefined})}async handleSubmitCard(t){const i=t.detail;const e=this.getCombinedUserData(i);if(!u.data.cardTokenId&&!u.data.cardId){this.cardError={showCardInvalid:true,type:"card_error"};return}if(!u.data.cardInformation&&!u.data.cardId){this.cardError={showCardInvalid:true,type:"tokenization_error"};return}this.cardError={showCardInvalid:false,type:null};const s={transaction:{quantity:1,...u.data.discount.couponCode&&{couponCode:u.data.discount.couponCode}},installments:Number(i.installments||u.data.cardInformation?.installments?.selectedInstallment?.installment),...u.data.cardTokenId&&{cardTokenId:u.data.cardTokenId,...u.data?.itemInformation?.type!==w.PLAN&&{saveCard:u.saveCard}},...u.data.cardId&&{cardId:u.data.cardId},...(!this.otpVerified||this.cardMode==="input")&&{customer:{firstName:e.fullName?.split(" ")[0],lastName:e.fullName?.split(" ").slice(1).join(" "),email:e.email,phone:{countryCode:e.countryCodePhoneNumber,number:e.phoneNumber}}},billingDetails:{address:{lineOne:e["billing-address"],city:e["billing-city"],state:e["billing-state"],country:e["billing-country"],zipCode:e["billing-zip"]},identification:{type:e.documentType,value:e.documentNumber}},customAttributes:{...u.deviceId&&{deviceId:u.deviceId}},...u.metadata&&{paymentMetadata:u.metadata}};const a=o();this.isSubmitting=true;this.isCardSubmitting=true;try{const t=await n.checkout.createCardCheckoutRequest(u.data.sessionId,a,s,u.data.accessToken||undefined);f.setCheckoutResponse(t.data);this.responseCheckoutCard=t.data;if(t.data.result?.status.toUpperCase()===l.APPROVED){this.isCardSuccess=true;f.setPaymentStatus(r.APPROVED);this.success.emit({paymentMethod:this.currentPaymentMethod,data:t.data});u.data.cardInformation.lastFour=t.data.result?.cardLastFour}else{this.error.emit({paymentMethod:this.currentPaymentMethod,data:t.data});f.setCheckoutResponse(t.data);this.rejectedPaymentCard=true;this.alertErrorKeys={message:t.data.result?.statusDetail.toLowerCase()??t.data.error?.error?.message?.toLowerCase()}}}catch(t){this.error.emit({paymentMethod:this.currentPaymentMethod,data:t.data});f.setCheckoutResponse(t.data);this.responseCheckoutCard=t.data;this.rejectedPaymentCard=true;this.alertErrorKeys={message:t.data?.error?.type?.toLowerCase()??t.data?.result?.statusDetail?.toLowerCase()}}finally{this.isSubmitting=false;this.isCardSubmitting=false}}async handleSubmitAPM(t){if(this.currentPaymentMethod!==b.CASH&&this.currentPaymentMethod!==b.BANK_TRANSFER){return}this.isSubmitting=true;const i=t.detail;const e=this.getCombinedUserData(i);try{const t={address:{country:e["billing-country"]||"",state:e["billing-state"]||"",city:e["billing-city"]||"",zipCode:e["billing-zip"]||"",lineOne:e["billing-address"]||""},identification:{type:e.documentType,value:e.documentNumber}};const s=this.currentApmPaymentMethod||I.mapToAPMPaymentMethod(this.currentPaymentMethod,u.data?.pricing?.country);const a={transaction:{quantity:1,...u.data.discount.couponCode&&{couponCode:u.data.discount.couponCode}},method:s,billingDetails:t,redirect:{approved:window.location.origin+"/payment/success",rejected:window.location.origin+"/payment/failure"},paymentMetadata:u.metadata,customAttributes:{bank:i.bankId||u.data?.bankId?.code}};{a.customer={firstName:e.fullName?.split(" ")[0]||"",lastName:e.fullName?.split(" ").slice(1).join(" ")||"",email:e.email,phone:{countryCode:e.countryCodePhoneNumber||"",number:e.phoneNumber||""}}}const r=o();const l=await n.checkout.createAPMCheckoutRequest(u.data.sessionId,r,a);this.isSubmitting=false;this.checkoutResponse=l.data;this.storedCheckoutResults.set(this.currentPaymentMethod,l.data);if(l.data?.date){u.data.paymentDate=l.data.date;u.createdAt=l.data.date}if(l.data?.traceId){u.data.paymentReference=l.data.traceId}}catch(t){this.isSubmitting=false;this.checkoutResponse=t.data;this.alertErrorKeys={message:t.data?.error?.type?.toLowerCase()??t.data?.result?.statusDetail?.toLowerCase()};this.rejectedPaymentAPM=true}}async submit(){if(this.formElement&&typeof this.formElement.submit==="function"){this.formElement.submit()}else{await this.handleSubmit({detail:{}})}}handlePaymentStatusChange=t=>{if(t.isCompleted){if(t.status===k.APPROVED){f.setPaymentStatus(r.APPROVED);this.success.emit({paymentMethod:this.currentPaymentMethod,data:this.checkoutResponse})}else if(t.status===k.REJECTED){f.setPaymentStatus(r.REJECTED);this.alertErrorKeys={alertTitle:r.APM_ERROR_GENERIC,message:r.APM_MESSAGE_ERROR}}}};async handleInputChange(t){if(t?.detail?.id==="email"&&this.oneClickCheckout){if(this.emailDebounceTimeout){clearTimeout(this.emailDebounceTimeout)}if(!t.detail.value||t.detail.value.trim()===""){this.customerExists=false;f.clearCustomerIdAndToken();return}this.emailDebounceTimeout=setTimeout((async()=>{try{const t=await n.customers.exists({email:u.data.userInformation.email},this.publicKey);this.customerExists=t.data.exists}catch(t){this.customerExists=false}}),500)}}validationSchema={email:s().when([],{is:()=>!this.otpVerified,then:t=>t.email("validation.emailInvalid").matches(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,"validation.emailInvalid").required("validation.emailRequired"),otherwise:t=>t.notRequired()}),fullName:s().when([],{is:()=>!this.otpVerified,then:t=>t.required("validation.fullNameRequired").matches(/^[a-zA-ZÀ-ÿ\u00f1\u00d1\s]{2,}\s+[a-zA-ZÀ-ÿ\u00f1\u00d1\s]{2,}$/,"validation.fullNameInvalid"),otherwise:t=>t.notRequired()}),isValidPhoneNumber:s().when([],{is:()=>c("phoneNumber",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.equals(["true"],"validation.phoneRequired"),otherwise:t=>t.notRequired()}),"billing-country":s().when([],{is:()=>c("billing-country",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.countryRequired"),otherwise:t=>t.notRequired()}),"billing-state":s().when([],{is:()=>c("billing-state",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.stateRequired"),otherwise:t=>t.notRequired()}),"billing-address":s().when([],{is:()=>c("billing-address",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.addressRequired"),otherwise:t=>t.notRequired()}),"billing-city":s().when([],{is:()=>c("billing-city",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.cityRequired"),otherwise:t=>t.notRequired()}),"billing-zip":s().when([],{is:()=>c("billing-zip",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.zipRequired"),otherwise:t=>t.notRequired()}),bankId:s().when([],{is:()=>c("bankId",this.currentRequiredFields),then:t=>t.required("validation.bankRequired"),otherwise:t=>t.notRequired()}),installments:s().when([],{is:()=>this.currentPaymentMethod===b.CARD&&u.data.cardInformation.installments.isAvailableInstallments&&u.data.cardInformation?.installments?.installments.length>0&&u.data.itemInformation.type!==w.PLAN,then:t=>t.required("validation.installmentsRequired"),otherwise:t=>t.notRequired()}),documentType:s().when([],{is:()=>c("documentType",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.documentTypeRequired"),otherwise:t=>t.notRequired()}),documentNumber:s().when([],{is:()=>c("documentNumber",this.currentRequiredFields)&&!this.otpVerified||this.otpVerified&&this.cardMode==="input",then:t=>t.required("validation.documentNumberRequired").min(7,"validation.documentInvalid"),otherwise:t=>t.notRequired()})};getInitialData=()=>({email:u.data.userInformation.email||"",fullName:u.data.userInformation.fullName||"",phoneNumber:u.data.userInformation.phoneNumber?.number||"",countryCodePhoneNumber:u.data.userInformation.countryCode||"",documentType:"",documentNumber:"","billing-country":u.data.userInformation.address?.billingAddress?.country||"","billing-state":u.data.userInformation?.address?.billingAddress?.state||"","billing-address":u.data.userInformation?.address?.billingAddress?.address||"","billing-city":u.data.userInformation?.address?.billingAddress?.city||"","billing-zip":u.data.userInformation?.address?.billingAddress?.zip||"",bankId:u.data.bankId?.code||"",card:"",installments:u.data.cardInformation?.installments?.selectedInstallment?.installment?.toString()||""});hasPrefilledAddress=()=>{const t=["billing-country","billing-state","billing-address","billing-city","billing-zip"];return t.some((t=>{const i=this.initialData[t];return i&&i.trim()!==""}))};get isQrCodeVisible(){return!!this.checkoutResponse?.result?.data?.qrCode}get isBankTransferVisible(){return!!this.checkoutResponse?.result?.data?.account&&!!this.checkoutResponse?.result?.data?.bankName&&!!this.checkoutResponse?.result?.data?.reference}isPaymentApproved=()=>{if(u.data.paymentStatus===r.APPROVED){return true}return false};handleRebillAccountClick(t){this.showOtp=t.detail}handleReturnForm(t){this.showOtp=t.detail;f.clearCustomerIdAndToken()}handleSignOut(){this.showOtp=false;this.otpVerified=false;if(!u?.data?.prefilledData?.email){this.customerExists=false}f.clearCustomerIdAndToken();f.clearUserInformation();this.cardError={showCardInvalid:false,type:null};this.alertErrorKeys=null;this.rejectedPaymentCard=false;this.rejectedPaymentAPM=false}handleCodeVerified(){this.otpVerified=true;this.showOtp=false;this.rejectedPaymentCard=false;this.alertErrorKeys=null;this.cardError={showCardInvalid:false,type:null};if(this.formElement){this.formElement.resetValidation()}}isPaymentRejected(){return u.data.paymentStatus===r.REJECTED&&this.currentPaymentMethod===b.BANK_TRANSFER}render(){const t=this.countries.map((t=>({label:t.country,value:t.isoCountryCode})));const i=(t={})=>e("rebill-summary",{key:"698d9a1b5eeee59f9e4b9762bedcedd4818a059e",totalAmount:u.data.pricing.total,currency:u.data.pricing.currency,itemTitle:u._session?.getTitle(),itemDescription:u._session?.getDescription(),itemAmount:u.data.pricing.subtotal,subtotal:u.data.pricing.subtotal,allowCoupon:u._session?.getAllowCoupon(this.displayConfig),currentBreakpoint:this.breakpoint,planFrequency:u._session?.getPlanFrequency(),planFrequencyCount:u._session?.getPlanFrequencyCount(),discountType:u.data.discount.discountType,discountedPercentage:u.data.discount.discountedPercentage,discountDuration:u.data.discount.discountDuration,discountAmount:u.data.discount.discountAmount,...t});return u.isInitialized&&e(e.Fragment,null,this.showRefreshModal&&e("rebill-modal-overlay",{key:"6a0d7aab67c17d0fc60bb30103e04ddc6903c2cc"}),this.displayConfig.processingPayment&&e("rebill-processing-payment",{key:"4dbf0982819ef2b65752a53654fc5a0c3c858875",style:{display:this.isCardSubmitting?"block":"none"}}),this.displayConfig.successPage&&this.isPaymentApproved()&&u.isInitialized?e("success-page",{typePaymentMethod:u.data.paymentMethodSelected,paymentMethodName:I.mapToAPMPaymentMethod(u.data.paymentMethodSelected||u.data.payment?.paymentMethodType,u.data?.pricing?.country),country:u.data?.pricing?.country,bank:u.data.payment?.paymentMethodMetadata?.bank||u.data.payment?.paymentMethodMetadata?.bank,cardLastFour:this.responseCheckoutCard?.result?.cardLastFour||u.data.cardInformation?.lastFour,paymentDate:u.data.paymentDate||this.responseCheckoutCard?.date||u.data.payment?.createdAt||this.checkoutResponse?.result?.data?.createdAt,referenceNumber:u.data.paymentReference||u.data.payment?.traceId||this.responseCheckoutCard?.traceId,onSuccessRedirect:t=>{this.successRedirect.emit(t.detail)},trialPeriodDays:u.data?.itemInformation?.trial?.trialPeriodDays,debitDay:u.data?.itemInformation?.debitDay,planAmount:u.data?.pricing?.planAmount}):e(e.Fragment,null,this.displayConfig.sandboxMode&&u.isSandbox&&u.data.sessionType===m.CHECKOUT_LANDING&&C(this.breakpoint,x.DESKTOP)&&e("div",{class:"mode-sandbox-mobile-container",style:{display:this.isCardSubmitting||this.isCardSuccess?"none":"block"}},e("rebill-mode-sandbox-mobile",null)),e("rebill-checkout-form",{ref:t=>this.formElement=t,style:{display:this.isCardSubmitting||this.isCardSuccess?"none":"block"},validationSchema:this.validationSchema,initialData:this.initialData,onSubmit:t=>this.handleSubmit(t),onChange:t=>this.handleFormChange(t),renderForm:({submit:s,formData:n,errors:a})=>{const o=!this.isCardSuccess&&this.checkoutResponse?.result&&(this.currentPaymentMethod===b.CASH||this.currentPaymentMethod===b.BANK_TRANSFER);return e("div",{class:`rebill-checkout ${!this.displayConfig.checkoutSummary?"full-width-layout":""}`},e("div",{class:"left-section"},e("div",{class:"left-section-container"},this.displayConfig.logo&&e("organization-logo",{organization:u.data.organization}),e("div",{class:"otp-container",style:{display:this.showOtp?"block":"none"}},e("otp-component",null)),e("div",{style:{display:this.showOtp?"none":"block"}},e("div",{class:"checkout-form-section"},this.displayConfig.checkoutSummary&&e("div",{class:"summary-mobile-tablet",style:{display:C(this.breakpoint,x.DESKTOP)?"block":"none"}},i({displayedComponents:["totalAmount","discount","timelineFreeTrial","timelineDebitDay","itemDetails"]})),!this.otpVerified&&this.displayConfig.customerInformation&&e("user-information",{customerExists:this.customerExists,disabled:this.isSubmitting,errors:{email:a.email,fullName:a.fullName}}),this.otpVerified&&this.displayConfig.customerInformation&&e("user-information-static",{variant:"otp",userInfo:{customerName:u.data.userInformation.fullName?.split(" ")[0],customerEmail:u.data.userInformation.email}}),e("div",{style:{display:"flex",flexDirection:"column",gap:"16px"}},e("payment-method-selector",{enabledPaymentMethods:this.filteredPaymentMethods,defaultSelected:this.currentPaymentMethod,disabled:this.isSubmitting,errorComponent:{showErrorComponent:this.displayConfig.errorMessage&&(this.currentPaymentError||this.isPaymentRejected()),alertTitle:h.getErrorTitle(this.currentPaymentMethod,u.data?.pricing?.country||"",this.alertErrorKeys?.alertTitle),message:h.getErrorMessage(this.alertErrorKeys?.message,this.currentPaymentMethod,u.data?.pricing?.country)},country:u.data?.pricing?.country,installmentsError:a.installments,showDocument:(!this.otpVerified||this.otpVerified&&this.cardMode==="input")&&!o&&!this.isQrCodeVisible&&(c("documentNumber",this.currentRequiredFields)||c("documentType",this.currentRequiredFields)),documentTypeError:a.documentType,documentNumberError:a.documentNumber,cardError:this.cardError,customCSS:this.css}),!o&&(()=>{const t=c("bankId",this.currentRequiredFields);return t})()&&e("div",{class:"animated-component fade-in"},e("rebill-bank-selector",{banks:d("bank",this.allRequiredFields[this.currentPaymentMethod].original)||[],defaultSelectedBankId:n.bankId||"",error:a?.bankId,disabled:this.isSubmitting}))),!o&&(!this.otpVerified||this.cardMode==="input")&&e(e.Fragment,null,this.displayConfig.billingAddress&&(c("billing-country",this.currentRequiredFields)||c("billing-state",this.currentRequiredFields)||c("billing-address",this.currentRequiredFields)||c("billing-city",this.currentRequiredFields)||c("billing-zip",this.currentRequiredFields))&&e("div",{class:"animated-component slide-in"},e("rebill-address",{disabled:this.isSubmitting,countryOptions:t,billingView:this.hasPrefilledAddress()?"form":"search",errors:{"billing-country":a["billing-country"],"billing-state":a["billing-state"],"billing-address":a["billing-address"],"billing-city":a["billing-city"],"billing-zip":a["billing-zip"]}})),this.displayConfig.customerInformation&&c("phoneNumber",this.currentRequiredFields)&&e("div",{class:"animated-component fade-in"},e("user-information-phone",{disabled:this.isSubmitting,error:a?.phoneNumber,countryCode:u.data.userInformation?.countryCode||u.data.country}))),o&&e("apm-checkout",{paymentMethod:this.currentPaymentMethod,referenceId:this.currentPaymentMethod===b.CASH?this.checkoutResponse?.result?.data?.referenceId:undefined,qrCodeData:this.currentPaymentMethod===b.BANK_TRANSFER?this.checkoutResponse?.result?.data?.qrCode:undefined,code:this.currentPaymentMethod===b.BANK_TRANSFER?this.checkoutResponse?.result?.data?.code:undefined,checkoutRequestId:this.checkoutResponse?.result?.checkoutRequestId,providerName:u.data.providerKey,expirationDate:(()=>{const t=new Date;t.setDate(t.getDate()+30);return t.toISOString()})(),onPaymentStatusChange:t=>this.handlePaymentStatusChange(t.detail),country:u.data?.pricing?.country,redirectUrl:this.checkoutResponse?.result?.data?.url,timeToRedirect:this.timeToRedirectAPM,bearerToken:this.checkoutResponse?.result?.data?.bearerToken,bankTransferData:this.checkoutResponse?.result?.data?.account&&this.checkoutResponse?.result?.data?.bankName&&this.checkoutResponse?.result?.data?.reference?{account:this.checkoutResponse.result.data.account,bankName:this.checkoutResponse.result.data.bankName,reference:this.checkoutResponse.result.data.reference}:undefined}),this.displayConfig.checkoutSummary&&e("div",{class:"summary-price-details",style:{display:C(this.breakpoint,x.DESKTOP)?"block":"none"}},i({displayedComponents:["priceDetails"]})),this.displayConfig.submitButton&&!(o&&(this.isQrCodeVisible||this.isBankTransferVisible))&&e("div",{class:"payment-button-container"},e("payment-button",{paymentMethod:this.currentPaymentMethod,isLoading:this.isSubmitting,trialPeriodDays:u.data?.itemInformation?.trial?.trialPeriodDays,onSubmit:()=>{s()},redirectUrl:!!this.checkoutResponse?.result?.data?.url,timeToRedirect:this.timeToRedirectAPM,isDisabled:u.data.fetchingInstallments,country:u.data?.pricing?.country}),e("rebill-alert",{type:"secure",variant:"variant-secure",icon:"lock-outline",message:p.translate("otp.secureMessage")}))),this.displayConfig.sandboxMode&&u.isSandbox&&u.data.sessionType===m.CHECKOUT_LANDING&&!C(this.breakpoint,x.DESKTOP)&&e("rebill-mode-sandbox",null)),this.displayConfig.footer&&e("rebill-footer",{style:{marginTop:C(this.breakpoint,x.DESKTOP)?"24px":"auto"}}))),this.displayConfig.checkoutSummary&&e("div",{class:"right-section-checkout"},e("div",{class:"checkout-summary-section"},e("div",{class:"summary-desktop",style:{display:!C(this.breakpoint,x.DESKTOP)?"block":"none"}},i()))))}})))}static get watchers(){return{language:["handleLanguageChange"]}}};O.style=F;export{O as rebill_checkout};
2
+ //# sourceMappingURL=p-405ab8da.entry.js.map
@@ -1,2 +1,2 @@
1
- import{E as e}from"./p-D8cwEAmw.js";const t={development:{baseURL:"http://localhost:3014/v3",iframeURL:"http://localhost:5173/",timeout:3e4},staging:{baseURL:"https://api.rebill.dev/v3",iframeURL:"https://sdk-iframe.rebill.dev/v3-1/index.html",timeout:3e4},production:{baseURL:"https://api.rebill.com/v3",iframeURL:"https://sdk-iframe.rebill.to/v3-1/index.html",timeout:3e4}};let s={};const o=(e={})=>{s={environment:"production",debug:false,...e};if(s.debug){console.log("🔧 Rebill SDK initialized with config:",s)}};const i=()=>{const o=s.environment||globalThis?.REBILL_ENV||e?.REBILL_ENV||"production";const i=["development","staging","production"];if(!i.includes(o)){console.warn(`⚠️ Invalid environment "${o}". Using "production" as fallback. Valid environments: ${i.join(", ")}`);return t.production}const n=t[o];if(s.debug||o==="development"){console.log(`🔧 SDK Config: Using ${o} environment`);console.log(`📍 API URL: ${n.baseURL}`);console.log(`🖼️ iFrame URL: ${n.iframeURL}`)}return n};const n=()=>s.environment||globalThis?.REBILL_ENV||e?.REBILL_ENV||"production";const a=()=>s.debug||false;const c={data:{countries:"/data/countries",states:e=>`/data/states/${e}`,countryCodes:e=>`/data/country-codes/${e}`,documentTypes:e=>`/data/identifications/${e}`},sessions:{updatePaymentMethod:"/sessions/current/payment-method",SDK:"/sessions/sdk"},checkout:{apmRequest:"/sessions/checkout/request",cardRequest:"/sessions/checkout",requiredFields:"/preview/checkout-fields",requestStatus:e=>`sessions/checkout/request/${e}`},discountCoupon:{apply:(e,t,s=1)=>`/sessions/${e}/price?couponCode=${t}&quantity=${s}`},cards:{bff:"/cards/bff"},fingerPrint:{get:e=>`/decidir/fingerprint/${e}`},customers:{exists:"/customers/bff/exists"},otp:{generate:"/otp",verify:"/otp/verify-code"}};export{c as A,n as a,a as b,i as g,o as i};
2
- //# sourceMappingURL=p-D339jHg4.js.map
1
+ import{E as e}from"./p-D8cwEAmw.js";const t={development:{baseURL:"http://localhost:3014/v3",iframeURL:"http://localhost:5173/",timeout:3e4},staging:{baseURL:"https://api.rebill.dev/v3",iframeURL:"https://sdk-iframe.rebill.dev/v3-1/index.html",timeout:3e4},production:{baseURL:"https://api.rebill.com/v3",iframeURL:"https://sdk-iframe.rebill.to/v3-1/index.html",timeout:3e4}};let s={};const o=(e={})=>{s={environment:"production",debug:false,...e};if(s.debug){console.log("🔧 Rebill SDK initialized with config:",s)}};const i=()=>{const o=s.environment||globalThis?.REBILL_ENV||e?.REBILL_ENV||"production";const i=["development","staging","production"];if(!i.includes(o)){console.warn(`⚠️ Invalid environment "${o}". Using "production" as fallback. Valid environments: ${i.join(", ")}`);return t.production}const n=t[o];if(s.debug||o==="development"){console.log(`🔧 SDK Config: Using ${o} environment`);console.log(`📍 API URL: ${n.baseURL}`);console.log(`🖼️ iFrame URL: ${n.iframeURL}`)}return n};const n=()=>s.environment||globalThis?.REBILL_ENV||e?.REBILL_ENV||"production";const a=()=>s.debug||false;const c={data:{countries:"/data/countries",states:e=>`/data/states/${e}`,countryCodes:e=>`/data/country-codes/${e}`,documentTypes:e=>`/data/identifications/${e}`},sessions:{updatePaymentMethod:"/sessions/current/payment-method",SDK:"/sessions/sdk"},checkout:{apmRequest:"/sessions/checkout/request",cardRequest:"/sessions/checkout",requiredFields:"/preview/checkout-fields",requestStatus:e=>`sessions/checkout/request/${e}`},discountCoupon:{apply:(e,t,s=1)=>`/sessions/${e}/price?couponCode=${encodeURIComponent(t)}&quantity=${s}`},cards:{bff:"/cards/bff"},fingerPrint:{get:e=>`/decidir/fingerprint/${e}`},customers:{exists:"/customers/bff/exists"},otp:{generate:"/otp",verify:"/otp/verify-code"}};export{c as A,n as a,a as b,i as g,o as i};
2
+ //# sourceMappingURL=p-B5khCLtC.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"p-D339jHg4.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":[],"mappings":";;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;AASD;AACA,IAAI,YAAY,GAAoB,EAAE;AAEtC;;;AAGG;MACU,aAAa,GAAG,CAAC,MAA0B,GAAA,EAAE,KAAI;AAC5D,IAAA,YAAY,GAAG;QACb,WAAW,EAAE,YAAY;AACzB,QAAA,KAAK,EAAE,KAAK;AACZ,QAAA,GAAG,MAAM;KACV;AAED,IAAA,IAAI,YAAY,CAAC,KAAK,EAAE;AACtB,QAAA,OAAO,CAAC,GAAG,CAAC,wCAAwC,EAAE,YAAY,CAAC;;;;AAKvE;AAEA;;;AAGG;AACI,MAAM,YAAY,GAAG,MAAgB;AAC1C,IAAA,MAAM,GAAG,GACP,YAAY,CAAC,WAAW;AACvB,QAAA,UAAkB,EAAE,UAAU;AAC9B,QAAA,GAAW,EAAE,UAAU;QACxB,YAAY,CAAC;IAEf,MAAM,iBAAiB,GAAkB,CAAC,aAAa,EAAE,SAAS,EAAE,YAAY,CAAC;IAEjF,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAAkB,CAAC,EAAE;AACnD,QAAA,OAAO,CAAC,IAAI,CACV,CAAA,yBAAA,EAA4B,GAAG,CAA0D,uDAAA,EAAA,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CACxH;QACD,OAAO,UAAU,CAAC,UAAU;;AAG9B,IAAA,MAAM,MAAM,GAAG,UAAU,CAAC,GAAkB,CAAC;IAE7C,IAAI,YAAY,CAAC,KAAK,IAAI,GAAG,KAAK,aAAa,EAAE;AAC/C,QAAA,OAAO,CAAC,GAAG,CAAC,wBAAwB,GAAG,CAAA,YAAA,CAAc,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,CAAA,YAAA,EAAe,MAAM,CAAC,OAAO,CAAE,CAAA,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,CAAA,iBAAA,EAAoB,MAAM,CAAC,SAAS,CAAE,CAAA,CAAC;;AAGrD,IAAA,OAAO,MAAM;AACf;AAEA;;AAEG;AACI,MAAM,qBAAqB,GAAG,MAAkB;IACrD,QACE,YAAY,CAAC,WAAW;AACvB,QAAA,UAAkB,EAAE,UAAU;AAC9B,QAAA,GAAW,EAAE,UAAU;AACxB,QAAA,YAAY;AAEhB;AAEA;;AAEG;AACI,MAAM,WAAW,GAAG,MAAc;AACvC,IAAA,OAAO,YAAY,CAAC,KAAK,IAAI,KAAK,CAAC;AACrC;AAEa,MAAA,aAAa,GAAG;AAC3B,IASA,IAAI,EAAE;AACJ,QAAA,SAAS,EAAE,iBAAiB;QAC5B,MAAM,EAAE,CAAC,WAAmB,KAAK,CAAA,aAAA,EAAgB,WAAW,CAAE,CAAA;QAC9D,YAAY,EAAE,CAAC,WAAmB,KAAK,CAAA,oBAAA,EAAuB,WAAW,CAAE,CAAA;QAC3E,aAAa,EAAE,CAAC,WAAmB,KAAK,CAAA,sBAAA,EAAyB,WAAW,CAAE,CAAA;AAC/E,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,mBAAmB,EAAE,kCAAkC;AACvD,QAAA,GAAG,EAAE,eAAe;AACrB,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,UAAU,EAAE,4BAA4B;AACxC,QAAA,WAAW,EAAE,oBAAoB;AACjC,QAAA,cAAc,EAAE,0BAA0B;QAC1C,aAAa,EAAE,CAAC,iBAAyB,KAAK,CAAA,0BAAA,EAA6B,iBAAiB,CAAE,CAAA;AAC/F,KAAA;AACD,IAAA,cAAc,EAAE;AACd,QAAA,KAAK,EAAE,CAAC,SAAiB,EAAE,UAAkB,EAAE,QAAmB,GAAA,CAAC,KACjE,CAAa,UAAA,EAAA,SAAS,qBAAqB,UAAU,CAAA,UAAA,EAAa,QAAQ,CAAE,CAAA;AAC/E,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,GAAG,EAAE,YAAY;AAClB,KAAA;AACD,IAAA,WAAW,EAAE;QACX,GAAG,EAAE,CAAC,IAAY,KAAK,CAAA,qBAAA,EAAwB,IAAI,CAAE,CAAA;AACtD,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,MAAM,EAAE,uBAAuB;AAChC,KAAA;AACD,IAAA,GAAG,EAAE;AACH,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,MAAM,EAAE,kBAAkB;AAC3B,KAAA;;;;;"}
1
+ {"version":3,"file":"p-B5khCLtC.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${encodeURIComponent(couponCode)}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":[],"mappings":";;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;AASD;AACA,IAAI,YAAY,GAAoB,EAAE;AAEtC;;;AAGG;MACU,aAAa,GAAG,CAAC,MAA0B,GAAA,EAAE,KAAI;AAC5D,IAAA,YAAY,GAAG;QACb,WAAW,EAAE,YAAY;AACzB,QAAA,KAAK,EAAE,KAAK;AACZ,QAAA,GAAG,MAAM;KACV;AAED,IAAA,IAAI,YAAY,CAAC,KAAK,EAAE;AACtB,QAAA,OAAO,CAAC,GAAG,CAAC,wCAAwC,EAAE,YAAY,CAAC;;;;AAKvE;AAEA;;;AAGG;AACI,MAAM,YAAY,GAAG,MAAgB;AAC1C,IAAA,MAAM,GAAG,GACP,YAAY,CAAC,WAAW;AACvB,QAAA,UAAkB,EAAE,UAAU;AAC9B,QAAA,GAAW,EAAE,UAAU;QACxB,YAAY,CAAC;IAEf,MAAM,iBAAiB,GAAkB,CAAC,aAAa,EAAE,SAAS,EAAE,YAAY,CAAC;IAEjF,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAAkB,CAAC,EAAE;AACnD,QAAA,OAAO,CAAC,IAAI,CACV,CAAA,yBAAA,EAA4B,GAAG,CAA0D,uDAAA,EAAA,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CACxH;QACD,OAAO,UAAU,CAAC,UAAU;;AAG9B,IAAA,MAAM,MAAM,GAAG,UAAU,CAAC,GAAkB,CAAC;IAE7C,IAAI,YAAY,CAAC,KAAK,IAAI,GAAG,KAAK,aAAa,EAAE;AAC/C,QAAA,OAAO,CAAC,GAAG,CAAC,wBAAwB,GAAG,CAAA,YAAA,CAAc,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,CAAA,YAAA,EAAe,MAAM,CAAC,OAAO,CAAE,CAAA,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,CAAA,iBAAA,EAAoB,MAAM,CAAC,SAAS,CAAE,CAAA,CAAC;;AAGrD,IAAA,OAAO,MAAM;AACf;AAEA;;AAEG;AACI,MAAM,qBAAqB,GAAG,MAAkB;IACrD,QACE,YAAY,CAAC,WAAW;AACvB,QAAA,UAAkB,EAAE,UAAU;AAC9B,QAAA,GAAW,EAAE,UAAU;AACxB,QAAA,YAAY;AAEhB;AAEA;;AAEG;AACI,MAAM,WAAW,GAAG,MAAc;AACvC,IAAA,OAAO,YAAY,CAAC,KAAK,IAAI,KAAK,CAAC;AACrC;AAEa,MAAA,aAAa,GAAG;AAC3B,IASA,IAAI,EAAE;AACJ,QAAA,SAAS,EAAE,iBAAiB;QAC5B,MAAM,EAAE,CAAC,WAAmB,KAAK,CAAA,aAAA,EAAgB,WAAW,CAAE,CAAA;QAC9D,YAAY,EAAE,CAAC,WAAmB,KAAK,CAAA,oBAAA,EAAuB,WAAW,CAAE,CAAA;QAC3E,aAAa,EAAE,CAAC,WAAmB,KAAK,CAAA,sBAAA,EAAyB,WAAW,CAAE,CAAA;AAC/E,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,mBAAmB,EAAE,kCAAkC;AACvD,QAAA,GAAG,EAAE,eAAe;AACrB,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,UAAU,EAAE,4BAA4B;AACxC,QAAA,WAAW,EAAE,oBAAoB;AACjC,QAAA,cAAc,EAAE,0BAA0B;QAC1C,aAAa,EAAE,CAAC,iBAAyB,KAAK,CAAA,0BAAA,EAA6B,iBAAiB,CAAE,CAAA;AAC/F,KAAA;AACD,IAAA,cAAc,EAAE;QACd,KAAK,EAAE,CAAC,SAAiB,EAAE,UAAkB,EAAE,QAAA,GAAmB,CAAC,KACjE,CAAA,UAAA,EAAa,SAAS,CAAqB,kBAAA,EAAA,kBAAkB,CAAC,UAAU,CAAC,CAAa,UAAA,EAAA,QAAQ,CAAE,CAAA;AACnG,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,GAAG,EAAE,YAAY;AAClB,KAAA;AACD,IAAA,WAAW,EAAE;QACX,GAAG,EAAE,CAAC,IAAY,KAAK,CAAA,qBAAA,EAAwB,IAAI,CAAE,CAAA;AACtD,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,MAAM,EAAE,uBAAuB;AAChC,KAAA;AACD,IAAA,GAAG,EAAE;AACH,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,MAAM,EAAE,kBAAkB;AAC3B,KAAA;;;;;"}