@nice2dev/ui-money 1.0.10 → 1.0.12

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.mjs CHANGED
@@ -1,9 +1,9 @@
1
- var Oe = Object.defineProperty;
2
- var ke = (r, e, n) => e in r ? Oe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var T = (r, e, n) => ke(r, typeof e != "symbol" ? e + "" : e, n);
4
- import Be, { useState as E, useRef as Te, useEffect as qe, useMemo as P, useCallback as R, forwardRef as te, useId as ye } from "react";
5
- import { jsxs as N, jsx as i } from "react/jsx-runtime";
6
- const se = [
1
+ var Xe = Object.defineProperty;
2
+ var Qe = (t, e, n) => e in t ? Xe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var K = (t, e, n) => Qe(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import Ve, { useState as B, useRef as We, useEffect as et, useMemo as k, useCallback as F, forwardRef as de, useId as Ce } from "react";
5
+ import { jsxs as N, jsx as s } from "react/jsx-runtime";
6
+ const fe = [
7
7
  // ── Majors ─────────────────────────────────────
8
8
  { code: "USD", numeric: 840, symbol: "$", name: "US Dollar", decimals: 2, symbolFirst: !0 },
9
9
  { code: "EUR", numeric: 978, symbol: "€", name: "Euro", decimals: 2, symbolFirst: !0 },
@@ -225,186 +225,186 @@ const se = [
225
225
  { code: "ETH", numeric: 0, symbol: "Ξ", name: "Ether", decimals: 8, symbolFirst: !0 },
226
226
  { code: "USDC", numeric: 0, symbol: "USDC", name: "USD Coin", decimals: 6 },
227
227
  { code: "USDT", numeric: 0, symbol: "USDT", name: "Tether", decimals: 6 }
228
- ], ve = new Map(se.map((r) => [r.code, r]));
229
- function L(r) {
230
- return ve.get(r.toUpperCase());
228
+ ], Oe = new Map(fe.map((t) => [t.code, t]));
229
+ function V(t) {
230
+ return Oe.get(t.toUpperCase());
231
231
  }
232
- function fn(r) {
233
- ve.set(r.code.toUpperCase(), r);
234
- const e = se.findIndex((n) => n.code === r.code);
235
- e >= 0 ? se[e] = r : se.push(r);
232
+ function Et(t) {
233
+ Oe.set(t.code.toUpperCase(), t);
234
+ const e = fe.findIndex((n) => n.code === t.code);
235
+ e >= 0 ? fe[e] = t : fe.push(t);
236
236
  }
237
- function re(r, e) {
238
- const n = L(e), t = (n == null ? void 0 : n.decimals) ?? 2, c = Math.pow(10, t);
239
- return { amount: (r < 0 ? -1 : 1) * Math.round(Math.abs(r) * c), currency: e.toUpperCase() };
237
+ function W(t, e) {
238
+ const n = V(e), c = (n == null ? void 0 : n.decimals) ?? 2, r = Math.pow(10, c);
239
+ return { amount: (t < 0 ? -1 : 1) * Math.round(Math.abs(t) * r), currency: e.toUpperCase() };
240
240
  }
241
- function $e(r) {
242
- const e = L(r.currency), n = (e == null ? void 0 : e.decimals) ?? 2;
243
- return r.amount / Math.pow(10, n);
241
+ function Ke(t) {
242
+ const e = V(t.currency), n = (e == null ? void 0 : e.decimals) ?? 2;
243
+ return t.amount / Math.pow(10, n);
244
244
  }
245
- function Le(r, e) {
246
- return r.currency.toUpperCase() === e.currency.toUpperCase();
245
+ function tt(t, e) {
246
+ return t.currency.toUpperCase() === e.currency.toUpperCase();
247
247
  }
248
- function pe(r, e, n) {
249
- if (!Le(r, e))
250
- throw new Error(`Cannot ${n} different currencies: ${r.currency} vs ${e.currency}`);
248
+ function $e(t, e, n) {
249
+ if (!tt(t, e))
250
+ throw new Error(`Cannot ${n} different currencies: ${t.currency} vs ${e.currency}`);
251
251
  }
252
- function He(r, e) {
253
- return pe(r, e, "add"), { amount: r.amount + e.amount, currency: r.currency };
252
+ function me(t, e) {
253
+ return $e(t, e, "add"), { amount: t.amount + e.amount, currency: t.currency };
254
254
  }
255
- function je(r, e) {
256
- return pe(r, e, "subtract"), { amount: r.amount - e.amount, currency: r.currency };
255
+ function nt(t, e) {
256
+ return $e(t, e, "subtract"), { amount: t.amount - e.amount, currency: t.currency };
257
257
  }
258
- function ze(r, e) {
258
+ function De(t, e) {
259
259
  return {
260
- amount: (r.amount * e < 0 ? -1 : 1) * Math.round(Math.abs(r.amount * e)),
261
- currency: r.currency
260
+ amount: (t.amount * e < 0 ? -1 : 1) * Math.round(Math.abs(t.amount * e)),
261
+ currency: t.currency
262
262
  };
263
263
  }
264
- function bn(r, e) {
265
- return pe(r, e, "compare"), r.amount - e.amount;
264
+ function At(t, e) {
265
+ return $e(t, e, "compare"), t.amount - e.amount;
266
266
  }
267
- function _n(r) {
268
- return r.amount === 0;
267
+ function Ot(t) {
268
+ return t.amount === 0;
269
269
  }
270
- function Nn(r) {
271
- return r.amount < 0;
270
+ function Kt(t) {
271
+ return t.amount < 0;
272
272
  }
273
- function gn(r) {
274
- return { amount: -r.amount, currency: r.currency };
273
+ function Bt(t) {
274
+ return { amount: -t.amount, currency: t.currency };
275
275
  }
276
- function ee(r, e = {}) {
277
- const n = L(r.currency), t = e.decimals ?? (n == null ? void 0 : n.decimals) ?? 2, c = r.amount / Math.pow(10, t);
276
+ function te(t, e = {}) {
277
+ const n = V(t.currency), c = e.decimals ?? (n == null ? void 0 : n.decimals) ?? 2, r = t.amount / Math.pow(10, c);
278
278
  try {
279
279
  return new Intl.NumberFormat(e.locale, {
280
280
  style: "currency",
281
- currency: r.currency,
282
- minimumFractionDigits: t,
283
- maximumFractionDigits: t,
281
+ currency: t.currency,
282
+ minimumFractionDigits: c,
283
+ maximumFractionDigits: c,
284
284
  currencyDisplay: e.currencyDisplay ?? "symbol"
285
- }).format(c);
285
+ }).format(r);
286
286
  } catch {
287
- const a = (n == null ? void 0 : n.symbol) ?? r.currency, o = c.toFixed(t);
287
+ const a = (n == null ? void 0 : n.symbol) ?? t.currency, o = r.toFixed(c);
288
288
  return n != null && n.symbolFirst ? `${a}${o}` : `${o} ${a}`;
289
289
  }
290
290
  }
291
- function Ye(r, e) {
292
- if (!r)
291
+ function rt(t, e) {
292
+ if (!t)
293
293
  return null;
294
- let n = r.replace(/[^\d.,\-]/g, "").trim();
294
+ let n = t.replace(/[^\d.,\-]/g, "").trim();
295
295
  if (!n || n === "-")
296
296
  return null;
297
- const t = n.startsWith("-");
298
- t && (n = n.slice(1));
299
- const c = n.lastIndexOf("."), a = n.lastIndexOf(","), o = Math.max(c, a);
300
- let u, l = "";
301
- o === -1 ? u = n : (u = n.slice(0, o).replace(/[.,]/g, ""), l = n.slice(o + 1).replace(/[.,]/g, ""));
302
- const s = `${u}.${l || "0"}`, y = parseFloat(s);
303
- return Number.isFinite(y) ? re(t ? -y : y, e) : null;
297
+ const c = n.startsWith("-");
298
+ c && (n = n.slice(1));
299
+ const r = n.lastIndexOf("."), a = n.lastIndexOf(","), o = Math.max(r, a);
300
+ let i, l = "";
301
+ o === -1 ? i = n : (i = n.slice(0, o).replace(/[.,]/g, ""), l = n.slice(o + 1).replace(/[.,]/g, ""));
302
+ const u = `${i}.${l || "0"}`, m = parseFloat(u);
303
+ return Number.isFinite(m) ? W(c ? -m : m, e) : null;
304
304
  }
305
- function de(r) {
306
- const e = (r || "").replace(/\D/g, "");
305
+ function Ne(t) {
306
+ const e = (t || "").replace(/\D/g, "");
307
307
  return e ? /^4/.test(e) ? "visa" : /^(5[1-5]|2(2[2-9]|[3-6]\d|7[01]|720))/.test(e) ? "mastercard" : /^3[47]/.test(e) ? "amex" : /^(6011|65|64[4-9]|622(12[6-9]|1[3-9]\d|[2-8]\d\d|9[01]\d|92[0-5]))/.test(e) ? "discover" : /^3(0[0-5]|[68])/.test(e) ? "diners" : /^35(2[89]|[3-8])/.test(e) ? "jcb" : /^62/.test(e) ? "unionpay" : /^(50|5[6-9]|6[0-9])/.test(e) ? "maestro" : /^(2200|2201|2202|2203|2204)/.test(e) ? "mir" : /^(4011|4312|4389|4514|4576|5041|5066|5067|509|6277|6362|6363|650|6516|6550)/.test(e) ? "elo" : /^(606282|3841)/.test(e) ? "hipercard" : "unknown" : "unknown";
308
308
  }
309
- function Se(r) {
310
- const e = (r || "").replace(/\D/g, "");
309
+ function Be(t) {
310
+ const e = (t || "").replace(/\D/g, "");
311
311
  if (e.length < 12 || e.length > 19)
312
312
  return !1;
313
- let n = 0, t = !1;
314
- for (let c = e.length - 1; c >= 0; c--) {
315
- let a = e.charCodeAt(c) - 48;
316
- t && (a *= 2, a > 9 && (a -= 9)), n += a, t = !t;
313
+ let n = 0, c = !1;
314
+ for (let r = e.length - 1; r >= 0; r--) {
315
+ let a = e.charCodeAt(r) - 48;
316
+ c && (a *= 2, a > 9 && (a -= 9)), n += a, c = !c;
317
317
  }
318
318
  return n % 10 === 0;
319
319
  }
320
- function Ge(r, e) {
321
- const n = (r || "").replace(/\D/g, ""), t = e ?? de(n);
322
- return t === "amex" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 15)].filter(Boolean).join(" ") : t === "diners" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 14)].filter(Boolean).join(" ") : (n.match(/.{1,4}/g) ?? []).join(" ").trim();
320
+ function ct(t, e) {
321
+ const n = (t || "").replace(/\D/g, ""), c = e ?? Ne(n);
322
+ return c === "amex" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 15)].filter(Boolean).join(" ") : c === "diners" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 14)].filter(Boolean).join(" ") : (n.match(/.{1,4}/g) ?? []).join(" ").trim();
323
323
  }
324
- function wn(r, e) {
325
- const n = (r || "").replace(/\D/g, "");
324
+ function Tt(t, e) {
325
+ const n = (t || "").replace(/\D/g, "");
326
326
  if (n.length < 4)
327
327
  return n;
328
- const t = n.slice(-4), c = "*".repeat(n.length - 4) + t, a = e ?? de(n);
329
- return a === "amex" ? [c.slice(0, 4), c.slice(4, 10), c.slice(10, 15)].filter(Boolean).join(" ") : a === "diners" ? [c.slice(0, 4), c.slice(4, 10), c.slice(10, 14)].filter(Boolean).join(" ") : (c.match(/.{1,4}/g) ?? []).join(" ").trim();
328
+ const c = n.slice(-4), r = "*".repeat(n.length - 4) + c, a = e ?? Ne(n);
329
+ return a === "amex" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 15)].filter(Boolean).join(" ") : a === "diners" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 14)].filter(Boolean).join(" ") : (r.match(/.{1,4}/g) ?? []).join(" ").trim();
330
330
  }
331
- function Ue(r) {
332
- const e = (r || "").replace(/\D/g, "");
331
+ function Te(t) {
332
+ const e = (t || "").replace(/\D/g, "");
333
333
  if (e.length < 3)
334
334
  return null;
335
- const n = e.slice(0, 2), t = e.length >= 4 ? e.slice(-2) : e.slice(2, 4), c = parseInt(n, 10);
336
- return !Number.isFinite(c) || c < 1 || c > 12 ? null : `${n}/${t}`;
335
+ const n = e.slice(0, 2), c = e.length >= 4 ? e.slice(-2) : e.slice(2, 4), r = parseInt(n, 10);
336
+ return !Number.isFinite(r) || r < 1 || r > 12 ? null : `${n}/${c}`;
337
337
  }
338
- function xe(r, e = /* @__PURE__ */ new Date()) {
339
- const n = Ue(r);
338
+ function Le(t, e = /* @__PURE__ */ new Date()) {
339
+ const n = Te(t);
340
340
  if (!n)
341
341
  return !1;
342
- const [t, c] = n.split("/"), a = parseInt(t, 10), o = 2e3 + parseInt(c, 10);
342
+ const [c, r] = n.split("/"), a = parseInt(c, 10), o = 2e3 + parseInt(r, 10);
343
343
  return new Date(o, a, 0, 23, 59, 59, 999).getTime() >= e.getTime();
344
344
  }
345
- function ie(r) {
346
- return r === "amex" ? 4 : 3;
345
+ function ye(t) {
346
+ return t === "amex" ? 4 : 3;
347
347
  }
348
- function we(r, e = {}) {
349
- var s;
350
- const n = {}, t = de(r.number), c = Se(r.number);
351
- c || (n.number = "Invalid card number");
352
- const a = xe(r.expiry, e.now);
348
+ function Ie(t, e = {}) {
349
+ var u;
350
+ const n = {}, c = Ne(t.number), r = Be(t.number);
351
+ r || (n.number = "Invalid card number");
352
+ const a = Le(t.expiry, e.now);
353
353
  a || (n.expiry = "Invalid or expired");
354
- const u = (r.cvc || "").replace(/\D/g, "").length === ie(t);
355
- u || (n.cvc = `CVC must be ${ie(t)} digits`);
356
- const l = !e.requireHolder || (((s = r.holderName) == null ? void 0 : s.trim().length) ?? 0) >= 2;
354
+ const i = (t.cvc || "").replace(/\D/g, "").length === ye(c);
355
+ i || (n.cvc = `CVC must be ${ye(c)} digits`);
356
+ const l = !e.requireHolder || (((u = t.holderName) == null ? void 0 : u.trim().length) ?? 0) >= 2;
357
357
  return l || (n.holderName = "Cardholder name required"), {
358
- brand: t,
359
- numberValid: c,
358
+ brand: c,
359
+ numberValid: r,
360
360
  expiryValid: a,
361
- cvcValid: u,
361
+ cvcValid: i,
362
362
  holderValid: l,
363
- isValid: c && a && u && l,
363
+ isValid: r && a && i && l,
364
364
  errors: n
365
365
  };
366
366
  }
367
- class Dn {
367
+ class Lt {
368
368
  constructor(e) {
369
- T(this, "id", "static");
369
+ K(this, "id", "static");
370
370
  this.rates = e;
371
371
  }
372
372
  async getRate(e, n) {
373
- const t = e.toUpperCase(), c = n.toUpperCase();
374
- if (t === c)
375
- return { base: t, quote: c, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
376
- const a = this.rates.find((s) => s.base === t && s.quote === c);
373
+ const c = e.toUpperCase(), r = n.toUpperCase();
374
+ if (c === r)
375
+ return { base: c, quote: r, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
376
+ const a = this.rates.find((u) => u.base === c && u.quote === r);
377
377
  if (a)
378
378
  return a;
379
- const o = this.rates.find((s) => s.base === c && s.quote === t);
379
+ const o = this.rates.find((u) => u.base === r && u.quote === c);
380
380
  if (o)
381
- return { base: t, quote: c, rate: 1 / o.rate, asOf: o.asOf };
382
- const u = this.rates.find((s) => s.base === t && s.quote === "USD") ?? this.rates.find((s) => s.base === "USD" && s.quote === t), l = this.rates.find((s) => s.base === "USD" && s.quote === c) ?? this.rates.find((s) => s.base === c && s.quote === "USD");
383
- if (u && l) {
384
- const s = u.base === "USD" ? 1 / u.rate : u.rate, y = l.base === "USD" ? l.rate : 1 / l.rate;
381
+ return { base: c, quote: r, rate: 1 / o.rate, asOf: o.asOf };
382
+ const i = this.rates.find((u) => u.base === c && u.quote === "USD") ?? this.rates.find((u) => u.base === "USD" && u.quote === c), l = this.rates.find((u) => u.base === "USD" && u.quote === r) ?? this.rates.find((u) => u.base === r && u.quote === "USD");
383
+ if (i && l) {
384
+ const u = i.base === "USD" ? 1 / i.rate : i.rate, m = l.base === "USD" ? l.rate : 1 / l.rate;
385
385
  return {
386
- base: t,
387
- quote: c,
388
- rate: s * y,
386
+ base: c,
387
+ quote: r,
388
+ rate: u * m,
389
389
  asOf: (/* @__PURE__ */ new Date()).toISOString()
390
390
  };
391
391
  }
392
- throw new Error(`No FX rate for ${t}/${c}`);
392
+ throw new Error(`No FX rate for ${c}/${r}`);
393
393
  }
394
394
  }
395
- class he {
395
+ class ge {
396
396
  constructor(e = {}) {
397
- T(this, "cache", /* @__PURE__ */ new Map());
398
- T(this, "fetchImpl");
399
- T(this, "ttl");
397
+ K(this, "cache", /* @__PURE__ */ new Map());
398
+ K(this, "fetchImpl");
399
+ K(this, "ttl");
400
400
  this.fetchImpl = e.fetchImpl ?? fetch, this.ttl = e.cacheTtl ?? 6e4;
401
401
  }
402
402
  cacheKey(e, n) {
403
403
  return `${this.id}:${e.toUpperCase()}/${n.toUpperCase()}`;
404
404
  }
405
405
  getCached(e, n) {
406
- const t = this.cacheKey(e, n), c = this.cache.get(t);
407
- return c && c.expires > Date.now() ? c.rate : (c && this.cache.delete(t), null);
406
+ const c = this.cacheKey(e, n), r = this.cache.get(c);
407
+ return r && r.expires > Date.now() ? r.rate : (r && this.cache.delete(c), null);
408
408
  }
409
409
  setCached(e) {
410
410
  this.cache.set(this.cacheKey(e.base, e.quote), {
@@ -413,93 +413,137 @@ class he {
413
413
  });
414
414
  }
415
415
  }
416
- class Cn extends he {
416
+ class at extends ge {
417
417
  constructor(n = {}) {
418
418
  super(n);
419
- T(this, "id", "frankfurter");
419
+ K(this, "id", "frankfurter");
420
420
  }
421
- async getRate(n, t) {
422
- const c = n.toUpperCase(), a = t.toUpperCase();
423
- if (c === a)
424
- return { base: c, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
425
- const o = this.getCached(c, a);
421
+ async getRate(n, c) {
422
+ const r = n.toUpperCase(), a = c.toUpperCase();
423
+ if (r === a)
424
+ return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
425
+ const o = this.getCached(r, a);
426
426
  if (o)
427
427
  return o;
428
- const u = `https://api.frankfurter.app/latest?from=${c}&to=${a}`, l = await this.fetchImpl(u);
428
+ const i = `https://api.frankfurter.app/latest?from=${r}&to=${a}`, l = await this.fetchImpl(i);
429
429
  if (!l.ok)
430
430
  throw new Error(`Frankfurter HTTP ${l.status}`);
431
- const s = await l.json(), y = s.rates[a];
432
- if (y == null)
433
- throw new Error(`Frankfurter: no rate for ${c}/${a}`);
434
- const h = { base: c, quote: a, rate: y, asOf: s.date };
435
- return this.setCached(h), h;
431
+ const u = await l.json(), m = u.rates[a];
432
+ if (m == null)
433
+ throw new Error(`Frankfurter: no rate for ${r}/${a}`);
434
+ const b = { base: r, quote: a, rate: m, asOf: u.date };
435
+ return this.setCached(b), b;
436
436
  }
437
437
  }
438
- class vn extends he {
439
- constructor(n, t = {}) {
440
- super(t);
441
- T(this, "id", "openexchangerates");
438
+ class it extends ge {
439
+ constructor(n, c = {}) {
440
+ super(c);
441
+ K(this, "id", "openexchangerates");
442
442
  this.appId = n;
443
443
  }
444
- async getRate(n, t) {
445
- const c = n.toUpperCase(), a = t.toUpperCase();
446
- if (c === a)
447
- return { base: c, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
448
- const o = this.getCached(c, a);
444
+ async getRate(n, c) {
445
+ const r = n.toUpperCase(), a = c.toUpperCase();
446
+ if (r === a)
447
+ return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
448
+ const o = this.getCached(r, a);
449
449
  if (o)
450
450
  return o;
451
- const u = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, l = await this.fetchImpl(u);
451
+ const i = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, l = await this.fetchImpl(i);
452
452
  if (!l.ok)
453
453
  throw new Error(`OpenExchangeRates HTTP ${l.status}`);
454
- const s = await l.json(), y = s.rates[c], h = s.rates[a];
455
- if (y == null || h == null)
456
- throw new Error(`OpenExchangeRates: missing rate for ${c} or ${a}`);
457
- const m = {
458
- base: c,
454
+ const u = await l.json(), m = u.rates[r], b = u.rates[a];
455
+ if (m == null || b == null)
456
+ throw new Error(`OpenExchangeRates: missing rate for ${r} or ${a}`);
457
+ const p = {
458
+ base: r,
459
459
  quote: a,
460
- rate: h / y,
461
- asOf: new Date(s.timestamp * 1e3).toISOString()
460
+ rate: b / m,
461
+ asOf: new Date(u.timestamp * 1e3).toISOString()
462
462
  };
463
- return this.setCached(m), m;
463
+ return this.setCached(p), p;
464
464
  }
465
465
  }
466
- class $n extends he {
466
+ class st extends ge {
467
467
  constructor(n = {}) {
468
468
  super(n);
469
- T(this, "id", "exchangerate.host");
469
+ K(this, "id", "exchangerate.host");
470
470
  }
471
- async getRate(n, t) {
472
- var m;
473
- const c = n.toUpperCase(), a = t.toUpperCase();
474
- if (c === a)
475
- return { base: c, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
476
- const o = this.getCached(c, a);
471
+ async getRate(n, c) {
472
+ var p;
473
+ const r = n.toUpperCase(), a = c.toUpperCase();
474
+ if (r === a)
475
+ return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
476
+ const o = this.getCached(r, a);
477
477
  if (o)
478
478
  return o;
479
- const u = `https://api.exchangerate.host/convert?from=${c}&to=${a}`, l = await this.fetchImpl(u);
479
+ const i = `https://api.exchangerate.host/convert?from=${r}&to=${a}`, l = await this.fetchImpl(i);
480
480
  if (!l.ok)
481
481
  throw new Error(`exchangerate.host HTTP ${l.status}`);
482
- const s = await l.json(), y = ((m = s.info) == null ? void 0 : m.rate) ?? s.result, h = { base: c, quote: a, rate: y, asOf: s.date };
483
- return this.setCached(h), h;
482
+ const u = await l.json(), m = ((p = u.info) == null ? void 0 : p.rate) ?? u.result, b = { base: r, quote: a, rate: m, asOf: u.date };
483
+ return this.setCached(b), b;
484
+ }
485
+ }
486
+ class ot extends ge {
487
+ constructor(n = {}) {
488
+ super(n);
489
+ K(this, "id", "nbp");
490
+ K(this, "table");
491
+ this.table = n.table ?? "A";
492
+ }
493
+ async getRate(n, c) {
494
+ const r = n.toUpperCase(), a = c.toUpperCase();
495
+ if (r === a) return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
496
+ const o = this.getCached(r, a);
497
+ if (o) return o;
498
+ const i = async (b) => {
499
+ var y;
500
+ if (b === "PLN") return { rate: 1, date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) };
501
+ const p = `https://api.nbp.pl/api/exchangerates/rates/${this.table}/${b}/?format=json`, d = await this.fetchImpl(p);
502
+ if (!d.ok) return null;
503
+ const h = (y = (await d.json()).rates) == null ? void 0 : y[0];
504
+ return h ? { rate: h.mid ?? h.ask ?? 0, date: h.effectiveDate } : null;
505
+ }, l = await i(r), u = await i(a);
506
+ if (!l || !u || l.rate === 0)
507
+ throw new Error(`NBP: missing rate for ${r} or ${a}`);
508
+ const m = {
509
+ base: r,
510
+ quote: a,
511
+ rate: l.rate / u.rate,
512
+ asOf: l.date
513
+ };
514
+ return this.setCached(m), m;
515
+ }
516
+ }
517
+ class lt extends at {
518
+ constructor() {
519
+ super(...arguments);
520
+ K(this, "id", "ecb");
521
+ }
522
+ }
523
+ class ut extends st {
524
+ constructor() {
525
+ super(...arguments);
526
+ K(this, "id", "free-forex");
484
527
  }
485
528
  }
486
- async function Ve(r, e, n) {
487
- const t = e.toUpperCase();
488
- if (r.currency.toUpperCase() === t)
489
- return r;
490
- const c = L(r.currency), a = L(t), o = (c == null ? void 0 : c.decimals) ?? 2, u = (a == null ? void 0 : a.decimals) ?? 2, { rate: l } = await n.getRate(r.currency, t), y = r.amount / Math.pow(10, o) * l;
529
+ const qt = (t = {}) => new ot(t), Ht = (t = {}) => new lt(t), jt = (t) => new it(t.apiKey, t), zt = (t = {}) => new ut(t);
530
+ async function dt(t, e, n) {
531
+ const c = e.toUpperCase();
532
+ if (t.currency.toUpperCase() === c)
533
+ return t;
534
+ const r = V(t.currency), a = V(c), o = (r == null ? void 0 : r.decimals) ?? 2, i = (a == null ? void 0 : a.decimals) ?? 2, { rate: l } = await n.getRate(t.currency, c), m = t.amount / Math.pow(10, o) * l;
491
535
  return {
492
- currency: t,
493
- amount: Math.round(y * Math.pow(10, u))
536
+ currency: c,
537
+ amount: Math.round(m * Math.pow(10, i))
494
538
  };
495
539
  }
496
- class Ze {
540
+ class mt {
497
541
  constructor(e = {}) {
498
- T(this, "id");
499
- T(this, "name");
500
- T(this, "supportedCurrencies");
501
- T(this, "minimums");
502
- T(this, "counter", 0);
542
+ K(this, "id");
543
+ K(this, "name");
544
+ K(this, "supportedCurrencies");
545
+ K(this, "minimums");
546
+ K(this, "counter", 0);
503
547
  this.id = e.id ?? "mock", this.name = e.name ?? "Mock Processor", this.supportedCurrencies = e.supportedCurrencies ?? "*";
504
548
  }
505
549
  newId(e) {
@@ -534,28 +578,28 @@ class Ze {
534
578
  };
535
579
  }
536
580
  }
537
- function G(r, e, n, t, c) {
581
+ function j(t, e, n, c, r) {
538
582
  const a = (o) => {
539
- const u = t == null ? void 0 : t[o];
540
- return u || (async () => {
583
+ const i = c == null ? void 0 : c[o];
584
+ return i || (async () => {
541
585
  throw new Error(
542
586
  `[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(o)}\` implementation that calls the ${e} SDK.`
543
587
  );
544
588
  });
545
589
  };
546
590
  return {
547
- id: r,
591
+ id: t,
548
592
  name: e,
549
593
  supportedCurrencies: n,
550
- minimums: c,
594
+ minimums: r,
551
595
  authorize: a("authorize"),
552
596
  capture: a("capture"),
553
597
  cancel: a("cancel"),
554
598
  refund: a("refund")
555
599
  };
556
600
  }
557
- function Je(r) {
558
- return G("stripe", "Stripe", "*", r, {
601
+ function pt(t) {
602
+ return j("stripe", "Stripe", "*", t, {
559
603
  USD: 50,
560
604
  EUR: 50,
561
605
  GBP: 30,
@@ -569,8 +613,8 @@ function Je(r) {
569
613
  PLN: 200
570
614
  });
571
615
  }
572
- function Qe(r) {
573
- return G(
616
+ function yt(t) {
617
+ return j(
574
618
  "paypal",
575
619
  "PayPal",
576
620
  [
@@ -597,666 +641,705 @@ function Qe(r) {
597
641
  "PHP",
598
642
  "ILS"
599
643
  ],
600
- r
644
+ t
601
645
  );
602
646
  }
603
- function Xe(r) {
604
- return G("adyen", "Adyen", "*", r);
647
+ function ft(t) {
648
+ return j("adyen", "Adyen", "*", t);
605
649
  }
606
- function We(r) {
607
- return G("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], r);
650
+ function ht(t) {
651
+ return j("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], t);
608
652
  }
609
- function en(r) {
610
- return G("mollie", "Mollie", "*", r);
653
+ function bt(t) {
654
+ return j("mollie", "Mollie", "*", t);
611
655
  }
612
- function nn(r) {
613
- return G("braintree", "Braintree", "*", r);
656
+ function _t(t) {
657
+ return j("braintree", "Braintree", "*", t);
614
658
  }
615
- function rn(r) {
616
- return G("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], r);
659
+ function Nt(t) {
660
+ return j("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], t);
617
661
  }
618
- function tn(r) {
619
- return G(
662
+ function gt(t) {
663
+ return j(
620
664
  "payu",
621
665
  "PayU",
622
666
  ["PLN", "EUR", "USD", "CZK", "HUF", "RON", "BGN", "TRY"],
623
- r
667
+ t
624
668
  );
625
669
  }
626
- function cn(r) {
627
- return G("przelewy24", "Przelewy24", ["PLN", "EUR"], r);
670
+ function wt(t) {
671
+ return j("przelewy24", "Przelewy24", ["PLN", "EUR"], t);
672
+ }
673
+ function Dt(t = {}) {
674
+ return j("tpay", "Tpay", ["PLN", "EUR", "USD", "GBP"], t);
675
+ }
676
+ function vt(t = {}) {
677
+ return j("autopay", "Autopay", ["PLN", "EUR", "USD", "GBP", "CZK"], t);
678
+ }
679
+ function Ct(t = {}) {
680
+ const { acquirer: e = "native", ...n } = t;
681
+ return j(`blik:${e}`, `BLIK (${e})`, ["PLN"], n);
628
682
  }
629
- function an(r) {
630
- return G(
683
+ function $t(t) {
684
+ return j(
631
685
  "klarna",
632
686
  "Klarna",
633
687
  ["USD", "EUR", "GBP", "SEK", "NOK", "DKK", "CHF", "AUD", "CAD", "NZD", "PLN"],
634
- r
688
+ t
635
689
  );
636
690
  }
637
- function sn(r) {
638
- return G(
691
+ function xt(t) {
692
+ return j(
639
693
  "coinbase-commerce",
640
694
  "Coinbase Commerce",
641
695
  ["BTC", "ETH", "USDC", "USDT", "USD", "EUR"],
642
- r
696
+ t
643
697
  );
644
698
  }
645
- const Sn = {
646
- mock: () => new Ze(),
647
- stripe: () => Je(),
648
- paypal: () => Qe(),
649
- adyen: () => Xe(),
650
- square: () => We(),
651
- mollie: () => en(),
652
- braintree: () => nn(),
653
- razorpay: () => rn(),
654
- payu: () => tn(),
655
- przelewy24: () => cn(),
656
- klarna: () => an(),
657
- "coinbase-commerce": () => sn()
699
+ const Gt = {
700
+ mock: () => new mt(),
701
+ stripe: () => pt(),
702
+ paypal: () => yt(),
703
+ adyen: () => ft(),
704
+ square: () => ht(),
705
+ mollie: () => bt(),
706
+ braintree: () => _t(),
707
+ razorpay: () => Nt(),
708
+ payu: () => gt(),
709
+ przelewy24: () => wt(),
710
+ tpay: () => Dt(),
711
+ autopay: () => vt(),
712
+ blik: () => Ct(),
713
+ klarna: () => $t(),
714
+ "coinbase-commerce": () => xt()
658
715
  };
659
- function Un(r, e) {
660
- const n = P(
661
- () => "amount" in r ? r : re(
662
- r.major,
663
- r.currency
716
+ function Yt(t, e) {
717
+ const n = k(
718
+ () => "amount" in t ? t : W(
719
+ t.major,
720
+ t.currency
664
721
  ),
665
722
  // eslint-disable-next-line react-hooks/exhaustive-deps
666
723
  []
667
- ), [t, c] = E(n), a = R(
668
- (m) => c((d) => re(m, d.currency)),
724
+ ), [c, r] = B(n), a = F(
725
+ (p) => r((d) => W(p, d.currency)),
669
726
  []
670
- ), o = R((m) => {
671
- c((d) => ({ ...d, currency: m.toUpperCase() }));
672
- }, []), u = R((m) => c((d) => He(d, m)), []), l = R(
673
- (m) => c((d) => je(d, m)),
727
+ ), o = F((p) => {
728
+ r((d) => ({ ...d, currency: p.toUpperCase() }));
729
+ }, []), i = F((p) => r((d) => me(d, p)), []), l = F(
730
+ (p) => r((d) => nt(d, p)),
674
731
  []
675
- ), s = R(
676
- (m) => c((d) => ze(d, m)),
732
+ ), u = F(
733
+ (p) => r((d) => De(d, p)),
677
734
  []
678
- ), y = P(() => ee(t, { locale: e }), [t, e]), h = P(() => $e(t), [t]);
679
- return { money: t, setMoney: c, setMajor: a, setCurrency: o, add: u, subtract: l, scale: s, formatted: y, major: h };
735
+ ), m = k(() => te(c, { locale: e }), [c, e]), b = k(() => Ke(c), [c]);
736
+ return { money: c, setMoney: r, setMajor: a, setCurrency: o, add: i, subtract: l, scale: u, formatted: m, major: b };
680
737
  }
681
- function me(r, e, n) {
682
- const [t, c] = E(null), [a, o] = E(null), [u, l] = E(!1), s = Te(0);
683
- return qe(() => {
684
- if (!r) {
685
- c(null);
738
+ function ve(t, e, n) {
739
+ const [c, r] = B(null), [a, o] = B(null), [i, l] = B(!1), u = We(0);
740
+ return et(() => {
741
+ if (!t) {
742
+ r(null);
686
743
  return;
687
744
  }
688
- const y = ++s.current;
689
- l(!0), o(null), Ve(r, e, n).then((h) => {
690
- s.current === y && c(h);
691
- }).catch((h) => {
692
- s.current === y && (o(h instanceof Error ? h : new Error(String(h))), c(null));
745
+ const m = ++u.current;
746
+ l(!0), o(null), dt(t, e, n).then((b) => {
747
+ u.current === m && r(b);
748
+ }).catch((b) => {
749
+ u.current === m && (o(b instanceof Error ? b : new Error(String(b))), r(null));
693
750
  }).finally(() => {
694
- s.current === y && l(!1);
751
+ u.current === m && l(!1);
695
752
  });
696
- }, [r == null ? void 0 : r.amount, r == null ? void 0 : r.currency, e, n]), { converted: t, loading: u, error: a };
753
+ }, [t == null ? void 0 : t.amount, t == null ? void 0 : t.currency, e, n]), { converted: c, loading: i, error: a };
697
754
  }
698
- function on(r) {
699
- const [e, n] = E("idle"), [t, c] = E(null), [a, o] = E(null), u = R(() => {
700
- n("idle"), c(null), o(null);
701
- }, []), l = R(
702
- async (m) => {
755
+ function St(t) {
756
+ const [e, n] = B("idle"), [c, r] = B(null), [a, o] = B(null), i = F(() => {
757
+ n("idle"), r(null), o(null);
758
+ }, []), l = F(
759
+ async (p) => {
703
760
  n("authorizing"), o(null);
704
761
  try {
705
- const d = await r.authorize(m);
706
- return c(d), n(d.status), d;
762
+ const d = await t.authorize(p);
763
+ return r(d), n(d.status), d;
707
764
  } catch (d) {
708
- const b = d instanceof Error ? d : new Error(String(d));
709
- throw o(b), n("failed"), b;
765
+ const f = d instanceof Error ? d : new Error(String(d));
766
+ throw o(f), n("failed"), f;
710
767
  }
711
768
  },
712
- [r]
713
- ), s = R(
714
- async (m, d) => {
715
- const b = m ?? (t == null ? void 0 : t.id);
716
- if (!b)
769
+ [t]
770
+ ), u = F(
771
+ async (p, d) => {
772
+ const f = p ?? (c == null ? void 0 : c.id);
773
+ if (!f)
717
774
  throw new Error("No authorization id to capture");
718
775
  n("capturing");
719
776
  try {
720
- const _ = await r.capture(b, d);
721
- return c(_), n(_.status), _;
722
- } catch (_) {
723
- const f = _ instanceof Error ? _ : new Error(String(_));
724
- throw o(f), n("failed"), f;
777
+ const h = await t.capture(f, d);
778
+ return r(h), n(h.status), h;
779
+ } catch (h) {
780
+ const y = h instanceof Error ? h : new Error(String(h));
781
+ throw o(y), n("failed"), y;
725
782
  }
726
783
  },
727
- [r, t == null ? void 0 : t.id]
728
- ), y = R(
729
- async (m) => {
730
- const d = m ?? (t == null ? void 0 : t.id);
784
+ [t, c == null ? void 0 : c.id]
785
+ ), m = F(
786
+ async (p) => {
787
+ const d = p ?? (c == null ? void 0 : c.id);
731
788
  if (!d)
732
789
  throw new Error("No payment id to cancel");
733
- const b = await r.cancel(d);
734
- return c(b), n(b.status), b;
790
+ const f = await t.cancel(d);
791
+ return r(f), n(f.status), f;
735
792
  },
736
- [r, t == null ? void 0 : t.id]
737
- ), h = R(
738
- async (m, d) => {
739
- const b = m ?? (t == null ? void 0 : t.id);
740
- if (!b)
793
+ [t, c == null ? void 0 : c.id]
794
+ ), b = F(
795
+ async (p, d) => {
796
+ const f = p ?? (c == null ? void 0 : c.id);
797
+ if (!f)
741
798
  throw new Error("No payment id to refund");
742
- const _ = await r.refund(b, d);
743
- return c(_), n(_.status), _;
799
+ const h = await t.refund(f, d);
800
+ return r(h), n(h.status), h;
744
801
  },
745
- [r, t == null ? void 0 : t.id]
802
+ [t, c == null ? void 0 : c.id]
746
803
  );
747
- return { status: e, response: t, error: a, authorize: l, capture: s, cancel: y, refund: h, reset: u };
804
+ return { status: e, response: c, error: a, authorize: l, capture: u, cancel: m, refund: b, reset: i };
748
805
  }
749
- const De = te(function({
806
+ const Fe = de(function({
750
807
  value: e,
751
808
  amount: n,
752
- currency: t,
753
- locale: c,
809
+ currency: c,
810
+ locale: r,
754
811
  display: a = "symbol",
755
812
  highlightNegative: o = !0,
756
- zeroPlaceholder: u,
813
+ zeroPlaceholder: i,
757
814
  convertTo: l,
758
- exchangeProvider: s,
759
- className: y,
760
- style: h,
761
- "aria-label": m
815
+ exchangeProvider: u,
816
+ className: m,
817
+ style: b,
818
+ "aria-label": p
762
819
  }, d) {
763
- const b = P(() => {
820
+ const f = k(() => {
764
821
  if (e)
765
822
  return e;
766
- if (n != null && t) {
767
- const I = L(t), F = (I == null ? void 0 : I.decimals) ?? 2;
823
+ if (n != null && c) {
824
+ const g = V(c), v = (g == null ? void 0 : g.decimals) ?? 2;
768
825
  return {
769
- amount: Math.round(n * Math.pow(10, F)),
770
- currency: t.toUpperCase()
826
+ amount: Math.round(n * Math.pow(10, v)),
827
+ currency: c.toUpperCase()
771
828
  };
772
829
  }
773
830
  return null;
774
- }, [e, n, t]), _ = P(() => b ? b.amount === 0 && u != null ? u : ee(b, { locale: c, currencyDisplay: a }) : "", [b, c, a, u]), { converted: f } = me(
775
- l && s ? b : null,
831
+ }, [e, n, c]), h = k(() => f ? f.amount === 0 && i != null ? i : te(f, { locale: r, currencyDisplay: a }) : "", [f, r, a, i]), { converted: y } = ve(
832
+ l && u ? f : null,
776
833
  l ?? "",
777
- s
834
+ u
778
835
  );
779
- if (!b)
836
+ if (!f)
780
837
  return null;
781
- const H = b.amount < 0, j = "nice-money" + (o && H ? " nice-money--negative" : "") + (y ? ` ${y}` : "");
782
- return /* @__PURE__ */ N("span", { ref: d, className: j, style: h, "aria-label": m, children: [
783
- /* @__PURE__ */ i("span", { className: "nice-money__value", children: _ }),
784
- f && /* @__PURE__ */ N("span", { className: "nice-money__converted", "aria-label": `Converted to ${f.currency}`, children: [
838
+ const _ = f.amount < 0, S = "nice-money" + (o && _ ? " nice-money--negative" : "") + (m ? ` ${m}` : "");
839
+ return /* @__PURE__ */ N("span", { ref: d, className: S, style: b, "aria-label": p, children: [
840
+ /* @__PURE__ */ s("span", { className: "nice-money__value", children: h }),
841
+ y && /* @__PURE__ */ N("span", { className: "nice-money__converted", "aria-label": `Converted to ${y.currency}`, children: [
785
842
  " ≈ ",
786
- ee(f, { locale: c })
843
+ te(y, { locale: r })
787
844
  ] })
788
845
  ] });
789
- }), xn = se.map((r) => r.code).sort(), Re = te(
846
+ }), Zt = fe.map((t) => t.code).sort(), qe = de(
790
847
  function({
791
848
  value: e,
792
849
  onChange: n,
793
- options: t = se,
794
- recents: c = [],
850
+ options: c = fe,
851
+ recents: r = [],
795
852
  searchable: a,
796
853
  showCode: o = !0,
797
- showSymbol: u = !0,
854
+ showSymbol: i = !0,
798
855
  compact: l = !1,
799
- disabled: s,
800
- readOnly: y,
801
- loading: h,
802
- accessMode: m,
856
+ disabled: u,
857
+ readOnly: m,
858
+ loading: b,
859
+ accessMode: p,
803
860
  label: d,
804
- helperText: b,
805
- error: _,
806
- required: f,
807
- size: H = "md",
808
- labelPlacement: j = "top",
809
- labelWidth: I,
810
- controlWidth: F,
811
- className: Q,
812
- style: X,
813
- id: A,
814
- name: M,
815
- title: ne,
816
- "data-testid": x,
817
- "aria-label": V,
818
- placeholder: O
819
- }, v) {
820
- if (m === "hidden")
821
- return null;
822
- const q = s || m === "disabled" || h, W = y || m === "readOnly", K = ye(), z = A ?? `nice-cs-${K}`, [Z, Y] = E(""), C = a ?? t.length > 8, D = P(() => {
823
- if (!Z.trim())
824
- return t;
825
- const p = Z.trim().toLowerCase();
826
- return t.filter(
827
- (S) => S.code.toLowerCase().includes(p) || S.name.toLowerCase().includes(p) || S.symbol.toLowerCase().includes(p)
861
+ helperText: f,
862
+ error: h,
863
+ required: y,
864
+ size: _ = "md",
865
+ labelPlacement: S = "top",
866
+ labelWidth: g,
867
+ controlWidth: v,
868
+ className: O,
869
+ style: Y,
870
+ id: Z,
871
+ name: R,
872
+ title: q,
873
+ "data-testid": ne,
874
+ "aria-label": E,
875
+ placeholder: J
876
+ }, z) {
877
+ const P = p === "hidden", X = u || p === "disabled" || b, se = m || p === "readOnly", A = Ce(), oe = Z ?? `nice-cs-${A}`, [H, U] = B(""), M = a ?? c.length > 8, T = k(() => {
878
+ if (!H.trim())
879
+ return c;
880
+ const D = H.trim().toLowerCase();
881
+ return c.filter(
882
+ (C) => C.code.toLowerCase().includes(D) || C.name.toLowerCase().includes(D) || C.symbol.toLowerCase().includes(D)
828
883
  );
829
- }, [t, Z]), $ = P(() => {
830
- const p = /* @__PURE__ */ new Set();
831
- return c.map((S) => L(S)).filter((S) => !!S && !p.has(S.code) && !!p.add(S.code));
832
- }, [c]), B = R(
833
- (p) => {
834
- const S = p.target.value, oe = L(S);
835
- oe && (n == null || n(S, oe));
884
+ }, [c, H]), x = k(() => {
885
+ const D = /* @__PURE__ */ new Set();
886
+ return r.map((C) => V(C)).filter((C) => !!C && !D.has(C.code) && !!D.add(C.code));
887
+ }, [r]), le = F(
888
+ (D) => {
889
+ const C = D.target.value, ce = V(C);
890
+ ce && (n == null || n(C, ce));
836
891
  },
837
892
  [n]
838
- ), ce = (p) => {
893
+ ), ee = (D) => {
839
894
  if (l)
840
- return `${u ? p.symbol + " " : ""}${p.code}`;
841
- const S = [];
842
- return u && S.push(p.symbol), o && S.push(p.code), S.push("—", p.name), S.join(" ");
843
- }, g = `nice-currency-selector nice-currency-selector--${H} nice-currency-selector--label-${j}` + (l ? " nice-currency-selector--compact" : "") + (_ ? " nice-currency-selector--error" : "") + (q ? " nice-currency-selector--disabled" : "") + (Q ? ` ${Q}` : ""), w = j === "left" && I != null ? { width: typeof I == "number" ? `${I}px` : I, flex: "none" } : void 0, k = F != null ? {
844
- width: typeof F == "number" ? `${F}px` : F,
895
+ return `${i ? D.symbol + " " : ""}${D.code}`;
896
+ const C = [];
897
+ return i && C.push(D.symbol), o && C.push(D.code), C.push("—", D.name), C.join(" ");
898
+ }, w = `nice-currency-selector nice-currency-selector--${_} nice-currency-selector--label-${S}` + (l ? " nice-currency-selector--compact" : "") + (h ? " nice-currency-selector--error" : "") + (X ? " nice-currency-selector--disabled" : "") + (O ? ` ${O}` : ""), I = S === "left" && g != null ? { width: typeof g == "number" ? `${g}px` : g, flex: "none" } : void 0, re = v != null ? {
899
+ width: typeof v == "number" ? `${v}px` : v,
845
900
  flex: "none"
846
901
  } : void 0;
847
- return /* @__PURE__ */ N("div", { ref: v, className: g, style: X, title: ne, "data-testid": x, children: [
848
- d && /* @__PURE__ */ N("label", { htmlFor: z, className: "nice-currency-selector__label", style: w, children: [
902
+ return P ? null : /* @__PURE__ */ N("div", { ref: z, className: w, style: Y, title: q, "data-testid": ne, children: [
903
+ d && /* @__PURE__ */ N("label", { htmlFor: oe, className: "nice-currency-selector__label", style: I, children: [
849
904
  d,
850
- f && /* @__PURE__ */ i("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
905
+ y && /* @__PURE__ */ s("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
851
906
  ] }),
852
- /* @__PURE__ */ N("div", { className: "nice-currency-selector__inner", style: k, children: [
853
- C && /* @__PURE__ */ i(
907
+ /* @__PURE__ */ N("div", { className: "nice-currency-selector__inner", style: re, children: [
908
+ M && /* @__PURE__ */ s(
854
909
  "input",
855
910
  {
856
911
  type: "search",
857
912
  className: "nice-currency-selector__search",
858
913
  placeholder: "Search currency…",
859
- value: Z,
860
- onChange: (p) => Y(p.target.value),
861
- disabled: q || W,
914
+ value: H,
915
+ onChange: (D) => U(D.target.value),
916
+ disabled: X || se,
862
917
  "aria-label": "Search currency"
863
918
  }
864
919
  ),
865
920
  /* @__PURE__ */ N(
866
921
  "select",
867
922
  {
868
- id: z,
869
- name: M,
923
+ id: oe,
924
+ name: R,
870
925
  className: "nice-currency-selector__select",
871
926
  value: e ?? "",
872
- onChange: B,
873
- disabled: q || W,
874
- required: f,
875
- "aria-invalid": !!_,
876
- "aria-label": V ?? (typeof d == "string" ? d : "Currency"),
927
+ onChange: le,
928
+ disabled: X || se,
929
+ required: y,
930
+ "aria-invalid": !!h,
931
+ "aria-label": E ?? (typeof d == "string" ? d : "Currency"),
877
932
  children: [
878
- !e && /* @__PURE__ */ i("option", { value: "", children: O ?? "Select currency…" }),
879
- $.length > 0 && /* @__PURE__ */ i("optgroup", { label: "Recent", children: $.map((p) => /* @__PURE__ */ i("option", { value: p.code, children: ce(p) }, `r-${p.code}`)) }),
880
- /* @__PURE__ */ i("optgroup", { label: $.length > 0 ? "All" : "", children: D.map((p) => /* @__PURE__ */ i("option", { value: p.code, children: ce(p) }, p.code)) })
933
+ !e && /* @__PURE__ */ s("option", { value: "", children: J ?? "Select currency…" }),
934
+ x.length > 0 && /* @__PURE__ */ s("optgroup", { label: "Recent", children: x.map((D) => /* @__PURE__ */ s("option", { value: D.code, children: ee(D) }, `r-${D.code}`)) }),
935
+ /* @__PURE__ */ s("optgroup", { label: x.length > 0 ? "All" : "", children: T.map((D) => /* @__PURE__ */ s("option", { value: D.code, children: ee(D) }, D.code)) })
881
936
  ]
882
937
  }
883
938
  )
884
939
  ] }),
885
- (_ || b) && /* @__PURE__ */ i(
940
+ (h || f) && /* @__PURE__ */ s(
886
941
  "span",
887
942
  {
888
- className: _ ? "nice-currency-selector__error" : "nice-currency-selector__helper",
889
- children: _ ?? b
943
+ className: h ? "nice-currency-selector__error" : "nice-currency-selector__helper",
944
+ children: h ?? f
890
945
  }
891
946
  )
892
947
  ] });
893
948
  }
894
- ), Me = te(
949
+ ), He = de(
895
950
  function({
896
951
  value: e,
897
952
  onChange: n,
898
- currency: t,
899
- onCurrencyChange: c,
953
+ currency: c,
954
+ onCurrencyChange: r,
900
955
  currencies: a,
901
956
  hideCurrencySelector: o,
902
- min: u,
957
+ min: i,
903
958
  max: l,
904
- step: s,
905
- locale: y,
906
- placeholder: h,
907
- label: m,
959
+ step: u,
960
+ locale: m,
961
+ placeholder: b,
962
+ label: p,
908
963
  helperText: d,
909
- error: b,
910
- size: _ = "md",
911
- disabled: f,
912
- readOnly: H,
913
- required: j,
914
- loading: I,
915
- accessMode: F,
916
- labelPlacement: Q = "top",
917
- errorPlacement: X = "bottom",
918
- labelWidth: A,
919
- controlWidth: M,
920
- submitOnEnter: ne,
921
- onSubmit: x,
922
- showFormattedPreview: V = !0,
923
- showSteppers: O = !1,
924
- className: v,
925
- style: q,
926
- id: W,
927
- name: K,
928
- title: z,
929
- "data-testid": Z,
930
- onBlur: Y,
931
- onFocus: C
932
- }, D) {
933
- const $ = f || F === "disabled" || I, B = H || F === "readOnly";
934
- if (F === "hidden")
935
- return null;
936
- const ce = ye(), g = W ?? `nice-money-${ce}`, w = ((e == null ? void 0 : e.currency) ?? t ?? "USD").toUpperCase(), k = L(w), p = (k == null ? void 0 : k.decimals) ?? 2, S = s ?? 1 / Math.pow(10, p), [oe, le] = E(
937
- () => e ? (e.amount / Math.pow(10, p)).toFixed(p) : ""
938
- ), [fe, be] = E(!1);
939
- Be.useEffect(() => {
940
- if (fe)
964
+ error: f,
965
+ size: h = "md",
966
+ disabled: y,
967
+ readOnly: _,
968
+ required: S,
969
+ loading: g,
970
+ accessMode: v,
971
+ labelPlacement: O = "top",
972
+ errorPlacement: Y = "bottom",
973
+ labelWidth: Z,
974
+ controlWidth: R,
975
+ submitOnEnter: q,
976
+ onSubmit: ne,
977
+ showFormattedPreview: E = !0,
978
+ showSteppers: J = !1,
979
+ className: z,
980
+ style: P,
981
+ id: X,
982
+ name: se,
983
+ title: A,
984
+ "data-testid": oe,
985
+ onBlur: H,
986
+ onFocus: U,
987
+ liveGrouping: M,
988
+ multiplierShortcuts: T = !0,
989
+ onValidationError: x
990
+ }, le) {
991
+ const ee = y || v === "disabled" || g, w = _ || v === "readOnly", I = v === "hidden", re = Ce(), D = X ?? `nice-money-${re}`, C = ((e == null ? void 0 : e.currency) ?? c ?? "USD").toUpperCase(), ce = V(C), G = (ce == null ? void 0 : ce.decimals) ?? 2, xe = u ?? 1 / Math.pow(10, G), [we, he] = B(
992
+ () => e ? (e.amount / Math.pow(10, G)).toFixed(G) : ""
993
+ ), [be, Se] = B(!1);
994
+ Ve.useEffect(() => {
995
+ if (be)
941
996
  return;
942
997
  if (e == null) {
943
- le("");
998
+ he("");
944
999
  return;
945
1000
  }
946
- const U = L(e.currency), J = (U == null ? void 0 : U.decimals) ?? 2;
947
- le((e.amount / Math.pow(10, J)).toFixed(J));
948
- }, [e, fe]);
949
- const _e = R(
950
- (U) => {
951
- const J = Ye(U, w);
952
- if (!J) {
1001
+ const $ = V(e.currency), L = ($ == null ? void 0 : $.decimals) ?? 2;
1002
+ he((e.amount / Math.pow(10, L)).toFixed(L));
1003
+ }, [e, be]);
1004
+ const Ue = F(
1005
+ ($) => {
1006
+ let L = $;
1007
+ if (T) {
1008
+ const ie = $.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);
1009
+ if (ie) {
1010
+ const ue = ie[2].toLowerCase() === "k" ? 1e3 : ie[2].toLowerCase() === "m" ? 1e6 : 1e9, ke = Number(ie[1].replace(",", ".")) * ue;
1011
+ if (!Number.isFinite(ke)) {
1012
+ x == null || x(new Error("overflow"));
1013
+ return;
1014
+ }
1015
+ L = String(ke);
1016
+ }
1017
+ }
1018
+ const Q = rt(L, C);
1019
+ if (!Q) {
953
1020
  n == null || n(null);
954
1021
  return;
955
1022
  }
956
- const ue = J.amount / Math.pow(10, p);
957
- if (u != null && ue < u) {
958
- n == null || n(re(u, w));
1023
+ if (!Number.isSafeInteger(Q.amount)) {
1024
+ x == null || x(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));
1025
+ return;
1026
+ }
1027
+ const ae = Q.amount / Math.pow(10, G);
1028
+ if (i != null && ae < i) {
1029
+ x == null || x(new Error(`min: ${i}`)), n == null || n(W(i, C));
959
1030
  return;
960
1031
  }
961
- if (l != null && ue > l) {
962
- n == null || n(re(l, w));
1032
+ if (l != null && ae > l) {
1033
+ x == null || x(new Error(`max: ${l}`)), n == null || n(W(l, C));
963
1034
  return;
964
1035
  }
965
- n == null || n(J);
1036
+ n == null || n(Q);
966
1037
  },
967
- [w, p, u, l, n]
968
- ), Ee = R(
969
- (U) => {
970
- const J = U.target.value;
971
- le(J), _e(J);
1038
+ [C, G, i, l, n, T, x]
1039
+ ), je = F(
1040
+ ($) => {
1041
+ const L = $.target.value;
1042
+ he(L), Ue(L);
972
1043
  },
973
- [_e]
974
- ), Ne = R(
975
- (U) => {
976
- const ue = (e ? e.amount / Math.pow(10, p) : 0) + U, Ke = Math.min(l ?? 1 / 0, Math.max(u ?? -1 / 0, ue));
977
- n == null || n(re(Ke, w));
1044
+ [Ue]
1045
+ ), Re = F(
1046
+ ($) => {
1047
+ const Q = (e ? e.amount / Math.pow(10, G) : 0) + $, ae = Math.min(l ?? 1 / 0, Math.max(i ?? -1 / 0, Q));
1048
+ n == null || n(W(ae, C));
978
1049
  },
979
- [e, p, u, l, w, n]
980
- ), ge = P(() => e ? ee(e, { locale: y }) : "", [e, y]), ae = typeof b == "string" ? b : void 0, Ie = `nice-money-input nice-money-input--${_} nice-money-input--label-${Q} nice-money-input--error-${X}` + (ae ? " nice-money-input--error" : "") + ($ ? " nice-money-input--disabled" : "") + (I ? " nice-money-input--loading" : "") + (v ? ` ${v}` : ""), Fe = (U) => {
981
- ne && U.key === "Enter" && x && (U.preventDefault(), x());
982
- }, Pe = Q === "left" && A != null ? { width: typeof A == "number" ? `${A}px` : A, flex: "none" } : void 0, Ae = M != null ? {
983
- width: typeof M == "number" ? `${M}px` : M,
1050
+ [e, G, i, l, C, n]
1051
+ ), _e = k(() => {
1052
+ var $, L;
1053
+ try {
1054
+ const Q = new Intl.NumberFormat(m).formatToParts(12345.6), ae = (($ = Q.find((ue) => ue.type === "group")) == null ? void 0 : $.value) ?? ",", ie = ((L = Q.find((ue) => ue.type === "decimal")) == null ? void 0 : L.value) ?? ".";
1055
+ return { group: ae, decimal: ie };
1056
+ } catch {
1057
+ return { group: ",", decimal: "." };
1058
+ }
1059
+ }, [m]), Me = M ?? !!_e.group, ze = k(() => {
1060
+ if (!Me || be === !1) return we;
1061
+ const $ = _e.decimal, L = _e.group, Q = we.replace(new RegExp(`[${L.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`, "g"), ""), [ae, ie] = Q.split($);
1062
+ if (!ae) return Q;
1063
+ const ue = ae.replace(/\B(?=(\d{3})+(?!\d))/g, L);
1064
+ return ie != null ? `${ue}${$}${ie}` : ue;
1065
+ }, [we, be, Me, _e]), Pe = k(() => e ? te(e, { locale: m }) : "", [e, m]), pe = typeof f == "string" ? f : void 0, Ge = `nice-money-input nice-money-input--${h} nice-money-input--label-${O} nice-money-input--error-${Y}` + (pe ? " nice-money-input--error" : "") + (ee ? " nice-money-input--disabled" : "") + (g ? " nice-money-input--loading" : "") + (z ? ` ${z}` : ""), Ye = ($) => {
1066
+ q && $.key === "Enter" && ne && ($.preventDefault(), ne());
1067
+ }, Ze = O === "left" && Z != null ? { width: typeof Z == "number" ? `${Z}px` : Z, flex: "none" } : void 0, Je = R != null ? {
1068
+ width: typeof R == "number" ? `${R}px` : R,
984
1069
  flex: "none"
985
1070
  } : void 0;
986
- return /* @__PURE__ */ N("div", { ref: D, className: Ie, style: q, title: z, "data-testid": Z, children: [
987
- m && /* @__PURE__ */ N("label", { htmlFor: g, className: "nice-money-input__label", style: Pe, children: [
988
- m,
989
- j && /* @__PURE__ */ i("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
1071
+ return I ? null : /* @__PURE__ */ N("div", { ref: le, className: Ge, style: P, title: A, "data-testid": oe, children: [
1072
+ p && /* @__PURE__ */ N("label", { htmlFor: D, className: "nice-money-input__label", style: Ze, children: [
1073
+ p,
1074
+ S && /* @__PURE__ */ s("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
990
1075
  ] }),
991
- /* @__PURE__ */ N("div", { className: "nice-money-input__row", style: Ae, children: [
992
- !o && /* @__PURE__ */ i(
993
- Re,
1076
+ /* @__PURE__ */ N("div", { className: "nice-money-input__row", style: Je, children: [
1077
+ !o && /* @__PURE__ */ s(
1078
+ qe,
994
1079
  {
995
- value: w,
1080
+ value: C,
996
1081
  compact: !0,
997
- options: a ? a.map(L).filter((U) => !!U) : void 0,
998
- onChange: (U) => c == null ? void 0 : c(U),
999
- disabled: $ || B,
1082
+ options: a ? a.map(V).filter(($) => !!$) : void 0,
1083
+ onChange: ($) => r == null ? void 0 : r($),
1084
+ disabled: ee || w,
1000
1085
  className: "nice-money-input__currency",
1001
1086
  "aria-label": "Currency"
1002
1087
  }
1003
1088
  ),
1004
- o && /* @__PURE__ */ i("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (k == null ? void 0 : k.symbol) ?? w }),
1005
- O && /* @__PURE__ */ i(
1089
+ o && /* @__PURE__ */ s("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (ce == null ? void 0 : ce.symbol) ?? C }),
1090
+ J && /* @__PURE__ */ s(
1006
1091
  "button",
1007
1092
  {
1008
1093
  type: "button",
1009
1094
  className: "nice-money-input__step nice-money-input__step--down",
1010
- onClick: () => Ne(-S),
1011
- disabled: $ || B || u != null && e != null && e.amount / Math.pow(10, p) <= u,
1095
+ onClick: () => Re(-xe),
1096
+ disabled: ee || w || i != null && e != null && e.amount / Math.pow(10, G) <= i,
1012
1097
  "aria-label": "Decrease amount",
1013
1098
  tabIndex: -1,
1014
1099
  children: "−"
1015
1100
  }
1016
1101
  ),
1017
- /* @__PURE__ */ i(
1102
+ /* @__PURE__ */ s(
1018
1103
  "input",
1019
1104
  {
1020
- id: g,
1021
- name: K,
1105
+ id: D,
1106
+ name: se,
1022
1107
  type: "text",
1023
1108
  inputMode: "decimal",
1024
1109
  autoComplete: "transaction-amount",
1025
1110
  className: "nice-money-input__amount",
1026
- value: oe,
1027
- onChange: Ee,
1028
- onKeyDown: Fe,
1029
- onFocus: (U) => {
1030
- be(!0), C == null || C(U);
1111
+ value: ze,
1112
+ onChange: je,
1113
+ onKeyDown: Ye,
1114
+ onFocus: ($) => {
1115
+ Se(!0), U == null || U($);
1031
1116
  },
1032
- onBlur: (U) => {
1033
- be(!1), e && le((e.amount / Math.pow(10, p)).toFixed(p)), Y == null || Y(U);
1117
+ onBlur: ($) => {
1118
+ Se(!1), e && he((e.amount / Math.pow(10, G)).toFixed(G)), H == null || H($);
1034
1119
  },
1035
- placeholder: h ?? `0${p > 0 ? "." + "0".repeat(p) : ""}`,
1036
- disabled: $,
1037
- readOnly: B,
1038
- required: j,
1039
- "aria-invalid": !!ae,
1040
- "aria-describedby": ae || d ? `${g}-help` : void 0
1120
+ placeholder: b ?? `0${G > 0 ? "." + "0".repeat(G) : ""}`,
1121
+ disabled: ee,
1122
+ readOnly: w,
1123
+ required: S,
1124
+ "aria-invalid": !!pe,
1125
+ "aria-describedby": pe || d ? `${D}-help` : void 0
1041
1126
  }
1042
1127
  ),
1043
- O && /* @__PURE__ */ i(
1128
+ J && /* @__PURE__ */ s(
1044
1129
  "button",
1045
1130
  {
1046
1131
  type: "button",
1047
1132
  className: "nice-money-input__step nice-money-input__step--up",
1048
- onClick: () => Ne(S),
1049
- disabled: $ || B || l != null && e != null && e.amount / Math.pow(10, p) >= l,
1133
+ onClick: () => Re(xe),
1134
+ disabled: ee || w || l != null && e != null && e.amount / Math.pow(10, G) >= l,
1050
1135
  "aria-label": "Increase amount",
1051
1136
  tabIndex: -1,
1052
1137
  children: "+"
1053
1138
  }
1054
1139
  ),
1055
- I && /* @__PURE__ */ i("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: "⟳" })
1140
+ g && /* @__PURE__ */ s("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: "⟳" })
1056
1141
  ] }),
1057
- V && ge && /* @__PURE__ */ i("span", { className: "nice-money-input__preview", "aria-live": "polite", children: ge }),
1058
- (ae || d) && /* @__PURE__ */ i(
1142
+ E && Pe && /* @__PURE__ */ s("span", { className: "nice-money-input__preview", "aria-live": "polite", children: Pe }),
1143
+ (pe || d) && /* @__PURE__ */ s(
1059
1144
  "span",
1060
1145
  {
1061
- id: `${g}-help`,
1062
- className: ae ? "nice-money-input__error" : "nice-money-input__helper",
1063
- children: ae ?? d
1146
+ id: `${D}-help`,
1147
+ className: pe ? "nice-money-input__error" : "nice-money-input__helper",
1148
+ children: pe ?? d
1064
1149
  }
1065
1150
  )
1066
1151
  ] });
1067
1152
  }
1068
- ), ln = { number: "", expiry: "", cvc: "" }, un = te(
1153
+ ), Ut = { number: "", expiry: "", cvc: "" }, Rt = de(
1069
1154
  function({
1070
- value: e = ln,
1155
+ value: e = Ut,
1071
1156
  onChange: n,
1072
- showHolderName: t = !0,
1073
- requireHolderName: c,
1157
+ showHolderName: c = !0,
1158
+ requireHolderName: r,
1074
1159
  showPostalCode: a = !1,
1075
1160
  acceptedBrands: o,
1076
- showBrandIcon: u = !0,
1161
+ showBrandIcon: i = !0,
1077
1162
  size: l = "md",
1078
- disabled: s,
1079
- readOnly: y,
1080
- loading: h,
1081
- accessMode: m,
1163
+ disabled: u,
1164
+ readOnly: m,
1165
+ loading: b,
1166
+ accessMode: p,
1082
1167
  label: d,
1083
- helperText: b,
1084
- error: _,
1085
- required: f,
1086
- className: H,
1087
- style: j,
1088
- id: I,
1089
- title: F,
1090
- "data-testid": Q
1091
- }, X) {
1092
- if (m === "hidden")
1093
- return null;
1094
- const A = s || m === "disabled" || h, M = y || m === "readOnly", ne = ye(), x = I ?? `nice-cc-${ne}`, [V, O] = E({
1168
+ helperText: f,
1169
+ error: h,
1170
+ required: y,
1171
+ className: _,
1172
+ style: S,
1173
+ id: g,
1174
+ title: v,
1175
+ "data-testid": O
1176
+ }, Y) {
1177
+ const Z = p === "hidden", R = u || p === "disabled" || b, q = m || p === "readOnly", ne = Ce(), E = g ?? `nice-cc-${ne}`, [J, z] = B({
1095
1178
  number: !1,
1096
1179
  expiry: !1,
1097
1180
  cvc: !1,
1098
1181
  holder: !1,
1099
1182
  postal: !1
1100
- }), v = P(() => de(e.number), [e.number]), q = P(
1101
- () => we(e, { requireHolder: c ?? t }),
1102
- [e, c, t]
1103
- ), W = !o || o.includes(v) || v === "unknown", K = R(
1104
- (g) => {
1105
- const w = { ...e, ...g }, k = we(w, { requireHolder: c ?? t });
1106
- n == null || n(w, k);
1183
+ }), P = k(() => Ne(e.number), [e.number]), X = k(
1184
+ () => Ie(e, { requireHolder: r ?? c }),
1185
+ [e, r, c]
1186
+ ), se = !o || o.includes(P) || P === "unknown", A = F(
1187
+ (w) => {
1188
+ const I = { ...e, ...w }, re = Ie(I, { requireHolder: r ?? c });
1189
+ n == null || n(I, re);
1107
1190
  },
1108
- [e, c, t, n]
1109
- ), z = R(
1110
- (g) => {
1111
- const w = g.target.value.replace(/\D/g, "").slice(0, 19);
1112
- K({ number: w });
1191
+ [e, r, c, n]
1192
+ ), oe = F(
1193
+ (w) => {
1194
+ const I = w.target.value.replace(/\D/g, "").slice(0, 19);
1195
+ A({ number: I });
1113
1196
  },
1114
- [K]
1115
- ), Z = R(
1116
- (g) => {
1117
- const w = g.target.value.replace(/\D/g, "").slice(0, 4);
1118
- let k = w;
1119
- w.length >= 3 ? k = `${w.slice(0, 2)}/${w.slice(2)}` : w.length === 2 && (k = `${w}/`), K({ expiry: k });
1197
+ [A]
1198
+ ), H = F(
1199
+ (w) => {
1200
+ const I = w.target.value.replace(/\D/g, "").slice(0, 4);
1201
+ let re = I;
1202
+ I.length >= 3 ? re = `${I.slice(0, 2)}/${I.slice(2)}` : I.length === 2 && (re = `${I}/`), A({ expiry: re });
1120
1203
  },
1121
- [K]
1122
- ), Y = R(
1123
- (g) => {
1124
- const w = g.target.value.replace(/\D/g, "").slice(0, ie(v));
1125
- K({ cvc: w });
1204
+ [A]
1205
+ ), U = F(
1206
+ (w) => {
1207
+ const I = w.target.value.replace(/\D/g, "").slice(0, ye(P));
1208
+ A({ cvc: I });
1126
1209
  },
1127
- [v, K]
1128
- ), C = P(() => Ge(e.number, v), [e.number, v]), D = V.number && e.number.length > 0 && (Se(e.number) ? W ? void 0 : "Card brand not accepted" : q.errors.number), $ = V.expiry && e.expiry.length > 0 && !xe(e.expiry) ? q.errors.expiry : void 0, B = V.cvc && e.cvc.length > 0 && e.cvc.length !== ie(v) ? q.errors.cvc : void 0, ce = `nice-credit-card nice-credit-card--${l}` + (A ? " nice-credit-card--disabled" : "") + (h ? " nice-credit-card--loading" : "") + (_ ? " nice-credit-card--error" : "") + (H ? ` ${H}` : "");
1129
- return /* @__PURE__ */ N("div", { ref: X, className: ce, style: j, title: F, "data-testid": Q, children: [
1210
+ [P, A]
1211
+ ), M = k(() => ct(e.number, P), [e.number, P]), T = J.number && e.number.length > 0 && (Be(e.number) ? se ? void 0 : "Card brand not accepted" : X.errors.number), x = J.expiry && e.expiry.length > 0 && !Le(e.expiry) ? X.errors.expiry : void 0, le = J.cvc && e.cvc.length > 0 && e.cvc.length !== ye(P) ? X.errors.cvc : void 0, ee = `nice-credit-card nice-credit-card--${l}` + (R ? " nice-credit-card--disabled" : "") + (b ? " nice-credit-card--loading" : "") + (h ? " nice-credit-card--error" : "") + (_ ? ` ${_}` : "");
1212
+ return Z ? null : /* @__PURE__ */ N("div", { ref: Y, className: ee, style: S, title: v, "data-testid": O, children: [
1130
1213
  d && /* @__PURE__ */ N("div", { className: "nice-credit-card__title", children: [
1131
1214
  d,
1132
- f && /* @__PURE__ */ i("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
1215
+ y && /* @__PURE__ */ s("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
1133
1216
  ] }),
1134
- /* @__PURE__ */ i("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
1135
- /* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Card number" }),
1217
+ /* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
1218
+ /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Card number" }),
1136
1219
  /* @__PURE__ */ N("span", { className: "nice-credit-card__input-wrapper", children: [
1137
- /* @__PURE__ */ i(
1220
+ /* @__PURE__ */ s(
1138
1221
  "input",
1139
1222
  {
1140
- id: `${x}-number`,
1223
+ id: `${E}-number`,
1141
1224
  type: "text",
1142
1225
  inputMode: "numeric",
1143
1226
  autoComplete: "cc-number",
1144
- placeholder: v === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
1145
- value: C,
1146
- onChange: z,
1147
- onBlur: () => O((g) => ({ ...g, number: !0 })),
1148
- disabled: A,
1149
- readOnly: M,
1150
- "aria-invalid": !!D,
1151
- "aria-describedby": D ? `${x}-number-err` : void 0,
1227
+ placeholder: P === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
1228
+ value: M,
1229
+ onChange: oe,
1230
+ onBlur: () => z((w) => ({ ...w, number: !0 })),
1231
+ disabled: R,
1232
+ readOnly: q,
1233
+ "aria-invalid": !!T,
1234
+ "aria-describedby": T ? `${E}-number-err` : void 0,
1152
1235
  className: "nice-credit-card__input",
1153
- maxLength: v === "amex" ? 17 : 23
1236
+ maxLength: P === "amex" ? 17 : 23
1154
1237
  }
1155
1238
  ),
1156
- u && /* @__PURE__ */ i(dn, { brand: v })
1239
+ i && /* @__PURE__ */ s(Mt, { brand: P })
1157
1240
  ] }),
1158
- D && /* @__PURE__ */ i("span", { id: `${x}-number-err`, className: "nice-credit-card__error", children: D })
1241
+ T && /* @__PURE__ */ s("span", { id: `${E}-number-err`, className: "nice-credit-card__error", children: T })
1159
1242
  ] }) }),
1160
1243
  /* @__PURE__ */ N("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
1161
1244
  /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1162
- /* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Expiry" }),
1163
- /* @__PURE__ */ i(
1245
+ /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Expiry" }),
1246
+ /* @__PURE__ */ s(
1164
1247
  "input",
1165
1248
  {
1166
- id: `${x}-expiry`,
1249
+ id: `${E}-expiry`,
1167
1250
  type: "text",
1168
1251
  inputMode: "numeric",
1169
1252
  autoComplete: "cc-exp",
1170
1253
  placeholder: "MM/YY",
1171
1254
  value: e.expiry,
1172
- onChange: Z,
1255
+ onChange: H,
1173
1256
  onBlur: () => {
1174
- O((w) => ({ ...w, expiry: !0 }));
1175
- const g = Ue(e.expiry);
1176
- g && g !== e.expiry && K({ expiry: g });
1257
+ z((I) => ({ ...I, expiry: !0 }));
1258
+ const w = Te(e.expiry);
1259
+ w && w !== e.expiry && A({ expiry: w });
1177
1260
  },
1178
- disabled: A,
1179
- readOnly: M,
1180
- "aria-invalid": !!$,
1181
- "aria-describedby": $ ? `${x}-expiry-err` : void 0,
1261
+ disabled: R,
1262
+ readOnly: q,
1263
+ "aria-invalid": !!x,
1264
+ "aria-describedby": x ? `${E}-expiry-err` : void 0,
1182
1265
  className: "nice-credit-card__input",
1183
1266
  maxLength: 5
1184
1267
  }
1185
1268
  ),
1186
- $ && /* @__PURE__ */ i("span", { id: `${x}-expiry-err`, className: "nice-credit-card__error", children: $ })
1269
+ x && /* @__PURE__ */ s("span", { id: `${E}-expiry-err`, className: "nice-credit-card__error", children: x })
1187
1270
  ] }),
1188
1271
  /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1189
- /* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: v === "amex" ? "CID" : "CVC" }),
1190
- /* @__PURE__ */ i(
1272
+ /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: P === "amex" ? "CID" : "CVC" }),
1273
+ /* @__PURE__ */ s(
1191
1274
  "input",
1192
1275
  {
1193
- id: `${x}-cvc`,
1276
+ id: `${E}-cvc`,
1194
1277
  type: "text",
1195
1278
  inputMode: "numeric",
1196
1279
  autoComplete: "cc-csc",
1197
- placeholder: "•".repeat(ie(v)),
1280
+ placeholder: "•".repeat(ye(P)),
1198
1281
  value: e.cvc,
1199
- onChange: Y,
1200
- onBlur: () => O((g) => ({ ...g, cvc: !0 })),
1201
- disabled: A,
1202
- readOnly: M,
1203
- "aria-invalid": !!B,
1204
- "aria-describedby": B ? `${x}-cvc-err` : void 0,
1282
+ onChange: U,
1283
+ onBlur: () => z((w) => ({ ...w, cvc: !0 })),
1284
+ disabled: R,
1285
+ readOnly: q,
1286
+ "aria-invalid": !!le,
1287
+ "aria-describedby": le ? `${E}-cvc-err` : void 0,
1205
1288
  className: "nice-credit-card__input",
1206
- maxLength: ie(v)
1289
+ maxLength: ye(P)
1207
1290
  }
1208
1291
  ),
1209
- B && /* @__PURE__ */ i("span", { id: `${x}-cvc-err`, className: "nice-credit-card__error", children: B })
1292
+ le && /* @__PURE__ */ s("span", { id: `${E}-cvc-err`, className: "nice-credit-card__error", children: le })
1210
1293
  ] })
1211
1294
  ] }),
1212
- t && /* @__PURE__ */ i("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1213
- /* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Cardholder name" }),
1214
- /* @__PURE__ */ i(
1295
+ c && /* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1296
+ /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Cardholder name" }),
1297
+ /* @__PURE__ */ s(
1215
1298
  "input",
1216
1299
  {
1217
- id: `${x}-holder`,
1300
+ id: `${E}-holder`,
1218
1301
  type: "text",
1219
1302
  autoComplete: "cc-name",
1220
1303
  placeholder: "Jane Doe",
1221
1304
  value: e.holderName ?? "",
1222
- onChange: (g) => K({ holderName: g.target.value }),
1223
- onBlur: () => O((g) => ({ ...g, holder: !0 })),
1224
- disabled: A,
1225
- readOnly: M,
1305
+ onChange: (w) => A({ holderName: w.target.value }),
1306
+ onBlur: () => z((w) => ({ ...w, holder: !0 })),
1307
+ disabled: R,
1308
+ readOnly: q,
1226
1309
  className: "nice-credit-card__input",
1227
1310
  maxLength: 120
1228
1311
  }
1229
1312
  )
1230
1313
  ] }) }),
1231
- a && /* @__PURE__ */ i("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1232
- /* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Postal code" }),
1233
- /* @__PURE__ */ i(
1314
+ a && /* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
1315
+ /* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Postal code" }),
1316
+ /* @__PURE__ */ s(
1234
1317
  "input",
1235
1318
  {
1236
- id: `${x}-postal`,
1319
+ id: `${E}-postal`,
1237
1320
  type: "text",
1238
1321
  autoComplete: "postal-code",
1239
1322
  value: e.postalCode ?? "",
1240
- onChange: (g) => K({ postalCode: g.target.value }),
1241
- onBlur: () => O((g) => ({ ...g, postal: !0 })),
1242
- disabled: A,
1243
- readOnly: M,
1323
+ onChange: (w) => A({ postalCode: w.target.value }),
1324
+ onBlur: () => z((w) => ({ ...w, postal: !0 })),
1325
+ disabled: R,
1326
+ readOnly: q,
1244
1327
  className: "nice-credit-card__input",
1245
1328
  maxLength: 16
1246
1329
  }
1247
1330
  )
1248
1331
  ] }) }),
1249
- (_ || b) && /* @__PURE__ */ i(
1332
+ (h || f) && /* @__PURE__ */ s(
1250
1333
  "div",
1251
1334
  {
1252
- className: _ ? "nice-credit-card__form-error" : "nice-credit-card__helper",
1253
- role: _ ? "alert" : void 0,
1254
- children: _ ?? b
1335
+ className: h ? "nice-credit-card__form-error" : "nice-credit-card__helper",
1336
+ role: h ? "alert" : void 0,
1337
+ children: h ?? f
1255
1338
  }
1256
1339
  )
1257
1340
  ] });
1258
1341
  }
1259
- ), Ce = {
1342
+ ), Ee = {
1260
1343
  visa: "VISA",
1261
1344
  mastercard: "MasterCard",
1262
1345
  amex: "AMEX",
@@ -1270,305 +1353,406 @@ const De = te(function({
1270
1353
  hipercard: "Hipercard",
1271
1354
  unknown: ""
1272
1355
  };
1273
- function dn({ brand: r }) {
1274
- return r === "unknown" ? null : /* @__PURE__ */ i(
1356
+ function Mt({ brand: t }) {
1357
+ return t === "unknown" ? null : /* @__PURE__ */ s(
1275
1358
  "span",
1276
1359
  {
1277
- className: `nice-credit-card__brand nice-credit-card__brand--${r}`,
1278
- "aria-label": Ce[r],
1279
- children: Ce[r]
1360
+ className: `nice-credit-card__brand nice-credit-card__brand--${t}`,
1361
+ "aria-label": Ee[t],
1362
+ children: Ee[t]
1280
1363
  }
1281
1364
  );
1282
1365
  }
1283
- const Rn = te(
1366
+ const Jt = de(
1284
1367
  function({
1285
1368
  processor: e,
1286
1369
  amount: n,
1287
- editableAmount: t,
1288
- customer: c,
1370
+ editableAmount: c,
1371
+ customer: r,
1289
1372
  currencies: a,
1290
1373
  description: o,
1291
- metadata: u,
1374
+ metadata: i,
1292
1375
  autoCapture: l = !0,
1293
- submitLabel: s = "Pay",
1294
- onSuccess: y,
1295
- onError: h,
1296
- consents: m,
1376
+ submitLabel: u = "Pay",
1377
+ onSuccess: m,
1378
+ onError: b,
1379
+ consents: p,
1297
1380
  className: d,
1298
- style: b
1299
- }, _) {
1300
- const [f, H] = E(n), [j, I] = E(n.currency), [F, Q] = E({ number: "", expiry: "", cvc: "" }), [X, A] = E(null), [M, ne] = E(!1), [x, V] = E(null), O = on(e), v = P(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(f.currency.toUpperCase()), [e, f.currency]), q = P(() => {
1301
- var D;
1302
- const C = (D = e.minimums) == null ? void 0 : D[f.currency.toUpperCase()];
1303
- return C == null || f.amount >= C;
1304
- }, [e, f]), W = P(() => {
1305
- var D;
1306
- const C = (D = e.minimums) == null ? void 0 : D[f.currency.toUpperCase()];
1307
- return C == null ? null : { amount: C, currency: f.currency };
1308
- }, [e, f.currency]), K = !!(X != null && X.isValid), z = !M && v && q && K, Z = R(
1309
- async (C) => {
1310
- if (C.preventDefault(), !!z) {
1311
- V(null), ne(!0);
1381
+ style: f
1382
+ }, h) {
1383
+ const [y, _] = B(n), [S, g] = B(n.currency), [v, O] = B({ number: "", expiry: "", cvc: "" }), [Y, Z] = B(null), [R, q] = B(!1), [ne, E] = B(null), J = St(e), z = k(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(y.currency.toUpperCase()), [e, y.currency]), P = k(() => {
1384
+ var M;
1385
+ const U = (M = e.minimums) == null ? void 0 : M[y.currency.toUpperCase()];
1386
+ return U == null || y.amount >= U;
1387
+ }, [e, y]), X = k(() => {
1388
+ var M;
1389
+ const U = (M = e.minimums) == null ? void 0 : M[y.currency.toUpperCase()];
1390
+ return U == null ? null : { amount: U, currency: y.currency };
1391
+ }, [e, y.currency]), se = !!(Y != null && Y.isValid), A = !R && z && P && se, oe = F(
1392
+ async (U) => {
1393
+ if (U.preventDefault(), !!A) {
1394
+ E(null), q(!0);
1312
1395
  try {
1313
- const D = {
1314
- amount: f,
1315
- card: F,
1316
- customer: c,
1396
+ const M = {
1397
+ amount: y,
1398
+ card: v,
1399
+ customer: r,
1317
1400
  description: o,
1318
- metadata: u,
1319
- idempotencyKey: mn()
1320
- }, $ = await O.authorize(D);
1321
- if (l && $.status === "authorized") {
1322
- const B = await O.capture($.id, f);
1323
- y == null || y(B);
1401
+ metadata: i,
1402
+ idempotencyKey: Pt()
1403
+ }, T = await J.authorize(M);
1404
+ if (l && T.status === "authorized") {
1405
+ const x = await J.capture(T.id, y);
1406
+ m == null || m(x);
1324
1407
  } else
1325
- y == null || y($);
1326
- } catch (D) {
1327
- const $ = D instanceof Error ? D : new Error(String(D));
1328
- V($.message), h == null || h($);
1408
+ m == null || m(T);
1409
+ } catch (M) {
1410
+ const T = M instanceof Error ? M : new Error(String(M));
1411
+ E(T.message), b == null || b(T);
1329
1412
  } finally {
1330
- ne(!1);
1413
+ q(!1);
1331
1414
  }
1332
1415
  }
1333
1416
  },
1334
1417
  [
1335
- z,
1336
- f,
1337
- F,
1338
- c,
1418
+ A,
1419
+ y,
1420
+ v,
1421
+ r,
1339
1422
  o,
1340
- u,
1423
+ i,
1341
1424
  l,
1342
- O,
1343
- y,
1344
- h
1425
+ J,
1426
+ m,
1427
+ b
1345
1428
  ]
1346
- ), Y = L(f.currency);
1429
+ ), H = V(y.currency);
1347
1430
  return /* @__PURE__ */ N(
1348
1431
  "form",
1349
1432
  {
1350
- ref: _,
1433
+ ref: h,
1351
1434
  className: "nice-payment-form" + (d ? ` ${d}` : ""),
1352
- style: b,
1353
- onSubmit: Z,
1354
- "aria-busy": M,
1435
+ style: f,
1436
+ onSubmit: oe,
1437
+ "aria-busy": R,
1355
1438
  children: [
1356
- /* @__PURE__ */ i("div", { className: "nice-payment-form__amount", children: t ? /* @__PURE__ */ i(
1357
- Me,
1439
+ /* @__PURE__ */ s("div", { className: "nice-payment-form__amount", children: c ? /* @__PURE__ */ s(
1440
+ He,
1358
1441
  {
1359
1442
  label: "Amount",
1360
- value: f,
1361
- currency: j,
1443
+ value: y,
1444
+ currency: S,
1362
1445
  currencies: a,
1363
- onChange: (C) => C && H(C),
1364
- onCurrencyChange: (C) => {
1365
- I(C), H((D) => ({ ...D, currency: C }));
1446
+ onChange: (U) => U && _(U),
1447
+ onCurrencyChange: (U) => {
1448
+ g(U), _((M) => ({ ...M, currency: U }));
1366
1449
  },
1367
- disabled: M,
1450
+ disabled: R,
1368
1451
  required: !0,
1369
1452
  showFormattedPreview: !0
1370
1453
  }
1371
1454
  ) : /* @__PURE__ */ N("div", { className: "nice-payment-form__total", children: [
1372
- /* @__PURE__ */ i("span", { className: "nice-payment-form__total-label", children: "Total" }),
1373
- /* @__PURE__ */ i(De, { value: f })
1455
+ /* @__PURE__ */ s("span", { className: "nice-payment-form__total-label", children: "Total" }),
1456
+ /* @__PURE__ */ s(Fe, { value: y })
1374
1457
  ] }) }),
1375
- o && /* @__PURE__ */ i("p", { className: "nice-payment-form__description", children: o }),
1376
- /* @__PURE__ */ i("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ i(
1377
- un,
1458
+ o && /* @__PURE__ */ s("p", { className: "nice-payment-form__description", children: o }),
1459
+ /* @__PURE__ */ s("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ s(
1460
+ Rt,
1378
1461
  {
1379
- value: F,
1380
- onChange: (C, D) => {
1381
- Q(C), A(D);
1462
+ value: v,
1463
+ onChange: (U, M) => {
1464
+ O(U), Z(M);
1382
1465
  },
1383
- disabled: M
1466
+ disabled: R
1384
1467
  }
1385
1468
  ) }),
1386
- !v && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
1469
+ !z && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
1387
1470
  e.name,
1388
1471
  " does not accept ",
1389
- (Y == null ? void 0 : Y.name) ?? f.currency,
1472
+ (H == null ? void 0 : H.name) ?? y.currency,
1390
1473
  "."
1391
1474
  ] }),
1392
- !q && W && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
1475
+ !P && X && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
1393
1476
  "Minimum charge for ",
1394
1477
  e.name,
1395
1478
  " is ",
1396
- /* @__PURE__ */ i(De, { value: W }),
1479
+ /* @__PURE__ */ s(Fe, { value: X }),
1397
1480
  "."
1398
1481
  ] }),
1399
- m && /* @__PURE__ */ i("div", { className: "nice-payment-form__consents", children: m }),
1400
- x && /* @__PURE__ */ i("div", { className: "nice-payment-form__error", role: "alert", children: x }),
1401
- /* @__PURE__ */ i(
1482
+ p && /* @__PURE__ */ s("div", { className: "nice-payment-form__consents", children: p }),
1483
+ ne && /* @__PURE__ */ s("div", { className: "nice-payment-form__error", role: "alert", children: ne }),
1484
+ /* @__PURE__ */ s(
1402
1485
  "button",
1403
1486
  {
1404
1487
  type: "submit",
1405
1488
  className: "nice-payment-form__submit",
1406
- disabled: !z,
1407
- "aria-disabled": !z,
1408
- children: M ? "Processing…" : s
1489
+ disabled: !A,
1490
+ "aria-disabled": !A,
1491
+ children: R ? "Processing…" : u
1409
1492
  }
1410
1493
  ),
1411
1494
  /* @__PURE__ */ N("p", { className: "nice-payment-form__processor", children: [
1412
1495
  "Secured by ",
1413
- /* @__PURE__ */ i("strong", { children: e.name })
1496
+ /* @__PURE__ */ s("strong", { children: e.name })
1414
1497
  ] })
1415
1498
  ]
1416
1499
  }
1417
1500
  );
1418
1501
  }
1419
1502
  );
1420
- function mn() {
1503
+ function Pt() {
1421
1504
  return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
1422
1505
  }
1423
- const Mn = te(function({
1506
+ const Xt = de(function({
1424
1507
  price: e,
1425
1508
  originalPrice: n,
1426
- period: t,
1427
- prefix: c,
1509
+ period: c,
1510
+ prefix: r,
1428
1511
  suffix: a,
1429
1512
  showDiscountBadge: o = !0,
1430
- size: u = "md",
1513
+ size: i = "md",
1431
1514
  locale: l,
1432
- className: s,
1433
- style: y
1434
- }, h) {
1435
- const m = n && n.currency === e.currency && n.amount > e.amount, d = P(() => !m || !n ? null : Math.round((n.amount - e.amount) / n.amount * 100), [m, n, e.amount]), b = `nice-price-tag nice-price-tag--${u}` + (s ? ` ${s}` : "");
1436
- return /* @__PURE__ */ N("div", { ref: h, className: b, style: y, children: [
1437
- c && /* @__PURE__ */ i("span", { className: "nice-price-tag__prefix", children: c }),
1515
+ className: u,
1516
+ style: m
1517
+ }, b) {
1518
+ const p = n && n.currency === e.currency && n.amount > e.amount, d = k(() => !p || !n ? null : Math.round((n.amount - e.amount) / n.amount * 100), [p, n, e.amount]), f = `nice-price-tag nice-price-tag--${i}` + (u ? ` ${u}` : "");
1519
+ return /* @__PURE__ */ N("div", { ref: b, className: f, style: m, children: [
1520
+ r && /* @__PURE__ */ s("span", { className: "nice-price-tag__prefix", children: r }),
1438
1521
  /* @__PURE__ */ N("span", { className: "nice-price-tag__main", children: [
1439
- /* @__PURE__ */ i("span", { className: "nice-price-tag__amount", children: ee(e, { locale: l }) }),
1440
- t && /* @__PURE__ */ i("span", { className: "nice-price-tag__period", children: t })
1522
+ /* @__PURE__ */ s("span", { className: "nice-price-tag__amount", children: te(e, { locale: l }) }),
1523
+ c && /* @__PURE__ */ s("span", { className: "nice-price-tag__period", children: c })
1441
1524
  ] }),
1442
- m && n && /* @__PURE__ */ i("span", { className: "nice-price-tag__original", "aria-label": "Original price", children: /* @__PURE__ */ i("s", { children: ee(n, { locale: l }) }) }),
1443
- m && o && d != null && d > 0 && /* @__PURE__ */ N("span", { className: "nice-price-tag__discount", "aria-label": `${d} percent off`, children: [
1525
+ p && n && /* @__PURE__ */ s("span", { className: "nice-price-tag__original", "aria-label": "Original price", children: /* @__PURE__ */ s("s", { children: te(n, { locale: l }) }) }),
1526
+ p && o && d != null && d > 0 && /* @__PURE__ */ N("span", { className: "nice-price-tag__discount", "aria-label": `${d} percent off`, children: [
1444
1527
  "−",
1445
1528
  d,
1446
1529
  "%"
1447
1530
  ] }),
1448
- a && /* @__PURE__ */ i("span", { className: "nice-price-tag__suffix", children: a })
1531
+ a && /* @__PURE__ */ s("span", { className: "nice-price-tag__suffix", children: a })
1449
1532
  ] });
1450
- }), En = te(
1533
+ }), Qt = de(
1451
1534
  function({
1452
1535
  source: e,
1453
1536
  onSourceChange: n,
1454
- targetCurrency: t,
1455
- onTargetCurrencyChange: c,
1537
+ targetCurrency: c,
1538
+ onTargetCurrencyChange: r,
1456
1539
  provider: a,
1457
1540
  locale: o,
1458
- showRateLine: u = !0,
1541
+ showRateLine: i = !0,
1459
1542
  className: l,
1460
- style: s
1461
- }, y) {
1462
- const { converted: h, loading: m, error: d } = me(e, t, a), b = P(
1543
+ style: u
1544
+ }, m) {
1545
+ const { converted: b, loading: p, error: d } = ve(e, c, a), f = k(
1463
1546
  () => ({ amount: Math.pow(10, 2), currency: e.currency }),
1464
1547
  [e.currency]
1465
- ), { converted: _ } = me(
1466
- u ? b : null,
1467
- t,
1548
+ ), { converted: h } = ve(
1549
+ i ? f : null,
1550
+ c,
1468
1551
  a
1469
1552
  );
1470
1553
  return /* @__PURE__ */ N(
1471
1554
  "div",
1472
1555
  {
1473
- ref: y,
1556
+ ref: m,
1474
1557
  className: "nice-currency-converter" + (l ? ` ${l}` : ""),
1475
- style: s,
1558
+ style: u,
1476
1559
  children: [
1477
- /* @__PURE__ */ i("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ i(
1478
- Me,
1560
+ /* @__PURE__ */ s("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ s(
1561
+ He,
1479
1562
  {
1480
1563
  label: "From",
1481
1564
  value: e,
1482
- onChange: (f) => f && n(f),
1565
+ onChange: (y) => y && n(y),
1483
1566
  currency: e.currency,
1484
- onCurrencyChange: (f) => n({ ...e, currency: f }),
1567
+ onCurrencyChange: (y) => n({ ...e, currency: y }),
1485
1568
  showFormattedPreview: !1
1486
1569
  }
1487
1570
  ) }),
1488
1571
  /* @__PURE__ */ N("div", { className: "nice-currency-converter__row", children: [
1489
- /* @__PURE__ */ i("label", { className: "nice-currency-converter__label", children: "To" }),
1572
+ /* @__PURE__ */ s("label", { className: "nice-currency-converter__label", children: "To" }),
1490
1573
  /* @__PURE__ */ N("div", { className: "nice-currency-converter__output", children: [
1491
- /* @__PURE__ */ i(
1492
- Re,
1574
+ /* @__PURE__ */ s(
1575
+ qe,
1493
1576
  {
1494
- value: t,
1495
- onChange: (f) => c(f),
1577
+ value: c,
1578
+ onChange: (y) => r(y),
1496
1579
  compact: !0
1497
1580
  }
1498
1581
  ),
1499
- /* @__PURE__ */ i("span", { className: "nice-currency-converter__amount", children: m ? "…" : d ? "—" : h ? ee(h, { locale: o }) : "" })
1582
+ /* @__PURE__ */ s("span", { className: "nice-currency-converter__amount", children: p ? "…" : d ? "—" : b ? te(b, { locale: o }) : "" })
1500
1583
  ] })
1501
1584
  ] }),
1502
- u && _ && /* @__PURE__ */ N("p", { className: "nice-currency-converter__rate", children: [
1585
+ i && h && /* @__PURE__ */ N("p", { className: "nice-currency-converter__rate", children: [
1503
1586
  "1 ",
1504
1587
  e.currency,
1505
1588
  " = ",
1506
- ee(_, { locale: o }),
1589
+ te(h, { locale: o }),
1507
1590
  " ",
1508
1591
  /* @__PURE__ */ N("span", { className: "nice-currency-converter__inverse", children: [
1509
1592
  "· 1 ",
1510
- t,
1593
+ c,
1511
1594
  " =",
1512
1595
  " ",
1513
- ee(re(1 / $e(_), e.currency), { locale: o })
1596
+ te(W(1 / Ke(h), e.currency), { locale: o })
1514
1597
  ] })
1515
1598
  ] }),
1516
- d && /* @__PURE__ */ i("p", { className: "nice-currency-converter__error", role: "alert", children: d.message })
1599
+ d && /* @__PURE__ */ s("p", { className: "nice-currency-converter__error", role: "alert", children: d.message })
1600
+ ]
1601
+ }
1602
+ );
1603
+ }
1604
+ );
1605
+ function Ae(t) {
1606
+ return { amount: Math.round(t.amount), currency: t.currency };
1607
+ }
1608
+ const Vt = de(
1609
+ function({
1610
+ lines: e,
1611
+ locale: n,
1612
+ rounding: c = "line",
1613
+ showTotals: r = !0,
1614
+ showGrandTotal: a = !0,
1615
+ hideRateColumn: o = !1,
1616
+ labels: i,
1617
+ density: l = "comfortable",
1618
+ className: u,
1619
+ style: m,
1620
+ id: b
1621
+ }, p) {
1622
+ const d = {
1623
+ label: (i == null ? void 0 : i.label) ?? "Item",
1624
+ rate: (i == null ? void 0 : i.rate) ?? "VAT",
1625
+ net: (i == null ? void 0 : i.net) ?? "Net",
1626
+ vat: (i == null ? void 0 : i.vat) ?? "Tax",
1627
+ gross: (i == null ? void 0 : i.gross) ?? "Gross",
1628
+ total: (i == null ? void 0 : i.total) ?? "Total"
1629
+ }, f = k(() => {
1630
+ if (c === "total") {
1631
+ const _ = /* @__PURE__ */ new Map();
1632
+ for (const g of e) {
1633
+ let v = _.get(g.vatRate);
1634
+ v || (v = [], _.set(g.vatRate, v)), v.push(g.netAmount);
1635
+ }
1636
+ const S = [];
1637
+ for (const [g, v] of _) {
1638
+ const O = v.reduce((R, q) => me(R, q), W(0, v[0].currency)), Y = Ae(De(O, g)), Z = me(O, Y);
1639
+ S.push({ rate: g, net: O, vat: Y, gross: Z });
1640
+ }
1641
+ return S;
1642
+ }
1643
+ return e.map((_) => {
1644
+ const S = Ae(De(_.netAmount, _.vatRate)), g = me(_.netAmount, S);
1645
+ return { label: _.label, rate: _.vatRate, net: _.netAmount, vat: S, gross: g };
1646
+ });
1647
+ }, [e, c]), h = k(() => {
1648
+ if (f.length === 0)
1649
+ return null;
1650
+ const _ = f[0].net.currency;
1651
+ let S = W(0, _), g = W(0, _), v = W(0, _);
1652
+ for (const O of f)
1653
+ S = me(S, O.net), g = me(g, O.vat), v = me(v, O.gross);
1654
+ return { net: S, vat: g, gross: v };
1655
+ }, [f]), y = (_) => te(_, { locale: n });
1656
+ return /* @__PURE__ */ N(
1657
+ "table",
1658
+ {
1659
+ ref: p,
1660
+ id: b,
1661
+ className: `nice-tax-breakdown nice-tax-breakdown--${l} ${u ?? ""}`,
1662
+ style: m,
1663
+ role: "table",
1664
+ "aria-label": d.total,
1665
+ children: [
1666
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ N("tr", { children: [
1667
+ f.some((_) => _.label !== void 0) && /* @__PURE__ */ s("th", { scope: "col", children: d.label }),
1668
+ !o && /* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__rate", children: d.rate }),
1669
+ /* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.net }),
1670
+ /* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.vat }),
1671
+ /* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.gross })
1672
+ ] }) }),
1673
+ /* @__PURE__ */ s("tbody", { children: f.map((_, S) => /* @__PURE__ */ N("tr", { children: [
1674
+ f.some((g) => g.label !== void 0) && /* @__PURE__ */ s("td", { children: _.label ?? "" }),
1675
+ !o && /* @__PURE__ */ N("td", { className: "nice-tax-breakdown__rate", children: [
1676
+ (_.rate * 100).toLocaleString(n, { maximumFractionDigits: 2 }),
1677
+ "%"
1678
+ ] }),
1679
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.net) }),
1680
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.vat) }),
1681
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.gross) })
1682
+ ] }, `${_.rate}-${S}`)) }),
1683
+ r && h && /* @__PURE__ */ s("tfoot", { children: a && /* @__PURE__ */ N("tr", { className: "nice-tax-breakdown__totals", children: [
1684
+ f.some((_) => _.label !== void 0) && /* @__PURE__ */ s("td", { children: d.total }),
1685
+ !o && /* @__PURE__ */ s("td", {}),
1686
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.net) }),
1687
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.vat) }),
1688
+ /* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.gross) })
1689
+ ] }) })
1517
1690
  ]
1518
1691
  }
1519
1692
  );
1520
1693
  }
1521
1694
  );
1522
1695
  export {
1523
- $n as ExchangeRateHostProvider,
1524
- Cn as FrankfurterProvider,
1525
- Ze as MockPaymentProcessor,
1526
- se as NICE_CURRENCY_CATALOG,
1527
- xn as NICE_CURRENCY_CODES,
1528
- Sn as NICE_PAYMENT_PROCESSORS,
1529
- un as NiceCreditCardInput,
1530
- En as NiceCurrencyConverter,
1531
- Re as NiceCurrencySelector,
1532
- De as NiceMoney,
1533
- Me as NiceMoneyInput,
1534
- Rn as NicePaymentForm,
1535
- Mn as NicePriceTag,
1536
- vn as OpenExchangeRatesProvider,
1537
- Dn as StaticExchangeRateProvider,
1538
- He as addMoney,
1539
- bn as compareMoney,
1540
- Ve as convertMoney,
1541
- de as detectCardBrand,
1542
- ie as expectedCvcLength,
1543
- L as findCurrency,
1544
- Ge as formatCardNumber,
1545
- ee as formatMoney,
1546
- $e as fromMoney,
1547
- xe as isExpiryValid,
1548
- Nn as isNegative,
1549
- _n as isZero,
1550
- Se as luhnCheck,
1551
- Xe as makeAdyenAdapter,
1552
- nn as makeBraintreeAdapter,
1553
- sn as makeCoinbaseCommerceAdapter,
1554
- an as makeKlarnaAdapter,
1555
- en as makeMollieAdapter,
1556
- Qe as makePayPalAdapter,
1557
- tn as makePayUAdapter,
1558
- cn as makePrzelewy24Adapter,
1559
- rn as makeRazorpayAdapter,
1560
- We as makeSquareAdapter,
1561
- Je as makeStripeAdapter,
1562
- wn as maskCardNumber,
1563
- ze as multiplyMoney,
1564
- gn as negateMoney,
1565
- Ue as normaliseExpiry,
1566
- Ye as parseMoney,
1567
- fn as registerCurrency,
1568
- je as subtractMoney,
1569
- re as toMoney,
1570
- me as useNiceExchangeRate,
1571
- Un as useNiceMoney,
1572
- on as useNicePayment,
1573
- we as validateCreditCard
1696
+ lt as EcbRatesProvider,
1697
+ st as ExchangeRateHostProvider,
1698
+ at as FrankfurterProvider,
1699
+ ut as FreeForexApiProvider,
1700
+ mt as MockPaymentProcessor,
1701
+ fe as NICE_CURRENCY_CATALOG,
1702
+ Zt as NICE_CURRENCY_CODES,
1703
+ Gt as NICE_PAYMENT_PROCESSORS,
1704
+ ot as NbpRatesProvider,
1705
+ Rt as NiceCreditCardInput,
1706
+ Qt as NiceCurrencyConverter,
1707
+ qe as NiceCurrencySelector,
1708
+ Fe as NiceMoney,
1709
+ He as NiceMoneyInput,
1710
+ Jt as NicePaymentForm,
1711
+ Xt as NicePriceTag,
1712
+ Vt as NiceTaxBreakdown,
1713
+ it as OpenExchangeRatesProvider,
1714
+ Lt as StaticExchangeRateProvider,
1715
+ me as addMoney,
1716
+ At as compareMoney,
1717
+ dt as convertMoney,
1718
+ Ht as createEcbRatesProvider,
1719
+ zt as createFreeForexApiProvider,
1720
+ qt as createNbpRatesProvider,
1721
+ jt as createOpenExchangeRatesProvider,
1722
+ Ne as detectCardBrand,
1723
+ ye as expectedCvcLength,
1724
+ V as findCurrency,
1725
+ ct as formatCardNumber,
1726
+ te as formatMoney,
1727
+ Ke as fromMoney,
1728
+ Le as isExpiryValid,
1729
+ Kt as isNegative,
1730
+ Ot as isZero,
1731
+ Be as luhnCheck,
1732
+ ft as makeAdyenAdapter,
1733
+ vt as makeAutopayAdapter,
1734
+ Ct as makeBlikAdapter,
1735
+ _t as makeBraintreeAdapter,
1736
+ xt as makeCoinbaseCommerceAdapter,
1737
+ $t as makeKlarnaAdapter,
1738
+ bt as makeMollieAdapter,
1739
+ yt as makePayPalAdapter,
1740
+ gt as makePayUAdapter,
1741
+ wt as makePrzelewy24Adapter,
1742
+ Nt as makeRazorpayAdapter,
1743
+ ht as makeSquareAdapter,
1744
+ pt as makeStripeAdapter,
1745
+ Dt as makeTpayAdapter,
1746
+ Tt as maskCardNumber,
1747
+ De as multiplyMoney,
1748
+ Bt as negateMoney,
1749
+ Te as normaliseExpiry,
1750
+ rt as parseMoney,
1751
+ Et as registerCurrency,
1752
+ nt as subtractMoney,
1753
+ W as toMoney,
1754
+ ve as useNiceExchangeRate,
1755
+ Yt as useNiceMoney,
1756
+ St as useNicePayment,
1757
+ Ie as validateCreditCard
1574
1758
  };