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