@movmo_app/payments 0.2.0 → 0.3.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.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import fr, { useState as S, useRef as q, useEffect as X, useCallback as B, useMemo as Ce } from "react";
2
- var ze = { exports: {} }, je = {};
1
+ import Er, { useState as O, useRef as Y, useEffect as B, useCallback as Z, useMemo as Ue } from "react";
2
+ var rr = { exports: {} }, Ae = {};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.min.js
@@ -9,21 +9,21 @@ var ze = { exports: {} }, je = {};
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
- var nr;
13
- function Ir() {
14
- if (nr) return je;
15
- nr = 1;
16
- var r = fr, t = Symbol.for("react.element"), s = Symbol.for("react.fragment"), o = Object.prototype.hasOwnProperty, l = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, f = { key: !0, ref: !0, __self: !0, __source: !0 };
17
- function d(v, y, T) {
18
- var g, w = {}, F = null, _ = null;
19
- T !== void 0 && (F = "" + T), y.key !== void 0 && (F = "" + y.key), y.ref !== void 0 && (_ = y.ref);
20
- for (g in y) o.call(y, g) && !f.hasOwnProperty(g) && (w[g] = y[g]);
21
- if (v && v.defaultProps) for (g in y = v.defaultProps, y) w[g] === void 0 && (w[g] = y[g]);
22
- return { $$typeof: t, type: v, key: F, ref: _, props: w, _owner: l.current };
12
+ var mr;
13
+ function zr() {
14
+ if (mr) return Ae;
15
+ mr = 1;
16
+ var r = Er, t = Symbol.for("react.element"), n = Symbol.for("react.fragment"), o = Object.prototype.hasOwnProperty, l = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, c = { key: !0, ref: !0, __self: !0, __source: !0 };
17
+ function m(y, p, D) {
18
+ var R, h = {}, v = null, E = null;
19
+ D !== void 0 && (v = "" + D), p.key !== void 0 && (v = "" + p.key), p.ref !== void 0 && (E = p.ref);
20
+ for (R in p) o.call(p, R) && !c.hasOwnProperty(R) && (h[R] = p[R]);
21
+ if (y && y.defaultProps) for (R in p = y.defaultProps, p) h[R] === void 0 && (h[R] = p[R]);
22
+ return { $$typeof: t, type: y, key: v, ref: E, props: h, _owner: l.current };
23
23
  }
24
- return je.Fragment = s, je.jsx = d, je.jsxs = d, je;
24
+ return Ae.Fragment = n, Ae.jsx = m, Ae.jsxs = m, Ae;
25
25
  }
26
- var _e = {};
26
+ var $e = {};
27
27
  /**
28
28
  * @license React
29
29
  * react-jsx-runtime.development.js
@@ -33,91 +33,91 @@ var _e = {};
33
33
  * This source code is licensed under the MIT license found in the
34
34
  * LICENSE file in the root directory of this source tree.
35
35
  */
36
- var sr;
37
- function Ur() {
38
- return sr || (sr = 1, process.env.NODE_ENV !== "production" && function() {
39
- var r = fr, t = Symbol.for("react.element"), s = Symbol.for("react.portal"), o = Symbol.for("react.fragment"), l = Symbol.for("react.strict_mode"), f = Symbol.for("react.profiler"), d = Symbol.for("react.provider"), v = Symbol.for("react.context"), y = Symbol.for("react.forward_ref"), T = Symbol.for("react.suspense"), g = Symbol.for("react.suspense_list"), w = Symbol.for("react.memo"), F = Symbol.for("react.lazy"), _ = Symbol.for("react.offscreen"), D = Symbol.iterator, R = "@@iterator";
40
- function G(e) {
36
+ var pr;
37
+ function Vr() {
38
+ return pr || (pr = 1, process.env.NODE_ENV !== "production" && function() {
39
+ var r = Er, t = 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"), p = Symbol.for("react.forward_ref"), D = Symbol.for("react.suspense"), R = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), v = Symbol.for("react.lazy"), E = Symbol.for("react.offscreen"), A = Symbol.iterator, k = "@@iterator";
40
+ function J(e) {
41
41
  if (e === null || typeof e != "object")
42
42
  return null;
43
- var n = D && e[D] || e[R];
44
- return typeof n == "function" ? n : null;
43
+ var s = A && e[A] || e[k];
44
+ return typeof s == "function" ? s : null;
45
45
  }
46
- var O = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
47
- function C(e) {
46
+ var g = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
47
+ function P(e) {
48
48
  {
49
- for (var n = arguments.length, i = new Array(n > 1 ? n - 1 : 0), u = 1; u < n; u++)
50
- i[u - 1] = arguments[u];
51
- J("error", e, i);
49
+ for (var s = arguments.length, i = new Array(s > 1 ? s - 1 : 0), f = 1; f < s; f++)
50
+ i[f - 1] = arguments[f];
51
+ G("error", e, i);
52
52
  }
53
53
  }
54
- function J(e, n, i) {
54
+ function G(e, s, i) {
55
55
  {
56
- var u = O.ReactDebugCurrentFrame, h = u.getStackAddendum();
57
- h !== "" && (n += "%s", i = i.concat([h]));
58
- var j = i.map(function(p) {
59
- return String(p);
56
+ var f = g.ReactDebugCurrentFrame, C = f.getStackAddendum();
57
+ C !== "" && (s += "%s", i = i.concat([C]));
58
+ var F = i.map(function(w) {
59
+ return String(w);
60
60
  });
61
- j.unshift("Warning: " + n), Function.prototype.apply.call(console[e], console, j);
61
+ F.unshift("Warning: " + s), Function.prototype.apply.call(console[e], console, F);
62
62
  }
63
63
  }
64
- var W = !1, se = !1, oe = !1, A = !1, x = !1, b;
65
- b = Symbol.for("react.module.reference");
66
- function I(e) {
67
- return !!(typeof e == "string" || typeof e == "function" || e === o || e === f || x || e === l || e === T || e === g || A || e === _ || W || se || oe || typeof e == "object" && e !== null && (e.$$typeof === F || e.$$typeof === w || e.$$typeof === d || e.$$typeof === v || e.$$typeof === y || // This needs to include all possible module reference object
64
+ var ue = !1, te = !1, j = !1, se = !1, he = !1, U;
65
+ U = Symbol.for("react.module.reference");
66
+ function T(e) {
67
+ return !!(typeof e == "string" || typeof e == "function" || e === o || e === c || he || e === l || e === D || e === R || se || e === E || ue || te || j || typeof e == "object" && e !== null && (e.$$typeof === v || e.$$typeof === h || e.$$typeof === m || e.$$typeof === y || e.$$typeof === p || // This needs to include all possible module reference object
68
68
  // types supported by any Flight configuration anywhere since
69
69
  // we don't know which Flight build this will end up being used
70
70
  // with.
71
- e.$$typeof === b || e.getModuleId !== void 0));
71
+ e.$$typeof === U || e.getModuleId !== void 0));
72
72
  }
73
- function U(e, n, i) {
74
- var u = e.displayName;
75
- if (u)
76
- return u;
77
- var h = n.displayName || n.name || "";
78
- return h !== "" ? i + "(" + h + ")" : i;
73
+ function d(e, s, i) {
74
+ var f = e.displayName;
75
+ if (f)
76
+ return f;
77
+ var C = s.displayName || s.name || "";
78
+ return C !== "" ? i + "(" + C + ")" : i;
79
79
  }
80
- function ie(e) {
80
+ function S(e) {
81
81
  return e.displayName || "Context";
82
82
  }
83
- function z(e) {
83
+ function _(e) {
84
84
  if (e == null)
85
85
  return null;
86
- if (typeof e.tag == "number" && C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
86
+ if (typeof e.tag == "number" && P("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
87
87
  return e.displayName || e.name || null;
88
88
  if (typeof e == "string")
89
89
  return e;
90
90
  switch (e) {
91
91
  case o:
92
92
  return "Fragment";
93
- case s:
93
+ case n:
94
94
  return "Portal";
95
- case f:
95
+ case c:
96
96
  return "Profiler";
97
97
  case l:
98
98
  return "StrictMode";
99
- case T:
99
+ case D:
100
100
  return "Suspense";
101
- case g:
101
+ case R:
102
102
  return "SuspenseList";
103
103
  }
104
104
  if (typeof e == "object")
105
105
  switch (e.$$typeof) {
106
- case v:
107
- var n = e;
108
- return ie(n) + ".Consumer";
109
- case d:
110
- var i = e;
111
- return ie(i._context) + ".Provider";
112
106
  case y:
113
- return U(e, e.render, "ForwardRef");
114
- case w:
115
- var u = e.displayName || null;
116
- return u !== null ? u : z(e.type) || "Memo";
117
- case F: {
118
- var h = e, j = h._payload, p = h._init;
107
+ var s = e;
108
+ return S(s) + ".Consumer";
109
+ case m:
110
+ var i = e;
111
+ return S(i._context) + ".Provider";
112
+ case p:
113
+ return d(e, e.render, "ForwardRef");
114
+ case h:
115
+ var f = e.displayName || null;
116
+ return f !== null ? f : _(e.type) || "Memo";
117
+ case v: {
118
+ var C = e, F = C._payload, w = C._init;
119
119
  try {
120
- return z(p(j));
120
+ return _(w(F));
121
121
  } catch {
122
122
  return null;
123
123
  }
@@ -125,18 +125,18 @@ function Ur() {
125
125
  }
126
126
  return null;
127
127
  }
128
- var N = Object.assign, Y = 0, ue, V, k, le, ce, fe, me;
129
- function pe() {
128
+ var M = Object.assign, X = 0, z, ee, V, N, W, me, ye;
129
+ function ge() {
130
130
  }
131
- pe.__reactDisabledLog = !0;
132
- function he() {
131
+ ge.__reactDisabledLog = !0;
132
+ function we() {
133
133
  {
134
- if (Y === 0) {
135
- ue = console.log, V = console.info, k = console.warn, le = console.error, ce = console.group, fe = console.groupCollapsed, me = console.groupEnd;
134
+ if (X === 0) {
135
+ z = console.log, ee = console.info, V = console.warn, N = console.error, W = console.group, me = console.groupCollapsed, ye = console.groupEnd;
136
136
  var e = {
137
137
  configurable: !0,
138
138
  enumerable: !0,
139
- value: pe,
139
+ value: ge,
140
140
  writable: !0
141
141
  };
142
142
  Object.defineProperties(console, {
@@ -149,250 +149,250 @@ function Ur() {
149
149
  groupEnd: e
150
150
  });
151
151
  }
152
- Y++;
152
+ X++;
153
153
  }
154
154
  }
155
- function Ee() {
155
+ function fe() {
156
156
  {
157
- if (Y--, Y === 0) {
157
+ if (X--, X === 0) {
158
158
  var e = {
159
159
  configurable: !0,
160
160
  enumerable: !0,
161
161
  writable: !0
162
162
  };
163
163
  Object.defineProperties(console, {
164
- log: N({}, e, {
165
- value: ue
166
- }),
167
- info: N({}, e, {
168
- value: V
164
+ log: M({}, e, {
165
+ value: z
169
166
  }),
170
- warn: N({}, e, {
171
- value: k
167
+ info: M({}, e, {
168
+ value: ee
172
169
  }),
173
- error: N({}, e, {
174
- value: le
170
+ warn: M({}, e, {
171
+ value: V
175
172
  }),
176
- group: N({}, e, {
177
- value: ce
173
+ error: M({}, e, {
174
+ value: N
178
175
  }),
179
- groupCollapsed: N({}, e, {
180
- value: fe
176
+ group: M({}, e, {
177
+ value: W
181
178
  }),
182
- groupEnd: N({}, e, {
179
+ groupCollapsed: M({}, e, {
183
180
  value: me
181
+ }),
182
+ groupEnd: M({}, e, {
183
+ value: ye
184
184
  })
185
185
  });
186
186
  }
187
- Y < 0 && C("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
187
+ X < 0 && P("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
188
188
  }
189
189
  }
190
- var ae = O.ReactCurrentDispatcher, Q;
191
- function ee(e, n, i) {
190
+ var je = g.ReactCurrentDispatcher, ve;
191
+ function H(e, s, i) {
192
192
  {
193
- if (Q === void 0)
193
+ if (ve === void 0)
194
194
  try {
195
195
  throw Error();
196
- } catch (h) {
197
- var u = h.stack.trim().match(/\n( *(at )?)/);
198
- Q = u && u[1] || "";
196
+ } catch (C) {
197
+ var f = C.stack.trim().match(/\n( *(at )?)/);
198
+ ve = f && f[1] || "";
199
199
  }
200
200
  return `
201
- ` + Q + e;
201
+ ` + ve + e;
202
202
  }
203
203
  }
204
- var re = !1, de;
204
+ var oe = !1, ie;
205
205
  {
206
- var ye = typeof WeakMap == "function" ? WeakMap : Map;
207
- de = new ye();
206
+ var be = typeof WeakMap == "function" ? WeakMap : Map;
207
+ ie = new be();
208
208
  }
209
- function ve(e, n) {
210
- if (!e || re)
209
+ function Ee(e, s) {
210
+ if (!e || oe)
211
211
  return "";
212
212
  {
213
- var i = de.get(e);
213
+ var i = ie.get(e);
214
214
  if (i !== void 0)
215
215
  return i;
216
216
  }
217
- var u;
218
- re = !0;
219
- var h = Error.prepareStackTrace;
217
+ var f;
218
+ oe = !0;
219
+ var C = Error.prepareStackTrace;
220
220
  Error.prepareStackTrace = void 0;
221
- var j;
222
- j = ae.current, ae.current = null, he();
221
+ var F;
222
+ F = je.current, je.current = null, we();
223
223
  try {
224
- if (n) {
225
- var p = function() {
224
+ if (s) {
225
+ var w = function() {
226
226
  throw Error();
227
227
  };
228
- if (Object.defineProperty(p.prototype, "props", {
228
+ if (Object.defineProperty(w.prototype, "props", {
229
229
  set: function() {
230
230
  throw Error();
231
231
  }
232
232
  }), typeof Reflect == "object" && Reflect.construct) {
233
233
  try {
234
- Reflect.construct(p, []);
235
- } catch (Z) {
236
- u = Z;
234
+ Reflect.construct(w, []);
235
+ } catch (ne) {
236
+ f = ne;
237
237
  }
238
- Reflect.construct(e, [], p);
238
+ Reflect.construct(e, [], w);
239
239
  } else {
240
240
  try {
241
- p.call();
242
- } catch (Z) {
243
- u = Z;
241
+ w.call();
242
+ } catch (ne) {
243
+ f = ne;
244
244
  }
245
- e.call(p.prototype);
245
+ e.call(w.prototype);
246
246
  }
247
247
  } else {
248
248
  try {
249
249
  throw Error();
250
- } catch (Z) {
251
- u = Z;
250
+ } catch (ne) {
251
+ f = ne;
252
252
  }
253
253
  e();
254
254
  }
255
- } catch (Z) {
256
- if (Z && u && typeof Z.stack == "string") {
257
- for (var m = Z.stack.split(`
258
- `), K = u.stack.split(`
259
- `), M = m.length - 1, L = K.length - 1; M >= 1 && L >= 0 && m[M] !== K[L]; )
255
+ } catch (ne) {
256
+ if (ne && f && typeof ne.stack == "string") {
257
+ for (var x = ne.stack.split(`
258
+ `), re = f.stack.split(`
259
+ `), I = x.length - 1, L = re.length - 1; I >= 1 && L >= 0 && x[I] !== re[L]; )
260
260
  L--;
261
- for (; M >= 1 && L >= 0; M--, L--)
262
- if (m[M] !== K[L]) {
263
- if (M !== 1 || L !== 1)
261
+ for (; I >= 1 && L >= 0; I--, L--)
262
+ if (x[I] !== re[L]) {
263
+ if (I !== 1 || L !== 1)
264
264
  do
265
- if (M--, L--, L < 0 || m[M] !== K[L]) {
266
- var te = `
267
- ` + m[M].replace(" at new ", " at ");
268
- return e.displayName && te.includes("<anonymous>") && (te = te.replace("<anonymous>", e.displayName)), typeof e == "function" && de.set(e, te), te;
265
+ if (I--, L--, L < 0 || x[I] !== re[L]) {
266
+ var de = `
267
+ ` + x[I].replace(" at new ", " at ");
268
+ return e.displayName && de.includes("<anonymous>") && (de = de.replace("<anonymous>", e.displayName)), typeof e == "function" && ie.set(e, de), de;
269
269
  }
270
- while (M >= 1 && L >= 0);
270
+ while (I >= 1 && L >= 0);
271
271
  break;
272
272
  }
273
273
  }
274
274
  } finally {
275
- re = !1, ae.current = j, Ee(), Error.prepareStackTrace = h;
275
+ oe = !1, je.current = F, fe(), Error.prepareStackTrace = C;
276
276
  }
277
- var we = e ? e.displayName || e.name : "", xe = we ? ee(we) : "";
278
- return typeof e == "function" && de.set(e, xe), xe;
277
+ var Pe = e ? e.displayName || e.name : "", Ce = Pe ? H(Pe) : "";
278
+ return typeof e == "function" && ie.set(e, Ce), Ce;
279
279
  }
280
- function P(e, n, i) {
281
- return ve(e, !1);
280
+ function Re(e, s, i) {
281
+ return Ee(e, !1);
282
282
  }
283
- function c(e) {
284
- var n = e.prototype;
285
- return !!(n && n.isReactComponent);
283
+ function _e(e) {
284
+ var s = e.prototype;
285
+ return !!(s && s.isReactComponent);
286
286
  }
287
- function E(e, n, i) {
287
+ function le(e, s, i) {
288
288
  if (e == null)
289
289
  return "";
290
290
  if (typeof e == "function")
291
- return ve(e, c(e));
291
+ return Ee(e, _e(e));
292
292
  if (typeof e == "string")
293
- return ee(e);
293
+ return H(e);
294
294
  switch (e) {
295
- case T:
296
- return ee("Suspense");
297
- case g:
298
- return ee("SuspenseList");
295
+ case D:
296
+ return H("Suspense");
297
+ case R:
298
+ return H("SuspenseList");
299
299
  }
300
300
  if (typeof e == "object")
301
301
  switch (e.$$typeof) {
302
- case y:
303
- return P(e.render);
304
- case w:
305
- return E(e.type, n, i);
306
- case F: {
307
- var u = e, h = u._payload, j = u._init;
302
+ case p:
303
+ return Re(e.render);
304
+ case h:
305
+ return le(e.type, s, i);
306
+ case v: {
307
+ var f = e, C = f._payload, F = f._init;
308
308
  try {
309
- return E(j(h), n, i);
309
+ return le(F(C), s, i);
310
310
  } catch {
311
311
  }
312
312
  }
313
313
  }
314
314
  return "";
315
315
  }
316
- var $ = Object.prototype.hasOwnProperty, H = {}, Be = O.ReactDebugCurrentFrame;
317
- function Te(e) {
316
+ var b = Object.prototype.hasOwnProperty, $ = {}, K = g.ReactDebugCurrentFrame;
317
+ function pe(e) {
318
318
  if (e) {
319
- var n = e._owner, i = E(e.type, e._source, n ? n.type : null);
320
- Be.setExtraStackFrame(i);
319
+ var s = e._owner, i = le(e.type, e._source, s ? s.type : null);
320
+ K.setExtraStackFrame(i);
321
321
  } else
322
- Be.setExtraStackFrame(null);
322
+ K.setExtraStackFrame(null);
323
323
  }
324
- function hr(e, n, i, u, h) {
324
+ function Ye(e, s, i, f, C) {
325
325
  {
326
- var j = Function.call.bind($);
327
- for (var p in e)
328
- if (j(e, p)) {
329
- var m = void 0;
326
+ var F = Function.call.bind(b);
327
+ for (var w in e)
328
+ if (F(e, w)) {
329
+ var x = void 0;
330
330
  try {
331
- if (typeof e[p] != "function") {
332
- var K = Error((u || "React class") + ": " + i + " type `" + p + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[p] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
333
- throw K.name = "Invariant Violation", K;
331
+ if (typeof e[w] != "function") {
332
+ var re = Error((f || "React class") + ": " + i + " type `" + w + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[w] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
333
+ throw re.name = "Invariant Violation", re;
334
334
  }
335
- m = e[p](n, p, u, i, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
336
- } catch (M) {
337
- m = M;
335
+ x = e[w](s, w, f, i, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
336
+ } catch (I) {
337
+ x = I;
338
338
  }
339
- m && !(m instanceof Error) && (Te(h), C("%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).", u || "React class", i, p, typeof m), Te(null)), m instanceof Error && !(m.message in H) && (H[m.message] = !0, Te(h), C("Failed %s type: %s", i, m.message), Te(null));
339
+ x && !(x instanceof Error) && (pe(C), P("%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).", f || "React class", i, w, typeof x), pe(null)), x instanceof Error && !(x.message in $) && ($[x.message] = !0, pe(C), P("Failed %s type: %s", i, x.message), pe(null));
340
340
  }
341
341
  }
342
342
  }
343
- var xr = Array.isArray;
344
- function De(e) {
345
- return xr(e);
343
+ var ze = Array.isArray;
344
+ function u(e) {
345
+ return ze(e);
346
346
  }
347
- function br(e) {
347
+ function ce(e) {
348
348
  {
349
- var n = typeof Symbol == "function" && Symbol.toStringTag, i = n && e[Symbol.toStringTag] || e.constructor.name || "Object";
349
+ var s = typeof Symbol == "function" && Symbol.toStringTag, i = s && e[Symbol.toStringTag] || e.constructor.name || "Object";
350
350
  return i;
351
351
  }
352
352
  }
353
- function gr(e) {
353
+ function ae(e) {
354
354
  try {
355
- return Ke(e), !1;
355
+ return q(e), !1;
356
356
  } catch {
357
357
  return !0;
358
358
  }
359
359
  }
360
- function Ke(e) {
360
+ function q(e) {
361
361
  return "" + e;
362
362
  }
363
- function qe(e) {
364
- if (gr(e))
365
- return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", br(e)), Ke(e);
363
+ function Le(e) {
364
+ if (ae(e))
365
+ return P("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ce(e)), q(e);
366
366
  }
367
- var Ge = O.ReactCurrentOwner, wr = {
367
+ var xe = g.ReactCurrentOwner, Ve = {
368
368
  key: !0,
369
369
  ref: !0,
370
370
  __self: !0,
371
371
  __source: !0
372
- }, Je, He;
373
- function Er(e) {
374
- if ($.call(e, "ref")) {
375
- var n = Object.getOwnPropertyDescriptor(e, "ref").get;
376
- if (n && n.isReactWarning)
372
+ }, nr, sr;
373
+ function Nr(e) {
374
+ if (b.call(e, "ref")) {
375
+ var s = Object.getOwnPropertyDescriptor(e, "ref").get;
376
+ if (s && s.isReactWarning)
377
377
  return !1;
378
378
  }
379
379
  return e.ref !== void 0;
380
380
  }
381
- function jr(e) {
382
- if ($.call(e, "key")) {
383
- var n = Object.getOwnPropertyDescriptor(e, "key").get;
384
- if (n && n.isReactWarning)
381
+ function kr(e) {
382
+ if (b.call(e, "key")) {
383
+ var s = Object.getOwnPropertyDescriptor(e, "key").get;
384
+ if (s && s.isReactWarning)
385
385
  return !1;
386
386
  }
387
387
  return e.key !== void 0;
388
388
  }
389
- function _r(e, n) {
390
- typeof e.ref == "string" && Ge.current;
389
+ function Pr(e, s) {
390
+ typeof e.ref == "string" && xe.current;
391
391
  }
392
- function Rr(e, n) {
392
+ function Tr(e, s) {
393
393
  {
394
394
  var i = function() {
395
- Je || (Je = !0, C("%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)", n));
395
+ nr || (nr = !0, P("%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)", s));
396
396
  };
397
397
  i.isReactWarning = !0, Object.defineProperty(e, "key", {
398
398
  get: i,
@@ -400,10 +400,10 @@ function Ur() {
400
400
  });
401
401
  }
402
402
  }
403
- function Cr(e, n) {
403
+ function Sr(e, s) {
404
404
  {
405
405
  var i = function() {
406
- He || (He = !0, C("%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)", n));
406
+ sr || (sr = !0, P("%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)", s));
407
407
  };
408
408
  i.isReactWarning = !0, Object.defineProperty(e, "ref", {
409
409
  get: i,
@@ -411,70 +411,70 @@ function Ur() {
411
411
  });
412
412
  }
413
413
  }
414
- var Nr = function(e, n, i, u, h, j, p) {
415
- var m = {
414
+ var Fr = function(e, s, i, f, C, F, w) {
415
+ var x = {
416
416
  // This tag allows us to uniquely identify this as a React Element
417
417
  $$typeof: t,
418
418
  // Built-in properties that belong on the element
419
419
  type: e,
420
- key: n,
420
+ key: s,
421
421
  ref: i,
422
- props: p,
422
+ props: w,
423
423
  // Record the component responsible for creating this element.
424
- _owner: j
424
+ _owner: F
425
425
  };
426
- return m._store = {}, Object.defineProperty(m._store, "validated", {
426
+ return x._store = {}, Object.defineProperty(x._store, "validated", {
427
427
  configurable: !1,
428
428
  enumerable: !1,
429
429
  writable: !0,
430
430
  value: !1
431
- }), Object.defineProperty(m, "_self", {
431
+ }), Object.defineProperty(x, "_self", {
432
432
  configurable: !1,
433
433
  enumerable: !1,
434
434
  writable: !1,
435
- value: u
436
- }), Object.defineProperty(m, "_source", {
435
+ value: f
436
+ }), Object.defineProperty(x, "_source", {
437
437
  configurable: !1,
438
438
  enumerable: !1,
439
439
  writable: !1,
440
- value: h
441
- }), Object.freeze && (Object.freeze(m.props), Object.freeze(m)), m;
440
+ value: C
441
+ }), Object.freeze && (Object.freeze(x.props), Object.freeze(x)), x;
442
442
  };
443
- function Pr(e, n, i, u, h) {
443
+ function Or(e, s, i, f, C) {
444
444
  {
445
- var j, p = {}, m = null, K = null;
446
- i !== void 0 && (qe(i), m = "" + i), jr(n) && (qe(n.key), m = "" + n.key), Er(n) && (K = n.ref, _r(n, h));
447
- for (j in n)
448
- $.call(n, j) && !wr.hasOwnProperty(j) && (p[j] = n[j]);
445
+ var F, w = {}, x = null, re = null;
446
+ i !== void 0 && (Le(i), x = "" + i), kr(s) && (Le(s.key), x = "" + s.key), Nr(s) && (re = s.ref, Pr(s, C));
447
+ for (F in s)
448
+ b.call(s, F) && !Ve.hasOwnProperty(F) && (w[F] = s[F]);
449
449
  if (e && e.defaultProps) {
450
- var M = e.defaultProps;
451
- for (j in M)
452
- p[j] === void 0 && (p[j] = M[j]);
450
+ var I = e.defaultProps;
451
+ for (F in I)
452
+ w[F] === void 0 && (w[F] = I[F]);
453
453
  }
454
- if (m || K) {
454
+ if (x || re) {
455
455
  var L = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
456
- m && Rr(p, L), K && Cr(p, L);
456
+ x && Tr(w, L), re && Sr(w, L);
457
457
  }
458
- return Nr(e, m, K, h, u, Ge.current, p);
458
+ return Fr(e, x, re, C, f, xe.current, w);
459
459
  }
460
460
  }
461
- var We = O.ReactCurrentOwner, Ze = O.ReactDebugCurrentFrame;
462
- function ge(e) {
461
+ var Ke = g.ReactCurrentOwner, or = g.ReactDebugCurrentFrame;
462
+ function ke(e) {
463
463
  if (e) {
464
- var n = e._owner, i = E(e.type, e._source, n ? n.type : null);
465
- Ze.setExtraStackFrame(i);
464
+ var s = e._owner, i = le(e.type, e._source, s ? s.type : null);
465
+ or.setExtraStackFrame(i);
466
466
  } else
467
- Ze.setExtraStackFrame(null);
467
+ or.setExtraStackFrame(null);
468
468
  }
469
- var Ae;
470
- Ae = !1;
471
- function $e(e) {
469
+ var qe;
470
+ qe = !1;
471
+ function Ge(e) {
472
472
  return typeof e == "object" && e !== null && e.$$typeof === t;
473
473
  }
474
- function Xe() {
474
+ function ir() {
475
475
  {
476
- if (We.current) {
477
- var e = z(We.current.type);
476
+ if (Ke.current) {
477
+ var e = _(Ke.current.type);
478
478
  if (e)
479
479
  return `
480
480
 
@@ -483,295 +483,330 @@ Check the render method of \`` + e + "`.";
483
483
  return "";
484
484
  }
485
485
  }
486
- function Sr(e) {
486
+ function Dr(e) {
487
487
  return "";
488
488
  }
489
- var Qe = {};
490
- function kr(e) {
489
+ var lr = {};
490
+ function Wr(e) {
491
491
  {
492
- var n = Xe();
493
- if (!n) {
492
+ var s = ir();
493
+ if (!s) {
494
494
  var i = typeof e == "string" ? e : e.displayName || e.name;
495
- i && (n = `
495
+ i && (s = `
496
496
 
497
497
  Check the top-level render call using <` + i + ">.");
498
498
  }
499
- return n;
499
+ return s;
500
500
  }
501
501
  }
502
- function er(e, n) {
502
+ function cr(e, s) {
503
503
  {
504
504
  if (!e._store || e._store.validated || e.key != null)
505
505
  return;
506
506
  e._store.validated = !0;
507
- var i = kr(n);
508
- if (Qe[i])
507
+ var i = Wr(s);
508
+ if (lr[i])
509
509
  return;
510
- Qe[i] = !0;
511
- var u = "";
512
- e && e._owner && e._owner !== We.current && (u = " It was passed a child from " + z(e._owner.type) + "."), ge(e), C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', i, u), ge(null);
510
+ lr[i] = !0;
511
+ var f = "";
512
+ e && e._owner && e._owner !== Ke.current && (f = " It was passed a child from " + _(e._owner.type) + "."), ke(e), P('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', i, f), ke(null);
513
513
  }
514
514
  }
515
- function rr(e, n) {
515
+ function dr(e, s) {
516
516
  {
517
517
  if (typeof e != "object")
518
518
  return;
519
- if (De(e))
519
+ if (u(e))
520
520
  for (var i = 0; i < e.length; i++) {
521
- var u = e[i];
522
- $e(u) && er(u, n);
521
+ var f = e[i];
522
+ Ge(f) && cr(f, s);
523
523
  }
524
- else if ($e(e))
524
+ else if (Ge(e))
525
525
  e._store && (e._store.validated = !0);
526
526
  else if (e) {
527
- var h = G(e);
528
- if (typeof h == "function" && h !== e.entries)
529
- for (var j = h.call(e), p; !(p = j.next()).done; )
530
- $e(p.value) && er(p.value, n);
527
+ var C = J(e);
528
+ if (typeof C == "function" && C !== e.entries)
529
+ for (var F = C.call(e), w; !(w = F.next()).done; )
530
+ Ge(w.value) && cr(w.value, s);
531
531
  }
532
532
  }
533
533
  }
534
- function Tr(e) {
534
+ function Ar(e) {
535
535
  {
536
- var n = e.type;
537
- if (n == null || typeof n == "string")
536
+ var s = e.type;
537
+ if (s == null || typeof s == "string")
538
538
  return;
539
539
  var i;
540
- if (typeof n == "function")
541
- i = n.propTypes;
542
- else if (typeof n == "object" && (n.$$typeof === y || // Note: Memo only checks outer props here.
540
+ if (typeof s == "function")
541
+ i = s.propTypes;
542
+ else if (typeof s == "object" && (s.$$typeof === p || // Note: Memo only checks outer props here.
543
543
  // Inner props are checked in the reconciler.
544
- n.$$typeof === w))
545
- i = n.propTypes;
544
+ s.$$typeof === h))
545
+ i = s.propTypes;
546
546
  else
547
547
  return;
548
548
  if (i) {
549
- var u = z(n);
550
- hr(i, e.props, "prop", u, e);
551
- } else if (n.PropTypes !== void 0 && !Ae) {
552
- Ae = !0;
553
- var h = z(n);
554
- C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", h || "Unknown");
549
+ var f = _(s);
550
+ Ye(i, e.props, "prop", f, e);
551
+ } else if (s.PropTypes !== void 0 && !qe) {
552
+ qe = !0;
553
+ var C = _(s);
554
+ P("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", C || "Unknown");
555
555
  }
556
- typeof n.getDefaultProps == "function" && !n.getDefaultProps.isReactClassApproved && C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
556
+ typeof s.getDefaultProps == "function" && !s.getDefaultProps.isReactClassApproved && P("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
557
557
  }
558
558
  }
559
- function Or(e) {
559
+ function $r(e) {
560
560
  {
561
- for (var n = Object.keys(e.props), i = 0; i < n.length; i++) {
562
- var u = n[i];
563
- if (u !== "children" && u !== "key") {
564
- ge(e), C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", u), ge(null);
561
+ for (var s = Object.keys(e.props), i = 0; i < s.length; i++) {
562
+ var f = s[i];
563
+ if (f !== "children" && f !== "key") {
564
+ ke(e), P("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", f), ke(null);
565
565
  break;
566
566
  }
567
567
  }
568
- e.ref !== null && (ge(e), C("Invalid attribute `ref` supplied to `React.Fragment`."), ge(null));
568
+ e.ref !== null && (ke(e), P("Invalid attribute `ref` supplied to `React.Fragment`."), ke(null));
569
569
  }
570
570
  }
571
- var tr = {};
572
- function ar(e, n, i, u, h, j) {
571
+ var ur = {};
572
+ function fr(e, s, i, f, C, F) {
573
573
  {
574
- var p = I(e);
575
- if (!p) {
576
- var m = "";
577
- (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (m += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
578
- var K = Sr();
579
- K ? m += K : m += Xe();
580
- var M;
581
- e === null ? M = "null" : De(e) ? M = "array" : e !== void 0 && e.$$typeof === t ? (M = "<" + (z(e.type) || "Unknown") + " />", m = " Did you accidentally export a JSX literal instead of a component?") : M = typeof e, C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", M, m);
574
+ var w = T(e);
575
+ if (!w) {
576
+ var x = "";
577
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (x += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
578
+ var re = Dr();
579
+ re ? x += re : x += ir();
580
+ var I;
581
+ e === null ? I = "null" : u(e) ? I = "array" : e !== void 0 && e.$$typeof === t ? (I = "<" + (_(e.type) || "Unknown") + " />", x = " Did you accidentally export a JSX literal instead of a component?") : I = typeof e, P("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", I, x);
582
582
  }
583
- var L = Pr(e, n, i, h, j);
583
+ var L = Or(e, s, i, C, F);
584
584
  if (L == null)
585
585
  return L;
586
- if (p) {
587
- var te = n.children;
588
- if (te !== void 0)
589
- if (u)
590
- if (De(te)) {
591
- for (var we = 0; we < te.length; we++)
592
- rr(te[we], e);
593
- Object.freeze && Object.freeze(te);
586
+ if (w) {
587
+ var de = s.children;
588
+ if (de !== void 0)
589
+ if (f)
590
+ if (u(de)) {
591
+ for (var Pe = 0; Pe < de.length; Pe++)
592
+ dr(de[Pe], e);
593
+ Object.freeze && Object.freeze(de);
594
594
  } else
595
- C("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
595
+ P("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
596
596
  else
597
- rr(te, e);
597
+ dr(de, e);
598
598
  }
599
- if ($.call(n, "key")) {
600
- var xe = z(e), Z = Object.keys(n).filter(function(Mr) {
601
- return Mr !== "key";
602
- }), Me = Z.length > 0 ? "{key: someKey, " + Z.join(": ..., ") + ": ...}" : "{key: someKey}";
603
- if (!tr[xe + Me]) {
604
- var $r = Z.length > 0 ? "{" + Z.join(": ..., ") + ": ...}" : "{}";
605
- C(`A props object containing a "key" prop is being spread into JSX:
599
+ if (b.call(s, "key")) {
600
+ var Ce = _(e), ne = Object.keys(s).filter(function(Yr) {
601
+ return Yr !== "key";
602
+ }), He = ne.length > 0 ? "{key: someKey, " + ne.join(": ..., ") + ": ...}" : "{key: someKey}";
603
+ if (!ur[Ce + He]) {
604
+ var Br = ne.length > 0 ? "{" + ne.join(": ..., ") + ": ...}" : "{}";
605
+ P(`A props object containing a "key" prop is being spread into JSX:
606
606
  let props = %s;
607
607
  <%s {...props} />
608
608
  React keys must be passed directly to JSX without using spread:
609
609
  let props = %s;
610
- <%s key={someKey} {...props} />`, Me, xe, $r, xe), tr[xe + Me] = !0;
610
+ <%s key={someKey} {...props} />`, He, Ce, Br, Ce), ur[Ce + He] = !0;
611
611
  }
612
612
  }
613
- return e === o ? Or(L) : Tr(L), L;
613
+ return e === o ? $r(L) : Ar(L), L;
614
614
  }
615
615
  }
616
- function Fr(e, n, i) {
617
- return ar(e, n, i, !0);
616
+ function Mr(e, s, i) {
617
+ return fr(e, s, i, !0);
618
618
  }
619
- function Dr(e, n, i) {
620
- return ar(e, n, i, !1);
619
+ function Ir(e, s, i) {
620
+ return fr(e, s, i, !1);
621
621
  }
622
- var Wr = Dr, Ar = Fr;
623
- _e.Fragment = o, _e.jsx = Wr, _e.jsxs = Ar;
624
- }()), _e;
622
+ var Ur = Ir, Lr = Mr;
623
+ $e.Fragment = o, $e.jsx = Ur, $e.jsxs = Lr;
624
+ }()), $e;
625
625
  }
626
- process.env.NODE_ENV === "production" ? ze.exports = Ir() : ze.exports = Ur();
627
- var a = ze.exports;
628
- function mr(r) {
629
- var t, s, o = "";
626
+ process.env.NODE_ENV === "production" ? rr.exports = zr() : rr.exports = Vr();
627
+ var a = rr.exports;
628
+ function _r(r) {
629
+ var t, n, o = "";
630
630
  if (typeof r == "string" || typeof r == "number") o += r;
631
631
  else if (typeof r == "object") if (Array.isArray(r)) {
632
632
  var l = r.length;
633
- for (t = 0; t < l; t++) r[t] && (s = mr(r[t])) && (o && (o += " "), o += s);
634
- } else for (s in r) r[s] && (o && (o += " "), o += s);
633
+ for (t = 0; t < l; t++) r[t] && (n = _r(r[t])) && (o && (o += " "), o += n);
634
+ } else for (n in r) r[n] && (o && (o += " "), o += n);
635
635
  return o;
636
636
  }
637
- function ne() {
638
- for (var r, t, s = 0, o = "", l = arguments.length; s < l; s++) (r = arguments[s]) && (t = mr(r)) && (o && (o += " "), o += t);
637
+ function Q() {
638
+ for (var r, t, n = 0, o = "", l = arguments.length; n < l; n++) (r = arguments[n]) && (t = _r(r)) && (o && (o += " "), o += t);
639
639
  return o;
640
640
  }
641
- const Lr = "https://core.spreedly.com/iframe/iframe-v1.min.js", Yr = "https://cdn.e2e.movmo.io";
642
- let Ne = {};
643
- const yt = (r) => {
644
- Ne = { ...Ne, ...r };
645
- }, Ie = (r) => {
646
- var s;
641
+ const Kr = "https://core.spreedly.com/iframe/iframe-v1.min.js", qr = "https://cdn.e2e.movmo.io";
642
+ let Te = {};
643
+ const Ct = (r) => {
644
+ Te = { ...Te, ...r };
645
+ }, Je = (r) => {
646
+ var n;
647
647
  const t = globalThis.process;
648
- return (s = t == null ? void 0 : t.env) == null ? void 0 : s[r];
649
- }, Fe = () => ({
650
- baseUrl: Ne.baseUrl ?? Ie("REACT_APP_MOVMO_API_URL") ?? "",
651
- spreedlyScriptUrl: Ne.spreedlyScriptUrl ?? Ie("REACT_APP_SPREEDLY_SCRIPT_URL") ?? Lr,
652
- iconCdnBaseUrl: Ne.iconCdnBaseUrl ?? Ie("REACT_APP_MOVMO_ICON_CDN_URL") ?? Yr
653
- }), pr = (r) => ({
648
+ return (n = t == null ? void 0 : t.env) == null ? void 0 : n[r];
649
+ }, We = () => ({
650
+ baseUrl: Te.baseUrl ?? Je("REACT_APP_MOVMO_API_URL") ?? "",
651
+ spreedlyScriptUrl: Te.spreedlyScriptUrl ?? Je("REACT_APP_SPREEDLY_SCRIPT_URL") ?? Kr,
652
+ iconCdnBaseUrl: Te.iconCdnBaseUrl ?? Je("REACT_APP_MOVMO_ICON_CDN_URL") ?? qr,
653
+ fetch: Te.fetch ?? (typeof globalThis < "u" && typeof globalThis.fetch == "function" ? globalThis.fetch.bind(globalThis) : (() => {
654
+ throw new Error("@movmo_app/payments: no fetch available");
655
+ })())
656
+ }), tr = (r) => ({
654
657
  id: r.id,
655
658
  last4: r.last4,
656
659
  brand: r.brand,
657
660
  expMonth: r.expMonth,
658
661
  expYear: r.expYear,
659
662
  isDefault: r.isDefault
660
- }), Pe = {
663
+ }), Se = {
661
664
  Accept: "application/json",
662
665
  "Content-Type": "application/json"
663
- }, Se = (r) => {
664
- const { baseUrl: t } = Fe();
666
+ }, Fe = (r) => {
667
+ const { baseUrl: t } = We();
665
668
  if (!t)
666
669
  throw new Error(
667
670
  "@movmo_app/payments: baseUrl is not configured. Call setPaymentsConfig({ baseUrl }) at app boot, or set REACT_APP_MOVMO_API_URL."
668
671
  );
669
672
  return `${t}${r}`;
670
- }, ke = async (r, t) => {
673
+ }, Oe = (r, t) => {
674
+ const { fetch: n } = We();
675
+ return n(r, t);
676
+ }, De = async (r, t) => {
671
677
  try {
672
678
  return (await r.json()).message || t;
673
679
  } catch {
674
680
  return t;
675
681
  }
676
- }, Vr = async () => {
677
- const r = await fetch(Se("/v1/payments/tokenization-session"), {
678
- method: "GET",
679
- headers: Pe,
680
- credentials: "include"
681
- });
682
- if (!r.ok)
683
- throw new Error(await ke(r, `Failed to fetch tokenization session (${r.status})`));
684
- return await r.json();
685
- }, zr = async (r, t, s) => {
686
- const o = await fetch(
687
- Se(`/v1/users/${encodeURIComponent(r)}/payment-methods/from-token`),
682
+ };
683
+ let Me = null;
684
+ const ar = () => {
685
+ if (Me) return Me;
686
+ const r = (async () => {
687
+ const t = await Oe(Fe("/v1/payments/tokenization-session"), {
688
+ method: "GET",
689
+ headers: Se,
690
+ credentials: "include"
691
+ });
692
+ if (!t.ok)
693
+ throw new Error(
694
+ await De(t, `Failed to fetch tokenization session (${t.status})`)
695
+ );
696
+ return await t.json();
697
+ })();
698
+ return Me = r, r.finally(() => {
699
+ Me === r && (Me = null);
700
+ }).catch(() => {
701
+ }), r;
702
+ }, Gr = (r) => typeof r.brand == "string" && typeof r.last4 == "string" && typeof r.expMonth == "number" && typeof r.expYear == "number", Hr = async (r, t, n) => {
703
+ const o = await Oe(
704
+ Fe(`/v1/users/${encodeURIComponent(r)}/payment-methods/from-token`),
688
705
  {
689
706
  method: "POST",
690
- headers: Pe,
707
+ headers: Se,
691
708
  credentials: "include",
692
- body: JSON.stringify({ tokenizedPaymentMethodId: t, isDefault: s })
709
+ body: JSON.stringify({ tokenizedPaymentMethodId: t, isDefault: n })
693
710
  }
694
711
  );
695
712
  if (!o.ok)
696
- throw new Error(await ke(o, `Failed to save payment method (${o.status})`));
713
+ throw new Error(await De(o, `Failed to save payment method (${o.status})`));
697
714
  const l = await o.json();
698
- return pr(l);
699
- }, Br = async (r) => {
700
- const t = await fetch(Se(`/v1/users/${encodeURIComponent(r)}/payment-methods`), {
715
+ if (Gr(l))
716
+ return tr(l);
717
+ const c = await Oe(
718
+ Fe(
719
+ `/v1/users/${encodeURIComponent(r)}/payment-methods/${encodeURIComponent(l.id)}`
720
+ ),
721
+ {
722
+ method: "GET",
723
+ headers: Se,
724
+ credentials: "include"
725
+ }
726
+ );
727
+ if (!c.ok)
728
+ throw new Error(
729
+ await De(c, `Failed to fetch saved payment method (${c.status})`)
730
+ );
731
+ const m = await c.json();
732
+ return tr(m);
733
+ }, Jr = async (r, t) => {
734
+ const n = await Oe(Fe(`/v1/users/${encodeURIComponent(r)}/payment-methods`), {
701
735
  method: "GET",
702
- headers: Pe,
703
- credentials: "include"
736
+ headers: Se,
737
+ credentials: "include",
738
+ signal: t
704
739
  });
705
- if (!t.ok)
706
- throw new Error(await ke(t, `Failed to fetch payment methods (${t.status})`));
707
- return (await t.json() ?? []).map(pr);
708
- }, Kr = async (r, t) => {
709
- const s = await fetch(
710
- Se(
740
+ if (!n.ok)
741
+ throw new Error(await De(n, `Failed to fetch payment methods (${n.status})`));
742
+ return (await n.json() ?? []).map(tr);
743
+ }, Xr = async (r, t) => {
744
+ const n = await Oe(
745
+ Fe(
711
746
  `/v1/users/${encodeURIComponent(r)}/payment-methods/${encodeURIComponent(t)}`
712
747
  ),
713
748
  {
714
749
  method: "DELETE",
715
- headers: Pe,
750
+ headers: Se,
716
751
  credentials: "include"
717
752
  }
718
753
  );
719
- if (!s.ok)
720
- throw new Error(await ke(s, `Failed to delete payment method (${s.status})`));
721
- }, qr = async (r, t, s) => {
722
- const o = await fetch(
723
- Se(
754
+ if (!n.ok)
755
+ throw new Error(await De(n, `Failed to delete payment method (${n.status})`));
756
+ }, Zr = async (r, t, n) => {
757
+ const o = await Oe(
758
+ Fe(
724
759
  `/v1/users/${encodeURIComponent(r)}/payment-methods/${encodeURIComponent(t)}`
725
760
  ),
726
761
  {
727
762
  method: "PUT",
728
- headers: Pe,
763
+ headers: Se,
729
764
  credentials: "include",
730
- body: JSON.stringify(s)
765
+ body: JSON.stringify(n)
731
766
  }
732
767
  );
733
768
  if (!o.ok)
734
- throw new Error(await ke(o, `Failed to update payment method (${o.status})`));
735
- }, Gr = {
769
+ throw new Error(await De(o, `Failed to update payment method (${o.status})`));
770
+ }, Qr = {
736
771
  visa: "visa",
737
772
  master: "mastercard",
738
773
  mastercard: "mastercard",
739
774
  american_express: "amex",
740
775
  amex: "amex",
741
776
  discover: "discover"
742
- }, Jr = 28, be = ({
777
+ }, et = 28, Ne = ({
743
778
  brand: r,
744
779
  className: t,
745
- width: s = 46
780
+ width: n = 46
746
781
  }) => {
747
- const o = Gr[r.toLowerCase()] ?? "credit-card", l = Math.max(s, Jr), f = Math.round(l * 24 / 34), { iconCdnBaseUrl: d } = Fe();
782
+ const o = r ? Qr[r.toLowerCase()] ?? "credit-card" : "credit-card", l = Math.max(n, et), c = Math.round(l * 24 / 34), { iconCdnBaseUrl: m } = We();
748
783
  return /* @__PURE__ */ a.jsx(
749
784
  "img",
750
785
  {
751
- src: `${d}/website/assets/icons/payments/${o}.svg`,
786
+ src: `${m}/website/assets/icons/payments/${o}.svg`,
752
787
  alt: o === "credit-card" ? "card" : `${o} card`,
753
788
  "data-testid": `card-brand-${r.toLowerCase()}`,
754
789
  className: t,
755
790
  width: l,
756
- height: f,
791
+ height: c,
757
792
  loading: "lazy"
758
793
  }
759
794
  );
760
795
  };
761
- let Re = null;
762
- const Hr = () => {
796
+ let Ie = null;
797
+ const rt = () => {
763
798
  if (typeof window > "u")
764
799
  return Promise.reject(new Error("Spreedly can only be loaded in a browser environment."));
765
800
  if (window.Spreedly)
766
801
  return Promise.resolve(window.Spreedly);
767
- if (Re)
768
- return Re;
769
- const { spreedlyScriptUrl: r } = Fe();
770
- return Re = new Promise((t, s) => {
802
+ if (Ie)
803
+ return Ie;
804
+ const { spreedlyScriptUrl: r } = We();
805
+ return Ie = new Promise((t, n) => {
771
806
  const o = document.querySelector(
772
807
  `script[src="${r}"]`
773
808
  ), l = () => {
774
- window.Spreedly ? t(window.Spreedly) : s(new Error("Spreedly script loaded but window.Spreedly is undefined."));
809
+ window.Spreedly ? t(window.Spreedly) : n(new Error("Spreedly script loaded but window.Spreedly is undefined."));
775
810
  };
776
811
  if (o) {
777
812
  if (window.Spreedly) {
@@ -781,246 +816,306 @@ const Hr = () => {
781
816
  o.addEventListener("load", l, { once: !0 }), o.addEventListener(
782
817
  "error",
783
818
  () => {
784
- o.remove(), s(new Error("Failed to load Spreedly iframe script."));
819
+ o.remove(), n(new Error("Failed to load Spreedly iframe script."));
785
820
  },
786
821
  { once: !0 }
787
822
  );
788
823
  return;
789
824
  }
790
- const f = document.createElement("script");
791
- f.src = r, f.async = !0, f.onload = l, f.onerror = () => {
792
- f.remove(), s(new Error("Failed to load Spreedly iframe script."));
793
- }, document.head.appendChild(f);
825
+ const c = document.createElement("script");
826
+ c.src = r, c.async = !0, c.onload = l, c.onerror = () => {
827
+ c.remove(), n(new Error("Failed to load Spreedly iframe script."));
828
+ }, document.head.appendChild(c);
794
829
  }).catch((t) => {
795
- throw Re = null, t;
796
- }), Re;
797
- }, Zr = "movmo-card-number", Xr = "movmo-card-cvv", Qr = (r) => ({
830
+ throw Ie = null, t;
831
+ }), Ie;
832
+ }, tt = "movmo-card-number", at = "movmo-card-cvv", nt = (r) => ({
798
833
  first_name: r.firstName,
799
834
  last_name: r.lastName,
800
835
  month: r.month,
801
836
  year: r.year,
802
837
  ...r.email ? { email: r.email } : {},
803
838
  ...r.zip ? { zip: r.zip } : {}
804
- }), et = (r = {}) => {
839
+ }), st = (r = {}) => {
805
840
  const {
806
- numberEl: t = Zr,
807
- cvvEl: s = Xr,
841
+ numberEl: t = tt,
842
+ cvvEl: n = at,
808
843
  onCardTokenized: o,
809
844
  onFieldErrors: l,
810
- onValidityChange: f,
811
- onBrandChange: d
812
- } = r, [v, y] = S("idle"), [T, g] = S(null), [w, F] = S({ number: !1, cvv: !1 }), [_, D] = S(null), R = q(null), G = q(o), O = q(l), C = q(f), J = q(d);
813
- X(() => {
814
- G.current = o;
815
- }, [o]), X(() => {
816
- O.current = l;
817
- }, [l]), X(() => {
818
- C.current = f;
819
- }, [f]), X(() => {
820
- J.current = d;
821
- }, [d]);
822
- const W = q({ number: !1, cvv: !1 });
823
- X(() => {
824
- let A = !1;
825
- return y("loading"), g(null), F({ number: !1, cvv: !1 }), D(null), W.current = { number: !1, cvv: !1 }, (async () => {
845
+ onValidityChange: c,
846
+ onBrandChange: m
847
+ } = r, [y, p] = O("idle"), [D, R] = O(null), [h, v] = O({ number: !1, cvv: !1 }), [E, A] = O(null), [k, J] = O({ number: !1, cvv: !1 }), g = Y(null), P = Y(o), G = Y(l), ue = Y(c), te = Y(m);
848
+ B(() => {
849
+ P.current = o;
850
+ }, [o]), B(() => {
851
+ G.current = l;
852
+ }, [l]), B(() => {
853
+ ue.current = c;
854
+ }, [c]), B(() => {
855
+ te.current = m;
856
+ }, [m]);
857
+ const j = Y({ number: !1, cvv: !1 });
858
+ B(() => {
859
+ let U = !1;
860
+ return p("loading"), R(null), v({ number: !1, cvv: !1 }), A(null), j.current = { number: !1, cvv: !1 }, (async () => {
826
861
  try {
827
- const [x, b] = await Promise.all([
828
- Vr(),
829
- Hr()
862
+ const [T, d] = await Promise.all([
863
+ ar(),
864
+ rt()
830
865
  ]);
831
- if (A) return;
832
- R.current = b, b.on("ready", () => {
833
- var I;
834
- if (!A) {
835
- y("ready");
866
+ if (U) return;
867
+ g.current = d, d.on("ready", () => {
868
+ var S, _, M, X, z, ee;
869
+ if (!U) {
870
+ p("ready");
836
871
  try {
837
- (I = b.setNumberFormat) == null || I.call(b, "prettyFormat");
872
+ (S = d.setFieldType) == null || S.call(d, "number", "tel"), (_ = d.setFieldType) == null || _.call(d, "cvv", "tel");
838
873
  } catch {
839
874
  }
875
+ try {
876
+ typeof d.setNumberFormat == "function" ? d.setNumberFormat("prettyFormat") : console.warn(
877
+ "@movmo_app/payments: Spreedly.setNumberFormat is missing — card-number digits will not be space-grouped."
878
+ );
879
+ } catch (V) {
880
+ console.warn("@movmo_app/payments: setNumberFormat failed", V);
881
+ }
882
+ try {
883
+ (M = d.setPlaceholder) == null || M.call(d, "number", "Card number"), (X = d.setPlaceholder) == null || X.call(d, "cvv", "CVV");
884
+ 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;';
885
+ (z = d.setStyle) == null || z.call(d, "number", V), (ee = d.setStyle) == null || ee.call(d, "cvv", V);
886
+ } catch {
887
+ }
888
+ }
889
+ }), d.on("paymentMethod", (S) => {
890
+ var _;
891
+ (_ = P.current) == null || _.call(P, S);
892
+ }), d.on("errors", (S) => {
893
+ var _;
894
+ (_ = G.current) == null || _.call(G, S);
895
+ }), d.on("fieldEvent", (S, _, M, X) => {
896
+ var V;
897
+ if (U) return;
898
+ if (_ === "focus") {
899
+ J((N) => N[S] ? N : { ...N, [S]: !0 });
900
+ return;
840
901
  }
841
- }), b.on("paymentMethod", (I) => {
842
- var U;
843
- (U = G.current) == null || U.call(G, I);
844
- }), b.on("errors", (I) => {
845
- var U;
846
- (U = O.current) == null || U.call(O, I);
847
- }), b.on("fieldEvent", (I, U, ie, z) => {
848
- var ue;
849
- if (A || U !== "input") return;
850
- const N = z ?? {};
851
- if (I === "number") {
852
- if (N.numberLength === 0)
853
- D((V) => {
854
- var k;
855
- return V !== null && ((k = J.current) == null || k.call(J, null)), null;
902
+ if (_ === "blur") {
903
+ J((N) => N[S] ? { ...N, [S]: !1 } : N);
904
+ return;
905
+ }
906
+ if (_ !== "input") return;
907
+ const z = X ?? {};
908
+ if (S === "number") {
909
+ if (z.numberLength === 0)
910
+ A((N) => {
911
+ var W;
912
+ return N !== null && ((W = te.current) == null || W.call(te, null)), null;
856
913
  });
857
- else if (N.cardType !== void 0) {
858
- const V = N.cardType || null;
859
- D((k) => {
860
- var le;
861
- return k !== V && ((le = J.current) == null || le.call(J, V)), V;
914
+ else if (z.cardType !== void 0) {
915
+ const N = z.cardType || null;
916
+ A((W) => {
917
+ var me;
918
+ return W !== N && ((me = te.current) == null || me.call(te, N)), N;
862
919
  });
863
920
  }
864
921
  }
865
- const Y = I === "number" ? typeof N.validNumber == "boolean" ? N.validNumber : void 0 : typeof N.validCvv == "boolean" ? N.validCvv : void 0;
866
- if (typeof Y == "boolean") {
867
- const V = W.current, k = I === "number" ? { ...V, number: Y } : { ...V, cvv: Y };
868
- (k.number !== V.number || k.cvv !== V.cvv) && (W.current = k, F(k), (ue = C.current) == null || ue.call(C, k));
922
+ const ee = S === "number" ? typeof z.validNumber == "boolean" ? z.validNumber : void 0 : typeof z.validCvv == "boolean" ? z.validCvv : void 0;
923
+ if (typeof ee == "boolean") {
924
+ const N = j.current, W = S === "number" ? { ...N, number: ee } : { ...N, cvv: ee };
925
+ (W.number !== N.number || W.cvv !== N.cvv) && (j.current = W, v(W), (V = ue.current) == null || V.call(ue, W));
869
926
  }
870
- }), b.on("consoleError", (I) => {
871
- var ie;
872
- const U = I instanceof Error ? I.message : "An unexpected error occurred while securing your card.";
873
- (ie = O.current) == null || ie.call(O, [{ message: U }]);
874
- }), b.init(x.environmentKey, {
927
+ }), d.on("consoleError", (S) => {
928
+ var M;
929
+ const _ = S instanceof Error ? S.message : "An unexpected error occurred while securing your card.";
930
+ (M = G.current) == null || M.call(G, [{ message: _ }]);
931
+ }), d.init(T.environmentKey, {
875
932
  numberEl: t,
876
- cvvEl: s,
877
- nonce: x.nonce,
878
- timestamp: String(x.timestamp),
879
- certificateToken: x.certificateToken,
880
- signature: x.signature
933
+ cvvEl: n,
934
+ nonce: T.nonce,
935
+ timestamp: String(T.timestamp),
936
+ certificateToken: T.certificateToken,
937
+ signature: T.signature
881
938
  });
882
- } catch (x) {
883
- if (A) return;
884
- const b = x instanceof Error ? x.message : "Failed to initialize card form.";
885
- g(b), y("error");
939
+ } catch (T) {
940
+ if (U) return;
941
+ const d = T instanceof Error ? T.message : "Failed to initialize card form.";
942
+ R(d), p("error");
886
943
  }
887
944
  })(), () => {
888
- var x, b;
889
- A = !0;
945
+ var T, d;
946
+ U = !0;
890
947
  try {
891
- (b = (x = R.current) == null ? void 0 : x.removeHandlers) == null || b.call(x);
948
+ (d = (T = g.current) == null ? void 0 : T.removeHandlers) == null || d.call(T);
892
949
  } catch {
893
950
  }
894
- R.current = null;
951
+ g.current = null;
895
952
  };
896
- }, [t, s]);
897
- const se = B((A) => {
898
- var x;
899
- (x = R.current) == null || x.tokenizeCreditCard(Qr(A));
900
- }, []), oe = B((A) => {
901
- var x, b;
902
- (b = (x = R.current) == null ? void 0 : x.transferFocus) == null || b.call(x, A);
953
+ }, [t, n]);
954
+ const se = Z((U) => {
955
+ var T;
956
+ (T = g.current) == null || T.tokenizeCreditCard(nt(U));
957
+ }, []), he = Z((U) => {
958
+ var T, d;
959
+ (d = (T = g.current) == null ? void 0 : T.transferFocus) == null || d.call(T, U);
903
960
  }, []);
904
- return { status: v, error: T, tokenize: se, validity: w, brand: _, focusField: oe };
905
- }, Ue = "h-11 w-full rounded-md border border-grayWarm-300 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]", or = "flex h-11 w-full items-center gap-2 rounded-md border border-grayWarm-300 bg-white px-3 py-2 transition-shadow focus-within:border-grayWarm-950 focus-within:shadow-[0_0_0_1px_#1c1917]", rt = (r) => {
961
+ return { status: y, error: D, tokenize: se, validity: h, brand: E, focused: k, focusField: he };
962
+ }, Xe = "h-11 w-full rounded-md border border-grayWarm-300 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]", hr = "flex h-11 w-full items-center gap-2 rounded-md border bg-white px-3 py-2 transition-shadow", yr = "border-grayWarm-950 shadow-[0_0_0_1px_#1c1917]", vr = "border-grayWarm-300", ot = (r) => {
906
963
  const t = r.trim();
907
964
  if (!t) return { firstName: "", lastName: "" };
908
- const s = t.lastIndexOf(" ");
909
- return s === -1 ? { firstName: t, lastName: "" } : {
910
- firstName: t.slice(0, s).trim(),
911
- lastName: t.slice(s + 1).trim()
965
+ const n = t.lastIndexOf(" ");
966
+ return n === -1 ? { firstName: t, lastName: "" } : {
967
+ firstName: t.slice(0, n).trim(),
968
+ lastName: t.slice(n + 1).trim()
912
969
  };
913
- }, yr = (r) => {
970
+ }, Rr = (r) => {
914
971
  const t = r.replace(/\D/g, "");
915
972
  if (t.length < 4) return { month: "", year: "" };
916
- const s = t.slice(0, 2), o = t.slice(2), l = o.length === 2 ? `20${o}` : o.slice(0, 4);
917
- return { month: s, year: l };
918
- }, tt = (r) => {
973
+ const n = t.slice(0, 2), o = t.slice(2), l = o.length === 2 ? `20${o}` : o.slice(0, 4);
974
+ return { month: n, year: l };
975
+ }, it = (r) => {
919
976
  const t = r.replace(/\D/g, "").slice(0, 4);
920
977
  return t.length <= 2 ? t : `${t.slice(0, 2)} / ${t.slice(2)}`;
921
- }, Le = (r) => {
922
- const { month: t, year: s } = yr(r);
923
- if (!t || !s) return !1;
924
- const o = parseInt(t, 10), l = parseInt(s, 10);
978
+ }, Ze = (r) => {
979
+ const { month: t, year: n } = Rr(r);
980
+ if (!t || !n) return !1;
981
+ const o = parseInt(t, 10), l = parseInt(n, 10);
925
982
  if (isNaN(o) || o < 1 || o > 12) return !1;
926
- const f = /* @__PURE__ */ new Date();
927
- return !(l < f.getFullYear() || l > f.getFullYear() + 20 || l === f.getFullYear() && o < f.getMonth() + 1);
928
- }, Ye = (r) => /^\d{5}(-\d{4})?$/.test(r.trim()), at = (r) => {
983
+ const c = /* @__PURE__ */ new Date();
984
+ return !(l < c.getFullYear() || l > c.getFullYear() + 20 || l === c.getFullYear() && o < c.getMonth() + 1);
985
+ }, Qe = (r) => /^\d{5}(-\d{4})?$/.test(r.trim()), lt = (r) => {
929
986
  const t = r.replace(/[^\d]/g, "").slice(0, 9);
930
987
  return t.length <= 5 ? t : `${t.slice(0, 5)}-${t.slice(5)}`;
931
- }, vr = ({
988
+ }, Cr = ({
932
989
  userId: r,
933
990
  onSuccess: t,
934
- onError: s,
991
+ onError: n,
935
992
  isDefault: o = !1,
936
993
  className: l,
937
- defaultCardholderName: f,
938
- defaultCardholderFirstName: d = "",
939
- defaultCardholderLastName: v = "",
940
- autoSave: y = !1,
941
- formId: T = "movmo-card-form",
942
- hideInternalSaveButton: g = !1,
943
- onCanSubmitChange: w
994
+ defaultCardholderName: c,
995
+ defaultCardholderFirstName: m = "",
996
+ defaultCardholderLastName: y = "",
997
+ autoSave: p = !1,
998
+ formId: D = "movmo-card-form",
999
+ hideInternalSaveButton: R = !1,
1000
+ onCanSubmitChange: h,
1001
+ onSavingChange: v,
1002
+ autoFocus: E
944
1003
  }) => {
945
- const F = f ?? [d, v].filter(Boolean).join(" "), [_, D] = S(F), [R, G] = S(""), [O, C] = S(""), [J, W] = S("idle"), [se, oe] = S(null), A = q(!1), x = B(
946
- async (P) => {
947
- W("saving");
1004
+ const A = c ?? [m, y].filter(Boolean).join(" "), [k, J] = O(A), [g, P] = O(""), [G, ue] = O(""), [te, j] = O("idle"), se = Y(!1), he = Z(
1005
+ async (b) => {
1006
+ j("saving");
948
1007
  try {
949
- const c = await zr(r, P, o);
950
- W("ready"), t(c);
951
- } catch (c) {
952
- const E = c instanceof Error ? c.message : "Failed to save payment method.";
953
- oe(E), W("ready"), A.current = !1, s(E);
1008
+ const $ = await Hr(r, b, o);
1009
+ j("ready"), t($);
1010
+ } catch ($) {
1011
+ const K = $ instanceof Error ? $.message : "Failed to save payment method.";
1012
+ j("ready"), se.current = !1, n(K);
954
1013
  }
955
1014
  },
956
- [r, o, t, s]
957
- ), b = B(
958
- (P) => {
959
- const c = P.map((E) => E.message).filter(Boolean).join("; ") || "Card validation failed.";
960
- oe(c), W((E) => E === "tokenizing" ? "ready" : E), A.current = !1, s(c);
1015
+ [r, o, t, n]
1016
+ ), U = Z(
1017
+ (b) => {
1018
+ const $ = b.map((K) => K.message).filter(Boolean).join("; ") || "Card validation failed.";
1019
+ j((K) => K === "tokenizing" ? "ready" : K), se.current = !1, n($);
961
1020
  },
962
- [s]
963
- ), I = Ce(
1021
+ [n]
1022
+ ), T = Ue(
964
1023
  () => ({
965
- onCardTokenized: x,
966
- onFieldErrors: b
1024
+ onCardTokenized: he,
1025
+ onFieldErrors: U
967
1026
  }),
968
- [x, b]
1027
+ [he, U]
969
1028
  ), {
970
- status: U,
971
- error: ie,
972
- tokenize: z,
973
- validity: N,
974
- brand: Y,
975
- focusField: ue
976
- } = et(I), V = _.trim().split(/\s+/).length >= 2, k = Le(R), le = Ye(O), ce = q(!1), fe = q(!1), me = q(!1), pe = q(null), he = q(null);
977
- X(() => {
978
- var P;
979
- N.cvv ? fe.current || (fe.current = !0, (P = pe.current) == null || P.focus()) : fe.current = !1;
980
- }, [N.cvv]);
981
- const Ee = !V || !k || !le || !N.number || !N.cvv, ae = J === "tokenizing" || J === "saving", Q = U === "ready" && !ae && !Ee, ee = q(w);
982
- X(() => {
983
- ee.current = w;
984
- }, [w]), X(() => {
985
- var P;
986
- (P = ee.current) == null || P.call(ee, Q);
987
- }, [Q]);
988
- const re = B(() => {
989
- const { firstName: P, lastName: c } = rt(_), { month: E, year: $ } = yr(R);
990
- oe(null), W("tokenizing"), z({ firstName: P, lastName: c, month: E, year: $, zip: O.trim() });
991
- }, [_, R, O, z]);
992
- X(() => {
993
- if (!y || !Q || A.current) return;
994
- const P = setTimeout(() => {
995
- A.current = !0, re();
1029
+ status: d,
1030
+ error: S,
1031
+ tokenize: _,
1032
+ validity: M,
1033
+ brand: X,
1034
+ focused: z,
1035
+ focusField: ee
1036
+ } = st(T), V = Y(!1);
1037
+ B(() => {
1038
+ !E || d !== "ready" || V.current || (V.current = !0, ee(E));
1039
+ }, [E, d, ee]);
1040
+ const N = k.trim().split(/\s+/).length >= 2, W = Ze(g), me = Qe(G), ye = Y(!1), ge = Y(!1), we = Y(!1), fe = Y(null), je = Y(null);
1041
+ B(() => {
1042
+ var b;
1043
+ M.cvv ? ge.current || (ge.current = !0, (b = fe.current) == null || b.focus()) : ge.current = !1;
1044
+ }, [M.cvv]);
1045
+ const ve = !N || !W || !me || !M.number || !M.cvv, H = te === "tokenizing" || te === "saving", oe = d === "ready" && !H && !ve, ie = Y(h);
1046
+ B(() => {
1047
+ ie.current = h;
1048
+ }, [h]), B(() => {
1049
+ var b;
1050
+ (b = ie.current) == null || b.call(ie, oe);
1051
+ }, [oe]);
1052
+ const be = Y(v);
1053
+ B(() => {
1054
+ be.current = v;
1055
+ }, [v]), B(() => {
1056
+ var b;
1057
+ (b = be.current) == null || b.call(be, H);
1058
+ }, [H]);
1059
+ const Ee = Z(() => {
1060
+ const { firstName: b, lastName: $ } = ot(k), { month: K, year: pe } = Rr(g);
1061
+ j("tokenizing"), _({ firstName: b, lastName: $, month: K, year: pe, zip: G.trim() });
1062
+ }, [k, g, G, _]);
1063
+ B(() => {
1064
+ if (!p || !oe || se.current) return;
1065
+ const b = setTimeout(() => {
1066
+ se.current = !0, Ee();
996
1067
  }, 1200);
997
- return () => clearTimeout(P);
998
- }, [y, Q, re]);
999
- const de = (P) => {
1000
- P.preventDefault(), Q && re();
1001
- }, ye = se ?? ie, ve = U !== "ready" || ae;
1002
- return /* @__PURE__ */ a.jsxs(
1068
+ return () => clearTimeout(b);
1069
+ }, [p, oe, Ee]);
1070
+ const Re = (b) => {
1071
+ b.preventDefault(), oe && Ee();
1072
+ }, _e = d !== "ready" || H, le = Y(n);
1073
+ return B(() => {
1074
+ le.current = n;
1075
+ }, [n]), B(() => {
1076
+ var b;
1077
+ S && ((b = le.current) == null || b.call(le, S));
1078
+ }, [S]), /* @__PURE__ */ a.jsxs(
1003
1079
  "form",
1004
1080
  {
1005
- id: T,
1006
- onSubmit: de,
1007
- className: ne("flex w-full flex-col gap-3", l),
1081
+ id: D,
1082
+ onSubmit: Re,
1083
+ className: Q("flex w-full flex-col gap-3", l),
1008
1084
  "data-testid": "movmo-card-form",
1009
1085
  children: [
1010
1086
  /* @__PURE__ */ a.jsxs("div", { children: [
1011
1087
  /* @__PURE__ */ a.jsx("span", { id: "movmo-card-number-label", className: "sr-only", children: "Card number" }),
1012
- /* @__PURE__ */ a.jsxs("div", { className: or, children: [
1013
- /* @__PURE__ */ a.jsx(be, { brand: Y ?? "", width: 32, className: "flex-shrink-0" }),
1014
- /* @__PURE__ */ a.jsx(
1015
- "div",
1016
- {
1017
- id: "movmo-card-number",
1018
- "aria-labelledby": "movmo-card-number-label",
1019
- className: "flex-1",
1020
- "data-testid": "movmo-card-number-mount"
1021
- }
1022
- )
1023
- ] })
1088
+ /* @__PURE__ */ a.jsxs(
1089
+ "div",
1090
+ {
1091
+ className: Q(
1092
+ hr,
1093
+ z.number ? yr : vr
1094
+ ),
1095
+ children: [
1096
+ /* @__PURE__ */ a.jsx(Ne, { brand: X ?? "", width: 32, className: "flex-shrink-0" }),
1097
+ /* @__PURE__ */ a.jsxs("div", { className: "relative h-full flex-1", children: [
1098
+ /* @__PURE__ */ a.jsx(
1099
+ "div",
1100
+ {
1101
+ id: "movmo-card-number",
1102
+ "aria-labelledby": "movmo-card-number-label",
1103
+ "aria-busy": d !== "ready",
1104
+ className: "absolute inset-0",
1105
+ "data-testid": "movmo-card-number-mount"
1106
+ }
1107
+ ),
1108
+ d !== "ready" ? /* @__PURE__ */ a.jsx(
1109
+ "div",
1110
+ {
1111
+ "aria-hidden": "true",
1112
+ className: "pointer-events-none absolute inset-y-2 left-0 right-2 animate-pulse rounded bg-grayWarm-200"
1113
+ }
1114
+ ) : null
1115
+ ] })
1116
+ ]
1117
+ }
1118
+ )
1024
1119
  ] }),
1025
1120
  /* @__PURE__ */ a.jsxs("div", { className: "grid grid-cols-3 gap-3", children: [
1026
1121
  /* @__PURE__ */ a.jsxs("div", { children: [
@@ -1033,13 +1128,13 @@ const Hr = () => {
1033
1128
  inputMode: "numeric",
1034
1129
  autoComplete: "cc-exp",
1035
1130
  placeholder: "MM / YY",
1036
- value: R,
1037
- onChange: (P) => {
1038
- const c = tt(P.target.value);
1039
- G(c), Le(c) && !ce.current ? (ce.current = !0, ue("cvv")) : Le(c) || (ce.current = !1);
1131
+ value: g,
1132
+ onChange: (b) => {
1133
+ const $ = it(b.target.value);
1134
+ P($), Ze($) && !ye.current ? (ye.current = !0, ee("cvv")) : Ze($) || (ye.current = !1);
1040
1135
  },
1041
- className: ne(Ue, R && !k && "border-error-500"),
1042
- disabled: ve,
1136
+ className: Q(Xe, g && !W && "border-error-500"),
1137
+ disabled: _e,
1043
1138
  required: !0,
1044
1139
  "data-testid": "movmo-card-expiry-input"
1045
1140
  }
@@ -1047,29 +1142,48 @@ const Hr = () => {
1047
1142
  ] }),
1048
1143
  /* @__PURE__ */ a.jsxs("div", { className: "relative", children: [
1049
1144
  /* @__PURE__ */ a.jsx("span", { id: "movmo-card-cvv-label", className: "sr-only", children: "CVV" }),
1050
- /* @__PURE__ */ a.jsxs("div", { className: or, children: [
1051
- /* @__PURE__ */ a.jsx(
1052
- "div",
1053
- {
1054
- id: "movmo-card-cvv",
1055
- "aria-labelledby": "movmo-card-cvv-label",
1056
- className: "flex-1",
1057
- "data-testid": "movmo-card-cvv-mount"
1058
- }
1059
- ),
1060
- /* @__PURE__ */ a.jsx(
1061
- "button",
1062
- {
1063
- type: "button",
1064
- "aria-label": "CVV help",
1065
- tabIndex: -1,
1066
- className: "flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full border border-grayWarm-300 text-xs text-grayWarm-500",
1067
- title: Y === "american_express" ? "The 4 numbers on the front of your card." : "The 3 numbers on the back of your card.",
1068
- "data-testid": "movmo-cvv-help",
1069
- children: "?"
1070
- }
1071
- )
1072
- ] })
1145
+ /* @__PURE__ */ a.jsxs(
1146
+ "div",
1147
+ {
1148
+ className: Q(
1149
+ hr,
1150
+ z.cvv ? yr : vr
1151
+ ),
1152
+ children: [
1153
+ /* @__PURE__ */ a.jsxs("div", { className: "relative h-full flex-1", children: [
1154
+ /* @__PURE__ */ a.jsx(
1155
+ "div",
1156
+ {
1157
+ id: "movmo-card-cvv",
1158
+ "aria-labelledby": "movmo-card-cvv-label",
1159
+ "aria-busy": d !== "ready",
1160
+ className: "absolute inset-0",
1161
+ "data-testid": "movmo-card-cvv-mount"
1162
+ }
1163
+ ),
1164
+ d !== "ready" ? /* @__PURE__ */ a.jsx(
1165
+ "div",
1166
+ {
1167
+ "aria-hidden": "true",
1168
+ className: "pointer-events-none absolute inset-y-2 left-0 right-2 animate-pulse rounded bg-grayWarm-200"
1169
+ }
1170
+ ) : null
1171
+ ] }),
1172
+ /* @__PURE__ */ a.jsx(
1173
+ "button",
1174
+ {
1175
+ type: "button",
1176
+ "aria-label": "CVV help",
1177
+ tabIndex: -1,
1178
+ className: "flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full border border-grayWarm-300 text-xs text-grayWarm-500",
1179
+ title: X === "american_express" ? "The 4 numbers on the front of your card." : "The 3 numbers on the back of your card.",
1180
+ "data-testid": "movmo-cvv-help",
1181
+ children: "?"
1182
+ }
1183
+ )
1184
+ ]
1185
+ }
1186
+ )
1073
1187
  ] }),
1074
1188
  /* @__PURE__ */ a.jsxs("div", { children: [
1075
1189
  /* @__PURE__ */ a.jsx("label", { htmlFor: "movmo-card-zip", className: "sr-only", children: "ZIP code" }),
@@ -1077,19 +1191,19 @@ const Hr = () => {
1077
1191
  "input",
1078
1192
  {
1079
1193
  id: "movmo-card-zip",
1080
- ref: pe,
1194
+ ref: fe,
1081
1195
  type: "text",
1082
1196
  inputMode: "numeric",
1083
1197
  autoComplete: "postal-code",
1084
1198
  placeholder: "ZIP code",
1085
- value: O,
1086
- onChange: (P) => {
1087
- var E;
1088
- const c = at(P.target.value);
1089
- C(c), Ye(c) && !me.current ? (me.current = !0, (E = he.current) == null || E.focus()) : Ye(c) || (me.current = !1);
1199
+ value: G,
1200
+ onChange: (b) => {
1201
+ var K;
1202
+ const $ = lt(b.target.value);
1203
+ ue($), Qe($) && !we.current ? (we.current = !0, (K = je.current) == null || K.focus()) : Qe($) || (we.current = !1);
1090
1204
  },
1091
- className: ne(Ue, O && !le && "border-error-500"),
1092
- disabled: ve,
1205
+ className: Q(Xe, G && !me && "border-error-500"),
1206
+ disabled: _e,
1093
1207
  required: !0,
1094
1208
  "data-testid": "movmo-card-zip-input"
1095
1209
  }
@@ -1102,112 +1216,118 @@ const Hr = () => {
1102
1216
  "input",
1103
1217
  {
1104
1218
  id: "movmo-card-cardholder-name",
1105
- ref: he,
1219
+ ref: je,
1106
1220
  type: "text",
1107
1221
  autoComplete: "cc-name",
1108
1222
  placeholder: "Cardholder name",
1109
- value: _,
1110
- onChange: (P) => D(P.target.value),
1111
- className: Ue,
1112
- disabled: ve,
1223
+ value: k,
1224
+ onChange: (b) => J(b.target.value),
1225
+ className: Xe,
1226
+ disabled: _e,
1113
1227
  required: !0,
1114
1228
  "data-testid": "movmo-card-cardholder-name-input"
1115
1229
  }
1116
1230
  )
1117
1231
  ] }),
1118
- ye ? /* @__PURE__ */ a.jsx(
1119
- "p",
1120
- {
1121
- role: "alert",
1122
- className: "rounded-md bg-error-50 px-3 py-2 text-sm text-error-700",
1123
- "data-testid": "movmo-card-error",
1124
- children: ye
1125
- }
1126
- ) : null,
1127
- !y && !g ? /* @__PURE__ */ a.jsx(
1232
+ !p && !R ? /* @__PURE__ */ a.jsx(
1128
1233
  "button",
1129
1234
  {
1130
1235
  type: "submit",
1131
- disabled: !Q,
1132
- className: ne(
1236
+ disabled: !oe,
1237
+ className: Q(
1133
1238
  "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",
1134
1239
  "disabled:cursor-not-allowed disabled:bg-grayWarm-300 disabled:text-grayWarm-500"
1135
1240
  ),
1136
1241
  "data-testid": "movmo-card-save",
1137
- children: ae ? "Saving…" : U === "loading" ? "Loading…" : "Save card"
1242
+ children: H ? "Saving…" : d === "loading" ? "Loading…" : "Save card"
1138
1243
  }
1139
- ) : ae ? /* @__PURE__ */ a.jsx("p", { className: "text-center text-sm text-grayWarm-500", "data-testid": "movmo-card-autosaving", children: "Saving card…" }) : null
1244
+ ) : H && p ? (
1245
+ // In autoSave mode (empty-state inline form, no Save button at all),
1246
+ // surface the in-flight state as inline text. The modal flow uses a
1247
+ // spinner inside the modal-footer Save button instead — see
1248
+ // AddPaymentMethodModal.isSaving.
1249
+ /* @__PURE__ */ a.jsx(
1250
+ "p",
1251
+ {
1252
+ className: "text-center text-sm text-grayWarm-500",
1253
+ "aria-live": "polite",
1254
+ "data-testid": "movmo-card-autosaving",
1255
+ children: "Saving card…"
1256
+ }
1257
+ )
1258
+ ) : null
1140
1259
  ]
1141
1260
  }
1142
1261
  );
1143
1262
  };
1144
- vr.displayName = "MovmoCardForm";
1145
- const nt = (r) => {
1146
- const [t, s] = S("idle"), [o, l] = S(null);
1147
- return { deletePaymentMethod: B(
1148
- async (d) => {
1149
- s("pending"), l(null);
1263
+ Cr.displayName = "MovmoCardForm";
1264
+ const ct = (r) => {
1265
+ const [t, n] = O("idle"), [o, l] = O(null);
1266
+ return { deletePaymentMethod: Z(
1267
+ async (m) => {
1268
+ n("pending"), l(null);
1150
1269
  try {
1151
- await Kr(r, d), s("idle");
1152
- } catch (v) {
1153
- const y = v instanceof Error ? v.message : "Failed to delete payment method.";
1154
- throw l(y), s("error"), v;
1270
+ await Xr(r, m), n("idle");
1271
+ } catch (y) {
1272
+ const p = y instanceof Error ? y.message : "Failed to delete payment method.";
1273
+ throw l(p), n("error"), y;
1155
1274
  }
1156
1275
  },
1157
1276
  [r]
1158
1277
  ), status: t, error: o };
1159
- }, st = (r) => {
1160
- const [t, s] = S("idle"), [o, l] = S(null);
1161
- return { setDefault: B(
1162
- async (d) => {
1163
- s("pending"), l(null);
1278
+ }, dt = (r) => {
1279
+ const [t, n] = O("idle"), [o, l] = O(null);
1280
+ return { setDefault: Z(
1281
+ async (m) => {
1282
+ n("pending"), l(null);
1164
1283
  try {
1165
- await qr(r, d, { isDefault: !0 }), s("idle");
1166
- } catch (v) {
1167
- const y = v instanceof Error ? v.message : "Failed to set default payment method.";
1168
- throw l(y), s("error"), v;
1284
+ await Zr(r, m, { isDefault: !0 }), n("idle");
1285
+ } catch (y) {
1286
+ const p = y instanceof Error ? y.message : "Failed to set default payment method.";
1287
+ throw l(p), n("error"), y;
1169
1288
  }
1170
1289
  },
1171
1290
  [r]
1172
1291
  ), status: t, error: o };
1173
- }, ot = (r) => {
1174
- const [t, s] = S([]), [o, l] = S("idle"), [f, d] = S(null), [v, y] = S(0), T = q(null);
1175
- X(() => {
1176
- var F;
1177
- (F = T.current) == null || F.abort();
1178
- const w = new AbortController();
1179
- return T.current = w, l("loading"), d(null), Br(r).then((_) => {
1180
- w.signal.aborted || (s(_), l("ready"));
1181
- }).catch((_) => {
1182
- if (w.signal.aborted) return;
1183
- const D = _ instanceof Error ? _.message : "Failed to fetch payment methods.";
1184
- d(D), l("error");
1292
+ }, ut = (r) => {
1293
+ const [t, n] = O([]), [o, l] = O("idle"), [c, m] = O(null), [y, p] = O(0), D = Y(null);
1294
+ B(() => {
1295
+ var v;
1296
+ (v = D.current) == null || v.abort();
1297
+ const h = new AbortController();
1298
+ return D.current = h, l("loading"), m(null), Jr(r, h.signal).then((E) => {
1299
+ h.signal.aborted || (n(E), l("ready"));
1300
+ }).catch((E) => {
1301
+ if (h.signal.aborted || E instanceof DOMException && E.name === "AbortError") return;
1302
+ const A = E instanceof Error ? E.message : "Failed to fetch payment methods.";
1303
+ m(A), l("error");
1185
1304
  }), () => {
1186
- w.abort();
1305
+ h.abort();
1187
1306
  };
1188
- }, [r, v]);
1189
- const g = B(() => {
1190
- y((w) => w + 1);
1307
+ }, [r, y]);
1308
+ const R = Z(() => {
1309
+ p((h) => h + 1);
1191
1310
  }, []);
1192
- return { items: t, status: o, error: f, refetch: g };
1193
- }, it = ({
1311
+ return { items: t, status: o, error: c, refetch: R };
1312
+ }, ft = ({
1194
1313
  open: r,
1195
1314
  onClose: t,
1196
- formId: s,
1315
+ formId: n,
1197
1316
  saveDisabled: o,
1198
1317
  saveLabel: l = "Save",
1199
- children: f
1200
- }) => (X(() => {
1318
+ isSaving: c = !1,
1319
+ children: m
1320
+ }) => (B(() => {
1201
1321
  if (!r) return;
1202
- const d = (v) => {
1203
- v.key === "Escape" && t();
1322
+ const y = (p) => {
1323
+ p.key === "Escape" && t();
1204
1324
  };
1205
- return document.addEventListener("keydown", d), () => document.removeEventListener("keydown", d);
1206
- }, [r, t]), X(() => {
1325
+ return document.addEventListener("keydown", y), () => document.removeEventListener("keydown", y);
1326
+ }, [r, t]), B(() => {
1207
1327
  if (!r) return;
1208
- const d = document.body.style.overflow;
1328
+ const y = document.body.style.overflow;
1209
1329
  return document.body.style.overflow = "hidden", () => {
1210
- document.body.style.overflow = d;
1330
+ document.body.style.overflow = y;
1211
1331
  };
1212
1332
  }, [r]), r ? /* @__PURE__ */ a.jsx(
1213
1333
  "div",
@@ -1216,8 +1336,8 @@ const nt = (r) => {
1216
1336
  "aria-modal": "true",
1217
1337
  "aria-labelledby": "movmo-add-payment-title",
1218
1338
  className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",
1219
- onClick: (d) => {
1220
- d.target === d.currentTarget && t();
1339
+ onClick: (y) => {
1340
+ y.target === y.currentTarget && t();
1221
1341
  },
1222
1342
  "data-testid": "add-payment-method-modal",
1223
1343
  children: /* @__PURE__ */ a.jsxs("div", { className: "flex max-h-full w-full max-w-md flex-col rounded-xl bg-white shadow-2xl", children: [
@@ -1228,15 +1348,16 @@ const nt = (r) => {
1228
1348
  type: "button",
1229
1349
  onClick: t,
1230
1350
  "aria-label": "Close add-payment dialog",
1231
- className: "flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border border-grayWarm-200 text-grayWarm-700 hover:bg-grayWarm-100",
1351
+ 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",
1232
1352
  "data-testid": "add-payment-method-close",
1233
- children: /* @__PURE__ */ a.jsx("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", children: /* @__PURE__ */ a.jsx(
1353
+ children: /* @__PURE__ */ a.jsx("svg", { viewBox: "0 0 20 20", width: "20", height: "20", "aria-hidden": "true", children: /* @__PURE__ */ a.jsx(
1234
1354
  "path",
1235
1355
  {
1236
- d: "M3 3L13 13M13 3L3 13",
1356
+ d: "M5 5L15 15M15 5L5 15",
1237
1357
  stroke: "currentColor",
1238
- strokeWidth: "1.75",
1239
- strokeLinecap: "round"
1358
+ strokeWidth: "1.67",
1359
+ strokeLinecap: "round",
1360
+ strokeLinejoin: "round"
1240
1361
  }
1241
1362
  ) })
1242
1363
  }
@@ -1249,9 +1370,9 @@ const nt = (r) => {
1249
1370
  children: "Add payment method"
1250
1371
  }
1251
1372
  ),
1252
- /* @__PURE__ */ a.jsx("span", { "aria-hidden": "true", className: "h-8 w-8 flex-shrink-0" })
1373
+ /* @__PURE__ */ a.jsx("span", { "aria-hidden": "true", className: "h-9 w-9 flex-shrink-0" })
1253
1374
  ] }),
1254
- /* @__PURE__ */ a.jsx("div", { className: "flex-1 overflow-y-auto p-4", children: f }),
1375
+ /* @__PURE__ */ a.jsx("div", { className: "flex-1 overflow-y-auto p-4", children: m }),
1255
1376
  /* @__PURE__ */ a.jsxs("div", { className: "flex gap-3 border-t border-grayWarm-200 p-4", children: [
1256
1377
  /* @__PURE__ */ a.jsx(
1257
1378
  "button",
@@ -1267,54 +1388,123 @@ const nt = (r) => {
1267
1388
  "button",
1268
1389
  {
1269
1390
  type: "submit",
1270
- form: s,
1271
- disabled: o,
1272
- className: ne(
1273
- "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 hover:bg-brand-600",
1274
- "disabled:cursor-not-allowed disabled:bg-grayWarm-300 disabled:text-grayWarm-500"
1391
+ form: n,
1392
+ disabled: c ? !1 : o,
1393
+ "aria-disabled": c || o,
1394
+ "aria-busy": c,
1395
+ className: Q(
1396
+ "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",
1397
+ c ? "cursor-not-allowed opacity-90 pointer-events-none" : "hover:bg-brand-600 disabled:cursor-not-allowed disabled:bg-grayWarm-300 disabled:text-grayWarm-500"
1275
1398
  ),
1276
1399
  "data-testid": "add-payment-method-save",
1277
- children: l
1400
+ children: c ? /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
1401
+ /* @__PURE__ */ a.jsxs(
1402
+ "svg",
1403
+ {
1404
+ className: "h-[18px] w-[18px] animate-spin",
1405
+ viewBox: "0 0 24 24",
1406
+ fill: "none",
1407
+ "aria-hidden": "true",
1408
+ children: [
1409
+ /* @__PURE__ */ a.jsx(
1410
+ "circle",
1411
+ {
1412
+ cx: "12",
1413
+ cy: "12",
1414
+ r: "10",
1415
+ stroke: "currentColor",
1416
+ strokeWidth: "3",
1417
+ strokeOpacity: "0.25"
1418
+ }
1419
+ ),
1420
+ /* @__PURE__ */ a.jsx(
1421
+ "path",
1422
+ {
1423
+ d: "M22 12a10 10 0 0 1-10 10",
1424
+ stroke: "currentColor",
1425
+ strokeWidth: "3",
1426
+ strokeLinecap: "round"
1427
+ }
1428
+ )
1429
+ ]
1430
+ }
1431
+ ),
1432
+ /* @__PURE__ */ a.jsx("span", { className: "sr-only", children: "Saving card" })
1433
+ ] }) : l
1278
1434
  }
1279
1435
  )
1280
1436
  ] })
1281
1437
  ] })
1282
1438
  }
1283
- ) : null), lt = (r, t, s = /* @__PURE__ */ new Date()) => t < s.getFullYear() || t === s.getFullYear() && r < s.getMonth() + 1, ir = (r) => {
1439
+ ) : null), mt = (r) => {
1440
+ if (!r) return "Card";
1441
+ const t = r.toLowerCase();
1442
+ return t === "amex" ? "Amex" : t.charAt(0).toUpperCase() + t.slice(1);
1443
+ }, pt = ({
1444
+ method: r,
1445
+ trailing: t,
1446
+ onClick: n,
1447
+ cardLabelFormat: o = "branded",
1448
+ className: l
1449
+ }) => /* @__PURE__ */ a.jsxs(
1450
+ "div",
1451
+ {
1452
+ className: Q("flex items-center gap-3", n && "cursor-pointer", l),
1453
+ onClick: n,
1454
+ role: n ? "button" : void 0,
1455
+ tabIndex: n ? 0 : void 0,
1456
+ onKeyDown: n ? (c) => {
1457
+ (c.key === "Enter" || c.key === " ") && (c.preventDefault(), n());
1458
+ } : void 0,
1459
+ "data-testid": `payment-method-preview-${r.id}`,
1460
+ children: [
1461
+ /* @__PURE__ */ a.jsx(Ne, { brand: r.brand, width: 34, className: "flex-shrink-0" }),
1462
+ /* @__PURE__ */ a.jsx("span", { className: "flex-1 text-lg font-semibold text-grayWarm-950", children: o === "masked" ? `•••• ${r.last4}` : `${mt(r.brand)} ${r.last4}` }),
1463
+ t
1464
+ ]
1465
+ }
1466
+ ), ht = (r, t, n = /* @__PURE__ */ new Date()) => t < n.getFullYear() || t === n.getFullYear() && r < n.getMonth() + 1, br = (r) => {
1467
+ if (!r) return "Card";
1284
1468
  const t = r.toLowerCase();
1285
- return t === "amex" ? "Amex" : t ? t.charAt(0).toUpperCase() + t.slice(1) : "Card";
1286
- }, ct = (r, t) => `${String(r).padStart(2, "0")}/${t}`, dt = ({
1469
+ return t === "amex" ? "Amex" : t.charAt(0).toUpperCase() + t.slice(1);
1470
+ }, yt = (r, t) => `${String(r).padStart(2, "0")}/${t}`, vt = ({
1287
1471
  method: r,
1288
1472
  selectable: t,
1289
- selected: s,
1473
+ selected: n,
1290
1474
  onSelect: o,
1291
1475
  onSetDefault: l,
1292
- onRemove: f,
1293
- disabled: d,
1294
- showDefaultBadge: v,
1295
- hideSetDefaultMenuItem: y
1476
+ onRemove: c,
1477
+ disabled: m,
1478
+ showDefaultBadge: y,
1479
+ hideSetDefaultMenuItem: p,
1480
+ cardLabelFormat: D = "branded"
1296
1481
  }) => {
1297
- const [T, g] = S(!1), w = q(null), F = lt(r.expMonth, r.expYear);
1298
- X(() => {
1299
- if (!T) return;
1300
- const D = (R) => {
1301
- var G;
1302
- (G = w.current) != null && G.contains(R.target) || g(!1);
1482
+ const [R, h] = O(!1), v = Y(null), E = ht(r.expMonth, r.expYear);
1483
+ B(() => {
1484
+ if (!R) return;
1485
+ const k = (J) => {
1486
+ var g;
1487
+ (g = v.current) != null && g.contains(J.target) || h(!1);
1303
1488
  };
1304
- return document.addEventListener("mousedown", D), () => document.removeEventListener("mousedown", D);
1305
- }, [T]);
1306
- const _ = () => {
1307
- t && o && !d && o(r);
1489
+ return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
1490
+ }, [R]);
1491
+ const A = () => {
1492
+ t && o && !m && o(r);
1308
1493
  };
1309
1494
  return /* @__PURE__ */ a.jsxs(
1310
1495
  "div",
1311
1496
  {
1312
- className: ne(
1313
- "flex items-center gap-3 rounded-lg border px-3 py-3 transition-colors",
1314
- t && !d && "cursor-pointer",
1315
- s ? "border-grayWarm-950 shadow-[0_0_0_1px_#1c1917]" : "border-grayWarm-200 hover:border-grayWarm-300"
1497
+ className: Q(
1498
+ // items-start + per-element mt offsets so the radio, brand icon, and
1499
+ // label all read as one horizontal line, with the Exp text directly
1500
+ // below the label in the same column. Matches main's flights-ui +
1501
+ // accounts-ui row layout (both use items-start).
1502
+ "flex items-start gap-3 transition-colors",
1503
+ t ? "rounded-lg border px-3 py-3" : "py-4",
1504
+ t && !m && "cursor-pointer",
1505
+ t && (n ? "border-grayWarm-950 shadow-[0_0_0_1px_#1c1917]" : "border-grayWarm-200 hover:border-grayWarm-300")
1316
1506
  ),
1317
- onClick: _,
1507
+ onClick: A,
1318
1508
  "data-testid": `payment-method-row-${r.id}`,
1319
1509
  children: [
1320
1510
  t ? /* @__PURE__ */ a.jsx(
@@ -1322,81 +1512,104 @@ const nt = (r) => {
1322
1512
  {
1323
1513
  type: "radio",
1324
1514
  name: "movmo-payment-method",
1325
- checked: s,
1515
+ checked: n,
1326
1516
  onChange: () => o == null ? void 0 : o(r),
1327
- onClick: (D) => D.stopPropagation(),
1328
- "aria-label": `Select ${ir(r.brand)} ending ${r.last4}`,
1329
- className: "h-4 w-4 cursor-pointer accent-grayWarm-950",
1330
- disabled: d
1517
+ onClick: (k) => k.stopPropagation(),
1518
+ "aria-label": `Select ${br(r.brand)} ending ${r.last4}`,
1519
+ 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",
1520
+ disabled: m
1331
1521
  }
1332
1522
  ) : null,
1333
- /* @__PURE__ */ a.jsx(be, { brand: r.brand, className: "flex-shrink-0" }),
1523
+ /* @__PURE__ */ a.jsx(Ne, { brand: r.brand, className: "flex-shrink-0" }),
1334
1524
  /* @__PURE__ */ a.jsxs("div", { className: "min-w-0 flex-1", children: [
1335
1525
  /* @__PURE__ */ a.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
1336
- /* @__PURE__ */ a.jsxs("span", { className: "text-base font-semibold text-grayWarm-900", children: [
1337
- ir(r.brand),
1338
- " ••••",
1339
- r.last4
1340
- ] }),
1341
- v && r.isDefault ? /* @__PURE__ */ a.jsx(
1526
+ /* @__PURE__ */ a.jsx("span", { className: "text-lg font-semibold text-grayWarm-950", children: D === "masked" ? `•••• ${r.last4}` : `${br(r.brand)} ${r.last4}` }),
1527
+ y && r.isDefault ? /* @__PURE__ */ a.jsx(
1342
1528
  "span",
1343
1529
  {
1344
- className: "inline-flex items-center rounded-full bg-success-50 px-2 py-0.5 text-xs font-medium text-success-700",
1530
+ className: "inline-flex items-center rounded-full bg-success-50 px-2 py-0.5 text-xs font-semibold text-success-700",
1345
1531
  "data-testid": `badge-default-${r.id}`,
1346
1532
  children: "Default"
1347
1533
  }
1348
1534
  ) : null,
1349
- F ? /* @__PURE__ */ a.jsx(
1535
+ E ? /* @__PURE__ */ a.jsx(
1350
1536
  "span",
1351
1537
  {
1352
- className: "inline-flex items-center rounded-full bg-error-50 px-2 py-0.5 text-xs font-medium text-error-700",
1538
+ className: "inline-flex items-center rounded-full bg-error-50 px-2 py-0.5 text-xs font-semibold text-error-700",
1353
1539
  "data-testid": `badge-expired-${r.id}`,
1354
1540
  children: "Expired"
1355
1541
  }
1356
1542
  ) : null
1357
1543
  ] }),
1358
- /* @__PURE__ */ a.jsxs("div", { className: ne("text-sm", F ? "text-grayWarm-400" : "text-grayWarm-600"), children: [
1544
+ /* @__PURE__ */ a.jsxs("div", { className: Q("text-base", E ? "text-grayWarm-400" : "text-grayWarm-600"), children: [
1359
1545
  "Exp. ",
1360
- ct(r.expMonth, r.expYear)
1546
+ yt(r.expMonth, r.expYear)
1361
1547
  ] })
1362
1548
  ] }),
1363
- /* @__PURE__ */ a.jsxs("div", { className: "relative flex-shrink-0", ref: w, children: [
1549
+ /* @__PURE__ */ a.jsxs("div", { className: "relative flex-shrink-0", ref: v, children: [
1364
1550
  /* @__PURE__ */ a.jsx(
1365
1551
  "button",
1366
1552
  {
1367
1553
  type: "button",
1368
1554
  "aria-label": `Open actions for card ending ${r.last4}`,
1369
1555
  "aria-haspopup": "menu",
1370
- "aria-expanded": T,
1556
+ "aria-expanded": R,
1371
1557
  className: "rounded-lg p-2 text-grayWarm-600 transition-colors hover:bg-grayWarm-100 disabled:cursor-not-allowed disabled:opacity-50",
1372
- disabled: d,
1373
- onClick: (D) => {
1374
- D.stopPropagation(), g((R) => !R);
1558
+ disabled: m,
1559
+ onClick: (k) => {
1560
+ k.stopPropagation(), h((J) => !J);
1375
1561
  },
1376
1562
  "data-testid": `menu-trigger-${r.id}`,
1377
- children: /* @__PURE__ */ a.jsxs("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", children: [
1378
- /* @__PURE__ */ a.jsx("circle", { cx: "3", cy: "8", r: "1.5", fill: "currentColor" }),
1379
- /* @__PURE__ */ a.jsx("circle", { cx: "8", cy: "8", r: "1.5", fill: "currentColor" }),
1380
- /* @__PURE__ */ a.jsx("circle", { cx: "13", cy: "8", r: "1.5", fill: "currentColor" })
1381
- ] })
1563
+ children: /* @__PURE__ */ a.jsx(
1564
+ "svg",
1565
+ {
1566
+ viewBox: "0 0 24 24",
1567
+ width: "20",
1568
+ height: "20",
1569
+ fill: "currentColor",
1570
+ "aria-hidden": "true",
1571
+ children: /* @__PURE__ */ 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" })
1572
+ }
1573
+ )
1382
1574
  }
1383
1575
  ),
1384
- T ? /* @__PURE__ */ a.jsxs(
1576
+ R ? /* @__PURE__ */ a.jsxs(
1385
1577
  "div",
1386
1578
  {
1387
1579
  role: "menu",
1388
- className: "absolute right-0 top-full z-10 mt-1 min-w-[160px] rounded-lg border border-grayWarm-200 bg-white py-1 shadow-lg",
1389
- onClick: (D) => D.stopPropagation(),
1580
+ className: Q(
1581
+ "absolute z-10 whitespace-nowrap rounded-lg border border-grayWarm-200 bg-white py-1 shadow-lg",
1582
+ // selectable mode (flights-ui): the row has a thick border that a
1583
+ // top-aligned dropdown would crash through. Float the menu ABOVE
1584
+ // the trigger button, horizontally centered, with a small tail
1585
+ // pointing back down at the dots. Matches main's flights-ui menu.
1586
+ // non-selectable mode (accounts-ui): no per-row border to
1587
+ // overlap; keep the menu below + right-aligned.
1588
+ t ? "bottom-full left-1/2 mb-2 -translate-x-1/2" : "right-0 top-full mt-1"
1589
+ ),
1590
+ onClick: (k) => k.stopPropagation(),
1390
1591
  "data-testid": `menu-${r.id}`,
1391
1592
  children: [
1392
- !r.isDefault && !y ? /* @__PURE__ */ a.jsx(
1593
+ t ? (
1594
+ // Tail: 8px square rotated 45° so its bottom-right corner
1595
+ // becomes a downward-pointing tip. Bottom + right borders of
1596
+ // the square form the menu's continuous border.
1597
+ /* @__PURE__ */ a.jsx(
1598
+ "span",
1599
+ {
1600
+ "aria-hidden": "true",
1601
+ 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"
1602
+ }
1603
+ )
1604
+ ) : null,
1605
+ !r.isDefault && !p ? /* @__PURE__ */ a.jsx(
1393
1606
  "button",
1394
1607
  {
1395
1608
  type: "button",
1396
1609
  role: "menuitem",
1397
- className: "block w-full px-4 py-2 text-left text-sm text-grayWarm-700 hover:bg-grayWarm-100",
1610
+ className: "block w-full px-4 py-1 text-left text-md font-semibold text-grayWarm-950 hover:text-grayWarm-700",
1398
1611
  onClick: () => {
1399
- g(!1), l(r);
1612
+ h(!1), l(r);
1400
1613
  },
1401
1614
  "data-testid": `menu-set-default-${r.id}`,
1402
1615
  children: "Set as default"
@@ -1407,12 +1620,12 @@ const nt = (r) => {
1407
1620
  {
1408
1621
  type: "button",
1409
1622
  role: "menuitem",
1410
- className: "block w-full px-4 py-2 text-left text-sm text-error-700 hover:bg-error-50",
1623
+ className: "block w-full px-4 py-1 text-left text-md font-semibold text-error-700 hover:text-error-500",
1411
1624
  onClick: () => {
1412
- g(!1), f(r);
1625
+ h(!1), c(r);
1413
1626
  },
1414
1627
  "data-testid": `menu-remove-${r.id}`,
1415
- children: "Remove"
1628
+ children: "Delete"
1416
1629
  }
1417
1630
  )
1418
1631
  ]
@@ -1422,19 +1635,19 @@ const nt = (r) => {
1422
1635
  ]
1423
1636
  }
1424
1637
  );
1425
- }, ut = (r) => `${Fe().iconCdnBaseUrl}/website/assets/icons/payments/${r}.svg`, Ve = ({ slug: r, alt: t }) => /* @__PURE__ */ a.jsx(
1638
+ }, bt = (r) => `${We().iconCdnBaseUrl}/website/assets/icons/payments/${r}.svg`, er = ({ slug: r, alt: t }) => /* @__PURE__ */ a.jsx(
1426
1639
  "img",
1427
1640
  {
1428
- src: ut(r),
1641
+ src: bt(r),
1429
1642
  alt: t,
1430
1643
  height: 20,
1431
1644
  loading: "lazy",
1432
1645
  style: { height: 20, width: "auto" }
1433
1646
  }
1434
- ), Oe = ({
1647
+ ), Be = ({
1435
1648
  type: r,
1436
1649
  label: t,
1437
- iconNode: s
1650
+ iconNode: n
1438
1651
  }) => (
1439
1652
  // Alt payment types are visible + clickable but don't yet do anything —
1440
1653
  // the click is intentionally a no-op so the row looks identical to the
@@ -1459,23 +1672,23 @@ const nt = (r) => {
1459
1672
  ),
1460
1673
  /* @__PURE__ */ a.jsxs("span", { className: "flex flex-1 items-center gap-2 text-sm font-semibold text-grayWarm-900", children: [
1461
1674
  t,
1462
- s
1675
+ n
1463
1676
  ] })
1464
1677
  ]
1465
1678
  }
1466
1679
  )
1467
- ), lr = ({
1680
+ ), xr = ({
1468
1681
  selected: r,
1469
1682
  onSelect: t,
1470
- creditCardBody: s,
1683
+ creditCardBody: n,
1471
1684
  className: o
1472
1685
  }) => {
1473
1686
  const l = r === "credit_card";
1474
- return /* @__PURE__ */ a.jsxs("div", { className: ne("flex w-full flex-col gap-3", o), children: [
1687
+ return /* @__PURE__ */ a.jsxs("div", { className: Q("flex w-full flex-col gap-3", o), children: [
1475
1688
  /* @__PURE__ */ a.jsxs(
1476
1689
  "label",
1477
1690
  {
1478
- className: ne(
1691
+ className: Q(
1479
1692
  "flex cursor-pointer flex-col gap-3 rounded-lg border px-4 py-3 transition-colors",
1480
1693
  l ? "border-grayWarm-900 shadow-[0_0_0_1px_#1c1917]" : "border-grayWarm-200"
1481
1694
  ),
@@ -1496,13 +1709,13 @@ const nt = (r) => {
1496
1709
  ),
1497
1710
  /* @__PURE__ */ a.jsx("span", { className: "flex-1 text-sm font-semibold text-grayWarm-900", children: "Credit card" }),
1498
1711
  /* @__PURE__ */ a.jsxs("div", { className: "flex items-center gap-1.5", children: [
1499
- /* @__PURE__ */ a.jsx(be, { brand: "mastercard", width: 28 }),
1500
- /* @__PURE__ */ a.jsx(be, { brand: "visa", width: 28 }),
1501
- /* @__PURE__ */ a.jsx(be, { brand: "amex", width: 28 }),
1502
- /* @__PURE__ */ a.jsx(be, { brand: "discover", width: 28 })
1712
+ /* @__PURE__ */ a.jsx(Ne, { brand: "mastercard", width: 28 }),
1713
+ /* @__PURE__ */ a.jsx(Ne, { brand: "visa", width: 28 }),
1714
+ /* @__PURE__ */ a.jsx(Ne, { brand: "amex", width: 28 }),
1715
+ /* @__PURE__ */ a.jsx(Ne, { brand: "discover", width: 28 })
1503
1716
  ] })
1504
1717
  ] }),
1505
- l ? /* @__PURE__ */ a.jsx("div", { "data-testid": "payment-type-credit_card-body", children: s }) : null
1718
+ l ? /* @__PURE__ */ a.jsx("div", { "data-testid": "payment-type-credit_card-body", children: n }) : null
1506
1719
  ]
1507
1720
  }
1508
1721
  ),
@@ -1515,31 +1728,31 @@ const nt = (r) => {
1515
1728
  }
1516
1729
  ) : null,
1517
1730
  /* @__PURE__ */ a.jsx(
1518
- Oe,
1731
+ Be,
1519
1732
  {
1520
1733
  type: "paypal",
1521
1734
  label: "PayPal",
1522
- iconNode: /* @__PURE__ */ a.jsx(Ve, { slug: "paypal", alt: "PayPal" })
1735
+ iconNode: /* @__PURE__ */ a.jsx(er, { slug: "paypal", alt: "PayPal" })
1523
1736
  }
1524
1737
  ),
1525
1738
  /* @__PURE__ */ a.jsx(
1526
- Oe,
1739
+ Be,
1527
1740
  {
1528
1741
  type: "googlepay",
1529
1742
  label: "GooglePay",
1530
- iconNode: /* @__PURE__ */ a.jsx(Ve, { slug: "google-pay", alt: "GooglePay" })
1743
+ iconNode: /* @__PURE__ */ a.jsx(er, { slug: "google-pay", alt: "GooglePay" })
1531
1744
  }
1532
1745
  ),
1533
1746
  /* @__PURE__ */ a.jsx(
1534
- Oe,
1747
+ Be,
1535
1748
  {
1536
1749
  type: "klarna",
1537
1750
  label: "Klarna",
1538
- iconNode: /* @__PURE__ */ a.jsx(Ve, { slug: "klarna", alt: "Klarna" })
1751
+ iconNode: /* @__PURE__ */ a.jsx(er, { slug: "klarna", alt: "Klarna" })
1539
1752
  }
1540
1753
  ),
1541
1754
  /* @__PURE__ */ a.jsx(
1542
- Oe,
1755
+ Be,
1543
1756
  {
1544
1757
  type: "ach",
1545
1758
  label: "Bank account (ACH)",
@@ -1547,143 +1760,190 @@ const nt = (r) => {
1547
1760
  }
1548
1761
  )
1549
1762
  ] });
1550
- }, cr = "movmo-add-payment-form", dr = (r) => {
1551
- const t = r.filter((o) => o.isDefault), s = r.filter((o) => !o.isDefault);
1552
- return [...t, ...s];
1553
- }, ur = () => /* @__PURE__ */ a.jsxs(
1763
+ }, gr = "movmo-add-payment-form", wr = (r) => {
1764
+ const t = r.filter((o) => o.isDefault), n = r.filter((o) => !o.isDefault);
1765
+ return [...t, ...n];
1766
+ }, jr = ({ withDefaultBadge: r = !1 }) => /* @__PURE__ */ a.jsxs(
1554
1767
  "div",
1555
1768
  {
1556
- className: "flex items-center gap-3 rounded-lg border border-grayWarm-200 px-3 py-3",
1769
+ className: "flex items-start justify-between py-4",
1557
1770
  "data-testid": "payment-method-skeleton",
1558
1771
  children: [
1559
- /* @__PURE__ */ a.jsx("div", { className: "h-8 w-[46px] flex-shrink-0 animate-pulse rounded bg-grayWarm-200" }),
1560
- /* @__PURE__ */ a.jsxs("div", { className: "flex-1 space-y-2", children: [
1561
- /* @__PURE__ */ a.jsx("div", { className: "h-4 w-32 animate-pulse rounded bg-grayWarm-200" }),
1562
- /* @__PURE__ */ a.jsx("div", { className: "h-3 w-20 animate-pulse rounded bg-grayWarm-200" })
1772
+ /* @__PURE__ */ a.jsxs("div", { className: "flex items-start gap-3", children: [
1773
+ /* @__PURE__ */ a.jsx("div", { className: "h-8 w-[46px] flex-shrink-0 animate-pulse rounded bg-grayWarm-200" }),
1774
+ /* @__PURE__ */ a.jsxs("div", { className: "space-y-2", children: [
1775
+ /* @__PURE__ */ a.jsxs("div", { className: "flex items-center gap-2", children: [
1776
+ /* @__PURE__ */ a.jsx("div", { className: "h-5 w-[120px] animate-pulse rounded bg-grayWarm-200" }),
1777
+ r ? /* @__PURE__ */ a.jsx("div", { className: "h-5 w-[56px] animate-pulse rounded-full bg-grayWarm-200" }) : null
1778
+ ] }),
1779
+ /* @__PURE__ */ a.jsx("div", { className: "h-4 w-[100px] animate-pulse rounded bg-grayWarm-200" })
1780
+ ] })
1563
1781
  ] }),
1564
- /* @__PURE__ */ a.jsx("div", { className: "h-8 w-8 animate-pulse rounded bg-grayWarm-200" })
1782
+ /* @__PURE__ */ a.jsx("div", { className: "h-5 w-5 flex-shrink-0 animate-pulse rounded-full bg-grayWarm-200" })
1565
1783
  ]
1566
1784
  }
1567
- ), ft = ({
1785
+ ), xt = ({
1568
1786
  userId: r,
1569
1787
  defaultCardholderName: t,
1570
- defaultCardholderFirstName: s,
1788
+ defaultCardholderFirstName: n,
1571
1789
  defaultCardholderLastName: o,
1572
1790
  selectedId: l,
1573
- onSelect: f,
1574
- onChange: d,
1575
- paymentTypeSelector: v = !0,
1576
- autoSaveFirstCard: y = !0,
1577
- selectionSetsDefault: T = !1,
1578
- showDefaultBadge: g = !0,
1579
- className: w
1791
+ onSelect: c,
1792
+ onChange: m,
1793
+ paymentTypeSelector: y = !0,
1794
+ autoSaveFirstCard: p = !0,
1795
+ selectionSetsDefault: D = !1,
1796
+ showDefaultBadge: R = !0,
1797
+ collapsible: h = !1,
1798
+ cardLabelFormat: v = "branded",
1799
+ className: E
1580
1800
  }) => {
1581
- const { items: F, status: _, error: D, refetch: R } = ot(r), { deletePaymentMethod: G, status: O } = nt(r), { setDefault: C, status: J } = st(r), [W, se] = S([]), [oe, A] = S(null), [x, b] = S(!1), [I, U] = S(null), [ie, z] = S(!1), [N, Y] = S(null), ue = B(() => {
1582
- b(!1), U(null), Y(null);
1583
- }, []), V = t ?? ([s, o].filter(Boolean).join(" ") || void 0);
1584
- X(() => {
1585
- _ === "ready" && se(dr(F));
1586
- }, [F, _]);
1587
- const k = B(
1588
- (c) => {
1589
- se((E) => {
1590
- const $ = typeof c == "function" ? c(E) : c, H = dr($);
1591
- return d == null || d(H), H;
1801
+ const { items: A, status: k, error: J, refetch: g } = ut(r), { deletePaymentMethod: P, status: G } = ct(r), { setDefault: ue, status: te } = dt(r), [j, se] = O([]), [he, U] = O(null), [T, d] = O(!1), [S, _] = O(null), [M, X] = O(!1), [z, ee] = O(!1), [V, N] = O(null), [W, me] = O(!1), ye = Y(!1), ge = Z(() => {
1802
+ d(!1), _(null), N(null);
1803
+ }, []), we = t ?? ([n, o].filter(Boolean).join(" ") || void 0);
1804
+ B(() => {
1805
+ k === "ready" && se(wr(A));
1806
+ }, [A, k]), B(() => {
1807
+ if (!c || ye.current || k !== "ready" || j.length === 0 || l) return;
1808
+ ye.current = !0;
1809
+ const u = j.find((ce) => ce.isDefault) ?? j[0];
1810
+ c(u);
1811
+ }, [c, k, j, l]);
1812
+ const fe = Z(
1813
+ (u) => {
1814
+ se((ce) => {
1815
+ const ae = typeof u == "function" ? u(ce) : u, q = wr(ae);
1816
+ return queueMicrotask(() => m == null ? void 0 : m(q)), q;
1592
1817
  });
1593
1818
  },
1594
- [d]
1595
- ), le = O === "pending" || J === "pending", ce = B(
1596
- async (c) => {
1597
- const E = W;
1598
- A(null), k(($) => $.map((H) => ({ ...H, isDefault: H.id === c.id })));
1819
+ [m]
1820
+ ), je = G === "pending" || te === "pending", ve = Z(
1821
+ async (u) => {
1822
+ const ce = j;
1823
+ U(null), fe((ae) => ae.map((q) => ({ ...q, isDefault: q.id === u.id })));
1599
1824
  try {
1600
- await C(c.id), R();
1601
- } catch ($) {
1602
- se(E), d == null || d(E);
1603
- const H = $ instanceof Error ? $.message : "Failed to set default payment method.";
1604
- A(H);
1825
+ await ue(u.id), g();
1826
+ } catch (ae) {
1827
+ se(ce), m == null || m(ce);
1828
+ const q = ae instanceof Error ? ae.message : "Failed to set default payment method.";
1829
+ U(q);
1605
1830
  }
1606
1831
  },
1607
- [W, k, C, R, d]
1608
- ), fe = B(
1609
- (c) => {
1610
- f == null || f(c), T && (c.isDefault || ce(c));
1832
+ [j, fe, ue, g, m]
1833
+ ), H = Z(
1834
+ (u) => {
1835
+ c == null || c(u), D && (u.isDefault || ve(u));
1611
1836
  },
1612
- [f, T, ce]
1613
- ), me = B(
1614
- async (c) => {
1615
- const E = W;
1616
- A(null), k(($) => $.filter((H) => H.id !== c.id));
1837
+ [c, D, ve]
1838
+ ), oe = Z(
1839
+ async (u) => {
1840
+ const ce = j;
1841
+ U(null);
1842
+ const ae = j.filter((xe) => xe.id !== u.id);
1843
+ fe(() => ae);
1844
+ const q = u.id === l && c ? ae.find((xe) => xe.isDefault) ?? ae[0] ?? null : null;
1845
+ q && H(q);
1846
+ const Le = !!q && D && q !== null && !q.isDefault;
1617
1847
  try {
1618
- await G(c.id), R();
1619
- } catch ($) {
1620
- se(E), d == null || d(E);
1621
- const H = $ instanceof Error ? $.message : "Failed to delete payment method.";
1622
- A(H);
1848
+ await P(u.id), Le || g();
1849
+ } catch (xe) {
1850
+ se(ce), m == null || m(ce);
1851
+ const Ve = xe instanceof Error ? xe.message : "Failed to delete payment method.";
1852
+ U(Ve);
1623
1853
  }
1624
1854
  },
1625
- [W, k, G, R, d]
1626
- ), pe = B(
1627
- (c) => {
1628
- U(null), b(!1), Y(null), k((E) => [c, ...E.filter(($) => $.id !== c.id)]), R();
1855
+ [
1856
+ j,
1857
+ fe,
1858
+ P,
1859
+ g,
1860
+ m,
1861
+ l,
1862
+ c,
1863
+ H,
1864
+ D
1865
+ ]
1866
+ ), ie = Z(
1867
+ (u) => {
1868
+ _(null), d(!1), N(null), fe((ae) => [u, ...ae.filter((q) => q.id !== u.id)]), H(u), !!c && D && !u.isDefault || g();
1629
1869
  },
1630
- [k, R]
1631
- ), he = B((c) => {
1632
- U(c);
1633
- }, []), Ee = _ === "ready" && W.length === 0, ae = typeof f == "function", Q = W.length === 0, ee = y && W.length === 0, re = B(
1634
- (c) => /* @__PURE__ */ a.jsx(
1635
- vr,
1870
+ [fe, g, H, c, D]
1871
+ ), be = Z((u) => {
1872
+ _(u);
1873
+ }, []), Ee = k === "ready" && j.length === 0, Re = typeof c == "function", _e = !Re && !h, le = j.length === 0, b = p && j.length === 0, $ = Z(
1874
+ (u) => /* @__PURE__ */ a.jsx(
1875
+ Cr,
1636
1876
  {
1637
1877
  userId: r,
1638
- isDefault: Q,
1639
- defaultCardholderName: V,
1640
- autoSave: !c && ee,
1641
- hideInternalSaveButton: c,
1642
- formId: c ? cr : void 0,
1643
- onCanSubmitChange: c ? z : void 0,
1644
- onSuccess: pe,
1645
- onError: he
1878
+ isDefault: le,
1879
+ defaultCardholderName: we,
1880
+ autoSave: !u && b,
1881
+ hideInternalSaveButton: u,
1882
+ formId: u ? gr : void 0,
1883
+ onCanSubmitChange: u ? X : void 0,
1884
+ onSavingChange: u ? ee : void 0,
1885
+ autoFocus: u ? "number" : void 0,
1886
+ onSuccess: ie,
1887
+ onError: be
1646
1888
  }
1647
1889
  ),
1648
- [r, Q, V, ee, pe, he]
1649
- ), de = Ce(() => re(!1), [re]), ye = Ce(() => re(!0), [re]), ve = Ce(() => v ? /* @__PURE__ */ a.jsx(
1650
- lr,
1890
+ [r, le, we, b, ie, be]
1891
+ ), K = Ue(() => $(!1), [$]), pe = Ue(() => $(!0), [$]), Ye = Ue(() => y ? /* @__PURE__ */ a.jsx(
1892
+ xr,
1651
1893
  {
1652
- selected: N,
1653
- onSelect: (c) => Y(c),
1654
- creditCardBody: de
1894
+ selected: V,
1895
+ onSelect: (u) => N(u),
1896
+ creditCardBody: K
1655
1897
  }
1656
- ) : de, [v, N, de]), P = Ce(() => v ? /* @__PURE__ */ a.jsx(
1657
- lr,
1898
+ ) : K, [y, V, K]), ze = Ue(() => y ? /* @__PURE__ */ a.jsx(
1899
+ xr,
1658
1900
  {
1659
- selected: N,
1660
- onSelect: (c) => Y(c),
1661
- creditCardBody: ye
1901
+ selected: V,
1902
+ onSelect: (u) => N(u),
1903
+ creditCardBody: pe
1662
1904
  }
1663
- ) : ye, [v, N, ye]);
1905
+ ) : pe, [y, V, pe]);
1664
1906
  return /* @__PURE__ */ a.jsxs(
1665
1907
  "div",
1666
1908
  {
1667
- className: ne("flex w-full flex-col gap-4", w),
1909
+ className: Q("flex w-full flex-col gap-4", E),
1668
1910
  "data-testid": "payment-methods-manager",
1669
1911
  children: [
1670
- _ === "loading" ? /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col gap-2", "data-testid": "payment-methods-loading", children: [
1671
- /* @__PURE__ */ a.jsx(ur, {}),
1672
- /* @__PURE__ */ a.jsx(ur, {})
1673
- ] }) : null,
1674
- _ === "error" ? /* @__PURE__ */ a.jsxs(
1912
+ k === "loading" && j.length === 0 ? (
1913
+ // Only show the skeleton on first load — during a silent refetch
1914
+ // (e.g. after set-default or delete optimistic mutations), the user
1915
+ // already sees the correct optimistic list and a skeleton flash
1916
+ // here would be jarring.
1917
+ /* @__PURE__ */ a.jsxs(
1918
+ "div",
1919
+ {
1920
+ className: Q(
1921
+ // Match the real-list shell so layout doesn't reflow when data
1922
+ // arrives. In selection mode the outer card is suppressed too.
1923
+ _e ? "flex flex-col divide-y divide-grayWarm-200 rounded-xl border border-grayWarm-200 px-4 md:px-6" : "flex flex-col gap-2"
1924
+ ),
1925
+ "data-testid": "payment-methods-loading",
1926
+ children: [
1927
+ /* @__PURE__ */ a.jsx(jr, { withDefaultBadge: !0 }),
1928
+ /* @__PURE__ */ a.jsx(jr, {})
1929
+ ]
1930
+ }
1931
+ )
1932
+ ) : null,
1933
+ k === "error" ? /* @__PURE__ */ a.jsxs(
1675
1934
  "div",
1676
1935
  {
1677
1936
  role: "alert",
1937
+ "aria-live": "polite",
1678
1938
  className: "flex items-center justify-between gap-3 rounded-md bg-error-50 p-3 text-sm text-error-700",
1679
1939
  "data-testid": "payment-methods-list-error",
1680
1940
  children: [
1681
- /* @__PURE__ */ a.jsx("span", { children: D ?? "Failed to load payment methods." }),
1941
+ /* @__PURE__ */ a.jsx("span", { children: J ?? "Failed to load payment methods." }),
1682
1942
  /* @__PURE__ */ a.jsx(
1683
1943
  "button",
1684
1944
  {
1685
1945
  type: "button",
1686
- onClick: R,
1946
+ onClick: g,
1687
1947
  className: "rounded-md border border-error-700 px-3 py-1 text-xs font-semibold text-error-700 hover:bg-error-50",
1688
1948
  children: "Retry"
1689
1949
  }
@@ -1691,62 +1951,136 @@ const nt = (r) => {
1691
1951
  ]
1692
1952
  }
1693
1953
  ) : null,
1694
- oe ? /* @__PURE__ */ a.jsx(
1954
+ he ? /* @__PURE__ */ a.jsx(
1695
1955
  "div",
1696
1956
  {
1697
1957
  role: "alert",
1958
+ "aria-live": "polite",
1698
1959
  className: "rounded-md bg-error-50 p-3 text-sm text-error-700",
1699
1960
  "data-testid": "payment-methods-mutation-error",
1700
- children: oe
1961
+ children: he
1701
1962
  }
1702
1963
  ) : null,
1703
- _ === "ready" && W.length > 0 ? /* @__PURE__ */ a.jsx("div", { className: "flex flex-col gap-2", children: W.map((c) => /* @__PURE__ */ a.jsx(
1704
- dt,
1964
+ h && j.length > 0 ? /* @__PURE__ */ a.jsx("div", { className: "border-t border-grayWarm-200 pt-4", children: /* @__PURE__ */ a.jsxs(
1965
+ "div",
1705
1966
  {
1706
- method: c,
1707
- selectable: ae,
1708
- selected: ae && c.id === l,
1709
- onSelect: fe,
1710
- onSetDefault: ce,
1711
- onRemove: me,
1712
- disabled: le,
1713
- showDefaultBadge: g,
1714
- hideSetDefaultMenuItem: T
1715
- },
1716
- c.id
1717
- )) }) : null,
1718
- Ee ? (
1719
- // Empty state: render the add-card body inline (per Figma 1536-21454).
1720
- /* @__PURE__ */ a.jsx("div", { "data-testid": "payment-methods-empty", children: ve })
1721
- ) : _ === "ready" ? /* @__PURE__ */ a.jsx(
1722
- "button",
1967
+ className: "flex items-center justify-between",
1968
+ "data-testid": W ? "payment-methods-drawer-header" : "payment-methods-collapsed-preview",
1969
+ children: [
1970
+ W ? /* @__PURE__ */ a.jsx("h3", { className: "text-md font-semibold text-grayWarm-950", children: "Payment methods" }) : /* @__PURE__ */ a.jsx(
1971
+ pt,
1972
+ {
1973
+ method: j.find((u) => u.id === l) ?? j.find((u) => u.isDefault) ?? j[0],
1974
+ cardLabelFormat: v,
1975
+ className: "flex-1"
1976
+ }
1977
+ ),
1978
+ /* @__PURE__ */ a.jsx(
1979
+ "button",
1980
+ {
1981
+ type: "button",
1982
+ "aria-label": W ? "Collapse payment methods" : "Expand payment methods",
1983
+ "aria-expanded": W,
1984
+ className: "bg-grayWarm-100 p-2 rounded-lg hover:bg-grayWarm-200 transition-colors",
1985
+ onClick: () => me((u) => !u),
1986
+ "data-testid": W ? "payment-methods-drawer-close" : "payment-methods-drawer-open",
1987
+ children: /* @__PURE__ */ a.jsx(
1988
+ "img",
1989
+ {
1990
+ src: `${We().iconCdnBaseUrl}/website/assets/icons/chevron-${W ? "up" : "down"}-double.svg`,
1991
+ alt: "",
1992
+ className: "w-5 h-5"
1993
+ }
1994
+ )
1995
+ }
1996
+ )
1997
+ ]
1998
+ }
1999
+ ) }) : null,
2000
+ j.length > 0 && (!h || W) ? /* @__PURE__ */ a.jsx(
2001
+ "div",
1723
2002
  {
1724
- type: "button",
1725
- onClick: () => {
1726
- U(null), Y(null), z(!1), b(!0);
1727
- },
1728
- 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",
1729
- "data-testid": "payment-methods-add-trigger",
1730
- children: "Add payment method"
2003
+ className: Q(
2004
+ "flex flex-col",
2005
+ // accounts-ui (non-selectable, non-collapsible): rounded outer card
2006
+ // with divide-y separators between rows.
2007
+ // flights-ui (selectable or collapsible): bare space-y-3 gap between
2008
+ // per-row bordered tiles; no outer card chrome.
2009
+ _e ? "rounded-xl border border-grayWarm-200 px-4 md:px-6 divide-y divide-grayWarm-200" : "space-y-3"
2010
+ ),
2011
+ children: j.map((u) => /* @__PURE__ */ a.jsx(
2012
+ vt,
2013
+ {
2014
+ method: u,
2015
+ selectable: Re,
2016
+ selected: Re && u.id === l,
2017
+ onSelect: H,
2018
+ onSetDefault: ve,
2019
+ onRemove: oe,
2020
+ disabled: je,
2021
+ showDefaultBadge: R,
2022
+ hideSetDefaultMenuItem: D,
2023
+ cardLabelFormat: v
2024
+ },
2025
+ u.id
2026
+ ))
1731
2027
  }
1732
2028
  ) : null,
2029
+ Ee ? (
2030
+ // Empty state: render the add-card body inline (per Figma 1536-21454).
2031
+ /* @__PURE__ */ a.jsx("div", { "data-testid": "payment-methods-empty", children: Ye })
2032
+ ) : j.length > 0 && (!h || W) ? (
2033
+ // Keep the Add button visible during silent refetches (status flips
2034
+ // back to 'loading' transiently after set-default / delete).
2035
+ // In collapsible mode only show the Add button when the drawer is open.
2036
+ /* @__PURE__ */ a.jsx(
2037
+ "button",
2038
+ {
2039
+ type: "button",
2040
+ onClick: () => {
2041
+ _(null), N(null), X(!1), d(!0);
2042
+ },
2043
+ onMouseEnter: () => {
2044
+ ar().catch(() => {
2045
+ });
2046
+ },
2047
+ onFocus: () => {
2048
+ ar().catch(() => {
2049
+ });
2050
+ },
2051
+ 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",
2052
+ "data-testid": "payment-methods-add-trigger",
2053
+ children: "Add payment method"
2054
+ }
2055
+ )
2056
+ ) : null,
1733
2057
  /* @__PURE__ */ a.jsxs(
1734
- it,
2058
+ ft,
1735
2059
  {
1736
- open: x,
1737
- onClose: ue,
1738
- formId: cr,
1739
- saveDisabled: !ie,
2060
+ open: T,
2061
+ onClose: ge,
2062
+ formId: gr,
2063
+ saveDisabled: !M,
2064
+ isSaving: z,
1740
2065
  children: [
1741
- P,
1742
- I ? /* @__PURE__ */ a.jsx(
1743
- "p",
1744
- {
1745
- role: "alert",
1746
- className: "mt-3 rounded-md bg-error-50 px-3 py-2 text-sm text-error-700",
1747
- "data-testid": "payment-methods-modal-error",
1748
- children: I
1749
- }
2066
+ ze,
2067
+ S ? (
2068
+ // Single source of truth for save-time errors (API failures + hook
2069
+ // init failures forwarded from MovmoCardForm.onError). MovmoCardForm
2070
+ // intentionally does NOT render its own banner — two role="alert"
2071
+ // nodes on the same string is a WCAG 4.1.3 violation (announced
2072
+ // twice). aria-live="polite" so SR users hear new errors but the
2073
+ // announcement doesn't interrupt their current input.
2074
+ /* @__PURE__ */ a.jsx(
2075
+ "p",
2076
+ {
2077
+ role: "alert",
2078
+ "aria-live": "polite",
2079
+ className: "mt-3 rounded-md bg-error-50 px-3 py-2 text-sm text-error-700",
2080
+ "data-testid": "payment-methods-modal-error",
2081
+ children: S
2082
+ }
2083
+ )
1750
2084
  ) : null
1751
2085
  ]
1752
2086
  }
@@ -1755,46 +2089,90 @@ const nt = (r) => {
1755
2089
  }
1756
2090
  );
1757
2091
  };
1758
- ft.displayName = "PaymentMethodsManager";
1759
- const mt = (r) => {
1760
- const t = r.toLowerCase();
1761
- return t === "amex" ? "Amex" : t ? t.charAt(0).toUpperCase() + t.slice(1) : "Card";
1762
- }, vt = ({
1763
- method: r,
1764
- trailing: t,
1765
- onClick: s,
1766
- className: o
1767
- }) => /* @__PURE__ */ a.jsxs(
1768
- "div",
1769
- {
1770
- className: ne("flex items-center gap-3 py-2", s && "cursor-pointer", o),
1771
- onClick: s,
1772
- role: s ? "button" : void 0,
1773
- tabIndex: s ? 0 : void 0,
1774
- onKeyDown: s ? (l) => {
1775
- (l.key === "Enter" || l.key === " ") && (l.preventDefault(), s());
1776
- } : void 0,
1777
- "data-testid": `payment-method-preview-${r.id}`,
1778
- children: [
1779
- /* @__PURE__ */ a.jsx(be, { brand: r.brand, className: "flex-shrink-0" }),
1780
- /* @__PURE__ */ a.jsxs("span", { className: "flex-1 text-base font-semibold text-grayWarm-900", children: [
1781
- mt(r.brand),
1782
- " ",
1783
- r.last4
1784
- ] }),
1785
- t
1786
- ]
2092
+ xt.displayName = "PaymentMethodsManager";
2093
+ const gt = "/v1/auth/", wt = "movmo_csrf_token", jt = (r) => {
2094
+ if (typeof document > "u") return null;
2095
+ const t = document.cookie ? document.cookie.split(";") : [];
2096
+ for (const n of t) {
2097
+ const o = n.trim();
2098
+ if (o.startsWith(r + "="))
2099
+ return decodeURIComponent(o.substring(r.length + 1));
1787
2100
  }
1788
- );
2101
+ return null;
2102
+ }, Et = (r) => typeof r == "string" ? r : r instanceof URL ? r.href : r.url, _t = () => {
2103
+ if (typeof globalThis < "u" && typeof globalThis.fetch == "function")
2104
+ return globalThis.fetch.bind(globalThis);
2105
+ throw new Error("@movmo_app/payments: no global fetch available in this environment");
2106
+ }, Nt = (r) => {
2107
+ const {
2108
+ refreshSession: t,
2109
+ onRefreshFailed: n,
2110
+ csrfCookieName: o = wt,
2111
+ extraHeaders: l,
2112
+ authPathFragment: c = gt,
2113
+ baseFetch: m = _t(),
2114
+ readCookie: y = jt
2115
+ } = r;
2116
+ let p = null;
2117
+ const D = () => {
2118
+ if (p) return p;
2119
+ const h = (async () => {
2120
+ await t();
2121
+ })();
2122
+ return p = h, h.finally(() => {
2123
+ p === h && (p = null);
2124
+ }).catch(() => {
2125
+ }), h;
2126
+ }, R = (h, v) => {
2127
+ const E = new Headers(v == null ? void 0 : v.headers), A = y(o);
2128
+ if (A && !E.has("X-CSRF-Token") && E.set("X-CSRF-Token", A), l) {
2129
+ const k = l(h, v);
2130
+ for (const [J, g] of Object.entries(k))
2131
+ E.has(J) || E.set(J, g);
2132
+ }
2133
+ return {
2134
+ ...v,
2135
+ headers: E,
2136
+ credentials: (v == null ? void 0 : v.credentials) ?? "include"
2137
+ };
2138
+ };
2139
+ return async function(v, E) {
2140
+ const A = await m(v, R(v, E));
2141
+ if (Et(v).includes(c) || A.status !== 401 && A.status !== 403)
2142
+ return A;
2143
+ try {
2144
+ await D();
2145
+ } catch (g) {
2146
+ try {
2147
+ n(g);
2148
+ } catch (P) {
2149
+ console.error(
2150
+ "@movmo_app/payments: onRefreshFailed callback threw — auth retry path is misconfigured",
2151
+ P
2152
+ );
2153
+ }
2154
+ return A;
2155
+ }
2156
+ try {
2157
+ return await m(v, R(v, E));
2158
+ } catch (g) {
2159
+ return console.error(
2160
+ "@movmo_app/payments: retry after token refresh failed — returning original response",
2161
+ g
2162
+ ), A;
2163
+ }
2164
+ };
2165
+ };
1789
2166
  export {
1790
- vr as MovmoCardForm,
1791
- vt as PaymentMethodPreview,
1792
- ft as PaymentMethodsManager,
1793
- Fe as getPaymentsConfig,
1794
- yt as setPaymentsConfig,
1795
- nt as useDeletePaymentMethod,
1796
- et as useMovmoCardFields,
1797
- st as useSetDefaultPaymentMethod,
1798
- ot as useUserPaymentMethods
2167
+ Cr as MovmoCardForm,
2168
+ pt as PaymentMethodPreview,
2169
+ xt as PaymentMethodsManager,
2170
+ Nt as createMovmoAuthFetch,
2171
+ We as getPaymentsConfig,
2172
+ Ct as setPaymentsConfig,
2173
+ ct as useDeletePaymentMethod,
2174
+ st as useMovmoCardFields,
2175
+ dt as useSetDefaultPaymentMethod,
2176
+ ut as useUserPaymentMethods
1799
2177
  };
1800
2178
  //# sourceMappingURL=index.es.js.map