xendit-components-web 0.0.17 → 0.0.18

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.
@@ -1,3 +1,3 @@
1
1
  /*! Copyright (c) 2026 Xendit Inc. Licensed under the MIT License (MIT). */
2
- import"preact/debug";import"preact/devtools";import{jsx as e,jsxs as n,Fragment as t}from"preact/jsx-runtime";import{render as i,options as a,createContext as r,Fragment as o,createElement as s,createRef as l}from"preact";import{useCallback as d,useContext as c,useRef as u,useLayoutEffect as h,useState as p,useMemo as m,useImperativeHandle as _,useEffect as f}from"preact/hooks";import b from"classnames";import y,{getCountries as x,getExampleNumber as g}from"libphonenumber-js";import v,{getCountryCallingCode as k}from"libphonenumber-js/min";import w from"libphonenumber-js/mobile/examples";import{forwardRef as C}from"preact/compat";import E from"qrcode";import A from"qrcode/lib/renderer/svg-tag.js";const P=n=>{const{name:t,size:i,direction:a}=n;let r;switch(a){case"left":r="rotate(0 12 12)";break;case"right":r="rotate(180 12 12)";break;case"up":r="rotate(90 12 12)";break;case"down":r="rotate(-90 12 12)"}return e("svg",{className:`xendit-icon ${n.className??""}`,width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:"none",children:e("g",{transform:r,children:N.find(e=>e.name===t)?.node??null})})};function S(n,t,i){return{name:n,node:e("g",{id:`xendit-icon-${n}`,transform:`scale(${1/i} ${1/i})`,children:t})}}const N=[S("chevron",e("path",{d:"M15 19.5L7.5 12L15 4.5",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),1),S("check",e("path",{d:"M13.5 4.5L6.5 11.5L3 8",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),16/24),S("x",n(t,{children:[e("path",{d:"M18.75 5.25L5.25 18.75",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),e("path",{d:"M18.75 18.75L5.25 5.25",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})]}),1),S("card",e("path",{fill:"currentColor",d:"M17.5 3.75H2.5C2.16848 3.75 1.85054 3.8817 1.61612 4.11612C1.3817 4.35054 1.25 4.66848 1.25 5V15C1.25 15.3315 1.3817 15.6495 1.61612 15.8839C1.85054 16.1183 2.16848 16.25 2.5 16.25H17.5C17.8315 16.25 18.1495 16.1183 18.3839 15.8839C18.6183 15.6495 18.75 15.3315 18.75 15V5C18.75 4.66848 18.6183 4.35054 18.3839 4.11612C18.1495 3.8817 17.8315 3.75 17.5 3.75ZM10.625 13.75H9.375C9.20924 13.75 9.05027 13.6842 8.93306 13.5669C8.81585 13.4497 8.75 13.2908 8.75 13.125C8.75 12.9592 8.81585 12.8003 8.93306 12.6831C9.05027 12.5658 9.20924 12.5 9.375 12.5H10.625C10.7908 12.5 10.9497 12.5658 11.0669 12.6831C11.1842 12.8003 11.25 12.9592 11.25 13.125C11.25 13.2908 11.1842 13.4497 11.0669 13.5669C10.9497 13.6842 10.7908 13.75 10.625 13.75ZM15.625 13.75H13.125C12.9592 13.75 12.8003 13.6842 12.6831 13.5669C12.5658 13.4497 12.5 13.2908 12.5 13.125C12.5 12.9592 12.5658 12.8003 12.6831 12.6831C12.8003 12.5658 12.9592 12.5 13.125 12.5H15.625C15.7908 12.5 15.9497 12.5658 16.0669 12.6831C16.1842 12.8003 16.25 12.9592 16.25 13.125C16.25 13.2908 16.1842 13.4497 16.0669 13.5669C15.9497 13.6842 15.7908 13.75 15.625 13.75ZM2.5 6.875V5H17.5V6.875H2.5Z"}),20/24),S("copy",n(t,{children:[e("path",{d:"M6 9.5H10",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M6 7.5H10",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M10 2.5H12.5C12.6326 2.5 12.7598 2.55268 12.8536 2.64645C12.9473 2.74021 13 2.86739 13 3V13.5C13 13.6326 12.9473 13.7598 12.8536 13.8536C12.7598 13.9473 12.6326 14 12.5 14H3.5C3.36739 14 3.24021 13.9473 3.14645 13.8536C3.05268 13.7598 3 13.6326 3 13.5V3C3 2.86739 3.05268 2.74021 3.14645 2.64645C3.24021 2.55268 3.36739 2.5 3.5 2.5H6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M5.5 4.5V4C5.5 3.33696 5.76339 2.70107 6.23223 2.23223C6.70107 1.76339 7.33696 1.5 8 1.5C8.66304 1.5 9.29893 1.76339 9.76777 2.23223C10.2366 2.70107 10.5 3.33696 10.5 4V4.5H5.5Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]}),16/24),S("dummy",e("path",{fill:"currentColor",d:"M17.5 11.875V15C17.5 15.3315 17.3683 15.6495 17.1339 15.8839C16.8995 16.1183 16.5815 16.25 16.25 16.25H3.75C3.41848 16.25 3.10054 16.1183 2.86612 15.8839C2.6317 15.6495 2.5 15.3315 2.5 15V11.875C2.5 11.5435 2.6317 11.2255 2.86612 10.9911C3.10054 10.7567 3.41848 10.625 3.75 10.625H16.25C16.5815 10.625 16.8995 10.7567 17.1339 10.9911C17.3683 11.2255 17.5 11.5435 17.5 11.875ZM16.25 3.75H3.75C3.41848 3.75 3.10054 3.8817 2.86612 4.11612C2.6317 4.35054 2.5 4.66848 2.5 5V8.125C2.5 8.45652 2.6317 8.77446 2.86612 9.00888C3.10054 9.2433 3.41848 9.375 3.75 9.375H16.25C16.5815 9.375 16.8995 9.2433 17.1339 9.00888C17.3683 8.77446 17.5 8.45652 17.5 8.125V5C17.5 4.66848 17.3683 4.35054 17.1339 4.11612C16.8995 3.8817 16.5815 3.75 16.25 3.75Z"}),20/24)];let R=!1;class XenditInitEvent extends Event{static type="init";constructor(){super(XenditInitEvent.type,{})}}class XenditFatalErrorEvent extends Event{message;static type="fatal-error";constructor(e){super(XenditFatalErrorEvent.type,{}),this.message=e}}class XenditReadyEvent extends Event{channelCode;static type="submission-ready";constructor(e){super(XenditReadyEvent.type,{}),this.channelCode=e}}class XenditNotReadyEvent extends Event{static type="submission-not-ready";constructor(){super(XenditNotReadyEvent.type,{})}}class XenditSubmissionBeginEvent extends Event{static type="submission-begin";constructor(){super(XenditSubmissionBeginEvent.type,{})}}class XenditSubmissionEndEvent extends Event{reason;userErrorMessage;developerErrorMessage;static type="submission-end";constructor(e,n,t){super(XenditSubmissionEndEvent.type,{}),this.reason=e,this.userErrorMessage=n,this.developerErrorMessage=t}}class XenditActionBeginEvent extends Event{static type="action-begin";constructor(){super(XenditActionBeginEvent.type,{})}}class XenditActionEndEvent extends Event{static type="action-end";constructor(){super(XenditActionEndEvent.type,{})}}class XenditWillRedirectEvent extends Event{static type="will-redirect";constructor(){super(XenditWillRedirectEvent.type,{})}}class XenditSessionCompleteEvent extends Event{static type="session-complete";constructor(){super(XenditSessionCompleteEvent.type,{})}}class XenditSessionExpiredOrCanceledEvent extends Event{static type="session-expired-or-canceled";constructor(){super(XenditSessionExpiredOrCanceledEvent.type,{})}}class XenditSessionPendingEvent extends Event{static type="session-pending";constructor(){super(XenditSessionPendingEvent.type,{})}}class XenditSessionNotPendingEvent extends Event{static type="session-not-pending";constructor(){super(XenditSessionNotPendingEvent.type,{})}}class XenditPaymentRequestCreatedEvent extends Event{paymentRequestId;static type="payment-request-created";constructor(e){super(XenditPaymentRequestCreatedEvent.type,{}),this.paymentRequestId=e}}class XenditPaymentTokenCreatedEvent extends Event{paymentTokenId;static type="payment-token-created";constructor(e){super(XenditPaymentTokenCreatedEvent.type,{}),this.paymentTokenId=e}}class XenditPaymentRequestDiscardedEvent extends Event{paymentRequestId;static type="payment-request-discarded";constructor(e){super(XenditPaymentRequestDiscardedEvent.type,{}),this.paymentRequestId=e}}class XenditPaymentTokenDiscardedEvent extends Event{paymentTokenId;static type="payment-token-discarded";constructor(e){super(XenditPaymentTokenDiscardedEvent.type,{}),this.paymentTokenId=e}}const I=Symbol("xendit-internal"),T=n=>e("div",{class:"xendit-accordion",children:n.children}),D=t=>{const{id:i,title:a,subtitle:r,disabled:o,open:s,onClick:l,children:c}=t,u=s?"up":"down",h=d(()=>{o||l(i)},[o,l,i]),p=d(e=>{"Enter"!==e.key&&" "!==e.key||(h(),e.preventDefault())},[h]),m=d(()=>{h()},[h]);return n("div",{className:b("xendit-accordion-item",o?"xendit-accordion-item-disabled":"",s?"xendit-accordion-item-open":"xendit-accordion-item-closed"),children:[n("div",{className:"xendit-accordion-item-header",onClick:m,onKeyDown:p,role:"button",tabIndex:o?-1:0,children:[e(P,{className:"xendit-accordion-item-header-icon",name:"dummy",size:24}),n("div",{className:"xendit-accordion-item-header-title xendit-text-16 xendit-text-bold",children:[a,r?e("div",{className:"xendit-accordion-item-header-subtitle xendit-text-14",children:r}):null]}),e(P,{className:"xendit-accordion-item-chevron",name:"chevron",size:24,direction:u})]}),e("div",{className:"xendit-accordion-item-content",inert:!s,children:e("div",{className:"xendit-accordion-item-padding",children:c})})]})},M=r(null);M.displayName="SessionContext";const U=r(null);U.displayName="BusinessContext";const L=r(null);L.displayName="CustomerContext";const O=r(null);O.displayName="ChannelsContext";const q=r(null);q.displayName="ChannelUiGroupsContext";const B=r(null);B.displayName="DigitalWalletsContext";const V=r(null);V.displayName="SdkContext";const K=r(null);K.displayName="CurrentChannelContext";const W=()=>{const e=c(M);if(null===e)throw new Error("useSession must be used within a XenditSessionProvider");return e},F=()=>{const e=c(O);if(null===e)throw new Error("useChannels must be used within a XenditSessionProvider");return e},$=()=>c(B),G=()=>{const e=c(V);if(null===e)throw new Error("useSdk must be used within a XenditSessionProvider");return e},X=()=>c(K),H=({children:n,data:t,sdk:i})=>{const{session:a,business:r,customer:o,channels:s,digitalWallets:l,channelUiGroups:d}=t,c=i.getCurrentChannel()?.[I]?.[0]??null;return"ACTIVE"!==i.getSdkStatus()||"ACTIVE"!==a.status?null:e(V.Provider,{value:i,children:e(K.Provider,{value:c,children:e(M.Provider,{value:a,children:e(U.Provider,{value:r,children:e(L.Provider,{value:o,children:e(O.Provider,{value:s,children:e(B.Provider,{value:l,children:e(q.Provider,{value:d,children:n})})})})})})})})},Y=300;function z(e){if(null==e)throw new Error("Assertion failed: argument is null or undefined; this is a bug, please contact support.")}function j(e){if(!Array.isArray(e))throw new Error("Assertion failed: expected array; this is a bug, please contact support.")}function Z(e){if(Array.isArray(e))throw new Error("Assertion failed: expected array; this is a bug, please contact support.")}function Q(e,n){if(e!==n)throw new Error("Assertion failed; this is a bug, please contact support.")}function J(e){return new Promise(n=>setTimeout(n,1*e))}class AbortError extends Error{constructor(){super("AbortError"),this.name="AbortError"}}function ee(e){return e instanceof AbortError&&"AbortError"===e.name}function ne(e,n){return new Promise((t,i)=>{function a(){n.removeEventListener("abort",a),clearTimeout(r),i(new AbortError)}const r=setTimeout(()=>{n.removeEventListener("abort",a),t()},1*e);n.aborted?a():n.addEventListener("abort",a)})}function te(e){const n=e.find(e=>{switch(e.type){case"REDIRECT_CUSTOMER":switch(e.descriptor){case"WEB_URL":return!0;case"DEEPLINK_URL":return function(){const e=navigator.userAgent;if(!e)return!1;if(/android/i.test(e))return!0;if(/iPad|iPhone|iPod/.test(e))return!0;return!1}();case"WEB_GOOGLE_PAYLINK":return!1}break;case"PRESENT_TO_CUSTOMER":return!0;case"API_POST_REQUEST":return!1}return!1});return n||e[0]}function ie(e,n){if(e[I].options.enablePaylinks)return n.find(e=>"REDIRECT_CUSTOMER"===e.type&&"WEB_GOOGLE_PAYLINK"===e.descriptor)}const ae="mock",re={pl:"https://checkout-ui-gateway.xendit.co",pd:"https://checkout-ui-gateway-prod-dev.xendit.co",sl:"https://checkout-ui-gateway-live.stg.tidnex.dev",sd:"https://checkout-ui-gateway-dev.stg.tidnex.dev"};function oe(e){return re[e]??null}function se(e,n){const t={...e};for(const e of Object.keys(n)){const i=n[e];void 0!==i&&(t[e]=i)}return t}function le(e){const n=u();return h(()=>{n.current=e}),n.current}function de(e){let n;if("string"==typeof e.channel_property)n=e.channel_property;else{n=Object.values(e.channel_property).join("__")}return n}const ce=Math.floor(255*Math.random());function ue(e){return`xendit-id-${de(e).split("").map(e=>(e.charCodeAt(0)%256^ce).toString(16)).join("")}`}function he(e){z(e%2==0);const n=function(e){const n=new Uint8Array(e);for(let t=0;t<e;t++)n[t]=Math.floor(256*Math.random());return n}(e/2);return Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join("")}function pe(){return[he(8),he(4),he(4),he(4),he(12)].join("-")}function me(){return`xendit-id-${u(he(12)).current}`}function _e(e){return"PRESENT_TO_CUSTOMER"===e.type}function fe(e){if(e instanceof Error)return e.stack??e.message;if("string"==typeof e)return e;try{return`Unknown error: ${JSON.stringify(e)}`}catch{return"Unknown error"}}function be(e){for(const n of Object.keys(e)){if("symbol"==typeof n)continue;const t=Object.getOwnPropertyDescriptor(e,n);void 0!==t&&("function"!=typeof t.get&&void 0===t.value&&delete e[n])}return e}function ye(e,n){let t=e;if(!n)return;if(Array.isArray(t))throw new Error("Getting values from channel property arrays is not supported.");let i=n;for(;;){if(!i||"object"!=typeof i||Array.isArray(i))return;const e=t.indexOf(".");if(-1===e)return i?i[t]:void 0;{const n=t.slice(0,e);i=i?i[n]:void 0,t=t.slice(e+1)}}}function xe(e){const n=ye("card_details.card_number",e);return"string"!=typeof n?null:n}function ge(e){const n={version:0,publicKey:"",iv:"",cipherText:"",valid:!1,validationError:null,withoutValidationError:e};if(!e)return n;const t=e.split("-");if(t.length<6)throw new Error("Invalid encrypted field value format.");if("xendit"!==t[0])throw new Error("Invalid encrypted field value format.");if("encrypted"!==t[1])throw new Error("Invalid encrypted field value format.");const i=parseInt(t[2],10);if(isNaN(i)||i<=0)throw new Error("Invalid encrypted field value format.");if(n.version=i,n.publicKey=t[3],n.iv=t[4],n.cipherText=t[5],t.length>6){if("invalid"!==t[6])throw new Error("Invalid encrypted field value format.");n.validationError=atob(t[7]),n.withoutValidationError=t.slice(0,6).join("-")}else n.valid=!0;return n}const ve=new WeakMap;let ke=1;function we(e,n){return z(e.length>0),z(e.length<=2),2===e.length?n?(z(!0===e[1].allow_save),e[1]):(z(!1===e[0].allow_save),e[0]):e[0]}function Ce(e,n){if("PAY"!==e.session_type)return!0;const t=e.amount,i=n.min_amount??0,a=n.max_amount??Number.MAX_VALUE;return!(t<i||t>a)}function Ee(e){Object.defineProperty(e,I,{enumerable:!1,writable:!1,configurable:!1,value:e[I]})}const Ae={CARDS:!0,QRIS:!0,QR_PH:!0,PROMPTPAY:!0,SGQR:!0};function Pe(e,n){for(const t of e)if(t.type.name===n)return!0;return!1}var Se,Ne;!function(e){e.BARE="bare",e.PRIMARY_ROUNDED="primary-rounded",e.WHITE_ROUNDED="white-rounded"}(Se||(Se={})),function(e){e.SM="sm",e.MD="md"}(Ne||(Ne={}));const Re=n=>{const{children:t,variant:i,size:a,type:r="button",...o}=n,s={[Se.BARE]:void 0,[Se.PRIMARY_ROUNDED]:"xendit-button-primary-rounded",[Se.WHITE_ROUNDED]:"xendit-button-white-rounded"}[i],l={[Ne.SM]:"xendit-button-sm",[Ne.MD]:void 0}[a??Ne.MD];return e("button",{...o,className:b(n.className,"xendit-button",s,l),type:r,children:t})},Ie=()=>{const n=.4*Math.PI,t=.4,i=Math.cos(n)*t,a=Math.sin(n)*t,r=Math.cos(0)*t,o=Math.sin(0)*t;return e("svg",{className:"xendit-button-loading-spinner",viewBox:"-0.5 -0.5 1 1",children:e("path",{d:`M ${i} ${a} A 0.4 0.4 0 0 0 ${r} ${o}`,fill:"none",stroke:"currentColor",strokeWidth:"0.1",strokeLinecap:"round"})})},Te=t=>{const{id:i,options:a,onChange:r,defaultIndex:o=-1,selectedIndex:s,className:l,placeholder:c,disabled:_}=t,f=G().t,b=me(),y=i||b,x="number"==typeof s,[g,v]=p(o),k=x?s:g,[w,C]=p(k>=0?k:0),[E,A]=p(!1),S=E&&!_&&a.length>0,[N,R]=p(""),I=u(null),T=u(null),D=u(null),M=u(null),U=u(null),L=m(()=>{const e=a.map(Ue).filter(({item:e})=>{if(""===N.trim())return!0;const n=N.toLowerCase();return e.title.toLowerCase().includes(n)||e.description?.toLowerCase().includes(n)||e.value.toLowerCase().includes(n)});return e.length>0?e:a.map(Ue)},[N,a]),O=Math.max(0,Math.min(L.length-1,w));h(()=>{if(!S)return;const e=e=>{const n=I.current;n&&(n.contains(e.target)||A(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[S]),h(()=>{if(!S)return;const e=e=>{const n=I.current;n&&e.relatedTarget&&(n.contains(e.relatedTarget)||A(!1))};return document.body.addEventListener("focusout",e),()=>document.body.removeEventListener("focusout",e)},[S]),h(()=>{S&&k>=0&&C(k)},[S,k]),h(()=>{if(!S)return;if(!M.current)return;if(!D.current)return;const e=D.current.parentElement;e&&(e.scrollTop=M.current.offsetTop-e.clientHeight/2+M.current.clientHeight/2)},[S,w]);const q=d(()=>{S||(A(!0),queueMicrotask(()=>U.current?.focus()))},[S]),B=d(()=>{S&&(A(!1),R(""),T.current?.focus())},[S]),V=d(()=>{S?B():q()},[B,S,q]),K=d(e=>{const n=a[e];n&&(n.disabled||(x||v(e),r(n,e),B()))},[B,x,r,a]),W=d(e=>{"ArrowDown"!==e.key&&"ArrowUp"!==e.key&&" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),q())},[q]),F=d(e=>{const n=e.target===U.current;if("Escape"===e.key)return e.preventDefault(),void B();if("Enter"===e.key||" "===e.key){if(n&&" "===e.key)return;e.preventDefault();const t=L[O];return void(t&&K(t.originalIndex))}return"ArrowDown"===e.key?(e.preventDefault(),void C(e=>Math.min(L.length-1,e+1))):"ArrowUp"===e.key?(e.preventDefault(),void C(e=>Math.max(0,e-1))):"Home"===e.key?(e.preventDefault(),void C(0)):"End"===e.key?(e.preventDefault(),void C(L.length-1)):void 0},[O,B,K,L]),$=d(e=>{e.stopPropagation(),e.preventDefault(),K(Number(e.currentTarget.dataset.index))},[K]),X=d(e=>{R(e.currentTarget.value),C(0)},[]),H=k>=0?a[k]:void 0;return n("div",{ref:I,className:`xendit-dropdown ${l??""}`,children:[n("button",{id:y,ref:T,type:"button",className:H?.leadingAsset?"xendit-dropdown-has-asset":"","aria-expanded":S?"true":"false",onClick:V,onKeyDown:W,disabled:_,children:[H?.leadingAsset?H.leadingAsset:null,e("span",H?{className:"xendit-dropdown-button-title xendit-text-14",children:H.shortTitle??H.title}:{className:"xendit-dropdown-button-title xendit-text-14",children:c}),e(P,{className:"xendit-dropdown-chevron",name:"chevron",size:16,direction:"down"})]}),S?n("div",{className:"xendit-dropdown-menu",children:[e("div",{className:"xendit-dropdown-search",children:e("input",{ref:U,placeholder:f("combobox.default_search_placeholder"),value:N,onInput:X,onClick:Me,onKeyDown:F})}),e("ul",{ref:D,role:"listbox",tabIndex:-1,onKeyDown:F,children:L.map(({item:t,originalIndex:i},a)=>{const r=i===k,o=a===O;return e("li",{role:"option","data-index":i,"aria-disabled":!!t.disabled||void 0,"aria-selected":r,onClick:$,ref:o?M:void 0,children:n("div",{className:`xendit-dropdown-item xendit-text-14 ${o?"xendit-dropdown-item-active":""} ${t.leadingAsset?"xendit-dropdown-has-asset":""} ${t.disabled?"xendit-dropdown-item-disabled":""}`,children:[t.leadingAsset?t.leadingAsset:null,n("div",{className:"xendit-dropdown-item-text xendit-text-14",children:[e("span",{className:"xendit-dropdown-item-title",children:t.title}),t.description&&e("span",{className:"xendit-dropdown-item-description xendit-text-12",children:t.description})]}),r?e(P,{name:"check",size:16,className:"xendit-dropdown-item-selected"}):null]})},i)})})]}):null]})},De=n=>e("div",{className:"xendit-dropdown xendit-skeleton-field",children:e("button",{inert:!0,id:n.id,disabled:!0,type:"button",children:e(Ie,{})})});function Me(e){e.stopPropagation()}function Ue(e,n){return{item:e,originalIndex:n}}function Le(e){return function(e,n){if(e===n)throw new Error("Assertion failed; this is a bug, please contact support.")}(e.session_type,"AUTHORIZATION"),Q(e.mode,"COMPONENTS"),be({id:e.payment_session_id,description:e.description||void 0,sessionType:e.session_type,mode:e.mode,referenceId:e.reference_id,country:e.country,currency:e.currency,amount:e.amount,channelProperties:e.channel_properties||void 0,expiresAt:new Date(e.expires_at),locale:e.locale,status:e.status,items:e.items?.map(e=>be({type:e.type,referenceId:e.reference_id,name:e.name,netUnitAmount:e.net_unit_amount,quantity:e.quantity,url:e.url,imageUrl:e.image_url,category:e.category,subcategory:e.subcategory,description:e.description,metadata:e.metadata}))})}function Oe(e,n,t,i){const a=be({groupId:e.id,label:e.label,get channels(){return(n[e.id]||[]).map(e=>Be(e,n,t,i))},[I]:e});return Ee(a),a}function qe(e,n){return Be(e,{},{},n)}function Be(e,n,t,i){z(!i.pairChannels.paired[e.channel_code]);const a=be({channelCode:i.pairChannels.pairs[e.channel_code]?.map(e=>e.channel_code)??e.channel_code,brandName:e.brand_name,brandColor:e.brand_color,brandLogoUrl:e.brand_logo_url,get uiGroup(){if(!t[e.ui_group])throw new Error("UI group not found");return Oe(t[e.ui_group],n,t,i)},minAmount:e.min_amount,maxAmount:e.max_amount,cardBrands:e.card?.brands.map(e=>({name:e.name,logoUrl:e.logo_url})),[I]:i.pairChannels.pairs[e.channel_code]??[e]});return Ee(a),a}function Ve(e){const n={};for(const t of e)n[t.id]=t;return n}function Ke(e,n){if(n.pairChannels.paired[e.channel_code])return!1;if(n.options.filterMinMax&&!Ce(n.session,e))return!1;const t=n.options.filter;return!(t&&!function(e,n){if("string"==typeof e&&n===e)return!0;if(Array.isArray(e)&&e.includes(n))return!0;if(e instanceof RegExp&&e.test(n))return!0;return!1}(t,e.channel_code))}function We(e,n){const t={};for(const i of e){if(!Ke(i,n))continue;const e=i.ui_group;t[e]||(t[e]=[]),t[e].push(i)}return t}function Fe(e){const n=new Map;for(const t of e){const e=t.brand_name;n.has(e)||n.set(e,[]),n.get(e).push(t)}const t={},i={};for(const[e,a]of n)for(const e of a){if(!1===a[0].allow_save){const n=a.find(n=>e.channel_code!==n.channel_code&&e.ui_group===n.ui_group&&!0===n.allow_save);n&&(t[e.channel_code]=[e,n],i[n.channel_code]=!0)}}return{pairs:t,paired:i}}const $e=t=>{const{group:i,open:a}=t,r=G(),{t:o}=r,s=W(),l=F(),c=X(),_=s.session_type,f=me(),[b,y]=p(null),x=u(null),[g,v]=p(!1),k=u(null),w=m(()=>Fe(l),[l]),C=m(()=>({pairChannels:w,session:{amount:s.amount,session_type:s.session_type},options:{filterMinMax:!1}}),[w,s.amount,s.session_type]),E=m(()=>l.filter(e=>Ke(e,C)&&e.ui_group===i.id),[l,i.id,C]);h(()=>{if(!x.current)return;if(!c)return;if(!a)return;E.find(e=>e.channel_code===c.channel_code)&&(k.current=r.createChannelComponent(qe(c,C)),k.current.parentElement!==x.current&&(v(!0),x.current.replaceChildren(k.current)))},[E,c,C,a,r]);const A=le(a);h(()=>{if(a&&!A&&null===c&&null!==b){const e=E.find(e=>e.channel_code===b);e&&r.setCurrentChannel(qe(e,C))}},[E,c,b,C,a,A,r]);const P=d(e=>{const n=l.find(n=>n.channel_code===e.value)||null;y(n?.channel_code??null),r.setCurrentChannel(n?qe(n,C):null)},[l,C,r]),S=m(()=>E.map(n=>({leadingAsset:e("img",{className:"xendit-channel-logo",src:n.brand_logo_url},n.channel_code),title:n.brand_name,value:n.channel_code,disabled:!Ce(s,n),description:Ge(o,s,n)||void 0})),[E,s,o]),N=1===E.length&&"CARDS"===E[0].channel_code;return n("div",{className:"xendit-channel-picker-group",children:[N?null:n("div",{className:"xendit-channel-form-field-group",children:[e("label",{htmlFor:f,className:"xendit-text-14",children:"SAVE"===_?o("payment_methods.add_payment_method",{groupName:i.label??"",ns:"session"}):o("payment_methods.pay_with")}),e(Te,{id:f,selectedIndex:function(){const e=S.findIndex(e=>e.value===c?.channel_code);if(-1!==e)return e;const n=S.findIndex(e=>e.value===b);return-1!==n?n:-1}(),options:S,disabled:S.length<=1,onChange:P,placeholder:o("payment_methods.select_channel_placeholder",{groupName:i.label,ns:"session"})})]}),e("div",{style:{display:g?"":"none"},ref:x})]})};function Ge(e,n,t){return Ce(n,t)?null:t.min_amount&&n.amount<t.min_amount?e("payment_methods.channel_disabled_amount_too_small"):e("payment_methods.channel_disabled_amount_too_large")}const Xe=n=>{const t=G(),i=u(null),a=$(),r=a?.google_pay;return h(()=>{if(i.current&&r){const e=t.createDigitalWalletComponent("GOOGLE_PAY");return i.current.appendChild(e),()=>{e.remove()}}},[r,t]),e("div",{ref:i,className:"xendit-channel-picker-digital-wallet-section"})},He=t=>{const i=G(),a=W(),r=(()=>{const e=c(q);if(null===e)throw new Error("useChannelUiGroups must be used within a XenditSessionProvider");return e})(),o=X(),s=F(),{t:l}=G(),_=m(()=>We(s,{options:{filterMinMax:!1},pairChannels:Fe(s),session:a}),[s,a]),f=u(null),b=m(()=>Fe(s),[s]),y=m(()=>({pairChannels:b,session:{amount:a.amount,session_type:a.session_type},options:{filterMinMax:!1}}),[b,a.amount,a.session_type]),x=o?.ui_group??null,[g,v]=p(null),k=d(e=>{if(x===e||g===e)x===e&&f.current?.dispatchEvent(new XenditClearCurrentChannelEvent(e)),g===e&&v(null);else{const n=r.find(n=>n.id===e);z(n);const t=Ye(a,n,s,l).enabledChannels;if(0===t)return;if(1===t){const n=_[e][0];i.setCurrentChannel(qe(n,y)),v(null)}else v(e),i.setCurrentChannel(null)}},[r,s,_,y,g,i,x,a,l]);h(()=>{null!==o&&null!==g&&v(null)},[o,g]);const w=i[I].options.enableDigitalWallets??!1;return n("div",{ref:f,children:[w?e(Xe,{}):null,e(T,{children:r.filter(e=>(_[e.id]||[]).length>0).map(n=>{const t=null!==x?x===n.id:g===n.id,i=Ye(a,n,s,l),r=0===i.enabledChannels,o=i.firstDisabledChannelReason;return e(D,{id:n.id,title:n.label,subtitle:o??void 0,open:t,disabled:r,onClick:k,children:e($e,{group:n,open:t})},n.id)})})]})};function Ye(e,n,t,i){let a=null,r=0;for(const o of t)o.ui_group===n.id&&(Ce(e,o)?r++:null===a&&(a=Ge(i,e,o)));return{enabledChannels:r,firstDisabledChannelReason:a}}class XenditClearCurrentChannelEvent extends Event{static type="xendit-clear-current-channel";uiGroup;constructor(e){super(XenditClearCurrentChannelEvent.type,{bubbles:!0,composed:!0}),this.uiGroup=e}}const ze=({countryCode:n,size:t=16})=>e("div",{style:{width:`${t}px`,height:`${t}px`,borderRadius:"50%",backgroundImage:`url(https://assets.xendit.co/payment-session/flags/circle/${n.toLowerCase()}.svg)`,backgroundSize:"cover",backgroundPosition:"center"}}),je=t=>{const{field:i,onChange:a}=t,r=ue(i),o=de(i),[s,l]=p(void 0),c=Ze.findIndex(e=>e.value===s),h=u(null);Qe(e=>{if(h.current){const n=Ze.find(n=>n.value===e);n&&m(n)}});const m=d(e=>{l(e.value),h.current&&(h.current.value=e.value),a()},[a]);return n("div",{children:[e("input",{type:"hidden",name:o,defaultValue:"",ref:h}),e(Te,{id:r,options:Ze,onChange:m,placeholder:i.placeholder,selectedIndex:c})]})},Ze=x().map(n=>({title:new Intl.DisplayNames(["en"],{type:"region"}).of(n),value:n,leadingAsset:e(ze,{countryCode:n})})).sort((e,n)=>e.title.localeCompare(n.title));function Qe(e){const n=bt()?.cardDetails,t=n?.details?.country_codes[0],i=le(t);h(()=>{t&&t!==i&&e(t)})}const Je=i=>{const{field:a,onChange:r}=i,o=ue(a),s=de(a),l=u(null),c=d(e=>{l.current&&(l.current.value=e.value),r()},[r]);if(!function(e){return"dropdown"===e.type.name}(a))throw new Error("DropdownField expects field.type.name to be 'dropdown'");return n(t,{children:[e(Te,{id:o,placeholder:a.placeholder,options:(h=a.type.options,h.map(e=>({title:e.label,description:e.subtitle,value:e.value}))),onChange:c}),e("input",{type:"hidden",name:s,defaultValue:"",ref:l})]});var h};const en="undefined"!=typeof window&&window.HTMLElement?window.HTMLElement:EventTarget;class XenditFormAssociatedFocusTrap extends en{static tag="xendit-form-associated-focus-trap";static formAssociated=!0;internals;constructor(){super(),this.internals=this.attachInternals()}}var nn;nn=XenditFormAssociatedFocusTrap,"undefined"!=typeof window&&window.customElements&&customElements.define(nn.tag,nn);class InternalUpdateWorldState extends Event{data;static type="xendit-update-world-state";constructor(e){super(InternalUpdateWorldState.type,{bubbles:!1}),this.data=e}}class InternalUpdateChannelComponentData extends Event{channelCode;data;static type="xendit-update-channel-component-data";constructor(e,n){super(InternalUpdateChannelComponentData.type,{bubbles:!1}),this.channelCode=e,this.data=n}}class InternalSetFieldTouchedEvent extends Event{static type="xendit-internal-set-field-touched";constructor(){super(InternalSetFieldTouchedEvent.type,{bubbles:!0})}}class InternalBehaviorTreeUpdateEvent extends Event{static type="xendit-internal-behavior-tree-update";constructor(){super(InternalBehaviorTreeUpdateEvent.type,{})}}class InternalNeedsRerenderEvent extends Event{static type="xendit-internal-needs-rerender";constructor(){super(InternalNeedsRerenderEvent.type,{})}}class InternalScheduleMockUpdateEvent extends Event{mockData;static type="xendit-internal-schedule-mock-update";constructor(e){super(InternalScheduleMockUpdateEvent.type,{}),this.mockData=e}}const tn=r(null);z("https://assets.xendit.co/components/secure-iframe-v0.0.17.html");const an=new URL("https://assets.xendit.co/components/secure-iframe-v0.0.17.html").origin,rn=({children:n})=>{const t=u(new Map),i={registerIframe:(e,n)=>{n.current&&t.current.set(e,n.current)},unregisterIframe:e=>t.current.delete(e),postMessageToIframe:(e,n)=>{const i=t.current.get(e);i?.contentWindow&&i.contentWindow.postMessage(n,an)}};return e(tn.Provider,{value:i,children:n})};z("https://assets.xendit.co/components/secure-iframe-v0.0.17.html");const on=new URL("https://assets.xendit.co/components/secure-iframe-v0.0.17.html"),sn=on.toString(),ln=on.origin,dn=t=>{const{field:i,onChange:a}=t,r=G(),o=ue(i),s=de(i),l=W(),m=u(null),_=u(null),[f,b]=p(),[y,x]=p(!1),[g,v]=p(null),{card:k}=_t()??{},w=d(e=>{if(!m.current)return;const n=m.current.contentWindow;if(e.source!==n)return;if(e.origin!==ln)return;const t=e.data;switch(t.type){case"xendit-iframe-ready":b(t.ecdhPublicKey);break;case"xendit-iframe-change":{if(!_.current)return;v(t.cardBrand);const e=t.encrypted,n=1,i=e.map(e=>{if(t.empty)return"";const i=["xendit-encrypted",n,f,e.iv,e.value];return!t.valid&&t.validationErrorCodes.length&&i.push("invalid",btoa(t.validationErrorCodes[0].localeKey)),i.join("-")});if(0===i.length)break;_.current.value=i.length>1?JSON.stringify(i):i[0],a?.();break}case"xendit-iframe-focus":x(!0);break;case"xendit-iframe-blur":x(!1),_.current?.value&&_.current?.dispatchEvent(new InternalSetFieldTouchedEvent);break;case"xendit-iframe-failed-init":console.error(`Iframe field for ${i.channel_property} failed to initialize securely`)}},[i.channel_property,f,a]),C=d(()=>{m.current?.contentWindow&&m.current.contentWindow.postMessage({type:"xendit-iframe-focus"},ln)},[]);h(()=>(window.addEventListener("message",w),()=>{window.removeEventListener("message",w)}),[w]);const E=c(tn);h(()=>(E?.registerIframe(s,m),()=>E?.unregisterIframe(s)),[s,E]);const A=new URL(sn);A.searchParams.set("input_type",i.type.name),A.searchParams.set("embedder",window.location.origin),A.searchParams.set("session_id",l.payment_session_id),A.searchParams.set("pk",r[I].sdkKey.publicKey),A.searchParams.set("sig",r[I].sdkKey.signature),r[I].options.iframeFieldAppearance&&A.searchParams.set("appearance",JSON.stringify(r[I].options.iframeFieldAppearance));return n("div",{className:`xendit-iframe-container ${y?"xendit-field-focus":""}`,children:[e(XenditFormAssociatedFocusTrap.tag,{id:o,onFocus:C,tabIndex:-1}),e("input",{type:"hidden",name:s,defaultValue:"",ref:_}),e("iframe",{src:A.toString(),ref:m,sandbox:"allow-scripts allow-same-origin"}),"credit_card_number"===i.type.name&&k&&e(cn,{cardsBrandList:k.brands,selectedCardBrand:g})]})},cn=({cardsBrandList:n,selectedCardBrand:t})=>{if(!n)return null;const i=n.find(e=>e.name===t)?.logo_url;return e("div",{className:"xendit-card-brands-list",children:t?i&&e("img",{className:"xendit-card-brand-logo",src:i,alt:t}):n.map(({name:n,logo_url:t})=>e("img",{className:"xendit-card-brand-logo",src:t,alt:n},n))})},un=t=>{const{field:i,onChange:a}=t,r=ue(i),o=de(i),s=W(),l=u(null),[c,h]=p(s.country),_=m(()=>{const e=hn.findIndex(e=>e.value===c);return-1===e?0:e},[c]),f=hn[_],[b,y]=p(""),x=u(null),v=d((e,n)=>{const t=pn(e,n);return t?t.number:`+${e.dial}${n}`},[]),C=d((e,n)=>{l.current&&(l.current.value=v(e,n))},[v]);function E(e){const n=e;h(n.value),C(n,b),a()}return Qe(e=>{const n=hn.find(n=>n.value===e);n&&n.value!==c&&!b&&E(n)}),n("div",{className:"xendit-input-phone",children:[e(Te,{options:hn,selectedIndex:_,onChange:E}),e("input",{id:r,ref:x,type:"tel",inputMode:"tel",placeholder:g(f.value,w)?.formatInternational()?.replace(`+${k(f.value)} `,"")||"",className:"xendit-text-14 xendit-phone-number-input",onBlur:function(e){!function(){const e=pn(f,b);if(e){const n=e.formatInternational();y(n.replace(`+${k(f.value)} `,""))}}(),e.currentTarget?.value&&l.current?.dispatchEvent(new InternalSetFieldTouchedEvent)},onChange:function(e){const n=e.target.value;y(n),C(f,n),a()},value:b,autoComplete:"tel"}),e("input",{type:"hidden",name:o,ref:l})]})},hn=Ze.map(e=>{const n=k(e.value);return n?{...e,shortTitle:`+${n}`,title:`${e.title} (+${n})`,dial:n}:null}).filter(e=>Boolean(e)),pn=(e,n)=>{const t=y(n,e.value);return t&&t.isPossible()?t:null};function mn(e){return{title:e.name,value:e.value}}const _n=[{name:"Alabama",value:"AL"},{name:"Alaska",value:"AK"},{name:"American Samoa",value:"AS"},{name:"Arizona",value:"AZ"},{name:"Arkansas",value:"AR"},{name:"California",value:"CA"},{name:"Colorado",value:"CO"},{name:"Connecticut",value:"CT"},{name:"Delaware",value:"DE"},{name:"District Of Columbia",value:"DC"},{name:"Federated States Of Micronesia",value:"FM"},{name:"Florida",value:"FL"},{name:"Georgia",value:"GA"},{name:"Guam",value:"GU"},{name:"Hawaii",value:"HI"},{name:"Idaho",value:"ID"},{name:"Illinois",value:"IL"},{name:"Indiana",value:"IN"},{name:"Iowa",value:"IA"},{name:"Kansas",value:"KS"},{name:"Kentucky",value:"KY"},{name:"Louisiana",value:"LA"},{name:"Maine",value:"ME"},{name:"Marshall Islands",value:"MH"},{name:"Maryland",value:"MD"},{name:"Massachusetts",value:"MA"},{name:"Michigan",value:"MI"},{name:"Minnesota",value:"MN"},{name:"Mississippi",value:"MS"},{name:"Missouri",value:"MO"},{name:"Montana",value:"MT"},{name:"Nebraska",value:"NE"},{name:"Nevada",value:"NV"},{name:"New Hampshire",value:"NH"},{name:"New Jersey",value:"NJ"},{name:"New Mexico",value:"NM"},{name:"New York",value:"NY"},{name:"North Carolina",value:"NC"},{name:"North Dakota",value:"ND"},{name:"Northern Mariana Islands",value:"MP"},{name:"Ohio",value:"OH"},{name:"Oklahoma",value:"OK"},{name:"Oregon",value:"OR"},{name:"Palau",value:"PW"},{name:"Pennsylvania",value:"PA"},{name:"Puerto Rico",value:"PR"},{name:"Rhode Island",value:"RI"},{name:"South Carolina",value:"SC"},{name:"South Dakota",value:"SD"},{name:"Tennessee",value:"TN"},{name:"Texas",value:"TX"},{name:"Utah",value:"UT"},{name:"Vermont",value:"VT"},{name:"Virgin Islands",value:"VI"},{name:"Virginia",value:"VA"},{name:"Washington",value:"WA"},{name:"West Virginia",value:"WV"},{name:"Wisconsin",value:"WI"},{name:"Wyoming",value:"WY"}].map(mn),fn=[{name:"Alberta",value:"AB"},{name:"British Columbia",value:"BC"},{name:"Manitoba",value:"MB"},{name:"New Brunswick",value:"NB"},{name:"Newfoundland and Labrador",value:"NL"},{name:"Northwest Territories",value:"NT"},{name:"Nova Scotia",value:"NS"},{name:"Nunavut",value:"NU"},{name:"Ontario",value:"ON"},{name:"Prince Edward Island",value:"PE"},{name:"Quebec",value:"QC"},{name:"Saskatchewan",value:"SK"},{name:"Yukon Territory",value:"YT"}].map(mn),bn=[{name:"Avon"},{name:"Bedfordshire"},{name:"Berkshire"},{name:"Buckinghamshire"},{name:"Cambridgeshire"},{name:"Cheshire"},{name:"Cleveland"},{name:"Cornwall"},{name:"Cumbria"},{name:"Derbyshire"},{name:"Devon"},{name:"Dorset"},{name:"Durham"},{name:"East Sussex"},{name:"Essex"},{name:"Gloucestershire"},{name:"Hampshire"},{name:"Herefordshire"},{name:"Hertfordshire"},{name:"Isle of Wight"},{name:"Kent"},{name:"Lancashire"},{name:"Leicestershire"},{name:"Lincolnshire"},{name:"London"},{name:"Merseyside"},{name:"Norfolk"},{name:"Northamptonshire"},{name:"Northumberland"},{name:"North Yorkshire"},{name:"Nottinghamshire"},{name:"Oxfordshire"},{name:"Rutland"},{name:"Shropshire"},{name:"Somerset"},{name:"South Yorkshire"},{name:"Staffordshire"},{name:"Suffolk"},{name:"Surrey"},{name:"Tyne and Wear"},{name:"Warwickshire"},{name:"West Midlands"},{name:"West Sussex"},{name:"West Yorkshire"},{name:"Wiltshire"},{name:"Worcestershire"},{name:"Clwyd"},{name:"Dyfed"},{name:"Gwent"},{name:"Gwynedd"},{name:"Mid Glamorgan"},{name:"Powys"},{name:"South Glamorgan"},{name:"West Glamorgan"},{name:"Aberdeenshire"},{name:"Angus"},{name:"Argyll"},{name:"Ayrshire"},{name:"Banffshire"},{name:"Berwickshire"},{name:"Bute"},{name:"Caithness"},{name:"Clackmannanshire"},{name:"Dumfriesshire"},{name:"Dunbartonshire"},{name:"East Lothian"},{name:"Fife"},{name:"Inverness-shire"},{name:"Kincardineshire"},{name:"Kinross-shire"},{name:"Kirkcudbrightshire"},{name:"Lanarkshire"},{name:"Midlothian"},{name:"Moray"},{name:"Nairnshire"},{name:"Orkney"},{name:"Peeblesshire"},{name:"Perthshire"},{name:"Renfrewshire"},{name:"Ross-shire"},{name:"Roxburghshire"},{name:"Selkirkshire"},{name:"Shetland"},{name:"Stirlingshire"},{name:"Sutherland"},{name:"West Lothian"},{name:"Wigtownshire"},{name:"Antrim"},{name:"Armagh"},{name:"Down"},{name:"Fermanagh"},{name:"Londonderry"},{name:"Tyrone"}].map(e=>({title:e.name,value:e.name})),yn=i=>{const{field:a,onChange:r}=i,o=ue(a),s=de(a),l=W(),c=_t()?.form,p=Jn(),m=u(null),_=d(()=>{m.current&&(m.current.value=""),r()},[r]),f=d(e=>{m.current&&(m.current.value=e.value),r(),m.current?.dispatchEvent(new InternalSetFieldTouchedEvent)},[r]),b=d(e=>{m.current&&(m.current.value=e.target.value),r(),m.current?.dispatchEvent(new InternalSetFieldTouchedEvent)},[r]),y=function(e){switch(e){case"US":return _n;case"CA":return fn;case"GB":return bn;default:return null}}(function(e,n,t,i){if(n)for(let i=0;i<n.length;i++){const a=n[i];if(i>0&&a===e){const e=n[i-1];if("country"===e.type.name){const n=ye(e.channel_property,t);if(n&&"string"==typeof n)return n}}}return i.country}(a,c??[],p??{},l)),x=le(y);return h(()=>{x!==y&&_()},[_,y,x]),n(t,{children:[e("input",{type:"hidden",name:s,defaultValue:"",ref:m}),y?e(Te,{id:o,options:y,onChange:f,placeholder:a.placeholder},(g=y,ve.has(g)||ve.set(g,ke++),ve.get(g).toString())):e("input",{type:"text",id:o,onChange:b,placeholder:a.placeholder,className:"xendit-input xendit-text-14"})]});var g};const xn=n=>{const{field:t,onChange:i}=n,a=ue(t),r=de(t),o=u(null);return e("input",{id:a,name:r,ref:o,type:"text",placeholder:t.placeholder,className:"xendit-text-14",onBlur:function(e){e.currentTarget?.value&&o.current?.dispatchEvent(new InternalSetFieldTouchedEvent)},onChange:function(e){i()},minLength:gn(t)?t.type.min_length:void 0,maxLength:gn(t)?t.type.max_length:void 0,autoComplete:gn(t)?t.type.autocomplete:void 0})};function gn(e){return"text"===e.type.name}const vn={IDR:"id",VND:"vi",BRL:"pt-BR",RUB:"ru",CZK:"cs",RON:"ro",UAH:"uk",CLP:"es-CL",COP:"es-CO",UYU:"es-UY",ARS:"es-AR",INR:"hi-IN",NPR:"hi-IN",LKR:"hi-IN",BDT:"hi-IN"},kn={USD:"US$",CAD:"CA$",EUR:"€",AFN:"؋",ALL:"Lek",AMD:"֏",ARS:"AR$",AUD:"AU$",AZN:"₼",BAM:"KM",BDT:"৳",BIF:"FBu",BND:"BN$",BOB:"Bs",BRL:"R$",BWP:"P",BYN:"Br",BZD:"BZ$",CDF:"FrCD",CHF:"CHF",CLP:"CL$",CNY:"CN¥",COP:"CO$",CRC:"₡",CVE:"CV$",CZK:"Kč",DJF:"Fdj",DKK:"kr",DOP:"RD$",ERN:"Nfk",ETB:"Br",GBP:"£",GEL:"₾",GHS:"GH₵",GNF:"FG",GTQ:"Q",HKD:"HK$",HNL:"L",HUF:"Ft",IDR:"Rp",ILS:"₪",INR:"₹",IRR:"IRR",ISK:"kr",JMD:"J$",JPY:"¥",KES:"Ksh",KHR:"៛",KMF:"FC",KRW:"₩",KZT:"₸",LKR:"SL Re",MDL:"lei",MGA:"MGA",MKD:"MKD",MMK:"K",MOP:"MOP$",MUR:"₨",MXN:"MX$",MYR:"RM",MZN:"MTn",NAD:"N$",NGN:"₦",NIO:"C$",NOK:"kr",NPR:"रु",NZD:"NZ$",PAB:"B/.",PEN:"S/.",PHP:"₱",PKR:"₨",PLN:"zł",PYG:"₲",RON:"RON",RSD:"RSD",RUB:"₽",RWF:"FR",SDG:"SDG",SEK:"kr",SGD:"S$",SOS:"Ssh",THB:"฿",TOP:"T$",TRY:"TL",TTD:"TT$",TWD:"NT$",TZS:"TSh",UAH:"₴",UGX:"USh",UYU:"$U",UZS:"сум",VND:"₫",XAF:"FCFA",XOF:"CFA",ZAR:"R",ZMW:"K",ZWL:"ZWL$"},wn={ALL:"1 $",BAM:"1 $",BYN:"1 $",CZK:"1 $",DKK:"1 $",GEL:"1 $",HUF:"1 $",ISK:"1 $",IRR:"1 $",KHR:"1$",MDL:"1 $",MKD:"1 $",NOK:"1 $",PLN:"1 $",RON:"1 $",RSD:"1 $",RUB:"1$",SEK:"1 $",UZS:"1 $",VND:"1$"},Cn={BHD:3,JOD:3,KWD:3,LYD:3,OMR:3,TND:3};function En(e,n){let t="";const i=e<0,a=vn[n]??"en",r=Cn[n]??2;if(t=new Intl.NumberFormat(a,{style:"decimal",minimumFractionDigits:r,maximumFractionDigits:20}).format(Math.abs(e)),t=t.replace(/(\.|,)000?$/,""),kn[n]){const e=kn[n]??n;t=(wn[n]??"$1").replace("$",e).replace("1",t)}else t=n+" "+t;return i&&(t="-"+t),t}const An=i=>{const{field:a,onChange:r}=i,{t:o}=G(),s=W(),l=ue(a),c=de(a),_=u(null),f=_t();z(f);const b=m(()=>Pe(f.form,"credit_card_number"),[f.form]),y=bt()?.paymentOptions,x=y?.options?.installment_plans,[g,v]=p(null),k=m(()=>{const e=x?.map(e=>({title:o("installment_plan.pay_in_installments",{installments:e.terms,amount:En(e.installment_amount,s.currency)}),subtitle:e.interest_rate,value:Pn(e)}))??[];return b&&e.unshift({title:o("installment_plan.pay_in_full",{amount:En(s.amount,s.currency)}),value:""}),e},[b,x,s.amount,s.currency,o]);let w=k?.findIndex(e=>e.value===g);-1===w&&(w=0);const C=d(()=>{v(null),_.current&&(_.current.value="")},[]),E=d(e=>{if(_.current){const n=x?.find(n=>Pn(n)===e.value);n?n.code?_.current.value=JSON.stringify([n.terms,n.interval,n.code]):_.current.value=JSON.stringify([n.terms,n.interval]):_.current.value="",_.current?.dispatchEvent(new InternalSetFieldTouchedEvent)}v(e.value),r()},[x,r]);h(()=>{k.length&&E(k[0])},[]);const A=le(k);return h(()=>{k===A||x?.some(e=>Pn(e)===g)||(k.length?E(k[0]):C())},[C,k,E,x,A,g]),n(t,{children:[y?e(Te,{id:l,placeholder:a.placeholder,className:"xendit-text-14",onChange:E,options:k,selectedIndex:w}):e(De,{id:l}),e("input",{type:"hidden",name:c,ref:_})]})};function Pn(e){return`${e.terms}_${e.interval}_${e.code??""}`}const Sn=n=>{const{field:t,className:i}=n;return e("div",{className:`${i} xendit-channel-form-field xendit-form-field-span-${t.span}`,children:function(){switch(t.type.name){case"credit_card_number":case"credit_card_expiry":case"credit_card_cvn":return e(dn,{...n});case"phone_number":return e(un,{...n});case"text":case"email":case"postal_code":return e(xn,{...n});case"dropdown":return e(Je,{...n});case"installment_plan":return e(An,{...n});case"country":return e(je,{...n});case"province":return e(yn,{...n})}throw t.type,new Error(`Unsupported field type: ${t.type.name}`)}()})};const Nn={en:{session:{"validation.card_cvn_invalid":"CVN is not valid","validation.card_expiry_invalid":"Card expiry is not valid","validation.card_number_incomplete":"Card number is incomplete","validation.card_number_invalid":"Card number is not valid","validation.generic_invalid":"{{field}} is not valid","validation.required":"{{field}} is required","validation.text_too_long":"{{field}} is too long","validation.text_too_short":"{{field}} is too short","payment.save_checkbox_label":"Save for faster payment next time","payment_methods.add_payment_method":"Add payment method","payment_methods.channel_disabled_amount_too_large":"Not available for this payment","payment_methods.channel_disabled_amount_too_small":"Not available for this payment","payment_methods.pay_with":"Pay with","payment_methods.select_channel_placeholder":"Select {{groupName}}","default_error.message_1":"There was a problem with the request.","default_error.message_2":"Please try again later.","default_error.title":"Error","combobox.default_search_placeholder":"Search...","installment_plan.pay_in_full":"Pay in Full — {{amount}}","installment_plan.pay_in_installments":"{{installments}}x Installments — {{amount}}","google_pay_errors.developer_error.title":"Google Pay Error","google_pay_errors.developer_error.message":"Something went wrong with Google Pay. Please try again or use a different payment method.","google_pay_errors.buyer_account_error.title":"Google Pay Error","google_pay_errors.buyer_account_error.message":"Your Google account is unable to make this payment. Use a different Google account or a different payment method.","google_pay_errors.merchant_account_error.title":"Google Pay Error","google_pay_errors.merchant_account_error.message":"Something went wrong with Google Pay. Please try again or use a different payment method.","google_pay_errors.internal_error.title":"Google Pay Error","google_pay_errors.internal_error.message":"Something went wrong with Google Pay. Please try again or use a different payment method.","google_pay_errors.unknown_error.title":"Google Pay Error","google_pay_errors.unknown_error.message":"An unknown error occurred with Google Pay. The error code is {{statusCode}}.","failure_code.account_access_blocked":"Your payment was declined. Please try again or use a different payment method.","failure_code.account_already_linked":"Your account has already been linked. Please use a different payment method.","failure_code.account_not_activated":"Your payment couldn’t be processed because your account hasn’t been activated. Please activate your account and try again.","failure_code.authentication_failed":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.capture_amount_exceeded":"Your payment couldn't be processed. Please make sure your payment details are correct and try again, or use a different payment method.","failure_code.card_declined":"Your card was declined. Please try again with another card or payment method.","failure_code.channel_unavailable":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.declined_by_issuer":"Your payment was declined. Please try again or use a different payment method.","failure_code.declined_by_processor":"Your payment was declined. Please try again or use a different payment method.","failure_code.expired_card":"Your card was declined because it is expired. Please try again or use a different payment method.","failure_code.expired_otp":"Your payment couldn’t be processed because your verification code is invalid. Please try again or use a different payment method.","failure_code.failure_details_unavailable":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.inactive_or_unauthorized_card":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.insufficient_balance":"Your payment couldn’t be processed because your account balance is insufficient. Please make sure you have enough funds and try again.","failure_code.invalid_account_details":"Your payment information is incorrect. Please double-check your card details or try a different payment method.","failure_code.invalid_cvv":"The CVN entered was incorrect. Please try again.","failure_code.invalid_merchant_settings":"Your payment couldn’t be processed. Please contact the seller or try a different payment method.","failure_code.invalid_otp":"Your payment couldn’t be processed because your verification code is invalid. Please try again or use a different payment method.","failure_code.invalid_token":"Your payment couldn’t be processed because your verification code is invalid. Please try again or use a different payment method.","failure_code.issuer_unavailable":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.otp_attempt_counts_exceeded":"Your payment couldn’t be processed because there were too many failed OTP attempts. Please make the payment again or use a different payment method.","failure_code.partner_timeout_error":"Your payment couldn't be processed. Please try again or use a different payment method.","failure_code.payment_amount_limits_exceeded":"Your payment couldn’t be processed because you’ve exceeded your transaction limit. Please use a different payment method.","failure_code.payment_attempt_counts_exceeded":"Your payment couldn’t be processed due to too many failed attempts.","failure_code.payment_request_expired":"Your payment couldn’t be processed because the link has expired. Please try again or use a different payment method.","failure_code.processor_error":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.server_error":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.stolen_card":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.suspected_fraudulent":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.timeout_error":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.user_declined_payment":"Your payment was declined. Please try again or use a different payment method.","failure_code.user_device_unreachable":"Your payment couldn’t be processed due to a network issue. Please try again or use a different payment method.","failure_code.user_did_not_authorize":"Your payment couldn’t be processed because it wasn’t authorized in time. Please try again.",failure_code_unknown:"A failure occurred with code {{failureCode}}","payment_request_status.canceled.subtext":"Please try to check out again or contact the seller if the problem persists.","payment_request_status.canceled.title":"This page is no longer available","payment_request_status.expired.subtext":"Your payment couldn’t be processed. Please try again or use a different payment method.","payment_request_status.expired.title":"Payment unsuccessful","payment_request_status.failed.subtext":"Your payment couldn't be processed. Please try a different payment method or submit an inquiry to the seller by sharing your Unique Identifiers.","payment_request_status.failed.title":"Payment failed","payment_token_status.canceled.subtext":"Please try again or use a different payment method.","payment_token_status.canceled.title":"Payment method couldn't be added","payment_token_status.expired.subtext":"Please try again or use a different payment method.","payment_token_status.expired.title":"Payment method couldn't be added","payment_token_status.failed.subtext":"Your payment couldn't be processed. Please try a different payment method or submit an inquiry to the seller by sharing your Unique Identifiers.","payment_token_status.failed.title":"Payment method couldn't be added","action.payment_confirmation_instructions":"Once you've paid, click the button above to get your payment confirmation.","action.payment_made":"I've made this payment","action_va.merchant_name":"Virtual Account Name","action_va.amount_to_pay":"Amount to Pay","action_va.virtual_account_number":"Virtual Account Number","action_va.copy":"Copy","action_va.copied_to_clipboard":"Copied to clipboard","action_qr.unable_to_generate":"Unable to generate QR code","action_deeplink.button":"Open App","action_deeplink.instructions":"Please complete your payment on {{channelName}} app.","action_deeplink.title":"Awaiting payment...","action_empty_list_push_notification.subtext":"Check the notification in your {{channelName}} app to complete your payment.","action_empty_list_push_notification.title":"Awaiting payment...","image_alt.channel_logo":"{{channelName}} logo","simulation.simulate_scenario":"Simulate scenario","simulation.simulate_test_scenario":"Simulate a test scenario","simulation.select_scenario":"Select a scenario","simulation.want_to_test_all_scenarios":"Want to test different scenarios?","simulation.see_all_scenarios":"See the full list here."}}.session,id:{session:{"validation.card_cvn_invalid":"CVN tidak valid","validation.card_expiry_invalid":"Tanggal kedaluwarsa kartu tidak valid","validation.card_number_incomplete":"Nomor kartu tidak lengkap","validation.card_number_invalid":"Nomor kartu tidak valid","validation.generic_invalid":"{{field}} tidak valid","validation.required":"{{field}} wajib diisi","validation.text_too_long":"{{field}} terlalu panjang","validation.text_too_short":"{{field}} terlalu pendek","payment.save_checkbox_label":"Simpan untuk pembayaran lebih cepat lain kali","payment_methods.add_payment_method":"Tambah metode pembayaran","payment_methods.channel_disabled_amount_too_large":"Tidak tersedia untuk pembayaran ini","payment_methods.channel_disabled_amount_too_small":"Tidak tersedia untuk pembayaran ini","payment_methods.pay_with":"Bayar dengan","payment_methods.select_channel_placeholder":"Pilih {{groupName}}","default_error.message_1":"Ada masalah dengan permintaan ini.","default_error.message_2":"Silakan coba lagi nanti.","default_error.title":"Error","failure_code.account_access_blocked":"Pembayaran Anda ditolak. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.account_already_linked":"Akun Anda sudah di-link. Silakan gunakan metode pembayaran lain.","failure_code.account_not_activated":"Pembayaran Anda tidak dapat diproses karena akun Anda belum diaktifkan. Harap aktifkan akun Anda dan coba lagi.","failure_code.authentication_failed":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.capture_amount_exceeded":"Pembayaran Anda tidak dapat diproses. Pastikan detail pembayaran Anda benar dan coba lagi, atau gunakan metode pembayaran lain.","failure_code.card_declined":"Kartu Anda ditolak. Silakan coba lagi dengan kartu atau metode pembayaran lain.","failure_code.channel_unavailable":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.declined_by_issuer":"Pembayaran Anda ditolak. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.declined_by_processor":"Pembayaran Anda ditolak. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.expired_card":"Kartu Anda ditolak karena sudah kedaluwarsa. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.expired_otp":"Pembayaran Anda tidak dapat diproses karena kode verifikasi tidak valid. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.failure_details_unavailable":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.inactive_or_unauthorized_card":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.insufficient_balance":"Pembayaran Anda tidak dapat diproses karena saldo akun Anda tidak mencukupi. Pastikan Anda memiliki dana yang cukup dan coba lagi.","failure_code.invalid_account_details":"Informasi pembayaran Anda salah. Harap periksa kembali detail kartu Anda atau coba gunakan metode pembayaran lain.","failure_code.invalid_cvv":"CVN yang dimasukkan salah. Silakan coba lagi.","failure_code.invalid_merchant_settings":"Pembayaran Anda tidak dapat diproses. Silakan hubungi penjual atau coba metode pembayaran lain.","failure_code.invalid_otp":"Pembayaran Anda tidak dapat diproses karena kode verifikasi tidak valid. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.invalid_token":"Pembayaran Anda tidak dapat diproses karena kode verifikasi tidak valid. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.issuer_unavailable":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.otp_attempt_counts_exceeded":"Pembayaran Anda tidak dapat diproses karena terlalu banyak percobaan OTP yang gagal. Harap lakukan pembayaran lagi atau gunakan metode pembayaran lain.","failure_code.partner_timeout_error":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.payment_amount_limits_exceeded":"Pembayaran Anda tidak dapat diproses karena Anda telah melampaui batas transaksi. Silakan gunakan metode pembayaran lain.","failure_code.payment_attempt_counts_exceeded":"Pembayaran Anda tidak dapat diproses karena terlalu banyak percobaan yang gagal.","failure_code.payment_request_expired":"Pembayaran Anda tidak dapat diproses karena link telah kedaluwarsa. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.processor_error":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.server_error":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.stolen_card":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.suspected_fraudulent":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.timeout_error":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.user_declined_payment":"Pembayaran Anda ditolak. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.user_device_unreachable":"Pembayaran Anda tidak dapat diproses karena masalah jaringan. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.user_did_not_authorize":"Pembayaran Anda tidak dapat diproses karena waktu pembayaran telah habis. Silakan coba lagi.",failure_code_unknown:"Terjadi kegagalan dengan kode {{failureCode}}","payment_request_status.canceled.subtext":"Silakan coba check out lagi atau hubungi penjual jika masalah terus berlanjut.","payment_request_status.canceled.title":"Halaman ini tidak tersedia lagi","payment_request_status.expired.subtext":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","payment_request_status.expired.title":"Pembayaran tidak berhasil","payment_request_status.failed.subtext":"Pembayaran Anda tidak dapat diproses. Silakan coba metode pembayaran lain atau ajukan pertanyaan kepada penjual dengan membagikan ID Unik Anda.","payment_request_status.failed.title":"Pembayaran gagal","payment_token_status.canceled.subtext":"Silakan coba lagi atau gunakan metode pembayaran lain.","payment_token_status.canceled.title":"Metode pembayaran tidak dapat ditambahkan","payment_token_status.expired.subtext":"Silakan coba lagi atau gunakan metode pembayaran lain.","payment_token_status.expired.title":"Metode pembayaran tidak dapat ditambahkan","payment_token_status.failed.subtext":"Pembayaran Anda tidak dapat diproses. Silakan coba metode pembayaran lain atau ajukan pertanyaan kepada penjual dengan membagikan ID Unik Anda.","payment_token_status.failed.title":"Metode pembayaran tidak dapat ditambahkan","action.payment_confirmation_instructions":"Setelah Anda bayar, klik tombol di atas untuk mendapatkan konfirmasi pembayaran Anda.","action.payment_made":"Saya telah melakukan pembayaran ini","action_va.amount_to_pay":"Jumlah Pembayaran","action_va.virtual_account_number":"Nomor Virtual Account","action_qr.unable_to_generate":"Tidak dapat membuat kode QR"}}.session,th:{session:{"validation.card_cvn_invalid":"CVN ไม่ถูกต้อง","validation.card_expiry_invalid":"วันหมดอายุของบัตรไม่ถูกต้อง","validation.card_number_incomplete":"หมายเลขบัตรไม่ครบถ้วน","validation.card_number_invalid":"หมายเลขบัตรไม่ถูกต้อง","validation.generic_invalid":"{{field}} ไม่ถูกต้อง","validation.required":"กรุณากรอก {{field}}","validation.text_too_long":"{{field}} ยาวเกินไป","validation.text_too_short":"{{field}} สั้นเกินไป","payment.save_checkbox_label":"บันทึกไว้สำหรับการชำระเงินที่เร็วขึ้นในครั้งถัดไป","payment_methods.add_payment_method":"เพิ่มวิธีการชำระเงิน","payment_methods.channel_disabled_amount_too_large":"ไม่สามารถใช้ได้กับการชำระเงินนี้","payment_methods.channel_disabled_amount_too_small":"ไม่สามารถใช้ได้กับการชำระเงินนี้","payment_methods.pay_with":"ชำระเงินด้วย","payment_methods.select_channel_placeholder":"เลือก {{groupName}}","default_error.message_1":"มีปัญหาในการประมวลผลคำขอ","default_error.message_2":"โปรดลองอีกครั้งในภายหลัง","default_error.title":"ข้อผิดพลาด","failure_code.account_access_blocked":"การชำระเงินของคุณถูกปฏิเสธ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.account_already_linked":"บัญชีนี้มีการเชื่อมต่อไว้แล้ว กรุณาเลือกวิธีการชำระเงินอื่น","failure_code.account_not_activated":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากบัญชีของคุณยังไม่ได้เปิดใช้งาน กรุณาเปิดใช้งานบัญชีและลองใหม่อีกครั้ง","failure_code.authentication_failed":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.capture_amount_exceeded":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาตรวจสอบรายละเอียดการชำระเงินให้ถูกต้องแล้วลองใหม่อีกครั้ง หรือใช้วิธีการชำระเงินอื่น","failure_code.card_declined":"บัตรของคุณถูกปฏิเสธ กรุณาลองใหม่ด้วยบัตรหรือวิธีการชำระเงินอื่น","failure_code.channel_unavailable":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.declined_by_issuer":"การชำระเงินของคุณถูกปฏิเสธ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.declined_by_processor":"การชำระเงินของคุณถูกปฏิเสธ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.expired_card":"บัตรของคุณถูกปฏิเสธเนื่องจากบัตรหมดอายุ กรุณาลองใหม่อีกครั้งหรือใช้วิธีการชําระเงินอื่น","failure_code.expired_otp":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากรหัสยืนยันของคุณไม่ถูกต้อง กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.failure_details_unavailable":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.inactive_or_unauthorized_card":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.insufficient_balance":"ไม่สามารถดำเนินการชำระเงินได้ เนื่องจากยอดเงินในบัญชีไม่เพียงพอ กรุณาตรวจสอบให้แน่ใจว่ามียอดเงินเพียงพอแล้วลองใหม่อีกครั้ง","failure_code.invalid_account_details":"ข้อมูลการชำระเงินไม่ถูกต้อง กรุณาตรวจสอบรายละเอียดบัตรอีกครั้ง หรือใช้วิธีการชำระเงินอื่น","failure_code.invalid_cvv":"CVN ที่กรอกไม่ถูกต้อง กรุณาลองใหม่อีกครั้ง","failure_code.invalid_merchant_settings":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาติดต่อผู้ขายหรือลองใช้วิธีชำระเงินอื่น","failure_code.invalid_otp":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากรหัสยืนยันของคุณไม่ถูกต้อง กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.invalid_token":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากรหัสยืนยันของคุณไม่ถูกต้อง กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.issuer_unavailable":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.otp_attempt_counts_exceeded":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากมีการกรอกรหัส OTP ผิดพลาดมากเกินไป กรุณาชำระเงินใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.partner_timeout_error":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.payment_amount_limits_exceeded":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากคุณทำธุรกรรมเกินขีดจำกัด กรุณาใช้วิธีชำระเงินอื่น","failure_code.payment_attempt_counts_exceeded":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากพยายามล้มเหลวหลายครั้งเกินไป","failure_code.payment_request_expired":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากลิงก์หมดอายุแล้ว กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.processor_error":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.server_error":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.stolen_card":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.suspected_fraudulent":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.timeout_error":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.user_declined_payment":"การชำระเงินของคุณถูกปฏิเสธ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.user_device_unreachable":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากปัญหาเครือข่าย กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.user_did_not_authorize":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากไม่ได้รับการอนุมัติภายในเวลาที่กำหนด กรุณาลองใหม่อีกครั้ง",failure_code_unknown:"เกิดข้อผิดพลาดขึ้น (รหัส: {{failureCode}})","payment_request_status.canceled.subtext":"กรุณาลองชำระเงินอีกครั้ง หรือ ติดต่อผู้ขายหากปัญหายังคงเกิดขึ้น","payment_request_status.canceled.title":"หน้านี้ไม่สามารถใช้งานได้แล้ว","payment_request_status.expired.subtext":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือลองใช้วิธีชำระเงินอื่น","payment_request_status.expired.title":"ชำระเงินไม่สำเร็จ","payment_request_status.failed.subtext":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใช้วิธีการชำระเงินอื่น หรือส่งคำถามไปยังผู้ขายโดยแชร์ Unique Identifiers ของคุณ","payment_request_status.failed.title":"ชำระเงินไม่สำเร็จ","payment_token_status.canceled.subtext":"กรุณาลองใหม่อีกครั้งหรือใช้วิธีการชําระเงินอื่น","payment_token_status.canceled.title":"ไม่สามารถเพิ่มวิธีการชําระเงินได้","payment_token_status.expired.subtext":"กรุณาลองใหม่อีกครั้งหรือใช้วิธีการชําระเงินอื่น","payment_token_status.expired.title":"ไม่สามารถเพิ่มวิธีการชําระเงินได้","payment_token_status.failed.subtext":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใช้วิธีการชำระเงินอื่น หรือส่งคำถามไปยังผู้ขายโดยแชร์ Unique Identifiers ของคุณ","payment_token_status.failed.title":"ไม่สามารถเพิ่มวิธีการชําระเงินได้","action.payment_confirmation_instructions":"เมื่อคุณชำระเงินแล้ว คลิกที่ปุ่มด้านบนเพื่อยืนยันการชำระเงิน","action.payment_made":"ฉันได้ชำระเงินแล้ว","action_va.amount_to_pay":"ยอดชำระ","action_va.virtual_account_number":"หมายเลข Virtual Account","action_qr.unable_to_generate":"ไม่สามารถสร้างคิวอาร์โค้ดได้"}}.session,vi:{session:{"validation.card_cvn_invalid":"CVN không hợp lệ","validation.card_expiry_invalid":"Ngày hết hạn thẻ không hợp lệ","validation.card_number_incomplete":"Số thẻ chưa đầy đủ","validation.card_number_invalid":"Số thẻ không hợp lệ","validation.generic_invalid":"{{field}} không hợp lệ","validation.required":"Vui lòng nhập {{field}}","validation.text_too_long":"{{field}} quá dài","validation.text_too_short":"{{field}} quá ngắn","payment.save_checkbox_label":"Lưu để thanh toán nhanh hơn lần sau","payment_methods.add_payment_method":"Thêm phương thức thanh toán","payment_methods.channel_disabled_amount_too_large":"Không khả dụng cho khoản thanh toán này","payment_methods.channel_disabled_amount_too_small":"Không khả dụng cho khoản thanh toán này","payment_methods.pay_with":"Thanh toán bằng","payment_methods.select_channel_placeholder":"Chọn {{groupName}}","default_error.message_1":"Có vấn đề với yêu cầu.","default_error.message_2":"Vui lòng thử lại sau.","default_error.title":"Lỗi","failure_code.account_access_blocked":"Thanh toán của bạn bị từ chối. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.account_already_linked":"Tài khoản của bạn đã được liên kết. Vui lòng dùng phương thức khác.","failure_code.account_not_activated":"Không thể thực hiện thanh toán vì tài khoản chưa được kích hoạt. Vui lòng kích hoạt và thử lại.","failure_code.authentication_failed":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.capture_amount_exceeded":"Không thể thực hiện thanh toán. Vui lòng kiểm tra thông tin thanh toán và thử lại, hoặc dùng phương thức khác.","failure_code.card_declined":"Thẻ của bạn đã bị từ chối. Vui lòng thử lại bằng thẻ khác hoặc phương thức khác.","failure_code.channel_unavailable":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.declined_by_issuer":"Thanh toán của bạn bị từ chối. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.declined_by_processor":"Thanh toán của bạn bị từ chối. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.expired_card":"Thẻ của bạn bị từ chối do đã hết hạn. Vui lòng thử lại hoặc sử dụng phương thức thanh toán khác.","failure_code.expired_otp":"Không thể thực hiện thanh toán vì mã xác minh không hợp lệ. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.failure_details_unavailable":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.inactive_or_unauthorized_card":"Không thể xử lý thanh toán của bạn. Vui lòng thử lại hoặc sử dụng phương thức thanh toán khác.","failure_code.insufficient_balance":"Không thể thực hiện thanh toán vì số dư tài khoản không đủ. Vui lòng nạp thêm tiền và thử lại.","failure_code.invalid_account_details":"Thông tin thanh toán không chính xác. Vui lòng kiểm tra lại hoặc dùng phương thức khác.","failure_code.invalid_cvv":"Mã CVN nhập không đúng. Vui lòng thử lại.","failure_code.invalid_merchant_settings":"Không thể thực hiện thanh toán. Vui lòng liên hệ người bán hoặc dùng phương thức khác.","failure_code.invalid_otp":"Không thể thực hiện thanh toán vì mã xác minh không hợp lệ. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.invalid_token":"Không thể thực hiện thanh toán vì mã xác minh không hợp lệ. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.issuer_unavailable":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.otp_attempt_counts_exceeded":"Không thể thực hiện thanh toán vì đã nhập sai OTP quá nhiều lần. Vui lòng thanh toán lại hoặc dùng phương thức khác.","failure_code.partner_timeout_error":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.payment_amount_limits_exceeded":"Không thể thực hiện thanh toán vì bạn đã vượt quá hạn mức giao dịch. Vui lòng dùng phương thức khác.","failure_code.payment_attempt_counts_exceeded":"Không thể thực hiện thanh toán do quá nhiều lần thử thất bại.","failure_code.payment_request_expired":"Không thể thực hiện thanh toán vì liên kết đã hết hạn. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.processor_error":"Không thể xử lý thanh toán của bạn. Vui lòng thử lại hoặc sử dụng phương thức thanh toán khác.","failure_code.server_error":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.stolen_card":"Không thể xử lý thanh toán của bạn. Vui lòng thử lại hoặc sử dụng phương thức thanh toán khác.","failure_code.suspected_fraudulent":"Không thể xử lý thanh toán của bạn. Vui lòng thử lại hoặc sử dụng phương thức thanh toán khác.","failure_code.timeout_error":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.user_declined_payment":"Thanh toán của bạn bị từ chối. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.user_device_unreachable":"Không thể thực hiện thanh toán do sự cố mạng. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.user_did_not_authorize":"Không thể thực hiện thanh toán vì không được xác nhận kịp thời. Vui lòng thử lại.",failure_code_unknown:"Có lỗi xảy ra với mã {{failureCode}}","payment_request_status.canceled.subtext":"Vui lòng thử thanh toán lại hoặc liên hệ người bán nếu vấn đề vẫn tiếp diễn.","payment_request_status.canceled.title":"Trang này không còn khả dụng","payment_request_status.expired.subtext":"Thanh toán của bạn không thể xử lý. Vui lòng thử lại hoặc chọn phương thức khác.","payment_request_status.expired.title":"Thanh toán không thành công","payment_request_status.failed.subtext":"Không thể thực hiện thanh toán. Vui lòng thử phương thức khác hoặc gửi yêu cầu đến người bán bằng cách chia sẻ Mã định danh duy nhất.","payment_request_status.failed.title":"Thanh toán thất bại","payment_token_status.canceled.subtext":"Vui lòng thử lại hoặc dùng phương thức khác.","payment_token_status.canceled.title":"Không thể thêm phương thức thanh toán","payment_token_status.expired.subtext":"Vui lòng thử lại hoặc dùng phương thức khác.","payment_token_status.expired.title":"Không thể thêm phương thức thanh toán","payment_token_status.failed.subtext":"Không thể thực hiện thanh toán. Vui lòng thử phương thức khác hoặc gửi yêu cầu đến người bán bằng cách chia sẻ Mã định danh duy nhất.","payment_token_status.failed.title":"Không thể thêm phương thức thanh toán","action.payment_confirmation_instructions":"Sau khi bạn đã thanh toán, hãy nhấp nút phía trên để nhận xác nhận thanh toán.","action.payment_made":"Tôi đã thực hiện thanh toán này","action_va.amount_to_pay":"Số tiền cần thanh toán","action_va.virtual_account_number":"Số tài khoản định danh (Virtual Account)","action_qr.unable_to_generate":"Không thể tạo mã QR"}}.session};const Rn=(e,n,t)=>n?(e=>"object"==typeof e&&null!==e&&"localeKey"in e)(n)?e(n.localeKey,{field:t.label}):n.value:null;function In(e){return e.startsWith("/")&&e.endsWith("/")?e.slice(1,-1):e}function Tn(e,n){if(0===n.length)return e.required?{localeKey:"validation.required"}:void 0;switch(e.type.name){case"credit_card_number":case"credit_card_expiry":case"credit_card_cvn":return function(e){const n=ge(e);if(!n.valid){if(n.validationError)return{localeKey:n.validationError};throw new Error("Unexpected value in encrypted field, this is a bug, please contact support.")}}(n);case"phone_number":return(e=>{const n=v(e);if(!n||!n.isValid())return{localeKey:"validation.generic_invalid"}})(n);case"email":return(e=>{if(!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[A-Za-z]{2,}$/.test(e))return{localeKey:"validation.generic_invalid"}})(n);case"postal_code":return(e=>{if(!/^(?![-\s]+)[A-Za-z0-9\s-]+$/.test(e))return{localeKey:"validation.generic_invalid"}})(n);case"text":return((e,n)=>{if(Array.isArray(e.type.regex_validators))for(const t of e.type.regex_validators)if(!new RegExp(In(t.regex)).test(n))return{value:t.message};return void 0!==e.type.min_length&&n.length<e.type.min_length?{localeKey:"validation.text_too_short"}:n.length>e.type.max_length?{localeKey:"validation.text_too_long"}:void 0})(e,n);case"country":case"province":case"installment_plan":case"dropdown":return;default:throw e.type,new Error(`Unsupported input type: ${e.type.name}; this is a bug, please contact support.`)}}function Dn(e,n){const t=Array.isArray(e.channel_property)?e.channel_property:[e.channel_property];for(const i of t){let t=Mn(n,i);if(void 0===t&&(t=""),"string"!=typeof t)continue;const a=Tn(e,t);if(a)return a}}function Mn(e,n){const t=n.split("."),i=e[t[0]];if(void 0!==i){if("object"!=typeof i||Array.isArray(i)){if(1!==t.length)throw new Error(`Attempted to read channel property "${n}" expecting an object but found a primitive value; this is a bug, please contact support.`);return i}return Mn(i,t.slice(1).join("."))}}const Un=r(null),Ln=({scenarios:n,onSelect:t,children:i})=>{const[a,r]=p(!1),o=u(null);return h(()=>{if(!a)return;const e=e=>{const n=o.current;n&&(n.contains(e.target)||r(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a]),e("div",{ref:o,children:e(Un.Provider,{value:{open:a,setOpen:r,scenarios:n,onSelect:t},children:i})})},On=({children:n})=>e("div",{className:"xendit-form-simulation-root",children:n}),qn=({children:n})=>{const{open:t,setOpen:i}=c(Un)||{};return e("button",{type:"button",className:"xendit-form-simulation-trigger",onClick:()=>i?.(!t),children:n})},Bn=()=>{const{open:t,setOpen:i,scenarios:a,onSelect:r}=c(Un)||{},{t:o}=G();return t&&a?n("div",{className:"xendit-form-simulation-popover",children:[e("div",{className:"xendit-text-12 xendit-text-semibold",children:o("simulation.simulate_test_scenario")}),e(Te,{onChange:e=>{const n=a.scenarios.find(n=>n.description===e.value);n&&(r?.(n.name),i?.(!1))},placeholder:o("simulation.select_scenario"),options:a.scenarios.map(n=>({title:n.description,value:n.description,leadingAsset:e("img",{src:n.imageUrl,className:"xendit-form-simulation-scenario-icon"})}))}),a?.docsLink?n("div",{className:"xendit-text-14",children:[o("simulation.want_to_test_all_scenarios")," ",e("a",{href:a.docsLink,target:"_blank",rel:"noopener noreferrer",className:"xendit-text-link",children:o("simulation.see_all_scenarios")})]}):null]}):null},Vn="field-radius-bl-0",Kn="field-radius-br-0",Wn="field-radius-tl-0",Fn="field-radius-tr-0",$n="field-collapse-r",Gn="field-collapse-l",Xn="field-collapse-t",Hn="field-collapse-b",Yn=({fieldGroup:t,groupIndex:i,handleFieldChanged:a,channelProperties:r,simulationScenarios:o})=>{const{t:s}=G(),l=u(null),[d,c]=p({}),m=t.map(e=>e.span),_=Math.ceil(t.reduce((e,n)=>e+n.span,0)/2);h(()=>{const e=l.current;if(e)return e.addEventListener(InternalSetFieldTouchedEvent.type,n),()=>{e.removeEventListener(InternalSetFieldTouchedEvent.type,n)};function n(e){const n=e.target.name;c(e=>({...e,[n]:!0}))}},[]);const f=(()=>{for(const n of t){if(!d[de(n)])continue;const t=Dn(n,r??{});if(t)return e("span",{className:"xendit-error-message xendit-text-12",children:Rn(s,t,n)})}return null})();return e(rn,{children:n("div",{className:"xendit-channel-form-field-group",children:[n("div",{className:"xendit-channel-form-field-group-label-container",children:[e("label",{htmlFor:ue(t[0]),className:"xendit-text-14",children:t[0].group_label??t[0].label??""}),o?e(zn,{simulationScenarios:o,fieldGroup:t}):null]}),e("div",{ref:l,className:"xendit-form-field-group "+(f?"invalid":""),children:t.map((n,t)=>{const i=(e=>{const n=m.slice(0,e).reduce((e,n)=>e+n,0),t=0===e?0:Math.floor(n/2);return{fieldPositionBySpan:n,fieldRow:t,fieldColumn:n%2,isLastRow:t===_-1}})(t),r=((e,n,t)=>{const{fieldPositionBySpan:i,fieldRow:a,fieldColumn:r,isLastRow:o}=t;return b({[Vn]:_>a+1||i%2==1,[Kn]:!!m[n+1],[Wn]:n>0,[Fn]:!(0===a&&1===r||0===a&&0===r&&2===e.span),[$n]:1===e.span&&0===r,[Gn]:1===e.span&&1===r,[Xn]:i>=2,[Hn]:!o})})(n,t,i);return e(Sn,{className:r,field:n,onChange:a},t)})},i),f]})})},zn=({simulationScenarios:t,fieldGroup:i})=>{const a=c(tn),{t:r}=G();return e(Ln,{scenarios:t,onSelect:e=>{const n=t.scenarios.find(n=>n.name===e);if(n?.values)for(const[e,t]of Object.entries(n.values)){const n=i.find(n=>de(n)===e);n&&("credit_card_number"!==n.type.name&&"credit_card_expiry"!==n.type.name&&"credit_card_cvn"!==n.type.name||a?.postMessageToIframe(e,{type:"xendit-iframe-populate-for-simulation",scenario:t}))}},children:n(On,{children:[e(qn,{children:e("div",{className:"xendit-text-12 xendit-text-semibold xendit-text-link",children:r("simulation.simulate_scenario")})}),e(Bn,{})]})})},jn={scenarios:[{imageUrl:"https://assets.xendit.co/payment-session/logos/VISA.svg",description:"3DS Challenge, authentication is successful if OTP is correct.",name:"3_ds_challenge_authentication_is_successful_if_otp_is_correct_visa",values:{"card_details.card_number":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_visa","card_details.expiry_month__card_details.expiry_year":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_visa","card_details.cvn":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_visa"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/VISA.svg",description:"3DS Frictionless, authentication is successful.",name:"3_ds_frictionless_authentication_is_successful_visa",values:{"card_details.card_number":"3_ds_frictionless_authentication_is_successful_visa","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_is_successful_visa","card_details.cvn":"3_ds_frictionless_authentication_is_successful_visa"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/MASTERCARD.svg",description:"3DS Challenge, authentication is successful if OTP is correct.",name:"3_ds_challenge_authentication_is_successful_if_otp_is_correct_mastercard",values:{"card_details.card_number":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_mastercard","card_details.expiry_month__card_details.expiry_year":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_mastercard","card_details.cvn":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_mastercard"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/MASTERCARD.svg",description:"3DS Frictionless, authentication is successful.",name:"3_ds_frictionless_authentication_is_successful_mastercard",values:{"card_details.card_number":"3_ds_frictionless_authentication_is_successful_mastercard","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_is_successful_mastercard","card_details.cvn":"3_ds_frictionless_authentication_is_successful_mastercard"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/VISA.svg",description:"3DS Challenge, with list of simulated options.",name:"3_ds_challenge_with_list_of_simulated_options_visa",values:{"card_details.card_number":"3_ds_challenge_with_list_of_simulated_options_visa","card_details.expiry_month__card_details.expiry_year":"3_ds_challenge_with_list_of_simulated_options_visa","card_details.cvn":"3_ds_challenge_with_list_of_simulated_options_visa"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/VISA.svg",description:"3DS Frictionless, authentication is successful.",name:"3_ds_frictionless_authentication_is_successful_visa2",values:{"card_details.card_number":"3_ds_frictionless_authentication_is_successful_visa2","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_is_successful_visa2","card_details.cvn":"3_ds_frictionless_authentication_is_successful_visa2"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/MASTERCARD.svg",description:"3DS Challenge, with list of simulated options.",name:"3_ds_challenge_with_list_of_simulated_options_mastercard",values:{"card_details.card_number":"3_ds_challenge_with_list_of_simulated_options_mastercard","card_details.expiry_month__card_details.expiry_year":"3_ds_challenge_with_list_of_simulated_options_mastercard","card_details.cvn":"3_ds_challenge_with_list_of_simulated_options_mastercard"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/MASTERCARD.svg",description:"3DS Frictionless, authentication is successful.",name:"3_ds_frictionless_authentication_is_successful_mastercard2",values:{"card_details.card_number":"3_ds_frictionless_authentication_is_successful_mastercard2","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_is_successful_mastercard2","card_details.cvn":"3_ds_frictionless_authentication_is_successful_mastercard2"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/VISA.svg",description:"3DS Challenge, authentication is successful if OTP is correct. For frictionless flow, use amount < THB 20.",name:"3_ds_challenge_authentication_is_successful_if_otp_is_correct_for_frictionless_flow_use_amount_thb_20_visa",values:{"card_details.card_number":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_for_frictionless_flow_use_amount_thb_20_visa","card_details.expiry_month__card_details.expiry_year":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_for_frictionless_flow_use_amount_thb_20_visa","card_details.cvn":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_for_frictionless_flow_use_amount_thb_20_visa"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/MASTERCARD.svg",description:"3DS Challenge, authentication is successful if OTP is correct. For frictionless flow, use amount < THB 20.",name:"3_ds_challenge_authentication_is_successful_if_otp_is_correct_for_frictionless_flow_use_amount_thb_20_mastercard",values:{"card_details.card_number":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_for_frictionless_flow_use_amount_thb_20_mastercard","card_details.expiry_month__card_details.expiry_year":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_for_frictionless_flow_use_amount_thb_20_mastercard","card_details.cvn":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_for_frictionless_flow_use_amount_thb_20_mastercard"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/VISA.svg",description:"Failing transaction",name:"failing_transaction_visa",values:{"card_details.card_number":"failing_transaction_visa","card_details.expiry_month__card_details.expiry_year":"failing_transaction_visa","card_details.cvn":"failing_transaction_visa"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/MASTERCARD.svg",description:"Failing transaction",name:"failing_transaction_mastercard",values:{"card_details.card_number":"failing_transaction_mastercard","card_details.expiry_month__card_details.expiry_year":"failing_transaction_mastercard","card_details.cvn":"failing_transaction_mastercard"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/AMEX.svg",description:"3DS Frictionless, authentication successful (use a 4 digit CVN)",name:"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn",values:{"card_details.card_number":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn","card_details.cvn":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/AMEX.svg",description:"3DS Frictionless, authentication successful (use a 4 digit CVN)",name:"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn2",values:{"card_details.card_number":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn2","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn2","card_details.cvn":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn2"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/AMEX.svg",description:"3DS Challenge (use a 4 digit CVN)",name:"3_ds_challenge_use_a_4_digit_cvn",values:{"card_details.card_number":"3_ds_challenge_use_a_4_digit_cvn","card_details.expiry_month__card_details.expiry_year":"3_ds_challenge_use_a_4_digit_cvn","card_details.cvn":"3_ds_challenge_use_a_4_digit_cvn"}}],docsLink:"https://docs.xendit.co/docs/cards-simulate-card-scenarios"},Zn=C(({form:n,onChannelPropertiesChanged:t},i)=>{const a=W(),r=_t(),o=G(),s=bt(),l=u(null),[c,h]=p(null);_(i,()=>({setAllFieldsTouched(){const e=l.current;e&&Array.from(e.elements).filter(e=>e instanceof HTMLInputElement).forEach(e=>{e.name&&e.dispatchEvent(new InternalSetFieldTouchedEvent)})}}));const b=d(()=>{if(!l.current)return{};return function(e){const n={};for(const[t,i]of e){if(i instanceof Blob)continue;const e=t.split("__"),a=et(e,i);e:for(const t of e){const e=t.split(".");let i=n;for(;e.length>1;){const n=e.shift();let t=i[n];if(void 0===t&&(t=i[n]={}),t&&"object"==typeof t){if(Array.isArray(t))continue e;i=t}}const r=a.length?a.shift():"";i[e[0]]=r}}return n}(new FormData(l.current).entries())},[]),y=d(()=>{if(!l.current)return;const e=b();h(e),t(e)},[b,t]),x=function(e,n,t,i){const a=m(()=>nt(e.session_type,n,t,i),[i,t,n,e.session_type]);return a}(a,n,c||{},s??null),g=le(x);f(()=>{(function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0})(g||[],x)||y()},[x,y,g]);const v=d(e=>"pd"!==o[I].sdkKey.hostId?null:"CARDS"===r?.channel_code&&e.some(e=>"credit_card_number"===e.type.name)?jn:null,[r,o]),k=function(e){const n=[[]];for(const t of e)1!==t.span||1!==n[n.length-1].length||1!==n[n.length-1][0].span?t.join?n[n.length-1].push(t):n.push([t]):n[n.length-1].push(t);return n}(x).filter(e=>e.length);return 0===k.length?null:e("div",{class:"xendit-channel-form",children:e("form",{ref:l,children:e(Qn.Provider,{value:c,children:k.map((n,t)=>e(Yn,{fieldGroup:n,groupIndex:t,handleFieldChanged:y,channelProperties:c,simulationScenarios:v(n)},t))})})})}),Qn=r(null),Jn=()=>c(Qn);function et(e,n){if(0===e.length)return[];if(1===e.length)return[n];if(""===n)return[];try{return JSON.parse(n)}catch(e){return[n]}}function nt(e,n,t,i){const a=Pe(n,"credit_card_number"),r=i?.cardDetails?.details?.require_billing_information,o=!!i?.paymentOptions?.options?.installment_plans?.length;return n.filter(n=>{if(n.flags?.require_billing_information){if("PAY"!==e)return!1;if(!r)return!1}if("installment_plan"===n.type.name&&!o&&a)return!1;for(const e of n.display_if||[]){const[n,i,a]=e,r=Mn(t,n);switch(i){case"equals":if(r!==a)return!1;break;case"not_equals":if(r===a)return!1}}return!0})}const tt=t=>{const i=u(null),a=u(null),r=void 0!==HTMLElement.prototype.animate;return h(()=>{r&&(i.current?.animate(it,at),a.current?.animate(rt,ot))},[r]),n("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[n("g",{opacity:"0.5",children:[e("path",{d:"M8.79453 10.2303C7.1791 10.2303 5.86953 11.5399 5.86953 13.1553V28.9503C5.86953 31.535 7.96484 33.6303 10.5495 33.6303H26.3445C27.96 33.6303 29.2695 32.3208 29.2695 30.7053",fill:"#F1F1F1"}),e("path",{d:"M8.79453 10.2303V10.2303C7.1791 10.2303 5.86953 11.5399 5.86953 13.1553V28.9503C5.86953 31.535 7.96484 33.6303 10.5495 33.6303H26.3445C27.96 33.6303 29.2695 32.3208 29.2695 30.7053V30.7053",stroke:"#D0D0D0",strokeWidth:"1.755",strokeLinecap:"round",strokeLinejoin:"round"})]}),n("g",{ref:a,style:{transformOrigin:"20px 20px"},children:[e("path",{d:"M28.8177 6.00256H14.7777C12.193 6.00256 10.0977 8.09787 10.0977 10.6826V24.7226C10.0977 27.3073 12.193 29.4026 14.7777 29.4026H28.8177C31.4023 29.4026 33.4977 27.3073 33.4977 24.7226V10.6826C33.4977 8.09787 31.4024 6.00256 28.8177 6.00256Z",fill:"white",stroke:"#EDEDED",strokeWidth:"1.755",strokeLinecap:"round",strokeLinejoin:"round"}),n("g",{style:{transformOrigin:"10px 30px"},ref:i,children:[e("path",{d:"M26.7697 20.5301V12.7301H18.9697",stroke:"#7C7C7C",strokeWidth:"1.872",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M17.4102 22.0901L26.7702 12.7301",stroke:"#7C7C7C",strokeWidth:"1.872",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})},it=[{transform:"scale(0.1)"},{transform:"scale(1)"}],at={duration:500,easing:"ease-out"},rt=[{transform:"rotate(0deg)"},{transform:"rotate(5deg)"},{transform:"rotate(-5deg)"},{transform:"rotate(0deg)"}],ot={duration:1e3,easing:"ease-out",iterations:1/0,delay:2e3},st=t=>{const i=u(null),a=u(null),r=me(),o=void 0!==HTMLElement.prototype.animate;return h(()=>{if(o&&i.current){const e=()=>{if(!i.current)return;const n=i.current.animate(lt,dt);setTimeout(()=>{a.current?.animate(ut,ht)},1e3),n.onfinish=()=>{const n=i.current?.animate(lt,ct);setTimeout(()=>{a.current?.animate(ut,ht)},500),n&&(n.onfinish=e)}};e()}},[o]),n("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"var(--xendit-color-icon-primary)",xmlns:"http://www.w3.org/2000/svg",...t,children:[n("g",{"clip-path":`url(#${r})`,children:[e("rect",{x:"8",y:"8",width:"24",height:"24",fill:"var(--xendit-color-icon-secondary)",ref:a}),e("path",{d:"M11.5 13.1528C11.5 12.24 12.24 11.5 13.1528 11.5H17.4028C18.3156 11.5 19.0556 12.24 19.0556 13.1528V17.4028C19.0556 18.3156 18.3156 19.0556 17.4028 19.0556H13.1528C12.24 19.0556 11.5 18.3156 11.5 17.4028V13.1528Z"}),e("path",{d:"M20.9444 13.1528C20.9444 12.24 21.6844 11.5 22.5972 11.5H26.8472C27.76 11.5 28.5 12.24 28.5 13.1528V17.4028C28.5 18.3156 27.76 19.0556 26.8472 19.0556H22.5972C21.6844 19.0556 20.9444 18.3156 20.9444 17.4028V13.1528Z"}),e("path",{d:"M11.5 22.5972C11.5 21.6844 12.24 20.9444 13.1528 20.9444H17.4028C18.3156 20.9444 19.0556 21.6844 19.0556 22.5972V26.8472C19.0556 27.76 18.3156 28.5 17.4028 28.5H13.1528C12.24 28.5 11.5 27.76 11.5 26.8472V22.5972Z"}),e("path",{d:"M20.9444 22.5972C20.9444 21.6844 21.6844 20.9444 22.5972 20.9444H26.8472C27.76 20.9444 28.5 21.6844 28.5 22.5972V26.8472C28.5 27.76 27.76 28.5 26.8472 28.5H22.5972C21.6844 28.5 20.9444 27.76 20.9444 26.8472V22.5972Z"}),e("path",{d:"M7.875 23C8.35825 23 8.75 23.3918 8.75 23.875V30.2754C8.75021 30.6755 9.07451 30.9998 9.47461 31H15.875C16.3582 31 16.75 31.3918 16.75 31.875C16.75 32.3582 16.3582 32.75 15.875 32.75H9.47461C8.10801 32.7498 7.00021 31.642 7 30.2754V23.875C7 23.3918 7.39175 23 7.875 23Z"}),e("path",{d:"M31.875 23C32.3582 23 32.75 23.3918 32.75 23.875V30.2754C32.7498 31.642 31.642 32.7498 30.2754 32.75H23.875C23.3918 32.75 23 32.3582 23 31.875C23 31.3918 23.3918 31 23.875 31H30.2754C30.6755 30.9998 30.9998 30.6755 31 30.2754V23.875C31 23.3918 31.3918 23 31.875 23Z"}),e("path",{d:"M15.875 7C16.3582 7 16.75 7.39175 16.75 7.875C16.75 8.35825 16.3582 8.75 15.875 8.75H9.47461C9.07451 8.75021 8.75021 9.07451 8.75 9.47461V15.875C8.75 16.3582 8.35825 16.75 7.875 16.75C7.39175 16.75 7 16.3582 7 15.875V9.47461C7.00021 8.10801 8.10801 7.00021 9.47461 7H15.875Z"}),e("path",{d:"M30.2754 7C31.642 7.00021 32.7498 8.10801 32.75 9.47461V15.875C32.75 16.3582 32.3582 16.75 31.875 16.75C31.3918 16.75 31 16.3582 31 15.875V9.47461C30.9998 9.07451 30.6755 8.75021 30.2754 8.75H23.875C23.3918 8.75 23 8.35825 23 7.875C23 7.39175 23.3918 7 23.875 7H30.2754Z"}),e("rect",{x:"3",y:"-4",width:"34",height:"4",rx:"1.75",ref:i})]}),e("defs",{children:e("clipPath",{id:r,children:e("rect",{width:"40",height:"40",fill:"white"})})})]})},lt=[{transform:"translateY(0)"},{transform:"translateY(44px)"}],dt={duration:1e3,delay:1e3,easing:"ease-out"},ct={duration:1e3,direction:"reverse",delay:500,easing:"ease-in"},ut=[{opacity:1},{opacity:0},{opacity:1}],ht={duration:1e3},pt=t=>{const{id:i,label:a,checked:r,onChange:o,disabled:s}=t,l=me(),d=i||l;return n("div",{className:"xendit-checkbox",children:[n("div",{className:"xendit-checkbox-box",children:[e("input",{id:d,type:"checkbox",onChange:e=>{o?.(e)},checked:r,disabled:s}),e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:"xendit-checkbox-graphic",children:e("polyline",{points:"40 144 96 200 224 72",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"16"})})]}),e("label",{htmlFor:d,className:"xendit-text-14",children:a})]})},mt=r(null),_t=()=>{const e=c(mt);if(void 0===e)throw new Error("useChannel must be used within a ChannelProvider");return e},ft=r(null);ft.displayName="ChannelComponentDataContext";const bt=()=>c(ft),yt=t=>{const{channelOrPair:i,channelData:a,savePaymentMethod:r,formRef:o}=t,s=u(null),l=G(),{t:d}=l,c=W(),h=i[0],p=i.length>1,m=we(i,r),_=function(e){if(e&&2===e.length)return[e[0],e[1]];return null}(m.instructions),f="OPTIONAL"===c.allow_save_payment_method&&(m.allow_save||p);return e(mt.Provider,{value:m,children:e(ft.Provider,{value:a,children:n("div",{className:"xendit-payment-channel",ref:s,children:[e(Zn,{ref:o,form:m.form,onChannelPropertiesChanged:e=>{let n=e;if("CARDS"===h.channel_code&&e.installment_configuration){const t=Object.fromEntries(Object.entries(e.installment_configuration).filter(([e,n])=>""!==n));n=0===Object.keys(t).length?{...e,installment_configuration:void 0}:{...e,installment_configuration:t}}const t=new XenditChannelPropertiesChangedEvent(h.channel_code,n);s.current?.dispatchEvent(t)}}),m.banner?e(xt,{banner:m.banner}):null,f&&e(pt,{label:d("payment.save_checkbox_label"),onChange:e=>{const n=e.target?.checked;l?.dispatchEvent(new InternalUpdateChannelComponentData(h.channel_code,{savePaymentMethod:n}))},checked:r}),_?n("div",{className:"xendit-payment-channel-instructions",children:["QR_CODE"===m.pm_type?e(st,{}):e(tt,{}),e("div",{className:"xendit-payment-channel-instructions-text xendit-text-12",children:_.map((n,t)=>e("p",{className:0===t?"xendit-text-semibold":void 0,children:n},t))})]}):null]})})})},xt=n=>{const t="number"==typeof n.banner.aspect_ratio?String(n.banner.aspect_ratio):void 0;return n.banner?.link_url?e("a",{href:n.banner.link_url,target:"_blank",rel:"noopener noreferrer",children:e("img",{src:n.banner.image_url,alt:n.banner.alt_text,className:"xendit-payment-channel-banner",style:{aspectRatio:t}})}):e("img",{src:n.banner.image_url,alt:n.banner.alt_text,className:"xendit-payment-channel-banner",style:{aspectRatio:t}})};class XenditChannelPropertiesChangedEvent extends Event{static type="xendit-channel-properties-changed";channel;channelProperties;constructor(e,n){super(XenditChannelPropertiesChangedEvent.type,{bubbles:!0,composed:!0}),this.channel=e,this.channelProperties=n}}class NetworkError extends Error{errorResponse;constructor(e){super(e.message),this.errorResponse=e}}function gt(e){const n=new URLSearchParams;return n.append("payload",JSON.stringify(e)),n}function vt(e,n,t){return async function(...i){let a,r,o,s,l;switch(e){case"GET":[a,r,o,l]=i;break;case"POST":[a,s,r,o,l]=i;break;default:throw new Error(`Unable to call endpoint with method ${e}; this is a bug, please contact support.`)}const d="v0.0.17";z(d),z(d.startsWith("v"));const c=a.hostId;if(c===ae)throw new Error("A network request was made in mock mode; this is a bug.");const u=oe(c);if(!u)throw new Error(`Unknown hostId ${c} in sdkKey; this is a bug, please contact support.`);const h=new URL(n(r),u);if(t&&!o)throw new Error("Query string argument is missing; this is a bug, please contact support.");const p=t?.(o)??new URLSearchParams;p.set("components_version",d),h.search=p.toString();const m={method:e,body:s?gt(s):void 0,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:l},_=await fetch(h,m);if(!_.ok){const e=await _.json();if(!e||!e.error_code)throw new Error("Unexpected error response from server");throw new NetworkError(e)}return _.json()}}const kt=vt("GET",e=>`/api/sessions/${e}`),wt=vt("POST",()=>"/api/sessions/payment_tokens"),Ct=vt("POST",()=>"/api/sessions/payment_requests"),Et=vt("POST",e=>`/api/sessions/${e.sessionAuthKey}/payment_requests/${e.paymentRequestId}/simulate`),At=vt("GET",e=>`/api/sessions/${e}/poll`,e=>new URLSearchParams(e?{token_request_id:e}:{})),Pt=vt("POST",e=>`/api/sessions/${e}/card_info`),St=vt("POST",e=>`/api/sessions/${e}/payment_options`);function Nt(e,n,t){return{impl:e,key:n??"",child:t,instance:void 0}}class BehaviorTree{fn;bb;root=Nt(class{});updating=!1;again=!1;constructor(e,n){this.fn=e,this.bb=n}update(){if(this.again=!0,this.updating)return;let e=0;try{for(this.updating=!0;this.again;){this.again=!1,e+=1,Rt(e);const n=this.root??void 0,t=this.fn(this.bb);this.root=t,It(n,t,this.bb,0)}}finally{this.updating=!1}}findBehavior(e){return Mt(this.root,e)}}function Rt(e){if(e>32)throw new Error("Max recursion depth exceeded; this is a bug, please contact support.")}function It(e,n,t,i){if(Rt(i),function(e,n){return void 0===e||void 0===n||Array.isArray(e)!==Array.isArray(n)||(!Array.isArray(e)||!Array.isArray(n))&&(Z(e),Z(n),e.impl!==n.impl||e.key!==n.key)}(e,n))e&&Dt(e,i+1),n&&Tt(n,t,i+1);else if(Array.isArray(e)||Array.isArray(n)){j(e),j(n);const a=Math.max(e.length,n.length);for(let r=0;r<a;r++)It(e[r],n[r],t,i+1)}else n&&(n.instance=e?.instance),e&&(e.instance=void 0),It(e?.child,n?.child,t,i+1),n?.instance?.update?.()}function Tt(e,n,t){if(Rt(t),Array.isArray(e))for(const i of e)i&&Tt(i,n,t+1);else e.instance=new e.impl(n,e.key),e.instance.enter?.(),e.child&&Tt(e.child,n,t+1)}function Dt(e,n){if(Rt(n),Array.isArray(e))for(const t of e)t&&Dt(t,n+1);else e.child&&Dt(e.child,n+1),e.instance?.exit?.(),e.instance=void 0}function Mt(e,n){if(Array.isArray(e))for(const t of e){if(!t)continue;const e=Mt(t,n);if(e)return e}else{if(e.impl===n)return e.instance??null;if(e.child)return Mt(e.child,n)}return null}function Ut(n){const{url:t,mock:i,onIframeComplete:a}=n,r=u(null),o=d(e=>{if(!r.current)return;const n=r.current.contentWindow;e.source===n&&"xendit-iframe-action-complete"===e.data?.type&&a(e.data)},[a]);return h(()=>(window.addEventListener("message",o),()=>{window.removeEventListener("message",o)}),[o]),e("iframe",i?{ref:r,srcDoc:Lt,className:"xendit-action-iframe"}:{ref:r,src:t,className:"xendit-action-iframe"})}const Lt="\n <html>\n <head>\n <title>Xendit Mock Action Iframe</title>\n <style>\n body {\n font-family: Arial, sans-serif;\n font-size: 14px;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 12px;\n }\n p {\n margin: 0;\n }\n .buttons {\n display: flex;\n gap: 8px;\n }\n button {\n font-size: 12px;\n display: flex;\n align-items: center;\n text-align: left;\n background-color: white;\n border: 1px solid rgba(243, 243, 243);\n border-radius: 4px;\n justify-content: space-between;\n padding: 4px;\n cursor: pointer;\n }\n button:hover {\n border-color: #1762ee;\n background-color: #1762ee;\n color: white;\n }\n </style>\n </head>\n <body>\n <p>This is a mock action page.</p>\n <p>Normally, this would be a 3DS authentication page.</p>\n <p>Click a button below to simulate the result of the action.</p>\n <div class=\"buttons\">\n <button onclick=\"parent.postMessage({type: 'xendit-iframe-action-complete', mockStatus: 'success'}, '*')\">\n Simulate Success\n </button>\n <button onclick=\"parent.postMessage({type: 'xendit-iframe-action-complete', mockStatus: 'fail'}, '*')\">\n Simulate Failure\n </button>\n </div>\n </body>\n </html>\n";function Ot(t){const{amount:i,businessName:a,channelLogo:r,currency:o,onAffirm:s,qrString:l,title:c,t:u}=t,[h,_]=p(!1),f=d(()=>{_(!0),s()},[s]),b=m(()=>{try{return function(e){const n=E.create(e),t=1,i=A.render(n,{margin:t}),a=(new DOMParser).parseFromString(i,"image/svg+xml").documentElement;a.style.width="100%",a.style.height="100%",a.setAttribute("width",String(n.modules.size+2*t)),a.setAttribute("height",String(n.modules.size+2*t));const r=a.querySelector("[fill]");r?.setAttribute("fill","var(--xendit-qr-background-color)");const o=a.querySelector("[stroke]");return o?.setAttribute("stroke","var(--xendit-qr-foreground-color)"),a}(l)}catch(e){console.log("Error generating QR code SVG:",e);const n=document.createElement("div");return n.innerText=u("action_qr.unable_to_generate"),n}},[l,u]);return t.hideUi?e("div",{"data-testid":"qr-code",ref:e=>{!e||1===e.childNodes.length&&e.firstChild===b||e?.replaceChildren(b)}}):n("div",{className:"xendit-action-present-to-customer",children:[e("img",{src:r,alt:"Channel Logo",className:"xendit-action-qr-channel-logo"}),e("div",{className:"xendit-action-title",children:c}),n("div",{className:"xendit-action-qr-content",children:[e("div",{className:"xendit-text-16 xendit-text-semibold xendit-text-center",children:a}),e("div",{"data-testid":"qr-code",className:"xendit-action-qr-qrcode-container",ref:e=>{!e||1===e.childNodes.length&&e.firstChild===b||e?.replaceChildren(b)}}),e("div",{className:"xendit-text-16 xendit-text-semibold xendit-text-center",children:En(i,o)})]}),n("div",{className:"xendit-action-present-to-customer-affirm",children:[e(Re,{variant:Se.WHITE_ROUNDED,disabled:h,onClick:f,className:"xendit-button-block",children:h?e(Ie,{}):u("action.payment_made")}),e("div",{className:"xendit-text-12 xendit-text-secondary xendit-text-center",children:u("action.payment_confirmation_instructions")})]})]})}const qt=t=>{const{title:i,onClose:a,children:r,seamless:o}=t,s=u(!1),l=u(!1),c=u(null),p=u(null),m=void 0!==HTMLElement.prototype.animate,_=d(()=>{s.current||(s.current=!0,a())},[a]),f=d(()=>{if(!c.current||!p.current||l.current)return;if(l.current=!0,!m)return void _();p.current.animate?.(Kt,Bt);const e=c.current.animate?.(Ft,Bt);e.onfinish=_},[_,m]);return h(()=>{m&&(p.current?.animate?.(Vt,Bt),c.current?.animate?.(Wt,Bt))},[m]),h(()=>{t.close&&f()},[t.close,f]),e("div",{className:"xendit-dialog-backdrop",ref:p,children:n("div",{className:"xendit-dialog",ref:c,children:[o?e("button",{"aria-label":"Close",onClick:f,className:"xendit-dialog-floating-close",children:e(P,{name:"x",size:20})}):n("div",{className:"xendit-dialog-header xendit-text-16 xendit-text-semibold",children:[i,e("button",{"aria-label":"Close",onClick:f,children:e(P,{name:"x",size:20})})]}),e("div",{className:"xendit-dialog-body",children:r})]})})},Bt={duration:200,easing:"ease-in-out",fill:"forwards"},Vt=[{backgroundColor:"rgba(0, 0, 0, 0)"},{backgroundColor:"rgba(0, 0, 0, 0.5)"}],Kt=Vt.slice().reverse(),Wt=[{opacity:0,transform:"scale(0.9) translateY(-20px)"},{opacity:1,transform:""}],Ft=Wt.slice().reverse();function $t(n){const{sdk:t,title:i,onClose:a,width:r,height:o}=n,s=u(null);return h(()=>{const e=t.createActionContainerComponent(I);return s.current?.replaceChildren(e),()=>{t.destroyComponent(e)}},[t]),e(qt,{title:i,onClose:a,close:n.close,seamless:!0,children:e("div",{className:"xendit-default-action-container",ref:s,style:{width:r?`calc(min(100vw - 64px, ${r}px))`:"calc(100vw - 64px)",height:o?`calc(min(100vh - 64px, ${o}px))`:void 0}})})}const Gt=({instructions:n})=>{switch(n.length){case 0:return null;case 1:return e(Xt,{instruction:n[0]});default:return e(Ht,{instructions:n})}},Xt=t=>n("div",{children:[e("p",{className:"xendit-instructions-single-tab-heading",children:t.instruction.title}),e(Yt,{instruction:t.instruction})]}),Ht=t=>{const[i,a]=p(0);return n("div",{children:[e("div",{className:"xendit-instructions-tab-list",children:t.instructions.map((n,t)=>e("button",{className:b("xendit-instructions-tab-button",{"xendit-instructions-active-tab":i===t}),onClick:()=>a(t),children:n.title},t))}),e(Yt,{instruction:t.instructions[i]})]})},Yt=n=>e("ol",{className:"xendit-instructions-numbered-list","data-testid":"instructions-steps",children:n.instruction.content.map((n,t)=>{const i=Array.isArray(n)?n:[n];return e("li",{className:"xendit-instructions-step-li",children:e("div",{className:"xendit-instructions-step-box",children:i.map((n,t)=>e(o,{children:Qt(n)},t))})},t)})});function zt(n){return Array.from(n).map((n,t)=>{switch(n.nodeType){case Node.TEXT_NODE:return null===n.textContent?null:n.textContent;case Node.ELEMENT_NODE:return function(n,t){const i=b({"xendit-instructions-bold":"B"===n.nodeName,"xendit-instructions-italics":"I"===n.nodeName});return i?e("span",{className:i,children:zt(n.childNodes)},t):zt(n.childNodes)}(n,t);default:return null}})}const jt="undefined"!=typeof DOMParser?new DOMParser:null;function Zt(e){try{if(!jt)return e;return zt(jt.parseFromString(e,"text/html").body.childNodes)}catch(n){return e}}function Qt(t){if("string"==typeof t)return e("p",{className:"xendit-instructions-step-item",children:Zt(t)});switch(t.type){case"text":return function(n){return e("p",{children:Zt(n.text)})}(t);case"image":return function(n){return e("div",{children:e("img",{src:n.src,alt:n.alt||"",style:{height:`${n.height??24}px`}})})}(t);case"bullets":return function(n){return e("ul",{className:"xendit-instructions-bullet-list",children:n.items.map((n,t)=>e("li",{children:Zt(n)},t))})}(t);case"form":return function(t){return n("div",{className:"xendit-instructions-form-card",children:[t.heading?e("h3",{className:"xendit-instructions-form-heading",children:Zt(t.heading)}):null,t.fields.map((t,i)=>n("div",{className:"xendit-instructions-form-field",children:[e("div",{className:"xendit-instructions-form-field-label",children:Zt(t.label)}),e("div",{className:"xendit-instructions-form-field-value",children:Zt(t.value)})]},i))]})}(t);case"table":return function(t){return n("table",{className:"xendit-instructions-table",children:[e("thead",{children:e("tr",{children:t.headers.map((n,t)=>e("th",{className:"xendit-instructions-table-header",children:Zt(n)},t))})}),e("tbody",{children:t.rows.map((n,t)=>e("tr",{children:n.map((n,t)=>e("td",{className:"xendit-instructions-table-cell",children:Zt(n)},t))},t))})]})}(t)}return null}const Jt=r({fire:()=>{},text:""}),ei=({children:n})=>{const[t,i]=p("");return e(Jt.Provider,{value:{text:t,fire:e=>{i(e);const n=setTimeout(()=>{i("")},2e3);return()=>clearTimeout(n)}},children:e("div",{style:{position:"relative"},children:n})})},ni=()=>{const{text:n}=c(Jt);return n?e("div",{className:"xendit-tooltip",children:n}):null};function ti(t){const{amount:i,channelLogo:a,currency:r,onAffirm:o,vaNumber:s,merchantName:l,instructions:c,title:u,t:h}=t,[m,_]=p(!1),f=d(()=>{_(!0),o()},[o]),b=[{heading:h("action_va.merchant_name"),value:l},{heading:h("action_va.virtual_account_number"),value:s,enableCopy:!0},{heading:h("action_va.amount_to_pay"),value:En(i,r),enableCopy:!0}];return n("div",{className:"xendit-action-present-to-customer",children:[e("img",{src:a,alt:"Channel Logo",className:"xendit-action-qr-channel-logo"}),e("div",{className:"xendit-action-title",children:u}),e("div",{className:"xendit-action-va-content",children:e("div",{className:"xendit-action-va-details",children:b.map((t,i)=>n("div",{className:"xendit-action-va-detail-item",children:[n("div",{className:"xendit-action-va-detail-content",children:[e("div",{className:"xendit-action-va-heading xendit-text-12 xendit-text-semibold",children:t.heading}),e("div",{className:"xendit-action-va-value xendit-text-semibold",children:t.value})]}),t.enableCopy?n(ei,{children:[e(ii,{value:t.value,t:h}),e(ni,{})]}):null]},i))})}),n("div",{className:"xendit-action-present-to-customer-affirm",children:[e(Re,{variant:Se.WHITE_ROUNDED,disabled:m,onClick:f,className:"xendit-button-block",children:m?e(Ie,{}):h("action.payment_made")}),e("div",{className:"xendit-text-12 xendit-text-secondary xendit-text-center",children:h("action.payment_confirmation_instructions")})]}),e(Gt,{instructions:c})]})}const ii=({value:t,t:i})=>{const{fire:a}=c(Jt);return n(Re,{variant:Se.WHITE_ROUNDED,size:Ne.SM,onClick:()=>{navigator.clipboard.writeText(t),a(i("action_va.copied_to_clipboard"))},children:[i("action_va.copy"),e(P,{name:"copy",size:16})]})};var ai;function ri(e){return"payment_request_id"in e?{id:e.payment_request_id,type:ai.PaymentRequest,entity:e}:{id:e.payment_token_id,type:ai.PaymentToken,entity:e}}function oi(e,n,t){return`${e===ai.PaymentRequest?"payment_request":"payment_token"}_status.${n.toLowerCase()}.${t}`}!function(e){e.PaymentRequest="REQUEST",e.PaymentToken="TOKEN"}(ai||(ai={}));function si(e,n,t){const{session:i,paymentEntity:a}=e;switch(z(i),z(a),z(n),t){case"PENDING":return li(i);case"PENDING_PAYMENT_ENTITY_ONLY":return function(e,n){const t=n.type===ai.PaymentRequest?n.entity:void 0,i=n.type===ai.PaymentToken?n.entity:void 0;return{session:e,payment_request:di(t,"PENDING"),payment_token:di(i,"PENDING")}}(i,a);case"SUCCESS":return"PENDING"===n._mock_action_type?li(i):function(e,n){const t=n.type===ai.PaymentRequest?n.entity:void 0,i=n.type===ai.PaymentToken?n.entity:void 0;return{session:{...e,status:"COMPLETED",payment_request_id:t?.payment_request_id,payment_token_id:i?.payment_token_id},payment_request:di(t,"SUCCEEDED"),payment_token:di(i,"ACTIVE"),succeeded_channel:{channel_code:n.entity.channel_code,logo_url:"https://placehold.co/48"}}}(i,a);case"FAILURE":return function(e,n){const t=n.type===ai.PaymentRequest?n.entity:void 0,i=n.type===ai.PaymentToken?n.entity:void 0;return{session:{...e,status:"ACTIVE"},payment_request:di(t,"FAILED"),payment_token:di(i,"FAILED")}}(i,a)}}function li(e){return{session:{...e,status:"PENDING"}}}function di(e,n){return e?{...e,status:n}:e}function ci(e,n){return"PENDING"===n?{payment_request_id:`pr-${pe()}`,status:"PENDING",channel_code:e,actions:[],session_token_request_id:pe()}:n?{payment_request_id:`pr-${pe()}`,status:"REQUIRES_ACTION",channel_code:e,actions:ui(n),session_token_request_id:pe()}:{payment_request_id:`pr-${pe()}`,status:"SUCCEEDED",channel_code:e,actions:[],session_token_request_id:pe()}}function ui(e){if(!e)return[];return(Array.isArray(e)?e:[e]).map(e=>function(e){if("PENDING"===e)throw new Error("PENDING mock action type should not generate an action");switch(e){case"IFRAME":return{type:"REDIRECT_CUSTOMER",descriptor:"WEB_URL",value:"https://example.com/iframe",iframe_capable:!0};case"REDIRECT":return{type:"REDIRECT_CUSTOMER",descriptor:"WEB_URL",value:"https://example.com/redirect",iframe_capable:!1};case"PAYLINK":return{type:"REDIRECT_CUSTOMER",descriptor:"WEB_GOOGLE_PAYLINK",value:"https://example.com/paylink"};case"DEEP_LINK":return{type:"REDIRECT_CUSTOMER",descriptor:"DEEPLINK_URL",value:"mockapp://mock-deep-link"};case"PUSH_NOTIFICATION":return null;case"QR":return{type:"PRESENT_TO_CUSTOMER",descriptor:"QR_STRING",value:"https://example.com/qr-code-data",action_title:"Pay with QR Code",action_subtitle:"Scan the QR code below",action_graphic:"",instructions:null};case"BARCODE":return{type:"PRESENT_TO_CUSTOMER",descriptor:"PAYMENT_CODE",value:"1234567890",action_title:"Pay at a Store",action_subtitle:"Show this barcode to the cashier",action_graphic:"",instructions:null};case"VA":return{type:"PRESENT_TO_CUSTOMER",descriptor:"VIRTUAL_ACCOUNT_NUMBER",value:"1234567890",action_title:"Pay with Virtual Account",action_subtitle:"Protect yourself from fraud - ensure all details are correct",action_graphic:"",instructions:[{title:"Mobile Banking",content:[{type:"text",text:"Open Mobile App"},{type:"text",text:"Select <b>Mock VA</b>, then select <b>Transfer</b>"},{type:"text",text:"Enter your Virtual Account Number, for example 3816523906568, then press <b>OK</b>"},{type:"text",text:"Click on <b>Send</b> button at the top right corner to proceed"},{type:"text",text:"Click <b>OK</b> to proceed"},{type:"text",text:"Enter your PIN to authorize the transaction"}]},{title:"Internet Banking",content:[{type:"text",text:"Login to the website"},{type:"text",text:"Select <b>Transfer</b>, then select <b>Transfer to Mock VA Virtual Account</b>"},{type:"text",text:"Enter the Virtual Account Number, for example 3816523906568"},{type:"text",text:"Select <b>Continue</b> to proceed your payment"}]},{title:"ATM",content:[{type:"text",text:"Insert your ATM card and PIN"},{type:"text",text:"Enter your ATM PIN"},{type:"text",text:"Select <b>Transfer</b>"},{type:"text",text:"Select <b>To Mock VA Virtual Account</b>"},{type:"text",text:"Enter Virtual Account Number, for example 3816523906568. Press <b>Correct</b> to proceed"},{type:"text",text:"Verify Virtual Account details and then enter amount to be transferred and select <b>Correct</b> to confirm"},{type:"text",text:"Confirm your transaction details displayed"},{type:"text",text:"Select <b>Yes</b> if the details are correct or <b>No</b> if the details are not correct"}]}]}}throw new Error(`Unknown mock action type: ${e}`)}(e)).filter(e=>null!==e)}const hi=t=>n("div",{className:"xendit-redirect-instructions",children:[e("div",{className:"xendit-redirect-instructions-logo",children:e("img",{src:t.logoUrl,alt:t.logoAlt})}),n("div",{className:"xendit-redirect-instructions-text",children:[e("div",{className:"xendit-text-16",children:t.title}),t.subtitle?e("div",{className:"xendit-text-14 xendit-text-secondary",children:t.subtitle}):null]}),t.redirectUrl?e("a",{href:t.redirectUrl,className:"xendit-redirect-instructions-button xendit-text-14",children:t.redirectButtonLabel??""}):null]}),pi=n=>{const t=n.t,i=n.channel,a=i.brand_name;return e(hi,{title:t("action_empty_list_push_notification.title"),subtitle:t("action_empty_list_push_notification.subtext",{channelName:a}),logoUrl:i.brand_logo_url,logoAlt:t("image_alt.channel_logo",{channelName:a}),redirectUrl:null,redirectButtonLabel:null})},mi=n=>{const t=n.t,i=n.channel,a=i.brand_name;return e(hi,{title:t("action_deeplink.title"),subtitle:t("action_deeplink.instructions",{channelName:a}),logoUrl:i.brand_logo_url,logoAlt:t("image_alt.channel_logo",{channelName:a}),redirectUrl:n.redirectUrl,redirectButtonLabel:t("action_deeplink.button",{channelName:a})})};class ContainerActionBehavior{bb;cleanupFn=null;defaultContainerHeight=0;defaultContainerWidth=400;title="Complete your payment";constructor(e){this.bb=e}ensureHasActionContainer(){if(this.bb.sdk[I].liveComponents.actionContainer)return()=>{this.emptyActionContainer()};let e=!1,n=!1;const t=document.createElement("div");t.setAttribute("class","xendit-default-action-container");const a={sdk:this.bb.sdk,title:this.title,width:this.defaultContainerWidth,height:this.defaultContainerHeight,onClose:()=>{e=!0,i(null,t),t.remove(),n||this.bb.sdk.abortSubmission()}};return i(s($t,a),t),document.body.appendChild(t),r=>{r||(n=!0),e||i(s($t,{...a,close:!0}),t)}}cleanupActionContainer(e){this.cleanupFn&&(this.cleanupFn(e),this.cleanupFn=null)}emptyActionContainer(){const e=this.bb.sdk[I].liveComponents.actionContainer;e&&i(null,e)}updateActionContainerBrandColor(){z(this.bb.channel);const e=this.bb.sdk[I].liveComponents.actionContainer;e&&e.style.setProperty("--xendit-channel-brand-color",this.bb.channel.brand_color)}populateActionContainer(e){const n=this.bb.sdk[I].liveComponents.actionContainer;if(!n)throw new Error("Trying to populate action container, but it is missing; A default action container should have been created. This is a bug, please contact support.");this.updateActionContainerBrandColor(),i(e(),n)}exit(){this.cleanupActionContainer(!1),this.emptyActionContainer()}}class ActionCompletedBehavior{bb;constructor(e){this.bb=e}enter(){}}class ActionRedirectBehavior{bb;url;constructor(e,n){this.bb=e,this.url=n}enter(){this.bb.dispatchEvent(new XenditWillRedirectEvent),window.location.href=this.url}}class ActionIframeBehavior extends ContainerActionBehavior{bb;url;constructor(e,n){super(e),this.bb=e,this.url=n,this.defaultContainerHeight=600}enter(){this.cleanupFn=this.ensureHasActionContainer(),this.populateActionContainer(()=>s(Ut,{url:this.url,mock:this.bb.mock,onIframeComplete:e=>{this.cleanupActionContainer(!1);const n="success"===e.mockStatus?"SUCCESS":"FAILURE";this.updateMocksOnIframeCompletion(n),this.bb.actionCompleted=!0,this.bb.pollImmediatelyRequested=!0,this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)}}))}updateMocksOnIframeCompletion(e){z(this.bb.world?.paymentEntity),this.bb.mock&&this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(si(this.bb.world,this.bb.channel,e)))}exit(){super.exit()}}class ActionQrBehavior extends ContainerActionBehavior{bb;actionIndex;constructor(e,n){super(e),this.bb=e,this.actionIndex=n}enter(){const e=this.bb.world?.paymentEntity?.entity.actions[Number(this.actionIndex)];Q(e?.type,"PRESENT_TO_CUSTOMER"),z(this.bb.world),z(this.bb.channel);const n=this.bb.sdk[I].liveComponents.actionContainer,t={amount:this.bb.world.session.amount,businessName:this.bb.world.business.name??"",channelLogo:this.bb.channel.brand_logo_url,currency:this.bb.world.session.currency,hideUi:"true"===n?.getAttribute("data-qr-code-only")||!1,onAffirm:this.affirmPayment.bind(this),qrString:e.value,title:e.action_subtitle,t:this.bb.sdk.t.bind(this.bb.sdk)};this.cleanupFn=this.ensureHasActionContainer(),this.populateActionContainer(()=>s(Ot,t))}affirmPayment(){this.bb.sdk.isProdLive()?this.bb.pollImmediatelyRequested=!0:this.bb.simulatePaymentRequested=!0,this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)}exit(){super.exit()}}class ActionDeepLinkBehavior extends ContainerActionBehavior{bb;actionIndex;constructor(e,n){super(e),this.bb=e,this.actionIndex=n}enter(){z(this.bb.world);const e=this.bb.world?.paymentEntity?.entity.actions[Number(this.actionIndex)];if(Q(e?.type,"REDIRECT_CUSTOMER"),"DEEPLINK_URL"!==e.descriptor&&"WEB_URL"!==e.descriptor)throw new Error("Unexpected action type in ActionDeepLinkBehavior");const n=this.bb.sdk.t.bind(this.bb.sdk),t=this.bb.channel;z(t),this.cleanupFn=this.ensureHasActionContainer(),this.populateActionContainer(()=>s(mi,{t:n,channel:t,redirectUrl:e.value}))}exit(){super.exit()}}class ActionEmptyListPushNotificationBehavior extends ContainerActionBehavior{bb;constructor(e){super(e),this.bb=e}enter(){z(this.bb.world),this.bb.hackyOvoActionLatch=!0;const e=this.bb.sdk.t.bind(this.bb.sdk),n=this.bb.channel;z(n),this.cleanupFn=this.ensureHasActionContainer(),this.populateActionContainer(()=>s(pi,{t:e,channel:n})),this.bb.mock&&this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(si(this.bb.world,this.bb.channel,"PENDING_PAYMENT_ENTITY_ONLY")))}exit(){this.bb.hackyOvoActionLatch=void 0,super.exit()}}class ActionVaBehavior extends ContainerActionBehavior{bb;actionIndex;constructor(e,n){super(e),this.bb=e,this.actionIndex=n}enter(){const e=this.bb.world?.paymentEntity?.entity.actions[Number(this.actionIndex)];Q(e?.type,"PRESENT_TO_CUSTOMER"),z(this.bb.world),z(this.bb.channel);const n={amount:this.bb.world.session.amount,channelLogo:this.bb.channel.brand_logo_url,currency:this.bb.world.session.currency,onAffirm:this.affirmPayment.bind(this),vaNumber:e.value,merchantName:this.bb.world.business.name??"",instructions:e.instructions??[],title:e.action_title,t:this.bb.sdk.t.bind(this.bb.sdk)};this.cleanupFn=this.ensureHasActionContainer(),this.populateActionContainer(()=>s(ti,n))}affirmPayment(){this.bb.sdk.isProdLive()?this.bb.pollImmediatelyRequested=!0:this.bb.simulatePaymentRequested=!0,this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)}}class ActionPaylinkBehavior{bb;actionIndex;el=null;constructor(e,n){this.bb=e,this.actionIndex=n}enter(){z(this.bb.world),z(this.bb.world.paymentEntity);const e=this.bb.world?.paymentEntity?.entity.actions[Number(this.actionIndex)];if(!e)throw new Error("Action not found for paylink behavior");Q(e.type,"REDIRECT_CUSTOMER"),Q(e.descriptor,"WEB_GOOGLE_PAYLINK");const n=document.createElement("link");n.rel="facilitated-payment",n.href=e.value,this.el=n,document.head.appendChild(n)}exit(){this.el?.remove(),this.el=null}}class CardInfoBehavior{bb;channelCode;cardDetailsRequest=null;constructor(e,n){this.bb=e,this.channelCode=n}enter(){this.lookupCardDetails()}update(){this.lookupCardDetails()}exit(){this.abortLookupCardDetails()}abortLookupCardDetails(){this.cardDetailsRequest&&(this.cardDetailsRequest.abortController.abort(new AbortError),this.cardDetailsRequest=null)}lookupCardDetails(){const e=xe(this.bb.channelProperties);if(!e)return;if(this.cardDetailsRequest?.cardNumber===e)return;if(this.bb.channelData?.cardDetails?.cardNumber===e)return;this.cardDetailsRequest&&this.abortLookupCardDetails();const n=new AbortController,t=ne(300,n.signal).then(()=>{if(this.bb.mock){const n=ge(e).cipherText;try{return JSON.parse(atob(n))}catch{}return{schemes:["VISA"],country_codes:["ID"],require_billing_information:!1}}{const t=ge(e).withoutValidationError;return Pt(this.bb.sdkKey,{card_number:t},this.bb.sdkKey.sessionAuthKey,void 0,n.signal)}}).then(n=>{this.bb.dispatchEvent(new InternalUpdateChannelComponentData(this.channelCode,{cardDetails:{cardNumber:e,details:n}}))}).catch(e=>{if(!ee(e))throw e});this.cardDetailsRequest={cardNumber:e,promise:t,abortController:n}}}class ChannelValidBehavior{bb;lastChannelCode=null;constructor(e){this.bb=e}enter(){this.sendReadyEventIfChanged()}update(){this.sendReadyEventIfChanged()}sendReadyEventIfChanged(){const e=this.bb.channel?.channel_code??null;e&&e!==this.lastChannelCode&&(this.bb.dispatchEvent(new XenditReadyEvent(e)),this.lastChannelCode=e)}exit(){this.bb.dispatchEvent(new XenditNotReadyEvent)}}class ChannelInvalidBehavior{bb;channelCode;constructor(e,n){this.bb=e,this.channelCode=n}enter(){}}class PollWorker{sdkKey;sdk;sessionTokenRequestId;onPollResult;started=!1;stopped=!1;constructor(e,n,t,i){this.sdkKey=e,this.sdk=n,this.sessionTokenRequestId=t,this.onPollResult=i}async start(){if(this.stopped)throw new Error("PollWorker has been stopped, make a new instance instead of calling start again");this.started=!0;for await(const e of async function*(e,n,t=2){yield 0;let i=e;for(let e=1;e<n;e++)i*=t,await J(i),yield e}(5e3,100,1.06)){if(this.stopped)return;let e;if(this.sdk.isMock()){if(!(this.sdk instanceof XenditComponentsTest&&this.sdk.nextMockUpdate))continue;await J(Y),e=this.sdk.nextMockUpdate,this.sdk.nextMockUpdate=null}else try{e=await At(this.sdkKey,this.sdkKey.sessionAuthKey,this.sessionTokenRequestId)}catch(e){continue}if(this.stopped)return;if(!e.session)throw new Error("Session is not defined");let n=null;e.payment_token?n=ri(e.payment_token):e.payment_request&&(n=ri(e.payment_request)),this.onPollResult(e,n),await J(1)}}isPolling(){return this.started&&!this.stopped}stop(){this.started=!1,this.stopped=!0}}class PePendingBehavior{bb;pollWorker;constructor(e){this.bb=e,this.pollWorker=new PollWorker(this.bb.sdkKey,this.bb.sdk,this.bb.world?.sessionTokenRequestId??null,this.onPollResult)}enter(){if(this.bb.mock)switch(z(this.bb.world?.paymentEntity),this.bb.world?.paymentEntity.entity.status){case"ACTIVE":case"AUTHORIZED":case"SUCCEEDED":case"PENDING":this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(si(this.bb.world,this.bb.channel,"SUCCESS")));break;case"FAILED":case"CANCELED":case"EXPIRED":this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(si(this.bb.world,this.bb.channel,"FAILURE")))}this.pollWorker.start()}exit(){this.pollWorker.stop()}onPollResult=(e,n)=>{this.bb.dispatchEvent(new InternalUpdateWorldState({session:e.session,paymentEntity:n??void 0,succeededChannel:e.succeeded_channel??null}))}}class PeRequiresActionBehavior{bb;pollWorker=null;canCreateActionContainer=!0;constructor(e){this.bb=e,this.resetPolling()}enter(){this.bb.dispatchEvent(new XenditActionBeginEvent),this.canCreateActionContainer=!1,this.pollWorker?.start()}update(){this.bb.pollImmediatelyRequested&&(this.bb.pollImmediatelyRequested=!1,this.resetPolling())}exit(){this.pollWorker?.stop(),this.bb.dispatchEvent(new XenditActionEndEvent),this.bb.actionCompleted=!1}onPollResult=(e,n)=>{this.bb.dispatchEvent(new InternalUpdateWorldState({session:e.session,paymentEntity:n??void 0,succeededChannel:e.succeeded_channel??null}))};resetPolling(){const e=this.pollWorker?.isPolling()??!1;this.pollWorker?.stop(),this.pollWorker=new PollWorker(this.bb.sdkKey,this.bb.sdk,this.bb.world?.sessionTokenRequestId??null,this.onPollResult),e&&this.pollWorker.start()}}class PeFailedBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.submissionRequested=!1,this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)}}class PaymentOptionsBehavior{bb;channelCode;paymentOptionsRequest=null;constructor(e,n){this.bb=e,this.channelCode=n}enter(){this.lookupPaymentOptions()}update(){this.lookupPaymentOptions()}exit(){this.abortLookupPaymentOptions()}abortLookupPaymentOptions(){this.paymentOptionsRequest&&(this.paymentOptionsRequest.abortController.abort(new AbortError),this.paymentOptionsRequest=null)}lookupPaymentOptions(){let e;if(z(this.bb.world),z(this.bb.channel),Pe(this.bb.channel.form,"credit_card_number")){if(e=xe(this.bb.channelProperties)??void 0,!e)return;if(this.paymentOptionsRequest?.cardNumber===e)return;if(this.bb.channelData?.paymentOptions?.cardNumber??null===e)return;if(e){if(!ge(e).valid)return}}else if(this.paymentOptionsRequest||this.bb.channelData?.paymentOptions)return;this.paymentOptionsRequest&&this.abortLookupPaymentOptions();const n=new AbortController,t=async function(e,n,t,i,a,r){if(r)return ne(Y,a).then(()=>function(e,n){return{channel_code:e,country:n.country,currency:n.currency,amount:n.amount,installment_plans:[{interval:"MONTH",interval_count:1,terms:3,installment_amount:Math.floor(n.amount/3),total_amount:n.amount,description:"Unused",code:"3M",interest_rate:1},{interval:"MONTH",interval_count:1,terms:6,installment_amount:Math.floor(n.amount/6),total_amount:n.amount,description:"Unused",code:"6M",interest_rate:1},{interval:"MONTH",interval_count:1,terms:9,installment_amount:Math.floor(n.amount/9),total_amount:n.amount,description:"Unused",interest_rate:1,code:void 0}]}}(t,n));return St(e,{channel_code:t,channel_properties:i?{card_number:i}:void 0},e.sessionAuthKey,null,a)}(this.bb.sdkKey,this.bb.world.session,this.bb.channel.channel_code,e,n.signal,this.bb.mock).then(n=>{this.bb.dispatchEvent(new InternalUpdateChannelComponentData(this.channelCode,{paymentOptions:{cardNumber:e??null,options:n}}))}).catch(e=>{if(!ee(e))throw e});this.paymentOptionsRequest={cardNumber:e??void 0,promise:t,abortController:n}}}class SdkLoadingBehavior{bb;constructor(e){this.bb=e}enter(){}}class SdkActiveBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new XenditInitEvent),this.bb.dispatchEvent(new InternalNeedsRerenderEvent)}exit(){this.bb.dispatchEvent(new InternalNeedsRerenderEvent)}}class SdkFatalErrorBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new XenditFatalErrorEvent(this.bb.sdkFatalErrorMessage??"Unknown error"))}}function _i(e,n){switch(e.type){case ai.PaymentRequest:n(new XenditPaymentRequestDiscardedEvent(e.id));break;case ai.PaymentToken:n(new XenditPaymentTokenDiscardedEvent(e.id))}n(new InternalUpdateWorldState({paymentEntity:null,sessionTokenRequestId:null}))}class SessionActiveBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new InternalNeedsRerenderEvent)}exit(){this.bb.dispatchEvent(new InternalNeedsRerenderEvent)}}class SessionCompletedBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new XenditSessionCompleteEvent)}}class SessionFailedBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new XenditSessionExpiredOrCanceledEvent)}}class SessionPendingBehavior{bb;pollWorker;constructor(e){this.bb=e,this.pollWorker=new PollWorker(this.bb.sdkKey,this.bb.sdk,this.bb.world?.sessionTokenRequestId??null,this.onPollResult)}enter(){this.pollWorker.start(),this.bb.dispatchEvent(new XenditSessionPendingEvent)}exit(){this.pollWorker.stop(),z(this.bb.world?.session);const e=this.bb.world.paymentEntity;"COMPLETED"!==this.bb.world.session.status&&e&&_i(e,this.bb.dispatchEvent),this.bb.dispatchEvent(new XenditSessionNotPendingEvent)}onPollResult=(e,n)=>{this.bb.dispatchEvent(new InternalUpdateWorldState({session:e.session,paymentEntity:n??void 0,succeededChannel:e.succeeded_channel??null}))}}class SimulatePaymentBehavior{bb;exited=!1;simulationRequest=null;constructor(e){this.bb=e}enter(){this.simulatePayment()}exit(){this.exited=!0,this.bb.simulatePaymentRequested=!1,this.abortSimulation()}abortSimulation(){this.simulationRequest&&(this.simulationRequest.abortController.abort(new AbortError),this.simulationRequest=null)}simulatePayment(){if(this.simulationRequest&&this.abortSimulation(),!this.bb.channel)throw new Error("Channel is missing");if(!this.bb.world)throw new Error("Invalid state");if(!this.bb.world.paymentEntity)throw new Error("Payment entity is missing");if(this.bb.world.paymentEntity.type!==ai.PaymentRequest)throw new Error("Payment entity is not a payment request");const e=this.bb.world?.paymentEntity.id,n=new AbortController,t=async function(e,n,t,i,a){return n?(await ne(Y,a),ci(t.channel_code,t._mock_action_type)):await Et(e,{channel_code:t.channel_code},{sessionAuthKey:e.sessionAuthKey,paymentRequestId:i},void 0,a)}(this.bb.sdkKey,this.bb.mock,this.bb.channel,e,n.signal).then(()=>{this.bb.mock&&this.bb.world&&this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(si(this.bb.world,this.bb.channel,"SUCCESS"))),this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)}).catch(e=>{ee(e)||this.exited||(this.bb.simulatePaymentRequested=!1,console.error("Simulate Payment failed:",e))});this.simulationRequest={promise:t,abortController:n}}}class SubmissionBehavior{bb;exited=!1;submission=null;submissionError=null;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new XenditSubmissionBeginEvent),this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(null)),this.submit()}exit(){this.exited=!0,z(this.bb.world?.session);const e=this.bb.sdk.t,n=this.bb.world.paymentEntity;let t,i,a;var r;"COMPLETED"!==this.bb.world.session.status&&"PENDING"!==this.bb.world.session.status&&n&&_i(n,this.bb.dispatchEvent),"ACTIVE"!==this.bb.world.session.status?t=`SESSION_${this.bb.world.session.status}`:!n||"FAILED"!==n.entity.status&&"CANCELED"!==n.entity.status&&"EXPIRED"!==n.entity.status?this.submissionError?(t="REQUEST_FAILED",!("message"in(r=this.submissionError))&&"text"in r&&"code"in r?(i=this.submissionError.text,a={type:"ERROR",code:this.submissionError.code}):(i=function(e){return[e("default_error.title"),e("default_error.message_1"),e("default_error.message_2")]}(e),a={type:"NETWORK_ERROR",code:"NETWORK_ERROR"})):t=this.submission?"REQUEST_ABORTED":"ACTION_ABORTED":(t=`PAYMENT_${n.type}_${n.entity.status}`,i=function(e,n,t,i){const a=e(oi(n,t,"title")),r=i?e(function(e){return`failure_code.${e.toLowerCase()}`}(i),e("failure_code_unknown",{failureCode:i})):e(oi(n,t,"subtext"));return[a,r]}(e,n.type,n.entity.status,n.entity.failure_code),a={type:"FAILURE",code:n.entity.failure_code??"UNKNOWN"}),this.bb.dispatchEvent(new XenditSubmissionEndEvent(t,i,a)),this.submission&&(this.submission?.abortController.abort(new AbortError),this.submission=null),this.bb.submissionRequested=!1,this.bb.dispatchEvent(new InternalNeedsRerenderEvent)}submit(){if(!this.bb.world?.session)throw new Error("Session object missing");if(!this.bb.channel)throw new Error("Channel missing");if(this.bb.instantSubmissionError)return this.bb.submissionRequested=!1,this.submissionError=this.bb.instantSubmissionError,this.bb.instantSubmissionError=null,void this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent);const e="OPTIONAL"===this.bb.world.session.allow_save_payment_method&&this.bb.channel?.allow_save,n=this.bb.world?.session?.session_type,t=this.bb.channel.channel_code,i=this.bb.channel._mock_action_type,a=this.bb.channelProperties??{},r=new AbortController,o=async function(e,n,t,i,a,r,o,s){let l;if(n)switch(t){case"PAY":await ne(Y,o.signal),l=ci(i,a);break;case"SAVE":await ne(Y,o.signal),l=function(e,n){return"PENDING"===n?{payment_token_id:`pt-${pe()}`,status:"PENDING",channel_code:e,actions:ui(n),session_token_request_id:pe()}:n?{payment_token_id:`pt-${pe()}`,status:"REQUIRES_ACTION",channel_code:e,actions:ui(n),session_token_request_id:pe()}:{payment_token_id:`pt-${pe()}`,status:"ACTIVE",channel_code:e,actions:[],session_token_request_id:pe()}}(i,a);break;default:throw new Error(`The session type ${t} is not supported.`)}else switch(t){case"PAY":l=await Ct(e,{session_id:e.sessionAuthKey,channel_code:i,channel_properties:r,save_payment_method:s},null,null,o.signal);break;case"SAVE":l=await wt(e,{session_id:e.sessionAuthKey,channel_code:i,channel_properties:r},null,null,o.signal);break;default:throw new Error(`The session type ${t} is not supported.`)}return ri(l)}(this.bb.sdkKey,this.bb.mock,n,t,i,a,r,e?this.bb.channelData?.savePaymentMethod??!1:void 0).then(e=>{switch(this.submission=null,e.type){case ai.PaymentRequest:this.bb.dispatchEvent(new XenditPaymentRequestCreatedEvent(e.id));break;case ai.PaymentToken:this.bb.dispatchEvent(new XenditPaymentTokenCreatedEvent(e.id))}this.bb.dispatchEvent(new InternalUpdateWorldState({paymentEntity:e,sessionTokenRequestId:e.entity.session_token_request_id}))}).catch(e=>{ee(e)||(console.error("Submission failed:",e),this.exited||(this.bb.submissionRequested=!1,this.submissionError=e instanceof NetworkError?{text:[e.errorResponse.error_content?.title,e.errorResponse.error_content?.message_1,e.errorResponse.error_content?.message_2].filter(e=>void 0!==e),code:e.errorResponse.error_code}:e,this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)))});this.submission={abortController:r,promise:o}}}function fi(e){switch(e.sdkStatus){case"LOADING":return Nt(SdkLoadingBehavior);case"ACTIVE":return Nt(SdkActiveBehavior,"active",function(e){switch(z(e.world?.session),e.world.session.status){case"ACTIVE":return Nt(SessionActiveBehavior,"active",e.submissionRequested?function(e){return z(e.world),Nt(SubmissionBehavior,"submission",e.world.paymentEntity&&null!==e.world.sessionTokenRequestId?function(e){function n(){return z(e.world?.paymentEntity),ie(e.sdk,e.world.paymentEntity.entity.actions)?function(e){z(e.world?.paymentEntity);const n=ie(e.sdk,e.world.paymentEntity.entity.actions);z(n);const t=e.world.paymentEntity.entity.actions.indexOf(n);return Nt(ActionPaylinkBehavior,String(t))}(e):void 0}if(z(e.world?.paymentEntity),e.hackyOvoActionLatch&&"PENDING"===e.world.paymentEntity.entity.status)return Nt(PeRequiresActionBehavior,e.world.paymentEntity.id,[Nt(ActionEmptyListPushNotificationBehavior,""),n()]);switch(e.world.paymentEntity.entity.status){case"PENDING":return Nt(PePendingBehavior);case"REQUIRES_ACTION":return Nt(PeRequiresActionBehavior,e.world.paymentEntity.id,[bi(e),n()]);case"FAILED":case"EXPIRED":case"CANCELED":return Nt(PeFailedBehavior);case"ACCEPTING_PAYMENTS":throw new Error("Status ACCEPTING_PAYMENTS should not happen");case"AUTHORIZED":case"ACTIVE":case"SUCCEEDED":return Nt(PePendingBehavior,e.world.paymentEntity.id);default:throw e.world.paymentEntity.entity,new Error(`Unknown payment entity status: ${e.world.paymentEntity.entity.status}`)}}(e):void 0)}(e):function(e){if(!e.channel||!e.world?.session)return;if(e.channelIsDigitalWallet)return;const n=function(e,n,t,i){t||(t={});for(const a of nt(e,n.form,t,i))if(Dn(a,t))return!1;return!0}(e.world.session.session_type,e.channel,e.channelProperties,e.channelData),t=Nt(n?ChannelValidBehavior:ChannelInvalidBehavior),i=Pe(e.channel.form,"credit_card_number")?Nt(CardInfoBehavior,e.channel.channel_code):void 0,a=Pe(e.channel.form,"installment_plan")?Nt(PaymentOptionsBehavior,e.channel.channel_code):void 0;return[t,i,a]}(e));case"COMPLETED":return Nt(SessionCompletedBehavior);case"EXPIRED":case"CANCELED":return Nt(SessionFailedBehavior,e.world.session.status);case"PENDING":return Nt(SessionPendingBehavior,e.world.session.status);default:throw e.world.session.status,new Error(`Unknown session status: ${e.world.session.status}`)}}(e));case"FATAL_ERROR":return Nt(SdkFatalErrorBehavior);default:throw e.sdkStatus,new Error(`Unknown SDK status: ${e.sdkStatus}`)}}function bi(e){if(z(e.world?.paymentEntity),e.actionCompleted)return Nt(ActionCompletedBehavior);const n=te(e.world.paymentEntity.entity.actions);if(!n)return Nt(ActionEmptyListPushNotificationBehavior,"");const t=e.world.paymentEntity.entity.actions.indexOf(n),i=!!ie(e.sdk,e.world.paymentEntity.entity.actions);let a;switch(e.simulatePaymentRequested&&_e(n)&&(a=Nt(SimulatePaymentBehavior)),n.type){case"REDIRECT_CUSTOMER":switch(n.descriptor){case"WEB_URL":return function(e){return"REDIRECT_CUSTOMER"===e.type&&!1!==e.iframe_capable}(n)?Nt(ActionIframeBehavior,n.value):i?Nt(ActionDeepLinkBehavior,String(t)):Nt(ActionRedirectBehavior,n.value);case"DEEPLINK_URL":return Nt(ActionDeepLinkBehavior,String(t));case"WEB_GOOGLE_PAYLINK":throw new Error("Paylink actions should not be the primary action")}break;case"PRESENT_TO_CUSTOMER":switch(n.descriptor){case"QR_STRING":return Nt(ActionQrBehavior,String(t),a);case"PAYMENT_CODE":throw new Error(`Unsupported action type ${n.type} ${n.descriptor}`);case"VIRTUAL_ACCOUNT_NUMBER":return Nt(ActionVaBehavior,String(t),a)}break;case"API_POST_REQUEST":switch(n.descriptor){case"CAPTURE_PAYMENT":case"VALIDATE_OTP":case"RESEND_OTP":throw new Error(`Unsupported action type ${n.type} ${n.descriptor}`)}}throw new Error(`Unknown action type: ${n.type} ${n.descriptor}`)}const yi=n=>{const{onReady:t,options:i}=n,a=G(),r=a.t,o=W(),s=(()=>{const e=c(U);if(null===e)throw new Error("useBusiness must be used within a XenditSessionProvider");return e})(),l=$(),p=l?.google_pay;z(p);const _=u(!1),f=u(null),b=u(null),y=m(()=>p.allowed_payment_methods.map(e=>e.payment_method_specification),[p.allowed_payment_methods]),x=m(()=>({apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:y,emailRequired:!0,merchantInfo:{merchantId:p.merchant_id,merchantName:s.name??""},transactionInfo:{transactionId:o.payment_session_id,totalPriceStatus:"FINAL",totalPrice:String(o.amount),currencyCode:o.currency}}),[s.name,p.merchant_id,y,o.amount,o.currency,o.payment_session_id]),g=m(()=>({buttonColor:"default",buttonType:"plain",buttonRadius:999,buttonSizeMode:"fill",buttonBorderType:"no_border",...i}),[i]);h(()=>{const e=window.google?.payments?.api?.PaymentsClient;e?b.current=new e({environment:a.isMock()?"TEST":"PRODUCTION"}):console.error("XenditComponents: Google Pay button was requested but the Google Pay SDK is not loaded.")},[a]);const v=d(()=>{z(b.current),b.current.loadPaymentData(x).then(function(e){const n=function(e){z(p);const n=a.getActiveChannels();for(const t of p.allowed_payment_methods)if(t.payment_method_specification.type===e.paymentMethodData.type)return xi(n,t.channel_code);throw new Error(`No matching channel found for selected Google Pay payment method ${e.paymentMethodData.type}`)}(e);z(n);let t={};"CARDS"===n.channelCode&&(t={google_pay:JSON.stringify(e)}),a.submitDigitalWallet("GOOGLE_PAY",n,t)}).catch(function(e){const n=e.statusCode??"UNKNOWN_ERROR";if("CANCELED"===n)return;function t(e,n){return`google_pay_errors.${e.toLowerCase()}.${n}`}const i={code:`GOOGLE_PAY_${n}`,text:[r(t(n,"title"),r("google_pay_errors.unknown_error.title")),r(t(n,"message"),r("google_pay_errors.unknown_error.message",{statusCode:n}))]},o=p.allowed_payment_methods[0];z(o);const s=xi(a.getActiveChannels(),o.channel_code);a.submitDigitalWallet("GOOGLE_PAY",s,{},i)})},[p,x,a,r]);return h(()=>{b.current&&(_.current||b.current.isReadyToPay({apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:y}).then(function(e){e.result&&(_.current||(_.current=!0,t()))}).catch(function(e){console.error("XenditComponents: Error when checking if Google Pay is ready",e)}))},[y,t]),h(()=>{if(!b.current)return;const e=b.current.createButton({...g,buttonLocale:o.locale,allowedPaymentMethods:y,onClick:v});f.current&&f.current.replaceChildren(e)},[g,y,v,o.locale]),e("div",{ref:f})};function xi(e,n){const t=e.find(e=>Array.isArray(e.channelCode)?e.channelCode.includes(n):e.channelCode===n);if(!t)throw new Error(`Channel not found for code: ${n}`);return t}const gi=e=>{const{scriptTagRegex:n,checkLoaded:t,children:i}=e,[,a]=p({}),r=t();return h(()=>{if(r)return;const e=Array.from(document.scripts).find(e=>n.test(e.src));if(e){const n=()=>{a({})};return e.addEventListener("load",n),()=>{e.removeEventListener("load",n)}}},[a,r,n]),h(()=>{if(!r){const e=setTimeout(()=>{a({})},1e3);return()=>clearTimeout(e)}}),r?i:null},vi=n=>{const{digitalWalletCode:t,digitalWalletOptions:i}=n,a=u(null),r=d(()=>{a.current?.parentElement?.style.setProperty("display","block")},[]);let o=null;if("GOOGLE_PAY"===t)o=e(gi,{scriptTagRegex:ki.GOOGLE_PAY.scriptTagRegex,checkLoaded:ki.GOOGLE_PAY.checkLoaded,children:e(yi,{onReady:r,options:i})});return e("div",{ref:a,children:o})},ki={GOOGLE_PAY:{scriptTagRegex:/https:\/\/pay.google.com\/.*\/js\/pay.js/,checkLoaded:()=>"undefined"!=typeof google&&void 0!==google.payments}};class XenditComponents extends EventTarget{t=e=>{throw new Error("Localization used before initialization; this is a bug.")};[I];constructor(e){if(super(),"undefined"==typeof window||"undefined"==typeof document)throw new Error("XenditComponents can only be instantiated in a browser");const n=function(e){if(!e)throw new Error("The componentsSdkKey option is missing; check the constructor parameters.");const n=e.split("-");if(n.length<4||n[2]!==ae&&null===oe(n[2]))throw new Error("The componentsSdkKey option has the wrong format. Ensure you pass the value returned from the `components_sdk_key` property of the `POST /sessions` response.");return{sessionAuthKey:[n[0],n[1]].join("-"),hostId:n[2],publicKey:n[3],signature:n[4]}}(e.componentsSdkKey);this[I]={sdkKey:n,options:e,worldState:null,liveComponents:{channelPicker:null,paymentChannels:new Map,actionContainer:null,digitalWalletContainer:new Map},behaviorTree:new BehaviorTree(fi,{sdk:this,sdkKey:n,mock:this.isMock(),sdkStatus:"LOADING",sdkFatalErrorMessage:null,channel:null,channelProperties:null,channelData:null,channelIsDigitalWallet:!1,instantSubmissionError:null,dispatchEvent:this.dispatchEvent.bind(this),world:null,submissionRequested:!1,simulatePaymentRequested:!1,actionCompleted:!1,pollImmediatelyRequested:!1}),currentChannelCode:null,currentDigitalWalletSubmission:null,eventListenersPresent:new Map},Ee(this),this.addEventListener("fatal-error",e=>{const n=e;this[I].eventListenersPresent.get("fatal-error")||console.error(`XenditComponents: A "fatal-error" event occurred but no event listener was attached: ${n.message}`)}),this[I].eventListenersPresent.set("fatal-error",!1),this.behaviorTreeUpdate(),this.addEventListener(InternalUpdateWorldState.type,this.onUpdateWorldState.bind(this)),this.addEventListener(InternalUpdateChannelComponentData.type,this.onUpdateChannelComponentData.bind(this)),this.addEventListener(InternalBehaviorTreeUpdateEvent.type,this.behaviorTreeUpdate.bind(this));let t=!1;this.addEventListener(InternalNeedsRerenderEvent.type,()=>{t||(t=!0,queueMicrotask(()=>{t=!1,this.rerenderAllComponents(),this.syncInertAttribute()}))}),this.initializeAsync()}async initializeAsync(){let e;try{e=await kt(this[I].sdkKey,this[I].sdkKey.sessionAuthKey),e.channels=e.channels.filter(e=>Ae[e.channel_code])}catch(e){return this[I].behaviorTree.bb.sdkStatus="FATAL_ERROR",this[I].behaviorTree.bb.sdkFatalErrorMessage=fe(e),void this.behaviorTreeUpdate()}this.dispatchEvent(new InternalUpdateWorldState({business:e.business,customer:e.customer,session:e.session,channels:e.channels,channelUiGroups:e.channel_ui_groups,digitalWallets:e.digital_wallets??null,paymentEntity:null,sessionTokenRequestId:null,succeededChannel:null}))}assertInitialized(){if(!this[I].worldState)throw new Error("The session data is not loaded. Listen for the `init` event. Only `createChannelPickerComponent` can be called before initialization.")}isMock(){return!1}isProdLive(){return"pl"===this[I].sdkKey.hostId}findChannel(e){this.assertInitialized();return this[I].worldState.channels.find(n=>n.channel_code===e)??null}onUpdateWorldState(e){const n=e.data;this[I].worldState=se(this[I].worldState??{},n);const t=this[I].worldState.session.locale;this.t=function(e){const n=Nn[e];return function(...t){let i,a,r={};switch(t.length){case 1:i=t[0];break;case 2:"string"==typeof t[1]?(i=t[0],a=t[1]):(i=t[0],r=t[1]);break;case 3:i=t[0],a=t[1],r=t[2];break;default:throw new Error("Invalid arguments for t function")}let o=n?.[i];return void 0===o&&void 0!==a&&(o=a),o?o.replace(/\{\{(\w+)\}\}/g,(e,n)=>r[n]?String(r[n]):""):(console.warn(`Missing localization for key: ${i} in locale: ${e}`),i)}}(t),this.behaviorTreeUpdate(),this.rerenderAllComponents()}onUpdateChannelComponentData(e){const n=e.channelCode,t=e.data,i=this[I].liveComponents.paymentChannels.get(n);i&&(i.data=se(i.data,t),this.behaviorTreeUpdate(),this.rerenderAllComponents())}behaviorTreeUpdate(){const e=this[I].behaviorTree.bb;if("LOADING"===e.sdkStatus&&this[I].worldState&&(e.sdkStatus="ACTIVE"),e.world=this[I].worldState,this[I].currentDigitalWalletSubmission)e.channel=this.findChannel(this[I].currentDigitalWalletSubmission.channelCode),e.channelProperties=this[I].currentDigitalWalletSubmission.channelProperties,e.channelData=null,e.channelIsDigitalWallet=!0,e.instantSubmissionError=this[I].currentDigitalWalletSubmission.instantSubmissionError;else{const n=this[I].currentChannelCode?this[I].liveComponents.paymentChannels.get(this[I].currentChannelCode):null;e.channel=n?we(n.channel[I],n.data.savePaymentMethod):null,e.channelProperties=n?n.channelProperties:null,e.channelData=n?n.data:null,e.channelIsDigitalWallet=!1}try{this[I].behaviorTree.update()}catch(e){this[I].behaviorTree.bb.sdkStatus="FATAL_ERROR",this[I].behaviorTree.bb.sdkFatalErrorMessage=fe(e),this[I].behaviorTree.update()}}getSdkStatus(){return this[I].behaviorTree.bb.sdkStatus}rerenderAllComponents(){this.renderChannelPicker();for(const e of this[I].liveComponents.paymentChannels.keys())this.renderPaymentChannel(e);for(const e of this[I].liveComponents.digitalWalletContainer.keys())this.renderDigitalWalletComponent(e)}getSession(){return this.assertInitialized(),Le(this[I].worldState.session)}getCustomer(){return this.assertInitialized(),this[I].worldState.customer?(Q((e=this[I].worldState.customer).type,"INDIVIDUAL"),z(e.individual_detail),{id:e.id,type:e.type,email:e.email??void 0,mobileNumber:e.mobile_number??void 0,individualDetail:{givenNames:e.individual_detail.given_names??void 0,surname:e.individual_detail.surname??void 0}}):null;var e}getActiveChannelGroups(e){return this.assertInitialized(),function(e,n,t){const i=Ve(n),a=We(e,t);return n.filter(e=>a[e.id]?.length).map(e=>Oe(e,a,i,t))}(this[I].worldState.channels,this[I].worldState.channelUiGroups,{options:{filter:e?.filter,filterMinMax:e?.filterMinMax??!0},session:this[I].worldState.session,pairChannels:Fe(this[I].worldState.channels)})}getActiveChannels(e){return this.assertInitialized(),function(e,n,t){const i=Ve(n),a=We(e,t);return e.filter(e=>Ke(e,t)).map(e=>Be(e,a,i,t))}(this[I].worldState.channels,this[I].worldState.channelUiGroups,{options:{filter:e?.filter,filterMinMax:e?.filterMinMax??!0},session:this[I].worldState.session,pairChannels:Fe(this[I].worldState.channels)})}createChannelPickerComponent(){this[I].liveComponents.channelPicker&&this.destroyComponent(this[I].liveComponents.channelPicker);const e=document.createElement("xendit-channel-picker");return e.setAttribute("translate","no"),this[I].liveComponents.channelPicker=e,this[I].worldState&&this.renderChannelPicker(),this.setupUiEventsForChannelPicker(e),e}renderChannelPicker(){this.assertInitialized();const e=this[I].liveComponents.channelPicker;e&&i(s(H,{data:this[I].worldState,sdk:this,children:s(He,{})}),e)}setupUiEventsForChannelPicker(e){e.addEventListener(XenditClearCurrentChannelEvent.type,e=>{this.assertInitialized();const n=e,t=this[I].currentChannelCode;if(!t)return;const i=this[I].worldState.channels.find(e=>e.channel_code===t);i&&i.ui_group===n.uiGroup&&this.setCurrentChannel(null)})}createChannelComponent(e,n=!0){if(this.assertInitialized(),!Ce(this[I].worldState.session,e[I][0]))throw new Error("Cannot create channel component: `session.amount` is outside of the channel's min/max amount.");const t=e[I][0].channel_code;n&&(this[I].currentChannelCode=t);const i=this[I].liveComponents.paymentChannels.get(t);let a,r=l();return i?(a=i.element,r=i.channelFormRef):(a=document.createElement("xendit-payment-channel"),a.setAttribute("data-channel-code",t),a.setAttribute("inert",""),a.setAttribute("translate","no"),a.style.setProperty("--xendit-channel-brand-color",e[I][0].brand_color),this.setupUiEventsForPaymentChannel(a),this[I].liveComponents.paymentChannels.set(t,{element:a,channel:e,channelProperties:null,channelFormRef:r,data:{savePaymentMethod:!1,cardDetails:null,paymentOptions:null}})),this.renderPaymentChannel(t),n&&(this.behaviorTreeUpdate(),this.syncInertAttribute()),this.dispatchEvent(new InternalNeedsRerenderEvent),a}renderPaymentChannel(e){this.assertInitialized();const n=this[I].liveComponents.paymentChannels.get(e);if(!n)return;const t=n.channel;i(s(H,{data:this[I].worldState,sdk:this,children:s(yt,{channelOrPair:t[I],channelData:n.data,savePaymentMethod:n.data.savePaymentMethod,formRef:n.channelFormRef})}),n.element)}getActiveDigitalWallets(){return this.assertInitialized(),this[I].worldState.digitalWallets?function(e,n,t,i){const a=[],r=Ve(t);if(e.google_pay){const t=e.google_pay.allowed_payment_methods.map(e=>{const t=n.find(n=>n.channel_code===e.channel_code);return z(t),t}),o=We(t,i);a.push({digitalWalletCode:"GOOGLE_PAY",get channels(){return t.map(e=>Be(e,o,r,i))},[I]:!0})}return a}(this[I].worldState.digitalWallets,this[I].worldState.channels,this[I].worldState.channelUiGroups,{options:{filterMinMax:!1},pairChannels:Fe(this[I].worldState.channels),session:this[I].worldState.session}):[]}createDigitalWalletComponent(e,n){this.assertInitialized();const t=this[I].liveComponents.digitalWalletContainer.get(e);t&&this.destroyComponent(t.element);const i=document.createElement("xendit-digital-wallet");return i.setAttribute("translate","no"),i.style.setProperty("display","none"),this[I].liveComponents.digitalWalletContainer.set(e,{element:i,options:n}),this.renderDigitalWalletComponent(e),i}renderDigitalWalletComponent(e){this.assertInitialized();const n=this[I].liveComponents.digitalWalletContainer.get(e);n&&i(s(H,{data:this[I].worldState,sdk:this,children:s(vi,{digitalWalletCode:e,digitalWalletOptions:n.options})}),n.element)}getCurrentChannel(){const e=this[I].currentChannelCode;return e?this.getActiveChannels().find(n=>{if(n.channelCode===e||Array.isArray(n.channelCode)&&n.channelCode.includes(e))return!0})??null:null}setCurrentChannel(e){const n=this[I].currentChannelCode,t=e?.[I][0].channel_code??null;if(n===t)return;this[I].currentChannelCode=t;let i=null;e&&t&&(i=this[I].liveComponents.paymentChannels.get(t)??null,i||(this.createChannelComponent(e,!1),i=this[I].liveComponents.paymentChannels.get(t)??null)),this.behaviorTreeUpdate(),this.syncInertAttribute(),this.renderChannelPicker()}syncInertAttribute(){const e=this[I].behaviorTree.bb.submissionRequested,n=this[I].liveComponents.paymentChannels;for(const[t,i]of n){(Array.isArray(i.channel.channelCode)?i.channel.channelCode[0]:i.channel.channelCode)!==this[I].currentChannelCode||e?i.element.setAttribute("inert",""):i.element.hasAttribute("inert")&&i.element.removeAttribute("inert")}}setupUiEventsForPaymentChannel(e){e.addEventListener(XenditChannelPropertiesChangedEvent.type,e=>{const n=e,t=n.channel,i=this[I].liveComponents.paymentChannels.get(t);i&&(i.channelProperties=n.channelProperties,this.behaviorTreeUpdate())})}showValidationErrors(){if(!this[I].behaviorTree.findBehavior(ChannelInvalidBehavior))return;const e=this[I].currentChannelCode;if(!e)return;const n=this[I].liveComponents.paymentChannels.get(e);if(!n)throw new Error("Current channel is set but component is missing; this is a bug, please contact support.");const t=n.channelFormRef.current;t?.setAllFieldsTouched()}createActionContainerComponent(e){this.assertInitialized(),this[I].liveComponents.actionContainer&&this.destroyComponent(this[I].liveComponents.actionContainer);const n=e===I,t=n?void 0:e,i=this[I].behaviorTree.findBehavior(PeRequiresActionBehavior);if(!n&&i&&!i.canCreateActionContainer)throw new Error("Unable to create action container; there is an action in progress. Create an action before or during the `action-begin` event.");const a=document.createElement("xendit-action-container");return a.setAttribute("translate","no"),t?.qrCode&&void 0!==t.qrCode.qrCodeOnly&&a.setAttribute("data-qr-code-only",t.qrCode.qrCodeOnly.toString()),this[I].liveComponents.actionContainer=a,a}destroyComponent(e){if(!e.tagName.startsWith("XENDIT-"))throw new Error("Unable to destroy component; only elements created by this SDK can be destroyed.");if(this[I].liveComponents.channelPicker===e)return this[I].liveComponents.channelPicker=null,i(null,e),void e.remove();for(const[n,t]of this[I].liveComponents.paymentChannels)if(t.element===e)return this[I].liveComponents.paymentChannels.delete(n),this[I].currentChannelCode===n&&this.setCurrentChannel(null),i(null,e),void e.remove();if(this[I].liveComponents.actionContainer===e)return this[I].liveComponents.actionContainer=null,i(null,e),void e.remove();for(const[n,t]of this[I].liveComponents.digitalWalletContainer)if(t.element===e)return this[I].liveComponents.digitalWalletContainer.delete(n),i(null,e),void e.remove();throw new Error("Unable to destroy component; component not found. It may have already been destroyed.")}submit(){this.assertInitialized();if(!this[I].behaviorTree.findBehavior(SessionActiveBehavior))throw new Error("Unable to submit; the session is not in the active state. Listen to the `session-complete` and `session-expired-or-canceled` events and display success or failure states accordingly.");const e=this[I].currentChannelCode;if(!e)throw new Error("Unable to submit; there is no current payment channel. Create a payment component with `createChannelComponent` or make an existing one active with `setCurrentChannel`.");if(!this[I].liveComponents.paymentChannels.get(e))throw new Error("Current channel is set but component is missing; this is a bug, please contact support.");this.showValidationErrors();if(this[I].behaviorTree.findBehavior(ChannelInvalidBehavior))throw new Error("Unable to submit; the form for the current channel has errors. Listen to the `submission-ready` and `submission-not-ready` events, do not allow submission while in the not-ready state.");if(!this[I].behaviorTree.findBehavior(ChannelValidBehavior))throw new Error("Unable to submit; the SDK is not in a valid state for submission. Listen to the `submission-ready` and `submission-not-ready` events, do not allow submission while in the not-ready state.");this[I].behaviorTree.bb.submissionRequested=!0,this.behaviorTreeUpdate(),this.syncInertAttribute()}submitDigitalWallet(e,n,t,i=null){this.assertInitialized(),this.setCurrentChannel(null),this[I].currentDigitalWalletSubmission={digitalWalletCode:e,channelCode:n[I][0].channel_code,channelProperties:t,instantSubmissionError:i},this.addEventListener(XenditSubmissionEndEvent.type,()=>{this[I].currentDigitalWalletSubmission=null},{once:!0}),this[I].behaviorTree.bb.submissionRequested=!0,this.behaviorTreeUpdate(),this.syncInertAttribute()}abortSubmission(){this.assertInitialized();this[I].behaviorTree.findBehavior(SubmissionBehavior)&&(this[I].behaviorTree.bb.submissionRequested=!1,this.behaviorTreeUpdate())}simulatePayment(){if(this.assertInitialized(),"PAY"!==this[I].worldState.session.session_type)throw new Error('Unable to simulate payment, the session type is not "PAY".');if(!this[I].behaviorTree.findBehavior(PeRequiresActionBehavior))throw new Error("Unable to simulate payment; there is no action in progress. You can simulate payments any time between the `action-begin` and `action-end` events.");const e=this[I].worldState.paymentEntity;if(!e)throw new Error("The PeRequiresActionBehavior is present but there is no payment entity. This is a bug, please contact support.");if(!this.findChannel(e.entity.channel_code))throw new Error("Channel not found; this is a bug, please contact support.");const n=te(e.entity.actions);if(!n||!_e(n))throw new Error("Unable to simulate payment; the action does not support simulation.");this[I].behaviorTree.bb.simulatePaymentRequested=!0,this.behaviorTreeUpdate()}pollImmediately(){if(this.assertInitialized(),"ACTIVE"!==this[I].worldState.session.status)throw new Error("Unable to poll immediately; the session is not longer active.");this[I].behaviorTree.bb.pollImmediatelyRequested=!0,this.behaviorTreeUpdate()}getState(){const e=this[I].currentChannelCode,n=this[I].liveComponents.paymentChannels.get(e??"");return{channelCode:e,channelProperties:n?.channelProperties||null,behaviorTree:this[I].behaviorTree}}addEventListener(e,n,t){return this[I].eventListenersPresent.set(e,!0),super.addEventListener(e,n,t)}removeEventListener(e,n,t){return super.removeEventListener(e,n,t)}static amountFormat(e,n){return En(e,n)}}class XenditComponentsTest extends XenditComponents{nextMockUpdate=null;constructor(e){super({...e,componentsSdkKey:`session-${he(32)}-mock-MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEyCADI5pdf6KmN8+Fxl2ES3yolUKXunNeY3gGScGNEvDcrcHAPKxIInAo5DVnDvTtYtqZvx/bu7HLeBJNMXwHhie/uyNEtT8dSaLc9bd0WSlYdxI+iUsTv2Qu0LiiPrZs-NKf7whM9meUs/eRCvG0oc180MDiyeli3kH6EQ3ZahECHsZQi5G2IpH6vk3cYMtf01Y1L4OBn1SZCOv1kwpjIUet4DJeoTwwq2nM5b+K7rD+/WFTi3AEX4NWJNkKi0a91`}),this.addEventListener(InternalScheduleMockUpdateEvent.type,this.setNextMockUpdate.bind(this))}async initializeAsync(){await J(Y);const e=(await import("./test-data.mjs")).makeTestBffData();this.dispatchEvent(new InternalUpdateWorldState({business:e.business,customer:e.customer,session:e.session,channels:e.channels,channelUiGroups:e.channel_ui_groups,digitalWallets:e.digital_wallets??null,paymentEntity:null,sessionTokenRequestId:null,succeededChannel:null}))}isMock(){return!0}setNextMockUpdate(e){const n=e;this.nextMockUpdate=n.mockData}}"undefined"==typeof window||"undefined"==typeof document||(R||(R=!0,a.debounceRendering=e=>queueMicrotask(e)),function(){const e=document.createElement("style");e.textContent='/* variables */\n:root {\n --xendit-font-family: sans-serif;\n --xendit-color-primary: #1762ee;\n --xendit-color-text: #252525;\n --xendit-color-text-secondary: #585858;\n --xendit-color-text-placeholder: #7d7d7d;\n --xendit-color-disabled: #f7f7f7;\n --xendit-color-danger: #d1414d;\n --xendit-color-border: #f3f3f3;\n --xendit-color-background: #ffffff;\n --xendit-focus-shadow: 0px 0px 0px 2px\n color-mix(in srgb, var(--xendit-color-primary) 15%, transparent);\n --xendit-animation-duration: 0.3s;\n --xendit-animation-ease: ease-in-out;\n --xendit-radius-1: 8px;\n --xendit-z-index-focus: 2;\n\n /* Browser-specific border collapse margins */\n --xendit-border-collapse-offset: -0.5px; /* Default for Chrome/Edge */\n --xendit-border-collapse-webkit-gecko: -1.5px; /* Fix Safari and Firefox subpixel rendering */\n\n /* QR code colors */\n --xendit-qr-foreground-color: #000000;\n --xendit-qr-background-color: #ffffff;\n\n /* icon colors */\n --xendit-color-icon-primary: #7c7c7c;\n --xendit-color-icon-secondary: #f1f1f1;\n}\n\n/* Set default font for root components */\nxendit-channel-picker,\nxendit-action-container,\nxendit-payment-channel {\n display: block;\n unicode-bidi: isolate;\n font-family: var(--xendit-font-family);\n color: var(--xendit-color-text);\n}\n\n.xendit-default-action-container {\n font-family: var(--xendit-font-family);\n}\n\nxendit-action-container {\n background-color: var(--xendit-color-background);\n flex: 1; /* Action container usually wants to stretch to fit, assuming the parent is a flexbox. */\n}\n\nxendit-payment-channel button,\nxendit-payment-channel textarea,\nxendit-payment-channel select,\nxendit-payment-channel input,\nxendit-payment-channel input::placeholder {\n font-family: inherit;\n}\n\nxendit-payment-channel input::placeholder,\nxendit-payment-channel textarea::placeholder,\nxendit-payment-channel select::placeholder {\n color: var(--xendit-color-text-placeholder);\n}\n\n/* Reusable typography classes */\n.xendit-text-12 {\n font-size: 12px;\n line-height: 16px;\n letter-spacing: -0.01px;\n}\n\n.xendit-text-14 {\n font-size: 14px;\n line-height: 16px;\n letter-spacing: -0.09px;\n}\n\n.xendit-text-16 {\n font-size: 16px;\n line-height: 16px;\n letter-spacing: -0.09px;\n}\n\n.xendit-text-18 {\n font-size: 18px;\n line-height: 24px;\n letter-spacing: -0.26px;\n}\n\n.xendit-text-20 {\n font-size: 20px;\n line-height: 28px;\n letter-spacing: -0.33px;\n}\n\n.xendit-text-12,\n.xendit-text-14,\n.xendit-text-16 {\n font-weight: 400;\n}\n\n.xendit-text-semibold {\n font-weight: 600;\n}\n\n.xendit-text-bold {\n font-weight: 700;\n}\n\n.xendit-text-link {\n color: var(--xendit-color-primary);\n}\n.xendit-text-secondary {\n color: var(--xendit-color-text-secondary);\n}\n\n.xendit-text-center {\n text-align: center;\n}\n\n/* Accordion component */\n\n.xendit-accordion {\n display: flex;\n flex-direction: column;\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n background: var(--xendit-color-background);\n}\n\n.xendit-accordion-item:not(:first-child) {\n border-top: 1px solid var(--xendit-color-border);\n border-top-left-radius: var(--xendit-radius-1);\n border-top-right-radius: var(--xendit-radius-1);\n}\n\n.xendit-accordion-item-header {\n display: grid;\n grid-template-columns: auto 1fr auto;\n grid-gap: 16px;\n align-items: center;\n cursor: pointer;\n padding: 24px 16px;\n color: var(--xendit-color-text);\n border-radius: 8px;\n}\n\n.xendit-accordion-item-disabled .xendit-accordion-item-header {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.xendit-accordion-item-header-title {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.xendit-accordion-item-disabled .xendit-accordion-item-header-title,\n.xendit-accordion-item-disabled .xendit-accordion-item-header-icon {\n opacity: 0.5;\n}\n\n.xendit-accordion-item.xendit-accordion-item-open\n .xendit-accordion-item-header {\n color: var(--xendit-color-primary);\n}\n\n.xendit-accordion-item-chevron {\n color: var(--xendit-color-text);\n}\n\n.xendit-accordion-item-disabled .xendit-accordion-item-chevron {\n display: none;\n}\n\n.xendit-accordion-item-chevron g {\n transition: transform var(--xendit-animation-duration)\n var(--xendit-animation-ease);\n}\n\n.xendit-accordion-item-header:focus-visible {\n border-radius: 8px;\n box-shadow: 0px 0px 0px 2px\n color-mix(in srgb, var(--xendit-color-primary) 15%, transparent);\n outline: none;\n}\n\n.xendit-accordion-item-content {\n overflow: hidden;\n transition: height var(--xendit-animation-duration)\n var(--xendit-animation-ease);\n}\n\n.xendit-accordion-item.xendit-accordion-item-closed\n .xendit-accordion-item-content {\n height: 0;\n}\n\n.xendit-accordion-item.xendit-accordion-item-open\n .xendit-accordion-item-content {\n height: calc-size(auto, size);\n}\n\n.xendit-accordion-item-padding {\n padding: 16px;\n}\n\n/* Channel picker digital wallet section */\n\n.xendit-channel-picker-digital-wallet-section {\n display: grid;\n grid-auto-flow: column;\n grid-auto-columns: 1fr;\n gap: 8px;\n margin-bottom: 8px;\n}\n\n/* Channel picker group */\n\n.xendit-channel-picker-group {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n.xendit-channel-picker-group select {\n border: 1px solid var(--xendit-color-border);\n border-radius: 8px;\n padding: 12px;\n appearance: none;\n outline: none;\n}\n\n.xendit-channel-picker-group select:focus {\n box-shadow: 0px 0px 0px 2px\n color-mix(in srgb, var(--xendit-color-primary) 15%, transparent);\n}\n\n.xendit-channel-logo {\n width: 24px;\n height: 16px;\n margin: -5px 0;\n padding: 4px;\n border: 1px solid var(--xendit-color-border);\n border-radius: 4px;\n background-color: white; /* always white, not --xendit-color-background */\n object-fit: contain;\n}\n\n/* Payment channel */\n\nxendit-payment-channel[inert] {\n filter: opacity(0.5) grayscale(1);\n}\n\n.xendit-payment-channel {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n.xendit-payment-channel-banner {\n width: 100%;\n height: auto;\n object-fit: contain;\n}\n\n.xendit-payment-channel-instructions {\n display: grid;\n grid-template-columns: auto 1fr;\n grid-gap: 12px;\n color: var(--xendit-color-text-secondary);\n}\n\n.xendit-payment-channel-instructions-logo {\n height: 40px;\n width: auto;\n object-fit: contain;\n}\n\n.xendit-payment-channel-instructions-text {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 4px;\n}\n\n.xendit-payment-channel-instructions-text p {\n margin: 0;\n}\n\n/* Forms */\n\n.xendit-channel-form {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n.xendit-channel-form > form {\n display: contents;\n}\n\n.xendit-form-field-group {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n\n.xendit-channel-form-field {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.xendit-channel-form-field-group {\n display: grid;\n gap: 8px;\n}\n\n.xendit-channel-form-field-group-label-container {\n display: flex;\n justify-content: space-between;\n gap: 16px;\n}\n\n.xendit-channel-form-field-group label {\n width: fit-content;\n cursor: pointer;\n}\n\n.xendit-form-field-group.invalid .xendit-channel-form-field input,\n.xendit-form-field-group.invalid\n .xendit-channel-form-field\n .xendit-iframe-container,\n.xendit-form-field-group.invalid .xendit-dropdown button {\n border: 1px solid var(--xendit-color-danger);\n}\n\n.xendit-channel-form-field input:not([type="checkbox"]),\n.xendit-channel-form-field select,\n.xendit-channel-form-field .xendit-iframe-container {\n display: flex;\n border: 1px solid var(--xendit-color-border);\n background: var(--xendit-color-background);\n border-radius: 8px;\n padding: 12px;\n appearance: none;\n}\n\n/* TODO: Refine these class usages */\n.xendit-channel-form-field.field-radius-tl-0 input,\n.xendit-channel-form-field.field-radius-tl-0 button,\n.xendit-channel-form-field.field-radius-tl-0 .xendit-iframe-container {\n border-top-left-radius: 0;\n}\n\n.xendit-channel-form-field.field-radius-tr-0 input,\n.xendit-channel-form-field.field-radius-tr-0 button,\n.xendit-channel-form-field.field-radius-tr-0 .xendit-iframe-container {\n border-top-right-radius: 0;\n}\n\n.xendit-channel-form-field.field-radius-bl-0 input,\n.xendit-channel-form-field.field-radius-bl-0 button,\n.xendit-channel-form-field.field-radius-bl-0 .xendit-iframe-container {\n border-bottom-left-radius: 0;\n}\n\n.xendit-channel-form-field.field-radius-br-0 input,\n.xendit-channel-form-field.field-radius-br-0 button,\n.xendit-channel-form-field.field-radius-br-0 .xendit-iframe-container {\n border-bottom-right-radius: 0;\n}\n\n.xendit-channel-form-field.field-collapse-l,\n.xendit-channel-form-field.field-collapse-l {\n margin-left: var(--xendit-border-collapse-offset);\n}\n\n.xendit-channel-form-field.field-collapse-r,\n.xendit-channel-form-field.field-collapse-r {\n margin-right: var(--xendit-border-collapse-offset);\n}\n\n.xendit-channel-form-field.field-collapse-l .xendit-iframe-container {\n margin-left: calc(var(--xendit-border-collapse-offset) * 2);\n width: calc(100% + abs(var(--xendit-border-collapse-offset) * 2));\n}\n\n.xendit-channel-form-field.field-collapse-r .xendit-iframe-container {\n margin-right: 0;\n}\n\n.xendit-channel-form-field.field-collapse-t input,\n.xendit-channel-form-field.field-collapse-t button,\n.xendit-channel-form-field.field-collapse-t .xendit-iframe-container {\n margin-top: var(--xendit-border-collapse-offset);\n}\n\n.xendit-channel-form-field.field-collapse-b input,\n.xendit-channel-form-field.field-collapse-b button,\n.xendit-channel-form-field.field-collapse-b .xendit-iframe-container {\n margin-bottom: var(--xendit-border-collapse-offset);\n}\n\n/* Safari and Firefox specific adjustments */\n@supports (font: -apple-system-body) or (-moz-appearance: none) {\n .xendit-channel-form-field.field-collapse-l .xendit-iframe-container {\n margin-left: 0;\n width: 100%;\n }\n\n .xendit-channel-form-field.field-collapse-b input,\n .xendit-channel-form-field.field-collapse-b button {\n margin-bottom: var(--xendit-border-collapse-webkit-gecko);\n height: calc(100% + abs(var(--xendit-border-collapse-webkit-gecko) * 2));\n }\n}\n\n.xendit-channel-form-field.field-collapse-r .xendit-iframe-container:focus {\n border-right: none;\n}\n\n.xendit-channel-form-field.field-collapse-l .xendit-iframe-container:focus {\n border-left: none;\n}\n/* Ends TODO */\n\n.xendit-card-brand-logo {\n width: 24px;\n height: 16px;\n border: 1px solid var(--xendit-color-border);\n border-radius: 4px;\n padding: 4px;\n background-color: white; /* always white, not --xendit-color-background */\n}\n\n.xendit-card-brands-list {\n display: flex;\n align-items: center;\n padding: 8px 12px;\n gap: 4px;\n}\n\n.xendit-channel-form-field input:focus,\n.xendit-channel-form-field select:focus,\n.xendit-channel-form-field .xendit-iframe-container.xendit-field-focus {\n border-color: var(--xendit-color-primary);\n box-shadow: var(--xendit-focus-shadow);\n outline: none;\n z-index: var(--xendit-z-index-focus);\n}\n\n.xendit-channel-form-field button:focus {\n position: relative;\n z-index: var(--xendit-z-index-focus);\n}\n\n.xendit-channel-form-field .xendit-iframe-container {\n height: 40px;\n width: 100%;\n padding: 0;\n overflow: hidden;\n box-sizing: border-box;\n}\n\n.xendit-channel-form-field .xendit-iframe-container iframe {\n height: 40px;\n width: 100%;\n border: none;\n min-width: 0;\n}\n\n.xendit-channel-form-field.xendit-form-field-span-1 {\n grid-column: span 1;\n}\n\n.xendit-channel-form-field.xendit-form-field-span-2 {\n grid-column: span 2;\n}\n\n.xendit-checkbox {\n display: flex;\n align-items: center;\n}\n\n.xendit-checkbox-box {\n display: flex;\n}\n\n.xendit-checkbox input {\n width: 16px;\n height: 16px;\n margin: 0;\n cursor: pointer;\n}\n\n.xendit-checkbox label {\n cursor: pointer;\n padding-left: 8px;\n}\n\n.xendit-checkbox input {\n opacity: 0;\n position: absolute;\n}\n\n.xendit-checkbox input + .xendit-checkbox-graphic {\n width: 16px;\n height: 16px;\n border: 1px solid var(--xendit-color-border);\n border-radius: 4px;\n box-sizing: border-box;\n color: transparent;\n}\n\n.xendit-checkbox input:checked + .xendit-checkbox-graphic {\n color: var(--xendit-color-background);\n background-color: var(--xendit-color-primary);\n border-color: var(--xendit-color-primary);\n}\n\n/* Dialog */\n\n.xendit-dialog-backdrop {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n padding: 48px;\n justify-content: center;\n align-items: center;\n}\n\n.xendit-dialog {\n background-color: var(--xendit-color-background);\n border-radius: 8px;\n position: relative;\n}\n\n.xendit-dialog-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n color: var(--xendit-color-text);\n padding: 16px;\n gap: 16px;\n line-height: 20px;\n border-bottom: 1px solid var(--xendit-color-border);\n}\n\n.xendit-dialog-header button {\n display: flex;\n background: none;\n border: none;\n color: var(--xendit-color-text);\n cursor: pointer;\n padding: 0;\n}\n\n.xendit-dialog-floating-close {\n position: absolute;\n top: 24px;\n right: 24px;\n background: none;\n border: none;\n color: var(--xendit-color-text);\n cursor: pointer;\n padding: 0;\n}\n\n.xendit-dialog-body {\n display: flex;\n padding: 24px;\n}\n\n.xendit-error-message {\n color: var(--xendit-color-danger);\n}\n\n/* Phone input Dropdown */\n.xendit-input-phone {\n display: flex;\n gap: 8px;\n}\n\n.xendit-phone-number-input {\n width: 100%;\n}\n\n.xendit-dropdown .xendit-dropdown-search input {\n padding: 8px;\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n box-sizing: border-box;\n}\n\n.xendit-dropdown-search input:focus {\n outline: none;\n border-color: var(--xendit-color-primary);\n box-shadow: var(--xendit-focus-shadow);\n}\n\n/* Phone input Dropdown ends */\n\n/* Dropdown */\n.xendit-dropdown button {\n width: 100%;\n display: grid;\n grid-template-columns: 1fr auto;\n align-items: center;\n gap: 8px;\n text-align: left;\n background-color: var(--xendit-color-background);\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n justify-content: space-between;\n padding: 12px;\n cursor: pointer;\n}\n\n.xendit-dropdown button.xendit-dropdown-has-asset {\n grid-template-columns: auto 1fr auto;\n}\n\n.xendit-dropdown button:disabled {\n background: var(--xendit-color-disabled);\n}\n\n.xendit-dropdown button:focus {\n outline: none;\n border: 1px solid var(--xendit-color-primary);\n box-shadow: 0px 0px 0px 2px #1762ee26;\n}\n\n.xendit-dropdown-menu {\n position: absolute;\n z-index: 1;\n display: flex;\n flex-direction: column;\n gap: 4px;\n max-height: 168px;\n width: 257px;\n padding: 4px;\n margin: 4px 0;\n background-color: var(--xendit-color-background);\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n list-style: none;\n box-shadow: 0px 4px 8px 0px #25252514;\n overflow-y: auto;\n}\n\n.xendit-dropdown-menu ul {\n list-style: none;\n padding: 4px;\n margin-top: 0;\n}\n\n.xendit-dropdown-search {\n position: sticky;\n top: 0;\n z-index: 1;\n}\n\n.xendit-dropdown-search input {\n width: 100%;\n}\n\n.xendit-dropdown-item {\n display: grid;\n grid-template-columns: 1fr auto;\n align-items: center;\n gap: 8px;\n padding: 8px 12px 8px 4px;\n border-radius: var(--xendit-radius-1);\n cursor: pointer;\n z-index: 0;\n --xendit-dropdown-item-hover-color: var(--xendit-color-background);\n --xendit-dropdown-item-hover-bg-color: var(--xendit-color-primary);\n}\n\n.xendit-dropdown-item-disabled {\n --xendit-dropdown-item-hover-color: var(--xendit-color-text);\n --xendit-dropdown-item-hover-bg-color: var(--xendit-color-disabled);\n}\n\n.xendit-dropdown-item-active {\n box-shadow: var(--xendit-focus-shadow);\n}\n\n.xendit-dropdown-item:hover {\n background-color: var(--xendit-dropdown-item-hover-bg-color);\n}\n\n.xendit-dropdown-item:hover .xendit-dropdown-item-text,\n.xendit-dropdown-item:hover .xendit-dropdown-item-description {\n color: var(--xendit-dropdown-item-hover-color);\n}\n\n.xendit-dropdown-item-selected {\n color: var(--xendit-color-primary);\n}\n\n.xendit-dropdown-item:hover .xendit-dropdown-item-selected {\n color: var(--xendit-dropdown-item-hover-color);\n}\n\n.xendit-dropdown-item.xendit-dropdown-has-asset {\n grid-template-columns: auto 1fr auto;\n}\n\n.xendit-dropdown-item-text {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.xendit-dropdown-item-disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n\n.xendit-dropdown-item-disabled:hover,\n.xendit-dropdown-item-disabled.xendit-dropdown-item-active {\n background-color: var(--xendit-color-disabled);\n}\n\n/* Dropdown ends */\n\n/* Button */\n.xendit-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 12px 16px;\n font-family: var(--xendit-font-family);\n font-size: 14px;\n font-weight: 600;\n line-height: 16px;\n letter-spacing: -0.09px;\n cursor: pointer;\n transition: background-color var(--xendit-animation-duration)\n var(--xendit-animation-ease);\n}\n.xendit-button-primary-rounded {\n border: 1px solid transparent;\n background-color: var(--xendit-color-primary);\n color: var(--xendit-color-background);\n border-radius: var(--xendit-radius-1);\n}\n.xendit-button-white-rounded {\n background-color: var(--xendit-color-background);\n color: var(--xendit-color-text);\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n}\n.xendit-button-white-rounded:hover {\n background-color: var(--xendit-color-border);\n}\n.xendit-button-block {\n width: 100%;\n}\n.xendit-button-sm {\n padding: 8px 12px;\n font-size: 12px;\n line-height: 16px;\n}\n\n@keyframes xendit-button-loading-spinner-spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.xendit-button-loading-spinner {\n width: 16px;\n height: 16px;\n animation: xendit-button-loading-spinner-spin 1s linear infinite;\n}\n\n.xendit-skeleton-field button {\n height: 42px;\n background-color: var(--xendit-color-disabled);\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--xendit-color-text-secondary);\n}\n\n/* Button ends */\n\n.xendit-dotted-line {\n height: 1px;\n border: none;\n background: repeating-linear-gradient(\n to right,\n var(--xendit-color-border) 0px 4px,\n transparent 4px 8px\n );\n margin: 16px 0;\n}\n\n/* Form Simulation Helper */\n.xendit-form-simulation-root {\n position: relative;\n}\n.xendit-form-simulation-trigger {\n background: transparent;\n border: none;\n cursor: pointer;\n padding: 0;\n}\n.xendit-form-simulation-popover {\n position: absolute;\n top: 100%;\n right: 0;\n\n width: 350px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n border-radius: 4px;\n padding: 12px;\n border: 1px solid var(--xendit-color-border);\n background: color-mix(\n in srgb,\n var(--xendit-color-background),\n transparent 40%\n );\n backdrop-filter: blur(6px);\n box-shadow: 0px 0px 0px 2px\n color-mix(in srgb, var(--xendit-color-primary) 15%, transparent);\n}\n.xendit-form-simulation-popover .xendit-dropdown {\n position: relative;\n}\n.xendit-form-simulation-popover .xendit-dropdown-menu {\n width: auto;\n}\n.xendit-form-simulation-scenario-icon {\n height: 28px;\n width: 40px;\n border-radius: 4px;\n border: 1px solid var(--xendit-color-border);\n object-fit: contain;\n background-color: white;\n}\n\n/* Form Simulation Helper ends */\n\n.xendit-tooltip {\n position: absolute;\n top: 100%;\n right: 50%;\n transform: translateX(50%);\n background-color: black;\n color: white;\n padding: 8px 12px;\n border-radius: var(--xendit-radius-1);\n white-space: nowrap;\n z-index: 1000;\n font-weight: 600;\n font-size: 14px;\n line-height: 16px;\n animation: xendit-tooltip-fade-in var(--xendit-animation-duration)\n var(--xendit-animation-ease);\n opacity: 1;\n}\n\n@keyframes xendit-tooltip-fade-in {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n/* Instructions */\n\n.xendit-instructions-bold {\n font-weight: 600;\n}\n.xendit-instructions-bullet-list {\n display: flex;\n flex-direction: column;\n gap: 12px;\n margin: 8px 0;\n}\n.xendit-instructions-bullet-list::marker {\n color: var(--xendit-color-text-secondary);\n}\n.xendit-instructions-form-card {\n display: flex;\n flex-direction: column;\n padding: 16px;\n border-radius: 12px;\n border: 1px solid var(--xendit-color-border);\n gap: 4px;\n width: 321px;\n}\n.xendit-instructions-form-field {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 8px 0;\n border-bottom: 1px solid var(--xendit-color-border);\n}\n.xendit-instructions-form-field-label {\n font-size: 12px;\n font-weight: 600;\n line-height: 16px;\n color: var(--xendit-color-text-secondary);\n}\n.xendit-instructions-form-field-value {\n font-size: 14px;\n line-height: 20px;\n color: var(--xendit-color-text);\n}\n.xendit-instructions-form-heading {\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n margin: 4px 0;\n}\n.xendit-instructions-italics {\n font-style: italic;\n}\n.xendit-instructions-numbered-list {\n display: flex;\n flex-direction: column;\n gap: 16px;\n list-style-type: decimal;\n padding-left: 40px;\n}\n.xendit-instructions-single-tab-heading {\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n margin-bottom: 16px;\n}\n.xendit-instructions-step-box {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.xendit-instructions-step-li {\n font-size: 14px;\n line-height: 20px;\n}\n.xendit-instructions-step-li p {\n margin: 0;\n}\n.xendit-instructions-step-li::marker {\n margin-left: 20px;\n}\n.xendit-instructions-tab-button {\n font-family: var(--xendit-font-family);\n font-size: 14px;\n padding: 8px 4px;\n background-color: transparent;\n border: none;\n border-top: 3px solid transparent;\n border-bottom: 3px solid transparent;\n}\n.xendit-instructions-active-tab {\n border-bottom-color: var(--xendit-color-primary);\n color: var(--xendit-color-primary);\n font-weight: 600;\n}\n.xendit-instructions-tab-list {\n display: flex;\n gap: 16px;\n margin-bottom: 16px;\n border-bottom: 1px solid var(--xendit-color-border);\n}\n.xendit-instructions-table {\n font-size: 14px;\n line-height: 16px;\n width: 100%;\n border-collapse: collapse;\n}\n.xendit-instructions-table-cell {\n padding: 4px;\n border: 1px solid black;\n}\n.xendit-instructions-table-header {\n font-size: 14px;\n font-weight: 600;\n line-height: 16px;\n padding: 4px;\n border: 1px solid black;\n}\n\n/* Instructions ends */\n\n.xendit-default-action-container {\n display: flex;\n flex-direction: column;\n border: none;\n}\n\n.xendit-action-title {\n font-weight: 600;\n font-size: 20px;\n line-height: 28px;\n text-align: center;\n}\n\n.xendit-action-iframe {\n border: none;\n width: 100%;\n height: 100%;\n}\n\n.xendit-action-present-to-customer {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n.xendit-action-present-to-customer-affirm {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.xendit-action-qr-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 16px;\n max-width: 384px;\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n padding: 16px;\n padding-bottom: 24px;\n}\n.xendit-action-qr-channel-logo {\n height: 64px;\n object-fit: contain;\n}\n.xendit-action-qr-qrcode-container {\n width: 100%;\n}\n\n/* va actions */\n.xendit-action-va-content {\n display: flex;\n flex-direction: column;\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n padding: 16px;\n padding-bottom: 24px;\n}\n.xendit-action-va-details {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n.xendit-action-va-detail-item {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n.xendit-action-va-detail-content {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.xendit-action-va-heading {\n color: var(--xendit-color-text-placeholder);\n}\n.xendit-action-va-tag {\n color: var(--xendit-color-text-placeholder);\n background-color: #fafafa;\n padding: 2px 4px;\n border-radius: 4px;\n}\n\n/* redirect, deeplink, and push notification actions */\n.xendit-redirect-instructions {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n gap: 24px;\n}\n\n.xendit-redirect-instructions-logo {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 112px;\n height: 112px;\n border: 2px solid var(--xendit-color-border);\n border-radius: 50%;\n overflow: hidden;\n}\n\n.xendit-redirect-instructions-logo img {\n width: 96px;\n height: 96px;\n object-fit: contain;\n}\n\n.xendit-redirect-instructions-text {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.xendit-redirect-instructions-button {\n display: inline-block;\n border-radius: 99px;\n color: white;\n padding: 12px 16px;\n background-color: var(--xendit-channel-brand-color, #000);\n text-decoration: none;\n white-space: nowrap;\n}\n\n.xendit-redirect-instructions-button:hover,\n.xendit-redirect-instructions-button:active {\n filter: brightness(1.1);\n}\n\n/* googlepay */\n\n.gpay-card-info-container-fill {\n display: flex;\n}\n';const n=document.querySelector("style, link");n?n.insertAdjacentElement("beforebegin",e):document.head.appendChild(e)}(),function(){const n=document.createElement("svg");n.id="xendit-icon-set",n.style.display="none",i(e("defs",{children:N.map(e=>e.node)}),n),document.head.appendChild(n)}());export{XenditActionBeginEvent,XenditActionEndEvent,XenditComponents,XenditComponentsTest,XenditFatalErrorEvent,XenditInitEvent,XenditNotReadyEvent,XenditPaymentRequestCreatedEvent,XenditPaymentRequestDiscardedEvent,XenditPaymentTokenCreatedEvent,XenditPaymentTokenDiscardedEvent,XenditReadyEvent,XenditSessionCompleteEvent,XenditSessionExpiredOrCanceledEvent,XenditSessionNotPendingEvent,XenditSessionPendingEvent,XenditSubmissionBeginEvent,XenditSubmissionEndEvent,XenditWillRedirectEvent,pe as a,he as r};
2
+ import"preact/debug";import"preact/devtools";import{options as e,createContext as n,render as t,createElement as i,Fragment as a,createRef as r}from"preact";import{jsx as o,jsxs as s,Fragment as l}from"preact/jsx-runtime";import{useCallback as d,useContext as c,useRef as u,useLayoutEffect as h,useState as p,useMemo as m,useImperativeHandle as f,useEffect as b}from"preact/hooks";import y from"classnames";import _,{getCountries as g,getExampleNumber as x}from"libphonenumber-js";import v,{getCountryCallingCode as k}from"libphonenumber-js/min";import w from"libphonenumber-js/mobile/examples";import{forwardRef as C}from"preact/compat";import E from"qrcode";import A from"qrcode/lib/renderer/svg-tag.js";let N=!1;class XenditInitEvent extends Event{static type="init";constructor(){super(XenditInitEvent.type,{})}}class XenditFatalErrorEvent extends Event{message;static type="fatal-error";constructor(e){super(XenditFatalErrorEvent.type,{}),this.message=e}}class XenditReadyEvent extends Event{channelCode;static type="submission-ready";constructor(e){super(XenditReadyEvent.type,{}),this.channelCode=e}}class XenditNotReadyEvent extends Event{static type="submission-not-ready";constructor(){super(XenditNotReadyEvent.type,{})}}class XenditSubmissionBeginEvent extends Event{static type="submission-begin";constructor(){super(XenditSubmissionBeginEvent.type,{})}}class XenditSubmissionEndEvent extends Event{reason;userErrorMessage;developerErrorMessage;static type="submission-end";constructor(e,n,t){super(XenditSubmissionEndEvent.type,{}),this.reason=e,this.userErrorMessage=n,this.developerErrorMessage=t}}class XenditActionBeginEvent extends Event{static type="action-begin";constructor(){super(XenditActionBeginEvent.type,{})}}class XenditActionEndEvent extends Event{static type="action-end";constructor(){super(XenditActionEndEvent.type,{})}}class XenditWillRedirectEvent extends Event{static type="will-redirect";constructor(){super(XenditWillRedirectEvent.type,{})}}class XenditSessionCompleteEvent extends Event{static type="session-complete";constructor(){super(XenditSessionCompleteEvent.type,{})}}class XenditSessionExpiredOrCanceledEvent extends Event{static type="session-expired-or-canceled";constructor(){super(XenditSessionExpiredOrCanceledEvent.type,{})}}class XenditSessionPendingEvent extends Event{static type="session-pending";constructor(){super(XenditSessionPendingEvent.type,{})}}class XenditSessionNotPendingEvent extends Event{static type="session-not-pending";constructor(){super(XenditSessionNotPendingEvent.type,{})}}class XenditPaymentRequestCreatedEvent extends Event{paymentRequestId;static type="payment-request-created";constructor(e){super(XenditPaymentRequestCreatedEvent.type,{}),this.paymentRequestId=e}}class XenditPaymentTokenCreatedEvent extends Event{paymentTokenId;static type="payment-token-created";constructor(e){super(XenditPaymentTokenCreatedEvent.type,{}),this.paymentTokenId=e}}class XenditPaymentRequestDiscardedEvent extends Event{paymentRequestId;static type="payment-request-discarded";constructor(e){super(XenditPaymentRequestDiscardedEvent.type,{}),this.paymentRequestId=e}}class XenditPaymentTokenDiscardedEvent extends Event{paymentTokenId;static type="payment-token-discarded";constructor(e){super(XenditPaymentTokenDiscardedEvent.type,{}),this.paymentTokenId=e}}const P=Symbol("xendit-internal"),S=e=>o("div",{class:"xendit-accordion",children:e.children}),I=e=>{const{name:n,size:t,direction:i}=e;let a;switch(i){case"right":a="rotate(180 12 12)";break;case"up":a="rotate(90 12 12)";break;case"down":a="rotate(-90 12 12)";break;default:a="rotate(0 12 12)"}let r=null;switch(n){case"chevron":r=o("path",{d:"M15 19.5L7.5 12L15 4.5",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"});break;case"check":r=R(o("path",{d:"M13.5 4.5L6.5 11.5L3 8",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),16/24);break;case"x":r=s(l,{children:[o("path",{d:"M18.75 5.25L5.25 18.75",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),o("path",{d:"M18.75 18.75L5.25 5.25",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})]});break;case"card":r=R(o("path",{fill:"currentColor",d:"M17.5 3.75H2.5C2.16848 3.75 1.85054 3.8817 1.61612 4.11612C1.3817 4.35054 1.25 4.66848 1.25 5V15C1.25 15.3315 1.3817 15.6495 1.61612 15.8839C1.85054 16.1183 2.16848 16.25 2.5 16.25H17.5C17.8315 16.25 18.1495 16.1183 18.3839 15.8839C18.6183 15.6495 18.75 15.3315 18.75 15V5C18.75 4.66848 18.6183 4.35054 18.3839 4.11612C18.1495 3.8817 17.8315 3.75 17.5 3.75ZM10.625 13.75H9.375C9.20924 13.75 9.05027 13.6842 8.93306 13.5669C8.81585 13.4497 8.75 13.2908 8.75 13.125C8.75 12.9592 8.81585 12.8003 8.93306 12.6831C9.05027 12.5658 9.20924 12.5 9.375 12.5H10.625C10.7908 12.5 10.9497 12.5658 11.0669 12.6831C11.1842 12.8003 11.25 12.9592 11.25 13.125C11.25 13.2908 11.1842 13.4497 11.0669 13.5669C10.9497 13.6842 10.7908 13.75 10.625 13.75ZM15.625 13.75H13.125C12.9592 13.75 12.8003 13.6842 12.6831 13.5669C12.5658 13.4497 12.5 13.2908 12.5 13.125C12.5 12.9592 12.5658 12.8003 12.6831 12.6831C12.8003 12.5658 12.9592 12.5 13.125 12.5H15.625C15.7908 12.5 15.9497 12.5658 16.0669 12.6831C16.1842 12.8003 16.25 12.9592 16.25 13.125C16.25 13.2908 16.1842 13.4497 16.0669 13.5669C15.9497 13.6842 15.7908 13.75 15.625 13.75ZM2.5 6.875V5H17.5V6.875H2.5Z"}),20/24);break;case"qr":r=R(s(l,{children:[o("path",{fill:"currentColor",d:"M8.125 3.125h-3.75c-.69 0-1.25.56-1.25 1.25v3.75c0 .69.56 1.25 1.25 1.25h3.75c.69 0 1.25-.56 1.25-1.25v-3.75c0-.69-.56-1.25-1.25-1.25M8.125 10.625h-3.75c-.69 0-1.25.56-1.25 1.25v3.75c0 .69.56 1.25 1.25 1.25h3.75c.69 0 1.25-.56 1.25-1.25v-3.75c0-.69-.56-1.25-1.25-1.25M15.625 3.125h-3.75c-.69 0-1.25.56-1.25 1.25v3.75c0 .69.56 1.25 1.25 1.25h3.75c.69 0 1.25-.56 1.25-1.25v-3.75c0-.69-.56-1.25-1.25-1.25M11.25 14.375a.624.624 0 0 0 .625-.625v-2.5a.624.624 0 1 0-1.25 0v2.5a.624.624 0 0 0 .625.625"}),o("path",{fill:"currentColor",d:"M16.25 11.875h-1.875v-.625a.624.624 0 1 0-1.25 0v4.375H11.25a.624.624 0 1 0 0 1.25h2.5a.624.624 0 0 0 .625-.625v-3.125h1.875a.624.624 0 1 0 0-1.25M16.25 14.375a.624.624 0 0 0-.625.625v1.25a.624.624 0 1 0 1.25 0V15a.624.624 0 0 0-.625-.625"})]}),20/24);break;case"otc":r=R(s(l,{children:[o("path",{fill:"currentColor","fill-rule":"evenodd",d:"M16.972 9.547c.092-.107.207-.021.207.12v6.924c0 .283-.23.513-.512.513h-7.18v-5.129a.513.513 0 0 0-.514-.512h-3.59a.513.513 0 0 0-.513.512v5.13H3.332a.514.514 0 0 1-.513-.514V9.853c0-.244.149-.33.331-.168.268.238.586.428.936.556a3.2 3.2 0 0 0 2.209 0c.35-.128.669-.318.936-.556a.56.56 0 0 1 .728 0c.267.238.586.428.935.556a3.2 3.2 0 0 0 2.209 0c.35-.128.669-.318.937-.556a.56.56 0 0 1 .727 0c.267.238.586.428.935.556a3.2 3.2 0 0 0 2.21 0c.349-.128.668-.318.936-.556.04-.036.081-.088.124-.138m-4.409 1.915a.513.513 0 0 0-.512.513v1.283c0 .283.23.512.512.513h2.052c.283 0 .513-.23.513-.513v-1.283a.513.513 0 0 0-.513-.512z","clip-rule":"evenodd"}),o("path",{fill:"currentColor",d:"M16.325 3c.148 0 .293.054.412.153.118.1.204.24.245.398l.99 2.872a.51.51 0 0 1-.333.654 2.4 2.4 0 0 1-.166.495c-.145.31-.357.593-.625.831a2.9 2.9 0 0 1-.936.556 3.2 3.2 0 0 1-2.209 0 2.9 2.9 0 0 1-.936-.556.56.56 0 0 0-.727 0 2.9 2.9 0 0 1-.936.556 3.2 3.2 0 0 1-2.209 0 2.9 2.9 0 0 1-.936-.556.56.56 0 0 0-.728 0 2.9 2.9 0 0 1-.935.556 3.2 3.2 0 0 1-2.21 0 2.9 2.9 0 0 1-.936-.556 2.6 2.6 0 0 1-.624-.831 2.4 2.4 0 0 1-.167-.495.51.51 0 0 1-.33-.654l.99-2.872a.77.77 0 0 1 .244-.397A.64.64 0 0 1 3.675 3z"})]}),20/24);break;case"ewallet":r=R(o("path",{fill:"currentColor","fill-rule":"evenodd",d:"M11.313 2.07c.94-.23 2.112.266 2.63 1.145H9.331c-1.242 0-2.295.021-3.171.053 1.648-.683 3.44-.78 5.153-1.198M4.338 17.855c1.061.072 2.691.145 4.971.145s3.91-.073 4.972-.145c1.168-.08 2.09-.963 2.186-2.134q.029-.335.054-.747a40 40 0 0 1-2.644-.012c-1.298-.052-2.345-1.039-2.405-2.362a26 26 0 0 1-.023-1.153q.002-.67.023-1.153c.06-1.323 1.107-2.31 2.405-2.362q.745-.029 1.494-.027.654 0 1.15.016a36 36 0 0 0-.054-.748c-.096-1.17-1.018-2.053-2.186-2.133-1.062-.073-2.692-.146-4.972-.146s-3.91.073-4.971.146c-1.169.08-2.09.962-2.187 2.133A53 53 0 0 0 2 11.447c0 1.922.073 3.326.151 4.274.096 1.171 1.018 2.053 2.187 2.134m8.675-5.325c.03.662.544 1.155 1.21 1.181q.508.022 1.274.024.766-.002 1.273-.024c.667-.026 1.18-.52 1.21-1.181q.019-.404.02-.971-.001-.569-.02-.971c-.03-.662-.544-1.156-1.21-1.182a32 32 0 0 0-1.273-.024c-.512 0-.934.01-1.274.024-.667.026-1.18.52-1.21 1.182q-.019.403-.02.97.001.569.02.972m2.041-1.749c.159 0 .311.05.424.137a.42.42 0 0 1 .175.33v.622a.42.42 0 0 1-.175.33.7.7 0 0 1-.424.136.7.7 0 0 1-.423-.137.42.42 0 0 1-.176-.33v-.621c0-.124.063-.242.176-.33a.7.7 0 0 1 .423-.137","clip-rule":"evenodd"}),20/24);break;case"bank_transfer":r=R(o("path",{fill:"currentColor",d:"M9.195 1.947a1.46 1.46 0 0 1 1.72 0l6.184 4.514c.814.593.629 1.463-.378 1.466H3.388C2.38 7.924 2.196 7.054 3.01 6.46zm.235 11.196a.2.2 0 0 1-.2.2H7.963a.2.2 0 0 1-.2-.2V9.377c0-.11.09-.2.2-.2H9.23c.11 0 .2.09.2.2zm2.916 0a.2.2 0 0 1-.2.2H10.88a.2.2 0 0 1-.2-.2V9.377c0-.11.09-.2.2-.2h1.267c.11 0 .2.09.2.2zm3.125 0a.2.2 0 0 1-.2.2h-1.475a.2.2 0 0 1-.2-.2V9.377c0-.11.09-.2.2-.2h1.475c.11 0 .2.09.2.2zm-12.916 1.45v1.875c0 .346.28.625.625.625h13.75a.625.625 0 0 0 .625-.625v-1.875s-12.07-.128-15 0m3.958-1.45a.2.2 0 0 1-.2.2H4.838a.2.2 0 0 1-.2-.2V9.377c0-.11.09-.2.2-.2h1.475c.11 0 .2.09.2.2z"}),20/24);break;case"online_banking":r=R(s(l,{children:[o("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.25",d:"M14.25 17.708a3.75 3.75 0 1 0 0-7.5 3.75 3.75 0 0 0 0 7.5"}),o("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",d:"M10.5 13.958H18m-3.75-3.75a5.437 5.437 0 0 0 0 7.5 5.44 5.44 0 0 0 0-7.5"}),o("path",{fill:"currentColor",d:"M8.706 14.537c.15.97.574 1.848 1.188 2.556H3.18a.625.625 0 0 1-.625-.625v-1.875c1.115-.049 3.556-.06 6.151-.056M6.346 9.177c.092 0 .167.074.167.166v3.833a.167.167 0 0 1-.167.167H4.805a.167.167 0 0 1-.167-.167V9.343c0-.092.075-.166.167-.166zM9.263 9.177c.092 0 .167.074.167.166v1.69a5.1 5.1 0 0 0-.767 2.31H7.93a.167.167 0 0 1-.167-.167V9.343c0-.092.075-.166.167-.166zM11.484 9.177q-.428.21-.804.495v-.329c0-.092.074-.166.166-.166zM10.055 1.667c.309 0 .61.098.86.28l6.184 4.514c.814.593.629 1.463-.378 1.466H3.388c-1.007-.003-1.192-.873-.379-1.466l6.185-4.513c.25-.183.551-.281.86-.281"})]}),20/24);break;case"copy":r=R(s(l,{children:[o("path",{d:"M6 9.5H10",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M6 7.5H10",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M10 2.5H12.5C12.6326 2.5 12.7598 2.55268 12.8536 2.64645C12.9473 2.74021 13 2.86739 13 3V13.5C13 13.6326 12.9473 13.7598 12.8536 13.8536C12.7598 13.9473 12.6326 14 12.5 14H3.5C3.36739 14 3.24021 13.9473 3.14645 13.8536C3.05268 13.7598 3 13.6326 3 13.5V3C3 2.86739 3.05268 2.74021 3.14645 2.64645C3.24021 2.55268 3.36739 2.5 3.5 2.5H6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M5.5 4.5V4C5.5 3.33696 5.76339 2.70107 6.23223 2.23223C6.70107 1.76339 7.33696 1.5 8 1.5C8.66304 1.5 9.29893 1.76339 9.76777 2.23223C10.2366 2.70107 10.5 3.33696 10.5 4V4.5H5.5Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]}),16/24);break;case"dummy":r=R(o("path",{fill:"currentColor",d:"M17.5 11.875V15C17.5 15.3315 17.3683 15.6495 17.1339 15.8839C16.8995 16.1183 16.5815 16.25 16.25 16.25H3.75C3.41848 16.25 3.10054 16.1183 2.86612 15.8839C2.6317 15.6495 2.5 15.3315 2.5 15V11.875C2.5 11.5435 2.6317 11.2255 2.86612 10.9911C3.10054 10.7567 3.41848 10.625 3.75 10.625H16.25C16.5815 10.625 16.8995 10.7567 17.1339 10.9911C17.3683 11.2255 17.5 11.5435 17.5 11.875ZM16.25 3.75H3.75C3.41848 3.75 3.10054 3.8817 2.86612 4.11612C2.6317 4.35054 2.5 4.66848 2.5 5V8.125C2.5 8.45652 2.6317 8.77446 2.86612 9.00888C3.10054 9.2433 3.41848 9.375 3.75 9.375H16.25C16.5815 9.375 16.8995 9.2433 17.1339 9.00888C17.3683 8.77446 17.5 8.45652 17.5 8.125V5C17.5 4.66848 17.3683 4.35054 17.1339 4.11612C16.8995 3.8817 16.5815 3.75 16.25 3.75Z"}),20/24);break;default:throw new Error(`Icon with name ${n} does not exist`)}return o("svg",{className:`xendit-icon ${e.className??""}`,width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"none",children:o("g",{transform:a,children:r})})};function R(e,n){return o("g",{transform:`scale(${1/n} ${1/n})`,children:e})}const T=e=>{const{id:n,title:t,iconName:i,subtitle:a,disabled:r,open:l,onClick:c,children:u}=e,h=l?"up":"down",p=d(()=>{r||c(n)},[r,c,n]),m=d(e=>{"Enter"!==e.key&&" "!==e.key||(p(),e.preventDefault())},[p]),f=d(()=>{p()},[p]);return s("div",{className:y("xendit-accordion-item",r?"xendit-accordion-item-disabled":"",l?"xendit-accordion-item-open":"xendit-accordion-item-closed"),children:[s("div",{className:"xendit-accordion-item-header",onClick:f,onKeyDown:m,role:"button",tabIndex:r?-1:0,children:[o(I,{className:"xendit-accordion-item-header-icon",name:i,size:24}),s("div",{className:"xendit-accordion-item-header-title xendit-text-16 xendit-text-bold",children:[t,a?o("div",{className:"xendit-accordion-item-header-subtitle xendit-text-14",children:a}):null]}),o(I,{className:"xendit-accordion-item-chevron",name:"chevron",size:24,direction:h})]}),o("div",{className:"xendit-accordion-item-content",inert:!l,children:o("div",{className:"xendit-accordion-item-padding",children:u})})]})},D=n(null);D.displayName="SessionContext";const M=n(null);M.displayName="BusinessContext";const L=n(null);L.displayName="CustomerContext";const U=n(null);U.displayName="ChannelsContext";const O=n(null);O.displayName="ChannelUiGroupsContext";const q=n(null);q.displayName="DigitalWalletsContext";const B=n(null);B.displayName="SdkContext";const V=n(null);V.displayName="CurrentChannelContext";const K=()=>{const e=c(D);if(null===e)throw new Error("useSession must be used within a XenditSessionProvider");return e},W=()=>{const e=c(U);if(null===e)throw new Error("useChannels must be used within a XenditSessionProvider");return e},F=()=>c(q),$=()=>{const e=c(B);if(null===e)throw new Error("useSdk must be used within a XenditSessionProvider");return e},G=()=>c(V),z=({children:e,data:n,sdk:t})=>{const{session:i,business:a,customer:r,channels:s,digitalWallets:l,channelUiGroups:d}=n,c=t.getCurrentChannel()?.[P]?.[0]??null;return"ACTIVE"!==t.getSdkStatus()||"ACTIVE"!==i.status?null:o(B.Provider,{value:t,children:o(V.Provider,{value:c,children:o(D.Provider,{value:i,children:o(M.Provider,{value:a,children:o(L.Provider,{value:r,children:o(U.Provider,{value:s,children:o(q.Provider,{value:l,children:o(O.Provider,{value:d,children:e})})})})})})})})},H=300;function X(e){if(!e)throw new Error("Assertion failed: argument is null or undefined; this is a bug, please contact support.")}function Y(e){if(!Array.isArray(e))throw new Error("Assertion failed: expected array; this is a bug, please contact support.")}function j(e){if(Array.isArray(e))throw new Error("Assertion failed: expected array; this is a bug, please contact support.")}function Q(e,n){if(e!==n)throw new Error("Assertion failed; this is a bug, please contact support.")}function Z(e){return new Promise(n=>setTimeout(n,1*e))}class AbortError extends Error{constructor(){super("AbortError"),this.name="AbortError"}}function J(e){return e instanceof AbortError&&"AbortError"===e.name}function ee(e,n){return new Promise((t,i)=>{function a(){n.removeEventListener("abort",a),clearTimeout(r),i(new AbortError)}const r=setTimeout(()=>{n.removeEventListener("abort",a),t()},1*e);n.aborted?a():n.addEventListener("abort",a)})}function ne(e){const n=e.find(e=>{switch(e.type){case"REDIRECT_CUSTOMER":switch(e.descriptor){case"WEB_URL":return!0;case"DEEPLINK_URL":return function(){const e=navigator.userAgent;if(!e)return!1;if(/android/i.test(e))return!0;if(/iPad|iPhone|iPod/.test(e))return!0;return!1}();case"WEB_GOOGLE_PAYLINK":return!1}break;case"PRESENT_TO_CUSTOMER":return!0;case"API_POST_REQUEST":return!1}return!1});return n||e[0]}function te(e,n){if(e[P].options.enablePaylinks)return n.find(e=>"REDIRECT_CUSTOMER"===e.type&&"WEB_GOOGLE_PAYLINK"===e.descriptor)}const ie="mock",ae={pl:"https://checkout-ui-gateway.xendit.co",pd:"https://checkout-ui-gateway-prod-dev.xendit.co",sl:"https://checkout-ui-gateway-live.stg.tidnex.dev",sd:"https://checkout-ui-gateway-dev.stg.tidnex.dev"};function re(e){return ae[e]??null}function oe(e,n){const t={...e};for(const e of Object.keys(n)){const i=n[e];void 0!==i&&(t[e]=i)}return t}function se(e){const n=u();return h(()=>{n.current=e}),n.current}function le(e){let n;if("string"==typeof e.channel_property)n=e.channel_property;else{n=Object.values(e.channel_property).join("__")}return n}const de=Math.floor(255*Math.random());function ce(e){return`xendit-id-${le(e).split("").map(e=>(e.charCodeAt(0)%256^de).toString(16)).join("")}`}function ue(e){X(e%2==0);const n=function(e){const n=new Uint8Array(e);for(let t=0;t<e;t++)n[t]=Math.floor(256*Math.random());return n}(e/2);return Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join("")}function he(){return[ue(8),ue(4),ue(4),ue(4),ue(12)].join("-")}function pe(){return`xendit-id-${u(ue(12)).current}`}function me(e){return"PRESENT_TO_CUSTOMER"===e.type}function fe(e){if(e instanceof Error)return e.stack??e.message;if("string"==typeof e)return e;try{return`Unknown error: ${JSON.stringify(e)}`}catch{return"Unknown error"}}function be(e){for(const n of Object.keys(e)){if("symbol"==typeof n)continue;const t=Object.getOwnPropertyDescriptor(e,n);void 0!==t&&("function"!=typeof t.get&&void 0===t.value&&delete e[n])}return e}function ye(e,n){let t=e;if(!n)return;if(Array.isArray(t))throw new Error("Getting values from channel property arrays is not supported.");let i=n;for(;;){if(!i||"object"!=typeof i||Array.isArray(i))return;const e=t.indexOf(".");if(-1===e)return i?i[t]:void 0;{const n=t.slice(0,e);i=i?i[n]:void 0,t=t.slice(e+1)}}}function _e(e){const n=ye("card_details.card_number",e);return"string"!=typeof n?null:n}function ge(e){const n={version:0,publicKey:"",iv:"",cipherText:"",valid:!1,validationError:null,withoutValidationError:e};if(!e)return n;const t=e.split("-");if(t.length<6)throw new Error("Invalid encrypted field value format.");if("xendit"!==t[0])throw new Error("Invalid encrypted field value format.");if("encrypted"!==t[1])throw new Error("Invalid encrypted field value format.");const i=parseInt(t[2],10);if(isNaN(i)||i<=0)throw new Error("Invalid encrypted field value format.");if(n.version=i,n.publicKey=t[3],n.iv=t[4],n.cipherText=t[5],t.length>6){if("invalid"!==t[6])throw new Error("Invalid encrypted field value format.");n.validationError=atob(t[7]),n.withoutValidationError=t.slice(0,6).join("-")}else n.valid=!0;return n}const xe=new WeakMap;let ve=1;function ke(e,n){return X(e.length>0),X(e.length<=2),2===e.length?n?(X(!0===e[1].allow_save),e[1]):(X(!1===e[0].allow_save),e[0]):e[0]}function we(e,n){if("PAY"!==e.session_type)return!0;const t=e.amount,i=n.min_amount??0,a=n.max_amount??Number.MAX_VALUE;return!(t<i||t>a)}function Ce(e){Object.defineProperty(e,P,{enumerable:!1,writable:!1,configurable:!1,value:e[P]})}const Ee={CARDS:!0,QRIS:!0,QR_PH:!0,PROMPTPAY:!0,SGQR:!0};function Ae(e,n){for(const t of e)if(t.type.name===n)return!0;return!1}var Ne,Pe;!function(e){e.BARE="bare",e.PRIMARY_ROUNDED="primary-rounded",e.WHITE_ROUNDED="white-rounded"}(Ne||(Ne={})),function(e){e.SM="sm",e.MD="md"}(Pe||(Pe={}));const Se=e=>{const{children:n,variant:t,size:i,type:a="button",...r}=e,s={[Ne.BARE]:void 0,[Ne.PRIMARY_ROUNDED]:"xendit-button-primary-rounded",[Ne.WHITE_ROUNDED]:"xendit-button-white-rounded"}[t],l={[Pe.SM]:"xendit-button-sm",[Pe.MD]:void 0}[i??Pe.MD];return o("button",{...r,className:y(e.className,"xendit-button",s,l),type:a,children:n})},Ie=()=>{const e=.4*Math.PI,n=.4,t=Math.cos(e)*n,i=Math.sin(e)*n,a=Math.cos(0)*n,r=Math.sin(0)*n;return o("svg",{className:"xendit-button-loading-spinner",viewBox:"-0.5 -0.5 1 1",children:o("path",{d:`M ${t} ${i} A 0.4 0.4 0 0 0 ${a} ${r}`,fill:"none",stroke:"currentColor",strokeWidth:"0.1",strokeLinecap:"round"})})},Re=e=>{const{id:n,options:t,onChange:i,defaultIndex:a=-1,selectedIndex:r,placeholder:l,disabled:c,className:f,fixedOverlayWidth:b,enableSearch:y}=e,_=$().t,g=pe(),x=n||g,v="number"==typeof r,[k,w]=p(a),C=v?r:k,[E,A]=p(C>=0?C:0),[N,P]=p(!1),S=N&&!c&&t.length>0,[R,T]=p(""),[D,M]=p(0),L=u(null),U=u(null),O=u(null),q=u(null),B=u(null),V=u(null),K=m(()=>{const e=t.map(Le).filter(({item:e})=>{if(""===R.trim())return!0;const n=R.toLowerCase();return e.title.toLowerCase().includes(n)||e.description?.toLowerCase().includes(n)||e.value.toLowerCase().includes(n)});return e.length>0?e:t.map(Le)},[R,t]),W=Math.max(0,Math.min(K.length-1,E));h(()=>{if(b)return void M(b);const e=L.current;if(!e)return;const n=e.getBoundingClientRect().width;if(M(n),!window.ResizeObserver)return;const t=new ResizeObserver(n=>{for(const t of n)t.target===e&&t.borderBoxSize?.length&&M(t.borderBoxSize[0].inlineSize)});return t.observe(e),()=>t.disconnect()},[b]),h(()=>{if(!S)return;const e=V.current;if(!e)return;const n=L.current;if(!n)return;if(!window.ResizeObserver)return;function t(){if(!e)return;if(!n)return;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();window.innerHeight-t.bottom<i.height?(e.style.position="fixed",e.style.bottom="0"):(e.style.position="",e.style.bottom="")}t();const i=new ResizeObserver(t);return i.observe(e),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{i.disconnect(),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[S]),h(()=>{if(!S)return;const e=e=>{const n=U.current;n&&(n.contains(e.target)||P(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[S]),h(()=>{if(!S)return;const e=e=>{const n=U.current;n&&e.relatedTarget&&(n.contains(e.relatedTarget)||P(!1))};return document.body.addEventListener("focusout",e),()=>document.body.removeEventListener("focusout",e)},[S]),h(()=>{S&&C>=0&&A(C)},[S,C]),h(()=>{if(!S)return;if(!q.current)return;if(!O.current)return;const e=O.current.parentElement;e&&(e.scrollTop=q.current.offsetTop-e.clientHeight/2+q.current.clientHeight/2)},[S,E]);const F=d(()=>{S||(P(!0),queueMicrotask(()=>B.current?.focus()))},[S]),G=d(()=>{S&&(P(!1),T(""),L.current?.focus())},[S]),z=d(()=>{S?G():F()},[G,S,F]),H=d(e=>{const n=t[e];n&&(n.disabled||(v||w(e),i(n,e),G()))},[G,v,i,t]),X=d(e=>{const n=e.target===B.current;if("Escape"===e.key)return e.preventDefault(),void G();if("Enter"===e.key||" "===e.key){if(n&&" "===e.key)return;e.preventDefault();const t=K[W];return void(t&&H(t.originalIndex))}return"ArrowDown"===e.key?(e.preventDefault(),void A(e=>Math.min(K.length-1,e+1))):"ArrowUp"===e.key?(e.preventDefault(),void A(e=>Math.max(0,e-1))):"Home"===e.key?(e.preventDefault(),void A(0)):"End"===e.key?(e.preventDefault(),void A(K.length-1)):void 0},[W,G,H,K]),Y=d(e=>{if(S)return X(e);"ArrowDown"!==e.key&&"ArrowUp"!==e.key&&" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),F())},[X,S,F]),j=d(e=>{e.stopPropagation(),e.preventDefault(),H(Number(e.currentTarget.dataset.index))},[H]),Q=d(e=>{T(e.currentTarget.value),A(0)},[]),Z=C>=0?t[C]:void 0;return s("div",{className:"xendit-dropdown-container",ref:U,style:{"--xendit-dropdown-width":D+"px"},children:[s("button",{id:x,ref:L,type:"button",className:`xendit-dropdown ${f} ${S?"xendit-dropdown-open":""} ${De(Z)?"xendit-dropdown-has-asset":""}`,"aria-expanded":S?"true":"false",onClick:z,onKeyDown:Y,disabled:c,children:[Z?.leadingAsset??null,o("span",Z?{className:"xendit-dropdown-text xendit-text-14",children:Z.shortTitle??Z.title}:{className:"xendit-dropdown-text xendit-text-14",children:l}),o(I,{className:"xendit-dropdown-chevron",name:"chevron",size:16,direction:"down"})]}),S?s("div",{className:"xendit-dropdown-overlay",style:{width:"var(--xendit-dropdown-width)"},ref:V,children:[y?o("div",{className:"xendit-dropdown-search",children:o("input",{ref:B,placeholder:_("combobox.default_search_placeholder"),value:R,onInput:Q,onClick:Me,onKeyDown:X})}):null,o("ul",{ref:O,role:"listbox",tabIndex:-1,onKeyDown:X,children:K.map(({item:e,originalIndex:n},t)=>{const i=n===C,a=t===W;return o("li",{role:"option","data-index":n,"aria-disabled":!!e.disabled||void 0,"aria-selected":i,onClick:j,ref:a?q:void 0,children:s("div",{className:`xendit-dropdown-item xendit-text-14 ${a?"xendit-dropdown-item-active":""} ${e.leadingAsset?"xendit-dropdown-has-asset":""} ${e.disabled?"xendit-dropdown-item-disabled":""}`,children:[e.leadingAssetInOverlay??e.leadingAsset??null,s("div",{className:"xendit-dropdown-item-text xendit-text-14",children:[o("span",{className:"xendit-dropdown-item-title",children:e.title}),e.description&&o("span",{className:"xendit-dropdown-item-description xendit-text-12",children:e.description})]}),i?o(I,{name:"check",size:16,className:"xendit-dropdown-item-selected"}):null]})},n)})})]}):null]})},Te=e=>o("div",{className:"xendit-dropdown-container xendit-skeleton-field",children:o("button",{className:`xendit-dropdown ${e.className}`,inert:!0,id:e.id,disabled:!0,type:"button",children:o(Ie,{})})});function De(e){return!!e&&!(!e.leadingAssetInOverlay&&!e.leadingAsset)}function Me(e){e.stopPropagation()}function Le(e,n){return{item:e,originalIndex:n}}function Ue(e){return function(e,n){if(e===n)throw new Error("Assertion failed; this is a bug, please contact support.")}(e.session_type,"AUTHORIZATION"),Q(e.mode,"COMPONENTS"),be({id:e.payment_session_id,description:e.description||void 0,sessionType:e.session_type,mode:e.mode,referenceId:e.reference_id,country:e.country,currency:e.currency,amount:e.amount,channelProperties:e.channel_properties||void 0,expiresAt:new Date(e.expires_at),locale:e.locale,status:e.status,items:e.items?.map(e=>be({type:e.type,referenceId:e.reference_id,name:e.name,netUnitAmount:e.net_unit_amount,quantity:e.quantity,url:e.url,imageUrl:e.image_url,category:e.category,subcategory:e.subcategory,description:e.description,metadata:e.metadata}))})}function Oe(e,n,t,i){const a=be({groupId:e.id,label:e.label,get channels(){return(n[e.id]||[]).map(e=>Be(e,n,t,i))},[P]:e});return Ce(a),a}function qe(e,n){return Be(e,{},{},n)}function Be(e,n,t,i){X(!i.pairChannels.paired[e.channel_code]);const a=be({channelCode:i.pairChannels.pairs[e.channel_code]?.map(e=>e.channel_code)??e.channel_code,brandName:e.brand_name,brandColor:e.brand_color,brandLogoUrl:e.brand_logo_url,get uiGroup(){if(!t[e.ui_group])throw new Error("UI group not found");return Oe(t[e.ui_group],n,t,i)},minAmount:e.min_amount,maxAmount:e.max_amount,cardBrands:e.card?.brands.map(e=>({name:e.name,logoUrl:e.logo_url})),[P]:i.pairChannels.pairs[e.channel_code]??[e]});return Ce(a),a}function Ve(e){const n={};for(const t of e)n[t.id]=t;return n}function Ke(e,n){if(n.pairChannels.paired[e.channel_code])return!1;if(n.options.filterMinMax&&!we(n.session,e))return!1;const t=n.options.filter;return!(t&&!function(e,n){if("string"==typeof e&&n===e)return!0;if(Array.isArray(e)&&e.includes(n))return!0;if(e instanceof RegExp&&e.test(n))return!0;return!1}(t,e.channel_code))}function We(e,n){const t={};for(const i of e){if(!Ke(i,n))continue;const e=i.ui_group;t[e]||(t[e]=[]),t[e].push(i)}return t}function Fe(e){const n=new Map;for(const t of e){const e=t.brand_name;n.has(e)||n.set(e,[]),n.get(e).push(t)}const t={},i={};for(const[e,a]of n)for(const e of a){if(!1===a[0].allow_save){const n=a.find(n=>e.channel_code!==n.channel_code&&e.ui_group===n.ui_group&&!0===n.allow_save);n&&(t[e.channel_code]=[e,n],i[n.channel_code]=!0)}}return{pairs:t,paired:i}}const $e=e=>o("hr",{className:"xendit-dotted-line"}),Ge=e=>{const{group:n,open:t}=e,i=$(),{t:a}=i,r=K(),l=W(),c=G(),f=r.session_type,b=pe(),[y,_]=p(null),g=u(null),[x,v]=p(!1),k=u(null),w=m(()=>Fe(l),[l]),C=m(()=>({pairChannels:w,session:{amount:r.amount,session_type:r.session_type},options:{filterMinMax:!1}}),[w,r.amount,r.session_type]),E=m(()=>l.filter(e=>Ke(e,C)&&e.ui_group===n.id),[l,n.id,C]);h(()=>{if(!g.current)return;if(!c)return;if(!t)return;E.find(e=>e.channel_code===c.channel_code)&&(k.current=i.createChannelComponent(qe(c,C)),k.current.parentElement!==g.current&&(v(!0),g.current.replaceChildren(k.current)))},[E,c,C,t,i]);const A=se(t);h(()=>{if(t&&!A&&null===c&&null!==y){const e=E.find(e=>e.channel_code===y);e&&i.setCurrentChannel(qe(e,C))}},[E,c,y,C,t,A,i]);const N=d(e=>{const n=l.find(n=>n.channel_code===e.value)||null;_(n?.channel_code??null),i.setCurrentChannel(n?qe(n,C):null)},[l,C,i]),P=m(()=>E.map(e=>({leadingAsset:o("img",{className:"xendit-dropdown-channel-logo",src:e.brand_logo_url},e.channel_code),leadingAssetInOverlay:o("img",{className:"xendit-channel-logo",src:e.brand_logo_url},e.channel_code),title:e.brand_name,value:e.channel_code,disabled:!we(r,e),description:ze(a,r,e)||void 0})),[E,r,a]),S=1===E.length&&"CARDS"===E[0].channel_code;return s("div",{className:"xendit-channel-picker-group",children:[S?null:s("div",{className:"xendit-channel-form-field-group",children:[o("label",{htmlFor:b,className:"xendit-text-14",children:"SAVE"===f?a("payment_methods.add_payment_method",{groupName:n.label??"",ns:"session"}):a("payment_methods.pay_with")}),o(Re,{id:b,selectedIndex:function(){const e=P.findIndex(e=>e.value===c?.channel_code);if(-1!==e)return e;const n=P.findIndex(e=>e.value===y);return-1!==n?n:1===P.length?0:-1}(),options:P,disabled:P.length<=1,onChange:N,placeholder:a("payment_methods.select_channel_placeholder",{groupName:n.label,ns:"session"})})]}),!S&&x?o($e,{}):null,o("div",{style:{display:x?"":"none"},ref:g})]})};function ze(e,n,t){return we(n,t)?null:t.min_amount&&n.amount<t.min_amount?e("payment_methods.channel_disabled_amount_too_small"):e("payment_methods.channel_disabled_amount_too_large")}const He=e=>{const n=$(),t=u(null),i=F(),a=i?.google_pay;return h(()=>{if(t.current&&a){const e=n.createDigitalWalletComponent("GOOGLE_PAY");return t.current.appendChild(e),()=>{e.remove()}}},[a,n]),o("div",{ref:t,className:"xendit-channel-picker-digital-wallet-section"})},Xe=e=>{const n=$(),t=K(),i=(()=>{const e=c(O);if(null===e)throw new Error("useChannelUiGroups must be used within a XenditSessionProvider");return e})(),a=G(),r=W(),{t:l}=$(),f=m(()=>We(r,{options:{filterMinMax:!1},pairChannels:Fe(r),session:t}),[r,t]),b=u(null),y=m(()=>Fe(r),[r]),_=m(()=>({pairChannels:y,session:{amount:t.amount,session_type:t.session_type},options:{filterMinMax:!1}}),[y,t.amount,t.session_type]),g=a?.ui_group??null,[x,v]=p(null),k=d(e=>{if(g===e||x===e)g===e&&b.current?.dispatchEvent(new XenditClearCurrentChannelEvent(e)),x===e&&v(null);else{const a=i.find(n=>n.id===e);X(a);const o=Ye(t,a,r,l).enabledChannels;if(0===o)return;if(1===o){const t=f[e][0];n.setCurrentChannel(qe(t,_)),v(null)}else v(e),n.setCurrentChannel(null)}},[i,r,f,_,x,n,g,t,l]);h(()=>{null!==a&&null!==x&&v(null)},[a,x]);const w=n[P].options.enableDigitalWallets??!1;return s("div",{ref:b,children:[w?o(He,{}):null,o(S,{children:i.filter(e=>(f[e.id]||[]).length>0).map(e=>{const n=null!==g?g===e.id:x===e.id,i=Ye(t,e,r,l),s=0===i.enabledChannels,d=i.firstDisabledChannelReason;return o(T,{id:e.id,title:e.label,iconName:Qe(g===e.id?a:null,f[e.id]),subtitle:d??void 0,open:n,disabled:s,onClick:k,children:o(Ge,{group:e,open:n})},e.id)})})]})};function Ye(e,n,t,i){let a=null,r=0;for(const o of t)o.ui_group===n.id&&(we(e,o)?r++:null===a&&(a=ze(i,e,o)));return{enabledChannels:r,firstDisabledChannelReason:a}}const je={CARDS:"card",QR_CODE:"qr",OVER_THE_COUNTER:"otc",EWALLET:"ewallet",BANK_TRANSFER:"bank_transfer",DIRECT_DEBIT:"bank_transfer",VIRTUAL_ACCOUNT:"bank_transfer",ONLINE_BANKING:"online_banking"};function Qe(e,n){if(e&&e.pm_type&&je[e.pm_type])return je[e.pm_type];for(const e of n)if(e.pm_type&&je[e.pm_type])return je[e.pm_type];return"dummy"}class XenditClearCurrentChannelEvent extends Event{static type="xendit-clear-current-channel";uiGroup;constructor(e){super(XenditClearCurrentChannelEvent.type,{bubbles:!0,composed:!0}),this.uiGroup=e}}const Ze=({countryCode:e,size:n=16})=>o("div",{style:{width:`${n}px`,height:`${n}px`,borderRadius:"50%",backgroundImage:`url(https://assets.xendit.co/payment-session/flags/circle/${e.toLowerCase()}.svg)`,backgroundSize:"cover",backgroundPosition:"center"}}),Je=e=>{const{field:n,onChange:t}=e,i=ce(n),a=le(n),[r,l]=p(void 0),c=en.findIndex(e=>e.value===r),h=u(null);nn(e=>{if(h.current){const n=en.find(n=>n.value===e);n&&m(n)}});const m=d(e=>{l(e.value),h.current&&(h.current.value=e.value),t()},[t]);return s("div",{children:[o("input",{type:"hidden",name:a,defaultValue:"",ref:h}),o(Re,{id:i,options:en,onChange:m,placeholder:n.placeholder,selectedIndex:c,enableSearch:!0,className:"xendit-form-field-inner"})]})},en=g().map(e=>({title:new Intl.DisplayNames(["en"],{type:"region"}).of(e),value:e,leadingAsset:o(Ze,{countryCode:e})})).sort((e,n)=>e.title.localeCompare(n.title));function nn(e){const n=gt()?.cardDetails,t=n?.details?.country_codes[0],i=se(t);h(()=>{t&&t!==i&&e(t)})}const tn=e=>{const{field:n,onChange:t}=e,i=ce(n),a=le(n);if(!function(e){return"dropdown"===e.type.name}(n))throw new Error("DropdownField expects field.type.name to be 'dropdown'");const r=u(null),c=m(()=>n.type.options.map(e=>({title:e.label,description:e.subtitle,value:e.value})),[n.type.options]),[f,b]=p(c[0]?.value??""),y=d(e=>{r.current&&(r.current.value=e.value),b(e.value),t()},[t]);h(()=>{c.length&&y(c[0])},[]);const _=c.findIndex(e=>e.value===f);return s(l,{children:[o(Re,{id:i,placeholder:n.placeholder,options:c,onChange:y,selectedIndex:_,className:"xendit-form-field-inner"}),o("input",{type:"hidden",name:a,defaultValue:"",ref:r})]})};const an="undefined"!=typeof window&&window.HTMLElement?window.HTMLElement:EventTarget;class XenditFormAssociatedFocusTrap extends an{static tag="xendit-form-associated-focus-trap";static formAssociated=!0;internals;constructor(){super(),this.internals=this.attachInternals()}}var rn;rn=XenditFormAssociatedFocusTrap,"undefined"!=typeof window&&window.customElements&&customElements.define(rn.tag,rn);class InternalUpdateWorldState extends Event{data;static type="xendit-update-world-state";constructor(e){super(InternalUpdateWorldState.type,{bubbles:!1}),this.data=e}}class InternalUpdateChannelComponentData extends Event{channelCode;data;static type="xendit-update-channel-component-data";constructor(e,n){super(InternalUpdateChannelComponentData.type,{bubbles:!1}),this.channelCode=e,this.data=n}}class InternalSetFieldTouchedEvent extends Event{static type="xendit-internal-set-field-touched";constructor(){super(InternalSetFieldTouchedEvent.type,{bubbles:!0})}}class InternalBehaviorTreeUpdateEvent extends Event{static type="xendit-internal-behavior-tree-update";constructor(){super(InternalBehaviorTreeUpdateEvent.type,{})}}class InternalNeedsRerenderEvent extends Event{static type="xendit-internal-needs-rerender";constructor(){super(InternalNeedsRerenderEvent.type,{})}}class InternalScheduleMockUpdateEvent extends Event{mockData;static type="xendit-internal-schedule-mock-update";constructor(e){super(InternalScheduleMockUpdateEvent.type,{}),this.mockData=e}}const on=n(null);X("https://assets.xendit.co/components/secure-iframe-v0.0.18.html");const sn=new URL("https://assets.xendit.co/components/secure-iframe-v0.0.18.html").origin,ln=({children:e})=>{const n=u(new Map),t={registerIframe:(e,t)=>{t.current&&n.current.set(e,t.current)},unregisterIframe:e=>n.current.delete(e),postMessageToIframe:(e,t)=>{const i=n.current.get(e);i?.contentWindow&&i.contentWindow.postMessage(t,sn)}};return o(on.Provider,{value:t,children:e})};X("https://assets.xendit.co/components/secure-iframe-v0.0.18.html");const dn=new URL("https://assets.xendit.co/components/secure-iframe-v0.0.18.html"),cn=dn.toString(),un=dn.origin,hn=e=>{const{field:n,onChange:t}=e,i=$(),a=ce(n),r=le(n),l=K(),m=u(null),f=u(null),[b,y]=p(),[_,g]=p(!1),[x,v]=p(null),{card:k}=yt()??{},w=d(e=>{if(!m.current)return;const i=m.current.contentWindow;if(e.source!==i)return;if(e.origin!==un)return;const a=e.data;switch(a.type){case"xendit-iframe-ready":y(a.ecdhPublicKey);break;case"xendit-iframe-change":{if(!f.current)return;v(a.cardBrand);const e=a.encrypted,n=1,i=e.map(e=>{if(a.empty)return"";const t=["xendit-encrypted",n,b,e.iv,e.value];return!a.valid&&a.validationErrorCodes.length&&t.push("invalid",btoa(a.validationErrorCodes[0].localeKey)),t.join("-")});if(0===i.length)break;f.current.value=i.length>1?JSON.stringify(i):i[0],t?.();break}case"xendit-iframe-focus":g(!0);break;case"xendit-iframe-blur":g(!1),f.current?.value&&f.current?.dispatchEvent(new InternalSetFieldTouchedEvent);break;case"xendit-iframe-failed-init":console.error(`Iframe field for ${n.channel_property} failed to initialize securely`)}},[n.channel_property,b,t]),C=d(()=>{m.current?.contentWindow&&m.current.contentWindow.postMessage({type:"xendit-iframe-focus"},un)},[]);h(()=>(window.addEventListener("message",w),()=>{window.removeEventListener("message",w)}),[w]);const E=c(on);h(()=>(E?.registerIframe(r,m),()=>E?.unregisterIframe(r)),[r,E]);const A=new URL(cn);A.searchParams.set("input_type",n.type.name),A.searchParams.set("embedder",window.location.origin),A.searchParams.set("session_id",l.payment_session_id),A.searchParams.set("pk",i[P].sdkKey.publicKey),A.searchParams.set("sig",i[P].sdkKey.signature),i[P].options.iframeFieldAppearance&&A.searchParams.set("appearance",JSON.stringify(i[P].options.iframeFieldAppearance));return s("div",{className:`xendit-iframe-container xendit-form-field-inner ${_?"xendit-field-focus":""}`,children:[o(XenditFormAssociatedFocusTrap.tag,{id:a,onFocus:C,tabIndex:-1}),o("input",{type:"hidden",name:r,defaultValue:"",ref:f}),o("iframe",{src:A.toString(),ref:m,sandbox:"allow-scripts allow-same-origin"}),"credit_card_number"===n.type.name&&k&&o(pn,{cardsBrandList:k.brands,selectedCardBrand:x})]})},pn=({cardsBrandList:e,selectedCardBrand:n})=>{if(!e)return null;const t=e.find(e=>e.name===n)?.logo_url;return o("div",{className:"xendit-card-brands-list",children:n?t&&o("img",{className:"xendit-card-brand-logo",src:t,alt:n}):e.map(({name:e,logo_url:n})=>o("img",{className:"xendit-card-brand-logo",src:n,alt:e},e))})},mn=e=>{const{field:n,onChange:t}=e,i=ce(n),a=le(n),r=K(),l=u(null),[c,h]=p(r.country),f=m(()=>{const e=fn.findIndex(e=>e.value===c);return-1===e?0:e},[c]),b=fn[f],[y,_]=p(""),g=u(null),v=d((e,n)=>{const t=bn(e,n);return t?t.number:`+${e.dial}${n}`},[]),C=d((e,n)=>{l.current&&(l.current.value=v(e,n))},[v]);function E(e){const n=e;h(n.value),C(n,y),t()}return nn(e=>{const n=fn.find(n=>n.value===e);n&&n.value!==c&&!y&&E(n)}),s("div",{className:"xendit-input-phone",children:[o(Re,{options:fn,selectedIndex:f,onChange:E,fixedOverlayWidth:300,enableSearch:!0,className:"xendit-form-field-inner"}),o("input",{id:i,ref:g,type:"tel",inputMode:"tel",placeholder:x(b.value,w)?.formatInternational()?.replace(`+${k(b.value)} `,"")||"",className:"xendit-text-14 xendit-form-field-inner xendit-phone-number-input",onBlur:function(e){!function(){const e=bn(b,y);if(e){const n=e.formatInternational();_(n.replace(`+${k(b.value)} `,""))}}(),e.currentTarget?.value&&l.current?.dispatchEvent(new InternalSetFieldTouchedEvent)},onChange:function(e){const n=e.target.value;_(n),C(b,n),t()},value:y,autoComplete:"tel"}),o("input",{type:"hidden",name:a,ref:l})]})},fn=en.map(e=>{const n=k(e.value);return n?{...e,shortTitle:`+${n}`,title:`${e.title} (+${n})`,dial:n}:null}).filter(e=>Boolean(e)),bn=(e,n)=>{const t=_(n,e.value);return t&&t.isPossible()?t:null};function yn(e){return{title:e.name,value:e.value}}const _n=[{name:"Alabama",value:"AL"},{name:"Alaska",value:"AK"},{name:"American Samoa",value:"AS"},{name:"Arizona",value:"AZ"},{name:"Arkansas",value:"AR"},{name:"California",value:"CA"},{name:"Colorado",value:"CO"},{name:"Connecticut",value:"CT"},{name:"Delaware",value:"DE"},{name:"District Of Columbia",value:"DC"},{name:"Federated States Of Micronesia",value:"FM"},{name:"Florida",value:"FL"},{name:"Georgia",value:"GA"},{name:"Guam",value:"GU"},{name:"Hawaii",value:"HI"},{name:"Idaho",value:"ID"},{name:"Illinois",value:"IL"},{name:"Indiana",value:"IN"},{name:"Iowa",value:"IA"},{name:"Kansas",value:"KS"},{name:"Kentucky",value:"KY"},{name:"Louisiana",value:"LA"},{name:"Maine",value:"ME"},{name:"Marshall Islands",value:"MH"},{name:"Maryland",value:"MD"},{name:"Massachusetts",value:"MA"},{name:"Michigan",value:"MI"},{name:"Minnesota",value:"MN"},{name:"Mississippi",value:"MS"},{name:"Missouri",value:"MO"},{name:"Montana",value:"MT"},{name:"Nebraska",value:"NE"},{name:"Nevada",value:"NV"},{name:"New Hampshire",value:"NH"},{name:"New Jersey",value:"NJ"},{name:"New Mexico",value:"NM"},{name:"New York",value:"NY"},{name:"North Carolina",value:"NC"},{name:"North Dakota",value:"ND"},{name:"Northern Mariana Islands",value:"MP"},{name:"Ohio",value:"OH"},{name:"Oklahoma",value:"OK"},{name:"Oregon",value:"OR"},{name:"Palau",value:"PW"},{name:"Pennsylvania",value:"PA"},{name:"Puerto Rico",value:"PR"},{name:"Rhode Island",value:"RI"},{name:"South Carolina",value:"SC"},{name:"South Dakota",value:"SD"},{name:"Tennessee",value:"TN"},{name:"Texas",value:"TX"},{name:"Utah",value:"UT"},{name:"Vermont",value:"VT"},{name:"Virgin Islands",value:"VI"},{name:"Virginia",value:"VA"},{name:"Washington",value:"WA"},{name:"West Virginia",value:"WV"},{name:"Wisconsin",value:"WI"},{name:"Wyoming",value:"WY"}].map(yn),gn=[{name:"Alberta",value:"AB"},{name:"British Columbia",value:"BC"},{name:"Manitoba",value:"MB"},{name:"New Brunswick",value:"NB"},{name:"Newfoundland and Labrador",value:"NL"},{name:"Northwest Territories",value:"NT"},{name:"Nova Scotia",value:"NS"},{name:"Nunavut",value:"NU"},{name:"Ontario",value:"ON"},{name:"Prince Edward Island",value:"PE"},{name:"Quebec",value:"QC"},{name:"Saskatchewan",value:"SK"},{name:"Yukon Territory",value:"YT"}].map(yn),xn=[{name:"Avon"},{name:"Bedfordshire"},{name:"Berkshire"},{name:"Buckinghamshire"},{name:"Cambridgeshire"},{name:"Cheshire"},{name:"Cleveland"},{name:"Cornwall"},{name:"Cumbria"},{name:"Derbyshire"},{name:"Devon"},{name:"Dorset"},{name:"Durham"},{name:"East Sussex"},{name:"Essex"},{name:"Gloucestershire"},{name:"Hampshire"},{name:"Herefordshire"},{name:"Hertfordshire"},{name:"Isle of Wight"},{name:"Kent"},{name:"Lancashire"},{name:"Leicestershire"},{name:"Lincolnshire"},{name:"London"},{name:"Merseyside"},{name:"Norfolk"},{name:"Northamptonshire"},{name:"Northumberland"},{name:"North Yorkshire"},{name:"Nottinghamshire"},{name:"Oxfordshire"},{name:"Rutland"},{name:"Shropshire"},{name:"Somerset"},{name:"South Yorkshire"},{name:"Staffordshire"},{name:"Suffolk"},{name:"Surrey"},{name:"Tyne and Wear"},{name:"Warwickshire"},{name:"West Midlands"},{name:"West Sussex"},{name:"West Yorkshire"},{name:"Wiltshire"},{name:"Worcestershire"},{name:"Clwyd"},{name:"Dyfed"},{name:"Gwent"},{name:"Gwynedd"},{name:"Mid Glamorgan"},{name:"Powys"},{name:"South Glamorgan"},{name:"West Glamorgan"},{name:"Aberdeenshire"},{name:"Angus"},{name:"Argyll"},{name:"Ayrshire"},{name:"Banffshire"},{name:"Berwickshire"},{name:"Bute"},{name:"Caithness"},{name:"Clackmannanshire"},{name:"Dumfriesshire"},{name:"Dunbartonshire"},{name:"East Lothian"},{name:"Fife"},{name:"Inverness-shire"},{name:"Kincardineshire"},{name:"Kinross-shire"},{name:"Kirkcudbrightshire"},{name:"Lanarkshire"},{name:"Midlothian"},{name:"Moray"},{name:"Nairnshire"},{name:"Orkney"},{name:"Peeblesshire"},{name:"Perthshire"},{name:"Renfrewshire"},{name:"Ross-shire"},{name:"Roxburghshire"},{name:"Selkirkshire"},{name:"Shetland"},{name:"Stirlingshire"},{name:"Sutherland"},{name:"West Lothian"},{name:"Wigtownshire"},{name:"Antrim"},{name:"Armagh"},{name:"Down"},{name:"Fermanagh"},{name:"Londonderry"},{name:"Tyrone"}].map(e=>({title:e.name,value:e.name})),vn=e=>{const{field:n,onChange:t}=e,i=ce(n),a=le(n),r=K(),c=yt()?.form,p=tt(),m=u(null),f=d(()=>{m.current&&(m.current.value=""),t()},[t]),b=d(e=>{m.current&&(m.current.value=e.value),t(),m.current?.dispatchEvent(new InternalSetFieldTouchedEvent)},[t]),y=d(e=>{m.current&&(m.current.value=e.target.value),t(),m.current?.dispatchEvent(new InternalSetFieldTouchedEvent)},[t]),_=function(e){switch(e){case"US":return _n;case"CA":return gn;case"GB":return xn;default:return null}}(function(e,n,t,i){if(n)for(let i=0;i<n.length;i++){const a=n[i];if(i>0&&a===e){const e=n[i-1];if("country"===e.type.name){const n=ye(e.channel_property,t);if(n&&"string"==typeof n)return n}}}return i.country}(n,c??[],p??{},r)),g=se(_);return h(()=>{g!==_&&f()},[f,_,g]),s(l,{children:[o("input",{type:"hidden",name:a,defaultValue:"",ref:m}),_?o(Re,{id:i,options:_,onChange:b,placeholder:n.placeholder,enableSearch:!0,className:"xendit-form-field-inner"},(x=_,xe.has(x)||xe.set(x,ve++),xe.get(x).toString())):o("input",{type:"text",id:i,onChange:y,placeholder:n.placeholder,className:"xendit-form-field-inner xendit-text-14"})]});var x};const kn=e=>{const{field:n,onChange:t}=e,i=ce(n),a=le(n),r=u(null);return o("input",{id:i,name:a,ref:r,type:"text",placeholder:n.placeholder,className:"xendit-form-field-inner xendit-text-14",onBlur:function(e){e.currentTarget?.value&&r.current?.dispatchEvent(new InternalSetFieldTouchedEvent)},onChange:function(e){t()},minLength:wn(n)?n.type.min_length:void 0,maxLength:wn(n)?n.type.max_length:void 0,autoComplete:wn(n)?n.type.autocomplete:void 0})};function wn(e){return"text"===e.type.name}const Cn={IDR:"id",VND:"vi",BRL:"pt-BR",RUB:"ru",CZK:"cs",RON:"ro",UAH:"uk",CLP:"es-CL",COP:"es-CO",UYU:"es-UY",ARS:"es-AR",INR:"hi-IN",NPR:"hi-IN",LKR:"hi-IN",BDT:"hi-IN"},En={USD:"US$",CAD:"CA$",EUR:"€",AFN:"؋",ALL:"Lek",AMD:"֏",ARS:"AR$",AUD:"AU$",AZN:"₼",BAM:"KM",BDT:"৳",BIF:"FBu",BND:"BN$",BOB:"Bs",BRL:"R$",BWP:"P",BYN:"Br",BZD:"BZ$",CDF:"FrCD",CHF:"CHF",CLP:"CL$",CNY:"CN¥",COP:"CO$",CRC:"₡",CVE:"CV$",CZK:"Kč",DJF:"Fdj",DKK:"kr",DOP:"RD$",ERN:"Nfk",ETB:"Br",GBP:"£",GEL:"₾",GHS:"GH₵",GNF:"FG",GTQ:"Q",HKD:"HK$",HNL:"L",HUF:"Ft",IDR:"Rp",ILS:"₪",INR:"₹",IRR:"IRR",ISK:"kr",JMD:"J$",JPY:"¥",KES:"Ksh",KHR:"៛",KMF:"FC",KRW:"₩",KZT:"₸",LKR:"SL Re",MDL:"lei",MGA:"MGA",MKD:"MKD",MMK:"K",MOP:"MOP$",MUR:"₨",MXN:"MX$",MYR:"RM",MZN:"MTn",NAD:"N$",NGN:"₦",NIO:"C$",NOK:"kr",NPR:"रु",NZD:"NZ$",PAB:"B/.",PEN:"S/.",PHP:"₱",PKR:"₨",PLN:"zł",PYG:"₲",RON:"RON",RSD:"RSD",RUB:"₽",RWF:"FR",SDG:"SDG",SEK:"kr",SGD:"S$",SOS:"Ssh",THB:"฿",TOP:"T$",TRY:"TL",TTD:"TT$",TWD:"NT$",TZS:"TSh",UAH:"₴",UGX:"USh",UYU:"$U",UZS:"сум",VND:"₫",XAF:"FCFA",XOF:"CFA",ZAR:"R",ZMW:"K",ZWL:"ZWL$"},An={ALL:"1 $",BAM:"1 $",BYN:"1 $",CZK:"1 $",DKK:"1 $",GEL:"1 $",HUF:"1 $",ISK:"1 $",IRR:"1 $",KHR:"1$",MDL:"1 $",MKD:"1 $",NOK:"1 $",PLN:"1 $",RON:"1 $",RSD:"1 $",RUB:"1$",SEK:"1 $",UZS:"1 $",VND:"1$"},Nn={BHD:3,JOD:3,KWD:3,LYD:3,OMR:3,TND:3};function Pn(e,n){let t="";const i=e<0,a=Cn[n]??"en",r=Nn[n]??2;if(t=new Intl.NumberFormat(a,{style:"decimal",minimumFractionDigits:r,maximumFractionDigits:20}).format(Math.abs(e)),t=t.replace(/(\.|,)000?$/,""),En[n]){const e=En[n]??n;t=(An[n]??"$1").replace("$",e).replace("1",t)}else t=n+" "+t;return i&&(t="-"+t),t}const Sn=e=>{const{field:n,onChange:t}=e,{t:i}=$(),a=K(),r=ce(n),c=le(n),f=u(null),b=yt();X(b);const y=m(()=>Ae(b.form,"credit_card_number"),[b.form]),_=gt()?.paymentOptions,g=_?.options?.installment_plans,[x,v]=p(null),k=m(()=>{const e=g?.map(e=>({title:i("installment_plan.pay_in_installments",{installments:e.terms,amount:Pn(e.installment_amount,a.currency)}),subtitle:e.interest_rate,value:In(e)}))??[];return y&&e.unshift({title:i("installment_plan.pay_in_full",{amount:Pn(a.amount,a.currency)}),value:""}),e},[y,g,a.amount,a.currency,i]);let w=k?.findIndex(e=>e.value===x);-1===w&&(w=0);const C=d(()=>{v(null),f.current&&(f.current.value="")},[]),E=d(e=>{if(f.current){const n=g?.find(n=>In(n)===e.value);n?n.code?f.current.value=JSON.stringify([n.terms,n.interval,n.code]):f.current.value=JSON.stringify([n.terms,n.interval]):f.current.value="",f.current?.dispatchEvent(new InternalSetFieldTouchedEvent)}v(e.value),t()},[g,t]);h(()=>{k.length&&E(k[0])},[]);const A=se(k);return h(()=>{k===A||g?.some(e=>In(e)===x)||(k.length?E(k[0]):C())},[C,k,E,g,A,x]),s(l,{children:[_?o(Re,{id:r,placeholder:n.placeholder,onChange:E,options:k,selectedIndex:w,className:"xendit-form-field-inner"}):o(Te,{id:r,className:"xendit-form-field-inner"}),o("input",{type:"hidden",name:c,ref:f})]})};function In(e){return`${e.terms}_${e.interval}_${e.code??""}`}const Rn=e=>{const{field:n,className:t}=e;return o("div",{className:`${t} xendit-channel-form-field xendit-form-field-span-${n.span}`,children:function(){switch(n.type.name){case"credit_card_number":case"credit_card_expiry":case"credit_card_cvn":return o(hn,{...e});case"phone_number":return o(mn,{...e});case"text":case"email":case"postal_code":return o(kn,{...e});case"dropdown":return o(tn,{...e});case"installment_plan":return o(Sn,{...e});case"country":return o(Je,{...e});case"province":return o(vn,{...e})}throw n.type,new Error(`Unsupported field type: ${n.type.name}`)}()})};const Tn={en:{session:{"validation.card_cvn_invalid":"CVN is not valid","validation.card_expiry_invalid":"Card expiry is not valid","validation.card_number_incomplete":"Card number is incomplete","validation.card_number_invalid":"Card number is not valid","validation.generic_invalid":"{{field}} is not valid","validation.required":"{{field}} is required","validation.text_too_long":"{{field}} is too long","validation.text_too_short":"{{field}} is too short","payment.save_checkbox_label":"Save for faster payment next time","payment_methods.add_payment_method":"Add payment method","payment_methods.channel_disabled_amount_too_large":"Not available for this payment","payment_methods.channel_disabled_amount_too_small":"Not available for this payment","payment_methods.pay_with":"Pay with","payment_methods.select_channel_placeholder":"Select {{groupName}}","default_error.message_1":"There was a problem with the request.","default_error.message_2":"Please try again later.","default_error.title":"Error","combobox.default_search_placeholder":"Search...","installment_plan.pay_in_full":"Pay in Full — {{amount}}","installment_plan.pay_in_installments":"{{installments}}x Installments — {{amount}}","google_pay_errors.developer_error.title":"Google Pay Error","google_pay_errors.developer_error.message":"Something went wrong with Google Pay. Please try again or use a different payment method.","google_pay_errors.buyer_account_error.title":"Google Pay Error","google_pay_errors.buyer_account_error.message":"Your Google account is unable to make this payment. Use a different Google account or a different payment method.","google_pay_errors.merchant_account_error.title":"Google Pay Error","google_pay_errors.merchant_account_error.message":"Something went wrong with Google Pay. Please try again or use a different payment method.","google_pay_errors.internal_error.title":"Google Pay Error","google_pay_errors.internal_error.message":"Something went wrong with Google Pay. Please try again or use a different payment method.","google_pay_errors.unknown_error.title":"Google Pay Error","google_pay_errors.unknown_error.message":"An unknown error occurred with Google Pay. The error code is {{statusCode}}.","failure_code.account_access_blocked":"Your payment was declined. Please try again or use a different payment method.","failure_code.account_already_linked":"Your account has already been linked. Please use a different payment method.","failure_code.account_not_activated":"Your payment couldn’t be processed because your account hasn’t been activated. Please activate your account and try again.","failure_code.authentication_failed":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.capture_amount_exceeded":"Your payment couldn't be processed. Please make sure your payment details are correct and try again, or use a different payment method.","failure_code.card_declined":"Your card was declined. Please try again with another card or payment method.","failure_code.channel_unavailable":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.declined_by_issuer":"Your payment was declined. Please try again or use a different payment method.","failure_code.declined_by_processor":"Your payment was declined. Please try again or use a different payment method.","failure_code.expired_card":"Your card was declined because it is expired. Please try again or use a different payment method.","failure_code.expired_otp":"Your payment couldn’t be processed because your verification code is invalid. Please try again or use a different payment method.","failure_code.failure_details_unavailable":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.inactive_or_unauthorized_card":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.insufficient_balance":"Your payment couldn’t be processed because your account balance is insufficient. Please make sure you have enough funds and try again.","failure_code.invalid_account_details":"Your payment information is incorrect. Please double-check your card details or try a different payment method.","failure_code.invalid_cvv":"The CVN entered was incorrect. Please try again.","failure_code.invalid_merchant_settings":"Your payment couldn’t be processed. Please contact the seller or try a different payment method.","failure_code.invalid_otp":"Your payment couldn’t be processed because your verification code is invalid. Please try again or use a different payment method.","failure_code.invalid_token":"Your payment couldn’t be processed because your verification code is invalid. Please try again or use a different payment method.","failure_code.issuer_unavailable":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.otp_attempt_counts_exceeded":"Your payment couldn’t be processed because there were too many failed OTP attempts. Please make the payment again or use a different payment method.","failure_code.partner_timeout_error":"Your payment couldn't be processed. Please try again or use a different payment method.","failure_code.payment_amount_limits_exceeded":"Your payment couldn’t be processed because you’ve exceeded your transaction limit. Please use a different payment method.","failure_code.payment_attempt_counts_exceeded":"Your payment couldn’t be processed due to too many failed attempts.","failure_code.payment_request_expired":"Your payment couldn’t be processed because the link has expired. Please try again or use a different payment method.","failure_code.processor_error":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.server_error":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.stolen_card":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.suspected_fraudulent":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.timeout_error":"Your payment couldn’t be processed. Please try again or use a different payment method.","failure_code.user_declined_payment":"Your payment was declined. Please try again or use a different payment method.","failure_code.user_device_unreachable":"Your payment couldn’t be processed due to a network issue. Please try again or use a different payment method.","failure_code.user_did_not_authorize":"Your payment couldn’t be processed because it wasn’t authorized in time. Please try again.",failure_code_unknown:"A failure occurred with code {{failureCode}}","payment_request_status.canceled.subtext":"Please try to check out again or contact the seller if the problem persists.","payment_request_status.canceled.title":"This page is no longer available","payment_request_status.expired.subtext":"Your payment couldn’t be processed. Please try again or use a different payment method.","payment_request_status.expired.title":"Payment unsuccessful","payment_request_status.failed.subtext":"Your payment couldn't be processed. Please try a different payment method or submit an inquiry to the seller by sharing your Unique Identifiers.","payment_request_status.failed.title":"Payment failed","payment_token_status.canceled.subtext":"Please try again or use a different payment method.","payment_token_status.canceled.title":"Payment method couldn't be added","payment_token_status.expired.subtext":"Please try again or use a different payment method.","payment_token_status.expired.title":"Payment method couldn't be added","payment_token_status.failed.subtext":"Your payment couldn't be processed. Please try a different payment method or submit an inquiry to the seller by sharing your Unique Identifiers.","payment_token_status.failed.title":"Payment method couldn't be added","action.payment_confirmation_instructions":"Once you've paid, click the button above to get your payment confirmation.","action.payment_made":"I've made this payment","action_va.merchant_name":"Virtual Account Name","action_va.amount_to_pay":"Amount to Pay","action_va.virtual_account_number":"Virtual Account Number","action_va.copy":"Copy","action_va.copied_to_clipboard":"Copied to clipboard","action_qr.unable_to_generate":"Unable to generate QR code","action_deeplink.button":"Open App","action_deeplink.instructions":"Please complete your payment on your {{channelName}} app.","action_deeplink.title":"Awaiting payment...","action_empty_list_push_notification.subtext":"Check the notification in your {{channelName}} app to complete your payment.","action_empty_list_push_notification.title":"Awaiting payment...","image_alt.channel_logo":"{{channelName}} logo","simulation.simulate_scenario":"Simulate scenario","simulation.simulate_test_scenario":"Simulate a test scenario","simulation.select_scenario":"Select a scenario","simulation.want_to_test_all_scenarios":"Want to test different scenarios?","simulation.see_all_scenarios":"See the full list here."}}.session,id:{session:{"validation.card_cvn_invalid":"CVN tidak valid","validation.card_expiry_invalid":"Tanggal kedaluwarsa kartu tidak valid","validation.card_number_incomplete":"Nomor kartu tidak lengkap","validation.card_number_invalid":"Nomor kartu tidak valid","validation.generic_invalid":"{{field}} tidak valid","validation.required":"{{field}} wajib diisi","validation.text_too_long":"{{field}} terlalu panjang","validation.text_too_short":"{{field}} terlalu pendek","payment.save_checkbox_label":"Simpan untuk pembayaran lebih cepat lain kali","payment_methods.add_payment_method":"Tambah metode pembayaran","payment_methods.channel_disabled_amount_too_large":"Tidak tersedia untuk pembayaran ini","payment_methods.channel_disabled_amount_too_small":"Tidak tersedia untuk pembayaran ini","payment_methods.pay_with":"Bayar dengan","payment_methods.select_channel_placeholder":"Pilih {{groupName}}","default_error.message_1":"Ada masalah dengan permintaan ini.","default_error.message_2":"Silakan coba lagi nanti.","default_error.title":"Error","failure_code.account_access_blocked":"Pembayaran Anda ditolak. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.account_already_linked":"Akun Anda sudah di-link. Silakan gunakan metode pembayaran lain.","failure_code.account_not_activated":"Pembayaran Anda tidak dapat diproses karena akun Anda belum diaktifkan. Harap aktifkan akun Anda dan coba lagi.","failure_code.authentication_failed":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.capture_amount_exceeded":"Pembayaran Anda tidak dapat diproses. Pastikan detail pembayaran Anda benar dan coba lagi, atau gunakan metode pembayaran lain.","failure_code.card_declined":"Kartu Anda ditolak. Silakan coba lagi dengan kartu atau metode pembayaran lain.","failure_code.channel_unavailable":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.declined_by_issuer":"Pembayaran Anda ditolak. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.declined_by_processor":"Pembayaran Anda ditolak. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.expired_card":"Kartu Anda ditolak karena sudah kedaluwarsa. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.expired_otp":"Pembayaran Anda tidak dapat diproses karena kode verifikasi tidak valid. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.failure_details_unavailable":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.inactive_or_unauthorized_card":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.insufficient_balance":"Pembayaran Anda tidak dapat diproses karena saldo akun Anda tidak mencukupi. Pastikan Anda memiliki dana yang cukup dan coba lagi.","failure_code.invalid_account_details":"Informasi pembayaran Anda salah. Harap periksa kembali detail kartu Anda atau coba gunakan metode pembayaran lain.","failure_code.invalid_cvv":"CVN yang dimasukkan salah. Silakan coba lagi.","failure_code.invalid_merchant_settings":"Pembayaran Anda tidak dapat diproses. Silakan hubungi penjual atau coba metode pembayaran lain.","failure_code.invalid_otp":"Pembayaran Anda tidak dapat diproses karena kode verifikasi tidak valid. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.invalid_token":"Pembayaran Anda tidak dapat diproses karena kode verifikasi tidak valid. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.issuer_unavailable":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.otp_attempt_counts_exceeded":"Pembayaran Anda tidak dapat diproses karena terlalu banyak percobaan OTP yang gagal. Harap lakukan pembayaran lagi atau gunakan metode pembayaran lain.","failure_code.partner_timeout_error":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.payment_amount_limits_exceeded":"Pembayaran Anda tidak dapat diproses karena Anda telah melampaui batas transaksi. Silakan gunakan metode pembayaran lain.","failure_code.payment_attempt_counts_exceeded":"Pembayaran Anda tidak dapat diproses karena terlalu banyak percobaan yang gagal.","failure_code.payment_request_expired":"Pembayaran Anda tidak dapat diproses karena link telah kedaluwarsa. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.processor_error":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.server_error":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.stolen_card":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.suspected_fraudulent":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.timeout_error":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.user_declined_payment":"Pembayaran Anda ditolak. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.user_device_unreachable":"Pembayaran Anda tidak dapat diproses karena masalah jaringan. Silakan coba lagi atau gunakan metode pembayaran lain.","failure_code.user_did_not_authorize":"Pembayaran Anda tidak dapat diproses karena waktu pembayaran telah habis. Silakan coba lagi.",failure_code_unknown:"Terjadi kegagalan dengan kode {{failureCode}}","payment_request_status.canceled.subtext":"Silakan coba check out lagi atau hubungi penjual jika masalah terus berlanjut.","payment_request_status.canceled.title":"Halaman ini tidak tersedia lagi","payment_request_status.expired.subtext":"Pembayaran Anda tidak dapat diproses. Silakan coba lagi atau gunakan metode pembayaran lain.","payment_request_status.expired.title":"Pembayaran tidak berhasil","payment_request_status.failed.subtext":"Pembayaran Anda tidak dapat diproses. Silakan coba metode pembayaran lain atau ajukan pertanyaan kepada penjual dengan membagikan ID Unik Anda.","payment_request_status.failed.title":"Pembayaran gagal","payment_token_status.canceled.subtext":"Silakan coba lagi atau gunakan metode pembayaran lain.","payment_token_status.canceled.title":"Metode pembayaran tidak dapat ditambahkan","payment_token_status.expired.subtext":"Silakan coba lagi atau gunakan metode pembayaran lain.","payment_token_status.expired.title":"Metode pembayaran tidak dapat ditambahkan","payment_token_status.failed.subtext":"Pembayaran Anda tidak dapat diproses. Silakan coba metode pembayaran lain atau ajukan pertanyaan kepada penjual dengan membagikan ID Unik Anda.","payment_token_status.failed.title":"Metode pembayaran tidak dapat ditambahkan","action.payment_confirmation_instructions":"Setelah Anda bayar, klik tombol di atas untuk mendapatkan konfirmasi pembayaran Anda.","action.payment_made":"Saya telah melakukan pembayaran ini","action_va.amount_to_pay":"Jumlah Pembayaran","action_va.virtual_account_number":"Nomor Virtual Account","action_qr.unable_to_generate":"Tidak dapat membuat kode QR"}}.session,th:{session:{"validation.card_cvn_invalid":"CVN ไม่ถูกต้อง","validation.card_expiry_invalid":"วันหมดอายุของบัตรไม่ถูกต้อง","validation.card_number_incomplete":"หมายเลขบัตรไม่ครบถ้วน","validation.card_number_invalid":"หมายเลขบัตรไม่ถูกต้อง","validation.generic_invalid":"{{field}} ไม่ถูกต้อง","validation.required":"กรุณากรอก {{field}}","validation.text_too_long":"{{field}} ยาวเกินไป","validation.text_too_short":"{{field}} สั้นเกินไป","payment.save_checkbox_label":"บันทึกไว้สำหรับการชำระเงินที่เร็วขึ้นในครั้งถัดไป","payment_methods.add_payment_method":"เพิ่มวิธีการชำระเงิน","payment_methods.channel_disabled_amount_too_large":"ไม่สามารถใช้ได้กับการชำระเงินนี้","payment_methods.channel_disabled_amount_too_small":"ไม่สามารถใช้ได้กับการชำระเงินนี้","payment_methods.pay_with":"ชำระเงินด้วย","payment_methods.select_channel_placeholder":"เลือก {{groupName}}","default_error.message_1":"มีปัญหาในการประมวลผลคำขอ","default_error.message_2":"โปรดลองอีกครั้งในภายหลัง","default_error.title":"ข้อผิดพลาด","failure_code.account_access_blocked":"การชำระเงินของคุณถูกปฏิเสธ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.account_already_linked":"บัญชีนี้มีการเชื่อมต่อไว้แล้ว กรุณาเลือกวิธีการชำระเงินอื่น","failure_code.account_not_activated":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากบัญชีของคุณยังไม่ได้เปิดใช้งาน กรุณาเปิดใช้งานบัญชีและลองใหม่อีกครั้ง","failure_code.authentication_failed":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.capture_amount_exceeded":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาตรวจสอบรายละเอียดการชำระเงินให้ถูกต้องแล้วลองใหม่อีกครั้ง หรือใช้วิธีการชำระเงินอื่น","failure_code.card_declined":"บัตรของคุณถูกปฏิเสธ กรุณาลองใหม่ด้วยบัตรหรือวิธีการชำระเงินอื่น","failure_code.channel_unavailable":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.declined_by_issuer":"การชำระเงินของคุณถูกปฏิเสธ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.declined_by_processor":"การชำระเงินของคุณถูกปฏิเสธ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.expired_card":"บัตรของคุณถูกปฏิเสธเนื่องจากบัตรหมดอายุ กรุณาลองใหม่อีกครั้งหรือใช้วิธีการชําระเงินอื่น","failure_code.expired_otp":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากรหัสยืนยันของคุณไม่ถูกต้อง กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.failure_details_unavailable":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.inactive_or_unauthorized_card":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.insufficient_balance":"ไม่สามารถดำเนินการชำระเงินได้ เนื่องจากยอดเงินในบัญชีไม่เพียงพอ กรุณาตรวจสอบให้แน่ใจว่ามียอดเงินเพียงพอแล้วลองใหม่อีกครั้ง","failure_code.invalid_account_details":"ข้อมูลการชำระเงินไม่ถูกต้อง กรุณาตรวจสอบรายละเอียดบัตรอีกครั้ง หรือใช้วิธีการชำระเงินอื่น","failure_code.invalid_cvv":"CVN ที่กรอกไม่ถูกต้อง กรุณาลองใหม่อีกครั้ง","failure_code.invalid_merchant_settings":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาติดต่อผู้ขายหรือลองใช้วิธีชำระเงินอื่น","failure_code.invalid_otp":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากรหัสยืนยันของคุณไม่ถูกต้อง กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.invalid_token":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากรหัสยืนยันของคุณไม่ถูกต้อง กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.issuer_unavailable":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.otp_attempt_counts_exceeded":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากมีการกรอกรหัส OTP ผิดพลาดมากเกินไป กรุณาชำระเงินใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.partner_timeout_error":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.payment_amount_limits_exceeded":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากคุณทำธุรกรรมเกินขีดจำกัด กรุณาใช้วิธีชำระเงินอื่น","failure_code.payment_attempt_counts_exceeded":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากพยายามล้มเหลวหลายครั้งเกินไป","failure_code.payment_request_expired":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากลิงก์หมดอายุแล้ว กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.processor_error":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.server_error":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.stolen_card":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.suspected_fraudulent":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือเลือกวิธีการชำระเงินอื่น","failure_code.timeout_error":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.user_declined_payment":"การชำระเงินของคุณถูกปฏิเสธ กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.user_device_unreachable":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากปัญหาเครือข่าย กรุณาลองใหม่อีกครั้งหรือใช้วิธีชำระเงินอื่น","failure_code.user_did_not_authorize":"ไม่สามารถดำเนินการชำระเงินได้เนื่องจากไม่ได้รับการอนุมัติภายในเวลาที่กำหนด กรุณาลองใหม่อีกครั้ง",failure_code_unknown:"เกิดข้อผิดพลาดขึ้น (รหัส: {{failureCode}})","payment_request_status.canceled.subtext":"กรุณาลองชำระเงินอีกครั้ง หรือ ติดต่อผู้ขายหากปัญหายังคงเกิดขึ้น","payment_request_status.canceled.title":"หน้านี้ไม่สามารถใช้งานได้แล้ว","payment_request_status.expired.subtext":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใหม่อีกครั้งหรือลองใช้วิธีชำระเงินอื่น","payment_request_status.expired.title":"ชำระเงินไม่สำเร็จ","payment_request_status.failed.subtext":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใช้วิธีการชำระเงินอื่น หรือส่งคำถามไปยังผู้ขายโดยแชร์ Unique Identifiers ของคุณ","payment_request_status.failed.title":"ชำระเงินไม่สำเร็จ","payment_token_status.canceled.subtext":"กรุณาลองใหม่อีกครั้งหรือใช้วิธีการชําระเงินอื่น","payment_token_status.canceled.title":"ไม่สามารถเพิ่มวิธีการชําระเงินได้","payment_token_status.expired.subtext":"กรุณาลองใหม่อีกครั้งหรือใช้วิธีการชําระเงินอื่น","payment_token_status.expired.title":"ไม่สามารถเพิ่มวิธีการชําระเงินได้","payment_token_status.failed.subtext":"ไม่สามารถดำเนินการชำระเงินได้ กรุณาลองใช้วิธีการชำระเงินอื่น หรือส่งคำถามไปยังผู้ขายโดยแชร์ Unique Identifiers ของคุณ","payment_token_status.failed.title":"ไม่สามารถเพิ่มวิธีการชําระเงินได้","action.payment_confirmation_instructions":"เมื่อคุณชำระเงินแล้ว คลิกที่ปุ่มด้านบนเพื่อยืนยันการชำระเงิน","action.payment_made":"ฉันได้ชำระเงินแล้ว","action_va.amount_to_pay":"ยอดชำระ","action_va.virtual_account_number":"หมายเลข Virtual Account","action_qr.unable_to_generate":"ไม่สามารถสร้างคิวอาร์โค้ดได้"}}.session,vi:{session:{"validation.card_cvn_invalid":"CVN không hợp lệ","validation.card_expiry_invalid":"Ngày hết hạn thẻ không hợp lệ","validation.card_number_incomplete":"Số thẻ chưa đầy đủ","validation.card_number_invalid":"Số thẻ không hợp lệ","validation.generic_invalid":"{{field}} không hợp lệ","validation.required":"Vui lòng nhập {{field}}","validation.text_too_long":"{{field}} quá dài","validation.text_too_short":"{{field}} quá ngắn","payment.save_checkbox_label":"Lưu để thanh toán nhanh hơn lần sau","payment_methods.add_payment_method":"Thêm phương thức thanh toán","payment_methods.channel_disabled_amount_too_large":"Không khả dụng cho khoản thanh toán này","payment_methods.channel_disabled_amount_too_small":"Không khả dụng cho khoản thanh toán này","payment_methods.pay_with":"Thanh toán bằng","payment_methods.select_channel_placeholder":"Chọn {{groupName}}","default_error.message_1":"Có vấn đề với yêu cầu.","default_error.message_2":"Vui lòng thử lại sau.","default_error.title":"Lỗi","failure_code.account_access_blocked":"Thanh toán của bạn bị từ chối. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.account_already_linked":"Tài khoản của bạn đã được liên kết. Vui lòng dùng phương thức khác.","failure_code.account_not_activated":"Không thể thực hiện thanh toán vì tài khoản chưa được kích hoạt. Vui lòng kích hoạt và thử lại.","failure_code.authentication_failed":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.capture_amount_exceeded":"Không thể thực hiện thanh toán. Vui lòng kiểm tra thông tin thanh toán và thử lại, hoặc dùng phương thức khác.","failure_code.card_declined":"Thẻ của bạn đã bị từ chối. Vui lòng thử lại bằng thẻ khác hoặc phương thức khác.","failure_code.channel_unavailable":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.declined_by_issuer":"Thanh toán của bạn bị từ chối. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.declined_by_processor":"Thanh toán của bạn bị từ chối. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.expired_card":"Thẻ của bạn bị từ chối do đã hết hạn. Vui lòng thử lại hoặc sử dụng phương thức thanh toán khác.","failure_code.expired_otp":"Không thể thực hiện thanh toán vì mã xác minh không hợp lệ. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.failure_details_unavailable":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.inactive_or_unauthorized_card":"Không thể xử lý thanh toán của bạn. Vui lòng thử lại hoặc sử dụng phương thức thanh toán khác.","failure_code.insufficient_balance":"Không thể thực hiện thanh toán vì số dư tài khoản không đủ. Vui lòng nạp thêm tiền và thử lại.","failure_code.invalid_account_details":"Thông tin thanh toán không chính xác. Vui lòng kiểm tra lại hoặc dùng phương thức khác.","failure_code.invalid_cvv":"Mã CVN nhập không đúng. Vui lòng thử lại.","failure_code.invalid_merchant_settings":"Không thể thực hiện thanh toán. Vui lòng liên hệ người bán hoặc dùng phương thức khác.","failure_code.invalid_otp":"Không thể thực hiện thanh toán vì mã xác minh không hợp lệ. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.invalid_token":"Không thể thực hiện thanh toán vì mã xác minh không hợp lệ. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.issuer_unavailable":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.otp_attempt_counts_exceeded":"Không thể thực hiện thanh toán vì đã nhập sai OTP quá nhiều lần. Vui lòng thanh toán lại hoặc dùng phương thức khác.","failure_code.partner_timeout_error":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.payment_amount_limits_exceeded":"Không thể thực hiện thanh toán vì bạn đã vượt quá hạn mức giao dịch. Vui lòng dùng phương thức khác.","failure_code.payment_attempt_counts_exceeded":"Không thể thực hiện thanh toán do quá nhiều lần thử thất bại.","failure_code.payment_request_expired":"Không thể thực hiện thanh toán vì liên kết đã hết hạn. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.processor_error":"Không thể xử lý thanh toán của bạn. Vui lòng thử lại hoặc sử dụng phương thức thanh toán khác.","failure_code.server_error":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.stolen_card":"Không thể xử lý thanh toán của bạn. Vui lòng thử lại hoặc sử dụng phương thức thanh toán khác.","failure_code.suspected_fraudulent":"Không thể xử lý thanh toán của bạn. Vui lòng thử lại hoặc sử dụng phương thức thanh toán khác.","failure_code.timeout_error":"Không thể thực hiện thanh toán. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.user_declined_payment":"Thanh toán của bạn bị từ chối. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.user_device_unreachable":"Không thể thực hiện thanh toán do sự cố mạng. Vui lòng thử lại hoặc dùng phương thức khác.","failure_code.user_did_not_authorize":"Không thể thực hiện thanh toán vì không được xác nhận kịp thời. Vui lòng thử lại.",failure_code_unknown:"Có lỗi xảy ra với mã {{failureCode}}","payment_request_status.canceled.subtext":"Vui lòng thử thanh toán lại hoặc liên hệ người bán nếu vấn đề vẫn tiếp diễn.","payment_request_status.canceled.title":"Trang này không còn khả dụng","payment_request_status.expired.subtext":"Thanh toán của bạn không thể xử lý. Vui lòng thử lại hoặc chọn phương thức khác.","payment_request_status.expired.title":"Thanh toán không thành công","payment_request_status.failed.subtext":"Không thể thực hiện thanh toán. Vui lòng thử phương thức khác hoặc gửi yêu cầu đến người bán bằng cách chia sẻ Mã định danh duy nhất.","payment_request_status.failed.title":"Thanh toán thất bại","payment_token_status.canceled.subtext":"Vui lòng thử lại hoặc dùng phương thức khác.","payment_token_status.canceled.title":"Không thể thêm phương thức thanh toán","payment_token_status.expired.subtext":"Vui lòng thử lại hoặc dùng phương thức khác.","payment_token_status.expired.title":"Không thể thêm phương thức thanh toán","payment_token_status.failed.subtext":"Không thể thực hiện thanh toán. Vui lòng thử phương thức khác hoặc gửi yêu cầu đến người bán bằng cách chia sẻ Mã định danh duy nhất.","payment_token_status.failed.title":"Không thể thêm phương thức thanh toán","action.payment_confirmation_instructions":"Sau khi bạn đã thanh toán, hãy nhấp nút phía trên để nhận xác nhận thanh toán.","action.payment_made":"Tôi đã thực hiện thanh toán này","action_va.amount_to_pay":"Số tiền cần thanh toán","action_va.virtual_account_number":"Số tài khoản định danh (Virtual Account)","action_qr.unable_to_generate":"Không thể tạo mã QR"}}.session};const Dn=(e,n,t)=>n?(e=>"object"==typeof e&&null!==e&&"localeKey"in e)(n)?e(n.localeKey,{field:t.label}):n.value:null;function Mn(e){return e.startsWith("/")&&e.endsWith("/")?e.slice(1,-1):e}function Ln(e,n){if(0===n.length)return e.required?{localeKey:"validation.required"}:void 0;switch(e.type.name){case"credit_card_number":case"credit_card_expiry":case"credit_card_cvn":return function(e){const n=ge(e);if(!n.valid){if(n.validationError)return{localeKey:n.validationError};throw new Error("Unexpected value in encrypted field, this is a bug, please contact support.")}}(n);case"phone_number":return(e=>{const n=v(e);if(!n||!n.isValid())return{localeKey:"validation.generic_invalid"}})(n);case"email":return(e=>{if(!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[A-Za-z]{2,}$/.test(e))return{localeKey:"validation.generic_invalid"}})(n);case"postal_code":return(e=>{if(!/^(?![-\s]+)[A-Za-z0-9\s-]+$/.test(e))return{localeKey:"validation.generic_invalid"}})(n);case"text":return((e,n)=>{if(Array.isArray(e.type.regex_validators))for(const t of e.type.regex_validators)if(!new RegExp(Mn(t.regex)).test(n))return{value:t.message};return void 0!==e.type.min_length&&n.length<e.type.min_length?{localeKey:"validation.text_too_short"}:n.length>e.type.max_length?{localeKey:"validation.text_too_long"}:void 0})(e,n);case"country":case"province":case"installment_plan":case"dropdown":return;default:throw e.type,new Error(`Unsupported input type: ${e.type.name}; this is a bug, please contact support.`)}}function Un(e,n){const t=Array.isArray(e.channel_property)?e.channel_property:[e.channel_property];for(const i of t){let t=On(n,i);if(void 0===t&&(t=""),"string"!=typeof t)continue;const a=Ln(e,t);if(a)return a}}function On(e,n){const t=n.split("."),i=e[t[0]];if(void 0!==i){if("object"!=typeof i||Array.isArray(i)){if(1!==t.length)throw new Error(`Attempted to read channel property "${n}" expecting an object but found a primitive value; this is a bug, please contact support.`);return i}return On(i,t.slice(1).join("."))}}const qn=n(null),Bn=({scenarios:e,onSelect:n,children:t})=>{const[i,a]=p(!1),r=u(null);return h(()=>{if(!i)return;const e=e=>{const n=r.current;n&&(n.contains(e.target)||a(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]),o("div",{ref:r,children:o(qn.Provider,{value:{open:i,setOpen:a,scenarios:e,onSelect:n},children:t})})},Vn=({children:e})=>o("div",{className:"xendit-form-simulation-root",children:e}),Kn=({children:e})=>{const{open:n,setOpen:t}=c(qn)||{};return o("button",{type:"button",className:"xendit-form-simulation-trigger",onClick:()=>t?.(!n),children:e})},Wn=()=>{const e=c(qn);X(e);const{open:n,setOpen:t,scenarios:i,onSelect:a}=e,{t:r}=$();return n&&i?s("div",{className:"xendit-form-simulation-popover",children:[o("div",{className:"xendit-text-12 xendit-text-semibold",children:r("simulation.simulate_test_scenario")}),o(Re,{onChange:e=>{a?.(e.value),t?.(!1)},placeholder:r("simulation.select_scenario"),options:i.scenarios.map(e=>({title:e.description,value:e.name,leadingAsset:o("img",{src:e.imageUrl,className:"xendit-channel-logo"})}))}),i?.docsLink?s("div",{className:"xendit-text-14",children:[r("simulation.want_to_test_all_scenarios")," ",o("a",{href:i.docsLink,target:"_blank",rel:"noopener noreferrer",className:"xendit-text-link",children:r("simulation.see_all_scenarios")})]}):null]}):null},Fn="field-radius-bl-0",$n="field-radius-br-0",Gn="field-radius-tl-0",zn="field-radius-tr-0",Hn="field-collapse-r",Xn="field-collapse-l",Yn="field-collapse-t",jn="field-collapse-b",Qn=({fieldGroup:e,groupIndex:n,handleFieldChanged:t,channelProperties:i,simulationScenarios:a})=>{const{t:r}=$(),l=u(null),[d,c]=p({}),m=e.map(e=>e.span),f=Math.ceil(e.reduce((e,n)=>e+n.span,0)/2);h(()=>{const e=l.current;if(e)return e.addEventListener(InternalSetFieldTouchedEvent.type,n),()=>{e.removeEventListener(InternalSetFieldTouchedEvent.type,n)};function n(e){const n=e.target.name;c(e=>({...e,[n]:!0}))}},[]);const b=(()=>{for(const n of e){if(!d[le(n)])continue;const e=Un(n,i??{});if(e)return o("span",{className:"xendit-error-message xendit-text-12",children:Dn(r,e,n)})}return null})();return o(ln,{children:s("div",{className:"xendit-channel-form-field-group",children:[s("div",{className:"xendit-channel-form-field-group-label-container",children:[o("label",{htmlFor:ce(e[0]),className:"xendit-text-14",children:e[0].group_label??e[0].label??""}),a?o(Zn,{simulationScenarios:a,fieldGroup:e}):null]}),o("div",{ref:l,className:"xendit-form-field-group "+(b?"invalid":""),children:e.map((e,n)=>{const i=(e=>{const n=m.slice(0,e).reduce((e,n)=>e+n,0),t=0===e?0:Math.floor(n/2);return{fieldPositionBySpan:n,fieldRow:t,fieldColumn:n%2,isLastRow:t===f-1}})(n),a=((e,n,t)=>{const{fieldPositionBySpan:i,fieldRow:a,fieldColumn:r,isLastRow:o}=t;return y({[Fn]:f>a+1||i%2==1,[$n]:!!m[n+1],[Gn]:n>0,[zn]:!(0===a&&1===r||0===a&&0===r&&2===e.span),[Hn]:1===e.span&&0===r,[Xn]:1===e.span&&1===r,[Yn]:i>=2,[jn]:!o})})(e,n,i);return o(Rn,{className:a,field:e,onChange:t},n)})},n),b]})})},Zn=({simulationScenarios:e,fieldGroup:n})=>{const t=c(on),{t:i}=$();return o(Bn,{scenarios:e,onSelect:i=>{const a=e.scenarios.find(e=>e.name===i);if(a?.values)for(const[e,i]of Object.entries(a.values)){const a=n.find(n=>le(n)===e);a&&("credit_card_number"!==a.type.name&&"credit_card_expiry"!==a.type.name&&"credit_card_cvn"!==a.type.name||t?.postMessageToIframe(e,{type:"xendit-iframe-populate-for-simulation",scenario:i}))}},children:s(Vn,{children:[o(Kn,{children:o("div",{className:"xendit-text-12 xendit-text-semibold xendit-text-link",children:i("simulation.simulate_scenario")})}),o(Wn,{})]})})},Jn={scenarios:[{imageUrl:"https://assets.xendit.co/payment-session/logos/VISA.svg",description:"3DS Challenge",name:"3_ds_challenge_authentication_is_successful_if_otp_is_correct_visa",values:{"card_details.card_number":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_visa","card_details.expiry_month__card_details.expiry_year":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_visa","card_details.cvn":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_visa"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/VISA.svg",description:"3DS Frictionless, success",name:"3_ds_frictionless_authentication_is_successful_visa",values:{"card_details.card_number":"3_ds_frictionless_authentication_is_successful_visa","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_is_successful_visa","card_details.cvn":"3_ds_frictionless_authentication_is_successful_visa"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/MASTERCARD.svg",description:"3DS Challenge",name:"3_ds_challenge_authentication_is_successful_if_otp_is_correct_mastercard",values:{"card_details.card_number":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_mastercard","card_details.expiry_month__card_details.expiry_year":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_mastercard","card_details.cvn":"3_ds_challenge_authentication_is_successful_if_otp_is_correct_mastercard"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/MASTERCARD.svg",description:"3DS Frictionless, success",name:"3_ds_frictionless_authentication_is_successful_mastercard",values:{"card_details.card_number":"3_ds_frictionless_authentication_is_successful_mastercard","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_is_successful_mastercard","card_details.cvn":"3_ds_frictionless_authentication_is_successful_mastercard"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/VISA.svg",description:"3DS Frictionless, success",name:"3_ds_frictionless_authentication_is_successful_visa2",values:{"card_details.card_number":"3_ds_frictionless_authentication_is_successful_visa2","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_is_successful_visa2","card_details.cvn":"3_ds_frictionless_authentication_is_successful_visa2"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/MASTERCARD.svg",description:"3DS Frictionless, success",name:"3_ds_frictionless_authentication_is_successful_mastercard2",values:{"card_details.card_number":"3_ds_frictionless_authentication_is_successful_mastercard2","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_is_successful_mastercard2","card_details.cvn":"3_ds_frictionless_authentication_is_successful_mastercard2"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/VISA.svg",description:"Failure",name:"failing_transaction_visa",values:{"card_details.card_number":"failing_transaction_visa","card_details.expiry_month__card_details.expiry_year":"failing_transaction_visa","card_details.cvn":"failing_transaction_visa"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/MASTERCARD.svg",description:"Failure",name:"failing_transaction_mastercard",values:{"card_details.card_number":"failing_transaction_mastercard","card_details.expiry_month__card_details.expiry_year":"failing_transaction_mastercard","card_details.cvn":"failing_transaction_mastercard"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/AMEX.svg",description:"3DS Frictionless, success",name:"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn",values:{"card_details.card_number":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn","card_details.cvn":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/AMEX.svg",description:"3DS Frictionless, success",name:"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn2",values:{"card_details.card_number":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn2","card_details.expiry_month__card_details.expiry_year":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn2","card_details.cvn":"3_ds_frictionless_authentication_successful_use_a_4_digit_cvn2"}},{imageUrl:"https://assets.xendit.co/payment-session/logos/AMEX.svg",description:"3DS Challenge",name:"3_ds_challenge_use_a_4_digit_cvn",values:{"card_details.card_number":"3_ds_challenge_use_a_4_digit_cvn","card_details.expiry_month__card_details.expiry_year":"3_ds_challenge_use_a_4_digit_cvn","card_details.cvn":"3_ds_challenge_use_a_4_digit_cvn"}}],docsLink:"https://docs.xendit.co/docs/cards-simulate-card-scenarios"},et=C(({form:e,onChannelPropertiesChanged:n},t)=>{const i=K(),a=yt(),r=$(),s=gt(),l=u(null),[c,h]=p(null);f(t,()=>({setAllFieldsTouched(){const e=l.current;e&&Array.from(e.elements).filter(e=>e instanceof HTMLInputElement).forEach(e=>{e.name&&e.dispatchEvent(new InternalSetFieldTouchedEvent)})}}));const y=d(()=>{if(!l.current)return{};return function(e){const n={};for(const[t,i]of e){if(i instanceof Blob)continue;const e=t.split("__"),a=it(e,i);e:for(const t of e){const e=t.split(".");let i=n;for(;e.length>1;){const n=e.shift();let t=i[n];if(void 0===t&&(t=i[n]={}),t&&"object"==typeof t){if(Array.isArray(t))continue e;i=t}}const r=a.length?a.shift():"";i[e[0]]=r}}return n}(new FormData(l.current).entries())},[]),_=d(()=>{if(!l.current)return;const e=y();h(e),n(e)},[y,n]),g=function(e,n,t,i){const a=m(()=>at(e.session_type,n,t,i),[i,t,n,e.session_type]);return a}(i,e,c||{},s??null),x=se(g);b(()=>{(function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0})(x||[],g)||_()},[g,_,x]);const v=d(e=>r.supportsSimulationScenarios()&&"CARDS"===a?.channel_code&&e.some(e=>"credit_card_number"===e.type.name)?Jn:null,[a,r]),k=function(e){const n=[[]];for(const t of e)1!==t.span||1!==n[n.length-1].length||1!==n[n.length-1][0].span?t.join?n[n.length-1].push(t):n.push([t]):n[n.length-1].push(t);return n}(g).filter(e=>e.length);return 0===k.length?null:o("div",{class:"xendit-channel-form",children:o("form",{ref:l,children:o(nt.Provider,{value:c,children:k.map((e,n)=>o(Qn,{fieldGroup:e,groupIndex:n,handleFieldChanged:_,channelProperties:c,simulationScenarios:v(e)},n))})})})}),nt=n(null),tt=()=>c(nt);function it(e,n){if(0===e.length)return[];if(1===e.length)return[n];if(""===n)return[];try{return JSON.parse(n)}catch(e){return[n]}}function at(e,n,t,i){const a=Ae(n,"credit_card_number"),r=i?.cardDetails?.details?.require_billing_information,o=!!i?.paymentOptions?.options?.installment_plans?.length;return n.filter(n=>{if(n.flags?.require_billing_information){if("PAY"!==e)return!1;if(!r)return!1}if("installment_plan"===n.type.name&&!o&&a)return!1;for(const e of n.display_if||[]){const[n,i,a]=e,r=On(t,n);switch(i){case"equals":if(r!==a)return!1;break;case"not_equals":if(r===a)return!1}}return!0})}const rt=e=>{const n=u(null),t=u(null),i=void 0!==HTMLElement.prototype.animate;return h(()=>{i&&(n.current?.animate(ot,st),t.current?.animate(lt,dt))},[i]),s("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[s("g",{opacity:"0.5",children:[o("path",{d:"M8.79453 10.2303C7.1791 10.2303 5.86953 11.5399 5.86953 13.1553V28.9503C5.86953 31.535 7.96484 33.6303 10.5495 33.6303H26.3445C27.96 33.6303 29.2695 32.3208 29.2695 30.7053",fill:"#F1F1F1"}),o("path",{d:"M8.79453 10.2303V10.2303C7.1791 10.2303 5.86953 11.5399 5.86953 13.1553V28.9503C5.86953 31.535 7.96484 33.6303 10.5495 33.6303H26.3445C27.96 33.6303 29.2695 32.3208 29.2695 30.7053V30.7053",stroke:"#D0D0D0",strokeWidth:"1.755",strokeLinecap:"round",strokeLinejoin:"round"})]}),s("g",{ref:t,style:{transformOrigin:"20px 20px"},children:[o("path",{d:"M28.8177 6.00256H14.7777C12.193 6.00256 10.0977 8.09787 10.0977 10.6826V24.7226C10.0977 27.3073 12.193 29.4026 14.7777 29.4026H28.8177C31.4023 29.4026 33.4977 27.3073 33.4977 24.7226V10.6826C33.4977 8.09787 31.4024 6.00256 28.8177 6.00256Z",fill:"white",stroke:"#EDEDED",strokeWidth:"1.755",strokeLinecap:"round",strokeLinejoin:"round"}),s("g",{style:{transformOrigin:"10px 30px"},ref:n,children:[o("path",{d:"M26.7697 20.5301V12.7301H18.9697",stroke:"#7C7C7C",strokeWidth:"1.872",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M17.4102 22.0901L26.7702 12.7301",stroke:"#7C7C7C",strokeWidth:"1.872",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})},ot=[{transform:"scale(0.1)"},{transform:"scale(1)"}],st={duration:500,easing:"ease-out"},lt=[{transform:"rotate(0deg)"},{transform:"rotate(5deg)"},{transform:"rotate(-5deg)"},{transform:"rotate(0deg)"}],dt={duration:1e3,easing:"ease-out",iterations:1/0,delay:2e3},ct=[{transform:"translateY(0)"},{transform:"translateY(44px)"}],ut={duration:1e3,delay:1e3,easing:"ease-out"},ht={duration:1e3,direction:"reverse",delay:500,easing:"ease-in"},pt=[{opacity:1},{opacity:0},{opacity:1}],mt={duration:1e3},ft=e=>{const{id:n,label:t,checked:i,onChange:a,disabled:r}=e,l=pe(),d=n||l;return s("div",{className:"xendit-checkbox",children:[s("div",{className:"xendit-checkbox-box",children:[o("input",{id:d,type:"checkbox",onChange:e=>{a?.(e)},checked:i,disabled:r}),o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:"xendit-checkbox-graphic",children:o("polyline",{points:"40 144 96 200 224 72",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"16"})})]}),o("label",{htmlFor:d,className:"xendit-text-14",children:t})]})},bt=n(null),yt=()=>{const e=c(bt);if(void 0===e)throw new Error("useChannel must be used within a ChannelProvider");return e},_t=n(null);_t.displayName="ChannelComponentDataContext";const gt=()=>c(_t),xt=e=>{const{channelOrPair:n,channelData:t,savePaymentMethod:i,formRef:a}=e,r=u(null),l=$(),{t:d}=l,c=K(),p=n[0],m=n.length>1,f=ke(n,i),b=function(e){if(e&&2===e.length)return[e[0],e[1]];return null}(f.instructions),y="OPTIONAL"===c.allow_save_payment_method&&(f.allow_save||m);return h(()=>{b||f.form.length||f.banner||console.error(`Missing display data for ${f.channel_code}, this is a bug, please contact support`)},[b,f.banner,f.channel_code,f.form]),o(bt.Provider,{value:f,children:o(_t.Provider,{value:t,children:s("div",{className:"xendit-payment-channel",ref:r,children:[o(et,{ref:a,form:f.form,onChannelPropertiesChanged:e=>{let n=e;if("CARDS"===p.channel_code&&e.installment_configuration){const t=Object.fromEntries(Object.entries(e.installment_configuration).filter(([e,n])=>""!==n));n=0===Object.keys(t).length?{...e,installment_configuration:void 0}:{...e,installment_configuration:t}}const t=new XenditChannelPropertiesChangedEvent(p.channel_code,n);r.current?.dispatchEvent(t)}}),f.banner?o(kt,{banner:f.banner}):null,y&&o(ft,{label:d("payment.save_checkbox_label"),onChange:e=>{const n=e.target?.checked;l?.dispatchEvent(new InternalUpdateChannelComponentData(p.channel_code,{savePaymentMethod:n}))},checked:i}),b?s("div",{className:"xendit-payment-channel-instructions",children:[vt[f.pm_type??""]??o(rt,{}),o("div",{className:"xendit-payment-channel-instructions-text xendit-text-12",children:b.map((e,n)=>o("p",{className:0===n?"xendit-text-semibold":void 0,children:e},n))})]}):null]})})})},vt={EWALLET:o(rt,{}),QR_CODE:o(e=>{const n=u(null),t=u(null),i=pe(),a=void 0!==HTMLElement.prototype.animate;return h(()=>{if(a&&n.current){const e=()=>{if(!n.current)return;const i=n.current.animate(ct,ut);setTimeout(()=>{t.current?.animate(pt,mt)},1e3),i.onfinish=()=>{const i=n.current?.animate(ct,ht);setTimeout(()=>{t.current?.animate(pt,mt)},500),i&&(i.onfinish=e)}};e()}},[a]),s("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"var(--xendit-color-icon-primary)",xmlns:"http://www.w3.org/2000/svg",...e,children:[s("g",{"clip-path":`url(#${i})`,children:[o("rect",{x:"8",y:"8",width:"24",height:"24",fill:"var(--xendit-color-icon-secondary)",ref:t}),o("path",{d:"M11.5 13.1528C11.5 12.24 12.24 11.5 13.1528 11.5H17.4028C18.3156 11.5 19.0556 12.24 19.0556 13.1528V17.4028C19.0556 18.3156 18.3156 19.0556 17.4028 19.0556H13.1528C12.24 19.0556 11.5 18.3156 11.5 17.4028V13.1528Z"}),o("path",{d:"M20.9444 13.1528C20.9444 12.24 21.6844 11.5 22.5972 11.5H26.8472C27.76 11.5 28.5 12.24 28.5 13.1528V17.4028C28.5 18.3156 27.76 19.0556 26.8472 19.0556H22.5972C21.6844 19.0556 20.9444 18.3156 20.9444 17.4028V13.1528Z"}),o("path",{d:"M11.5 22.5972C11.5 21.6844 12.24 20.9444 13.1528 20.9444H17.4028C18.3156 20.9444 19.0556 21.6844 19.0556 22.5972V26.8472C19.0556 27.76 18.3156 28.5 17.4028 28.5H13.1528C12.24 28.5 11.5 27.76 11.5 26.8472V22.5972Z"}),o("path",{d:"M20.9444 22.5972C20.9444 21.6844 21.6844 20.9444 22.5972 20.9444H26.8472C27.76 20.9444 28.5 21.6844 28.5 22.5972V26.8472C28.5 27.76 27.76 28.5 26.8472 28.5H22.5972C21.6844 28.5 20.9444 27.76 20.9444 26.8472V22.5972Z"}),o("path",{d:"M7.875 23C8.35825 23 8.75 23.3918 8.75 23.875V30.2754C8.75021 30.6755 9.07451 30.9998 9.47461 31H15.875C16.3582 31 16.75 31.3918 16.75 31.875C16.75 32.3582 16.3582 32.75 15.875 32.75H9.47461C8.10801 32.7498 7.00021 31.642 7 30.2754V23.875C7 23.3918 7.39175 23 7.875 23Z"}),o("path",{d:"M31.875 23C32.3582 23 32.75 23.3918 32.75 23.875V30.2754C32.7498 31.642 31.642 32.7498 30.2754 32.75H23.875C23.3918 32.75 23 32.3582 23 31.875C23 31.3918 23.3918 31 23.875 31H30.2754C30.6755 30.9998 30.9998 30.6755 31 30.2754V23.875C31 23.3918 31.3918 23 31.875 23Z"}),o("path",{d:"M15.875 7C16.3582 7 16.75 7.39175 16.75 7.875C16.75 8.35825 16.3582 8.75 15.875 8.75H9.47461C9.07451 8.75021 8.75021 9.07451 8.75 9.47461V15.875C8.75 16.3582 8.35825 16.75 7.875 16.75C7.39175 16.75 7 16.3582 7 15.875V9.47461C7.00021 8.10801 8.10801 7.00021 9.47461 7H15.875Z"}),o("path",{d:"M30.2754 7C31.642 7.00021 32.7498 8.10801 32.75 9.47461V15.875C32.75 16.3582 32.3582 16.75 31.875 16.75C31.3918 16.75 31 16.3582 31 15.875V9.47461C30.9998 9.07451 30.6755 8.75021 30.2754 8.75H23.875C23.3918 8.75 23 8.35825 23 7.875C23 7.39175 23.3918 7 23.875 7H30.2754Z"}),o("rect",{x:"3",y:"-4",width:"34",height:"4",rx:"1.75",ref:n})]}),o("defs",{children:o("clipPath",{id:i,children:o("rect",{width:"40",height:"40",fill:"white"})})})]})},{})},kt=e=>{const n="number"==typeof e.banner.aspect_ratio?String(e.banner.aspect_ratio):void 0;return e.banner?.link_url?o("a",{href:e.banner.link_url,target:"_blank",rel:"noopener noreferrer",children:o("img",{src:e.banner.image_url,alt:e.banner.alt_text,className:"xendit-payment-channel-banner",style:{aspectRatio:n}})}):o("img",{src:e.banner.image_url,alt:e.banner.alt_text,className:"xendit-payment-channel-banner",style:{aspectRatio:n}})};class XenditChannelPropertiesChangedEvent extends Event{static type="xendit-channel-properties-changed";channel;channelProperties;constructor(e,n){super(XenditChannelPropertiesChangedEvent.type,{bubbles:!0,composed:!0}),this.channel=e,this.channelProperties=n}}class NetworkError extends Error{errorResponse;constructor(e){super(e.message),this.errorResponse=e}}function wt(e){const n=new URLSearchParams;return n.append("payload",JSON.stringify(e)),n}function Ct(e,n,t){return async function(...i){let a,r,o,s,l;switch(e){case"GET":[a,r,o,l]=i;break;case"POST":[a,s,r,o,l]=i;break;default:throw new Error(`Unable to call endpoint with method ${e}; this is a bug, please contact support.`)}const d="v0.0.18";X(d),X(d.startsWith("v"));const c=a.hostId;if(c===ie)throw new Error("A network request was made in mock mode; this is a bug.");const u=re(c);if(!u)throw new Error(`Unknown hostId ${c} in sdkKey; this is a bug, please contact support.`);const h=new URL(n(r),u);if(t&&!o)throw new Error("Query string argument is missing; this is a bug, please contact support.");const p=t?.(o)??new URLSearchParams;p.set("components_version",d),h.search=p.toString();const m={method:e,body:s?wt(s):void 0,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:l},f=await fetch(h,m);if(!f.ok){const e=await f.json();if(!e||!e.error_code)throw new Error("Unexpected error response from server");throw new NetworkError(e)}return f.json()}}const Et=Ct("GET",e=>`/api/sessions/${e}`),At=Ct("POST",()=>"/api/sessions/payment_tokens"),Nt=Ct("POST",()=>"/api/sessions/payment_requests"),Pt=Ct("POST",e=>`/api/sessions/${e.sessionAuthKey}/payment_requests/${e.paymentRequestId}/simulate`),St=Ct("GET",e=>`/api/sessions/${e}/poll`,e=>new URLSearchParams(e?{token_request_id:e}:{})),It=Ct("POST",e=>`/api/sessions/${e}/card_info`),Rt=Ct("POST",e=>`/api/sessions/${e}/payment_options`);function Tt(e,n,t){return{impl:e,key:n??"",child:t,instance:void 0}}class BehaviorTree{fn;bb;root=Tt(class{});updating=!1;again=!1;constructor(e,n){this.fn=e,this.bb=n}update(){if(this.again=!0,this.updating)return;let e=0;try{for(this.updating=!0;this.again;){this.again=!1,e+=1,Dt(e);const n=this.root??void 0,t=this.fn(this.bb);this.root=t,Mt(n,t,this.bb,0)}}finally{this.updating=!1}}findBehavior(e){return Ot(this.root,e)}}function Dt(e){if(e>32)throw new Error("Max recursion depth exceeded; this is a bug, please contact support.")}function Mt(e,n,t,i){if(Dt(i),function(e,n){return void 0===e||void 0===n||Array.isArray(e)!==Array.isArray(n)||(!Array.isArray(e)||!Array.isArray(n))&&(j(e),j(n),e.impl!==n.impl||e.key!==n.key)}(e,n))e&&Ut(e,i+1),n&&Lt(n,t,i+1);else if(Array.isArray(e)||Array.isArray(n)){Y(e),Y(n);const a=Math.max(e.length,n.length);for(let r=0;r<a;r++)Mt(e[r],n[r],t,i+1)}else n&&(n.instance=e?.instance),e&&(e.instance=void 0),Mt(e?.child,n?.child,t,i+1),n?.instance?.update?.()}function Lt(e,n,t){if(Dt(t),Array.isArray(e))for(const i of e)i&&Lt(i,n,t+1);else e.instance=new e.impl(n,e.key),e.instance.enter?.(),e.child&&Lt(e.child,n,t+1)}function Ut(e,n){if(Dt(n),Array.isArray(e))for(const t of e)t&&Ut(t,n+1);else e.child&&Ut(e.child,n+1),e.instance?.exit?.(),e.instance=void 0}function Ot(e,n){if(Array.isArray(e))for(const t of e){if(!t)continue;const e=Ot(t,n);if(e)return e}else{if(e.impl===n)return e.instance??null;if(e.child)return Ot(e.child,n)}return null}class ActionCompletedBehavior{bb;constructor(e){this.bb=e}enter(){}}const qt=e=>s("div",{className:"xendit-redirect-instructions",children:[o("div",{className:"xendit-redirect-instructions-logo",children:o("img",{src:e.logoUrl,alt:e.logoAlt})}),s("div",{className:"xendit-redirect-instructions-text",children:[o("div",{className:"xendit-text-16",children:e.title}),e.subtitle?o("div",{className:"xendit-text-14 xendit-text-secondary",children:e.subtitle}):null]}),e.redirectUrl?o("a",{href:e.redirectUrl,className:"xendit-redirect-instructions-button xendit-text-14",children:e.redirectButtonLabel??""}):null]}),Bt=e=>{const n=e.t,t=e.channel,i=t.brand_name;return o(qt,{title:n("action_deeplink.title"),subtitle:n("action_deeplink.instructions",{channelName:i}),logoUrl:t.brand_logo_url,logoAlt:n("image_alt.channel_logo",{channelName:i}),redirectUrl:e.redirectUrl,redirectButtonLabel:n("action_deeplink.button",{channelName:i})})},Vt=e=>{const{title:n,onClose:t,children:i,seamless:a,borderColor:r,noBackground:l}=e,c=u(!1),p=u(!1),m=u(null),f=u(null),b=void 0!==HTMLElement.prototype.animate,y=d(()=>{c.current||(c.current=!0,t())},[t]),_=d(()=>{if(!m.current||!f.current||p.current)return;if(p.current=!0,!b)return void y();f.current.animate?.($t,Wt);const e=m.current.animate?.(zt,Wt);e.onfinish=y},[y,b]);return h(()=>{b&&(f.current?.animate?.(Ft,Kt),m.current?.animate?.(Gt,Kt))},[b]),h(()=>{e.close&&_()},[e.close,_]),o("div",{className:"xendit-dialog-backdrop",ref:f,children:s("div",{className:"xendit-dialog "+(l?"":"xendit-dialog-with-background"),ref:m,style:r?{border:`4px solid ${r}`}:void 0,children:[a?null:s("div",{className:"xendit-dialog-header xendit-text-16 xendit-text-semibold",children:[n,o("button",{"aria-label":"Close",onClick:_,children:o(I,{name:"x",size:20})})]}),l?i:o("div",{className:"xendit-dialog-body",children:i}),a?o("button",{"aria-label":"Close",onClick:_,className:"xendit-dialog-floating-close",children:o(I,{name:"x",size:20})}):null]})})},Kt={duration:500,easing:"cubic-bezier(.32,.23,0,.92)",fill:"forwards"},Wt={duration:200,easing:"linear",fill:"forwards"},Ft=[{backgroundColor:"rgba(0, 0, 0, 0)"},{backgroundColor:"rgba(0, 0, 0, 0.2)",offset:.1},{backgroundColor:"rgba(0, 0, 0, 0.6)"}],$t=Ft.slice().reverse(),Gt=[{opacity:0,transform:"scale(0.98) translateY(-40px) rotateX(15deg)"},{opacity:0,transform:"scale(0.98) translateY(-40px) rotateX(15deg)"},{opacity:1,transform:""}],zt=[{opacity:1,transform:""},{opacity:0,transform:"scale(0.92) translateY(-10px)"}];function Ht(e){const{sdk:n,title:t,onClose:i,width:a,height:r,borderColor:s}=e,l=u(null);return h(()=>{const e=n.createActionContainerComponent(P);return l.current?.replaceChildren(e),()=>{n.destroyComponent(e)}},[n]),o(Vt,{title:t,onClose:i,close:e.close,borderColor:s,seamless:!0,noBackground:e.defaultActionContainerType===Xt.QrWithCustomArt,children:o("div",{className:"xendit-default-action-container",ref:l,style:{width:a?`calc(min(100vw - 64px, ${a}px))`:"calc(100vw - 64px)",height:r?`calc(min(100vh - 64px, ${r}px))`:void 0}})})}var Xt;!function(e){e.QrWithCustomArt="qr-with-custom-art",e.Generic="generic"}(Xt||(Xt={}));class ContainerActionBehavior{bb;cleanupFn=null;defaultContainerHeight=0;defaultContainerWidth=400;title="Complete your payment";constructor(e){this.bb=e}ensureHasActionContainer(e=Xt.Generic){if(X(this.bb.channel),this.bb.sdk[P].liveComponents.actionContainer)return()=>{this.emptyActionContainer()};let n=!1,a=!1;const r=document.createElement("div");r.setAttribute("class","xendit-default-action-container");const o={sdk:this.bb.sdk,title:this.title,width:this.defaultContainerWidth,height:this.defaultContainerHeight,borderColor:void 0,defaultActionContainerType:e,onClose:()=>{n=!0,t(null,r),r.remove(),a||this.bb.sdk.abortSubmission()}};return t(i(Ht,o),r),document.body.appendChild(r),e=>{e||(a=!0),n||t(i(Ht,{...o,close:!0}),r)}}cleanupActionContainer(e){this.cleanupFn&&(this.cleanupFn(e),this.cleanupFn=null)}emptyActionContainer(){const e=this.bb.sdk[P].liveComponents.actionContainer;e&&t(null,e)}updateActionContainerBrandColor(){X(this.bb.channel);const e=this.bb.sdk[P].liveComponents.actionContainer;e&&e.style.setProperty("--xendit-channel-brand-color",this.bb.channel.brand_color)}populateActionContainer(e){const n=this.bb.sdk[P].liveComponents.actionContainer;if(!n)throw new Error("Trying to populate action container, but it is missing; A default action container should have been created. This is a bug, please contact support.");this.updateActionContainerBrandColor(),t(e(),n)}exit(){this.cleanupActionContainer(!1),this.emptyActionContainer()}}class ActionDeepLinkBehavior extends ContainerActionBehavior{bb;actionIndex;constructor(e,n){super(e),this.bb=e,this.actionIndex=n}enter(){X(this.bb.world);const e=this.bb.world?.paymentEntity?.entity.actions[Number(this.actionIndex)];if(Q(e?.type,"REDIRECT_CUSTOMER"),"DEEPLINK_URL"!==e.descriptor&&"WEB_URL"!==e.descriptor)throw new Error("Unexpected action type in ActionDeepLinkBehavior");const n=this.bb.sdk.t.bind(this.bb.sdk),t=this.bb.channel;X(t),this.cleanupFn=this.ensureHasActionContainer(),this.populateActionContainer(()=>i(Bt,{t:n,channel:t,redirectUrl:e.value}))}exit(){super.exit()}}const Yt=e=>{const n=e.t,t=e.channel,i=t.brand_name;return o(qt,{title:n("action_empty_list_push_notification.title"),subtitle:n("action_empty_list_push_notification.subtext",{channelName:i}),logoUrl:t.brand_logo_url,logoAlt:n("image_alt.channel_logo",{channelName:i}),redirectUrl:null,redirectButtonLabel:null})};var jt;function Qt(e){return"payment_request_id"in e?{id:e.payment_request_id,type:jt.PaymentRequest,entity:e}:{id:e.payment_token_id,type:jt.PaymentToken,entity:e}}function Zt(e,n,t){return`${e===jt.PaymentRequest?"payment_request":"payment_token"}_status.${n.toLowerCase()}.${t}`}!function(e){e.PaymentRequest="REQUEST",e.PaymentToken="TOKEN"}(jt||(jt={}));function Jt(e,n,t){const{session:i,paymentEntity:a}=e;switch(X(i),X(a),X(n),t){case"PENDING":return ei(i);case"PENDING_PAYMENT_ENTITY_ONLY":return function(e,n){const t=n.type===jt.PaymentRequest?n.entity:void 0,i=n.type===jt.PaymentToken?n.entity:void 0;return{session:e,payment_request:ni(t,"PENDING"),payment_token:ni(i,"PENDING")}}(i,a);case"SUCCESS":return"PENDING"===n._mock_action_type?ei(i):function(e,n){const t=n.type===jt.PaymentRequest?n.entity:void 0,i=n.type===jt.PaymentToken?n.entity:void 0;return{session:{...e,status:"COMPLETED",payment_request_id:t?.payment_request_id,payment_token_id:i?.payment_token_id},payment_request:ni(t,"SUCCEEDED"),payment_token:ni(i,"ACTIVE"),succeeded_channel:{channel_code:n.entity.channel_code,logo_url:"https://placehold.co/48"}}}(i,a);case"FAILURE":return function(e,n){const t=n.type===jt.PaymentRequest?n.entity:void 0,i=n.type===jt.PaymentToken?n.entity:void 0;return{session:{...e,status:"ACTIVE"},payment_request:ni(t,"FAILED"),payment_token:ni(i,"FAILED")}}(i,a)}}function ei(e){return{session:{...e,status:"PENDING"}}}function ni(e,n){return e?{...e,status:n}:e}function ti(e,n){return"PENDING"===n?{payment_request_id:`pr-${he()}`,status:"PENDING",channel_code:e,actions:[],session_token_request_id:he()}:n?{payment_request_id:`pr-${he()}`,status:"REQUIRES_ACTION",channel_code:e,actions:ii(n),session_token_request_id:he()}:{payment_request_id:`pr-${he()}`,status:"SUCCEEDED",channel_code:e,actions:[],session_token_request_id:he()}}function ii(e){if(!e)return[];return(Array.isArray(e)?e:[e]).map(e=>function(e){if("PENDING"===e)throw new Error("PENDING mock action type should not generate an action");switch(e){case"IFRAME":return{type:"REDIRECT_CUSTOMER",descriptor:"WEB_URL",value:"https://example.com/iframe",iframe_capable:!0};case"REDIRECT":return{type:"REDIRECT_CUSTOMER",descriptor:"WEB_URL",value:"https://example.com/redirect",iframe_capable:!1};case"PAYLINK":return{type:"REDIRECT_CUSTOMER",descriptor:"WEB_GOOGLE_PAYLINK",value:"https://example.com/paylink"};case"DEEP_LINK":return{type:"REDIRECT_CUSTOMER",descriptor:"DEEPLINK_URL",value:"mockapp://mock-deep-link"};case"PUSH_NOTIFICATION":return null;case"QR":return{type:"PRESENT_TO_CUSTOMER",descriptor:"QR_STRING",value:"https://example.com/qr-code-data",action_title:"Pay with QR Code",action_subtitle:"Scan the QR code below",action_graphic:"",instructions:null};case"BARCODE":return{type:"PRESENT_TO_CUSTOMER",descriptor:"PAYMENT_CODE",value:"1234567890",action_title:"Pay at a Store",action_subtitle:"Show this barcode to the cashier",action_graphic:"",instructions:null};case"VA":return{type:"PRESENT_TO_CUSTOMER",descriptor:"VIRTUAL_ACCOUNT_NUMBER",value:"1234567890",action_title:"Pay with Virtual Account",action_subtitle:"Protect yourself from fraud - ensure all details are correct",action_graphic:"",instructions:[{title:"Mobile Banking",content:[{type:"text",text:"Open Mobile App"},{type:"text",text:"Select <b>Mock VA</b>, then select <b>Transfer</b>"},{type:"text",text:"Enter your Virtual Account Number, for example 3816523906568, then press <b>OK</b>"},{type:"text",text:"Click on <b>Send</b> button at the top right corner to proceed"},{type:"text",text:"Click <b>OK</b> to proceed"},{type:"text",text:"Enter your PIN to authorize the transaction"}]},{title:"Internet Banking",content:[{type:"text",text:"Login to the website"},{type:"text",text:"Select <b>Transfer</b>, then select <b>Transfer to Mock VA Virtual Account</b>"},{type:"text",text:"Enter the Virtual Account Number, for example 3816523906568"},{type:"text",text:"Select <b>Continue</b> to proceed your payment"}]},{title:"ATM",content:[{type:"text",text:"Insert your ATM card and PIN"},{type:"text",text:"Enter your ATM PIN"},{type:"text",text:"Select <b>Transfer</b>"},{type:"text",text:"Select <b>To Mock VA Virtual Account</b>"},{type:"text",text:"Enter Virtual Account Number, for example 3816523906568. Press <b>Correct</b> to proceed"},{type:"text",text:"Verify Virtual Account details and then enter amount to be transferred and select <b>Correct</b> to confirm"},{type:"text",text:"Confirm your transaction details displayed"},{type:"text",text:"Select <b>Yes</b> if the details are correct or <b>No</b> if the details are not correct"}]}]}}throw new Error(`Unknown mock action type: ${e}`)}(e)).filter(e=>null!==e)}class ActionEmptyListPushNotificationBehavior extends ContainerActionBehavior{bb;constructor(e){super(e),this.bb=e}enter(){X(this.bb.world),this.bb.hackyOvoActionLatch=!0;const e=this.bb.sdk.t.bind(this.bb.sdk),n=this.bb.channel;X(n),this.cleanupFn=this.ensureHasActionContainer(),this.populateActionContainer(()=>i(Yt,{t:e,channel:n})),this.bb.mock&&this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(Jt(this.bb.world,this.bb.channel,"PENDING_PAYMENT_ENTITY_ONLY")))}exit(){this.bb.hackyOvoActionLatch=void 0,super.exit()}}function ai(e){const{url:n,mock:t,onIframeComplete:i}=e,a=u(null),r=d(e=>{if(!a.current)return;const n=a.current.contentWindow;e.source===n&&"xendit-iframe-action-complete"===e.data?.type&&i(e.data)},[i]);return h(()=>(window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}),[r]),o("iframe",t?{ref:a,srcDoc:ri,className:"xendit-action-iframe"}:{ref:a,src:n,className:"xendit-action-iframe"})}const ri="\n <html>\n <head>\n <title>Xendit Mock Action Iframe</title>\n <style>\n body {\n font-family: Arial, sans-serif;\n font-size: 14px;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 12px;\n }\n p {\n margin: 0;\n }\n .buttons {\n display: flex;\n gap: 8px;\n }\n button {\n font-size: 12px;\n display: flex;\n align-items: center;\n text-align: left;\n background-color: white;\n border: 1px solid rgba(243, 243, 243);\n border-radius: 4px;\n justify-content: space-between;\n padding: 4px;\n cursor: pointer;\n }\n button:hover {\n border-color: #1762ee;\n background-color: #1762ee;\n color: white;\n }\n </style>\n </head>\n <body>\n <p>This is a mock action page.</p>\n <p>Normally, this would be a 3DS authentication page.</p>\n <p>Click a button below to simulate the result of the action.</p>\n <div class=\"buttons\">\n <button onclick=\"parent.postMessage({type: 'xendit-iframe-action-complete', mockStatus: 'success'}, '*')\">\n Simulate Success\n </button>\n <button onclick=\"parent.postMessage({type: 'xendit-iframe-action-complete', mockStatus: 'fail'}, '*')\">\n Simulate Failure\n </button>\n </div>\n </body>\n </html>\n";class ActionIframeBehavior extends ContainerActionBehavior{bb;url;constructor(e,n){super(e),this.bb=e,this.url=n,this.defaultContainerHeight=600}enter(){this.cleanupFn=this.ensureHasActionContainer(),this.populateActionContainer(()=>i(ai,{url:this.url,mock:this.bb.mock,onIframeComplete:e=>{this.cleanupActionContainer(!1);const n="success"===e.mockStatus?"SUCCESS":"FAILURE";this.updateMocksOnIframeCompletion(n),this.bb.actionCompleted=!0,this.bb.pollImmediatelyRequested=!0,this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)}}))}updateMocksOnIframeCompletion(e){X(this.bb.world?.paymentEntity),this.bb.mock&&this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(Jt(this.bb.world,this.bb.channel,e)))}exit(){super.exit()}}class ActionPaylinkBehavior{bb;actionIndex;el=null;constructor(e,n){this.bb=e,this.actionIndex=n}enter(){X(this.bb.world),X(this.bb.world.paymentEntity);const e=this.bb.world?.paymentEntity?.entity.actions[Number(this.actionIndex)];if(!e)throw new Error("Action not found for paylink behavior");Q(e.type,"REDIRECT_CUSTOMER"),Q(e.descriptor,"WEB_GOOGLE_PAYLINK");const n=document.createElement("link");n.rel="facilitated-payment",n.href=e.value,this.el=n,document.head.appendChild(n)}exit(){this.el?.remove(),this.el=null}}function oi(e){const{amount:n,businessName:t,channelName:i,channelLogo:a,currency:r,onAffirm:c,qrString:h,parsedQr:f,t:b}=e,[y,_]=p(!1),g=d(()=>{_(!0),c()},[c]),x=m(()=>{try{return ci(h,pi)}catch(e){console.log("Error generating QR code SVG:",e);const n=document.createElement("div");return n.innerText=b("action_qr.unable_to_generate"),n}},[h,b]),v=u(!1),k=d(e=>{if(e instanceof PointerEvent&&"touch"!==e.pointerType)return;if(v.current)return;e.currentTarget.animate?.([{transform:"scale(1)"},{transform:"scale(0.95)"},{transform:"scale(1)"}],{duration:150,easing:"ease-in-out"});const a=ci(h,mi),o=[hi(t),hi(i),hi(r),hi(String(n)),hi(ui())].join("-");v.current=!0,async function(e,n){if(!window.URL?.createObjectURL)throw new Error("Browser doesn't support URL.createObjectURL");if(!window.Blob)throw new Error("Browser doesn't support Blob");if(!document.createElement)throw new Error("Browser doesn't support createElement");const t=(new XMLSerializer).serializeToString(e),i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(i),r=new Image;return r.src=a,new Promise((e,t)=>{r.onload=function(){let i=r.naturalWidth,o=r.naturalHeight;if(0!==i)for(;i<256;)i*=2,o*=2;document.body.appendChild(r);const s=document.createElement("canvas");s.width=i,s.height=o;const l=s.getContext("2d");if(!l)return t(new Error("Failed to get canvas context"));l.drawImage(r,0,0,i,o),URL.revokeObjectURL(a);const d=s.toDataURL("image/png"),c=document.createElement("a");c.href=d,c.download=n,document.body.appendChild(c),c.click(),document.body.removeChild(c),r.remove(),e()},r.onerror=function(e){URL.revokeObjectURL(a),t(new Error("Failed to generate image"))}})}(a,`${o}.png`).catch(e=>{console.error("Error downloading QR code:",e)})},[n,t,i,r,h]);if(e.hideUi)return o("div",{"data-testid":"qr-code",ref:e=>{!e||1===e.childNodes.length&&e.firstChild===x||e?.replaceChildren(x)}});const w=o("div",{"data-testid":"qr-code",className:"xendit-action-qr-qrcode-container",role:"button",tabIndex:0,onClick:k,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),k(e))},ref:e=>{!e||1===e.childNodes.length&&e.firstChild===x||e?.replaceChildren(x)}}),C=s("div",{className:"xendit-action-present-to-customer-affirm",children:[o(Se,{variant:Ne.WHITE_ROUNDED,disabled:y,onClick:g,className:"xendit-button-block",children:y?o(Ie,{}):b("action.payment_made")}),o("div",{className:"xendit-text-12 xendit-text-secondary xendit-text-center",children:b("action.payment_confirmation_instructions")})]}),E=Pn(n,r),A=si(f);return A?s(l,{children:[o(A,{channelLogo:a,channelName:i,merchantName:t,amountText:E,parsedQr:f,qr:w,t:b}),o("div",{style:{padding:"8px",background:"white",marginTop:"25px",borderRadius:"8px"},children:C})]}):s("div",{className:"xendit-action-present-to-customer",children:[o("img",{src:a,alt:b("image_alt.channel_logo",{channelName:i}),className:"xendit-action-qr-channel-logo"}),s("div",{className:"xendit-action-qr-content",children:[o("div",{className:"xendit-text-16 xendit-text-center xendit-qr-merchant-info",children:o("div",{className:"xendit-text-semibold",children:t})}),w,o("div",{className:"xendit-text-16 xendit-text-semibold xendit-text-center",children:E})]}),C]})}function si(e){return e&&e.merchantAccountInformation&&"object"==typeof e.merchantAccountInformation&&e.merchantAccountInformation["ID.CO.QRIS.WWW"]?di:null}const li="rgb(238, 54, 66)";function di(e){const{channelLogo:n,channelName:t,merchantName:i,amountText:a,parsedQr:r,t:l}=e;const d=function(){const e=r?.merchantAccountInformation;if("string"==typeof e)return;const n=e?.["ID.CO.QRIS.WWW"];return"string"!=typeof n&&n?.nmid?`NMID: ${n.nmid}`:void 0}();return s("div",{style:{display:"flex",gap:"16px",flexDirection:"column",padding:"20px",position:"relative",borderRadius:"8px",overflow:"hidden",backgroundColor:"var(--xendit-color-background)"},children:[o("img",{src:n,alt:l("image_alt.channel_logo",{channelName:t}),style:{height:"64px",alignSelf:"flex-start"}}),s("div",{className:"xendit-text-center xendit-text-16",style:{display:"flex",flexDirection:"column",gap:"4px"},children:[o("div",{className:"xendit-text-semibold",children:i}),d?o("div",{children:d}):null]}),s("div",{style:{position:"relative",margin:"-20px",padding:"20px"},children:[e.qr,o("svg",{style:{position:"absolute",top:"-9%",left:0,width:"60%",height:"auto",pointerEvents:"none"},viewBox:"0 0 100 100",children:o("polygon",{fill:li,points:"0,0 50,50 0,100"})}),o("svg",{style:{position:"absolute",bottom:0,right:0,width:"30%",height:"auto",pointerEvents:"none"},viewBox:"0 0 100 100",children:o("polygon",{fill:li,points:"0,100 100,100 100,0"})}),o("div",{className:"xendit-text-16 xendit-text-semibold xendit-text-center",children:a})]})]})}function ci(e,n){const t=E.create(e),i=A.render(t,{margin:n.margin}),a=(new DOMParser).parseFromString(i,"image/svg+xml").documentElement;a.style.width="100%",a.style.height="100%",a.setAttribute("width",String(t.modules.size+2*n.margin)),a.setAttribute("height",String(t.modules.size+2*n.margin));const r=a.querySelector("[stroke]");r?.setAttribute("stroke",n.colors[0]);const o=a.querySelector("[fill]");return o?.setAttribute("fill",n.colors[1]),n.borderRadius&&(a.style.borderRadius=`${n.borderRadius}px`),a}function ui(){const e=new Date;return new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",day:"2-digit",month:"2-digit",year:"numeric"}).format(e)}function hi(e){return e.split("").map(e=>/[a-zA-Z0-9]/.test(e)?e.toLowerCase():"-").join("").replace(/-+/g,"-")}const pi={margin:2,borderRadius:4,colors:["var(--xendit-qr-foreground-color)","var(--xendit-qr-background-color)"]},mi={margin:2,colors:["#000","#FFF"]},fi={"00":{name:"payloadFormatIndicator",type:"numeric"},"01":{name:"pointOfInitiationMethod",type:"numeric"},52:{name:"merchantCategoryCode",type:"numeric"},53:{name:"transactionCurrency",type:"numeric"},54:{name:"transactionAmount",type:"ans"},55:{name:"tipOrConvenienceIndicator",type:"numeric"},56:{name:"valueOfConvenienceFeeFixed",type:"ans"},57:{name:"valueOfConvenienceFeePercentage",type:"ans"},58:{name:"countryCode",type:"ans"},59:{name:"merchantName",type:"ans"},60:{name:"merchantCity",type:"ans"},61:{name:"postalCode",type:"ans"},62:{name:"additionalData",type:"template",templateClass:{"01":{name:"billNumber",type:"ans"},"02":{name:"mobileNumber",type:"ans"},"03":{name:"storeLabel",type:"ans"},"04":{name:"loyaltyNumber",type:"ans"},"05":{name:"referenceLabel",type:"ans"},"06":{name:"customerLabel",type:"ans"},"07":{name:"terminalLabel",type:"ans"},"08":{name:"purposeOfTransaction",type:"ans"},"09":{name:"additionalConsumerDataRequest",type:"ans"}}},63:{name:"crc",type:"ans"},64:{name:"language",type:"template",templateClass:{"00":{name:"languagePreference",type:"ans"},"01":{name:"merchantNameAlternateLanguage",type:"string"},"02":{name:"merchantCityAlternateLanguage",type:"string"}}}},bi={"ID.CO.QRIS.WWW":{"00":{name:"globallyUniqueIdentifier",type:"string"},"02":{name:"nmid",type:"ans"},"03":{name:"businessType",type:"ans"}},"ID.DANA.WWW":{"00":{name:"globallyUniqueIdentifier",type:"string"},"01":{name:"merchantId",type:"ans"},"02":{name:"storeOrTerminalId",type:"ans"},"03":{name:"additionalIdentifier",type:"ans"}},"SG.SGQR":{"00":{name:"globallyUniqueIdentifier",type:"string"},"01":{name:"sgqrNumber",type:"ans"},"02":{name:"version",type:"ans"},"03":{name:"postalCode",type:"ans"},"04":{name:"level",type:"ans"},"05":{name:"unit",type:"ans"},"06":{name:"misc",type:"ans"},"07":{name:"revisionDate",type:"ans"}},"SG.PAYNOW":{"00":{name:"globallyUniqueIdentifier",type:"string"},"01":{name:"type",type:"numeric"},"02":{name:"identifier",type:"ans"},"03":{name:"editable",type:"numeric"}},"ph.ppmi.p2m":{"00":{name:"globallyUniqueIdentifier",type:"string"},"01":{name:"acquirerId",type:"ans"},"03":{name:"merchantId",type:"ans"},"05":{name:"notifyFlags",type:"numeric"}}};function yi(e){return/^[\uD800-\uDBFF]$/.test(e)}function _i(e){const n=new Set,t=[];for(;e.length;){const i=e.substring(0,2);if(!/^\d{2}$/.test(i))throw new Error("Invalid EMVCo QR string, invalid tag");if(n.has(i))throw new Error(`Duplicate tag ${i} in EMVCo QR string`);n.add(i);const a=e.substring(2,4);if(!/^\d{2}$/.test(a))throw new Error("Invalid EMVCo QR string, invalid length");const r=parseInt(a,10);if(!r)throw new Error(`Invalid EMVCo QR string, expected length but got ${a}`);let o="",s=0,l=0;for(;l<r;){const n=e.substring(4+s,5+s);if(""===n)throw new Error("Invalid EMVCo QR string, unexpected end of string");o+=n,s+=1,yi(n)?l+=.5:l+=1}t.push({key:i,value:o}),e=e.substring(4+s)}return t}function gi(e,n,t,i){e[`field${t}`]=i;const a=n[t];if(!a)return;const r="template"===a.type&&a.templateClass?xi(a.templateClass,i).result:i;e[a.name]=r}function xi(e,n){const t=_i(n),i={};for(const{key:n,value:a}of t)gi(i,e,n,a);return{result:i,raw:t}}function vi(e,n,t){const i=_i(t),a=i.find(({key:e})=>"00"===e)?.value;if(!a)throw new Error(`Missing field 00 in merchant account information template for field ${n}`);const r=bi[a];return r&&(e[a]=xi(r,t).result),e}class ActionQrBehavior extends ContainerActionBehavior{bb;actionIndex;constructor(e,n){super(e),this.bb=e,this.actionIndex=n}enter(){const e=this.bb.world?.paymentEntity?.entity.actions[Number(this.actionIndex)];Q(e?.type,"PRESENT_TO_CUSTOMER"),X(this.bb.world),X(this.bb.channel),X(this.bb.world.paymentEntity);let n=null;try{n=function(e){const{result:n,raw:t}=xi(fi,e);n.merchantAccountInformation={};for(const e of t){const t=Number(e.key);t>=26&&t<=51&&vi(n.merchantAccountInformation,e.key,e.value)}return n}(e.value)}catch{}if(this.bb.mock&&"string"==typeof this.bb.channelProperties?.mock_emvco_qr_field_26_00){const e=this.bb.channelProperties.mock_emvco_qr_field_26_00;n={merchantAccountInformation:{[e]:{globallyUniqueIdentifier:e}}}}const t=function(e){return null!==si(e)}(n),a=this.bb.sdk[P].liveComponents.actionContainer,r={amount:this.bb.world.session.amount,businessName:this.bb.world.business.name??"",channelName:this.bb.channel.brand_name,channelLogo:this.bb.channel.brand_logo_url,currency:this.bb.world.session.currency,hideUi:"true"===a?.getAttribute("data-qr-code-only")||!1,onAffirm:this.affirmPayment.bind(this),qrString:e.value,parsedQr:n,title:e.action_subtitle,t:this.bb.sdk.t.bind(this.bb.sdk)},o=t?Xt.QrWithCustomArt:Xt.Generic;this.cleanupFn=this.ensureHasActionContainer(o),this.populateActionContainer(()=>i(oi,r))}affirmPayment(){this.bb.sdk.isProdLive()?this.bb.pollImmediatelyRequested=!0:this.bb.simulatePaymentRequested=!0,this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)}exit(){super.exit()}}class ActionRedirectBehavior{bb;url;constructor(e,n){this.bb=e,this.url=n}enter(){this.bb.dispatchEvent(new XenditWillRedirectEvent),window.location.href=this.url}}const ki=({instructions:e})=>{switch(e.length){case 0:return null;case 1:return o(wi,{instruction:e[0]});default:return o(Ci,{instructions:e})}},wi=e=>s("div",{children:[o("p",{className:"xendit-instructions-single-tab-heading",children:e.instruction.title}),o(Ei,{instruction:e.instruction})]}),Ci=e=>{const[n,t]=p(0);return s("div",{children:[o("div",{className:"xendit-instructions-tab-list",children:e.instructions.map((e,i)=>o("button",{className:y("xendit-instructions-tab-button",{"xendit-instructions-active-tab":n===i}),onClick:()=>t(i),children:e.title},i))}),o(Ei,{instruction:e.instructions[n]})]})},Ei=e=>o("ol",{className:"xendit-instructions-numbered-list","data-testid":"instructions-steps",children:e.instruction.content.map((e,n)=>{const t=Array.isArray(e)?e:[e];return o("li",{className:"xendit-instructions-step-li",children:o("div",{className:"xendit-instructions-step-box",children:t.map((e,n)=>o(a,{children:Si(e)},n))})},n)})});function Ai(e){return Array.from(e).map((e,n)=>{switch(e.nodeType){case Node.TEXT_NODE:return null===e.textContent?null:e.textContent;case Node.ELEMENT_NODE:return function(e,n){const t=y({"xendit-instructions-bold":"B"===e.nodeName,"xendit-instructions-italics":"I"===e.nodeName});return t?o("span",{className:t,children:Ai(e.childNodes)},n):Ai(e.childNodes)}(e,n);default:return null}})}const Ni="undefined"!=typeof DOMParser?new DOMParser:null;function Pi(e){try{if(!Ni)return e;return Ai(Ni.parseFromString(e,"text/html").body.childNodes)}catch(n){return e}}function Si(e){if("string"==typeof e)return o("p",{className:"xendit-instructions-step-item",children:Pi(e)});switch(e.type){case"text":return function(e){return o("p",{children:Pi(e.text)})}(e);case"image":return function(e){return o("div",{children:o("img",{src:e.src,alt:e.alt||"",style:{height:`${e.height??24}px`}})})}(e);case"bullets":return function(e){return o("ul",{className:"xendit-instructions-bullet-list",children:e.items.map((e,n)=>o("li",{children:Pi(e)},n))})}(e);case"form":return function(e){return s("div",{className:"xendit-instructions-form-card",children:[e.heading?o("h3",{className:"xendit-instructions-form-heading",children:Pi(e.heading)}):null,e.fields.map((e,n)=>s("div",{className:"xendit-instructions-form-field",children:[o("div",{className:"xendit-instructions-form-field-label",children:Pi(e.label)}),o("div",{className:"xendit-instructions-form-field-value",children:Pi(e.value)})]},n))]})}(e);case"table":return function(e){return s("table",{className:"xendit-instructions-table",children:[o("thead",{children:o("tr",{children:e.headers.map((e,n)=>o("th",{className:"xendit-instructions-table-header",children:Pi(e)},n))})}),o("tbody",{children:e.rows.map((e,n)=>o("tr",{children:e.map((e,n)=>o("td",{className:"xendit-instructions-table-cell",children:Pi(e)},n))},n))})]})}(e)}return null}const Ii=n({fire:()=>{},clear:()=>{},text:""}),Ri=({children:e})=>{const[n,t]=p(""),i=d(e=>{t(e);const n=setTimeout(()=>{t("")},2e3);return()=>clearTimeout(n)},[]),a=d(()=>{t("")},[]);return o(Ii.Provider,{value:{text:n,fire:i,clear:a},children:o("div",{style:{position:"relative"},children:e})})},Ti=()=>{const{text:e,clear:n}=c(Ii);return h(()=>{if(e){const e=()=>{n()};return document.body.addEventListener("mousedown",e),()=>{document.body.removeEventListener("mousedown",e)}}},[n,e]),e?o("div",{className:"xendit-tooltip",children:e}):null};function Di(e){const{amount:n,channelLogo:t,currency:i,onAffirm:a,vaNumber:r,merchantName:l,instructions:c,title:u,t:h}=e,[m,f]=p(!1),b=d(()=>{f(!0),a()},[a]),y=[{heading:h("action_va.merchant_name"),value:l},{heading:h("action_va.virtual_account_number"),value:r,enableCopy:!0},{heading:h("action_va.amount_to_pay"),value:Pn(n,i),enableCopy:!0}];return s("div",{className:"xendit-action-present-to-customer",children:[o("img",{src:t,alt:"Channel Logo",className:"xendit-action-qr-channel-logo"}),o("div",{className:"xendit-action-title",children:u}),o("div",{className:"xendit-action-va-content",children:o("div",{className:"xendit-action-va-details",children:y.map((e,n)=>s("div",{className:"xendit-action-va-detail-item",children:[s("div",{className:"xendit-action-va-detail-content",children:[o("div",{className:"xendit-action-va-heading xendit-text-12 xendit-text-semibold",children:e.heading}),o("div",{className:"xendit-action-va-value xendit-text-semibold",children:e.value})]}),e.enableCopy?s(Ri,{children:[o(Mi,{value:e.value,t:h}),o(Ti,{})]}):null]},n))})}),s("div",{className:"xendit-action-present-to-customer-affirm",children:[o(Se,{variant:Ne.WHITE_ROUNDED,disabled:m,onClick:b,className:"xendit-button-block",children:m?o(Ie,{}):h("action.payment_made")}),o("div",{className:"xendit-text-12 xendit-text-secondary xendit-text-center",children:h("action.payment_confirmation_instructions")})]}),o(ki,{instructions:c})]})}const Mi=({value:e,t:n})=>{const{fire:t}=c(Ii);return s(Se,{variant:Ne.WHITE_ROUNDED,size:Pe.SM,onClick:()=>{navigator.clipboard.writeText(e),t(n("action_va.copied_to_clipboard"))},children:[n("action_va.copy"),o(I,{name:"copy",size:16})]})};class ActionVaBehavior extends ContainerActionBehavior{bb;actionIndex;constructor(e,n){super(e),this.bb=e,this.actionIndex=n}enter(){const e=this.bb.world?.paymentEntity?.entity.actions[Number(this.actionIndex)];Q(e?.type,"PRESENT_TO_CUSTOMER"),X(this.bb.world),X(this.bb.channel);const n={amount:this.bb.world.session.amount,channelLogo:this.bb.channel.brand_logo_url,currency:this.bb.world.session.currency,onAffirm:this.affirmPayment.bind(this),vaNumber:e.value,merchantName:this.bb.world.business.name??"",instructions:e.instructions??[],title:e.action_title,t:this.bb.sdk.t.bind(this.bb.sdk)};this.cleanupFn=this.ensureHasActionContainer(),this.populateActionContainer(()=>i(Di,n))}affirmPayment(){this.bb.sdk.isProdLive()?this.bb.pollImmediatelyRequested=!0:this.bb.simulatePaymentRequested=!0,this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)}}class CardInfoBehavior{bb;channelCode;cardDetailsRequest=null;constructor(e,n){this.bb=e,this.channelCode=n}enter(){this.lookupCardDetails()}update(){this.lookupCardDetails()}exit(){this.abortLookupCardDetails()}abortLookupCardDetails(){this.cardDetailsRequest&&(this.cardDetailsRequest.abortController.abort(new AbortError),this.cardDetailsRequest=null)}lookupCardDetails(){const e=_e(this.bb.channelProperties);if(!e)return;if(this.cardDetailsRequest?.cardNumber===e)return;if(this.bb.channelData?.cardDetails?.cardNumber===e)return;this.cardDetailsRequest&&this.abortLookupCardDetails();const n=new AbortController,t=ee(300,n.signal).then(()=>{if(this.bb.mock){const n=ge(e).cipherText;try{return JSON.parse(atob(n))}catch{}return{schemes:["VISA"],country_codes:["ID"],require_billing_information:!1}}{const t=ge(e).withoutValidationError;return It(this.bb.sdkKey,{card_number:t},this.bb.sdkKey.sessionAuthKey,void 0,n.signal)}}).then(n=>{this.bb.dispatchEvent(new InternalUpdateChannelComponentData(this.channelCode,{cardDetails:{cardNumber:e,details:n}}))}).catch(e=>{if(!J(e))throw e});this.cardDetailsRequest={cardNumber:e,promise:t,abortController:n}}}class ChannelInvalidBehavior{bb;channelCode;constructor(e,n){this.bb=e,this.channelCode=n}enter(){}}class ChannelValidBehavior{bb;lastChannelCode=null;constructor(e){this.bb=e}enter(){this.sendReadyEventIfChanged()}update(){this.sendReadyEventIfChanged()}sendReadyEventIfChanged(){const e=this.bb.channel?.channel_code??null;e&&e!==this.lastChannelCode&&(this.bb.dispatchEvent(new XenditReadyEvent(e)),this.lastChannelCode=e)}exit(){this.bb.dispatchEvent(new XenditNotReadyEvent)}}class PaymentEntityFailedBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.submissionRequested=!1,this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)}}class PollWorker{sdkKey;sdk;sessionTokenRequestId;onPollResult;started=!1;stopped=!1;constructor(e,n,t,i){this.sdkKey=e,this.sdk=n,this.sessionTokenRequestId=t,this.onPollResult=i}async start(){if(this.stopped)throw new Error("PollWorker has been stopped, make a new instance instead of calling start again");this.started=!0;for await(const e of async function*(e,n,t=2){yield 0;let i=e;for(let e=1;e<n;e++)i*=t,await Z(i),yield e}(5e3,100,1.06)){if(this.stopped)return;let e;if(this.sdk.isMock()){if(!(this.sdk instanceof XenditComponentsTest&&this.sdk.nextMockUpdate))continue;await Z(H),e=this.sdk.nextMockUpdate,this.sdk.nextMockUpdate=null}else try{e=await St(this.sdkKey,this.sdkKey.sessionAuthKey,this.sessionTokenRequestId)}catch(e){continue}if(this.stopped)return;if(!e.session)throw new Error("Session is not defined");let n=null;e.payment_token?n=Qt(e.payment_token):e.payment_request&&(n=Qt(e.payment_request)),this.onPollResult(e,n),await Z(1)}}isPolling(){return this.started&&!this.stopped}stop(){this.started=!1,this.stopped=!0}}class PaymentEntityPendingBehavior{bb;pollWorker;constructor(e){this.bb=e,this.pollWorker=new PollWorker(this.bb.sdkKey,this.bb.sdk,this.bb.world?.sessionTokenRequestId??null,this.onPollResult)}enter(){if(this.bb.mock)switch(X(this.bb.world?.paymentEntity),this.bb.world?.paymentEntity.entity.status){case"ACTIVE":case"AUTHORIZED":case"SUCCEEDED":case"PENDING":this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(Jt(this.bb.world,this.bb.channel,"SUCCESS")));break;case"FAILED":case"CANCELED":case"EXPIRED":this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(Jt(this.bb.world,this.bb.channel,"FAILURE")))}this.pollWorker.start()}exit(){this.pollWorker.stop()}onPollResult=(e,n)=>{this.bb.dispatchEvent(new InternalUpdateWorldState({session:e.session,paymentEntity:n??void 0,succeededChannel:e.succeeded_channel??null}))}}class PaymentEntityRequiresActionBehavior{bb;pollWorker=null;canCreateActionContainer=!0;constructor(e){this.bb=e,this.resetPolling()}enter(){this.bb.dispatchEvent(new XenditActionBeginEvent),this.canCreateActionContainer=!1,this.pollWorker?.start()}update(){this.bb.pollImmediatelyRequested&&(this.bb.pollImmediatelyRequested=!1,this.resetPolling())}exit(){this.pollWorker?.stop(),this.bb.dispatchEvent(new XenditActionEndEvent),this.bb.actionCompleted=!1}onPollResult=(e,n)=>{this.bb.dispatchEvent(new InternalUpdateWorldState({session:e.session,paymentEntity:n??void 0,succeededChannel:e.succeeded_channel??null}))};resetPolling(){const e=this.pollWorker?.isPolling()??!1;this.pollWorker?.stop(),this.pollWorker=new PollWorker(this.bb.sdkKey,this.bb.sdk,this.bb.world?.sessionTokenRequestId??null,this.onPollResult),e&&this.pollWorker.start()}}class PaymentOptionsBehavior{bb;channelCode;paymentOptionsRequest=null;constructor(e,n){this.bb=e,this.channelCode=n}enter(){this.lookupPaymentOptions()}update(){this.lookupPaymentOptions()}exit(){this.abortLookupPaymentOptions()}abortLookupPaymentOptions(){this.paymentOptionsRequest&&(this.paymentOptionsRequest.abortController.abort(new AbortError),this.paymentOptionsRequest=null)}lookupPaymentOptions(){let e;if(X(this.bb.world),X(this.bb.channel),Ae(this.bb.channel.form,"credit_card_number")){if(e=_e(this.bb.channelProperties)??void 0,!e)return;if(this.paymentOptionsRequest?.cardNumber===e)return;if(this.bb.channelData?.paymentOptions?.cardNumber??null===e)return;if(e){if(!ge(e).valid)return}}else if(this.paymentOptionsRequest||this.bb.channelData?.paymentOptions)return;this.paymentOptionsRequest&&this.abortLookupPaymentOptions();const n=new AbortController,t=async function(e,n,t,i,a,r){if(r)return ee(H,a).then(()=>function(e,n){return{channel_code:e,country:n.country,currency:n.currency,amount:n.amount,installment_plans:[{interval:"MONTH",interval_count:1,terms:3,installment_amount:Math.floor(n.amount/3),total_amount:n.amount,description:"Unused",code:"3M",interest_rate:1},{interval:"MONTH",interval_count:1,terms:6,installment_amount:Math.floor(n.amount/6),total_amount:n.amount,description:"Unused",code:"6M",interest_rate:1},{interval:"MONTH",interval_count:1,terms:9,installment_amount:Math.floor(n.amount/9),total_amount:n.amount,description:"Unused",interest_rate:1,code:void 0}]}}(t,n));return Rt(e,{channel_code:t,channel_properties:i?{card_number:i}:void 0},e.sessionAuthKey,null,a)}(this.bb.sdkKey,this.bb.world.session,this.bb.channel.channel_code,e,n.signal,this.bb.mock).then(n=>{this.bb.dispatchEvent(new InternalUpdateChannelComponentData(this.channelCode,{paymentOptions:{cardNumber:e??null,options:n}}))}).catch(e=>{if(!J(e))throw e});this.paymentOptionsRequest={cardNumber:e??void 0,promise:t,abortController:n}}}class SdkActiveBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new XenditInitEvent),this.bb.dispatchEvent(new InternalNeedsRerenderEvent)}exit(){this.bb.dispatchEvent(new InternalNeedsRerenderEvent)}}class SdkFatalErrorBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new XenditFatalErrorEvent(this.bb.sdkFatalErrorMessage??"Unknown error"))}}class SdkLoadingBehavior{bb;constructor(e){this.bb=e}enter(){}}class SessionActiveBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new InternalNeedsRerenderEvent)}exit(){this.bb.dispatchEvent(new InternalNeedsRerenderEvent)}}class SessionCompletedBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new XenditSessionCompleteEvent)}}class SessionFailedBehavior{bb;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new XenditSessionExpiredOrCanceledEvent)}}function Li(e,n){switch(e.type){case jt.PaymentRequest:n(new XenditPaymentRequestDiscardedEvent(e.id));break;case jt.PaymentToken:n(new XenditPaymentTokenDiscardedEvent(e.id))}n(new InternalUpdateWorldState({paymentEntity:null,sessionTokenRequestId:null}))}class SessionPendingBehavior{bb;pollWorker;constructor(e){this.bb=e,this.pollWorker=new PollWorker(this.bb.sdkKey,this.bb.sdk,this.bb.world?.sessionTokenRequestId??null,this.onPollResult)}enter(){this.pollWorker.start(),this.bb.dispatchEvent(new XenditSessionPendingEvent)}exit(){this.pollWorker.stop(),X(this.bb.world?.session);const e=this.bb.world.paymentEntity;"COMPLETED"!==this.bb.world.session.status&&e&&Li(e,this.bb.dispatchEvent),this.bb.dispatchEvent(new XenditSessionNotPendingEvent)}onPollResult=(e,n)=>{this.bb.dispatchEvent(new InternalUpdateWorldState({session:e.session,paymentEntity:n??void 0,succeededChannel:e.succeeded_channel??null}))}}class SimulatePaymentBehavior{bb;exited=!1;simulationRequest=null;constructor(e){this.bb=e}enter(){this.simulatePayment()}exit(){this.exited=!0,this.bb.simulatePaymentRequested=!1,this.abortSimulation()}abortSimulation(){this.simulationRequest&&(this.simulationRequest.abortController.abort(new AbortError),this.simulationRequest=null)}simulatePayment(){if(this.simulationRequest&&this.abortSimulation(),!this.bb.channel)throw new Error("Channel is missing");if(!this.bb.world)throw new Error("Invalid state");if(!this.bb.world.paymentEntity)throw new Error("Payment entity is missing");if(this.bb.world.paymentEntity.type!==jt.PaymentRequest)throw new Error("Payment entity is not a payment request");const e=this.bb.world?.paymentEntity.id,n=new AbortController,t=async function(e,n,t,i,a){return n?(await ee(H,a),ti(t.channel_code,t._mock_action_type)):await Pt(e,{channel_code:t.channel_code},{sessionAuthKey:e.sessionAuthKey,paymentRequestId:i},void 0,a)}(this.bb.sdkKey,this.bb.mock,this.bb.channel,e,n.signal).then(()=>{this.bb.mock&&this.bb.world&&this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(Jt(this.bb.world,this.bb.channel,"SUCCESS"))),this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)}).catch(e=>{J(e)||this.exited||(this.bb.simulatePaymentRequested=!1,console.error("Simulate Payment failed:",e))});this.simulationRequest={promise:t,abortController:n}}}class SubmissionBehavior{bb;exited=!1;submission=null;submissionError=null;constructor(e){this.bb=e}enter(){this.bb.dispatchEvent(new XenditSubmissionBeginEvent),this.bb.dispatchEvent(new InternalScheduleMockUpdateEvent(null)),this.submit()}exit(){this.exited=!0,X(this.bb.world?.session);const e=this.bb.sdk.t,n=this.bb.world.paymentEntity;let t,i,a;var r;"COMPLETED"!==this.bb.world.session.status&&"PENDING"!==this.bb.world.session.status&&n&&Li(n,this.bb.dispatchEvent),"ACTIVE"!==this.bb.world.session.status?t=`SESSION_${this.bb.world.session.status}`:!n||"FAILED"!==n.entity.status&&"CANCELED"!==n.entity.status&&"EXPIRED"!==n.entity.status?this.submissionError?(t="REQUEST_FAILED",!("message"in(r=this.submissionError))&&"text"in r&&"code"in r?(i=this.submissionError.text,a={type:"ERROR",code:this.submissionError.code}):(i=function(e){return[e("default_error.title"),e("default_error.message_1"),e("default_error.message_2")]}(e),a={type:"NETWORK_ERROR",code:"NETWORK_ERROR"})):t=this.submission?"REQUEST_ABORTED":"ACTION_ABORTED":(t=`PAYMENT_${n.type}_${n.entity.status}`,i=function(e,n,t,i){const a=e(Zt(n,t,"title")),r=i?e(function(e){return`failure_code.${e.toLowerCase()}`}(i),e("failure_code_unknown",{failureCode:i})):e(Zt(n,t,"subtext"));return[a,r]}(e,n.type,n.entity.status,n.entity.failure_code),a={type:"FAILURE",code:n.entity.failure_code??"UNKNOWN"}),this.bb.dispatchEvent(new XenditSubmissionEndEvent(t,i,a)),this.submission&&(this.submission?.abortController.abort(new AbortError),this.submission=null),this.bb.submissionRequested=!1,this.bb.dispatchEvent(new InternalNeedsRerenderEvent)}submit(){if(!this.bb.world?.session)throw new Error("Session object missing");if(!this.bb.channel)throw new Error("Channel missing");if(this.bb.instantSubmissionError)return this.bb.submissionRequested=!1,this.submissionError=this.bb.instantSubmissionError,this.bb.instantSubmissionError=null,void this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent);const e="OPTIONAL"===this.bb.world.session.allow_save_payment_method&&this.bb.channel?.allow_save,n=this.bb.world?.session?.session_type,t=this.bb.channel.channel_code,i=this.bb.channel._mock_action_type,a=this.bb.channelProperties??{},r=new AbortController,o=async function(e,n,t,i,a,r,o,s){let l;if(n)switch(t){case"PAY":await ee(H,o.signal),l=ti(i,a);break;case"SAVE":await ee(H,o.signal),l=function(e,n){return"PENDING"===n?{payment_token_id:`pt-${he()}`,status:"PENDING",channel_code:e,actions:ii(n),session_token_request_id:he()}:n?{payment_token_id:`pt-${he()}`,status:"REQUIRES_ACTION",channel_code:e,actions:ii(n),session_token_request_id:he()}:{payment_token_id:`pt-${he()}`,status:"ACTIVE",channel_code:e,actions:[],session_token_request_id:he()}}(i,a);break;default:throw new Error(`The session type ${t} is not supported.`)}else switch(t){case"PAY":l=await Nt(e,{session_id:e.sessionAuthKey,channel_code:i,channel_properties:r,save_payment_method:s},null,null,o.signal);break;case"SAVE":l=await At(e,{session_id:e.sessionAuthKey,channel_code:i,channel_properties:r},null,null,o.signal);break;default:throw new Error(`The session type ${t} is not supported.`)}return Qt(l)}(this.bb.sdkKey,this.bb.mock,n,t,i,a,r,e?this.bb.channelData?.savePaymentMethod??!1:void 0).then(e=>{switch(this.submission=null,e.type){case jt.PaymentRequest:this.bb.dispatchEvent(new XenditPaymentRequestCreatedEvent(e.id));break;case jt.PaymentToken:this.bb.dispatchEvent(new XenditPaymentTokenCreatedEvent(e.id))}this.bb.dispatchEvent(new InternalUpdateWorldState({paymentEntity:e,sessionTokenRequestId:e.entity.session_token_request_id}))}).catch(e=>{J(e)||(console.error("Submission failed:",e),this.exited||(this.bb.submissionRequested=!1,this.submissionError=e instanceof NetworkError?{text:[e.errorResponse.error_content?.title,e.errorResponse.error_content?.message_1,e.errorResponse.error_content?.message_2].filter(e=>void 0!==e),code:e.errorResponse.error_code}:e,this.bb.dispatchEvent(new InternalBehaviorTreeUpdateEvent)))});this.submission={abortController:r,promise:o}}}function Ui(e){switch(e.sdkStatus){case"LOADING":return Tt(SdkLoadingBehavior);case"ACTIVE":return Tt(SdkActiveBehavior,"active",function(e){switch(X(e.world?.session),e.world.session.status){case"ACTIVE":return Tt(SessionActiveBehavior,"active",e.submissionRequested?function(e){return X(e.world),Tt(SubmissionBehavior,"submission",e.world.paymentEntity&&null!==e.world.sessionTokenRequestId?function(e){function n(){return X(e.world?.paymentEntity),te(e.sdk,e.world.paymentEntity.entity.actions)?function(e){X(e.world?.paymentEntity);const n=te(e.sdk,e.world.paymentEntity.entity.actions);X(n);const t=e.world.paymentEntity.entity.actions.indexOf(n);return Tt(ActionPaylinkBehavior,String(t))}(e):void 0}if(X(e.world?.paymentEntity),e.hackyOvoActionLatch&&"PENDING"===e.world.paymentEntity.entity.status)return Tt(PaymentEntityRequiresActionBehavior,e.world.paymentEntity.id,[Tt(ActionEmptyListPushNotificationBehavior,""),n()]);switch(e.world.paymentEntity.entity.status){case"PENDING":return Tt(PaymentEntityPendingBehavior);case"REQUIRES_ACTION":return Tt(PaymentEntityRequiresActionBehavior,e.world.paymentEntity.id,[Oi(e),n()]);case"FAILED":case"EXPIRED":case"CANCELED":return Tt(PaymentEntityFailedBehavior);case"ACCEPTING_PAYMENTS":throw new Error("Status ACCEPTING_PAYMENTS should not happen");case"AUTHORIZED":case"ACTIVE":case"SUCCEEDED":return Tt(PaymentEntityPendingBehavior,e.world.paymentEntity.id);default:throw e.world.paymentEntity.entity,new Error(`Unknown payment entity status: ${e.world.paymentEntity.entity.status}`)}}(e):void 0)}(e):function(e){if(!e.channel||!e.world?.session)return;if(e.channelIsDigitalWallet)return;const n=function(e,n,t,i){t||(t={});for(const a of at(e,n.form,t,i))if(Un(a,t))return!1;return!0}(e.world.session.session_type,e.channel,e.channelProperties,e.channelData),t=Tt(n?ChannelValidBehavior:ChannelInvalidBehavior),i=Ae(e.channel.form,"credit_card_number")?Tt(CardInfoBehavior,e.channel.channel_code):void 0,a=Ae(e.channel.form,"installment_plan")?Tt(PaymentOptionsBehavior,e.channel.channel_code):void 0;return[t,i,a]}(e));case"COMPLETED":return Tt(SessionCompletedBehavior);case"EXPIRED":case"CANCELED":return Tt(SessionFailedBehavior,e.world.session.status);case"PENDING":return Tt(SessionPendingBehavior,e.world.session.status);default:throw e.world.session.status,new Error(`Unknown session status: ${e.world.session.status}`)}}(e));case"FATAL_ERROR":return Tt(SdkFatalErrorBehavior);default:throw e.sdkStatus,new Error(`Unknown SDK status: ${e.sdkStatus}`)}}function Oi(e){if(X(e.world?.paymentEntity),e.actionCompleted)return Tt(ActionCompletedBehavior);const n=ne(e.world.paymentEntity.entity.actions);if(!n)return Tt(ActionEmptyListPushNotificationBehavior,"");const t=e.world.paymentEntity.entity.actions.indexOf(n),i=!!te(e.sdk,e.world.paymentEntity.entity.actions);let a;switch(e.simulatePaymentRequested&&me(n)&&(a=Tt(SimulatePaymentBehavior)),n.type){case"REDIRECT_CUSTOMER":switch(n.descriptor){case"WEB_URL":return function(e){return"REDIRECT_CUSTOMER"===e.type&&!1!==e.iframe_capable}(n)?Tt(ActionIframeBehavior,n.value):i?Tt(ActionDeepLinkBehavior,String(t)):Tt(ActionRedirectBehavior,n.value);case"DEEPLINK_URL":return Tt(ActionDeepLinkBehavior,String(t));case"WEB_GOOGLE_PAYLINK":throw new Error("Paylink actions should not be the primary action")}break;case"PRESENT_TO_CUSTOMER":switch(n.descriptor){case"QR_STRING":return Tt(ActionQrBehavior,String(t),a);case"PAYMENT_CODE":throw new Error(`Unsupported action type ${n.type} ${n.descriptor}`);case"VIRTUAL_ACCOUNT_NUMBER":return Tt(ActionVaBehavior,String(t),a)}break;case"API_POST_REQUEST":switch(n.descriptor){case"CAPTURE_PAYMENT":case"VALIDATE_OTP":case"RESEND_OTP":throw new Error(`Unsupported action type ${n.type} ${n.descriptor}`)}}throw new Error(`Unknown action type: ${n.type} ${n.descriptor}`)}const qi=e=>{const{onReady:n,options:t}=e,i=$(),a=i.t,r=K(),s=(()=>{const e=c(M);if(null===e)throw new Error("useBusiness must be used within a XenditSessionProvider");return e})(),l=F(),p=l?.google_pay;X(p);const f=u(!1),b=u(null),y=u(null),_=m(()=>p.allowed_payment_methods.map(e=>e.payment_method_specification),[p.allowed_payment_methods]),g=m(()=>({apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:_,emailRequired:!0,merchantInfo:{merchantId:p.merchant_id,merchantName:s.name??""},transactionInfo:{transactionId:r.payment_session_id,totalPriceStatus:"FINAL",totalPrice:String(r.amount),currencyCode:r.currency}}),[s.name,p.merchant_id,_,r.amount,r.currency,r.payment_session_id]),x=m(()=>({buttonColor:"default",buttonType:"plain",buttonRadius:999,buttonSizeMode:"fill",buttonBorderType:"no_border",...t}),[t]);h(()=>{const e=window.google?.payments?.api?.PaymentsClient;e?y.current=new e({environment:i.isMock()?"TEST":"PRODUCTION"}):console.error("XenditComponents: Google Pay button was requested but the Google Pay SDK is not loaded.")},[i]);const v=d(()=>{X(y.current),y.current.loadPaymentData(g).then(function(e){const n=function(e){X(p);const n=i.getActiveChannels();for(const t of p.allowed_payment_methods)if(t.payment_method_specification.type===e.paymentMethodData.type)return Bi(n,t.channel_code);throw new Error(`No matching channel found for selected Google Pay payment method ${e.paymentMethodData.type}`)}(e);X(n);let t={};"CARDS"===n.channelCode&&(t={google_pay:JSON.stringify(e)}),i.submitDigitalWallet("GOOGLE_PAY",n,t)}).catch(function(e){const n=e.statusCode??"UNKNOWN_ERROR";if("CANCELED"===n)return;function t(e,n){return`google_pay_errors.${e.toLowerCase()}.${n}`}const r={code:`GOOGLE_PAY_${n}`,text:[a(t(n,"title"),a("google_pay_errors.unknown_error.title")),a(t(n,"message"),a("google_pay_errors.unknown_error.message",{statusCode:n}))]},o=p.allowed_payment_methods[0];X(o);const s=Bi(i.getActiveChannels(),o.channel_code);i.submitDigitalWallet("GOOGLE_PAY",s,{},r)})},[p,g,i,a]);return h(()=>{y.current&&(f.current||y.current.isReadyToPay({apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:_}).then(function(e){e.result&&(f.current||(f.current=!0,n()))}).catch(function(e){console.error("XenditComponents: Error when checking if Google Pay is ready",e)}))},[_,n]),h(()=>{if(!y.current)return;const e=y.current.createButton({...x,buttonLocale:r.locale,allowedPaymentMethods:_,onClick:v});b.current&&b.current.replaceChildren(e)},[x,_,v,r.locale]),o("div",{ref:b})};function Bi(e,n){const t=e.find(e=>Array.isArray(e.channelCode)?e.channelCode.includes(n):e.channelCode===n);if(!t)throw new Error(`Channel not found for code: ${n}`);return t}const Vi=e=>{const{scriptTagRegex:n,checkLoaded:t,children:i}=e,[,a]=p({}),r=t();return h(()=>{if(r)return;const e=Array.from(document.scripts).find(e=>n.test(e.src));if(e){const n=()=>{a({})};return e.addEventListener("load",n),()=>{e.removeEventListener("load",n)}}},[a,r,n]),h(()=>{if(!r){const e=setTimeout(()=>{a({})},1e3);return()=>clearTimeout(e)}}),r?i:null},Ki=e=>{const{digitalWalletCode:n,digitalWalletOptions:t}=e,i=u(null),a=d(()=>{i.current?.parentElement?.style.setProperty("display","block")},[]);let r=null;if("GOOGLE_PAY"===n)r=o(Vi,{scriptTagRegex:Wi.GOOGLE_PAY.scriptTagRegex,checkLoaded:Wi.GOOGLE_PAY.checkLoaded,children:o(qi,{onReady:a,options:t})});return o("div",{ref:i,children:r})},Wi={GOOGLE_PAY:{scriptTagRegex:/https:\/\/pay.google.com\/.*\/js\/pay.js/,checkLoaded:()=>"undefined"!=typeof google&&void 0!==google.payments}};class XenditComponents extends EventTarget{t=e=>{throw new Error("Localization used before initialization; this is a bug.")};[P];constructor(e){if(super(),"undefined"==typeof window||"undefined"==typeof document)throw new Error("XenditComponents can only be instantiated in a browser");const n=function(e){if(!e)throw new Error("The componentsSdkKey option is missing; check the constructor parameters.");const n=e.split("-");if(n.length<4||n[2]!==ie&&null===re(n[2]))throw new Error("The componentsSdkKey option has the wrong format. Ensure you pass the value returned from the `components_sdk_key` property of the `POST /sessions` response.");return{sessionAuthKey:[n[0],n[1]].join("-"),hostId:n[2],publicKey:n[3],signature:n[4]}}(e.componentsSdkKey);this[P]={sdkKey:n,options:e,worldState:null,liveComponents:{channelPicker:null,paymentChannels:new Map,actionContainer:null,digitalWalletContainer:new Map},behaviorTree:new BehaviorTree(Ui,{sdk:this,sdkKey:n,mock:this.isMock(),sdkStatus:"LOADING",sdkFatalErrorMessage:null,channel:null,channelProperties:null,channelData:null,channelIsDigitalWallet:!1,instantSubmissionError:null,dispatchEvent:this.dispatchEvent.bind(this),world:null,submissionRequested:!1,simulatePaymentRequested:!1,actionCompleted:!1,pollImmediatelyRequested:!1}),currentChannelCode:null,currentDigitalWalletSubmission:null,eventListenersPresent:new Map},Ce(this),this.addEventListener("fatal-error",e=>{const n=e;this[P].eventListenersPresent.get("fatal-error")||console.error(`XenditComponents: A "fatal-error" event occurred but no event listener was attached: ${n.message}`)}),this[P].eventListenersPresent.set("fatal-error",!1),this.behaviorTreeUpdate(),this.addEventListener(InternalUpdateWorldState.type,this.onUpdateWorldState.bind(this)),this.addEventListener(InternalUpdateChannelComponentData.type,this.onUpdateChannelComponentData.bind(this)),this.addEventListener(InternalBehaviorTreeUpdateEvent.type,this.behaviorTreeUpdate.bind(this));let t=!1;this.addEventListener(InternalNeedsRerenderEvent.type,()=>{t||(t=!0,queueMicrotask(()=>{t=!1,this.rerenderAllComponents(),this.syncInertAttribute()}))}),this.initializeAsync()}async initializeAsync(){let e;try{e=await Et(this[P].sdkKey,this[P].sdkKey.sessionAuthKey),e.channels=e.channels.filter(e=>Ee[e.channel_code])}catch(e){return this[P].behaviorTree.bb.sdkStatus="FATAL_ERROR",this[P].behaviorTree.bb.sdkFatalErrorMessage=fe(e),void this.behaviorTreeUpdate()}this.dispatchEvent(new InternalUpdateWorldState({business:e.business,customer:e.customer,session:e.session,channels:e.channels,channelUiGroups:e.channel_ui_groups,digitalWallets:e.digital_wallets??null,paymentEntity:null,sessionTokenRequestId:null,succeededChannel:null}))}assertInitialized(){if(!this[P].worldState)throw new Error("The session data is not loaded. Listen for the `init` event. Only `createChannelPickerComponent` can be called before initialization.")}isMock(){return!1}isProdLive(){return"pl"===this[P].sdkKey.hostId}supportsSimulationScenarios(){return this.isMock()||"pd"===this[P].sdkKey.hostId||"sd"===this[P].sdkKey.hostId}findChannel(e){this.assertInitialized();return this[P].worldState.channels.find(n=>n.channel_code===e)??null}onUpdateWorldState(e){const n=e.data;this[P].worldState=oe(this[P].worldState??{},n);const t=this[P].worldState.session.locale;this.t=function(e){const n=Tn[e];return function(...t){let i,a,r={};switch(t.length){case 1:i=t[0];break;case 2:"string"==typeof t[1]?(i=t[0],a=t[1]):(i=t[0],r=t[1]);break;case 3:i=t[0],a=t[1],r=t[2];break;default:throw new Error("Invalid arguments for t function")}let o=n?.[i];return void 0===o&&void 0!==a&&(o=a),o?o.replace(/\{\{(\w+)\}\}/g,(e,n)=>r[n]?String(r[n]):""):(console.warn(`Missing localization for key: ${i} in locale: ${e}`),i)}}(t),this.behaviorTreeUpdate(),this.rerenderAllComponents()}onUpdateChannelComponentData(e){const n=e.channelCode,t=e.data,i=this[P].liveComponents.paymentChannels.get(n);i&&(i.data=oe(i.data,t),this.behaviorTreeUpdate(),this.rerenderAllComponents())}behaviorTreeUpdate(){const e=this[P].behaviorTree.bb;if("LOADING"===e.sdkStatus&&this[P].worldState&&(e.sdkStatus="ACTIVE"),e.world=this[P].worldState,this[P].currentDigitalWalletSubmission)e.channel=this.findChannel(this[P].currentDigitalWalletSubmission.channelCode),e.channelProperties=this[P].currentDigitalWalletSubmission.channelProperties,e.channelData=null,e.channelIsDigitalWallet=!0,e.instantSubmissionError=this[P].currentDigitalWalletSubmission.instantSubmissionError;else{const n=this[P].currentChannelCode?this[P].liveComponents.paymentChannels.get(this[P].currentChannelCode):null;e.channel=n?ke(n.channel[P],n.data.savePaymentMethod):null,e.channelProperties=n?n.channelProperties:null,e.channelData=n?n.data:null,e.channelIsDigitalWallet=!1}try{this[P].behaviorTree.update()}catch(e){this[P].behaviorTree.bb.sdkStatus="FATAL_ERROR",this[P].behaviorTree.bb.sdkFatalErrorMessage=fe(e),this[P].behaviorTree.update()}}getSdkStatus(){return this[P].behaviorTree.bb.sdkStatus}rerenderAllComponents(){this.renderChannelPicker();for(const e of this[P].liveComponents.paymentChannels.keys())this.renderPaymentChannel(e);for(const e of this[P].liveComponents.digitalWalletContainer.keys())this.renderDigitalWalletComponent(e)}getSession(){return this.assertInitialized(),Ue(this[P].worldState.session)}getCustomer(){return this.assertInitialized(),this[P].worldState.customer?(Q((e=this[P].worldState.customer).type,"INDIVIDUAL"),X(e.individual_detail),{id:e.id,type:e.type,email:e.email??void 0,mobileNumber:e.mobile_number??void 0,individualDetail:{givenNames:e.individual_detail.given_names??void 0,surname:e.individual_detail.surname??void 0}}):null;var e}getActiveChannelGroups(e){return this.assertInitialized(),function(e,n,t){const i=Ve(n),a=We(e,t);return n.filter(e=>a[e.id]?.length).map(e=>Oe(e,a,i,t))}(this[P].worldState.channels,this[P].worldState.channelUiGroups,{options:{filter:e?.filter,filterMinMax:e?.filterMinMax??!0},session:this[P].worldState.session,pairChannels:Fe(this[P].worldState.channels)})}getActiveChannels(e){return this.assertInitialized(),function(e,n,t){const i=Ve(n),a=We(e,t);return e.filter(e=>Ke(e,t)).map(e=>Be(e,a,i,t))}(this[P].worldState.channels,this[P].worldState.channelUiGroups,{options:{filter:e?.filter,filterMinMax:e?.filterMinMax??!0},session:this[P].worldState.session,pairChannels:Fe(this[P].worldState.channels)})}createChannelPickerComponent(){this[P].liveComponents.channelPicker&&this.destroyComponent(this[P].liveComponents.channelPicker);const e=document.createElement("xendit-channel-picker");return e.setAttribute("translate","no"),this[P].liveComponents.channelPicker=e,this[P].worldState&&this.renderChannelPicker(),this.setupUiEventsForChannelPicker(e),e}renderChannelPicker(){this.assertInitialized();const e=this[P].liveComponents.channelPicker;e&&t(i(z,{data:this[P].worldState,sdk:this,children:i(Xe,{})}),e)}setupUiEventsForChannelPicker(e){e.addEventListener(XenditClearCurrentChannelEvent.type,e=>{this.assertInitialized();const n=e,t=this[P].currentChannelCode;if(!t)return;const i=this[P].worldState.channels.find(e=>e.channel_code===t);i&&i.ui_group===n.uiGroup&&this.setCurrentChannel(null)})}createChannelComponent(e,n=!0){if(this.assertInitialized(),!we(this[P].worldState.session,e[P][0]))throw new Error("Cannot create channel component: `session.amount` is outside of the channel's min/max amount.");const t=e[P][0].channel_code;n&&(this[P].currentChannelCode=t);const i=this[P].liveComponents.paymentChannels.get(t);let a,o=r();return i?(a=i.element,o=i.channelFormRef):(a=document.createElement("xendit-payment-channel"),a.setAttribute("data-channel-code",t),a.setAttribute("inert",""),a.setAttribute("translate","no"),a.style.setProperty("--xendit-channel-brand-color",e[P][0].brand_color),this.setupUiEventsForPaymentChannel(a),this[P].liveComponents.paymentChannels.set(t,{element:a,channel:e,channelProperties:null,channelFormRef:o,data:{savePaymentMethod:!1,cardDetails:null,paymentOptions:null}})),this.renderPaymentChannel(t),n&&(this.behaviorTreeUpdate(),this.syncInertAttribute()),this.dispatchEvent(new InternalNeedsRerenderEvent),a}renderPaymentChannel(e){this.assertInitialized();const n=this[P].liveComponents.paymentChannels.get(e);if(!n)return;const a=n.channel;t(i(z,{data:this[P].worldState,sdk:this,children:i(xt,{channelOrPair:a[P],channelData:n.data,savePaymentMethod:n.data.savePaymentMethod,formRef:n.channelFormRef})}),n.element)}getActiveDigitalWallets(){return this.assertInitialized(),this[P].worldState.digitalWallets?function(e,n,t,i){const a=[],r=Ve(t);if(e.google_pay){const t=e.google_pay.allowed_payment_methods.map(e=>{const t=n.find(n=>n.channel_code===e.channel_code);return X(t),t}),o=We(t,i);a.push({digitalWalletCode:"GOOGLE_PAY",get channels(){return t.map(e=>Be(e,o,r,i))},[P]:!0})}return a}(this[P].worldState.digitalWallets,this[P].worldState.channels,this[P].worldState.channelUiGroups,{options:{filterMinMax:!1},pairChannels:Fe(this[P].worldState.channels),session:this[P].worldState.session}):[]}createDigitalWalletComponent(e,n){this.assertInitialized();const t=this[P].liveComponents.digitalWalletContainer.get(e);t&&this.destroyComponent(t.element);const i=document.createElement("xendit-digital-wallet");return i.setAttribute("translate","no"),i.style.setProperty("display","none"),this[P].liveComponents.digitalWalletContainer.set(e,{element:i,options:n}),this.renderDigitalWalletComponent(e),i}renderDigitalWalletComponent(e){this.assertInitialized();const n=this[P].liveComponents.digitalWalletContainer.get(e);n&&t(i(z,{data:this[P].worldState,sdk:this,children:i(Ki,{digitalWalletCode:e,digitalWalletOptions:n.options})}),n.element)}getCurrentChannel(){const e=this[P].currentChannelCode;return e?this.getActiveChannels().find(n=>{if(n.channelCode===e||Array.isArray(n.channelCode)&&n.channelCode.includes(e))return!0})??null:null}setCurrentChannel(e){const n=this[P].currentChannelCode,t=e?.[P][0].channel_code??null;if(n===t)return;this[P].currentChannelCode=t;let i=null;e&&t&&(i=this[P].liveComponents.paymentChannels.get(t)??null,i||(this.createChannelComponent(e,!1),i=this[P].liveComponents.paymentChannels.get(t)??null)),this.behaviorTreeUpdate(),this.syncInertAttribute(),this.renderChannelPicker()}syncInertAttribute(){const e=this[P].behaviorTree.bb.submissionRequested,n=this[P].liveComponents.paymentChannels;for(const[t,i]of n){(Array.isArray(i.channel.channelCode)?i.channel.channelCode[0]:i.channel.channelCode)!==this[P].currentChannelCode||e?i.element.setAttribute("inert",""):i.element.hasAttribute("inert")&&i.element.removeAttribute("inert")}}setupUiEventsForPaymentChannel(e){e.addEventListener(XenditChannelPropertiesChangedEvent.type,e=>{const n=e,t=n.channel,i=this[P].liveComponents.paymentChannels.get(t);i&&(i.channelProperties=n.channelProperties,this.behaviorTreeUpdate())})}showValidationErrors(){if(!this[P].behaviorTree.findBehavior(ChannelInvalidBehavior))return;const e=this[P].currentChannelCode;if(!e)return;const n=this[P].liveComponents.paymentChannels.get(e);if(!n)throw new Error("Current channel is set but component is missing; this is a bug, please contact support.");const t=n.channelFormRef.current;t?.setAllFieldsTouched()}createActionContainerComponent(e){this.assertInitialized(),this[P].liveComponents.actionContainer&&this.destroyComponent(this[P].liveComponents.actionContainer);const n=e===P,t=n?void 0:e,i=this[P].behaviorTree.findBehavior(PaymentEntityRequiresActionBehavior);if(!n&&i&&!i.canCreateActionContainer)throw new Error("Unable to create action container; there is an action in progress. Create an action before or during the `action-begin` event.");const a=document.createElement("xendit-action-container");return a.setAttribute("translate","no"),t?.qrCode&&void 0!==t.qrCode.qrCodeOnly&&a.setAttribute("data-qr-code-only",t.qrCode.qrCodeOnly.toString()),this[P].liveComponents.actionContainer=a,a}destroyComponent(e){if(!e.tagName.startsWith("XENDIT-"))throw new Error("Unable to destroy component; only elements created by this SDK can be destroyed.");if(this[P].liveComponents.channelPicker===e)return this[P].liveComponents.channelPicker=null,t(null,e),void e.remove();for(const[n,i]of this[P].liveComponents.paymentChannels)if(i.element===e)return this[P].liveComponents.paymentChannels.delete(n),this[P].currentChannelCode===n&&this.setCurrentChannel(null),t(null,e),void e.remove();if(this[P].liveComponents.actionContainer===e)return this[P].liveComponents.actionContainer=null,t(null,e),void e.remove();for(const[n,i]of this[P].liveComponents.digitalWalletContainer)if(i.element===e)return this[P].liveComponents.digitalWalletContainer.delete(n),t(null,e),void e.remove();throw new Error("Unable to destroy component; component not found. It may have already been destroyed.")}submit(){this.assertInitialized();if(!this[P].behaviorTree.findBehavior(SessionActiveBehavior))throw new Error("Unable to submit; the session is not in the active state. Listen to the `session-complete` and `session-expired-or-canceled` events and display success or failure states accordingly.");const e=this[P].currentChannelCode;if(!e)throw new Error("Unable to submit; there is no current payment channel. Create a payment component with `createChannelComponent` or make an existing one active with `setCurrentChannel`.");if(!this[P].liveComponents.paymentChannels.get(e))throw new Error("Current channel is set but component is missing; this is a bug, please contact support.");this.showValidationErrors();if(this[P].behaviorTree.findBehavior(ChannelInvalidBehavior))throw new Error("Unable to submit; the form for the current channel has errors. Listen to the `submission-ready` and `submission-not-ready` events, do not allow submission while in the not-ready state.");if(!this[P].behaviorTree.findBehavior(ChannelValidBehavior))throw new Error("Unable to submit; the SDK is not in a valid state for submission. Listen to the `submission-ready` and `submission-not-ready` events, do not allow submission while in the not-ready state.");this[P].behaviorTree.bb.submissionRequested=!0,this.behaviorTreeUpdate(),this.syncInertAttribute()}submitDigitalWallet(e,n,t,i=null){this.assertInitialized(),this.setCurrentChannel(null),this[P].currentDigitalWalletSubmission={digitalWalletCode:e,channelCode:n[P][0].channel_code,channelProperties:t,instantSubmissionError:i},this.addEventListener(XenditSubmissionEndEvent.type,()=>{this[P].currentDigitalWalletSubmission=null},{once:!0}),this[P].behaviorTree.bb.submissionRequested=!0,this.behaviorTreeUpdate(),this.syncInertAttribute()}abortSubmission(){this.assertInitialized();this[P].behaviorTree.findBehavior(SubmissionBehavior)&&(this[P].behaviorTree.bb.submissionRequested=!1,this.behaviorTreeUpdate())}simulatePayment(){if(this.assertInitialized(),"PAY"!==this[P].worldState.session.session_type)throw new Error('Unable to simulate payment, the session type is not "PAY".');if(!this[P].behaviorTree.findBehavior(PaymentEntityRequiresActionBehavior))throw new Error("Unable to simulate payment; there is no action in progress. You can simulate payments any time between the `action-begin` and `action-end` events.");const e=this[P].worldState.paymentEntity;if(!e)throw new Error("The PeRequiresActionBehavior is present but there is no payment entity. This is a bug, please contact support.");if(!this.findChannel(e.entity.channel_code))throw new Error("Channel not found; this is a bug, please contact support.");const n=ne(e.entity.actions);if(!n||!me(n))throw new Error("Unable to simulate payment; the action does not support simulation.");this[P].behaviorTree.bb.simulatePaymentRequested=!0,this.behaviorTreeUpdate()}pollImmediately(){if(this.assertInitialized(),"ACTIVE"!==this[P].worldState.session.status)throw new Error("Unable to poll immediately; the session is not longer active.");this[P].behaviorTree.bb.pollImmediatelyRequested=!0,this.behaviorTreeUpdate()}getState(){const e=this[P].currentChannelCode,n=this[P].liveComponents.paymentChannels.get(e??"");return{channelCode:e,channelProperties:n?.channelProperties||null,behaviorTree:this[P].behaviorTree}}addEventListener(e,n,t){return this[P].eventListenersPresent.set(e,!0),super.addEventListener(e,n,t)}removeEventListener(e,n,t){return super.removeEventListener(e,n,t)}static amountFormat(e,n){return Pn(e,n)}}class XenditComponentsTest extends XenditComponents{nextMockUpdate=null;constructor(e){super({...e,componentsSdkKey:`session-${ue(32)}-mock-MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEyCADI5pdf6KmN8+Fxl2ES3yolUKXunNeY3gGScGNEvDcrcHAPKxIInAo5DVnDvTtYtqZvx/bu7HLeBJNMXwHhie/uyNEtT8dSaLc9bd0WSlYdxI+iUsTv2Qu0LiiPrZs-NKf7whM9meUs/eRCvG0oc180MDiyeli3kH6EQ3ZahECHsZQi5G2IpH6vk3cYMtf01Y1L4OBn1SZCOv1kwpjIUet4DJeoTwwq2nM5b+K7rD+/WFTi3AEX4NWJNkKi0a91`}),this.addEventListener(InternalScheduleMockUpdateEvent.type,this.setNextMockUpdate.bind(this))}async initializeAsync(){await Z(H);const e=(await import("./test-data.mjs")).makeTestBffData();this.dispatchEvent(new InternalUpdateWorldState({business:e.business,customer:e.customer,session:e.session,channels:e.channels,channelUiGroups:e.channel_ui_groups,digitalWallets:e.digital_wallets??null,paymentEntity:null,sessionTokenRequestId:null,succeededChannel:null}))}isMock(){return!0}setNextMockUpdate(e){const n=e;this.nextMockUpdate=n.mockData}}"undefined"==typeof window||"undefined"==typeof document||(N||(N=!0,e.debounceRendering=e=>queueMicrotask(e)),function(){const e=document.createElement("style");e.textContent="/* variables */\n:root {\n --xendit-font-family: sans-serif;\n --xendit-color-primary: #1762ee;\n --xendit-color-text: #252525;\n --xendit-color-text-secondary: #585858;\n --xendit-color-text-placeholder: #7d7d7d;\n --xendit-color-disabled: #f7f7f7;\n --xendit-color-danger: #d1414d;\n --xendit-color-border: #f3f3f3;\n --xendit-color-background: #ffffff;\n --xendit-focus-shadow: 0px 0px 0px 2px\n color-mix(in srgb, var(--xendit-color-primary) 15%, transparent);\n --xendit-card-shadow: 0px 4px 8px 0px #25252514;\n --xendit-dialog-shadow: 8px 8px 12px 8px #25252529;\n --xendit-animation-duration: 0.3s;\n --xendit-animation-ease: ease-in-out;\n --xendit-radius-1: 8px;\n --xendit-z-index-focus: 2;\n --xendit-z-index-overlay: 3;\n\n /* Browser-specific border collapse margins */\n --xendit-border-collapse-offset: -0.5px; /* Default for Chrome/Edge */\n --xendit-border-collapse-webkit-gecko: -1.5px; /* Fix Safari and Firefox subpixel rendering */\n\n /* QR code colors */\n --xendit-qr-foreground-color: #000000;\n --xendit-qr-background-color: #ffffff;\n\n /* icon colors */\n --xendit-color-icon-primary: #7c7c7c;\n --xendit-color-icon-secondary: #f1f1f1;\n}\n\n/* Set default font for root components */\nxendit-channel-picker,\nxendit-action-container,\nxendit-payment-channel {\n display: block;\n unicode-bidi: isolate;\n font-family: var(--xendit-font-family);\n color: var(--xendit-color-text);\n touch-action: manipulation;\n}\n\n.xendit-default-action-container {\n font-family: var(--xendit-font-family);\n touch-action: manipulation;\n}\n\nxendit-action-container {\n position: relative;\n flex: 1; /* Action container usually wants to stretch to fit, assuming the parent is a flexbox. */\n touch-action: manipulation;\n}\n\nxendit-payment-channel button,\nxendit-payment-channel textarea,\nxendit-payment-channel select,\nxendit-payment-channel input,\nxendit-payment-channel input::placeholder {\n font-family: inherit;\n}\n\nxendit-payment-channel input::placeholder,\nxendit-payment-channel textarea::placeholder,\nxendit-payment-channel select::placeholder {\n color: var(--xendit-color-text-placeholder);\n}\n\n/* Reusable typography classes */\n.xendit-text-12 {\n font-size: 12px;\n line-height: 16px;\n letter-spacing: -0.01px;\n}\n\n.xendit-text-14 {\n font-size: 14px;\n line-height: 16px;\n letter-spacing: -0.09px;\n}\n\n.xendit-text-16 {\n font-size: 16px;\n line-height: 16px;\n letter-spacing: -0.09px;\n}\n\n.xendit-text-18 {\n font-size: 18px;\n line-height: 24px;\n letter-spacing: -0.26px;\n}\n\n.xendit-text-20 {\n font-size: 20px;\n line-height: 28px;\n letter-spacing: -0.33px;\n}\n\n.xendit-text-12,\n.xendit-text-14,\n.xendit-text-16 {\n font-weight: 400;\n}\n\n.xendit-text-semibold {\n font-weight: 600;\n}\n\n.xendit-text-bold {\n font-weight: 700;\n}\n\n.xendit-text-link {\n color: var(--xendit-color-primary);\n}\n.xendit-text-secondary {\n color: var(--xendit-color-text-secondary);\n}\n\n.xendit-text-center {\n text-align: center;\n}\n\n.xendit-dotted-line {\n height: 1px;\n border: none;\n background: repeating-linear-gradient(\n to right,\n var(--xendit-color-border) 0px 4px,\n transparent 4px 8px\n );\n margin: 0;\n}\n\n/* Accordion component */\n\n.xendit-accordion {\n display: flex;\n flex-direction: column;\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n background: var(--xendit-color-background);\n}\n\n.xendit-accordion-item:not(:first-child) {\n border-top: 1px solid var(--xendit-color-border);\n border-top-left-radius: var(--xendit-radius-1);\n border-top-right-radius: var(--xendit-radius-1);\n}\n\n.xendit-accordion-item-header {\n display: grid;\n grid-template-columns: auto 1fr auto;\n grid-gap: 16px;\n align-items: center;\n cursor: pointer;\n padding: 24px 16px;\n color: var(--xendit-color-text);\n border-radius: 8px;\n}\n\n.xendit-accordion-item-disabled .xendit-accordion-item-header {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.xendit-accordion-item-header-title {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.xendit-accordion-item-disabled .xendit-accordion-item-header-title,\n.xendit-accordion-item-disabled .xendit-accordion-item-header-icon {\n opacity: 0.5;\n}\n\n.xendit-accordion-item.xendit-accordion-item-open\n .xendit-accordion-item-header {\n color: var(--xendit-color-primary);\n}\n\n.xendit-accordion-item-chevron {\n color: var(--xendit-color-text);\n}\n\n.xendit-accordion-item-disabled .xendit-accordion-item-chevron {\n display: none;\n}\n\n.xendit-accordion-item-chevron g {\n transition: transform var(--xendit-animation-duration)\n var(--xendit-animation-ease);\n}\n\n.xendit-accordion-item-header:focus-visible {\n border-radius: 8px;\n box-shadow: var(--xendit-focus-shadow);\n outline: none;\n}\n\n.xendit-accordion-item-content {\n overflow: hidden;\n transition: height var(--xendit-animation-duration)\n var(--xendit-animation-ease);\n}\n\n.xendit-accordion-item.xendit-accordion-item-closed\n .xendit-accordion-item-content {\n height: 0;\n}\n\n.xendit-accordion-item.xendit-accordion-item-open\n .xendit-accordion-item-content {\n height: calc-size(auto, size);\n}\n\n.xendit-accordion-item-padding {\n padding: 16px;\n}\n\n/* Channel picker digital wallet section */\n\n.xendit-channel-picker-digital-wallet-section {\n display: grid;\n grid-auto-flow: column;\n grid-auto-columns: 1fr;\n gap: 8px;\n margin-bottom: 8px;\n}\n\n/* Channel picker group */\n\n.xendit-channel-picker-group {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n.xendit-channel-picker-group select {\n border: 1px solid var(--xendit-color-border);\n border-radius: 8px;\n padding: 12px;\n appearance: none;\n outline: none;\n}\n\n.xendit-channel-picker-group select:focus {\n box-shadow: var(--xendit-focus-shadow);\n}\n\n.xendit-channel-logo {\n width: 24px;\n height: 16px;\n margin: -5px 0;\n padding: 4px;\n border: 1px solid var(--xendit-color-border);\n border-radius: 4px;\n background-color: white; /* always white, not --xendit-color-background */\n object-fit: contain;\n}\n\n/* Payment channel */\n\nxendit-payment-channel[inert] {\n filter: opacity(0.5) grayscale(1);\n}\n\n.xendit-payment-channel {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n.xendit-payment-channel-banner {\n width: 100%;\n height: auto;\n object-fit: contain;\n}\n\n.xendit-payment-channel-instructions {\n display: grid;\n grid-template-columns: auto 1fr;\n grid-gap: 12px;\n color: var(--xendit-color-text-secondary);\n}\n\n.xendit-payment-channel-instructions-logo {\n height: 40px;\n width: auto;\n object-fit: contain;\n}\n\n.xendit-payment-channel-instructions-text {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 4px;\n}\n\n.xendit-payment-channel-instructions-text p {\n margin: 0;\n}\n\n/* Forms */\n\n.xendit-channel-form {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n.xendit-channel-form > form {\n display: contents;\n}\n\n.xendit-form-field-group {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n\n.xendit-channel-form-field {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.xendit-channel-form-field-group {\n display: grid;\n gap: 8px;\n}\n\n.xendit-channel-form-field-group-label-container {\n display: flex;\n justify-content: space-between;\n gap: 16px;\n}\n\n.xendit-channel-form-field-group label {\n width: fit-content;\n cursor: pointer;\n}\n\n.xendit-form-field-group.invalid\n .xendit-channel-form-field\n .xendit-form-field-inner {\n border: 1px solid var(--xendit-color-danger);\n}\n\n.xendit-channel-form-field .xendit-form-field-inner {\n border: 1px solid var(--xendit-color-border);\n background: var(--xendit-color-background);\n border-radius: 8px;\n appearance: none;\n}\n\n.xendit-channel-form-field.field-radius-tl-0 .xendit-form-field-inner {\n border-top-left-radius: 0;\n}\n\n.xendit-channel-form-field.field-radius-tr-0 .xendit-form-field-inner {\n border-top-right-radius: 0;\n}\n\n.xendit-channel-form-field.field-radius-bl-0 .xendit-form-field-inner {\n border-bottom-left-radius: 0;\n}\n\n.xendit-channel-form-field.field-radius-br-0 .xendit-form-field-inner {\n border-bottom-right-radius: 0;\n}\n\n.xendit-channel-form-field.field-collapse-l,\n.xendit-channel-form-field.field-collapse-l {\n margin-left: var(--xendit-border-collapse-offset);\n}\n\n.xendit-channel-form-field.field-collapse-r,\n.xendit-channel-form-field.field-collapse-r {\n margin-right: var(--xendit-border-collapse-offset);\n}\n\n.xendit-channel-form-field.field-collapse-l .xendit-iframe-container {\n margin-left: calc(var(--xendit-border-collapse-offset) * 2);\n width: calc(100% + abs(var(--xendit-border-collapse-offset) * 2));\n}\n\n.xendit-channel-form-field.field-collapse-r .xendit-iframe-container {\n margin-right: 0;\n}\n\n.xendit-channel-form-field.field-collapse-t .xendit-form-field-inner {\n margin-top: var(--xendit-border-collapse-offset);\n}\n\n.xendit-channel-form-field.field-collapse-b .xendit-form-field-inner {\n margin-bottom: var(--xendit-border-collapse-offset);\n}\n\n/* Safari and Firefox specific adjustments */\n@supports (font: -apple-system-body) or (-moz-appearance: none) {\n .xendit-channel-form-field.field-collapse-l .xendit-iframe-container {\n margin-left: 0;\n width: 100%;\n }\n\n .xendit-channel-form-field.field-collapse-b input,\n .xendit-channel-form-field.field-collapse-b button {\n margin-bottom: var(--xendit-border-collapse-webkit-gecko);\n height: calc(100% + abs(var(--xendit-border-collapse-webkit-gecko) * 2));\n }\n}\n\n.xendit-channel-form-field.field-collapse-r .xendit-iframe-container:focus {\n border-right: none;\n}\n\n.xendit-channel-form-field.field-collapse-l .xendit-iframe-container:focus {\n border-left: none;\n}\n\n.xendit-card-brand-logo {\n width: 24px;\n height: 16px;\n border: 1px solid var(--xendit-color-border);\n border-radius: 4px;\n padding: 4px;\n background-color: white; /* always white, not --xendit-color-background */\n}\n\n.xendit-card-brands-list {\n display: flex;\n align-items: center;\n padding: 8px 12px;\n gap: 4px;\n}\n\n.xendit-channel-form-field .xendit-form-field-inner:focus,\n.xendit-channel-form-field .xendit-form-field-inner.xendit-field-focus {\n border-color: var(--xendit-color-primary);\n box-shadow: var(--xendit-focus-shadow);\n outline: none;\n z-index: var(--xendit-z-index-focus);\n position: relative;\n}\n\n.xendit-channel-form-field button.xendit-dropdown-open {\n z-index: var(--xendit-z-index-focus);\n}\n\n.xendit-channel-form-field input.xendit-form-field-inner {\n padding: 12px;\n}\n\n.xendit-channel-form-field .xendit-iframe-container {\n height: 40px;\n width: 100%;\n padding: 0;\n overflow: hidden;\n box-sizing: border-box;\n}\n\n.xendit-channel-form-field .xendit-iframe-container iframe {\n height: 40px;\n width: 100%;\n border: none;\n min-width: 0;\n}\n\n.xendit-channel-form-field.xendit-form-field-span-1 {\n grid-column: span 1;\n}\n\n.xendit-channel-form-field.xendit-form-field-span-2 {\n grid-column: span 2;\n}\n\n.xendit-checkbox {\n display: flex;\n align-items: center;\n}\n\n.xendit-checkbox-box {\n display: flex;\n}\n\n.xendit-checkbox input {\n width: 16px;\n height: 16px;\n margin: 0;\n cursor: pointer;\n}\n\n.xendit-checkbox label {\n cursor: pointer;\n padding-left: 8px;\n}\n\n.xendit-checkbox input {\n opacity: 0;\n position: absolute;\n}\n\n.xendit-checkbox input + .xendit-checkbox-graphic {\n width: 16px;\n height: 16px;\n border: 1px solid var(--xendit-color-border);\n border-radius: 4px;\n box-sizing: border-box;\n color: transparent;\n}\n\n.xendit-checkbox input:checked + .xendit-checkbox-graphic {\n color: var(--xendit-color-background);\n background-color: var(--xendit-color-primary);\n border-color: var(--xendit-color-primary);\n}\n\n.xendit-checkbox input:focus + .xendit-checkbox-graphic {\n border: 1px solid var(--xendit-color-primary);\n box-shadow: var(--xendit-focus-shadow);\n}\n\n/* Dialog */\n\n.xendit-dialog-backdrop {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n padding: 48px;\n justify-content: center;\n align-items: center;\n}\n\n.xendit-dialog {\n position: relative;\n}\n\n.xendit-dialog.xendit-dialog-with-background {\n background-color: var(--xendit-color-background);\n border-radius: 8px;\n box-shadow: var(--xendit-dialog-shadow);\n}\n\n.xendit-dialog-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n color: var(--xendit-color-text);\n padding: 16px;\n gap: 16px;\n line-height: 20px;\n border-bottom: 1px solid var(--xendit-color-border);\n}\n\n.xendit-dialog-header button {\n display: flex;\n background: none;\n border: none;\n color: var(--xendit-color-text);\n cursor: pointer;\n padding: 0;\n}\n\n.xendit-dialog-floating-close {\n position: absolute;\n top: 24px;\n right: 24px;\n display: flex;\n background: none;\n border: none;\n color: var(--xendit-color-text);\n cursor: pointer;\n padding: 0;\n}\n\n.xendit-dialog-body {\n display: flex;\n padding: 24px;\n}\n\n.xendit-error-message {\n color: var(--xendit-color-danger);\n}\n\n/* Phone input Dropdown */\n.xendit-input-phone {\n display: flex;\n gap: 8px;\n}\n\n.xendit-phone-number-input {\n width: 100%;\n}\n\n/* Phone input Dropdown ends */\n\n/* Dropdown */\n.xendit-dropdown {\n width: 100%;\n display: grid;\n grid-template-columns: 1fr auto;\n align-items: center;\n text-align: left;\n background-color: var(--xendit-color-background);\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n justify-content: space-between;\n cursor: pointer;\n padding: 0;\n padding-left: 12px;\n outline: none;\n}\n\n.xendit-dropdown:focus {\n border-color: var(--xendit-color-primary);\n box-shadow: var(--xendit-focus-shadow);\n outline: none;\n z-index: var(--xendit-z-index-focus);\n position: relative;\n}\n\n.xendit-dropdown.xendit-dropdown-has-asset {\n grid-template-columns: auto 1fr auto;\n}\n\n.xendit-dropdown-channel-logo {\n height: 24px;\n width: 32px;\n object-fit: contain;\n padding: 2px 0px;\n padding-right: 12px;\n border-right: 1px solid var(--xendit-color-border);\n}\n\n.xendit-dropdown-text {\n padding: 12px;\n padding-right: 0;\n}\n\n.xendit-dropdown-chevron {\n height: 38px;\n width: 38px;\n padding: 12px;\n box-sizing: border-box;\n}\n\n.xendit-dropdown:disabled {\n background: var(--xendit-color-disabled);\n cursor: default;\n}\n\n.xendit-dropdown-overlay {\n contain: style;\n position: absolute;\n z-index: var(--xendit-z-index-overlay);\n display: flex;\n flex-direction: column;\n gap: 4px;\n max-height: 320px;\n padding: 4px;\n margin: 4px 0;\n box-sizing: border-box;\n background-color: var(--xendit-color-background);\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n list-style: none;\n box-shadow: var(--xendit-card-shadow);\n overflow-y: auto;\n overscroll-behavior: none;\n}\n\n.xendit-dropdown-overlay ul {\n list-style: none;\n padding: 4px;\n margin: 0;\n}\n\n.xendit-dropdown-search {\n position: sticky;\n top: 0;\n z-index: 1;\n}\n\n.xendit-dropdown-search input {\n width: 100%;\n padding: 8px;\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n box-sizing: border-box;\n outline: none;\n}\n\n.xendit-dropdown-search input:focus {\n border-color: var(--xendit-color-primary);\n box-shadow: var(--xendit-focus-shadow);\n}\n\n.xendit-dropdown-item {\n display: grid;\n grid-template-columns: 1fr auto;\n align-items: center;\n gap: 8px;\n padding: 8px 12px 8px 4px;\n border-radius: var(--xendit-radius-1);\n cursor: pointer;\n z-index: 0;\n --xendit-dropdown-item-hover-color: var(--xendit-color-background);\n --xendit-dropdown-item-hover-bg-color: var(--xendit-color-primary);\n}\n\n.xendit-dropdown-item-disabled {\n --xendit-dropdown-item-hover-color: var(--xendit-color-text);\n --xendit-dropdown-item-hover-bg-color: var(--xendit-color-disabled);\n}\n\n.xendit-dropdown-item-active {\n box-shadow: var(--xendit-focus-shadow);\n}\n\n.xendit-dropdown-item:hover {\n background-color: var(--xendit-dropdown-item-hover-bg-color);\n}\n\n.xendit-dropdown-item:hover .xendit-dropdown-item-text,\n.xendit-dropdown-item:hover .xendit-dropdown-item-description {\n color: var(--xendit-dropdown-item-hover-color);\n}\n\n.xendit-dropdown-item-selected {\n color: var(--xendit-color-primary);\n}\n\n.xendit-dropdown-item:hover .xendit-dropdown-item-selected {\n color: var(--xendit-dropdown-item-hover-color);\n}\n\n.xendit-dropdown-item.xendit-dropdown-has-asset {\n grid-template-columns: auto 1fr auto;\n}\n\n.xendit-dropdown-item-text {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.xendit-dropdown-item-disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n\n.xendit-dropdown-item-disabled:hover,\n.xendit-dropdown-item-disabled.xendit-dropdown-item-active {\n background-color: var(--xendit-color-disabled);\n}\n\n/* Dropdown ends */\n\n/* Button */\n.xendit-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 12px 16px;\n font-family: var(--xendit-font-family);\n font-size: 14px;\n font-weight: 600;\n line-height: 16px;\n letter-spacing: -0.09px;\n cursor: pointer;\n transition: background-color var(--xendit-animation-duration)\n var(--xendit-animation-ease);\n}\n.xendit-button-primary-rounded {\n border: 1px solid transparent;\n background-color: var(--xendit-color-primary);\n color: var(--xendit-color-background);\n border-radius: var(--xendit-radius-1);\n}\n.xendit-button-white-rounded {\n background-color: var(--xendit-color-background);\n color: var(--xendit-color-text);\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n}\n.xendit-button-white-rounded:hover {\n background-color: var(--xendit-color-border);\n}\n.xendit-button-block {\n width: 100%;\n}\n.xendit-button-sm {\n padding: 8px 12px;\n font-size: 12px;\n line-height: 16px;\n}\n\n@keyframes xendit-button-loading-spinner-spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.xendit-button-loading-spinner {\n width: 16px;\n height: 16px;\n animation: xendit-button-loading-spinner-spin 1s linear infinite;\n}\n\n.xendit-skeleton-field button {\n height: 42px;\n background-color: var(--xendit-color-disabled);\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--xendit-color-text-secondary);\n}\n\n/* Button ends */\n\n/* Form Simulation Helper */\n.xendit-form-simulation-root {\n position: relative;\n}\n.xendit-form-simulation-trigger {\n background: transparent;\n border: none;\n cursor: pointer;\n padding: 0;\n}\n.xendit-form-simulation-popover {\n position: absolute;\n top: 100%;\n right: 0;\n\n width: 350px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n border-radius: 4px;\n padding: 12px;\n border: 1px solid var(--xendit-color-border);\n background: color-mix(\n in srgb,\n var(--xendit-color-background),\n transparent 40%\n );\n backdrop-filter: blur(6px);\n box-shadow: var(--xendit-card-shadow);\n}\n\n.xendit-form-simulation-popover .xendit-dropdown-overlay {\n width: auto;\n}\n\n.xendit-form-simulation-scenario-icon {\n height: 28px;\n width: 40px;\n border-radius: 4px;\n border: 1px solid var(--xendit-color-border);\n object-fit: contain;\n background-color: white;\n}\n\n/* Form Simulation Helper ends */\n\n.xendit-tooltip {\n position: absolute;\n top: 100%;\n right: 50%;\n transform: translateX(50%);\n background-color: black;\n color: white;\n padding: 8px 12px;\n border-radius: var(--xendit-radius-1);\n white-space: nowrap;\n z-index: 1000;\n font-weight: 600;\n font-size: 14px;\n line-height: 16px;\n animation: xendit-tooltip-fade-in var(--xendit-animation-duration)\n var(--xendit-animation-ease);\n opacity: 1;\n}\n\n@keyframes xendit-tooltip-fade-in {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n/* Instructions */\n\n.xendit-instructions-bold {\n font-weight: 600;\n}\n.xendit-instructions-bullet-list {\n display: flex;\n flex-direction: column;\n gap: 12px;\n margin: 8px 0;\n}\n.xendit-instructions-bullet-list::marker {\n color: var(--xendit-color-text-secondary);\n}\n.xendit-instructions-form-card {\n display: flex;\n flex-direction: column;\n padding: 16px;\n border-radius: 12px;\n border: 1px solid var(--xendit-color-border);\n gap: 4px;\n width: 321px;\n}\n.xendit-instructions-form-field {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 8px 0;\n border-bottom: 1px solid var(--xendit-color-border);\n}\n.xendit-instructions-form-field-label {\n font-size: 12px;\n font-weight: 600;\n line-height: 16px;\n color: var(--xendit-color-text-secondary);\n}\n.xendit-instructions-form-field-value {\n font-size: 14px;\n line-height: 20px;\n color: var(--xendit-color-text);\n}\n.xendit-instructions-form-heading {\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n margin: 4px 0;\n}\n.xendit-instructions-italics {\n font-style: italic;\n}\n.xendit-instructions-numbered-list {\n display: flex;\n flex-direction: column;\n gap: 16px;\n list-style-type: decimal;\n padding-left: 40px;\n}\n.xendit-instructions-single-tab-heading {\n font-size: 14px;\n font-weight: 600;\n line-height: 20px;\n margin-bottom: 16px;\n}\n.xendit-instructions-step-box {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.xendit-instructions-step-li {\n font-size: 14px;\n line-height: 20px;\n}\n.xendit-instructions-step-li p {\n margin: 0;\n}\n.xendit-instructions-step-li::marker {\n margin-left: 20px;\n}\n.xendit-instructions-tab-button {\n font-family: var(--xendit-font-family);\n font-size: 14px;\n padding: 8px 4px;\n background-color: transparent;\n border: none;\n border-top: 3px solid transparent;\n border-bottom: 3px solid transparent;\n cursor: pointer;\n}\n.xendit-instructions-active-tab {\n border-bottom-color: var(--xendit-color-primary);\n color: var(--xendit-color-primary);\n font-weight: 600;\n}\n.xendit-instructions-tab-list {\n display: flex;\n gap: 16px;\n margin-bottom: 16px;\n border-bottom: 1px solid var(--xendit-color-border);\n}\n.xendit-instructions-table {\n font-size: 14px;\n line-height: 16px;\n width: 100%;\n border-collapse: collapse;\n}\n.xendit-instructions-table-cell {\n padding: 4px;\n border: 1px solid black;\n}\n.xendit-instructions-table-header {\n font-size: 14px;\n font-weight: 600;\n line-height: 16px;\n padding: 4px;\n border: 1px solid black;\n}\n\n/* Instructions ends */\n\n.xendit-default-action-container {\n display: flex;\n flex-direction: column;\n border: none;\n}\n\n.xendit-action-title {\n font-weight: 600;\n font-size: 20px;\n line-height: 28px;\n text-align: center;\n}\n\n.xendit-action-iframe {\n border: none;\n width: 100%;\n height: 100%;\n}\n\n.xendit-action-present-to-customer {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n.xendit-action-present-to-customer-affirm {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.xendit-action-qr-content {\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n max-width: 384px;\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n padding: 16px;\n overflow: hidden;\n}\n.xendit-qr-merchant-info {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n}\n.xendit-action-qr-channel-logo {\n height: 64px;\n align-self: center;\n object-fit: contain;\n}\n.xendit-action-qr-qrcode-container {\n width: 100%;\n position: relative;\n z-index: var(--xendit-z-index-overlay);\n}\n\n/* va actions */\n.xendit-action-va-content {\n display: flex;\n flex-direction: column;\n border: 1px solid var(--xendit-color-border);\n border-radius: var(--xendit-radius-1);\n padding: 16px;\n padding-bottom: 24px;\n}\n.xendit-action-va-details {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n.xendit-action-va-detail-item {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n.xendit-action-va-detail-content {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.xendit-action-va-heading {\n color: var(--xendit-color-text-placeholder);\n}\n.xendit-action-va-tag {\n color: var(--xendit-color-text-placeholder);\n background-color: #fafafa;\n padding: 2px 4px;\n border-radius: 4px;\n}\n\n/* redirect, deeplink, and push notification actions */\n.xendit-redirect-instructions {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n gap: 24px;\n}\n\n.xendit-redirect-instructions-logo {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 112px;\n height: 112px;\n border: 2px solid var(--xendit-color-border);\n border-radius: 50%;\n overflow: hidden;\n box-shadow: var(--xendit-card-shadow);\n}\n\n.xendit-redirect-instructions-logo img {\n width: 96px;\n height: 96px;\n object-fit: contain;\n}\n\n.xendit-redirect-instructions-text {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.xendit-redirect-instructions-button {\n display: inline-block;\n border-radius: 99px;\n color: white;\n padding: 12px 16px;\n background-color: var(--xendit-channel-brand-color, #000);\n text-decoration: none;\n white-space: nowrap;\n box-shadow: var(--xendit-card-shadow);\n}\n\n.xendit-redirect-instructions-button:hover,\n.xendit-redirect-instructions-button:active {\n filter: brightness(1.1);\n}\n\n/* googlepay */\n\n.gpay-card-info-container-fill {\n display: flex;\n}\n";const n=document.querySelector("style, link");n?n.insertAdjacentElement("beforebegin",e):document.head.appendChild(e)}());export{XenditActionBeginEvent,XenditActionEndEvent,XenditComponents,XenditComponentsTest,XenditFatalErrorEvent,XenditInitEvent,XenditNotReadyEvent,XenditPaymentRequestCreatedEvent,XenditPaymentRequestDiscardedEvent,XenditPaymentTokenCreatedEvent,XenditPaymentTokenDiscardedEvent,XenditReadyEvent,XenditSessionCompleteEvent,XenditSessionExpiredOrCanceledEvent,XenditSessionNotPendingEvent,XenditSessionPendingEvent,XenditSubmissionBeginEvent,XenditSubmissionEndEvent,XenditWillRedirectEvent,he as a,ue as r};
3
3
  //# sourceMappingURL=index.mjs.map