@movmo_app/payments 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var er=Object.defineProperty;var tr=(t,r,n)=>r in t?er(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n;var ut=(t,r,n)=>tr(t,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react");var yt={exports:{}},Qe={};/**
1
+ "use strict";var ar=Object.defineProperty;var nr=(e,r,n)=>r in e?ar(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var qe=(e,r,n)=>nr(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react");var vt={exports:{}},et={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var jt;function rr(){if(jt)return Qe;jt=1;var t=s,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function m(y,f,N){var E,x={},g=null,j=null;N!==void 0&&(g=""+N),f.key!==void 0&&(g=""+f.key),f.ref!==void 0&&(j=f.ref);for(E in f)o.call(f,E)&&!c.hasOwnProperty(E)&&(x[E]=f[E]);if(y&&y.defaultProps)for(E in f=y.defaultProps,f)x[E]===void 0&&(x[E]=f[E]);return{$$typeof:r,type:y,key:g,ref:j,props:x,_owner:l.current}}return Qe.Fragment=n,Qe.jsx=m,Qe.jsxs=m,Qe}var et={};/**
9
+ */var Ct;function sr(){if(Ct)return et;Ct=1;var e=s,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function m(v,h,j){var _,w={},C=null,x=null;j!==void 0&&(C=""+j),h.key!==void 0&&(C=""+h.key),h.ref!==void 0&&(x=h.ref);for(_ in h)o.call(h,_)&&!c.hasOwnProperty(_)&&(w[_]=h[_]);if(v&&v.defaultProps)for(_ in h=v.defaultProps,h)w[_]===void 0&&(w[_]=h[_]);return{$$typeof:r,type:v,key:C,ref:x,props:w,_owner:l.current}}return et.Fragment=n,et.jsx=m,et.jsxs=m,et}var tt={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,18 +14,18 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var _t;function ar(){return _t||(_t=1,process.env.NODE_ENV!=="production"&&function(){var t=s,r=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),y=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),P=Symbol.iterator,re="@@iterator";function A(e){if(e===null||typeof e!="object")return null;var i=P&&e[P]||e[re];return typeof i=="function"?i:null}var _=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function k(e){{for(var i=arguments.length,d=new Array(i>1?i-1:0),b=1;b<i;b++)d[b-1]=arguments[b];D("error",e,d)}}function D(e,i,d){{var b=_.ReactDebugCurrentFrame,F=b.getStackAddendum();F!==""&&(i+="%s",d=d.concat([F]));var W=d.map(function(R){return String(R)});W.unshift("Warning: "+i),Function.prototype.apply.call(console[e],console,W)}}var pe=!1,de=!1,ge=!1,ue=!1,se=!1,X;X=Symbol.for("react.module.reference");function w(e){return!!(typeof e=="string"||typeof e=="function"||e===o||e===c||se||e===l||e===N||e===E||ue||e===j||pe||de||ge||typeof e=="object"&&e!==null&&(e.$$typeof===g||e.$$typeof===x||e.$$typeof===m||e.$$typeof===y||e.$$typeof===f||e.$$typeof===X||e.getModuleId!==void 0))}function ye(e,i,d){var b=e.displayName;if(b)return b;var F=i.displayName||i.name||"";return F!==""?d+"("+F+")":d}function _e(e){return e.displayName||"Context"}function z(e){if(e==null)return null;if(typeof e.tag=="number"&&k("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case o:return"Fragment";case n:return"Portal";case c:return"Profiler";case l:return"StrictMode";case N:return"Suspense";case E:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case y:var i=e;return _e(i)+".Consumer";case m:var d=e;return _e(d._context)+".Provider";case f:return ye(e,e.render,"ForwardRef");case x:var b=e.displayName||null;return b!==null?b:z(e.type)||"Memo";case g:{var F=e,W=F._payload,R=F._init;try{return z(R(W))}catch{return null}}}return null}var h=Object.assign,v=0,S,M,te,ae,H,G,Y;function T(){}T.__reactDisabledLog=!0;function K(){{if(v===0){S=console.log,M=console.info,te=console.warn,ae=console.error,H=console.group,G=console.groupCollapsed,Y=console.groupEnd;var e={configurable:!0,enumerable:!0,value:T,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}v++}}function Ce(){{if(v--,v===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:h({},e,{value:S}),info:h({},e,{value:M}),warn:h({},e,{value:te}),error:h({},e,{value:ae}),group:h({},e,{value:H}),groupCollapsed:h({},e,{value:G}),groupEnd:h({},e,{value:Y})})}v<0&&k("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ve=_.ReactCurrentDispatcher,q;function we(e,i,d){{if(q===void 0)try{throw Error()}catch(F){var b=F.stack.trim().match(/\n( *(at )?)/);q=b&&b[1]||""}return`
18
- `+q+e}}var J=!1,Pe;{var ke=typeof WeakMap=="function"?WeakMap:Map;Pe=new ke}function ne(e,i){if(!e||J)return"";{var d=Pe.get(e);if(d!==void 0)return d}var b;J=!0;var F=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var W;W=ve.current,ve.current=null,K();try{if(i){var R=function(){throw Error()};if(Object.defineProperty(R.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(R,[])}catch(fe){b=fe}Reflect.construct(e,[],R)}else{try{R.call()}catch(fe){b=fe}e.call(R.prototype)}}else{try{throw Error()}catch(fe){b=fe}e()}}catch(fe){if(fe&&b&&typeof fe.stack=="string"){for(var C=fe.stack.split(`
19
- `),ce=b.stack.split(`
20
- `),B=C.length-1,V=ce.length-1;B>=1&&V>=0&&C[B]!==ce[V];)V--;for(;B>=1&&V>=0;B--,V--)if(C[B]!==ce[V]){if(B!==1||V!==1)do if(B--,V--,V<0||C[B]!==ce[V]){var be=`
21
- `+C[B].replace(" at new "," at ");return e.displayName&&be.includes("<anonymous>")&&(be=be.replace("<anonymous>",e.displayName)),typeof e=="function"&&Pe.set(e,be),be}while(B>=1&&V>=0);break}}}finally{J=!1,ve.current=W,Ce(),Error.prepareStackTrace=F}var He=e?e.displayName||e.name:"",Be=He?we(He):"";return typeof e=="function"&&Pe.set(e,Be),Be}function Q(e,i,d){return ne(e,!1)}function Te(e){var i=e.prototype;return!!(i&&i.isReactComponent)}function $(e,i,d){if(e==null)return"";if(typeof e=="function")return ne(e,Te(e));if(typeof e=="string")return we(e);switch(e){case N:return we("Suspense");case E:return we("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return Q(e.render);case x:return $(e.type,i,d);case g:{var b=e,F=b._payload,W=b._init;try{return $(W(F),i,d)}catch{}}}return""}var oe=Object.prototype.hasOwnProperty,Re={},ee=_.ReactDebugCurrentFrame;function Ee(e){if(e){var i=e._owner,d=$(e.type,e._source,i?i.type:null);ee.setExtraStackFrame(d)}else ee.setExtraStackFrame(null)}function Fe(e,i,d,b,F){{var W=Function.call.bind(oe);for(var R in e)if(W(e,R)){var C=void 0;try{if(typeof e[R]!="function"){var ce=Error((b||"React class")+": "+d+" type `"+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[R]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ce.name="Invariant Violation",ce}C=e[R](i,R,b,d,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(B){C=B}C&&!(C instanceof Error)&&(Ee(F),k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",b||"React class",d,R,typeof C),Ee(null)),C instanceof Error&&!(C.message in Re)&&(Re[C.message]=!0,Ee(F),k("Failed %s type: %s",d,C.message),Ee(null))}}}var he=Array.isArray;function Ie(e){return he(e)}function xe(e){{var i=typeof Symbol=="function"&&Symbol.toStringTag,d=i&&e[Symbol.toStringTag]||e.constructor.name||"Object";return d}}function ie(e){try{return We(e),!1}catch{return!0}}function We(e){return""+e}function Me(e){if(ie(e))return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",xe(e)),We(e)}var Ae=_.ReactCurrentOwner,Le={key:!0,ref:!0,__self:!0,__source:!0},De,Ne;function p(e){if(oe.call(e,"ref")){var i=Object.getOwnPropertyDescriptor(e,"ref").get;if(i&&i.isReactWarning)return!1}return e.ref!==void 0}function O(e){if(oe.call(e,"key")){var i=Object.getOwnPropertyDescriptor(e,"key").get;if(i&&i.isReactWarning)return!1}return e.key!==void 0}function me(e,i){typeof e.ref=="string"&&Ae.current}function le(e,i){{var d=function(){De||(De=!0,k("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",i))};d.isReactWarning=!0,Object.defineProperty(e,"key",{get:d,configurable:!0})}}function at(e,i){{var d=function(){Ne||(Ne=!0,k("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",i))};d.isReactWarning=!0,Object.defineProperty(e,"ref",{get:d,configurable:!0})}}var st=function(e,i,d,b,F,W,R){var C={$$typeof:r,type:e,key:i,ref:d,props:R,_owner:W};return C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(C,"_self",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.defineProperty(C,"_source",{configurable:!1,enumerable:!1,writable:!1,value:F}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C};function nt(e,i,d,b,F){{var W,R={},C=null,ce=null;d!==void 0&&(Me(d),C=""+d),O(i)&&(Me(i.key),C=""+i.key),p(i)&&(ce=i.ref,me(i,F));for(W in i)oe.call(i,W)&&!Le.hasOwnProperty(W)&&(R[W]=i[W]);if(e&&e.defaultProps){var B=e.defaultProps;for(W in B)R[W]===void 0&&(R[W]=B[W])}if(C||ce){var V=typeof e=="function"?e.displayName||e.name||"Unknown":e;C&&le(R,V),ce&&at(R,V)}return st(e,C,ce,F,b,Ae.current,R)}}var $e=_.ReactCurrentOwner,Ve=_.ReactDebugCurrentFrame;function Se(e){if(e){var i=e._owner,d=$(e.type,e._source,i?i.type:null);Ve.setExtraStackFrame(d)}else Ve.setExtraStackFrame(null)}var Ue;Ue=!1;function Xe(e){return typeof e=="object"&&e!==null&&e.$$typeof===r}function ot(){{if($e.current){var e=z($e.current.type);if(e)return`
17
+ */var Rt;function or(){return Rt||(Rt=1,process.env.NODE_ENV!=="production"&&function(){var e=s,r=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),v=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),P=Symbol.iterator,M="@@iterator";function I(t){if(t===null||typeof t!="object")return null;var i=P&&t[P]||t[M];return typeof i=="function"?i:null}var k=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function E(t){{for(var i=arguments.length,d=new Array(i>1?i-1:0),g=1;g<i;g++)d[g-1]=arguments[g];O("error",t,d)}}function O(t,i,d){{var g=k.ReactDebugCurrentFrame,F=g.getStackAddendum();F!==""&&(i+="%s",d=d.concat([F]));var W=d.map(function(N){return String(N)});W.unshift("Warning: "+i),Function.prototype.apply.call(console[t],console,W)}}var pe=!1,de=!1,we=!1,ue=!1,se=!1,Q;Q=Symbol.for("react.module.reference");function b(t){return!!(typeof t=="string"||typeof t=="function"||t===o||t===c||se||t===l||t===j||t===_||ue||t===x||pe||de||we||typeof t=="object"&&t!==null&&(t.$$typeof===C||t.$$typeof===w||t.$$typeof===m||t.$$typeof===v||t.$$typeof===h||t.$$typeof===Q||t.getModuleId!==void 0))}function ye(t,i,d){var g=t.displayName;if(g)return g;var F=i.displayName||i.name||"";return F!==""?d+"("+F+")":d}function _e(t){return t.displayName||"Context"}function z(t){if(t==null)return null;if(typeof t.tag=="number"&&E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case o:return"Fragment";case n:return"Portal";case c:return"Profiler";case l:return"StrictMode";case j:return"Suspense";case _:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case v:var i=t;return _e(i)+".Consumer";case m:var d=t;return _e(d._context)+".Provider";case h:return ye(t,t.render,"ForwardRef");case w:var g=t.displayName||null;return g!==null?g:z(t.type)||"Memo";case C:{var F=t,W=F._payload,N=F._init;try{return z(N(W))}catch{return null}}}return null}var p=Object.assign,y=0,S,A,re,ae,q,G,V;function T(){}T.__reactDisabledLog=!0;function K(){{if(y===0){S=console.log,A=console.info,re=console.warn,ae=console.error,q=console.group,G=console.groupCollapsed,V=console.groupEnd;var t={configurable:!0,enumerable:!0,value:T,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}y++}}function Ce(){{if(y--,y===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:p({},t,{value:S}),info:p({},t,{value:A}),warn:p({},t,{value:re}),error:p({},t,{value:ae}),group:p({},t,{value:q}),groupCollapsed:p({},t,{value:G}),groupEnd:p({},t,{value:V})})}y<0&&E("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ve=k.ReactCurrentDispatcher,J;function Ee(t,i,d){{if(J===void 0)try{throw Error()}catch(F){var g=F.stack.trim().match(/\n( *(at )?)/);J=g&&g[1]||""}return`
18
+ `+J+t}}var Z=!1,Pe;{var Re=typeof WeakMap=="function"?WeakMap:Map;Pe=new Re}function oe(t,i){if(!t||Z)return"";{var d=Pe.get(t);if(d!==void 0)return d}var g;Z=!0;var F=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var W;W=ve.current,ve.current=null,K();try{if(i){var N=function(){throw Error()};if(Object.defineProperty(N.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(N,[])}catch(fe){g=fe}Reflect.construct(t,[],N)}else{try{N.call()}catch(fe){g=fe}t.call(N.prototype)}}else{try{throw Error()}catch(fe){g=fe}t()}}catch(fe){if(fe&&g&&typeof fe.stack=="string"){for(var R=fe.stack.split(`
19
+ `),ce=g.stack.split(`
20
+ `),Y=R.length-1,H=ce.length-1;Y>=1&&H>=0&&R[Y]!==ce[H];)H--;for(;Y>=1&&H>=0;Y--,H--)if(R[Y]!==ce[H]){if(Y!==1||H!==1)do if(Y--,H--,H<0||R[Y]!==ce[H]){var be=`
21
+ `+R[Y].replace(" at new "," at ");return t.displayName&&be.includes("<anonymous>")&&(be=be.replace("<anonymous>",t.displayName)),typeof t=="function"&&Pe.set(t,be),be}while(Y>=1&&H>=0);break}}}finally{Z=!1,ve.current=W,Ce(),Error.prepareStackTrace=F}var He=t?t.displayName||t.name:"",Be=He?Ee(He):"";return typeof t=="function"&&Pe.set(t,Be),Be}function ee(t,i,d){return oe(t,!1)}function Te(t){var i=t.prototype;return!!(i&&i.isReactComponent)}function $(t,i,d){if(t==null)return"";if(typeof t=="function")return oe(t,Te(t));if(typeof t=="string")return Ee(t);switch(t){case j:return Ee("Suspense");case _:return Ee("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case h:return ee(t.render);case w:return $(t.type,i,d);case C:{var g=t,F=g._payload,W=g._init;try{return $(W(F),i,d)}catch{}}}return""}var ie=Object.prototype.hasOwnProperty,ke={},te=k.ReactDebugCurrentFrame;function je(t){if(t){var i=t._owner,d=$(t.type,t._source,i?i.type:null);te.setExtraStackFrame(d)}else te.setExtraStackFrame(null)}function Fe(t,i,d,g,F){{var W=Function.call.bind(ie);for(var N in t)if(W(t,N)){var R=void 0;try{if(typeof t[N]!="function"){var ce=Error((g||"React class")+": "+d+" type `"+N+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[N]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ce.name="Invariant Violation",ce}R=t[N](i,N,g,d,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Y){R=Y}R&&!(R instanceof Error)&&(je(F),E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",g||"React class",d,N,typeof R),je(null)),R instanceof Error&&!(R.message in ke)&&(ke[R.message]=!0,je(F),E("Failed %s type: %s",d,R.message),je(null))}}}var he=Array.isArray;function ze(t){return he(t)}function ge(t){{var i=typeof Symbol=="function"&&Symbol.toStringTag,d=i&&t[Symbol.toStringTag]||t.constructor.name||"Object";return d}}function le(t){try{return Oe(t),!1}catch{return!0}}function Oe(t){return""+t}function We(t){if(le(t))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ge(t)),Oe(t)}var Ae=k.ReactCurrentOwner,Le={key:!0,ref:!0,__self:!0,__source:!0},De,Ne;function f(t){if(ie.call(t,"ref")){var i=Object.getOwnPropertyDescriptor(t,"ref").get;if(i&&i.isReactWarning)return!1}return t.ref!==void 0}function D(t){if(ie.call(t,"key")){var i=Object.getOwnPropertyDescriptor(t,"key").get;if(i&&i.isReactWarning)return!1}return t.key!==void 0}function me(t,i){typeof t.ref=="string"&&Ae.current}function ne(t,i){{var d=function(){De||(De=!0,E("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",i))};d.isReactWarning=!0,Object.defineProperty(t,"key",{get:d,configurable:!0})}}function st(t,i){{var d=function(){Ne||(Ne=!0,E("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",i))};d.isReactWarning=!0,Object.defineProperty(t,"ref",{get:d,configurable:!0})}}var ot=function(t,i,d,g,F,W,N){var R={$$typeof:r,type:t,key:i,ref:d,props:N,_owner:W};return R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(R,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(R,"_source",{configurable:!1,enumerable:!1,writable:!1,value:F}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R};function it(t,i,d,g,F){{var W,N={},R=null,ce=null;d!==void 0&&(We(d),R=""+d),D(i)&&(We(i.key),R=""+i.key),f(i)&&(ce=i.ref,me(i,F));for(W in i)ie.call(i,W)&&!Le.hasOwnProperty(W)&&(N[W]=i[W]);if(t&&t.defaultProps){var Y=t.defaultProps;for(W in Y)N[W]===void 0&&(N[W]=Y[W])}if(R||ce){var H=typeof t=="function"?t.displayName||t.name||"Unknown":t;R&&ne(N,H),ce&&st(N,H)}return ot(t,R,ce,F,g,Ae.current,N)}}var $e=k.ReactCurrentOwner,Ve=k.ReactDebugCurrentFrame;function Se(t){if(t){var i=t._owner,d=$(t.type,t._source,i?i.type:null);Ve.setExtraStackFrame(d)}else Ve.setExtraStackFrame(null)}var Ue;Ue=!1;function Qe(t){return typeof t=="object"&&t!==null&&t.$$typeof===r}function lt(){{if($e.current){var t=z($e.current.type);if(t)return`
22
22
 
23
- Check the render method of \``+e+"`."}return""}}function u(e){return""}var L={};function I(e){{var i=ot();if(!i){var d=typeof e=="string"?e:e.displayName||e.name;d&&(i=`
23
+ Check the render method of \``+t+"`."}return""}}function u(t){return""}var B={};function L(t){{var i=lt();if(!i){var d=typeof t=="string"?t:t.displayName||t.name;d&&(i=`
24
24
 
25
- Check the top-level render call using <`+d+">.")}return i}}function U(e,i){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var d=I(i);if(L[d])return;L[d]=!0;var b="";e&&e._owner&&e._owner!==$e.current&&(b=" It was passed a child from "+z(e._owner.type)+"."),Se(e),k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,b),Se(null)}}function je(e,i){{if(typeof e!="object")return;if(Ie(e))for(var d=0;d<e.length;d++){var b=e[d];Xe(b)&&U(b,i)}else if(Xe(e))e._store&&(e._store.validated=!0);else if(e){var F=A(e);if(typeof F=="function"&&F!==e.entries)for(var W=F.call(e),R;!(R=W.next()).done;)Xe(R.value)&&U(R.value,i)}}}function Oe(e){{var i=e.type;if(i==null||typeof i=="string")return;var d;if(typeof i=="function")d=i.propTypes;else if(typeof i=="object"&&(i.$$typeof===f||i.$$typeof===x))d=i.propTypes;else return;if(d){var b=z(i);Fe(d,e.props,"prop",b,e)}else if(i.PropTypes!==void 0&&!Ue){Ue=!0;var F=z(i);k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",F||"Unknown")}typeof i.getDefaultProps=="function"&&!i.getDefaultProps.isReactClassApproved&&k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function it(e){{for(var i=Object.keys(e.props),d=0;d<i.length;d++){var b=i[d];if(b!=="children"&&b!=="key"){Se(e),k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),Se(null);break}}e.ref!==null&&(Se(e),k("Invalid attribute `ref` supplied to `React.Fragment`."),Se(null))}}var wt={};function Et(e,i,d,b,F,W){{var R=w(e);if(!R){var C="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(C+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ce=u();ce?C+=ce:C+=ot();var B;e===null?B="null":Ie(e)?B="array":e!==void 0&&e.$$typeof===r?(B="<"+(z(e.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):B=typeof e,k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",B,C)}var V=nt(e,i,d,F,W);if(V==null)return V;if(R){var be=i.children;if(be!==void 0)if(b)if(Ie(be)){for(var He=0;He<be.length;He++)je(be[He],e);Object.freeze&&Object.freeze(be)}else k("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else je(be,e)}if(oe.call(i,"key")){var Be=z(e),fe=Object.keys(i).filter(function(Qt){return Qt!=="key"}),dt=fe.length>0?"{key: someKey, "+fe.join(": ..., ")+": ...}":"{key: someKey}";if(!wt[Be+dt]){var Xt=fe.length>0?"{"+fe.join(": ..., ")+": ...}":"{}";k(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+d+">.")}return i}}function U(t,i){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var d=L(i);if(B[d])return;B[d]=!0;var g="";t&&t._owner&&t._owner!==$e.current&&(g=" It was passed a child from "+z(t._owner.type)+"."),Se(t),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,g),Se(null)}}function xe(t,i){{if(typeof t!="object")return;if(ze(t))for(var d=0;d<t.length;d++){var g=t[d];Qe(g)&&U(g,i)}else if(Qe(t))t._store&&(t._store.validated=!0);else if(t){var F=I(t);if(typeof F=="function"&&F!==t.entries)for(var W=F.call(t),N;!(N=W.next()).done;)Qe(N.value)&&U(N.value,i)}}}function Me(t){{var i=t.type;if(i==null||typeof i=="string")return;var d;if(typeof i=="function")d=i.propTypes;else if(typeof i=="object"&&(i.$$typeof===h||i.$$typeof===w))d=i.propTypes;else return;if(d){var g=z(i);Fe(d,t.props,"prop",g,t)}else if(i.PropTypes!==void 0&&!Ue){Ue=!0;var F=z(i);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",F||"Unknown")}typeof i.getDefaultProps=="function"&&!i.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ct(t){{for(var i=Object.keys(t.props),d=0;d<i.length;d++){var g=i[d];if(g!=="children"&&g!=="key"){Se(t),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),Se(null);break}}t.ref!==null&&(Se(t),E("Invalid attribute `ref` supplied to `React.Fragment`."),Se(null))}}var jt={};function _t(t,i,d,g,F,W){{var N=b(t);if(!N){var R="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(R+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ce=u();ce?R+=ce:R+=lt();var Y;t===null?Y="null":ze(t)?Y="array":t!==void 0&&t.$$typeof===r?(Y="<"+(z(t.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):Y=typeof t,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Y,R)}var H=it(t,i,d,F,W);if(H==null)return H;if(N){var be=i.children;if(be!==void 0)if(g)if(ze(be)){for(var He=0;He<be.length;He++)xe(be[He],t);Object.freeze&&Object.freeze(be)}else E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else xe(be,t)}if(ie.call(i,"key")){var Be=z(t),fe=Object.keys(i).filter(function(rr){return rr!=="key"}),mt=fe.length>0?"{key: someKey, "+fe.join(": ..., ")+": ...}":"{key: someKey}";if(!jt[Be+mt]){var tr=fe.length>0?"{"+fe.join(": ..., ")+": ...}":"{}";E(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,dt,Be,Xt,Be),wt[Be+dt]=!0}}return e===o?it(V):Oe(V),V}}function Kt(e,i,d){return Et(e,i,d,!0)}function qt(e,i,d){return Et(e,i,d,!1)}var Jt=qt,Zt=Kt;et.Fragment=o,et.jsx=Jt,et.jsxs=Zt}()),et}process.env.NODE_ENV==="production"?yt.exports=rr():yt.exports=ar();var a=yt.exports;function Ot(t){var r,n,o="";if(typeof t=="string"||typeof t=="number")o+=t;else if(typeof t=="object")if(Array.isArray(t)){var l=t.length;for(r=0;r<l;r++)t[r]&&(n=Ot(t[r]))&&(o&&(o+=" "),o+=n)}else for(n in t)t[n]&&(o&&(o+=" "),o+=n);return o}function Z(){for(var t,r,n=0,o="",l=arguments.length;n<l;n++)(t=arguments[n])&&(r=Ot(t))&&(o&&(o+=" "),o+=r);return o}const sr="https://core.spreedly.com/iframe/iframe-v1.min.js",nr="https://cdn.e2e.movmo.io";let Ge={};const or=t=>{Ge={...Ge,...t}},mt=t=>{var n;const r=globalThis.process;return(n=r==null?void 0:r.env)==null?void 0:n[t]},Ye=()=>({baseUrl:Ge.baseUrl??mt("REACT_APP_MOVMO_API_URL")??"",spreedlyScriptUrl:Ge.spreedlyScriptUrl??mt("REACT_APP_SPREEDLY_SCRIPT_URL")??sr,iconCdnBaseUrl:Ge.iconCdnBaseUrl??mt("REACT_APP_MOVMO_ICON_CDN_URL")??nr,fetch:Ge.fetch??(typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):(()=>{throw new Error("@movmo_app/payments: no fetch available")})())}),vt=t=>({id:t.id,last4:t.last4,brand:t.brand,expMonth:t.expMonth,expYear:t.expYear,isDefault:t.isDefault,vault:t.vault,cardholderName:t.cardholderName,zip:t.zip}),Ke={Accept:"application/json","Content-Type":"application/json"},qe=t=>{const{baseUrl:r}=Ye();if(!r)throw new Error("@movmo_app/payments: baseUrl is not configured. Call setPaymentsConfig({ baseUrl }) at app boot, or set REACT_APP_MOVMO_API_URL.");return`${r}${t}`},Je=(t,r)=>{const{fetch:n}=Ye();return n(t,r)},Ze=async(t,r)=>{try{return(await t.json()).message||r}catch{return r}};let tt=null;const xt=()=>{if(tt)return tt;const t=(async()=>{const r=await Je(qe("/v1/payments/tokenization-session"),{method:"GET",headers:Ke,credentials:"include"});if(!r.ok)throw new Error(await Ze(r,`Failed to fetch tokenization session (${r.status})`));return await r.json()})();return tt=t,t.finally(()=>{tt===t&&(tt=null)}).catch(()=>{}),t},ir=t=>typeof t.brand=="string"&&typeof t.last4=="string"&&typeof t.expMonth=="number"&&typeof t.expYear=="number",lr=async(t,r,n)=>{const o=await Je(qe(`/v1/users/${encodeURIComponent(t)}/payment-methods/from-token`),{method:"POST",headers:Ke,credentials:"include",body:JSON.stringify({tokenizedPaymentMethodId:r,isDefault:n})});if(!o.ok)throw new Error(await Ze(o,`Failed to save payment method (${o.status})`));const l=await o.json();if(ir(l))return vt(l);const c=await Je(qe(`/v1/users/${encodeURIComponent(t)}/payment-methods/${encodeURIComponent(l.id)}`),{method:"GET",headers:Ke,credentials:"include"});if(!c.ok)throw new Error(await Ze(c,`Failed to fetch saved payment method (${c.status})`));const m=await c.json();return vt(m)},cr=async(t,r)=>{if(!t)return[];const n=await Je(qe(`/v1/users/${encodeURIComponent(t)}/payment-methods`),{method:"GET",headers:Ke,credentials:"include",signal:r});if(!n.ok)throw new Error(await Ze(n,`Failed to fetch payment methods (${n.status})`));return(await n.json()??[]).map(vt)},dr=async(t,r)=>{const n=await Je(qe(`/v1/users/${encodeURIComponent(t)}/payment-methods/${encodeURIComponent(r)}`),{method:"DELETE",headers:Ke,credentials:"include"});if(!n.ok)throw new Error(await Ze(n,`Failed to delete payment method (${n.status})`))},At=async(t,r,n)=>{const o=await Je(qe(`/v1/users/${encodeURIComponent(t)}/payment-methods/${encodeURIComponent(r)}`),{method:"PUT",headers:Ke,credentials:"include",body:JSON.stringify(n)});if(!o.ok)throw new Error(await Ze(o,`Failed to update payment method (${o.status})`))},ur={visa:"visa",master:"mastercard",mastercard:"mastercard",american_express:"amex",amex:"amex",discover:"discover"},mr=28,ze=({brand:t,className:r,width:n=46})=>{const o=t?ur[t.toLowerCase()]??"credit-card":"credit-card",l=Math.max(n,mr),c=Math.round(l*24/34),{iconCdnBaseUrl:m}=Ye();return a.jsx("img",{src:`${m}/website/assets/icons/payments/${o}.svg`,alt:o==="credit-card"?"card":`${o} card`,"data-testid":`card-brand-${t.toLowerCase()}`,className:r,width:l,height:c,loading:"lazy"})};let rt=null;const fr=()=>{if(typeof window>"u")return Promise.reject(new Error("Spreedly can only be loaded in a browser environment."));if(window.Spreedly)return Promise.resolve(window.Spreedly);if(rt)return rt;const{spreedlyScriptUrl:t}=Ye();return rt=new Promise((r,n)=>{const o=document.querySelector(`script[src="${t}"]`),l=()=>{window.Spreedly?r(window.Spreedly):n(new Error("Spreedly script loaded but window.Spreedly is undefined."))};if(o){if(window.Spreedly){l();return}o.addEventListener("load",l,{once:!0}),o.addEventListener("error",()=>{o.remove(),n(new Error("Failed to load Spreedly iframe script."))},{once:!0});return}const c=document.createElement("script");c.src=t,c.async=!0,c.onload=l,c.onerror=()=>{c.remove(),n(new Error("Failed to load Spreedly iframe script."))},document.head.appendChild(c)}).catch(r=>{throw rt=null,r}),rt};class lt extends Error{constructor(n,o){super(o instanceof Error?o.message:"Failed to initialize card form.");ut(this,"source");ut(this,"cause");this.name="InitError",this.source=n,this.cause=o}}const pr="movmo-card-number",hr="movmo-card-cvv",yr=t=>({first_name:t.firstName,last_name:t.lastName,month:t.month,year:t.year,...t.email?{email:t.email}:{},...t.zip?{zip:t.zip}:{}}),Dt=(t={})=>{const{numberEl:r=pr,cvvEl:n=hr,onCardTokenized:o,onFieldErrors:l,onValidityChange:c,onBrandChange:m}=t,[y,f]=s.useState("idle"),[N,E]=s.useState(null),[x,g]=s.useState(null),[j,P]=s.useState(null),[re,A]=s.useState({number:!1,cvv:!1}),[_,k]=s.useState(null),[D,pe]=s.useState({number:!1,cvv:!1}),de=s.useRef(null),ge=s.useRef(o),ue=s.useRef(l),se=s.useRef(c),X=s.useRef(m);s.useEffect(()=>{ge.current=o},[o]),s.useEffect(()=>{ue.current=l},[l]),s.useEffect(()=>{se.current=c},[c]),s.useEffect(()=>{X.current=m},[m]);const w=s.useRef({number:!1,cvv:!1});s.useEffect(()=>{let z=!1;return f("loading"),E(null),g(null),P(null),A({number:!1,cvv:!1}),k(null),w.current={number:!1,cvv:!1},(async()=>{try{const[h,v]=await Promise.all([xt().catch(S=>{throw new lt("tokenization-session",S)}),fr().catch(S=>{throw new lt("spreedly-script",S)})]);if(z)return;de.current=v,v.on("ready",()=>{var S,M,te,ae,H,G;if(!z){f("ready");try{(S=v.setFieldType)==null||S.call(v,"number","tel"),(M=v.setFieldType)==null||M.call(v,"cvv","tel")}catch(Y){console.warn("@movmo_app/payments: setFieldType failed",Y)}try{typeof v.setNumberFormat=="function"?v.setNumberFormat("prettyFormat"):console.warn("@movmo_app/payments: Spreedly.setNumberFormat is missing — card-number digits will not be space-grouped.")}catch(Y){console.warn("@movmo_app/payments: setNumberFormat failed",Y)}try{(te=v.setPlaceholder)==null||te.call(v,"number","Card number"),(ae=v.setPlaceholder)==null||ae.call(v,"cvv","CVV");const Y='box-sizing: border-box;width: 100%;height: 100%;margin: 0;padding: 0;border: 0;background: transparent;outline: none;font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;font-size: 14px;font-weight: 400;line-height: 20px;color: rgb(28 25 23);letter-spacing: 0;vertical-align: middle;';(H=v.setStyle)==null||H.call(v,"number",Y),(G=v.setStyle)==null||G.call(v,"cvv",Y)}catch(Y){console.warn("@movmo_app/payments: setPlaceholder/setStyle failed",Y)}}}),v.on("paymentMethod",S=>{var M;(M=ge.current)==null||M.call(ge,S)}),v.on("errors",S=>{var M;(M=ue.current)==null||M.call(ue,S)}),v.on("fieldEvent",(S,M,te,ae)=>{var Y;if(z)return;if(M==="focus"){pe(T=>T[S]?T:{...T,[S]:!0});return}if(M==="blur"){pe(T=>T[S]?{...T,[S]:!1}:T);return}if(M!=="input")return;const H=ae??{};if(S==="number"){if(H.numberLength===0)k(T=>{var K;return T!==null&&((K=X.current)==null||K.call(X,null)),null});else if(H.cardType!==void 0){const T=H.cardType||null;k(K=>{var Ce;return K!==T&&((Ce=X.current)==null||Ce.call(X,T)),T})}}const G=S==="number"?typeof H.validNumber=="boolean"?H.validNumber:void 0:typeof H.validCvv=="boolean"?H.validCvv:void 0;if(typeof G=="boolean"){const T=w.current,K=S==="number"?{...T,number:G}:{...T,cvv:G};(K.number!==T.number||K.cvv!==T.cvv)&&(w.current=K,A(K),(Y=se.current)==null||Y.call(se,K))}}),v.on("consoleError",S=>{var te;const M=S instanceof Error?S.message:"An unexpected error occurred while securing your card.";(te=ue.current)==null||te.call(ue,[{message:M}])}),v.init(h.environmentKey,{numberEl:r,cvvEl:n,nonce:h.nonce,timestamp:String(h.timestamp),certificateToken:h.certificateToken,signature:h.signature})}catch(h){if(z)return;const v=h instanceof Error?h.message:"Failed to initialize card form.";E(v),g(h instanceof lt?h.source:"spreedly-script"),P(h instanceof lt?h.cause:h),f("error")}})(),()=>{var h,v;z=!0;try{(v=(h=de.current)==null?void 0:h.removeHandlers)==null||v.call(h)}catch(S){console.warn("@movmo_app/payments: removeHandlers failed during cleanup",S)}de.current=null}},[r,n]);const ye=s.useCallback(z=>{var h;(h=de.current)==null||h.tokenizeCreditCard(yr(z))},[]),_e=s.useCallback(z=>{var h,v;(v=(h=de.current)==null?void 0:h.transferFocus)==null||v.call(h,z)},[]);return{status:y,error:N,errorSource:x,errorCause:j,tokenize:ye,validity:re,brand:_,focused:D,focusField:_e}},bt={number:"Enter your card number",expiry:"Enter a valid expiry date",cvv:"Enter the security code",zip:"Enter your postal code",name:"Enter first and last name as printed on the card"},vr="Your card saves automatically once all fields are complete.",$t=t=>/^[A-Za-z0-9][A-Za-z0-9 -]{1,8}[A-Za-z0-9]$/.test(t.trim()),Ut=t=>{const r=t.replace(/[^A-Za-z0-9 -]/g,"").slice(0,10);if(!/^[\d-]*$/.test(r))return r;const n=r.replace(/-+/g,"-").replace(/^-/,"");return n.includes("-")?n:n.length===9?`${n.slice(0,5)}-${n.slice(5)}`:n},xr=({hookStatus:t,validity:r,nameValid:n,expiryValid:o,zipValid:l})=>{const c=t==="ready",m=[],y=f=>m.push({field:f,message:bt[f]});return c&&!r.number&&y("number"),o||y("expiry"),c&&!r.cvv&&y("cvv"),l||y("zip"),n||y("name"),m},ft="h-11 w-full rounded-md border bg-white px-3 py-2 text-sm text-grayWarm-900 placeholder:text-grayWarm-400 outline-none focus:border-grayWarm-950 focus:shadow-[0_0_0_1px_#1c1917]",Ct="flex h-11 w-full items-center gap-2 rounded-md border bg-white px-3 py-2 transition-shadow",kt="border-grayWarm-950 shadow-[0_0_0_1px_#1c1917]",Rt="border-grayWarm-300",Nt="border-error-500",br={number:!1,expiry:!1,cvv:!1,zip:!1,name:!1},gr=t=>{const r=t.trim();if(!r)return{firstName:"",lastName:""};const n=r.lastIndexOf(" ");return n===-1?{firstName:r,lastName:""}:{firstName:r.slice(0,n).trim(),lastName:r.slice(n+1).trim()}},zt=t=>{const r=t.replace(/\D/g,"");if(r.length<4)return{month:"",year:""};const n=r.slice(0,2),o=r.slice(2),l=o.length===2?`20${o}`:o.slice(0,4);return{month:n,year:l}},wr=t=>{const r=t.replace(/\D/g,"").slice(0,4);return r.length<=2?r:`${r.slice(0,2)} / ${r.slice(2)}`},pt=t=>{const{month:r,year:n}=zt(t);if(!r||!n)return!1;const o=parseInt(r,10),l=parseInt(n,10);if(isNaN(o)||o<1||o>12)return!1;const c=new Date;return!(l<c.getFullYear()||l>c.getFullYear()+20||l===c.getFullYear()&&o<c.getMonth()+1)},gt=({userId:t,onSuccess:r,onError:n,onErrorDetail:o,isDefault:l=!1,className:c,defaultCardholderName:m,defaultCardholderFirstName:y="",defaultCardholderLastName:f="",autoSave:N=!1,formId:E="movmo-card-form",hideInternalSaveButton:x=!1,onCanSubmitChange:g,onSavingChange:j,autoFocus:P,onValidationChange:re})=>{const A=m??[y,f].filter(Boolean).join(" "),[_,k]=s.useState(A),[D,pe]=s.useState(""),[de,ge]=s.useState(""),[ue,se]=s.useState("idle"),X=s.useRef(!1),w=s.useRef(o);s.useEffect(()=>{w.current=o},[o]);const ye=s.useCallback(async p=>{var O;se("saving");try{const me=await lr(t,p,l);se("ready"),r(me)}catch(me){const le=me instanceof Error?me.message:"Failed to save payment method.";se("ready"),X.current=!1,n(le),(O=w.current)==null||O.call(w,{source:"save-from-token",message:le,cause:me})}},[t,l,r,n]),_e=s.useCallback(p=>{var me;const O=p.map(le=>le.message).filter(Boolean).join("; ")||"Card validation failed.";se(le=>le==="tokenizing"?"ready":le),X.current=!1,n(O),(me=w.current)==null||me.call(w,{source:"card-tokenize",message:O})},[n]),z=s.useMemo(()=>({onCardTokenized:ye,onFieldErrors:_e}),[ye,_e]),{status:h,error:v,errorSource:S,errorCause:M,tokenize:te,validity:ae,brand:H,focused:G,focusField:Y}=Dt(z),T=s.useRef(!1);s.useEffect(()=>{!P||h!=="ready"||T.current||(T.current=!0,Y(P))},[P,h,Y]);const K=_.trim().split(/\s+/).length>=2,Ce=pt(D),ve=$t(de),[q,we]=s.useState(br),J=s.useCallback(p=>we(O=>O[p]?O:{...O,[p]:!0}),[]),Pe=s.useRef(G);s.useEffect(()=>{const p=Pe.current;Pe.current=G,p.number&&!G.number&&J("number"),p.cvv&&!G.cvv&&J("cvv")},[G,J]);const ke=s.useMemo(()=>xr({hookStatus:h,validity:ae,nameValid:K,expiryValid:Ce,zipValid:ve}),[h,ae,K,Ce,ve]),ne=p=>ke.some(O=>O.field===p),Q=s.useMemo(()=>ke.map(p=>p.field),[ke]),Te=s.useMemo(()=>Q.filter(p=>q[p]),[Q,q]),$=s.useRef(re);s.useEffect(()=>{$.current=re},[re]),s.useEffect(()=>{var p;(p=$.current)==null||p.call($,{valid:Q.length===0,missing:Q,touchedInvalid:Te})},[Q,Te]);const oe=q.number&&ne("number"),Re=q.name&&ne("name"),ee=ke.find(p=>(p.field==="expiry"||p.field==="cvv"||p.field==="zip")&&q[p.field]),Ee=s.useRef(!1),Fe=s.useRef(!1),he=s.useRef(null);s.useEffect(()=>{var p;ae.cvv?Fe.current||(Fe.current=!0,(p=he.current)==null||p.focus()):Fe.current=!1},[ae.cvv]);const Ie=!K||!Ce||!ve||!ae.number||!ae.cvv,xe=ue==="tokenizing"||ue==="saving",ie=h==="ready"&&!xe&&!Ie,We=s.useRef(g);s.useEffect(()=>{We.current=g},[g]),s.useEffect(()=>{var p;(p=We.current)==null||p.call(We,ie)},[ie]);const Me=s.useRef(j);s.useEffect(()=>{Me.current=j},[j]),s.useEffect(()=>{var p;(p=Me.current)==null||p.call(Me,xe)},[xe]);const Ae=s.useCallback(()=>{const{firstName:p,lastName:O}=gr(_),{month:me,year:le}=zt(D);se("tokenizing"),te({firstName:p,lastName:O,month:me,year:le,zip:de.trim()})},[_,D,de,te]);s.useEffect(()=>{if(!N||!ie||X.current)return;const p=setTimeout(()=>{X.current=!0,Ae()},1200);return()=>clearTimeout(p)},[N,ie,Ae]);const Le=p=>{p.preventDefault(),ie&&Ae()},De=h!=="ready"||xe,Ne=s.useRef(n);return s.useEffect(()=>{Ne.current=n},[n]),s.useEffect(()=>{var p,O;v&&((p=Ne.current)==null||p.call(Ne,v),(O=w.current)==null||O.call(w,{source:S??"spreedly-script",message:v,cause:M}))},[v,S,M]),a.jsxs("form",{id:E,onSubmit:Le,className:Z("flex w-full flex-col gap-3",c),"data-testid":"movmo-card-form",children:[a.jsxs("div",{children:[a.jsx("span",{id:"movmo-card-number-label",className:"sr-only",children:"Card number"}),a.jsxs("div",{className:Z(Ct,G.number?kt:oe?Nt:Rt),"data-testid":"movmo-card-number-shell",children:[a.jsx(ze,{brand:H??"",width:32,className:"flex-shrink-0"}),a.jsxs("div",{className:"relative h-full flex-1",children:[a.jsx("div",{id:"movmo-card-number","aria-labelledby":"movmo-card-number-label","aria-busy":h!=="ready","aria-describedby":oe?"movmo-card-number-error":void 0,className:"absolute inset-0","data-testid":"movmo-card-number-mount"}),h!=="ready"?a.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 right-2 animate-pulse rounded bg-grayWarm-200"}):null]})]}),oe&&a.jsx("p",{id:"movmo-card-number-error",className:"mt-1 text-xs text-error-700","data-testid":"movmo-card-number-error",children:bt.number})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"movmo-card-expiry",className:"sr-only",children:"Expiry MM / YY"}),a.jsx("input",{id:"movmo-card-expiry",type:"text",inputMode:"numeric",autoComplete:"cc-exp",placeholder:"MM / YY",value:D,onChange:p=>{const O=wr(p.target.value);pe(O),pt(O)&&!Ee.current?(Ee.current=!0,Y("cvv")):pt(O)||(Ee.current=!1)},onBlur:()=>J("expiry"),"aria-invalid":q.expiry&&ne("expiry"),"aria-describedby":(ee==null?void 0:ee.field)==="expiry"?"movmo-card-row-error":void 0,className:Z(ft,q.expiry&&ne("expiry")?"border-error-500":"border-grayWarm-300"),disabled:De,required:!0,"data-testid":"movmo-card-expiry-input"})]}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{id:"movmo-card-cvv-label",className:"sr-only",children:"CVV"}),a.jsxs("div",{className:Z(Ct,G.cvv?kt:q.cvv&&ne("cvv")?Nt:Rt),"data-testid":"movmo-card-cvv-shell",children:[a.jsxs("div",{className:"relative h-full flex-1",children:[a.jsx("div",{id:"movmo-card-cvv","aria-labelledby":"movmo-card-cvv-label","aria-busy":h!=="ready","aria-describedby":(ee==null?void 0:ee.field)==="cvv"?"movmo-card-row-error":void 0,className:"absolute inset-0","data-testid":"movmo-card-cvv-mount"}),h!=="ready"?a.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 right-2 animate-pulse rounded bg-grayWarm-200"}):null]}),a.jsx("button",{type:"button","aria-label":"CVV help",tabIndex:-1,className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full border border-grayWarm-300 text-xs text-grayWarm-500",title:H==="american_express"?"The 4 numbers on the front of your card.":"The 3 numbers on the back of your card.","data-testid":"movmo-cvv-help",children:"?"})]})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"movmo-card-zip",className:"sr-only",children:"Postal code"}),a.jsx("input",{id:"movmo-card-zip",ref:he,type:"text",autoComplete:"postal-code",placeholder:"Postal code",value:de,onChange:p=>{ge(Ut(p.target.value))},onBlur:()=>J("zip"),"aria-invalid":q.zip&&ne("zip"),"aria-describedby":(ee==null?void 0:ee.field)==="zip"?"movmo-card-row-error":void 0,className:Z(ft,q.zip&&ne("zip")?"border-error-500":"border-grayWarm-300"),disabled:De,required:!0,"data-testid":"movmo-card-zip-input"})]})]}),ee&&a.jsx("p",{id:"movmo-card-row-error",className:"mt-1 text-xs text-error-700","data-testid":"movmo-card-row-error",children:ee.message})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"movmo-card-cardholder-name",className:"sr-only",children:"Cardholder name"}),a.jsx("input",{id:"movmo-card-cardholder-name",type:"text",autoComplete:"cc-name",placeholder:"Cardholder name",value:_,onChange:p=>k(p.target.value),onBlur:()=>J("name"),"aria-invalid":Re,"aria-describedby":Re?"movmo-card-name-error":void 0,className:Z(ft,Re?"border-error-500":"border-grayWarm-300"),disabled:De,required:!0,"data-testid":"movmo-card-cardholder-name-input"}),Re&&a.jsx("p",{id:"movmo-card-name-error",className:"mt-1 text-xs text-error-700","data-testid":"movmo-card-name-error",children:bt.name})]}),!N&&!x?a.jsx("button",{type:"submit",disabled:!ie,className:Z("inline-flex h-11 items-center justify-center rounded-md bg-brand-500 px-4 text-sm font-semibold text-white transition-colors hover:bg-brand-600","disabled:cursor-not-allowed disabled:bg-grayWarm-300 disabled:text-grayWarm-500"),"data-testid":"movmo-card-save",children:xe?"Saving…":h==="loading"?"Loading…":"Save card"}):N?a.jsx("div",{className:"text-center","aria-live":"polite","data-testid":"movmo-card-autosave-status",children:xe?a.jsx("p",{className:"text-sm text-grayWarm-500","data-testid":"movmo-card-autosaving",children:"Saving card…"}):ke.length>0?a.jsx("p",{className:"text-xs text-grayWarm-600","data-testid":"movmo-card-autosave-hint",children:vr}):null}):null]})};gt.displayName="MovmoCardForm";const It=t=>{const[r,n]=s.useState("idle"),[o,l]=s.useState(null);return{deletePaymentMethod:s.useCallback(async m=>{n("pending"),l(null);try{await dr(t,m),n("idle")}catch(y){const f=y instanceof Error?y.message:"Failed to delete payment method.";throw l(f),n("error"),y}},[t]),status:r,error:o}},Lt=t=>{const[r,n]=s.useState("idle"),[o,l]=s.useState(null);return{setDefault:s.useCallback(async m=>{n("pending"),l(null);try{await At(t,m,{isDefault:!0}),n("idle")}catch(y){const f=y instanceof Error?y.message:"Failed to set default payment method.";throw l(f),n("error"),y}},[t]),status:r,error:o}},Bt=t=>{const[r,n]=s.useState("idle"),[o,l]=s.useState(null);return{updatePaymentMethod:s.useCallback(async(m,y)=>{n("pending"),l(null);try{await At(t,m,y),n("idle")}catch(f){const N=f instanceof Error?f.message:"Failed to update payment method.";throw l(N),n("error"),f}},[t]),status:r,error:o}},Yt=t=>{const[r,n]=s.useState([]),[o,l]=s.useState("idle"),[c,m]=s.useState(null),[y,f]=s.useState(0),N=s.useRef(null);s.useEffect(()=>{var g;if((g=N.current)==null||g.abort(),!t){N.current=null,n([]),m(null),l("ready");return}const x=new AbortController;return N.current=x,l("loading"),m(null),cr(t,x.signal).then(j=>{x.signal.aborted||(n(j),l("ready"))}).catch(j=>{if(x.signal.aborted||j instanceof DOMException&&j.name==="AbortError")return;const P=j instanceof Error?j.message:"Failed to fetch payment methods.";m(P),l("error")}),()=>{x.abort()}},[t,y]);const E=s.useCallback(()=>{f(x=>x+1)},[]);return{items:r,status:o,error:c,refetch:E}},Vt=({open:t,onClose:r,title:n,titleId:o,formId:l,saveDisabled:c,saveLabel:m="Save",isSaving:y=!1,testIdPrefix:f="payment-method",children:N})=>(s.useEffect(()=>{if(!t)return;const E=x=>{x.key==="Escape"&&r()};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[t,r]),s.useEffect(()=>{if(!t)return;const E=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=E}},[t]),t?a.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":o,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:E=>{E.target===E.currentTarget&&r()},"data-testid":`${f}-modal`,children:a.jsxs("div",{className:"flex max-h-full w-full max-w-md flex-col rounded-xl bg-white shadow-2xl",children:[a.jsxs("div",{className:"flex items-center gap-3 border-b border-grayWarm-200 px-4 py-3",children:[a.jsx("button",{type:"button",onClick:r,"aria-label":`Close ${n.toLowerCase()} dialog`,className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-grayWarm-100 p-2 text-grayWarm-950 transition-colors hover:bg-grayWarm-200","data-testid":`${f}-close`,children:a.jsx("svg",{viewBox:"0 0 20 20",width:"20",height:"20","aria-hidden":"true",children:a.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"currentColor",strokeWidth:"1.67",strokeLinecap:"round",strokeLinejoin:"round"})})}),a.jsx("h2",{id:o,className:"flex-1 text-center text-base font-semibold text-grayWarm-900",children:n}),a.jsx("span",{"aria-hidden":"true",className:"h-9 w-9 flex-shrink-0"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:N}),a.jsxs("div",{className:"flex gap-3 border-t border-grayWarm-200 p-4",children:[a.jsx("button",{type:"button",onClick:r,className:"inline-flex h-11 flex-1 items-center justify-center rounded-lg border border-grayWarm-300 px-4 text-sm font-semibold text-grayWarm-900 transition-colors hover:border-grayWarm-900 hover:shadow-[0_0_0_1px_#1c1917]","data-testid":`${f}-cancel`,children:"Cancel"}),a.jsx("button",{type:"submit",form:l,disabled:y?!1:c,"aria-disabled":y||c,"aria-busy":y,className:Z("inline-flex h-11 flex-1 items-center justify-center rounded-lg bg-brand-500 px-4 text-sm font-semibold text-white transition-colors",y?"cursor-not-allowed opacity-90 pointer-events-none":"hover:bg-brand-600 disabled:cursor-not-allowed disabled:bg-grayWarm-300 disabled:text-grayWarm-500"),"data-testid":`${f}-save`,children:y?a.jsxs(a.Fragment,{children:[a.jsxs("svg",{className:"h-[18px] w-[18px] animate-spin",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeOpacity:"0.25"}),a.jsx("path",{d:"M22 12a10 10 0 0 1-10 10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}),a.jsx("span",{className:"sr-only",children:"Saving"})]}):m})]})]})}):null),Er=({open:t,onClose:r,formId:n,saveDisabled:o,saveLabel:l="Save",isSaving:c=!1,children:m})=>a.jsx(Vt,{open:t,onClose:r,title:"Add payment method",titleId:"movmo-add-payment-title",formId:n,saveDisabled:o,saveLabel:l,isSaving:c,testIdPrefix:"add-payment-method",children:m}),jr=(t,r)=>`${String(t).padStart(2,"0")}/${r}`,_r=t=>{if(!t)return"Card";const r=t.toLowerCase();return r==="amex"?"Amex":r.charAt(0).toUpperCase()+r.slice(1)},Cr=({open:t,method:r,onClose:n,onSave:o,isSaving:l=!1,error:c=null})=>{const m=s.useId(),[y,f]=s.useState(""),[N,E]=s.useState("");if(s.useEffect(()=>{t&&r&&(f(r.cardholderName??""),E(r.zip??""))},[t,r]),!r)return null;const x=y.trim(),g=N.trim(),j=x!==(r.cardholderName??"").trim(),P=g!==(r.zip??"").trim(),re=j||P,A=(!j||x.length>0)&&(!P||$t(g)),_=!re||!A,k=D=>{if(D.preventDefault(),_||l)return;const pe={};j&&(pe.cardholderName=x),P&&(pe.zip=g),o(pe).catch(()=>{})};return a.jsxs(Vt,{open:t,onClose:n,title:"Edit payment method",titleId:"movmo-edit-payment-title",formId:m,saveDisabled:_,isSaving:l,testIdPrefix:"edit-payment-method",children:[a.jsxs("div",{className:"mb-4 flex items-start gap-3 rounded-lg bg-grayWarm-50 p-3","data-testid":"edit-payment-method-context",children:[a.jsx(ze,{brand:r.brand,className:"flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"text-lg font-semibold text-grayWarm-950",children:[_r(r.brand)," •••• ",r.last4]}),a.jsxs("div",{className:"text-sm text-grayWarm-600",children:["Exp. ",jr(r.expMonth,r.expYear)]})]})]}),a.jsxs("form",{id:m,onSubmit:k,className:"flex flex-col gap-4",noValidate:!0,children:[a.jsxs("label",{className:"flex flex-col gap-1.5 text-sm font-medium text-grayWarm-700",children:["Cardholder name",a.jsx("input",{type:"text",autoComplete:"cc-name",value:y,onChange:D=>f(D.target.value),disabled:l,maxLength:255,"data-testid":"edit-payment-method-cardholder",className:"h-11 rounded-lg border border-grayWarm-300 px-3 text-base font-normal text-grayWarm-950 focus:border-grayWarm-950 focus:outline-none focus:ring-1 focus:ring-grayWarm-950"})]}),a.jsxs("label",{className:"flex flex-col gap-1.5 text-sm font-medium text-grayWarm-700",children:["Postal code",a.jsx("input",{type:"text",autoComplete:"postal-code",value:N,onChange:D=>E(Ut(D.target.value)),disabled:l,"data-testid":"edit-payment-method-zip",className:"h-11 rounded-lg border border-grayWarm-300 px-3 text-base font-normal text-grayWarm-950 focus:border-grayWarm-950 focus:outline-none focus:ring-1 focus:ring-grayWarm-950"})]}),c?a.jsx("p",{role:"alert",className:"text-sm text-error-700","data-testid":"edit-payment-method-error",children:c}):null]})]})},kr=t=>{if(!t)return"Card";const r=t.toLowerCase();return r==="amex"?"Amex":r.charAt(0).toUpperCase()+r.slice(1)},Ht=({method:t,trailing:r,onClick:n,cardLabelFormat:o="branded",className:l})=>a.jsxs("div",{className:Z("flex items-center gap-3",n&&"cursor-pointer",l),onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:n?c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n())}:void 0,"data-testid":`payment-method-preview-${t.id}`,children:[a.jsx(ze,{brand:t.brand,width:34,className:"flex-shrink-0"}),a.jsx("span",{className:"flex-1 text-lg font-semibold text-grayWarm-950",children:o==="masked"?`•••• ${t.last4}`:`${kr(t.brand)} ${t.last4}`}),r]}),Rr=(t,r,n=new Date)=>r<n.getFullYear()||r===n.getFullYear()&&t<n.getMonth()+1,St=t=>{if(!t)return"Card";const r=t.toLowerCase();return r==="amex"?"Amex":r.charAt(0).toUpperCase()+r.slice(1)},Nr=(t,r)=>`${String(t).padStart(2,"0")}/${r}`,Sr=({method:t,selectable:r,selected:n,onSelect:o,onSetDefault:l,onRemove:c,onEdit:m,disabled:y,showDefaultBadge:f,hideSetDefaultMenuItem:N,cardLabelFormat:E="branded"})=>{const[x,g]=s.useState(!1),j=s.useRef(null),P=Rr(t.expMonth,t.expYear);s.useEffect(()=>{if(!x)return;const A=_=>{var k;(k=j.current)!=null&&k.contains(_.target)||g(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[x]);const re=()=>{r&&o&&!y&&o(t)};return a.jsxs("div",{className:Z("flex items-start gap-3 transition-colors",r?"rounded-lg border px-3 py-3":"py-4",r&&!y&&"cursor-pointer",r&&(n?"border-grayWarm-950 shadow-[0_0_0_1px_#1c1917]":"border-grayWarm-200 hover:border-grayWarm-300")),onClick:re,"data-testid":`payment-method-row-${t.id}`,children:[r?a.jsx("input",{type:"radio",name:"movmo-payment-method",checked:n,onChange:()=>o==null?void 0:o(t),onClick:A=>A.stopPropagation(),"aria-label":`Select ${St(t.brand)} ending ${t.last4}`,className:"mr-1 h-4 w-4 mt-2 cursor-pointer appearance-none rounded-full border-2 border-grayWarm-300 checked:border-[5px] checked:border-grayWarm-950 bg-white checked:bg-white focus:ring-0 focus:ring-offset-0",disabled:y}):null,a.jsx(ze,{brand:t.brand,className:"flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"text-lg font-semibold text-grayWarm-950",children:E==="masked"?`•••• ${t.last4}`:`${St(t.brand)} ${t.last4}`}),f&&t.isDefault?a.jsx("span",{className:"inline-flex items-center rounded-full bg-success-50 px-2 py-0.5 text-xs font-semibold text-success-700","data-testid":`badge-default-${t.id}`,children:"Default"}):null,P?a.jsx("span",{className:"inline-flex items-center rounded-full bg-error-50 px-2 py-0.5 text-xs font-semibold text-error-700","data-testid":`badge-expired-${t.id}`,children:"Expired"}):null]}),a.jsxs("div",{className:Z("text-base",P?"text-grayWarm-400":"text-grayWarm-600"),children:["Exp. ",Nr(t.expMonth,t.expYear)]})]}),a.jsxs("div",{className:"relative flex-shrink-0",ref:j,children:[a.jsx("button",{type:"button","aria-label":`Open actions for card ending ${t.last4}`,"aria-haspopup":"menu","aria-expanded":x,className:"rounded-lg p-2 text-grayWarm-600 transition-colors hover:bg-grayWarm-100 disabled:cursor-not-allowed disabled:opacity-50",disabled:y,onClick:A=>{A.stopPropagation(),g(_=>!_)},"data-testid":`menu-trigger-${t.id}`,children:a.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})}),x?a.jsxs("div",{role:"menu",className:Z("absolute z-10 whitespace-nowrap rounded-lg border border-grayWarm-200 bg-white py-1 shadow-lg",r?"bottom-full left-1/2 mb-2 -translate-x-1/2":"right-0 top-full mt-1"),onClick:A=>A.stopPropagation(),"data-testid":`menu-${t.id}`,children:[r?a.jsx("span",{"aria-hidden":"true",className:"absolute -bottom-1.5 left-1/2 h-3 w-3 -translate-x-1/2 rotate-45 border-b border-r border-grayWarm-200 bg-white"}):null,!t.isDefault&&!N?a.jsx("button",{type:"button",role:"menuitem",className:"block w-full px-4 py-1 text-left text-md font-semibold text-grayWarm-950 hover:text-grayWarm-700",onClick:()=>{g(!1),l(t)},"data-testid":`menu-set-default-${t.id}`,children:"Set as default"}):null,m&&t.vault==="spreedly"?a.jsx("button",{type:"button",role:"menuitem",className:"block w-full px-4 py-1 text-left text-md font-semibold text-grayWarm-950 hover:text-grayWarm-700",onClick:()=>{g(!1),m(t)},"data-testid":`menu-edit-${t.id}`,children:"Edit"}):null,a.jsx("button",{type:"button",role:"menuitem",className:"block w-full px-4 py-1 text-left text-md font-semibold text-error-700 hover:text-error-500",onClick:()=>{g(!1),c(t)},"data-testid":`menu-remove-${t.id}`,children:"Delete"})]}):null]})]})},Pr=t=>`${Ye().iconCdnBaseUrl}/website/assets/icons/payments/${t}.svg`,ht=({slug:t,alt:r})=>a.jsx("img",{src:Pr(t),alt:r,height:20,loading:"lazy",style:{height:20,width:"auto"}}),ct=({type:t,label:r,iconNode:n,disabled:o=!1})=>a.jsxs("label",{className:"flex cursor-pointer items-center gap-3 rounded-lg border border-grayWarm-200 px-4 py-3 transition-colors hover:border-grayWarm-300","data-testid":`payment-type-${t}`,children:[a.jsx("input",{type:"radio",name:"movmo-payment-type",value:t,disabled:o,onChange:()=>{},className:Z("h-4 w-4 accent-grayWarm-900",o?"cursor-not-allowed":"cursor-pointer"),"aria-label":r}),a.jsxs("span",{className:"flex flex-1 items-center gap-2 text-sm font-semibold text-grayWarm-900",children:[r,n]})]}),Pt=({selected:t,onSelect:r,creditCardBody:n,disabled:o=!1,className:l})=>{const c=t==="credit_card";return a.jsxs("div",{className:Z("flex w-full flex-col gap-3",l),children:[a.jsxs("label",{className:Z("flex cursor-pointer flex-col gap-3 rounded-lg border px-4 py-3 transition-colors",c?"border-grayWarm-900 shadow-[0_0_0_1px_#1c1917]":"border-grayWarm-200"),"data-testid":"payment-type-credit_card",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("input",{type:"radio",name:"movmo-payment-type",value:"credit_card",checked:c,disabled:o,onChange:()=>{o||r("credit_card")},className:Z("h-4 w-4 accent-grayWarm-900",o?"cursor-not-allowed":"cursor-pointer"),"aria-label":"Credit card"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-grayWarm-900",children:"Credit card"}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(ze,{brand:"mastercard",width:28}),a.jsx(ze,{brand:"visa",width:28}),a.jsx(ze,{brand:"amex",width:28}),a.jsx(ze,{brand:"discover",width:28})]})]}),c?a.jsx("div",{"data-testid":"payment-type-credit_card-body",children:n}):null]}),c?a.jsx("p",{className:"mt-2 text-sm font-semibold text-grayWarm-900","data-testid":"payment-type-other-options-header",children:"Other options"}):null,a.jsx(ct,{type:"paypal",label:"PayPal",iconNode:a.jsx(ht,{slug:"paypal",alt:"PayPal"}),disabled:o}),a.jsx(ct,{type:"googlepay",label:"GooglePay",iconNode:a.jsx(ht,{slug:"google-pay",alt:"GooglePay"}),disabled:o}),a.jsx(ct,{type:"klarna",label:"Klarna",iconNode:a.jsx(ht,{slug:"klarna",alt:"Klarna"}),disabled:o}),a.jsx(ct,{type:"ach",label:"Bank account (ACH)",iconNode:a.jsx("span",{className:"text-xs font-medium text-grayWarm-500",children:"Direct debit"}),disabled:o})]})},Tt="movmo-add-payment-form",Tr=t=>{console.error("@movmo_app/payments: failed to update payment method",t);const r=t instanceof Error?t.message.trim():"";return/spreedly-backed cards/i.test(r)?"This card's details can't be edited.":r||"Failed to update payment method."},Ft=t=>{const r=t.filter(o=>o.isDefault),n=t.filter(o=>!o.isDefault);return[...r,...n]},Wt=({message:t,testId:r})=>a.jsx("p",{role:"alert","aria-live":"polite",className:"mt-3 rounded-md bg-error-50 px-3 py-2 text-sm text-error-700","data-testid":r,children:t}),Mt=({withDefaultBadge:t=!1})=>a.jsxs("div",{className:"flex items-start justify-between py-4","data-testid":"payment-method-skeleton",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"h-8 w-[46px] flex-shrink-0 animate-pulse rounded bg-grayWarm-200"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"h-5 w-[120px] animate-pulse rounded bg-grayWarm-200"}),t?a.jsx("div",{className:"h-5 w-[56px] animate-pulse rounded-full bg-grayWarm-200"}):null]}),a.jsx("div",{className:"h-4 w-[100px] animate-pulse rounded bg-grayWarm-200"})]})]}),a.jsx("div",{className:"h-5 w-5 flex-shrink-0 animate-pulse rounded-full bg-grayWarm-200"})]}),Gt=({userId:t,defaultCardholderName:r,defaultCardholderFirstName:n,defaultCardholderLastName:o,selectedId:l,onSelect:c,onChange:m,onError:y,onEvent:f,paymentTypeSelector:N=!0,autoSaveFirstCard:E=!0,selectionSetsDefault:x=!1,showDefaultBadge:g=!0,collapsible:j=!1,cardLabelFormat:P="branded",className:re})=>{const{items:A,status:_,error:k,refetch:D}=Yt(t),{deletePaymentMethod:pe,status:de}=It(t),{setDefault:ge,status:ue}=Lt(t),{updatePaymentMethod:se,status:X}=Bt(t),[w,ye]=s.useState([]),_e=s.useRef(w);s.useEffect(()=>{_e.current=w},[w]);const[z,h]=s.useState(null),[v,S]=s.useState(!1),[M,te]=s.useState(null),[ae,H]=s.useState(!1),[G,Y]=s.useState(!1),[T,K]=s.useState(null),[Ce,ve]=s.useState(null),[q,we]=s.useState(null),[J,Pe]=s.useState(!1),ke=s.useRef(!1),ne=s.useRef(y);s.useEffect(()=>{ne.current=y},[y]);const Q=s.useCallback(u=>{var L;(L=ne.current)==null||L.call(ne,u)},[]),Te=s.useRef(f);s.useEffect(()=>{Te.current=f},[f]);const $=s.useCallback((u,L)=>{var I;(I=Te.current)==null||I.call(Te,u,L)},[]),oe=s.useRef(!1),Re=s.useCallback(u=>{if(u.touchedInvalid.length===0){oe.current=!1;return}oe.current||(oe.current=!0,$("validation_error",{field_count:u.touchedInvalid.length,fields:u.touchedInvalid}))},[$]),ee=s.useCallback(()=>{S(!1),te(null),we(null),oe.current=!1},[]),Ee=r??([n,o].filter(Boolean).join(" ")||void 0);s.useEffect(()=>{_==="ready"&&ye(Ft(A))},[A,_]);const Fe=s.useRef(null);s.useEffect(()=>{if(_==="error"&&k){if(Fe.current===k)return;Fe.current=k,Q({source:"list",message:k})}else _!=="error"&&(Fe.current=null)},[_,k,Q]),s.useEffect(()=>{if(!c||ke.current||_!=="ready"||w.length===0||l)return;ke.current=!0,$("autoselected",{had_saved_methods:!0});const u=w.find(L=>L.isDefault)??w[0];c(u)},[c,_,w,l,$]);const he=s.useCallback(u=>{ye(L=>{const I=typeof u=="function"?u(L):u,U=Ft(I);return queueMicrotask(()=>m==null?void 0:m(U)),U})},[m]),Ie=de==="pending"||ue==="pending"||X==="pending",xe=s.useCallback(async u=>{const L=w;h(null),he(I=>I.map(U=>({...U,isDefault:U.id===u.id})));try{await ge(u.id),D(),$("set_default")}catch(I){ye(L),m==null||m(L);const U=I instanceof Error?I.message:"Failed to set default payment method.";h(U),Q({source:"set-default",message:U,cause:I})}},[w,he,ge,D,m,Q,$]),ie=s.useCallback(u=>{c==null||c(u),x&&(u.isDefault||xe(u))},[c,x,xe]),We=s.useCallback(u=>{$("selected",{method_count:w.length}),ie(u)},[$,w,ie]),Me=s.useCallback(async u=>{const L=w;h(null);const I=w.filter(Oe=>Oe.id!==u.id);he(()=>I);const U=u.id===l&&c?I.find(Oe=>Oe.isDefault)??I[0]??null:null;U&&ie(U);const je=!!U&&x&&U!==null&&!U.isDefault;try{await pe(u.id),je||D(),$("deleted",{remaining_count:I.length})}catch(Oe){ye(L),m==null||m(L);const it=Oe instanceof Error?Oe.message:"Failed to delete payment method.";h(it),Q({source:"delete",message:it,cause:Oe})}},[w,he,pe,D,m,l,c,ie,x,Q,$]),Ae=s.useCallback(u=>{ve(null),K(u)},[]),Le=s.useCallback(()=>{K(null),ve(null)},[]),De=s.useCallback(async u=>{if(!T)return;const L=T,I=w;ve(null),he(U=>U.map(je=>je.id===L.id?{...je,...u.cardholderName!==void 0?{cardholderName:u.cardholderName}:{},...u.zip!==void 0?{zip:u.zip}:{}}:je));try{await se(L.id,u),Le(),D(),$("edited",{fields:Object.keys(u)})}catch(U){ye(I),m==null||m(I);const je=Tr(U);ve(je),Q({source:"update",message:je,cause:U})}},[T,w,he,se,D,m,Le,Q,$]),Ne=s.useCallback(u=>{ee(),he(I=>[u,...I.filter(U=>U.id!==u.id)]),ie(u),!!c&&x&&!u.isDefault||D(),$("added",{method_count:_e.current.length+1})},[ee,he,D,ie,c,x,$]),p=s.useCallback(u=>{te(u)},[]),O=s.useCallback(u=>{Y(u),u&&te(null)},[]),me=_==="ready"&&w.length===0,le=typeof c=="function",at=!le&&!j,st=w.length===0,nt=E&&w.length===0,$e=s.useCallback(u=>a.jsx(gt,{userId:t,isDefault:st,defaultCardholderName:Ee,autoSave:!u&&nt,hideInternalSaveButton:u,formId:u?Tt:void 0,onCanSubmitChange:u?H:void 0,onSavingChange:O,autoFocus:u?"number":void 0,onSuccess:Ne,onError:p,onErrorDetail:Q,onValidationChange:Re}),[t,st,Ee,nt,Ne,p,O,Q,Re]),Ve=s.useMemo(()=>$e(!1),[$e]),Se=s.useMemo(()=>$e(!0),[$e]),Ue=!t,Xe=s.useMemo(()=>N?a.jsx(Pt,{selected:q,onSelect:u=>we(u),creditCardBody:Ve,disabled:Ue}):Ve,[N,q,Ve,Ue]),ot=s.useMemo(()=>N?a.jsx(Pt,{selected:q,onSelect:u=>we(u),creditCardBody:Se,disabled:Ue}):Se,[N,q,Se,Ue]);return a.jsxs("div",{className:Z("flex w-full flex-col gap-4",re),"data-testid":"payment-methods-manager",children:[_==="loading"&&w.length===0?a.jsxs("div",{className:Z(at?"flex flex-col divide-y divide-grayWarm-200 rounded-xl border border-grayWarm-200 px-4 md:px-6":"flex flex-col gap-2"),"data-testid":"payment-methods-loading",children:[a.jsx(Mt,{withDefaultBadge:!0}),a.jsx(Mt,{})]}):null,_==="error"?a.jsxs("div",{role:"alert","aria-live":"polite",className:"flex items-center justify-between gap-3 rounded-md bg-error-50 p-3 text-sm text-error-700","data-testid":"payment-methods-list-error",children:[a.jsx("span",{children:k??"Failed to load payment methods."}),a.jsx("button",{type:"button",onClick:D,className:"rounded-md border border-error-700 px-3 py-1 text-xs font-semibold text-error-700 hover:bg-error-50",children:"Retry"})]}):null,z?a.jsx("div",{role:"alert","aria-live":"polite",className:"rounded-md bg-error-50 p-3 text-sm text-error-700","data-testid":"payment-methods-mutation-error",children:z}):null,j&&w.length>0?a.jsx("div",{className:"border-t border-grayWarm-200 pt-4",children:a.jsxs("div",{className:"flex items-center justify-between","data-testid":J?"payment-methods-drawer-header":"payment-methods-collapsed-preview",children:[J?a.jsx("h3",{className:"text-md font-semibold text-grayWarm-950",children:"Payment methods"}):a.jsx(Ht,{method:w.find(u=>u.id===l)??w.find(u=>u.isDefault)??w[0],cardLabelFormat:P,className:"flex-1"}),a.jsx("button",{type:"button","aria-label":J?"Collapse payment methods":"Expand payment methods","aria-expanded":J,className:"bg-grayWarm-100 p-2 rounded-lg hover:bg-grayWarm-200 transition-colors",onClick:()=>Pe(u=>!u),"data-testid":J?"payment-methods-drawer-close":"payment-methods-drawer-open",children:a.jsx("img",{src:`${Ye().iconCdnBaseUrl}/website/assets/icons/chevron-${J?"up":"down"}-double.svg`,alt:"",className:"w-5 h-5"})})]})}):null,w.length>0&&(!j||J)?a.jsx("div",{className:Z("flex flex-col",at?"rounded-xl border border-grayWarm-200 px-4 md:px-6 divide-y divide-grayWarm-200":"space-y-3"),children:w.map(u=>a.jsx(Sr,{method:u,selectable:le,selected:le&&u.id===l,onSelect:We,onSetDefault:xe,onRemove:Me,onEdit:Ae,disabled:Ie,showDefaultBadge:g,hideSetDefaultMenuItem:x,cardLabelFormat:P},u.id))}):null,me?a.jsxs("div",{"data-testid":"payment-methods-empty",children:[Xe,M&&!v?a.jsx(Wt,{message:M,testId:"payment-methods-inline-error"}):null]}):w.length>0&&(!j||J)?a.jsx("button",{type:"button",onClick:()=>{te(null),we(null),H(!1),S(!0),oe.current=!1},onMouseEnter:()=>{xt().catch(()=>{})},onFocus:()=>{xt().catch(()=>{})},className:"self-start rounded-lg bg-brand-50 px-6 py-3 text-md font-semibold text-brand-600 transition-colors hover:bg-brand-100","data-testid":"payment-methods-add-trigger",children:"Add payment method"}):null,a.jsxs(Er,{open:v,onClose:ee,formId:Tt,saveDisabled:!ae,isSaving:G,children:[ot,M?a.jsx(Wt,{message:M,testId:"payment-methods-modal-error"}):null]}),a.jsx(Cr,{open:T!==null,method:T,onClose:Le,onSave:De,isSaving:X==="pending",error:Ce})]})};Gt.displayName="PaymentMethodsManager";const Fr="/v1/auth/",Wr="movmo_csrf_token",Mr=t=>{if(typeof document>"u")return null;const r=document.cookie?document.cookie.split(";"):[];for(const n of r){const o=n.trim();if(o.startsWith(t+"="))return decodeURIComponent(o.substring(t.length+1))}return null},Or=t=>typeof t=="string"?t:t instanceof URL?t.href:t.url,Ar=()=>{if(typeof globalThis<"u"&&typeof globalThis.fetch=="function")return globalThis.fetch.bind(globalThis);throw new Error("@movmo_app/payments: no global fetch available in this environment")},Dr=t=>{const{refreshSession:r,onRefreshFailed:n,csrfCookieName:o=Wr,extraHeaders:l,authPathFragment:c=Fr,baseFetch:m=Ar(),readCookie:y=Mr}=t;let f=null;const N=()=>{if(f)return f;const x=(async()=>{await r()})();return f=x,x.finally(()=>{f===x&&(f=null)}).catch(()=>{}),x},E=(x,g)=>{const j=new Headers(g==null?void 0:g.headers),P=y(o);if(P&&!j.has("X-CSRF-Token")&&j.set("X-CSRF-Token",P),l){const re=l(x,g);for(const[A,_]of Object.entries(re))j.has(A)||j.set(A,_)}return{...g,headers:j,credentials:(g==null?void 0:g.credentials)??"include"}};return async function(g,j){const P=await m(g,E(g,j));if(Or(g).includes(c)||P.status!==401&&P.status!==403)return P;try{await N()}catch(_){try{n(_)}catch(k){console.error("@movmo_app/payments: onRefreshFailed callback threw — auth retry path is misconfigured",k)}return P}try{return await m(g,E(g,j))}catch(_){return console.error("@movmo_app/payments: retry after token refresh failed — returning original response",_),P}}};exports.MovmoCardForm=gt;exports.PaymentMethodPreview=Ht;exports.PaymentMethodsManager=Gt;exports.createMovmoAuthFetch=Dr;exports.getPaymentsConfig=Ye;exports.setPaymentsConfig=or;exports.useDeletePaymentMethod=It;exports.useMovmoCardFields=Dt;exports.useSetDefaultPaymentMethod=Lt;exports.useUpdatePaymentMethod=Bt;exports.useUserPaymentMethods=Yt;
30
+ <%s key={someKey} {...props} />`,mt,Be,tr,Be),jt[Be+mt]=!0}}return t===o?ct(H):Me(H),H}}function Zt(t,i,d){return _t(t,i,d,!0)}function Xt(t,i,d){return _t(t,i,d,!1)}var Qt=Xt,er=Zt;tt.Fragment=o,tt.jsx=Qt,tt.jsxs=er}()),tt}process.env.NODE_ENV==="production"?vt.exports=sr():vt.exports=or();var a=vt.exports;function Dt(e){var r,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(r=0;r<l;r++)e[r]&&(n=Dt(e[r]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function X(){for(var e,r,n=0,o="",l=arguments.length;n<l;n++)(e=arguments[n])&&(r=Dt(e))&&(o&&(o+=" "),o+=r);return o}const ir="https://core.spreedly.com/iframe/iframe-v1.min.js",lr="https://cdn.e2e.movmo.io";let Ge={};const cr=e=>{Ge={...Ge,...e}},ft=e=>{var n;const r=globalThis.process;return(n=r==null?void 0:r.env)==null?void 0:n[e]},Ye=()=>({baseUrl:Ge.baseUrl??ft("REACT_APP_MOVMO_API_URL")??"",spreedlyScriptUrl:Ge.spreedlyScriptUrl??ft("REACT_APP_SPREEDLY_SCRIPT_URL")??ir,iconCdnBaseUrl:Ge.iconCdnBaseUrl??ft("REACT_APP_MOVMO_ICON_CDN_URL")??lr,fetch:Ge.fetch??(typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):(()=>{throw new Error("@movmo_app/payments: no fetch available")})())}),dr="recovery_cooldown",ur=(e,r)=>{if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";try{return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZone:r}).format(n)}catch{return""}},mr=e=>{const r=ur(e??"");return r?`Account recovery is in progress. You can change payment methods after ${r}.`:"Account recovery is in progress. You can change payment methods once it ends."},gt=e=>({id:e.id,last4:e.last4,brand:e.brand,expMonth:e.expMonth,expYear:e.expYear,isDefault:e.isDefault,vault:e.vault,cardholderName:e.cardholderName,zip:e.zip}),Ke={Accept:"application/json","Content-Type":"application/json"},Je=e=>{const{baseUrl:r}=Ye();if(!r)throw new Error("@movmo_app/payments: baseUrl is not configured. Call setPaymentsConfig({ baseUrl }) at app boot, or set REACT_APP_MOVMO_API_URL.");return`${r}${e}`},Ze=(e,r)=>{const{fetch:n}=Ye();return n(e,r)};class wt extends Error{constructor(n,o){super(n);qe(this,"status");qe(this,"code");qe(this,"until");this.name="PaymentsApiError",this.status=o.status,this.code=o.code,this.until=o.until}}const fr=async e=>{try{const r=await e.json();if(typeof r!="object"||r===null)return{};const{message:n,code:o,until:l}=r;return{message:typeof n=="string"?n:void 0,code:typeof o=="string"?o:void 0,until:typeof l=="string"?l:void 0}}catch{return{}}},Xe=async(e,r)=>{const{message:n,code:o,until:l}=await fr(e),c=o===dr?mr(l):n||r;return new wt(c,{status:e.status,code:o,until:l})};let rt=null;const xt=()=>{if(rt)return rt;const e=(async()=>{const r=await Ze(Je("/v1/payments/tokenization-session"),{method:"GET",headers:Ke,credentials:"include"});if(!r.ok)throw await Xe(r,`Failed to fetch tokenization session (${r.status})`);return await r.json()})();return rt=e,e.finally(()=>{rt===e&&(rt=null)}).catch(()=>{}),e},pr=e=>typeof e.brand=="string"&&typeof e.last4=="string"&&typeof e.expMonth=="number"&&typeof e.expYear=="number",hr=async(e,r,n)=>{const o=await Ze(Je(`/v1/users/${encodeURIComponent(e)}/payment-methods/from-token`),{method:"POST",headers:Ke,credentials:"include",body:JSON.stringify({tokenizedPaymentMethodId:r,isDefault:n})});if(!o.ok)throw await Xe(o,`Failed to save payment method (${o.status})`);const l=await o.json();if(pr(l))return gt(l);const c=await Ze(Je(`/v1/users/${encodeURIComponent(e)}/payment-methods/${encodeURIComponent(l.id)}`),{method:"GET",headers:Ke,credentials:"include"});if(!c.ok)throw await Xe(c,`Failed to fetch saved payment method (${c.status})`);const m=await c.json();return gt(m)},yr=async(e,r)=>{if(!e)return[];const n=await Ze(Je(`/v1/users/${encodeURIComponent(e)}/payment-methods`),{method:"GET",headers:Ke,credentials:"include",signal:r});if(!n.ok)throw await Xe(n,`Failed to fetch payment methods (${n.status})`);return(await n.json()??[]).map(gt)},vr=async(e,r)=>{const n=await Ze(Je(`/v1/users/${encodeURIComponent(e)}/payment-methods/${encodeURIComponent(r)}`),{method:"DELETE",headers:Ke,credentials:"include"});if(!n.ok)throw await Xe(n,`Failed to delete payment method (${n.status})`)},$t=async(e,r,n)=>{const o=await Ze(Je(`/v1/users/${encodeURIComponent(e)}/payment-methods/${encodeURIComponent(r)}`),{method:"PUT",headers:Ke,credentials:"include",body:JSON.stringify(n)});if(!o.ok)throw await Xe(o,`Failed to update payment method (${o.status})`)},nt=(e,r,n)=>r instanceof wt?{source:e,message:r.message,cause:r,status:r.status,...r.code!==void 0?{code:r.code}:{},...r.until!==void 0?{until:r.until}:{}}:{source:e,message:r instanceof Error?r.message:n,cause:r},gr={visa:"visa",master:"mastercard",mastercard:"mastercard",american_express:"amex",amex:"amex",discover:"discover"},xr=28,Ie=({brand:e,className:r,width:n=46})=>{const o=e?gr[e.toLowerCase()]??"credit-card":"credit-card",l=Math.max(n,xr),c=Math.round(l*24/34),{iconCdnBaseUrl:m}=Ye();return a.jsx("img",{src:`${m}/website/assets/icons/payments/${o}.svg`,alt:o==="credit-card"?"card":`${o} card`,"data-testid":`card-brand-${e.toLowerCase()}`,className:r,width:l,height:c,loading:"lazy"})};let at=null;const br=()=>{if(typeof window>"u")return Promise.reject(new Error("Spreedly can only be loaded in a browser environment."));if(window.Spreedly)return Promise.resolve(window.Spreedly);if(at)return at;const{spreedlyScriptUrl:e}=Ye();return at=new Promise((r,n)=>{const o=document.querySelector(`script[src="${e}"]`),l=()=>{window.Spreedly?r(window.Spreedly):n(new Error("Spreedly script loaded but window.Spreedly is undefined."))};if(o){if(window.Spreedly){l();return}o.addEventListener("load",l,{once:!0}),o.addEventListener("error",()=>{o.remove(),n(new Error("Failed to load Spreedly iframe script."))},{once:!0});return}const c=document.createElement("script");c.src=e,c.async=!0,c.onload=l,c.onerror=()=>{c.remove(),n(new Error("Failed to load Spreedly iframe script."))},document.head.appendChild(c)}).catch(r=>{throw at=null,r}),at};class dt extends Error{constructor(n,o){super(o instanceof Error?o.message:"Failed to initialize card form.");qe(this,"source");qe(this,"cause");this.name="InitError",this.source=n,this.cause=o}}const wr="movmo-card-number",Er="movmo-card-cvv",jr=e=>({first_name:e.firstName,last_name:e.lastName,month:e.month,year:e.year,...e.email?{email:e.email}:{},...e.zip?{zip:e.zip}:{}}),Ut=(e={})=>{const{numberEl:r=wr,cvvEl:n=Er,onCardTokenized:o,onFieldErrors:l,onValidityChange:c,onBrandChange:m}=e,[v,h]=s.useState("idle"),[j,_]=s.useState(null),[w,C]=s.useState(null),[x,P]=s.useState(null),[M,I]=s.useState({number:!1,cvv:!1}),[k,E]=s.useState(null),[O,pe]=s.useState({number:!1,cvv:!1}),de=s.useRef(null),we=s.useRef(o),ue=s.useRef(l),se=s.useRef(c),Q=s.useRef(m);s.useEffect(()=>{we.current=o},[o]),s.useEffect(()=>{ue.current=l},[l]),s.useEffect(()=>{se.current=c},[c]),s.useEffect(()=>{Q.current=m},[m]);const b=s.useRef({number:!1,cvv:!1});s.useEffect(()=>{let z=!1;return h("loading"),_(null),C(null),P(null),I({number:!1,cvv:!1}),E(null),b.current={number:!1,cvv:!1},(async()=>{try{const[p,y]=await Promise.all([xt().catch(S=>{throw new dt("tokenization-session",S)}),br().catch(S=>{throw new dt("spreedly-script",S)})]);if(z)return;de.current=y,y.on("ready",()=>{var S,A,re,ae,q,G;if(!z){h("ready");try{(S=y.setFieldType)==null||S.call(y,"number","tel"),(A=y.setFieldType)==null||A.call(y,"cvv","tel")}catch(V){console.warn("@movmo_app/payments: setFieldType failed",V)}try{typeof y.setNumberFormat=="function"?y.setNumberFormat("prettyFormat"):console.warn("@movmo_app/payments: Spreedly.setNumberFormat is missing — card-number digits will not be space-grouped.")}catch(V){console.warn("@movmo_app/payments: setNumberFormat failed",V)}try{(re=y.setPlaceholder)==null||re.call(y,"number","Card number"),(ae=y.setPlaceholder)==null||ae.call(y,"cvv","CVV");const V='box-sizing: border-box;width: 100%;height: 100%;margin: 0;padding: 0;border: 0;background: transparent;outline: none;font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;font-size: 14px;font-weight: 400;line-height: 20px;color: rgb(28 25 23);letter-spacing: 0;vertical-align: middle;';(q=y.setStyle)==null||q.call(y,"number",V),(G=y.setStyle)==null||G.call(y,"cvv",V)}catch(V){console.warn("@movmo_app/payments: setPlaceholder/setStyle failed",V)}}}),y.on("paymentMethod",S=>{var A;(A=we.current)==null||A.call(we,S)}),y.on("errors",S=>{var A;(A=ue.current)==null||A.call(ue,S)}),y.on("fieldEvent",(S,A,re,ae)=>{var V;if(z)return;if(A==="focus"){pe(T=>T[S]?T:{...T,[S]:!0});return}if(A==="blur"){pe(T=>T[S]?{...T,[S]:!1}:T);return}if(A!=="input")return;const q=ae??{};if(S==="number"){if(q.numberLength===0)E(T=>{var K;return T!==null&&((K=Q.current)==null||K.call(Q,null)),null});else if(q.cardType!==void 0){const T=q.cardType||null;E(K=>{var Ce;return K!==T&&((Ce=Q.current)==null||Ce.call(Q,T)),T})}}const G=S==="number"?typeof q.validNumber=="boolean"?q.validNumber:void 0:typeof q.validCvv=="boolean"?q.validCvv:void 0;if(typeof G=="boolean"){const T=b.current,K=S==="number"?{...T,number:G}:{...T,cvv:G};(K.number!==T.number||K.cvv!==T.cvv)&&(b.current=K,I(K),(V=se.current)==null||V.call(se,K))}}),y.on("consoleError",S=>{var re;const A=S instanceof Error?S.message:"An unexpected error occurred while securing your card.";(re=ue.current)==null||re.call(ue,[{message:A}])}),y.init(p.environmentKey,{numberEl:r,cvvEl:n,nonce:p.nonce,timestamp:String(p.timestamp),certificateToken:p.certificateToken,signature:p.signature})}catch(p){if(z)return;const y=p instanceof Error?p.message:"Failed to initialize card form.";_(y),C(p instanceof dt?p.source:"spreedly-script"),P(p instanceof dt?p.cause:p),h("error")}})(),()=>{var p,y;z=!0;try{(y=(p=de.current)==null?void 0:p.removeHandlers)==null||y.call(p)}catch(S){console.warn("@movmo_app/payments: removeHandlers failed during cleanup",S)}de.current=null}},[r,n]);const ye=s.useCallback(z=>{var p;(p=de.current)==null||p.tokenizeCreditCard(jr(z))},[]),_e=s.useCallback(z=>{var p,y;(y=(p=de.current)==null?void 0:p.transferFocus)==null||y.call(p,z)},[]);return{status:v,error:j,errorSource:w,errorCause:x,tokenize:ye,validity:M,brand:k,focused:O,focusField:_e}},bt={number:"Enter your card number",expiry:"Enter a valid expiry date",cvv:"Enter the security code",zip:"Enter your postal code",name:"Enter first and last name as printed on the card"},_r="Your card saves automatically once all fields are complete.",It=e=>/^[A-Za-z0-9][A-Za-z0-9 -]{1,8}[A-Za-z0-9]$/.test(e.trim()),zt=e=>{const r=e.replace(/[^A-Za-z0-9 -]/g,"").slice(0,10);if(!/^[\d-]*$/.test(r))return r;const n=r.replace(/-+/g,"-").replace(/^-/,"");return n.includes("-")?n:n.length===9?`${n.slice(0,5)}-${n.slice(5)}`:n},Cr=({hookStatus:e,validity:r,nameValid:n,expiryValid:o,zipValid:l})=>{const c=e==="ready",m=[],v=h=>m.push({field:h,message:bt[h]});return c&&!r.number&&v("number"),o||v("expiry"),c&&!r.cvv&&v("cvv"),l||v("zip"),n||v("name"),m},pt="h-11 w-full rounded-md border bg-white px-3 py-2 text-sm text-grayWarm-900 placeholder:text-grayWarm-400 outline-none focus:border-grayWarm-950 focus:shadow-[0_0_0_1px_#1c1917]",kt="flex h-11 w-full items-center gap-2 rounded-md border bg-white px-3 py-2 transition-shadow",Nt="border-grayWarm-950 shadow-[0_0_0_1px_#1c1917]",St="border-grayWarm-300",Pt="border-error-500",Rr={number:!1,expiry:!1,cvv:!1,zip:!1,name:!1},kr=e=>{const r=e.trim();if(!r)return{firstName:"",lastName:""};const n=r.lastIndexOf(" ");return n===-1?{firstName:r,lastName:""}:{firstName:r.slice(0,n).trim(),lastName:r.slice(n+1).trim()}},Lt=e=>{const r=e.replace(/\D/g,"");if(r.length<4)return{month:"",year:""};const n=r.slice(0,2),o=r.slice(2),l=o.length===2?`20${o}`:o.slice(0,4);return{month:n,year:l}},Nr=e=>{const r=e.replace(/\D/g,"").slice(0,4);return r.length<=2?r:`${r.slice(0,2)} / ${r.slice(2)}`},ht=e=>{const{month:r,year:n}=Lt(e);if(!r||!n)return!1;const o=parseInt(r,10),l=parseInt(n,10);if(isNaN(o)||o<1||o>12)return!1;const c=new Date;return!(l<c.getFullYear()||l>c.getFullYear()+20||l===c.getFullYear()&&o<c.getMonth()+1)},Et=({userId:e,onSuccess:r,onError:n,onErrorDetail:o,isDefault:l=!1,className:c,defaultCardholderName:m,defaultCardholderFirstName:v="",defaultCardholderLastName:h="",autoSave:j=!1,formId:_="movmo-card-form",hideInternalSaveButton:w=!1,onCanSubmitChange:C,onSavingChange:x,autoFocus:P,onValidationChange:M})=>{const I=m??[v,h].filter(Boolean).join(" "),[k,E]=s.useState(I),[O,pe]=s.useState(""),[de,we]=s.useState(""),[ue,se]=s.useState("idle"),Q=s.useRef(!1),b=s.useRef(o);s.useEffect(()=>{b.current=o},[o]);const ye=s.useCallback(async f=>{var D;se("saving");try{const me=await hr(e,f,l);se("ready"),r(me)}catch(me){const ne=me instanceof Error?me.message:"Failed to save payment method.";se("ready"),Q.current=!1,n(ne),(D=b.current)==null||D.call(b,{...nt("save-from-token",me,ne),message:ne})}},[e,l,r,n]),_e=s.useCallback(f=>{var me;const D=f.map(ne=>ne.message).filter(Boolean).join("; ")||"Card validation failed.";se(ne=>ne==="tokenizing"?"ready":ne),Q.current=!1,n(D),(me=b.current)==null||me.call(b,{source:"card-tokenize",message:D})},[n]),z=s.useMemo(()=>({onCardTokenized:ye,onFieldErrors:_e}),[ye,_e]),{status:p,error:y,errorSource:S,errorCause:A,tokenize:re,validity:ae,brand:q,focused:G,focusField:V}=Ut(z),T=s.useRef(!1);s.useEffect(()=>{!P||p!=="ready"||T.current||(T.current=!0,V(P))},[P,p,V]);const K=k.trim().split(/\s+/).length>=2,Ce=ht(O),ve=It(de),[J,Ee]=s.useState(Rr),Z=s.useCallback(f=>Ee(D=>D[f]?D:{...D,[f]:!0}),[]),Pe=s.useRef(G);s.useEffect(()=>{const f=Pe.current;Pe.current=G,f.number&&!G.number&&Z("number"),f.cvv&&!G.cvv&&Z("cvv")},[G,Z]);const Re=s.useMemo(()=>Cr({hookStatus:p,validity:ae,nameValid:K,expiryValid:Ce,zipValid:ve}),[p,ae,K,Ce,ve]),oe=f=>Re.some(D=>D.field===f),ee=s.useMemo(()=>Re.map(f=>f.field),[Re]),Te=s.useMemo(()=>ee.filter(f=>J[f]),[ee,J]),$=s.useRef(M);s.useEffect(()=>{$.current=M},[M]),s.useEffect(()=>{var f;(f=$.current)==null||f.call($,{valid:ee.length===0,missing:ee,touchedInvalid:Te})},[ee,Te]);const ie=J.number&&oe("number"),ke=J.name&&oe("name"),te=Re.find(f=>(f.field==="expiry"||f.field==="cvv"||f.field==="zip")&&J[f.field]),je=s.useRef(!1),Fe=s.useRef(!1),he=s.useRef(null);s.useEffect(()=>{var f;ae.cvv?Fe.current||(Fe.current=!0,(f=he.current)==null||f.focus()):Fe.current=!1},[ae.cvv]);const ze=!K||!Ce||!ve||!ae.number||!ae.cvv,ge=ue==="tokenizing"||ue==="saving",le=p==="ready"&&!ge&&!ze,Oe=s.useRef(C);s.useEffect(()=>{Oe.current=C},[C]),s.useEffect(()=>{var f;(f=Oe.current)==null||f.call(Oe,le)},[le]);const We=s.useRef(x);s.useEffect(()=>{We.current=x},[x]),s.useEffect(()=>{var f;(f=We.current)==null||f.call(We,ge)},[ge]);const Ae=s.useCallback(()=>{const{firstName:f,lastName:D}=kr(k),{month:me,year:ne}=Lt(O);se("tokenizing"),re({firstName:f,lastName:D,month:me,year:ne,zip:de.trim()})},[k,O,de,re]);s.useEffect(()=>{if(!j||!le||Q.current)return;const f=setTimeout(()=>{Q.current=!0,Ae()},1200);return()=>clearTimeout(f)},[j,le,Ae]);const Le=f=>{f.preventDefault(),le&&Ae()},De=p!=="ready"||ge,Ne=s.useRef(n);return s.useEffect(()=>{Ne.current=n},[n]),s.useEffect(()=>{var f,D;y&&((f=Ne.current)==null||f.call(Ne,y),(D=b.current)==null||D.call(b,{...nt(S??"spreedly-script",A,y),message:y}))},[y,S,A]),a.jsxs("form",{id:_,onSubmit:Le,className:X("flex w-full flex-col gap-3",c),"data-testid":"movmo-card-form",children:[a.jsxs("div",{children:[a.jsx("span",{id:"movmo-card-number-label",className:"sr-only",children:"Card number"}),a.jsxs("div",{className:X(kt,G.number?Nt:ie?Pt:St),"data-testid":"movmo-card-number-shell",children:[a.jsx(Ie,{brand:q??"",width:32,className:"flex-shrink-0"}),a.jsxs("div",{className:"relative h-full flex-1",children:[a.jsx("div",{id:"movmo-card-number","aria-labelledby":"movmo-card-number-label","aria-busy":p!=="ready","aria-describedby":ie?"movmo-card-number-error":void 0,className:"absolute inset-0","data-testid":"movmo-card-number-mount"}),p!=="ready"?a.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 right-2 animate-pulse rounded bg-grayWarm-200"}):null]})]}),ie&&a.jsx("p",{id:"movmo-card-number-error",className:"mt-1 text-xs text-error-700","data-testid":"movmo-card-number-error",children:bt.number})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"movmo-card-expiry",className:"sr-only",children:"Expiry MM / YY"}),a.jsx("input",{id:"movmo-card-expiry",type:"text",inputMode:"numeric",autoComplete:"cc-exp",placeholder:"MM / YY",value:O,onChange:f=>{const D=Nr(f.target.value);pe(D),ht(D)&&!je.current?(je.current=!0,V("cvv")):ht(D)||(je.current=!1)},onBlur:()=>Z("expiry"),"aria-invalid":J.expiry&&oe("expiry"),"aria-describedby":(te==null?void 0:te.field)==="expiry"?"movmo-card-row-error":void 0,className:X(pt,J.expiry&&oe("expiry")?"border-error-500":"border-grayWarm-300"),disabled:De,required:!0,"data-testid":"movmo-card-expiry-input"})]}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{id:"movmo-card-cvv-label",className:"sr-only",children:"CVV"}),a.jsxs("div",{className:X(kt,G.cvv?Nt:J.cvv&&oe("cvv")?Pt:St),"data-testid":"movmo-card-cvv-shell",children:[a.jsxs("div",{className:"relative h-full flex-1",children:[a.jsx("div",{id:"movmo-card-cvv","aria-labelledby":"movmo-card-cvv-label","aria-busy":p!=="ready","aria-describedby":(te==null?void 0:te.field)==="cvv"?"movmo-card-row-error":void 0,className:"absolute inset-0","data-testid":"movmo-card-cvv-mount"}),p!=="ready"?a.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 right-2 animate-pulse rounded bg-grayWarm-200"}):null]}),a.jsx("button",{type:"button","aria-label":"CVV help",tabIndex:-1,className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full border border-grayWarm-300 text-xs text-grayWarm-500",title:q==="american_express"?"The 4 numbers on the front of your card.":"The 3 numbers on the back of your card.","data-testid":"movmo-cvv-help",children:"?"})]})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"movmo-card-zip",className:"sr-only",children:"Postal code"}),a.jsx("input",{id:"movmo-card-zip",ref:he,type:"text",autoComplete:"postal-code",placeholder:"Postal code",value:de,onChange:f=>{we(zt(f.target.value))},onBlur:()=>Z("zip"),"aria-invalid":J.zip&&oe("zip"),"aria-describedby":(te==null?void 0:te.field)==="zip"?"movmo-card-row-error":void 0,className:X(pt,J.zip&&oe("zip")?"border-error-500":"border-grayWarm-300"),disabled:De,required:!0,"data-testid":"movmo-card-zip-input"})]})]}),te&&a.jsx("p",{id:"movmo-card-row-error",className:"mt-1 text-xs text-error-700","data-testid":"movmo-card-row-error",children:te.message})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"movmo-card-cardholder-name",className:"sr-only",children:"Cardholder name"}),a.jsx("input",{id:"movmo-card-cardholder-name",type:"text",autoComplete:"cc-name",placeholder:"Cardholder name",value:k,onChange:f=>E(f.target.value),onBlur:()=>Z("name"),"aria-invalid":ke,"aria-describedby":ke?"movmo-card-name-error":void 0,className:X(pt,ke?"border-error-500":"border-grayWarm-300"),disabled:De,required:!0,"data-testid":"movmo-card-cardholder-name-input"}),ke&&a.jsx("p",{id:"movmo-card-name-error",className:"mt-1 text-xs text-error-700","data-testid":"movmo-card-name-error",children:bt.name})]}),!j&&!w?a.jsx("button",{type:"submit",disabled:!le,className:X("inline-flex h-11 items-center justify-center rounded-md bg-brand-500 px-4 text-sm font-semibold text-white transition-colors hover:bg-brand-600","disabled:cursor-not-allowed disabled:bg-grayWarm-300 disabled:text-grayWarm-500"),"data-testid":"movmo-card-save",children:ge?"Saving…":p==="loading"?"Loading…":"Save card"}):j?a.jsx("div",{className:"text-center","aria-live":"polite","data-testid":"movmo-card-autosave-status",children:ge?a.jsx("p",{className:"text-sm text-grayWarm-500","data-testid":"movmo-card-autosaving",children:"Saving card…"}):Re.length>0?a.jsx("p",{className:"text-xs text-grayWarm-600","data-testid":"movmo-card-autosave-hint",children:_r}):null}):null]})};Et.displayName="MovmoCardForm";const Bt=e=>{const[r,n]=s.useState("idle"),[o,l]=s.useState(null);return{deletePaymentMethod:s.useCallback(async m=>{n("pending"),l(null);try{await vr(e,m),n("idle")}catch(v){const h=v instanceof Error?v.message:"Failed to delete payment method.";throw l(h),n("error"),v}},[e]),status:r,error:o}},Yt=e=>{const[r,n]=s.useState("idle"),[o,l]=s.useState(null);return{setDefault:s.useCallback(async m=>{n("pending"),l(null);try{await $t(e,m,{isDefault:!0}),n("idle")}catch(v){const h=v instanceof Error?v.message:"Failed to set default payment method.";throw l(h),n("error"),v}},[e]),status:r,error:o}},Vt=e=>{const[r,n]=s.useState("idle"),[o,l]=s.useState(null);return{updatePaymentMethod:s.useCallback(async(m,v)=>{n("pending"),l(null);try{await $t(e,m,v),n("idle")}catch(h){const j=h instanceof Error?h.message:"Failed to update payment method.";throw l(j),n("error"),h}},[e]),status:r,error:o}},Ht=e=>{const[r,n]=s.useState([]),[o,l]=s.useState("idle"),[c,m]=s.useState(null),[v,h]=s.useState(0),j=s.useRef(null);s.useEffect(()=>{var C;if((C=j.current)==null||C.abort(),!e){j.current=null,n([]),m(null),l("ready");return}const w=new AbortController;return j.current=w,l("loading"),m(null),yr(e,w.signal).then(x=>{w.signal.aborted||(n(x),l("ready"))}).catch(x=>{if(w.signal.aborted||x instanceof DOMException&&x.name==="AbortError")return;const P=x instanceof Error?x.message:"Failed to fetch payment methods.";m(P),l("error")}),()=>{w.abort()}},[e,v]);const _=s.useCallback(()=>{h(w=>w+1)},[]);return{items:r,status:o,error:c,refetch:_}},qt=({open:e,onClose:r,title:n,titleId:o,formId:l,saveDisabled:c,saveLabel:m="Save",isSaving:v=!1,testIdPrefix:h="payment-method",children:j})=>(s.useEffect(()=>{if(!e)return;const _=w=>{w.key==="Escape"&&r()};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[e,r]),s.useEffect(()=>{if(!e)return;const _=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=_}},[e]),e?a.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":o,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:_=>{_.target===_.currentTarget&&r()},"data-testid":`${h}-modal`,children:a.jsxs("div",{className:"flex max-h-full w-full max-w-md flex-col rounded-xl bg-white shadow-2xl",children:[a.jsxs("div",{className:"flex items-center gap-3 border-b border-grayWarm-200 px-4 py-3",children:[a.jsx("button",{type:"button",onClick:r,"aria-label":`Close ${n.toLowerCase()} dialog`,className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-grayWarm-100 p-2 text-grayWarm-950 transition-colors hover:bg-grayWarm-200","data-testid":`${h}-close`,children:a.jsx("svg",{viewBox:"0 0 20 20",width:"20",height:"20","aria-hidden":"true",children:a.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"currentColor",strokeWidth:"1.67",strokeLinecap:"round",strokeLinejoin:"round"})})}),a.jsx("h2",{id:o,className:"flex-1 text-center text-base font-semibold text-grayWarm-900",children:n}),a.jsx("span",{"aria-hidden":"true",className:"h-9 w-9 flex-shrink-0"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:j}),a.jsxs("div",{className:"flex gap-3 border-t border-grayWarm-200 p-4",children:[a.jsx("button",{type:"button",onClick:r,className:"inline-flex h-11 flex-1 items-center justify-center rounded-lg border border-grayWarm-300 px-4 text-sm font-semibold text-grayWarm-900 transition-colors hover:border-grayWarm-900 hover:shadow-[0_0_0_1px_#1c1917]","data-testid":`${h}-cancel`,children:"Cancel"}),a.jsx("button",{type:"submit",form:l,disabled:v?!1:c,"aria-disabled":v||c,"aria-busy":v,className:X("inline-flex h-11 flex-1 items-center justify-center rounded-lg bg-brand-500 px-4 text-sm font-semibold text-white transition-colors",v?"cursor-not-allowed opacity-90 pointer-events-none":"hover:bg-brand-600 disabled:cursor-not-allowed disabled:bg-grayWarm-300 disabled:text-grayWarm-500"),"data-testid":`${h}-save`,children:v?a.jsxs(a.Fragment,{children:[a.jsxs("svg",{className:"h-[18px] w-[18px] animate-spin",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeOpacity:"0.25"}),a.jsx("path",{d:"M22 12a10 10 0 0 1-10 10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}),a.jsx("span",{className:"sr-only",children:"Saving"})]}):m})]})]})}):null),Sr=({open:e,onClose:r,formId:n,saveDisabled:o,saveLabel:l="Save",isSaving:c=!1,children:m})=>a.jsx(qt,{open:e,onClose:r,title:"Add payment method",titleId:"movmo-add-payment-title",formId:n,saveDisabled:o,saveLabel:l,isSaving:c,testIdPrefix:"add-payment-method",children:m}),Pr=(e,r)=>`${String(e).padStart(2,"0")}/${r}`,Tr=e=>{if(!e)return"Card";const r=e.toLowerCase();return r==="amex"?"Amex":r.charAt(0).toUpperCase()+r.slice(1)},Fr=({open:e,method:r,onClose:n,onSave:o,isSaving:l=!1,error:c=null})=>{const m=s.useId(),[v,h]=s.useState(""),[j,_]=s.useState("");if(s.useEffect(()=>{e&&r&&(h(r.cardholderName??""),_(r.zip??""))},[e,r]),!r)return null;const w=v.trim(),C=j.trim(),x=w!==(r.cardholderName??"").trim(),P=C!==(r.zip??"").trim(),M=x||P,I=(!x||w.length>0)&&(!P||It(C)),k=!M||!I,E=O=>{if(O.preventDefault(),k||l)return;const pe={};x&&(pe.cardholderName=w),P&&(pe.zip=C),o(pe).catch(()=>{})};return a.jsxs(qt,{open:e,onClose:n,title:"Edit payment method",titleId:"movmo-edit-payment-title",formId:m,saveDisabled:k,isSaving:l,testIdPrefix:"edit-payment-method",children:[a.jsxs("div",{className:"mb-4 flex items-start gap-3 rounded-lg bg-grayWarm-50 p-3","data-testid":"edit-payment-method-context",children:[a.jsx(Ie,{brand:r.brand,className:"flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"text-lg font-semibold text-grayWarm-950",children:[Tr(r.brand)," •••• ",r.last4]}),a.jsxs("div",{className:"text-sm text-grayWarm-600",children:["Exp. ",Pr(r.expMonth,r.expYear)]})]})]}),a.jsxs("form",{id:m,onSubmit:E,className:"flex flex-col gap-4",noValidate:!0,children:[a.jsxs("label",{className:"flex flex-col gap-1.5 text-sm font-medium text-grayWarm-700",children:["Cardholder name",a.jsx("input",{type:"text",autoComplete:"cc-name",value:v,onChange:O=>h(O.target.value),disabled:l,maxLength:255,"data-testid":"edit-payment-method-cardholder",className:"h-11 rounded-lg border border-grayWarm-300 px-3 text-base font-normal text-grayWarm-950 focus:border-grayWarm-950 focus:outline-none focus:ring-1 focus:ring-grayWarm-950"})]}),a.jsxs("label",{className:"flex flex-col gap-1.5 text-sm font-medium text-grayWarm-700",children:["Postal code",a.jsx("input",{type:"text",autoComplete:"postal-code",value:j,onChange:O=>_(zt(O.target.value)),disabled:l,"data-testid":"edit-payment-method-zip",className:"h-11 rounded-lg border border-grayWarm-300 px-3 text-base font-normal text-grayWarm-950 focus:border-grayWarm-950 focus:outline-none focus:ring-1 focus:ring-grayWarm-950"})]}),c?a.jsx("p",{role:"alert",className:"text-sm text-error-700","data-testid":"edit-payment-method-error",children:c}):null]})]})},Or=e=>{if(!e)return"Card";const r=e.toLowerCase();return r==="amex"?"Amex":r.charAt(0).toUpperCase()+r.slice(1)},Gt=({method:e,trailing:r,onClick:n,cardLabelFormat:o="branded",className:l})=>a.jsxs("div",{className:X("flex items-center gap-3",n&&"cursor-pointer",l),onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:n?c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n())}:void 0,"data-testid":`payment-method-preview-${e.id}`,children:[a.jsx(Ie,{brand:e.brand,width:34,className:"flex-shrink-0"}),a.jsx("span",{className:"flex-1 text-lg font-semibold text-grayWarm-950",children:o==="masked"?`•••• ${e.last4}`:`${Or(e.brand)} ${e.last4}`}),r]}),Wr=(e,r,n=new Date)=>r<n.getFullYear()||r===n.getFullYear()&&e<n.getMonth()+1,Tt=e=>{if(!e)return"Card";const r=e.toLowerCase();return r==="amex"?"Amex":r.charAt(0).toUpperCase()+r.slice(1)},Mr=(e,r)=>`${String(e).padStart(2,"0")}/${r}`,Ar=({method:e,selectable:r,selected:n,onSelect:o,onSetDefault:l,onRemove:c,onEdit:m,disabled:v,showDefaultBadge:h,hideSetDefaultMenuItem:j,cardLabelFormat:_="branded"})=>{const[w,C]=s.useState(!1),x=s.useRef(null),P=Wr(e.expMonth,e.expYear);s.useEffect(()=>{if(!w)return;const I=k=>{var E;(E=x.current)!=null&&E.contains(k.target)||C(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[w]);const M=()=>{r&&o&&!v&&o(e)};return a.jsxs("div",{className:X("flex items-start gap-3 transition-colors",r?"rounded-lg border px-3 py-3":"py-4",r&&!v&&"cursor-pointer",r&&(n?"border-grayWarm-950 shadow-[0_0_0_1px_#1c1917]":"border-grayWarm-200 hover:border-grayWarm-300")),onClick:M,"data-testid":`payment-method-row-${e.id}`,children:[r?a.jsx("input",{type:"radio",name:"movmo-payment-method",checked:n,onChange:()=>o==null?void 0:o(e),onClick:I=>I.stopPropagation(),"aria-label":`Select ${Tt(e.brand)} ending ${e.last4}`,className:"mr-1 h-4 w-4 mt-2 cursor-pointer appearance-none rounded-full border-2 border-grayWarm-300 checked:border-[5px] checked:border-grayWarm-950 bg-white checked:bg-white focus:ring-0 focus:ring-offset-0",disabled:v}):null,a.jsx(Ie,{brand:e.brand,className:"flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"text-lg font-semibold text-grayWarm-950",children:_==="masked"?`•••• ${e.last4}`:`${Tt(e.brand)} ${e.last4}`}),h&&e.isDefault?a.jsx("span",{className:"inline-flex items-center rounded-full bg-success-50 px-2 py-0.5 text-xs font-semibold text-success-700","data-testid":`badge-default-${e.id}`,children:"Default"}):null,P?a.jsx("span",{className:"inline-flex items-center rounded-full bg-error-50 px-2 py-0.5 text-xs font-semibold text-error-700","data-testid":`badge-expired-${e.id}`,children:"Expired"}):null]}),a.jsxs("div",{className:X("text-base",P?"text-grayWarm-400":"text-grayWarm-600"),children:["Exp. ",Mr(e.expMonth,e.expYear)]})]}),a.jsxs("div",{className:"relative flex-shrink-0",ref:x,children:[a.jsx("button",{type:"button","aria-label":`Open actions for card ending ${e.last4}`,"aria-haspopup":"menu","aria-expanded":w,className:"rounded-lg p-2 text-grayWarm-600 transition-colors hover:bg-grayWarm-100 disabled:cursor-not-allowed disabled:opacity-50",disabled:v,onClick:I=>{I.stopPropagation(),C(k=>!k)},"data-testid":`menu-trigger-${e.id}`,children:a.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})}),w?a.jsxs("div",{role:"menu",className:X("absolute z-10 whitespace-nowrap rounded-lg border border-grayWarm-200 bg-white py-1 shadow-lg",r?"bottom-full left-1/2 mb-2 -translate-x-1/2":"right-0 top-full mt-1"),onClick:I=>I.stopPropagation(),"data-testid":`menu-${e.id}`,children:[r?a.jsx("span",{"aria-hidden":"true",className:"absolute -bottom-1.5 left-1/2 h-3 w-3 -translate-x-1/2 rotate-45 border-b border-r border-grayWarm-200 bg-white"}):null,!e.isDefault&&!j?a.jsx("button",{type:"button",role:"menuitem",className:"block w-full px-4 py-1 text-left text-md font-semibold text-grayWarm-950 hover:text-grayWarm-700",onClick:()=>{C(!1),l(e)},"data-testid":`menu-set-default-${e.id}`,children:"Set as default"}):null,m&&e.vault==="spreedly"?a.jsx("button",{type:"button",role:"menuitem",className:"block w-full px-4 py-1 text-left text-md font-semibold text-grayWarm-950 hover:text-grayWarm-700",onClick:()=>{C(!1),m(e)},"data-testid":`menu-edit-${e.id}`,children:"Edit"}):null,a.jsx("button",{type:"button",role:"menuitem",className:"block w-full px-4 py-1 text-left text-md font-semibold text-error-700 hover:text-error-500",onClick:()=>{C(!1),c(e)},"data-testid":`menu-remove-${e.id}`,children:"Delete"})]}):null]})]})},Dr=e=>`${Ye().iconCdnBaseUrl}/website/assets/icons/payments/${e}.svg`,yt=({slug:e,alt:r})=>a.jsx("img",{src:Dr(e),alt:r,height:20,loading:"lazy",style:{height:20,width:"auto"}}),ut=({type:e,label:r,iconNode:n,disabled:o=!1})=>a.jsxs("label",{className:"flex cursor-pointer items-center gap-3 rounded-lg border border-grayWarm-200 px-4 py-3 transition-colors hover:border-grayWarm-300","data-testid":`payment-type-${e}`,children:[a.jsx("input",{type:"radio",name:"movmo-payment-type",value:e,disabled:o,onChange:()=>{},className:X("h-4 w-4 accent-grayWarm-900",o?"cursor-not-allowed":"cursor-pointer"),"aria-label":r}),a.jsxs("span",{className:"flex flex-1 items-center gap-2 text-sm font-semibold text-grayWarm-900",children:[r,n]})]}),Ft=({selected:e,onSelect:r,creditCardBody:n,disabled:o=!1,className:l})=>{const c=e==="credit_card";return a.jsxs("div",{className:X("flex w-full flex-col gap-3",l),children:[a.jsxs("label",{className:X("flex cursor-pointer flex-col gap-3 rounded-lg border px-4 py-3 transition-colors",c?"border-grayWarm-900 shadow-[0_0_0_1px_#1c1917]":"border-grayWarm-200"),"data-testid":"payment-type-credit_card",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("input",{type:"radio",name:"movmo-payment-type",value:"credit_card",checked:c,disabled:o,onChange:()=>{o||r("credit_card")},className:X("h-4 w-4 accent-grayWarm-900",o?"cursor-not-allowed":"cursor-pointer"),"aria-label":"Credit card"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-grayWarm-900",children:"Credit card"}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(Ie,{brand:"mastercard",width:28}),a.jsx(Ie,{brand:"visa",width:28}),a.jsx(Ie,{brand:"amex",width:28}),a.jsx(Ie,{brand:"discover",width:28})]})]}),c?a.jsx("div",{"data-testid":"payment-type-credit_card-body",children:n}):null]}),c?a.jsx("p",{className:"mt-2 text-sm font-semibold text-grayWarm-900","data-testid":"payment-type-other-options-header",children:"Other options"}):null,a.jsx(ut,{type:"paypal",label:"PayPal",iconNode:a.jsx(yt,{slug:"paypal",alt:"PayPal"}),disabled:o}),a.jsx(ut,{type:"googlepay",label:"GooglePay",iconNode:a.jsx(yt,{slug:"google-pay",alt:"GooglePay"}),disabled:o}),a.jsx(ut,{type:"klarna",label:"Klarna",iconNode:a.jsx(yt,{slug:"klarna",alt:"Klarna"}),disabled:o}),a.jsx(ut,{type:"ach",label:"Bank account (ACH)",iconNode:a.jsx("span",{className:"text-xs font-medium text-grayWarm-500",children:"Direct debit"}),disabled:o})]})},Ot="movmo-add-payment-form",$r=e=>{console.error("@movmo_app/payments: failed to update payment method",e);const r=e instanceof Error?e.message.trim():"";return/spreedly-backed cards/i.test(r)?"This card's details can't be edited.":r||"Failed to update payment method."},Wt=e=>{const r=e.filter(o=>o.isDefault),n=e.filter(o=>!o.isDefault);return[...r,...n]},Mt=({message:e,testId:r})=>a.jsx("p",{role:"alert","aria-live":"polite",className:"mt-3 rounded-md bg-error-50 px-3 py-2 text-sm text-error-700","data-testid":r,children:e}),At=({withDefaultBadge:e=!1})=>a.jsxs("div",{className:"flex items-start justify-between py-4","data-testid":"payment-method-skeleton",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"h-8 w-[46px] flex-shrink-0 animate-pulse rounded bg-grayWarm-200"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"h-5 w-[120px] animate-pulse rounded bg-grayWarm-200"}),e?a.jsx("div",{className:"h-5 w-[56px] animate-pulse rounded-full bg-grayWarm-200"}):null]}),a.jsx("div",{className:"h-4 w-[100px] animate-pulse rounded bg-grayWarm-200"})]})]}),a.jsx("div",{className:"h-5 w-5 flex-shrink-0 animate-pulse rounded-full bg-grayWarm-200"})]}),Kt=({userId:e,defaultCardholderName:r,defaultCardholderFirstName:n,defaultCardholderLastName:o,selectedId:l,onSelect:c,onChange:m,onError:v,onEvent:h,paymentTypeSelector:j=!0,autoSaveFirstCard:_=!0,selectionSetsDefault:w=!1,showDefaultBadge:C=!0,collapsible:x=!1,cardLabelFormat:P="branded",className:M})=>{const{items:I,status:k,error:E,refetch:O}=Ht(e),{deletePaymentMethod:pe,status:de}=Bt(e),{setDefault:we,status:ue}=Yt(e),{updatePaymentMethod:se,status:Q}=Vt(e),[b,ye]=s.useState([]),_e=s.useRef(b);s.useEffect(()=>{_e.current=b},[b]);const[z,p]=s.useState(null),[y,S]=s.useState(!1),[A,re]=s.useState(null),[ae,q]=s.useState(!1),[G,V]=s.useState(!1),[T,K]=s.useState(null),[Ce,ve]=s.useState(null),[J,Ee]=s.useState(null),[Z,Pe]=s.useState(!1),Re=s.useRef(!1),oe=s.useRef(v);s.useEffect(()=>{oe.current=v},[v]);const ee=s.useCallback(u=>{var B;(B=oe.current)==null||B.call(oe,u)},[]),Te=s.useRef(h);s.useEffect(()=>{Te.current=h},[h]);const $=s.useCallback((u,B)=>{var L;(L=Te.current)==null||L.call(Te,u,B)},[]),ie=s.useRef(!1),ke=s.useCallback(u=>{if(u.touchedInvalid.length===0){ie.current=!1;return}ie.current||(ie.current=!0,$("validation_error",{field_count:u.touchedInvalid.length,fields:u.touchedInvalid}))},[$]),te=s.useCallback(()=>{S(!1),re(null),Ee(null),ie.current=!1},[]),je=r??([n,o].filter(Boolean).join(" ")||void 0);s.useEffect(()=>{k==="ready"&&ye(Wt(I))},[I,k]);const Fe=s.useRef(null);s.useEffect(()=>{if(k==="error"&&E){if(Fe.current===E)return;Fe.current=E,ee({source:"list",message:E})}else k!=="error"&&(Fe.current=null)},[k,E,ee]),s.useEffect(()=>{if(!c||Re.current||k!=="ready"||b.length===0||l)return;Re.current=!0,$("autoselected",{had_saved_methods:!0});const u=b.find(B=>B.isDefault)??b[0];c(u)},[c,k,b,l,$]);const he=s.useCallback(u=>{ye(B=>{const L=typeof u=="function"?u(B):u,U=Wt(L);return queueMicrotask(()=>m==null?void 0:m(U)),U})},[m]),ze=de==="pending"||ue==="pending"||Q==="pending",ge=s.useCallback(async u=>{const B=b;p(null),he(L=>L.map(U=>({...U,isDefault:U.id===u.id})));try{await we(u.id),O(),$("set_default")}catch(L){ye(B),m==null||m(B);const U=L instanceof Error?L.message:"Failed to set default payment method.";p(U),ee({...nt("set-default",L,"Failed to set default payment method."),message:U})}},[b,he,we,O,m,ee,$]),le=s.useCallback(u=>{c==null||c(u),w&&(u.isDefault||ge(u))},[c,w,ge]),Oe=s.useCallback(u=>{$("selected",{method_count:b.length}),le(u)},[$,b,le]),We=s.useCallback(async u=>{const B=b;p(null);const L=b.filter(Me=>Me.id!==u.id);he(()=>L);const U=u.id===l&&c?L.find(Me=>Me.isDefault)??L[0]??null:null;U&&le(U);const xe=!!U&&w&&U!==null&&!U.isDefault;try{await pe(u.id),xe||O(),$("deleted",{remaining_count:L.length})}catch(Me){ye(B),m==null||m(B);const ct=Me instanceof Error?Me.message:"Failed to delete payment method.";p(ct),ee({...nt("delete",Me,"Failed to delete payment method."),message:ct})}},[b,he,pe,O,m,l,c,le,w,ee,$]),Ae=s.useCallback(u=>{ve(null),K(u)},[]),Le=s.useCallback(()=>{K(null),ve(null)},[]),De=s.useCallback(async u=>{if(!T)return;const B=T,L=b;ve(null),he(U=>U.map(xe=>xe.id===B.id?{...xe,...u.cardholderName!==void 0?{cardholderName:u.cardholderName}:{},...u.zip!==void 0?{zip:u.zip}:{}}:xe));try{await se(B.id,u),Le(),O(),$("edited",{fields:Object.keys(u)})}catch(U){ye(L),m==null||m(L);const xe=$r(U);ve(xe),ee({...nt("update",U,xe),message:xe})}},[T,b,he,se,O,m,Le,ee,$]),Ne=s.useCallback(u=>{te(),he(L=>[u,...L.filter(U=>U.id!==u.id)]),le(u),!!c&&w&&!u.isDefault||O(),$("added",{method_count:_e.current.length+1})},[te,he,O,le,c,w,$]),f=s.useCallback(u=>{re(u)},[]),D=s.useCallback(u=>{V(u),u&&re(null)},[]),me=k==="ready"&&b.length===0,ne=typeof c=="function",st=!ne&&!x,ot=b.length===0,it=_&&b.length===0,$e=s.useCallback(u=>a.jsx(Et,{userId:e,isDefault:ot,defaultCardholderName:je,autoSave:!u&&it,hideInternalSaveButton:u,formId:u?Ot:void 0,onCanSubmitChange:u?q:void 0,onSavingChange:D,autoFocus:u?"number":void 0,onSuccess:Ne,onError:f,onErrorDetail:ee,onValidationChange:ke}),[e,ot,je,it,Ne,f,D,ee,ke]),Ve=s.useMemo(()=>$e(!1),[$e]),Se=s.useMemo(()=>$e(!0),[$e]),Ue=!e,Qe=s.useMemo(()=>j?a.jsx(Ft,{selected:J,onSelect:u=>Ee(u),creditCardBody:Ve,disabled:Ue}):Ve,[j,J,Ve,Ue]),lt=s.useMemo(()=>j?a.jsx(Ft,{selected:J,onSelect:u=>Ee(u),creditCardBody:Se,disabled:Ue}):Se,[j,J,Se,Ue]);return a.jsxs("div",{className:X("flex w-full flex-col gap-4",M),"data-testid":"payment-methods-manager",children:[k==="loading"&&b.length===0?a.jsxs("div",{className:X(st?"flex flex-col divide-y divide-grayWarm-200 rounded-xl border border-grayWarm-200 px-4 md:px-6":"flex flex-col gap-2"),"data-testid":"payment-methods-loading",children:[a.jsx(At,{withDefaultBadge:!0}),a.jsx(At,{})]}):null,k==="error"?a.jsxs("div",{role:"alert","aria-live":"polite",className:"flex items-center justify-between gap-3 rounded-md bg-error-50 p-3 text-sm text-error-700","data-testid":"payment-methods-list-error",children:[a.jsx("span",{children:E??"Failed to load payment methods."}),a.jsx("button",{type:"button",onClick:O,className:"rounded-md border border-error-700 px-3 py-1 text-xs font-semibold text-error-700 hover:bg-error-50",children:"Retry"})]}):null,z?a.jsx("div",{role:"alert","aria-live":"polite",className:"rounded-md bg-error-50 p-3 text-sm text-error-700","data-testid":"payment-methods-mutation-error",children:z}):null,x&&b.length>0?a.jsx("div",{className:"border-t border-grayWarm-200 pt-4",children:a.jsxs("div",{className:"flex items-center justify-between","data-testid":Z?"payment-methods-drawer-header":"payment-methods-collapsed-preview",children:[Z?a.jsx("h3",{className:"text-md font-semibold text-grayWarm-950",children:"Payment methods"}):a.jsx(Gt,{method:b.find(u=>u.id===l)??b.find(u=>u.isDefault)??b[0],cardLabelFormat:P,className:"flex-1"}),a.jsx("button",{type:"button","aria-label":Z?"Collapse payment methods":"Expand payment methods","aria-expanded":Z,className:"bg-grayWarm-100 p-2 rounded-lg hover:bg-grayWarm-200 transition-colors",onClick:()=>Pe(u=>!u),"data-testid":Z?"payment-methods-drawer-close":"payment-methods-drawer-open",children:a.jsx("img",{src:`${Ye().iconCdnBaseUrl}/website/assets/icons/chevron-${Z?"up":"down"}-double.svg`,alt:"",className:"w-5 h-5"})})]})}):null,b.length>0&&(!x||Z)?a.jsx("div",{className:X("flex flex-col",st?"rounded-xl border border-grayWarm-200 px-4 md:px-6 divide-y divide-grayWarm-200":"space-y-3"),children:b.map(u=>a.jsx(Ar,{method:u,selectable:ne,selected:ne&&u.id===l,onSelect:Oe,onSetDefault:ge,onRemove:We,onEdit:Ae,disabled:ze,showDefaultBadge:C,hideSetDefaultMenuItem:w,cardLabelFormat:P},u.id))}):null,me?a.jsxs("div",{"data-testid":"payment-methods-empty",children:[Qe,A&&!y?a.jsx(Mt,{message:A,testId:"payment-methods-inline-error"}):null]}):b.length>0&&(!x||Z)?a.jsx("button",{type:"button",onClick:()=>{re(null),Ee(null),q(!1),S(!0),ie.current=!1},onMouseEnter:()=>{xt().catch(()=>{})},onFocus:()=>{xt().catch(()=>{})},className:"self-start rounded-lg bg-brand-50 px-6 py-3 text-md font-semibold text-brand-600 transition-colors hover:bg-brand-100","data-testid":"payment-methods-add-trigger",children:"Add payment method"}):null,a.jsxs(Sr,{open:y,onClose:te,formId:Ot,saveDisabled:!ae,isSaving:G,children:[lt,A?a.jsx(Mt,{message:A,testId:"payment-methods-modal-error"}):null]}),a.jsx(Fr,{open:T!==null,method:T,onClose:Le,onSave:De,isSaving:Q==="pending",error:Ce})]})};Kt.displayName="PaymentMethodsManager";const Ur="/v1/auth/",Ir="movmo_csrf_token",Jt=new Set(["reauth_required","movmo_session_required","first_party_only","recovery_cooldown","account_deletion_pending"]),zr=e=>{if(typeof document>"u")return null;const r=document.cookie?document.cookie.split(";"):[];for(const n of r){const o=n.trim();if(o.startsWith(e+"="))return decodeURIComponent(o.substring(e.length+1))}return null},Lr=e=>typeof e=="string"?e:e instanceof URL?e.href:e.url,Br=()=>{if(typeof globalThis<"u"&&typeof globalThis.fetch=="function")return globalThis.fetch.bind(globalThis);throw new Error("@movmo_app/payments: no global fetch available in this environment")},Yr=e=>{const{refreshSession:r,onRefreshFailed:n,csrfCookieName:o=Ir,extraHeaders:l,authPathFragment:c=Ur,baseFetch:m=Br(),readCookie:v=zr}=e,h=new Set(e.noRefreshCodes??Jt);let j=null;const _=()=>{if(j)return j;const C=(async()=>{await r()})();return j=C,C.finally(()=>{j===C&&(j=null)}).catch(()=>{}),C},w=(C,x)=>{const P=new Headers(x==null?void 0:x.headers),M=v(o);if(M&&!P.has("X-CSRF-Token")&&P.set("X-CSRF-Token",M),l){const I=l(C,x);for(const[k,E]of Object.entries(I))P.has(k)||P.set(k,E)}return{...x,headers:P,credentials:(x==null?void 0:x.credentials)??"include"}};return async function(x,P){const M=await m(x,w(x,P));if(Lr(x).includes(c)||M.status!==401&&M.status!==403)return M;if(M.status===403)try{const E=await M.clone().json(),O=E==null?void 0:E.code;if(typeof O=="string"&&h.has(O))return M}catch{}try{await _()}catch(E){try{n(E)}catch(O){console.error("@movmo_app/payments: onRefreshFailed callback threw — auth retry path is misconfigured",O)}return M}try{return await m(x,w(x,P))}catch(E){return console.error("@movmo_app/payments: retry after token refresh failed — returning original response",E),M}}};exports.DEFAULT_NO_REFRESH_CODES=Jt;exports.MovmoCardForm=Et;exports.PaymentMethodPreview=Gt;exports.PaymentMethodsManager=Kt;exports.PaymentsApiError=wt;exports.createMovmoAuthFetch=Yr;exports.getPaymentsConfig=Ye;exports.setPaymentsConfig=cr;exports.useDeletePaymentMethod=Bt;exports.useMovmoCardFields=Ut;exports.useSetDefaultPaymentMethod=Yt;exports.useUpdatePaymentMethod=Vt;exports.useUserPaymentMethods=Ht;
31
31
  //# sourceMappingURL=index.cjs.js.map