@nice2dev/ui-money 1.1.7 → 1.1.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,64 @@
1
1
  # @nice2dev/ui-money
2
2
 
3
+ ## 1.1.10
4
+
5
+ ### Patch Changes
6
+
7
+ - The package description on npm shows a dash instead of the mis-encoded "—".
8
+
9
+ ## 1.1.9
10
+
11
+ ### Patch Changes
12
+
13
+ - 1.1.9 — themes reach the controls again, every control has a rendered demo, no breaking changes.
14
+
15
+ **Theming.** `NiceThemeProvider`, `applyTheme` and `NiceThemePreview` write the `--nice-*` tokens
16
+ again, so a theme recolours the controls and not only the app's own CSS — since 1.1.7 only
17
+ light/dark switched. The provider's scope wins over values set on `:root`, as it did before 1.1.7:
18
+ put a brand colour into the theme rather than on `<html>`. Alias tokens are computed in the theme
19
+ scope, not only on `:root`. About 1,600 places that used a text token as a background or border, or
20
+ a surface token as text colour, now use the token of the right role. `--nice-warning-light` and
21
+ `--nice-danger-light` are the light shade of the status colour, like `--nice-success-light`
22
+ (new: `--nice-color-warning-light`, `--nice-color-error-light`); backgrounds use `--nice-*-bg`.
23
+
24
+ **Styles that never shipped.** Six stylesheets in `@nice2dev/ui` were unreachable from its entry
25
+ point, so `NiceLiveDataGrid`, `NiceTaskInbox`, `NiceBPMNDesigner`, `NiceInstanceMonitor`,
26
+ `NiceIntegrationHub`, `NiceRulesEngine` and `NiceVideoEditor` rendered unstyled; eleven more
27
+ components had no stylesheet at all; `workflow.css` read its spacing scale as pixels; and
28
+ `NiceModuleGrid` was styled for a `<table>` it does not render.
29
+
30
+ **Language.** `useNiceTranslation()` returns `{ t, lang }` and dates are formatted in the interface
31
+ language rather than the browser's (`ui-presentations` adds `useNiceLang()`). `NiceInvoiceLineEditor`
32
+ takes its currency and units from the active language unless you pass them. `NiceAuditLog`,
33
+ `NiceRecordingPanel`, the four game-engine editors and `NiceTemplateEditor` are translated, the
34
+ game-engine dictionary is actually registered, and 136 ui-audio strings have English defaults
35
+ instead of rendering raw keys.
36
+
37
+ **Canvas and document colours.** Canvas never resolves `var()`: the QR and barcode generators drew a
38
+ black rectangle, the whiteboard lost its colours and light presets parsed to `NaN`. Data colours are
39
+ resolved first now. Colours stored in documents — slide templates, theme presets, brand kits,
40
+ exports — are literals, so a saved document looks the same in every theme.
41
+
42
+ **Fixes found by the new demos.** All 895 controls now have a rendered showcase demo, and roughly
43
+ every third new demo exposed a bug. `ui-platform`: the service worker re-registered on every
44
+ render, a screen permission prompt appeared on mount, reconnects and start-up tasks ran twice,
45
+ valid EAN-13 codes were rejected. `ui-ai`: `createProviderFromConfig` dropped the endpoint path —
46
+ OpenAI, Anthropic and Groq were called without `/v1` and Azure always threw — and the theme
47
+ generator failed on every request. `ui-communication`: the local participant appeared twice in a
48
+ conference and `activeConversationId` was ignored. `ui-buildings`: automation days were saved as
49
+ indices (both forms are read now), the row toggle changed the selected rule instead of the clicked
50
+ one, and floor-plan devices were drawn in the corner. `ui-mobile`: `NiceTouchTable` rendered invalid
51
+ table markup. `ui-diagrams`: arrowheads grew with the stroke width and transition clicks never fired.
52
+ `ui-3d`: opening a code editor before the 3D view broke the whole app. `ui-presentations`: the editor
53
+ clipped slides in columns narrower than 800 px.
54
+
55
+ **Additive API only.** `@nice2dev/ui-platform` now exports its hooks, provider aliases and Props / Ref
56
+ types. Nothing was renamed or removed.
57
+
58
+ ## 1.1.8
59
+
60
+ No changes in this release.
61
+
3
62
  ## 1.1.7
4
63
 
5
64
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var vt=Object.defineProperty;var kt=(t,e,r)=>e in t?vt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var H=(t,e,r)=>kt(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),n=require("react/jsx-runtime"),me=require("@nice2dev/ui-core"),de=[{code:"USD",numeric:840,symbol:"$",name:"US Dollar",decimals:2,symbolFirst:!0},{code:"EUR",numeric:978,symbol:"€",name:"Euro",decimals:2,symbolFirst:!0},{code:"GBP",numeric:826,symbol:"£",name:"Pound Sterling",decimals:2,symbolFirst:!0},{code:"JPY",numeric:392,symbol:"¥",name:"Japanese Yen",decimals:0,symbolFirst:!0},{code:"CHF",numeric:756,symbol:"Fr",name:"Swiss Franc",decimals:2},{code:"CAD",numeric:124,symbol:"CA$",name:"Canadian Dollar",decimals:2,symbolFirst:!0},{code:"AUD",numeric:36,symbol:"A$",name:"Australian Dollar",decimals:2,symbolFirst:!0},{code:"NZD",numeric:554,symbol:"NZ$",name:"New Zealand Dollar",decimals:2,symbolFirst:!0},{code:"CNY",numeric:156,symbol:"¥",name:"Chinese Yuan Renminbi",decimals:2,symbolFirst:!0},{code:"HKD",numeric:344,symbol:"HK$",name:"Hong Kong Dollar",decimals:2,symbolFirst:!0},{code:"SGD",numeric:702,symbol:"S$",name:"Singapore Dollar",decimals:2,symbolFirst:!0},{code:"PLN",numeric:985,symbol:"zł",name:"Polish Złoty",decimals:2},{code:"CZK",numeric:203,symbol:"Kč",name:"Czech Koruna",decimals:2},{code:"HUF",numeric:348,symbol:"Ft",name:"Hungarian Forint",decimals:2},{code:"RON",numeric:946,symbol:"lei",name:"Romanian Leu",decimals:2},{code:"BGN",numeric:975,symbol:"лв",name:"Bulgarian Lev",decimals:2},{code:"HRK",numeric:191,symbol:"kn",name:"Croatian Kuna",decimals:2},{code:"DKK",numeric:208,symbol:"kr",name:"Danish Krone",decimals:2},{code:"SEK",numeric:752,symbol:"kr",name:"Swedish Krona",decimals:2},{code:"NOK",numeric:578,symbol:"kr",name:"Norwegian Krone",decimals:2},{code:"ISK",numeric:352,symbol:"kr",name:"Icelandic Króna",decimals:0},{code:"RUB",numeric:643,symbol:"₽",name:"Russian Ruble",decimals:2},{code:"UAH",numeric:980,symbol:"₴",name:"Ukrainian Hryvnia",decimals:2},{code:"TRY",numeric:949,symbol:"₺",name:"Turkish Lira",decimals:2,symbolFirst:!0},{code:"MXN",numeric:484,symbol:"Mex$",name:"Mexican Peso",decimals:2,symbolFirst:!0},{code:"BRL",numeric:986,symbol:"R$",name:"Brazilian Real",decimals:2,symbolFirst:!0},{code:"ARS",numeric:32,symbol:"AR$",name:"Argentine Peso",decimals:2,symbolFirst:!0},{code:"CLP",numeric:152,symbol:"CL$",name:"Chilean Peso",decimals:0,symbolFirst:!0},{code:"COP",numeric:170,symbol:"CO$",name:"Colombian Peso",decimals:2,symbolFirst:!0},{code:"PEN",numeric:604,symbol:"S/",name:"Peruvian Sol",decimals:2,symbolFirst:!0},{code:"UYU",numeric:858,symbol:"$U",name:"Uruguayan Peso",decimals:2,symbolFirst:!0},{code:"INR",numeric:356,symbol:"₹",name:"Indian Rupee",decimals:2,symbolFirst:!0},{code:"IDR",numeric:360,symbol:"Rp",name:"Indonesian Rupiah",decimals:2,symbolFirst:!0},{code:"KRW",numeric:410,symbol:"₩",name:"South Korean Won",decimals:0,symbolFirst:!0},{code:"MYR",numeric:458,symbol:"RM",name:"Malaysian Ringgit",decimals:2,symbolFirst:!0},{code:"PHP",numeric:608,symbol:"₱",name:"Philippine Peso",decimals:2,symbolFirst:!0},{code:"THB",numeric:764,symbol:"฿",name:"Thai Baht",decimals:2,symbolFirst:!0},{code:"VND",numeric:704,symbol:"₫",name:"Vietnamese Đồng",decimals:0},{code:"TWD",numeric:901,symbol:"NT$",name:"New Taiwan Dollar",decimals:2,symbolFirst:!0},{code:"PKR",numeric:586,symbol:"₨",name:"Pakistani Rupee",decimals:2},{code:"BDT",numeric:50,symbol:"৳",name:"Bangladeshi Taka",decimals:2},{code:"LKR",numeric:144,symbol:"Rs",name:"Sri Lankan Rupee",decimals:2},{code:"AED",numeric:784,symbol:"د.إ",name:"UAE Dirham",decimals:2},{code:"SAR",numeric:682,symbol:"ر.س",name:"Saudi Riyal",decimals:2},{code:"QAR",numeric:634,symbol:"ر.ق",name:"Qatari Riyal",decimals:2},{code:"KWD",numeric:414,symbol:"د.ك",name:"Kuwaiti Dinar",decimals:3},{code:"BHD",numeric:48,symbol:".د.ب",name:"Bahraini Dinar",decimals:3},{code:"OMR",numeric:512,symbol:"ر.ع",name:"Omani Rial",decimals:3},{code:"JOD",numeric:400,symbol:"د.أ",name:"Jordanian Dinar",decimals:3},{code:"ILS",numeric:376,symbol:"₪",name:"Israeli New Shekel",decimals:2,symbolFirst:!0},{code:"EGP",numeric:818,symbol:"E£",name:"Egyptian Pound",decimals:2,symbolFirst:!0},{code:"ZAR",numeric:710,symbol:"R",name:"South African Rand",decimals:2,symbolFirst:!0},{code:"NGN",numeric:566,symbol:"₦",name:"Nigerian Naira",decimals:2,symbolFirst:!0},{code:"KES",numeric:404,symbol:"KSh",name:"Kenyan Shilling",decimals:2},{code:"GHS",numeric:936,symbol:"₵",name:"Ghanaian Cedi",decimals:2},{code:"MAD",numeric:504,symbol:"د.م.",name:"Moroccan Dirham",decimals:2},{code:"TND",numeric:788,symbol:"د.ت",name:"Tunisian Dinar",decimals:3},{code:"BTC",numeric:0,symbol:"₿",name:"Bitcoin",decimals:8,symbolFirst:!0},{code:"ETH",numeric:0,symbol:"Ξ",name:"Ether",decimals:8,symbolFirst:!0},{code:"USDC",numeric:0,symbol:"USDC",name:"USD Coin",decimals:6},{code:"USDT",numeric:0,symbol:"USDT",name:"Tether",decimals:6}],Fe=new Map(de.map(t=>[t.code,t]));function X(t){return Fe.get(t.toUpperCase())}function wt(t){Fe.set(t.code.toUpperCase(),t);const e=de.findIndex(r=>r.code===t.code);e>=0?de[e]=t:de.push(t)}function W(t,e){const r=X(e),c=(r==null?void 0:r.decimals)??2,a=Math.pow(10,c);return{amount:(t<0?-1:1)*Math.round(Math.abs(t)*a),currency:e.toUpperCase()}}function we(t){const e=X(t.currency),r=(e==null?void 0:e.decimals)??2;return t.amount/Math.pow(10,r)}function Ct(t,e){return t.currency.toUpperCase()===e.currency.toUpperCase()}function Ce(t,e,r){if(!Ct(t,e))throw new Error(`Cannot ${r} different currencies: ${t.currency} vs ${e.currency}`)}function oe(t,e){return Ce(t,e,"add"),{amount:t.amount+e.amount,currency:t.currency}}function Ke(t,e){return Ce(t,e,"subtract"),{amount:t.amount-e.amount,currency:t.currency}}function _e(t,e){return{amount:(t.amount*e<0?-1:1)*Math.round(Math.abs(t.amount*e)),currency:t.currency}}function jt(t,e){return Ce(t,e,"compare"),t.amount-e.amount}function Mt(t){return t.amount===0}function Pt(t){return t.amount<0}function St(t){return{amount:-t.amount,currency:t.currency}}function ee(t,e={}){const r=X(t.currency),c=e.decimals??(r==null?void 0:r.decimals)??2,a=t.amount/Math.pow(10,c);try{return new Intl.NumberFormat(e.locale,{style:"currency",currency:t.currency,minimumFractionDigits:c,maximumFractionDigits:c,currencyDisplay:e.currencyDisplay??"symbol"}).format(a)}catch{const s=(r==null?void 0:r.symbol)??t.currency,m=a.toFixed(c);return r!=null&&r.symbolFirst?`${s}${m}`:`${m} ${s}`}}function Be(t,e){if(!t)return null;let r=t.replace(/[^\d.,\-]/g,"").trim();if(!r||r==="-")return null;const c=r.startsWith("-");c&&(r=r.slice(1));const a=r.lastIndexOf("."),s=r.lastIndexOf(","),m=Math.max(a,s);let i,l="";m===-1?i=r:(i=r.slice(0,m).replace(/[.,]/g,""),l=r.slice(m+1).replace(/[.,]/g,""));const d=`${i}.${l||"0"}`,y=parseFloat(d);return Number.isFinite(y)?W(c?-y:y,e):null}function ye(t){const e=(t||"").replace(/\D/g,"");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"}function je(t){const e=(t||"").replace(/\D/g,"");if(e.length<12||e.length>19)return!1;let r=0,c=!1;for(let a=e.length-1;a>=0;a--){let s=e.charCodeAt(a)-48;c&&(s*=2,s>9&&(s-=9)),r+=s,c=!c}return r%10===0}function Le(t,e){const r=(t||"").replace(/\D/g,""),c=e??ye(r);return c==="amex"?[r.slice(0,4),r.slice(4,10),r.slice(10,15)].filter(Boolean).join(" "):c==="diners"?[r.slice(0,4),r.slice(4,10),r.slice(10,14)].filter(Boolean).join(" "):(r.match(/.{1,4}/g)??[]).join(" ").trim()}function Dt(t,e){const r=(t||"").replace(/\D/g,"");if(r.length<4)return r;const c=r.slice(-4),a="*".repeat(r.length-4)+c,s=e??ye(r);return s==="amex"?[a.slice(0,4),a.slice(4,10),a.slice(10,15)].filter(Boolean).join(" "):s==="diners"?[a.slice(0,4),a.slice(4,10),a.slice(10,14)].filter(Boolean).join(" "):(a.match(/.{1,4}/g)??[]).join(" ").trim()}function Me(t){const e=(t||"").replace(/\D/g,"");if(e.length<3)return null;const r=e.slice(0,2),c=e.length>=4?e.slice(-2):e.slice(2,4),a=parseInt(r,10);return!Number.isFinite(a)||a<1||a>12?null:`${r}/${c}`}function Pe(t,e=new Date){const r=Me(t);if(!r)return!1;const[c,a]=r.split("/"),s=parseInt(c,10),m=2e3+parseInt(a,10);return new Date(m,s,0,23,59,59,999).getTime()>=e.getTime()}function le(t){return t==="amex"?4:3}function ve(t,e={}){var d;const r={},c=ye(t.number),a=je(t.number);a||(r.number="Invalid card number");const s=Pe(t.expiry,e.now);s||(r.expiry="Invalid or expired");const i=(t.cvc||"").replace(/\D/g,"").length===le(c);i||(r.cvc=`CVC must be ${le(c)} digits`);const l=!e.requireHolder||(((d=t.holderName)==null?void 0:d.trim().length)??0)>=2;return l||(r.holderName="Cardholder name required"),{brand:c,numberValid:a,expiryValid:s,cvcValid:i,holderValid:l,isValid:a&&s&&i&&l,errors:r}}class It{constructor(e){H(this,"id","static");this.rates=e}async getRate(e,r){const c=e.toUpperCase(),a=r.toUpperCase();if(c===a)return{base:c,quote:a,rate:1,asOf:new Date().toISOString()};const s=this.rates.find(d=>d.base===c&&d.quote===a);if(s)return s;const m=this.rates.find(d=>d.base===a&&d.quote===c);if(m)return{base:c,quote:a,rate:1/m.rate,asOf:m.asOf};const i=this.rates.find(d=>d.base===c&&d.quote==="USD")??this.rates.find(d=>d.base==="USD"&&d.quote===c),l=this.rates.find(d=>d.base==="USD"&&d.quote===a)??this.rates.find(d=>d.base===a&&d.quote==="USD");if(i&&l){const d=i.base==="USD"?1/i.rate:i.rate,y=l.base==="USD"?l.rate:1/l.rate;return{base:c,quote:a,rate:d*y,asOf:new Date().toISOString()}}throw new Error(`No FX rate for ${c}/${a}`)}}class xe{constructor(e={}){H(this,"cache",new Map);H(this,"fetchImpl");H(this,"ttl");this.fetchImpl=e.fetchImpl??fetch,this.ttl=e.cacheTtl??6e4}cacheKey(e,r){return`${this.id}:${e.toUpperCase()}/${r.toUpperCase()}`}getCached(e,r){const c=this.cacheKey(e,r),a=this.cache.get(c);return a&&a.expires>Date.now()?a.rate:(a&&this.cache.delete(c),null)}setCached(e){this.cache.set(this.cacheKey(e.base,e.quote),{expires:Date.now()+this.ttl,rate:e})}}class He extends xe{constructor(r={}){super(r);H(this,"id","frankfurter")}async getRate(r,c){const a=r.toUpperCase(),s=c.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const m=this.getCached(a,s);if(m)return m;const i=`https://api.frankfurter.app/latest?from=${a}&to=${s}`,l=await this.fetchImpl(i);if(!l.ok)throw new Error(`Frankfurter HTTP ${l.status}`);const d=await l.json(),y=d.rates[s];if(y==null)throw new Error(`Frankfurter: no rate for ${a}/${s}`);const x={base:a,quote:s,rate:y,asOf:d.date};return this.setCached(x),x}}class ze extends xe{constructor(r,c={}){super(c);H(this,"id","openexchangerates");this.appId=r}async getRate(r,c){const a=r.toUpperCase(),s=c.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const m=this.getCached(a,s);if(m)return m;const i=`https://openexchangerates.org/api/latest.json?app_id=${this.appId}`,l=await this.fetchImpl(i);if(!l.ok)throw new Error(`OpenExchangeRates HTTP ${l.status}`);const d=await l.json(),y=d.rates[a],x=d.rates[s];if(y==null||x==null)throw new Error(`OpenExchangeRates: missing rate for ${a} or ${s}`);const h={base:a,quote:s,rate:x/y,asOf:new Date(d.timestamp*1e3).toISOString()};return this.setCached(h),h}}class Ye extends xe{constructor(r={}){super(r);H(this,"id","exchangerate.host")}async getRate(r,c){var h;const a=r.toUpperCase(),s=c.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const m=this.getCached(a,s);if(m)return m;const i=`https://api.exchangerate.host/convert?from=${a}&to=${s}`,l=await this.fetchImpl(i);if(!l.ok)throw new Error(`exchangerate.host HTTP ${l.status}`);const d=await l.json(),y=((h=d.info)==null?void 0:h.rate)??d.result,x={base:a,quote:s,rate:y,asOf:d.date};return this.setCached(x),x}}class Ge extends xe{constructor(r={}){super(r);H(this,"id","nbp");H(this,"table");this.table=r.table??"A"}async getRate(r,c){const a=r.toUpperCase(),s=c.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const m=this.getCached(a,s);if(m)return m;const i=async x=>{var _;if(x==="PLN")return{rate:1,date:new Date().toISOString().slice(0,10)};const h=`https://api.nbp.pl/api/exchangerates/rates/${this.table}/${x}/?format=json`,u=await this.fetchImpl(h);if(!u.ok)return null;const f=(_=(await u.json()).rates)==null?void 0:_[0];return f?{rate:f.mid??f.ask??0,date:f.effectiveDate}:null},l=await i(a),d=await i(s);if(!l||!d||l.rate===0)throw new Error(`NBP: missing rate for ${a} or ${s}`);const y={base:a,quote:s,rate:l.rate/d.rate,asOf:l.date};return this.setCached(y),y}}class Ze extends He{constructor(){super(...arguments);H(this,"id","ecb")}}class Je extends Ye{constructor(){super(...arguments);H(this,"id","free-forex")}}const Rt=(t={})=>new Ge(t),$t=(t={})=>new Ze(t),At=t=>new ze(t.apiKey,t),Ut=(t={})=>new Je(t);async function Ve(t,e,r){const c=e.toUpperCase();if(t.currency.toUpperCase()===c)return t;const a=X(t.currency),s=X(c),m=(a==null?void 0:a.decimals)??2,i=(s==null?void 0:s.decimals)??2,{rate:l}=await r.getRate(t.currency,c),y=t.amount/Math.pow(10,m)*l;return{currency:c,amount:Math.round(y*Math.pow(10,i))}}class Xe{constructor(e={}){H(this,"id");H(this,"name");H(this,"supportedCurrencies");H(this,"minimums");H(this,"counter",0);this.id=e.id??"mock",this.name=e.name??"Mock Processor",this.supportedCurrencies=e.supportedCurrencies??"*"}newId(e){return this.counter+=1,`${e}_${Date.now().toString(36)}_${this.counter}`}async authorize(e){return{id:this.newId("auth"),status:"authorized",processor:this.id,amount:e.amount,raw:{mock:!0,request:e}}}async capture(e,r){return{id:e.replace("auth_","cap_"),status:"captured",processor:this.id,amount:r}}async cancel(e){return{id:e,status:"cancelled",processor:this.id}}async refund(e,r){return{id:e.replace(/^[a-z]+_/,"ref_"),status:"refunded",processor:this.id,amount:r}}}function J(t,e,r,c,a){const s=m=>{const i=c==null?void 0:c[m];return i||(async()=>{throw new Error(`[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(m)}\` implementation that calls the ${e} SDK.`)})};return{id:t,name:e,supportedCurrencies:r,minimums:a,authorize:s("authorize"),capture:s("capture"),cancel:s("cancel"),refund:s("refund")}}function Qe(t){return J("stripe","Stripe","*",t,{USD:50,EUR:50,GBP:30,JPY:50,AUD:50,CAD:50,CHF:50,DKK:250,NOK:300,SEK:300,PLN:200})}function We(t){return J("paypal","PayPal",["USD","EUR","GBP","AUD","CAD","JPY","CHF","NZD","SEK","NOK","DKK","PLN","CZK","HUF","BRL","MXN","HKD","SGD","TWD","THB","PHP","ILS"],t)}function et(t){return J("adyen","Adyen","*",t)}function tt(t){return J("square","Square",["USD","CAD","GBP","AUD","JPY","EUR"],t)}function rt(t){return J("mollie","Mollie","*",t)}function nt(t){return J("braintree","Braintree","*",t)}function at(t){return J("razorpay","Razorpay",["INR","USD","EUR","GBP","AED"],t)}function ct(t){return J("payu","PayU",["PLN","EUR","USD","CZK","HUF","RON","BGN","TRY"],t)}function st(t){return J("przelewy24","Przelewy24",["PLN","EUR"],t)}function it(t={}){return J("tpay","Tpay",["PLN","EUR","USD","GBP"],t)}function ot(t={}){return J("autopay","Autopay",["PLN","EUR","USD","GBP","CZK"],t)}function lt(t={}){const{acquirer:e="native",...r}=t;return J(`blik:${e}`,`BLIK (${e})`,["PLN"],r)}function dt(t){return J("klarna","Klarna",["USD","EUR","GBP","SEK","NOK","DKK","CHF","AUD","CAD","NZD","PLN"],t)}function ut(t){return J("coinbase-commerce","Coinbase Commerce",["BTC","ETH","USDC","USDT","USD","EUR"],t)}const mt={mock:()=>new Xe,stripe:()=>Qe(),paypal:()=>We(),adyen:()=>et(),square:()=>tt(),mollie:()=>rt(),braintree:()=>nt(),razorpay:()=>at(),payu:()=>ct(),przelewy24:()=>st(),tpay:()=>it(),autopay:()=>ot(),blik:()=>lt(),klarna:()=>dt(),"coinbase-commerce":()=>ut()};function Et(t){const e=mt[t];return e?e().supportedCurrencies:"*"}function Tt(t){return`/api/payments/${t}/webhook`}const Ot=[{id:"stripe",name:"Stripe",type:"card",credentials:[{key:"apiKey",label:"Secret API key",secret:!0,required:!0,help:"sk_live_… / sk_test_…"},{key:"publishableKey",label:"Publishable key",required:!0,help:"pk_live_… / pk_test_…"},{key:"webhookSecret",label:"Webhook signing secret",secret:!0,help:"whsec_…"}],supportedMethods:["card","applepay","googlepay","link"],allowedDomains:["api.stripe.com"],hasTestMode:!0},{id:"paypal",name:"PayPal",type:"wallet",credentials:[{key:"clientId",label:"Client ID",required:!0},{key:"clientSecret",label:"Client secret",secret:!0,required:!0},{key:"webhookId",label:"Webhook ID"}],supportedMethods:["paypal","card","paylater"],allowedDomains:["api-m.paypal.com","api-m.sandbox.paypal.com"],hasTestMode:!0},{id:"adyen",name:"Adyen",type:"aggregator",credentials:[{key:"apiKey",label:"API key",secret:!0,required:!0},{key:"merchantAccount",label:"Merchant account",required:!0},{key:"hmacKey",label:"HMAC key (webhooks)",secret:!0},{key:"clientKey",label:"Client key"}],supportedMethods:["card","ideal","bancontact","applepay","googlepay"],allowedDomains:["checkout-test.adyen.com","checkout-live.adyen.com"],hasTestMode:!0},{id:"square",name:"Square",type:"card",credentials:[{key:"accessToken",label:"Access token",secret:!0,required:!0},{key:"applicationId",label:"Application ID",required:!0},{key:"locationId",label:"Location ID",required:!0}],supportedMethods:["card","applepay","googlepay"],allowedDomains:["connect.squareup.com","connect.squareupsandbox.com"],hasTestMode:!0},{id:"mollie",name:"Mollie",type:"aggregator",credentials:[{key:"apiKey",label:"API key",secret:!0,required:!0,help:"live_… / test_…"}],supportedMethods:["card","ideal","bancontact","blik","applepay"],allowedDomains:["api.mollie.com"],hasTestMode:!0},{id:"braintree",name:"Braintree",type:"card",credentials:[{key:"merchantId",label:"Merchant ID",required:!0},{key:"publicKey",label:"Public key",required:!0},{key:"privateKey",label:"Private key",secret:!0,required:!0}],supportedMethods:["card","paypal","applepay","googlepay"],allowedDomains:["api.braintreegateway.com","api.sandbox.braintreegateway.com"],hasTestMode:!0},{id:"razorpay",name:"Razorpay",type:"aggregator",credentials:[{key:"keyId",label:"Key ID",required:!0},{key:"keySecret",label:"Key secret",secret:!0,required:!0},{key:"webhookSecret",label:"Webhook secret",secret:!0}],supportedMethods:["card","upi","netbanking","wallet"],allowedDomains:["api.razorpay.com"],hasTestMode:!0},{id:"payu",name:"PayU",type:"aggregator",credentials:[{key:"posId",label:"POS ID",required:!0},{key:"clientId",label:"OAuth client ID",required:!0},{key:"clientSecret",label:"OAuth client secret",secret:!0,required:!0},{key:"secondKey",label:"Second key (MD5)",secret:!0}],supportedMethods:["card","blik","transfer","googlepay"],allowedDomains:["secure.payu.com","secure.snd.payu.com"],hasTestMode:!0},{id:"przelewy24",name:"Przelewy24",type:"bank",credentials:[{key:"merchantId",label:"Merchant ID",required:!0},{key:"posId",label:"POS ID",required:!0},{key:"crcKey",label:"CRC key",secret:!0,required:!0},{key:"apiKey",label:"API key",secret:!0,required:!0}],supportedMethods:["transfer","blik","card"],allowedDomains:["secure.przelewy24.pl","sandbox.przelewy24.pl"],hasTestMode:!0},{id:"tpay",name:"Tpay",type:"aggregator",credentials:[{key:"merchantId",label:"Merchant ID",required:!0},{key:"apiKey",label:"API key",secret:!0,required:!0},{key:"apiPassword",label:"API password",secret:!0,required:!0}],supportedMethods:["card","blik","transfer","applepay"],allowedDomains:["api.tpay.com","secure.tpay.com"],hasTestMode:!0},{id:"autopay",name:"Autopay",type:"aggregator",credentials:[{key:"serviceId",label:"Service ID",required:!0},{key:"sharedSecret",label:"Shared secret",secret:!0,required:!0}],supportedMethods:["card","blik","transfer"],allowedDomains:["pay.autopay.eu","testpay.autopay.eu"],hasTestMode:!0},{id:"blik",name:"BLIK",type:"bank",credentials:[{key:"acquirer",label:"Acquirer (p24 / tpay / payu / native)",required:!0,help:"Underlying acquirer routing BLIK."}],supportedMethods:["blik"],hasTestMode:!0},{id:"klarna",name:"Klarna",type:"bnpl",credentials:[{key:"username",label:"API username (UID)",required:!0},{key:"password",label:"API password",secret:!0,required:!0},{key:"region",label:"Region (eu / na / oc)",help:"Selects the Klarna API host."}],supportedMethods:["paylater","installments","paynow"],allowedDomains:["api.klarna.com","api.playground.klarna.com"],hasTestMode:!0},{id:"coinbase-commerce",name:"Coinbase Commerce",type:"crypto",credentials:[{key:"apiKey",label:"API key",secret:!0,required:!0},{key:"webhookSharedSecret",label:"Webhook shared secret",secret:!0}],supportedMethods:["crypto"],allowedDomains:["api.commerce.coinbase.com"],hasTestMode:!1},{id:"wallet",name:"In-app Wallet",type:"wallet",currencyKey:"mock",credentials:[{key:"ledgerAccount",label:"Ledger account",required:!0,help:"Account the wallet debits/credits."}],supportedMethods:["wallet"],hasTestMode:!0}],pe=Object.fromEntries(Ot.map(t=>{const{currencyKey:e,...r}=t,c={...r,supportedCurrencies:Et(e??t.id),webhookPath:Tt(t.id)};return[t.id,c]})),pt=Object.values(pe);function qt(t){return pe[t]}function Ft(t,e){const r=o.useMemo(()=>"amount"in t?t:W(t.major,t.currency),[]),[c,a]=o.useState(r),s=o.useCallback(h=>a(u=>W(h,u.currency)),[]),m=o.useCallback(h=>{a(u=>({...u,currency:h.toUpperCase()}))},[]),i=o.useCallback(h=>a(u=>oe(u,h)),[]),l=o.useCallback(h=>a(u=>Ke(u,h)),[]),d=o.useCallback(h=>a(u=>_e(u,h)),[]),y=o.useMemo(()=>ee(c,{locale:e}),[c,e]),x=o.useMemo(()=>we(c),[c]);return{money:c,setMoney:a,setMajor:s,setCurrency:m,add:i,subtract:l,scale:d,formatted:y,major:x}}function ge(t,e,r){const[c,a]=o.useState(null),[s,m]=o.useState(null),[i,l]=o.useState(!1),d=o.useRef(0);return o.useEffect(()=>{if(!t){a(null);return}const y=++d.current;l(!0),m(null),Ve(t,e,r).then(x=>{d.current===y&&a(x)}).catch(x=>{d.current===y&&(m(x instanceof Error?x:new Error(String(x))),a(null))}).finally(()=>{d.current===y&&l(!1)})},[t==null?void 0:t.amount,t==null?void 0:t.currency,e,r]),{converted:c,loading:i,error:s}}function yt(t){const[e,r]=o.useState("idle"),[c,a]=o.useState(null),[s,m]=o.useState(null),i=o.useCallback(()=>{r("idle"),a(null),m(null)},[]),l=o.useCallback(async h=>{r("authorizing"),m(null);try{const u=await t.authorize(h);return a(u),r(u.status),u}catch(u){const b=u instanceof Error?u:new Error(String(u));throw m(b),r("failed"),b}},[t]),d=o.useCallback(async(h,u)=>{const b=h??(c==null?void 0:c.id);if(!b)throw new Error("No authorization id to capture");r("capturing");try{const f=await t.capture(b,u);return a(f),r(f.status),f}catch(f){const _=f instanceof Error?f:new Error(String(f));throw m(_),r("failed"),_}},[t,c==null?void 0:c.id]),y=o.useCallback(async h=>{const u=h??(c==null?void 0:c.id);if(!u)throw new Error("No payment id to cancel");const b=await t.cancel(u);return a(b),r(b.status),b},[t,c==null?void 0:c.id]),x=o.useCallback(async(h,u)=>{const b=h??(c==null?void 0:c.id);if(!b)throw new Error("No payment id to refund");const f=await t.refund(b,u);return a(f),r(f.status),f},[t,c==null?void 0:c.id]);return{status:e,response:c,error:s,authorize:l,capture:d,cancel:y,refund:x,reset:i}}const ke=o.forwardRef(function({value:e,amount:r,currency:c,locale:a,display:s="symbol",highlightNegative:m=!0,zeroPlaceholder:i,convertTo:l,exchangeProvider:d,className:y,style:x,"aria-label":h},u){const b=o.useMemo(()=>{if(e)return e;if(r!=null&&c){const N=X(c),C=(N==null?void 0:N.decimals)??2;return{amount:Math.round(r*Math.pow(10,C)),currency:c.toUpperCase()}}return null},[e,r,c]),f=o.useMemo(()=>b?b.amount===0&&i!=null?i:ee(b,{locale:a,currencyDisplay:s}):"",[b,a,s,i]),{converted:_}=ge(l&&d?b:null,l??"",d);if(!b)return null;const g=b.amount<0,v="nice-money"+(m&&g?" nice-money--negative":"")+(y?` ${y}`:"");return n.jsxs("span",{ref:u,className:v,style:x,"aria-label":h,children:[n.jsx("span",{className:"nice-money__value",children:f}),_&&n.jsxs("span",{className:"nice-money__converted","aria-label":`Converted to ${_.currency}`,children:[" ≈ ",ee(_,{locale:a})]})]})}),Kt=de.map(t=>t.code).sort(),Se=o.forwardRef(function({value:e,onChange:r,options:c=de,recents:a=[],searchable:s,showCode:m=!0,showSymbol:i=!0,compact:l=!1,disabled:d,readOnly:y,loading:x,accessMode:h,label:u,helperText:b,error:f,required:_,size:g="md",labelPlacement:v="top",labelWidth:N,controlWidth:C,className:I,style:A,id:P,name:j,title:R,"data-testid":G,"aria-label":O,placeholder:k},q){const E=h==="hidden",Z=d||h==="disabled"||x,te=y||h==="readOnly",F=o.useId(),re=P??`nice-cs-${F}`,[z,$]=o.useState(""),U=s??c.length>8,L=o.useMemo(()=>{if(!z.trim())return c;const M=z.trim().toLowerCase();return c.filter(S=>S.code.toLowerCase().includes(M)||S.name.toLowerCase().includes(M)||S.symbol.toLowerCase().includes(M))},[c,z]),p=o.useMemo(()=>{const M=new Set;return a.map(S=>X(S)).filter(S=>!!S&&!M.has(S.code)&&!!M.add(S.code))},[a]),K=o.useCallback(M=>{const S=M.target.value,ae=X(S);ae&&(r==null||r(S,ae))},[r]),B=M=>{if(l)return`${i?M.symbol+" ":""}${M.code}`;const S=[];return i&&S.push(M.symbol),m&&S.push(M.code),S.push("—",M.name),S.join(" ")},w=`nice-currency-selector nice-currency-selector--${g} nice-currency-selector--label-${v}`+(l?" nice-currency-selector--compact":"")+(f?" nice-currency-selector--error":"")+(Z?" nice-currency-selector--disabled":"")+(I?` ${I}`:""),T=v==="left"&&N!=null?{width:typeof N=="number"?`${N}px`:N,flex:"none"}:void 0,ne=C!=null?{width:typeof C=="number"?`${C}px`:C,flex:"none"}:void 0;return E?null:n.jsxs("div",{ref:q,className:w,style:A,title:R,"data-testid":G,children:[u&&n.jsxs("label",{htmlFor:re,className:"nice-currency-selector__label",style:T,children:[u,_&&n.jsx("span",{className:"nice-currency-selector__required","aria-hidden":!0,children:"*"})]}),n.jsxs("div",{className:"nice-currency-selector__inner",style:ne,children:[U&&n.jsx("input",{type:"search",className:"nice-currency-selector__search",placeholder:"Search currency…",value:z,onChange:M=>$(M.target.value),disabled:Z||te,"aria-label":"Search currency"}),n.jsxs("select",{id:re,name:j,className:"nice-currency-selector__select",value:e??"",onChange:K,disabled:Z||te,required:_,"aria-invalid":!!f,"aria-label":O??(typeof u=="string"?u:"Currency"),children:[!e&&n.jsx("option",{value:"",children:k??"Select currency…"}),p.length>0&&n.jsx("optgroup",{label:"Recent",children:p.map(M=>n.jsx("option",{value:M.code,children:B(M)},`r-${M.code}`))}),n.jsx("optgroup",{label:p.length>0?"All":"",children:L.map(M=>n.jsx("option",{value:M.code,children:B(M)},M.code))})]})]}),(f||b)&&n.jsx("span",{className:f?"nice-currency-selector__error":"nice-currency-selector__helper",children:f??b})]})}),De=o.forwardRef(function({value:e,onChange:r,currency:c,onCurrencyChange:a,currencies:s,hideCurrencySelector:m,min:i,max:l,step:d,locale:y,placeholder:x,label:h,helperText:u,error:b,size:f="md",disabled:_,readOnly:g,required:v,loading:N,accessMode:C,labelPlacement:I="top",errorPlacement:A="bottom",labelWidth:P,controlWidth:j,submitOnEnter:R,onSubmit:G,showFormattedPreview:O=!0,showSteppers:k=!1,className:q,style:E,id:Z,name:te,title:F,"data-testid":re,onBlur:z,onFocus:$,liveGrouping:U,multiplierShortcuts:L=!0,onValidationError:p},K){const B=_||C==="disabled"||N,w=g||C==="readOnly",T=C==="hidden",ne=o.useId(),M=Z??`nice-money-${ne}`,S=((e==null?void 0:e.currency)??c??"USD").toUpperCase(),ae=X(S),V=(ae==null?void 0:ae.decimals)??2,Ie=d??1/Math.pow(10,V),[Ne,he]=o.useState(()=>e?(e.amount/Math.pow(10,V)).toFixed(V):""),[be,Re]=o.useState(!1);o.useEffect(()=>{if(be)return;if(e==null){he("");return}const D=X(e.currency),Y=(D==null?void 0:D.decimals)??2;he((e.amount/Math.pow(10,Y)).toFixed(Y))},[e,be]);const $e=o.useCallback(D=>{let Y=D;if(L){const se=D.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);if(se){const ie=se[2].toLowerCase()==="k"?1e3:se[2].toLowerCase()==="m"?1e6:1e9,Te=Number(se[1].replace(",","."))*ie;if(!Number.isFinite(Te)){p==null||p(new Error("overflow"));return}Y=String(Te)}}const Q=Be(Y,S);if(!Q){r==null||r(null);return}if(!Number.isSafeInteger(Q.amount)){p==null||p(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));return}const ce=Q.amount/Math.pow(10,V);if(i!=null&&ce<i){p==null||p(new Error(`min: ${i}`)),r==null||r(W(i,S));return}if(l!=null&&ce>l){p==null||p(new Error(`max: ${l}`)),r==null||r(W(l,S));return}r==null||r(Q)},[S,V,i,l,r,L,p]),bt=o.useCallback(D=>{const Y=D.target.value;he(Y),$e(Y)},[$e]),Ae=o.useCallback(D=>{const Q=(e?e.amount/Math.pow(10,V):0)+D,ce=Math.min(l??1/0,Math.max(i??-1/0,Q));r==null||r(W(ce,S))},[e,V,i,l,S,r]),fe=o.useMemo(()=>{var D,Y;try{const Q=new Intl.NumberFormat(y).formatToParts(12345.6),ce=((D=Q.find(ie=>ie.type==="group"))==null?void 0:D.value)??",",se=((Y=Q.find(ie=>ie.type==="decimal"))==null?void 0:Y.value)??".";return{group:ce,decimal:se}}catch{return{group:",",decimal:"."}}},[y]),Ue=U??!!fe.group,ft=o.useMemo(()=>{if(!Ue||be===!1)return Ne;const D=fe.decimal,Y=fe.group,Q=Ne.replace(new RegExp(`[${Y.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}]`,"g"),""),[ce,se]=Q.split(D);if(!ce)return Q;const ie=ce.replace(/\B(?=(\d{3})+(?!\d))/g,Y);return se!=null?`${ie}${D}${se}`:ie},[Ne,be,Ue,fe]),Ee=o.useMemo(()=>e?ee(e,{locale:y}):"",[e,y]),ue=typeof b=="string"?b:void 0,_t=`nice-money-input nice-money-input--${f} nice-money-input--label-${I} nice-money-input--error-${A}`+(ue?" nice-money-input--error":"")+(B?" nice-money-input--disabled":"")+(N?" nice-money-input--loading":"")+(q?` ${q}`:""),gt=D=>{R&&D.key==="Enter"&&G&&(D.preventDefault(),G())},xt=I==="left"&&P!=null?{width:typeof P=="number"?`${P}px`:P,flex:"none"}:void 0,Nt=j!=null?{width:typeof j=="number"?`${j}px`:j,flex:"none"}:void 0;return T?null:n.jsxs("div",{ref:K,className:_t,style:E,title:F,"data-testid":re,children:[h&&n.jsxs("label",{htmlFor:M,className:"nice-money-input__label",style:xt,children:[h,v&&n.jsx("span",{className:"nice-money-input__required","aria-hidden":!0,children:"*"})]}),n.jsxs("div",{className:"nice-money-input__row",style:Nt,children:[!m&&n.jsx(Se,{value:S,compact:!0,options:s?s.map(X).filter(D=>!!D):void 0,onChange:D=>a==null?void 0:a(D),disabled:B||w,className:"nice-money-input__currency","aria-label":"Currency"}),m&&n.jsx("span",{className:"nice-money-input__symbol","aria-hidden":!0,children:(ae==null?void 0:ae.symbol)??S}),k&&n.jsx("button",{type:"button",className:"nice-money-input__step nice-money-input__step--down",onClick:()=>Ae(-Ie),disabled:B||w||i!=null&&e!=null&&e.amount/Math.pow(10,V)<=i,"aria-label":"Decrease amount",tabIndex:-1,children:"−"}),n.jsx("input",{id:M,name:te,type:"text",inputMode:"decimal",autoComplete:"transaction-amount",className:"nice-money-input__amount",value:ft,onChange:bt,onKeyDown:gt,onFocus:D=>{Re(!0),$==null||$(D)},onBlur:D=>{Re(!1),e&&he((e.amount/Math.pow(10,V)).toFixed(V)),z==null||z(D)},placeholder:x??`0${V>0?"."+"0".repeat(V):""}`,disabled:B,readOnly:w,required:v,"aria-invalid":!!ue,"aria-describedby":ue||u?`${M}-help`:void 0}),k&&n.jsx("button",{type:"button",className:"nice-money-input__step nice-money-input__step--up",onClick:()=>Ae(Ie),disabled:B||w||l!=null&&e!=null&&e.amount/Math.pow(10,V)>=l,"aria-label":"Increase amount",tabIndex:-1,children:"+"}),N&&n.jsx("span",{className:"nice-money-input__spinner","aria-hidden":!0,children:"⟳"})]}),O&&Ee&&n.jsx("span",{className:"nice-money-input__preview","aria-live":"polite",children:Ee}),(ue||u)&&n.jsx("span",{id:`${M}-help`,className:ue?"nice-money-input__error":"nice-money-input__helper",children:ue??u})]})}),Bt={number:"",expiry:"",cvc:""},ht=o.forwardRef(function({value:e=Bt,onChange:r,showHolderName:c=!0,requireHolderName:a,showPostalCode:s=!1,acceptedBrands:m,showBrandIcon:i=!0,size:l="md",disabled:d,readOnly:y,loading:x,accessMode:h,label:u,helperText:b,error:f,required:_,className:g,style:v,id:N,title:C,"data-testid":I},A){const P=h==="hidden",j=d||h==="disabled"||x,R=y||h==="readOnly",G=o.useId(),O=N??`nice-cc-${G}`,[k,q]=o.useState({number:!1,expiry:!1,cvc:!1,holder:!1,postal:!1}),E=o.useMemo(()=>ye(e.number),[e.number]),Z=o.useMemo(()=>ve(e,{requireHolder:a??c}),[e,a,c]),te=!m||m.includes(E)||E==="unknown",F=o.useCallback(w=>{const T={...e,...w},ne=ve(T,{requireHolder:a??c});r==null||r(T,ne)},[e,a,c,r]),re=o.useCallback(w=>{const T=w.target.value.replace(/\D/g,"").slice(0,19);F({number:T})},[F]),z=o.useCallback(w=>{const T=w.target.value.replace(/\D/g,"").slice(0,4);let ne=T;T.length>=3?ne=`${T.slice(0,2)}/${T.slice(2)}`:T.length===2&&(ne=`${T}/`),F({expiry:ne})},[F]),$=o.useCallback(w=>{const T=w.target.value.replace(/\D/g,"").slice(0,le(E));F({cvc:T})},[E,F]),U=o.useMemo(()=>Le(e.number,E),[e.number,E]),L=k.number&&e.number.length>0&&(je(e.number)?te?void 0:"Card brand not accepted":Z.errors.number),p=k.expiry&&e.expiry.length>0&&!Pe(e.expiry)?Z.errors.expiry:void 0,K=k.cvc&&e.cvc.length>0&&e.cvc.length!==le(E)?Z.errors.cvc:void 0,B=`nice-credit-card nice-credit-card--${l}`+(j?" nice-credit-card--disabled":"")+(x?" nice-credit-card--loading":"")+(f?" nice-credit-card--error":"")+(g?` ${g}`:"");return P?null:n.jsxs("div",{ref:A,className:B,style:v,title:C,"data-testid":I,children:[u&&n.jsxs("div",{className:"nice-credit-card__title",children:[u,_&&n.jsx("span",{className:"nice-credit-card__required","aria-hidden":!0,children:"*"})]}),n.jsx("div",{className:"nice-credit-card__row",children:n.jsxs("label",{className:"nice-credit-card__field nice-credit-card__field--number",children:[n.jsx("span",{className:"nice-credit-card__label",children:"Card number"}),n.jsxs("span",{className:"nice-credit-card__input-wrapper",children:[n.jsx("input",{id:`${O}-number`,type:"text",inputMode:"numeric",autoComplete:"cc-number",placeholder:E==="amex"?"3782 822463 10005":"1234 1234 1234 1234",value:U,onChange:re,onBlur:()=>q(w=>({...w,number:!0})),disabled:j,readOnly:R,"aria-invalid":!!L,"aria-describedby":L?`${O}-number-err`:void 0,className:"nice-credit-card__input",maxLength:E==="amex"?17:23}),i&&n.jsx(Lt,{brand:E})]}),L&&n.jsx("span",{id:`${O}-number-err`,className:"nice-credit-card__error",children:L})]})}),n.jsxs("div",{className:"nice-credit-card__row nice-credit-card__row--split",children:[n.jsxs("label",{className:"nice-credit-card__field",children:[n.jsx("span",{className:"nice-credit-card__label",children:"Expiry"}),n.jsx("input",{id:`${O}-expiry`,type:"text",inputMode:"numeric",autoComplete:"cc-exp",placeholder:"MM/YY",value:e.expiry,onChange:z,onBlur:()=>{q(T=>({...T,expiry:!0}));const w=Me(e.expiry);w&&w!==e.expiry&&F({expiry:w})},disabled:j,readOnly:R,"aria-invalid":!!p,"aria-describedby":p?`${O}-expiry-err`:void 0,className:"nice-credit-card__input",maxLength:5}),p&&n.jsx("span",{id:`${O}-expiry-err`,className:"nice-credit-card__error",children:p})]}),n.jsxs("label",{className:"nice-credit-card__field",children:[n.jsx("span",{className:"nice-credit-card__label",children:E==="amex"?"CID":"CVC"}),n.jsx("input",{id:`${O}-cvc`,type:"text",inputMode:"numeric",autoComplete:"cc-csc",placeholder:"•".repeat(le(E)),value:e.cvc,onChange:$,onBlur:()=>q(w=>({...w,cvc:!0})),disabled:j,readOnly:R,"aria-invalid":!!K,"aria-describedby":K?`${O}-cvc-err`:void 0,className:"nice-credit-card__input",maxLength:le(E)}),K&&n.jsx("span",{id:`${O}-cvc-err`,className:"nice-credit-card__error",children:K})]})]}),c&&n.jsx("div",{className:"nice-credit-card__row",children:n.jsxs("label",{className:"nice-credit-card__field",children:[n.jsx("span",{className:"nice-credit-card__label",children:"Cardholder name"}),n.jsx("input",{id:`${O}-holder`,type:"text",autoComplete:"cc-name",placeholder:"Jane Doe",value:e.holderName??"",onChange:w=>F({holderName:w.target.value}),onBlur:()=>q(w=>({...w,holder:!0})),disabled:j,readOnly:R,className:"nice-credit-card__input",maxLength:120})]})}),s&&n.jsx("div",{className:"nice-credit-card__row",children:n.jsxs("label",{className:"nice-credit-card__field",children:[n.jsx("span",{className:"nice-credit-card__label",children:"Postal code"}),n.jsx("input",{id:`${O}-postal`,type:"text",autoComplete:"postal-code",value:e.postalCode??"",onChange:w=>F({postalCode:w.target.value}),onBlur:()=>q(w=>({...w,postal:!0})),disabled:j,readOnly:R,className:"nice-credit-card__input",maxLength:16})]})}),(f||b)&&n.jsx("div",{className:f?"nice-credit-card__form-error":"nice-credit-card__helper",role:f?"alert":void 0,children:f??b})]})}),Oe={visa:"VISA",mastercard:"MasterCard",amex:"AMEX",discover:"Discover",diners:"Diners",jcb:"JCB",unionpay:"UnionPay",maestro:"Maestro",mir:"MIR",elo:"Elo",hipercard:"Hipercard",unknown:""};function Lt({brand:t}){return t==="unknown"?null:n.jsx("span",{className:`nice-credit-card__brand nice-credit-card__brand--${t}`,"aria-label":Oe[t],children:Oe[t]})}const Ht=o.forwardRef(function({processor:e,amount:r,editableAmount:c,customer:a,currencies:s,description:m,metadata:i,autoCapture:l=!0,submitLabel:d="Pay",onSuccess:y,onError:x,consents:h,className:u,style:b},f){const[_,g]=o.useState(r),[v,N]=o.useState(r.currency),[C,I]=o.useState({number:"",expiry:"",cvc:""}),[A,P]=o.useState(null),[j,R]=o.useState(!1),[G,O]=o.useState(null),k=yt(e),q=o.useMemo(()=>e.supportedCurrencies==="*"?!0:e.supportedCurrencies.includes(_.currency.toUpperCase()),[e,_.currency]),E=o.useMemo(()=>{var U;const $=(U=e.minimums)==null?void 0:U[_.currency.toUpperCase()];return $==null||_.amount>=$},[e,_]),Z=o.useMemo(()=>{var U;const $=(U=e.minimums)==null?void 0:U[_.currency.toUpperCase()];return $==null?null:{amount:$,currency:_.currency}},[e,_.currency]),te=!!(A!=null&&A.isValid),F=!j&&q&&E&&te,re=o.useCallback(async $=>{if($.preventDefault(),!!F){O(null),R(!0);try{const U={amount:_,card:C,customer:a,description:m,metadata:i,idempotencyKey:zt()},L=await k.authorize(U);if(l&&L.status==="authorized"){const p=await k.capture(L.id,_);y==null||y(p)}else y==null||y(L)}catch(U){const L=U instanceof Error?U:new Error(String(U));O(L.message),x==null||x(L)}finally{R(!1)}}},[F,_,C,a,m,i,l,k,y,x]),z=X(_.currency);return n.jsxs("form",{ref:f,className:"nice-payment-form"+(u?` ${u}`:""),style:b,onSubmit:re,"aria-busy":j,children:[n.jsx("div",{className:"nice-payment-form__amount",children:c?n.jsx(De,{label:"Amount",value:_,currency:v,currencies:s,onChange:$=>$&&g($),onCurrencyChange:$=>{N($),g(U=>({...U,currency:$}))},disabled:j,required:!0,showFormattedPreview:!0}):n.jsxs("div",{className:"nice-payment-form__total",children:[n.jsx("span",{className:"nice-payment-form__total-label",children:"Total"}),n.jsx(ke,{value:_})]})}),m&&n.jsx("p",{className:"nice-payment-form__description",children:m}),n.jsx("div",{className:"nice-payment-form__card",children:n.jsx(ht,{value:C,onChange:($,U)=>{I($),P(U)},disabled:j})}),!q&&n.jsxs("div",{className:"nice-payment-form__warning",role:"alert",children:[e.name," does not accept ",(z==null?void 0:z.name)??_.currency,"."]}),!E&&Z&&n.jsxs("div",{className:"nice-payment-form__warning",role:"alert",children:["Minimum charge for ",e.name," is ",n.jsx(ke,{value:Z}),"."]}),h&&n.jsx("div",{className:"nice-payment-form__consents",children:h}),G&&n.jsx("div",{className:"nice-payment-form__error",role:"alert",children:G}),n.jsx("button",{type:"submit",className:"nice-payment-form__submit",disabled:!F,"aria-disabled":!F,children:j?"Processing…":d}),n.jsxs("p",{className:"nice-payment-form__processor",children:["Secured by ",n.jsx("strong",{children:e.name})]})]})});function zt(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`}const Yt=o.forwardRef(function({price:e,originalPrice:r,period:c,prefix:a,suffix:s,showDiscountBadge:m=!0,size:i="md",locale:l,className:d,style:y},x){const h=r&&r.currency===e.currency&&r.amount>e.amount,u=o.useMemo(()=>!h||!r?null:Math.round((r.amount-e.amount)/r.amount*100),[h,r,e.amount]),b=`nice-price-tag nice-price-tag--${i}`+(d?` ${d}`:"");return n.jsxs("div",{ref:x,className:b,style:y,children:[a&&n.jsx("span",{className:"nice-price-tag__prefix",children:a}),n.jsxs("span",{className:"nice-price-tag__main",children:[n.jsx("span",{className:"nice-price-tag__amount",children:ee(e,{locale:l})}),c&&n.jsx("span",{className:"nice-price-tag__period",children:c})]}),h&&r&&n.jsx("span",{className:"nice-price-tag__original","aria-label":"Original price",children:n.jsx("s",{children:ee(r,{locale:l})})}),h&&m&&u!=null&&u>0&&n.jsxs("span",{className:"nice-price-tag__discount","aria-label":`${u} percent off`,children:["−",u,"%"]}),s&&n.jsx("span",{className:"nice-price-tag__suffix",children:s})]})}),Gt={amount:0,currency:"USD"},Zt=o.forwardRef(function({source:e,defaultSource:r,onSourceChange:c,targetCurrency:a,defaultTargetCurrency:s,onTargetCurrencyChange:m,provider:i,locale:l,showRateLine:d=!0,className:y,style:x},h){const[u,b]=me.useControllableState({value:e,defaultValue:r,fallbackValue:Gt,onChange:c,componentName:"NiceCurrencyConverter"}),[f,_]=me.useControllableState({value:a,defaultValue:s,fallbackValue:u.currency,onChange:m,componentName:"NiceCurrencyConverter"}),{converted:g,loading:v,error:N}=ge(u,f,i),C=o.useMemo(()=>({amount:Math.pow(10,2),currency:u.currency}),[u.currency]),{converted:I}=ge(d?C:null,f,i);return n.jsxs("div",{ref:h,className:"nice-currency-converter"+(y?` ${y}`:""),style:x,children:[n.jsx("div",{className:"nice-currency-converter__row",children:n.jsx(De,{label:"From",value:u,onChange:A=>A&&b(A),currency:u.currency,onCurrencyChange:A=>b({...u,currency:A}),showFormattedPreview:!1})}),n.jsxs("div",{className:"nice-currency-converter__row",children:[n.jsx("label",{className:"nice-currency-converter__label",children:"To"}),n.jsxs("div",{className:"nice-currency-converter__output",children:[n.jsx(Se,{value:f,onChange:A=>_(A),compact:!0}),n.jsx("span",{className:"nice-currency-converter__amount",children:v?"…":N?"—":g?ee(g,{locale:l}):""})]})]}),d&&I&&n.jsxs("p",{className:"nice-currency-converter__rate",children:["1 ",u.currency," = ",ee(I,{locale:l})," ",n.jsxs("span",{className:"nice-currency-converter__inverse",children:["· 1 ",f," ="," ",ee(W(1/we(I),u.currency),{locale:l})]})]}),N&&n.jsx("p",{className:"nice-currency-converter__error",role:"alert",children:N.message})]})});function qe(t){return{amount:Math.round(t.amount),currency:t.currency}}const Jt=o.forwardRef(function({lines:e,locale:r,rounding:c="line",showTotals:a=!0,showGrandTotal:s=!0,hideRateColumn:m=!1,labels:i,density:l="comfortable",className:d,style:y,id:x},h){const u={label:(i==null?void 0:i.label)??"Item",rate:(i==null?void 0:i.rate)??"VAT",net:(i==null?void 0:i.net)??"Net",vat:(i==null?void 0:i.vat)??"Tax",gross:(i==null?void 0:i.gross)??"Gross",total:(i==null?void 0:i.total)??"Total"},b=o.useMemo(()=>{if(c==="total"){const g=new Map;for(const N of e){let C=g.get(N.vatRate);C||(C=[],g.set(N.vatRate,C)),C.push(N.netAmount)}const v=[];for(const[N,C]of g){const I=C.reduce((j,R)=>oe(j,R),W(0,C[0].currency)),A=qe(_e(I,N)),P=oe(I,A);v.push({rate:N,net:I,vat:A,gross:P})}return v}return e.map(g=>{const v=qe(_e(g.netAmount,g.vatRate)),N=oe(g.netAmount,v);return{label:g.label,rate:g.vatRate,net:g.netAmount,vat:v,gross:N}})},[e,c]),f=o.useMemo(()=>{if(b.length===0)return null;const g=b[0].net.currency;let v=W(0,g),N=W(0,g),C=W(0,g);for(const I of b)v=oe(v,I.net),N=oe(N,I.vat),C=oe(C,I.gross);return{net:v,vat:N,gross:C}},[b]),_=g=>ee(g,{locale:r});return n.jsxs("table",{ref:h,id:x,className:`nice-tax-breakdown nice-tax-breakdown--${l} ${d??""}`,style:y,role:"table","aria-label":u.total,children:[n.jsx("thead",{children:n.jsxs("tr",{children:[b.some(g=>g.label!==void 0)&&n.jsx("th",{scope:"col",children:u.label}),!m&&n.jsx("th",{scope:"col",className:"nice-tax-breakdown__rate",children:u.rate}),n.jsx("th",{scope:"col",className:"nice-tax-breakdown__num",children:u.net}),n.jsx("th",{scope:"col",className:"nice-tax-breakdown__num",children:u.vat}),n.jsx("th",{scope:"col",className:"nice-tax-breakdown__num",children:u.gross})]})}),n.jsx("tbody",{children:b.map((g,v)=>n.jsxs("tr",{children:[b.some(N=>N.label!==void 0)&&n.jsx("td",{children:g.label??""}),!m&&n.jsxs("td",{className:"nice-tax-breakdown__rate",children:[(g.rate*100).toLocaleString(r,{maximumFractionDigits:2}),"%"]}),n.jsx("td",{className:"nice-tax-breakdown__num",children:_(g.net)}),n.jsx("td",{className:"nice-tax-breakdown__num",children:_(g.vat)}),n.jsx("td",{className:"nice-tax-breakdown__num",children:_(g.gross)})]},`${g.rate}-${v}`))}),a&&f&&n.jsx("tfoot",{children:s&&n.jsxs("tr",{className:"nice-tax-breakdown__totals",children:[b.some(g=>g.label!==void 0)&&n.jsx("td",{children:u.total}),!m&&n.jsx("td",{}),n.jsx("td",{className:"nice-tax-breakdown__num",children:_(f.net)}),n.jsx("td",{className:"nice-tax-breakdown__num",children:_(f.vat)}),n.jsx("td",{className:"nice-tax-breakdown__num",children:_(f.gross)})]})})]})}),Vt=o.forwardRef(function(e,r){const{methods:c,value:a,onChange:s,layout:m="list",columns:i=2,currency:l,label:d,name:y,readOnly:x=!1,className:h,style:u,id:b,accessMode:f,"data-testid":_}=e,g=o.useId(),v=y??`nice-pm-${g}`,N=o.useMemo(()=>{if(!l)return c;const P=l.toUpperCase();return c.filter(j=>!j.currencies||j.currencies.map(R=>R.toUpperCase()).includes(P))},[c,l]);if(f==="hidden")return null;const C=x||f==="disabled"||f==="readOnly",I=`nice-payment-method-selector nice-payment-method-selector--${m}`+(h?` ${h}`:""),A=m==="grid"?{gridTemplateColumns:`repeat(${i}, minmax(0, 1fr))`}:void 0;return n.jsxs("div",{ref:r,id:b,className:I,style:u,"data-testid":_,children:[d&&n.jsx("div",{className:"nice-payment-method-selector__label",children:d}),n.jsxs("div",{className:"nice-payment-method-selector__options",style:A,role:"radiogroup","aria-label":d??"Payment method",children:[N.map(P=>{const j=P.id===a,R=C||P.disabled;return n.jsxs("label",{className:"nice-payment-method-selector__option"+(j?" nice-payment-method-selector__option--selected":"")+(R?" nice-payment-method-selector__option--disabled":""),children:[n.jsx("input",{type:"radio",className:"nice-payment-method-selector__radio",name:v,value:P.id,checked:j,disabled:R,onChange:()=>s==null?void 0:s(P.id)}),P.icon&&n.jsx("span",{className:"nice-payment-method-selector__icon",children:P.icon}),n.jsxs("span",{className:"nice-payment-method-selector__text",children:[n.jsx("span",{className:"nice-payment-method-selector__name",children:P.label}),P.description&&n.jsx("span",{className:"nice-payment-method-selector__desc",children:P.description})]})]},P.id)}),N.length===0&&n.jsx("div",{className:"nice-payment-method-selector__empty",children:"No methods available."})]})]})}),Xt=[{target:".nice-payment-provider-config",titleKey:"tutorial.paymentProviderConfig.intro.title",title:"Payment provider",contentKey:"tutorial.paymentProviderConfig.intro.content",content:"Pick a provider, fill its credentials (secrets are masked), choose test/live, enable methods and copy the webhook URL.",placement:"auto"}],Qt={providerId:"",mode:"test",credentials:{},enabledMethods:[]},Wt=o.forwardRef(function(e,r){const{value:c,defaultValue:a,onChange:s,providers:m,onTestConnection:i,showWebhookUrl:l=!0,baseUrl:d,readOnly:y=!1,testLabel:x="Test connection",tutorial:h,className:u,style:b,id:f,accessMode:_,"data-testid":g}=e,[v,N]=me.useControllableState({value:c,defaultValue:a,fallbackValue:Qt,onChange:s,componentName:"NicePaymentProviderConfig"}),C=o.useId(),[I,A]=o.useState(new Set),[P,j]=o.useState(!1),[R,G]=o.useState(null),O=o.useMemo(()=>m?m.map(p=>pe[p]).filter(p=>!!p):pt,[m]),k=pe[v.providerId];if(_==="hidden")return null;const q=y||_==="disabled"||_==="readOnly",E=p=>{G(null),A(new Set),N({providerId:p,mode:v.mode,credentials:{},enabledMethods:[]})},Z=(p,K)=>{N({...v,credentials:{...v.credentials,[p]:K}})},te=p=>{const K=new Set(v.enabledMethods??[]);K.has(p)?K.delete(p):K.add(p),N({...v,enabledMethods:[...K]})},F=p=>{A(K=>{const B=new Set(K);return B.has(p)?B.delete(p):B.add(p),B})},re=async()=>{if(i){j(!0),G(null);try{G(await i(v))}catch(p){G({ok:!1,message:p instanceof Error?p.message:String(p)})}finally{j(!1)}}},z=k!=null&&k.webhookPath?`${(d??"").replace(/\/$/,"")}${k.webhookPath}`:"",$=(k==null?void 0:k.supportedCurrencies)==="*"?"All currencies":((k==null?void 0:k.supportedCurrencies)??[]).join(", "),U="nice-payment-provider-config"+(u?` ${u}`:""),L=((k==null?void 0:k.credentials)??[]).filter(p=>!p.testOnly||v.mode==="test");return n.jsxs("div",{ref:r,id:f,className:U,style:b,"data-testid":g,children:[h&&n.jsx("div",{className:"nice-payment-provider-config__tutorial",children:n.jsx(me.NiceTutorialButton,{steps:me.resolveTutorial(h,Xt)})}),n.jsxs("div",{className:"nice-payment-provider-config__row",children:[n.jsxs("label",{className:"nice-payment-provider-config__field",children:[n.jsx("span",{className:"nice-payment-provider-config__field-label",children:"Provider"}),n.jsxs("select",{className:"nice-payment-provider-config__select",value:v.providerId,disabled:q,onChange:p=>E(p.target.value),children:[n.jsx("option",{value:"",children:"— select provider —"}),O.map(p=>n.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(k==null?void 0:k.hasTestMode)&&n.jsxs("div",{className:"nice-payment-provider-config__mode",role:"group","aria-label":"Mode",children:[n.jsx("button",{type:"button",className:"nice-payment-provider-config__mode-btn"+(v.mode==="test"?" nice-payment-provider-config__mode-btn--active":""),onClick:()=>N({...v,mode:"test"}),disabled:q,children:"Test"}),n.jsx("button",{type:"button",className:"nice-payment-provider-config__mode-btn"+(v.mode==="live"?" nice-payment-provider-config__mode-btn--active":""),onClick:()=>N({...v,mode:"live"}),disabled:q,children:"Live"})]})]}),k&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"nice-payment-provider-config__meta",children:[n.jsx("span",{className:"nice-payment-provider-config__badge",children:k.type}),n.jsx("span",{className:"nice-payment-provider-config__currencies",children:$})]}),n.jsx("div",{className:"nice-payment-provider-config__credentials",children:L.map(p=>{const K=`${C}-${p.key}`,B=p.secret,w=I.has(p.key);return n.jsxs("div",{className:"nice-payment-provider-config__field",children:[n.jsxs("label",{className:"nice-payment-provider-config__field-label",htmlFor:K,children:[p.label,p.required&&n.jsx("span",{className:"nice-payment-provider-config__required",children:" *"})]}),n.jsxs("div",{className:"nice-payment-provider-config__input-wrap",children:[n.jsx("input",{id:K,type:B&&!w?"password":"text",className:"nice-payment-provider-config__input",value:v.credentials[p.key]??"",readOnly:q,autoComplete:B?"new-password":"off",onChange:T=>Z(p.key,T.target.value)}),B&&n.jsx("button",{type:"button",className:"nice-payment-provider-config__reveal",onClick:()=>F(p.key),"aria-label":w?"Hide":"Reveal","aria-pressed":w,children:w?"🙈":"👁"})]}),p.help&&n.jsx("span",{className:"nice-payment-provider-config__help",children:p.help})]},p.key)})}),k.supportedMethods&&k.supportedMethods.length>0&&n.jsxs("div",{className:"nice-payment-provider-config__methods",children:[n.jsx("span",{className:"nice-payment-provider-config__field-label",children:"Enabled methods"}),n.jsx("div",{className:"nice-payment-provider-config__method-list",children:k.supportedMethods.map(p=>n.jsxs("label",{className:"nice-payment-provider-config__method",children:[n.jsx("input",{type:"checkbox",checked:(v.enabledMethods??[]).includes(p),disabled:q,onChange:()=>te(p)}),p]},p))})]}),l&&k.webhookPath&&n.jsxs("div",{className:"nice-payment-provider-config__field",children:[n.jsx("span",{className:"nice-payment-provider-config__field-label",children:"Webhook URL"}),n.jsx("code",{className:"nice-payment-provider-config__webhook",children:z})]}),i&&n.jsxs("div",{className:"nice-payment-provider-config__test",children:[n.jsx("button",{type:"button",className:"nice-payment-provider-config__test-btn",onClick:()=>void re(),disabled:q||P,children:P?"Testing…":x}),R&&n.jsxs("span",{className:"nice-payment-provider-config__test-result nice-payment-provider-config__test-result--"+(R.ok?"ok":"error"),children:[R.ok?"✓":"✕"," ",R.message??(R.ok?"OK":"Failed")]})]})]})]})});exports.EcbRatesProvider=Ze;exports.ExchangeRateHostProvider=Ye;exports.FrankfurterProvider=He;exports.FreeForexApiProvider=Je;exports.MockPaymentProcessor=Xe;exports.NICE_CURRENCY_CATALOG=de;exports.NICE_CURRENCY_CODES=Kt;exports.NICE_PAYMENT_PROCESSORS=mt;exports.NICE_PAYMENT_PROVIDER_LIST=pt;exports.NICE_PAYMENT_PROVIDER_PROFILES=pe;exports.NbpRatesProvider=Ge;exports.NiceCreditCardInput=ht;exports.NiceCurrencyConverter=Zt;exports.NiceCurrencySelector=Se;exports.NiceMoney=ke;exports.NiceMoneyInput=De;exports.NicePaymentForm=Ht;exports.NicePaymentMethodSelector=Vt;exports.NicePaymentProviderConfig=Wt;exports.NicePriceTag=Yt;exports.NiceTaxBreakdown=Jt;exports.OpenExchangeRatesProvider=ze;exports.StaticExchangeRateProvider=It;exports.addMoney=oe;exports.compareMoney=jt;exports.convertMoney=Ve;exports.createEcbRatesProvider=$t;exports.createFreeForexApiProvider=Ut;exports.createNbpRatesProvider=Rt;exports.createOpenExchangeRatesProvider=At;exports.detectCardBrand=ye;exports.expectedCvcLength=le;exports.findCurrency=X;exports.findPaymentProviderProfile=qt;exports.formatCardNumber=Le;exports.formatMoney=ee;exports.fromMoney=we;exports.isExpiryValid=Pe;exports.isNegative=Pt;exports.isZero=Mt;exports.luhnCheck=je;exports.makeAdyenAdapter=et;exports.makeAutopayAdapter=ot;exports.makeBlikAdapter=lt;exports.makeBraintreeAdapter=nt;exports.makeCoinbaseCommerceAdapter=ut;exports.makeKlarnaAdapter=dt;exports.makeMollieAdapter=rt;exports.makePayPalAdapter=We;exports.makePayUAdapter=ct;exports.makePrzelewy24Adapter=st;exports.makeRazorpayAdapter=at;exports.makeSquareAdapter=tt;exports.makeStripeAdapter=Qe;exports.makeTpayAdapter=it;exports.maskCardNumber=Dt;exports.multiplyMoney=_e;exports.negateMoney=St;exports.normaliseExpiry=Me;exports.parseMoney=Be;exports.registerCurrency=wt;exports.subtractMoney=Ke;exports.toMoney=W;exports.useNiceExchangeRate=ge;exports.useNiceMoney=Ft;exports.useNicePayment=yt;exports.validateCreditCard=ve;
1
+ "use strict";var vt=Object.defineProperty;var kt=(t,e,r)=>e in t?vt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var z=(t,e,r)=>kt(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),n=require("react/jsx-runtime"),le=require("@nice2dev/ui-core"),ue=[{code:"USD",numeric:840,symbol:"$",name:"US Dollar",decimals:2,symbolFirst:!0},{code:"EUR",numeric:978,symbol:"€",name:"Euro",decimals:2,symbolFirst:!0},{code:"GBP",numeric:826,symbol:"£",name:"Pound Sterling",decimals:2,symbolFirst:!0},{code:"JPY",numeric:392,symbol:"¥",name:"Japanese Yen",decimals:0,symbolFirst:!0},{code:"CHF",numeric:756,symbol:"Fr",name:"Swiss Franc",decimals:2},{code:"CAD",numeric:124,symbol:"CA$",name:"Canadian Dollar",decimals:2,symbolFirst:!0},{code:"AUD",numeric:36,symbol:"A$",name:"Australian Dollar",decimals:2,symbolFirst:!0},{code:"NZD",numeric:554,symbol:"NZ$",name:"New Zealand Dollar",decimals:2,symbolFirst:!0},{code:"CNY",numeric:156,symbol:"¥",name:"Chinese Yuan Renminbi",decimals:2,symbolFirst:!0},{code:"HKD",numeric:344,symbol:"HK$",name:"Hong Kong Dollar",decimals:2,symbolFirst:!0},{code:"SGD",numeric:702,symbol:"S$",name:"Singapore Dollar",decimals:2,symbolFirst:!0},{code:"PLN",numeric:985,symbol:"zł",name:"Polish Złoty",decimals:2},{code:"CZK",numeric:203,symbol:"Kč",name:"Czech Koruna",decimals:2},{code:"HUF",numeric:348,symbol:"Ft",name:"Hungarian Forint",decimals:2},{code:"RON",numeric:946,symbol:"lei",name:"Romanian Leu",decimals:2},{code:"BGN",numeric:975,symbol:"лв",name:"Bulgarian Lev",decimals:2},{code:"HRK",numeric:191,symbol:"kn",name:"Croatian Kuna",decimals:2},{code:"DKK",numeric:208,symbol:"kr",name:"Danish Krone",decimals:2},{code:"SEK",numeric:752,symbol:"kr",name:"Swedish Krona",decimals:2},{code:"NOK",numeric:578,symbol:"kr",name:"Norwegian Krone",decimals:2},{code:"ISK",numeric:352,symbol:"kr",name:"Icelandic Króna",decimals:0},{code:"RUB",numeric:643,symbol:"₽",name:"Russian Ruble",decimals:2},{code:"UAH",numeric:980,symbol:"₴",name:"Ukrainian Hryvnia",decimals:2},{code:"TRY",numeric:949,symbol:"₺",name:"Turkish Lira",decimals:2,symbolFirst:!0},{code:"MXN",numeric:484,symbol:"Mex$",name:"Mexican Peso",decimals:2,symbolFirst:!0},{code:"BRL",numeric:986,symbol:"R$",name:"Brazilian Real",decimals:2,symbolFirst:!0},{code:"ARS",numeric:32,symbol:"AR$",name:"Argentine Peso",decimals:2,symbolFirst:!0},{code:"CLP",numeric:152,symbol:"CL$",name:"Chilean Peso",decimals:0,symbolFirst:!0},{code:"COP",numeric:170,symbol:"CO$",name:"Colombian Peso",decimals:2,symbolFirst:!0},{code:"PEN",numeric:604,symbol:"S/",name:"Peruvian Sol",decimals:2,symbolFirst:!0},{code:"UYU",numeric:858,symbol:"$U",name:"Uruguayan Peso",decimals:2,symbolFirst:!0},{code:"INR",numeric:356,symbol:"₹",name:"Indian Rupee",decimals:2,symbolFirst:!0},{code:"IDR",numeric:360,symbol:"Rp",name:"Indonesian Rupiah",decimals:2,symbolFirst:!0},{code:"KRW",numeric:410,symbol:"₩",name:"South Korean Won",decimals:0,symbolFirst:!0},{code:"MYR",numeric:458,symbol:"RM",name:"Malaysian Ringgit",decimals:2,symbolFirst:!0},{code:"PHP",numeric:608,symbol:"₱",name:"Philippine Peso",decimals:2,symbolFirst:!0},{code:"THB",numeric:764,symbol:"฿",name:"Thai Baht",decimals:2,symbolFirst:!0},{code:"VND",numeric:704,symbol:"₫",name:"Vietnamese Đồng",decimals:0},{code:"TWD",numeric:901,symbol:"NT$",name:"New Taiwan Dollar",decimals:2,symbolFirst:!0},{code:"PKR",numeric:586,symbol:"₨",name:"Pakistani Rupee",decimals:2},{code:"BDT",numeric:50,symbol:"৳",name:"Bangladeshi Taka",decimals:2},{code:"LKR",numeric:144,symbol:"Rs",name:"Sri Lankan Rupee",decimals:2},{code:"AED",numeric:784,symbol:"د.إ",name:"UAE Dirham",decimals:2},{code:"SAR",numeric:682,symbol:"ر.س",name:"Saudi Riyal",decimals:2},{code:"QAR",numeric:634,symbol:"ر.ق",name:"Qatari Riyal",decimals:2},{code:"KWD",numeric:414,symbol:"د.ك",name:"Kuwaiti Dinar",decimals:3},{code:"BHD",numeric:48,symbol:".د.ب",name:"Bahraini Dinar",decimals:3},{code:"OMR",numeric:512,symbol:"ر.ع",name:"Omani Rial",decimals:3},{code:"JOD",numeric:400,symbol:"د.أ",name:"Jordanian Dinar",decimals:3},{code:"ILS",numeric:376,symbol:"₪",name:"Israeli New Shekel",decimals:2,symbolFirst:!0},{code:"EGP",numeric:818,symbol:"E£",name:"Egyptian Pound",decimals:2,symbolFirst:!0},{code:"ZAR",numeric:710,symbol:"R",name:"South African Rand",decimals:2,symbolFirst:!0},{code:"NGN",numeric:566,symbol:"₦",name:"Nigerian Naira",decimals:2,symbolFirst:!0},{code:"KES",numeric:404,symbol:"KSh",name:"Kenyan Shilling",decimals:2},{code:"GHS",numeric:936,symbol:"₵",name:"Ghanaian Cedi",decimals:2},{code:"MAD",numeric:504,symbol:"د.م.",name:"Moroccan Dirham",decimals:2},{code:"TND",numeric:788,symbol:"د.ت",name:"Tunisian Dinar",decimals:3},{code:"BTC",numeric:0,symbol:"₿",name:"Bitcoin",decimals:8,symbolFirst:!0},{code:"ETH",numeric:0,symbol:"Ξ",name:"Ether",decimals:8,symbolFirst:!0},{code:"USDC",numeric:0,symbol:"USDC",name:"USD Coin",decimals:6},{code:"USDT",numeric:0,symbol:"USDT",name:"Tether",decimals:6}],Fe=new Map(ue.map(t=>[t.code,t]));function X(t){return Fe.get(t.toUpperCase())}function wt(t){Fe.set(t.code.toUpperCase(),t);const e=ue.findIndex(r=>r.code===t.code);e>=0?ue[e]=t:ue.push(t)}function W(t,e){const r=X(e),c=(r==null?void 0:r.decimals)??2,a=Math.pow(10,c);return{amount:(t<0?-1:1)*Math.round(Math.abs(t)*a),currency:e.toUpperCase()}}function we(t){const e=X(t.currency),r=(e==null?void 0:e.decimals)??2;return t.amount/Math.pow(10,r)}function Ct(t,e){return t.currency.toUpperCase()===e.currency.toUpperCase()}function Ce(t,e,r){if(!Ct(t,e))throw new Error(`Cannot ${r} different currencies: ${t.currency} vs ${e.currency}`)}function oe(t,e){return Ce(t,e,"add"),{amount:t.amount+e.amount,currency:t.currency}}function Ke(t,e){return Ce(t,e,"subtract"),{amount:t.amount-e.amount,currency:t.currency}}function _e(t,e){return{amount:(t.amount*e<0?-1:1)*Math.round(Math.abs(t.amount*e)),currency:t.currency}}function jt(t,e){return Ce(t,e,"compare"),t.amount-e.amount}function Mt(t){return t.amount===0}function Pt(t){return t.amount<0}function St(t){return{amount:-t.amount,currency:t.currency}}function ee(t,e={}){const r=X(t.currency),c=e.decimals??(r==null?void 0:r.decimals)??2,a=t.amount/Math.pow(10,c);try{return new Intl.NumberFormat(e.locale,{style:"currency",currency:t.currency,minimumFractionDigits:c,maximumFractionDigits:c,currencyDisplay:e.currencyDisplay??"symbol"}).format(a)}catch{const s=(r==null?void 0:r.symbol)??t.currency,m=a.toFixed(c);return r!=null&&r.symbolFirst?`${s}${m}`:`${m} ${s}`}}function Be(t,e){if(!t)return null;let r=t.replace(/[^\d.,\-]/g,"").trim();if(!r||r==="-")return null;const c=r.startsWith("-");c&&(r=r.slice(1));const a=r.lastIndexOf("."),s=r.lastIndexOf(","),m=Math.max(a,s);let i,l="";m===-1?i=r:(i=r.slice(0,m).replace(/[.,]/g,""),l=r.slice(m+1).replace(/[.,]/g,""));const d=`${i}.${l||"0"}`,y=parseFloat(d);return Number.isFinite(y)?W(c?-y:y,e):null}function ye(t){const e=(t||"").replace(/\D/g,"");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"}function je(t){const e=(t||"").replace(/\D/g,"");if(e.length<12||e.length>19)return!1;let r=0,c=!1;for(let a=e.length-1;a>=0;a--){let s=e.charCodeAt(a)-48;c&&(s*=2,s>9&&(s-=9)),r+=s,c=!c}return r%10===0}function Le(t,e){const r=(t||"").replace(/\D/g,""),c=e??ye(r);return c==="amex"?[r.slice(0,4),r.slice(4,10),r.slice(10,15)].filter(Boolean).join(" "):c==="diners"?[r.slice(0,4),r.slice(4,10),r.slice(10,14)].filter(Boolean).join(" "):(r.match(/.{1,4}/g)??[]).join(" ").trim()}function Dt(t,e){const r=(t||"").replace(/\D/g,"");if(r.length<4)return r;const c=r.slice(-4),a="*".repeat(r.length-4)+c,s=e??ye(r);return s==="amex"?[a.slice(0,4),a.slice(4,10),a.slice(10,15)].filter(Boolean).join(" "):s==="diners"?[a.slice(0,4),a.slice(4,10),a.slice(10,14)].filter(Boolean).join(" "):(a.match(/.{1,4}/g)??[]).join(" ").trim()}function Me(t){const e=(t||"").replace(/\D/g,"");if(e.length<3)return null;const r=e.slice(0,2),c=e.length>=4?e.slice(-2):e.slice(2,4),a=parseInt(r,10);return!Number.isFinite(a)||a<1||a>12?null:`${r}/${c}`}function Pe(t,e=new Date){const r=Me(t);if(!r)return!1;const[c,a]=r.split("/"),s=parseInt(c,10),m=2e3+parseInt(a,10);return new Date(m,s,0,23,59,59,999).getTime()>=e.getTime()}function de(t){return t==="amex"?4:3}function ve(t,e={}){var d;const r={},c=ye(t.number),a=je(t.number);a||(r.number="Invalid card number");const s=Pe(t.expiry,e.now);s||(r.expiry="Invalid or expired");const i=(t.cvc||"").replace(/\D/g,"").length===de(c);i||(r.cvc=`CVC must be ${de(c)} digits`);const l=!e.requireHolder||(((d=t.holderName)==null?void 0:d.trim().length)??0)>=2;return l||(r.holderName="Cardholder name required"),{brand:c,numberValid:a,expiryValid:s,cvcValid:i,holderValid:l,isValid:a&&s&&i&&l,errors:r}}class It{constructor(e){z(this,"id","static");this.rates=e}async getRate(e,r){const c=e.toUpperCase(),a=r.toUpperCase();if(c===a)return{base:c,quote:a,rate:1,asOf:new Date().toISOString()};const s=this.rates.find(d=>d.base===c&&d.quote===a);if(s)return s;const m=this.rates.find(d=>d.base===a&&d.quote===c);if(m)return{base:c,quote:a,rate:1/m.rate,asOf:m.asOf};const i=this.rates.find(d=>d.base===c&&d.quote==="USD")??this.rates.find(d=>d.base==="USD"&&d.quote===c),l=this.rates.find(d=>d.base==="USD"&&d.quote===a)??this.rates.find(d=>d.base===a&&d.quote==="USD");if(i&&l){const d=i.base==="USD"?1/i.rate:i.rate,y=l.base==="USD"?l.rate:1/l.rate;return{base:c,quote:a,rate:d*y,asOf:new Date().toISOString()}}throw new Error(`No FX rate for ${c}/${a}`)}}class ge{constructor(e={}){z(this,"cache",new Map);z(this,"fetchImpl");z(this,"ttl");this.fetchImpl=e.fetchImpl??fetch,this.ttl=e.cacheTtl??6e4}cacheKey(e,r){return`${this.id}:${e.toUpperCase()}/${r.toUpperCase()}`}getCached(e,r){const c=this.cacheKey(e,r),a=this.cache.get(c);return a&&a.expires>Date.now()?a.rate:(a&&this.cache.delete(c),null)}setCached(e){this.cache.set(this.cacheKey(e.base,e.quote),{expires:Date.now()+this.ttl,rate:e})}}class ze extends ge{constructor(r={}){super(r);z(this,"id","frankfurter")}async getRate(r,c){const a=r.toUpperCase(),s=c.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const m=this.getCached(a,s);if(m)return m;const i=`https://api.frankfurter.app/latest?from=${a}&to=${s}`,l=await this.fetchImpl(i);if(!l.ok)throw new Error(`Frankfurter HTTP ${l.status}`);const d=await l.json(),y=d.rates[s];if(y==null)throw new Error(`Frankfurter: no rate for ${a}/${s}`);const g={base:a,quote:s,rate:y,asOf:d.date};return this.setCached(g),g}}class He extends ge{constructor(r,c={}){super(c);z(this,"id","openexchangerates");this.appId=r}async getRate(r,c){const a=r.toUpperCase(),s=c.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const m=this.getCached(a,s);if(m)return m;const i=`https://openexchangerates.org/api/latest.json?app_id=${this.appId}`,l=await this.fetchImpl(i);if(!l.ok)throw new Error(`OpenExchangeRates HTTP ${l.status}`);const d=await l.json(),y=d.rates[a],g=d.rates[s];if(y==null||g==null)throw new Error(`OpenExchangeRates: missing rate for ${a} or ${s}`);const h={base:a,quote:s,rate:g/y,asOf:new Date(d.timestamp*1e3).toISOString()};return this.setCached(h),h}}class Ye extends ge{constructor(r={}){super(r);z(this,"id","exchangerate.host")}async getRate(r,c){var h;const a=r.toUpperCase(),s=c.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const m=this.getCached(a,s);if(m)return m;const i=`https://api.exchangerate.host/convert?from=${a}&to=${s}`,l=await this.fetchImpl(i);if(!l.ok)throw new Error(`exchangerate.host HTTP ${l.status}`);const d=await l.json(),y=((h=d.info)==null?void 0:h.rate)??d.result,g={base:a,quote:s,rate:y,asOf:d.date};return this.setCached(g),g}}class Ge extends ge{constructor(r={}){super(r);z(this,"id","nbp");z(this,"table");this.table=r.table??"A"}async getRate(r,c){const a=r.toUpperCase(),s=c.toUpperCase();if(a===s)return{base:a,quote:s,rate:1,asOf:new Date().toISOString()};const m=this.getCached(a,s);if(m)return m;const i=async g=>{var x;if(g==="PLN")return{rate:1,date:new Date().toISOString().slice(0,10)};const h=`https://api.nbp.pl/api/exchangerates/rates/${this.table}/${g}/?format=json`,u=await this.fetchImpl(h);if(!u.ok)return null;const f=(x=(await u.json()).rates)==null?void 0:x[0];return f?{rate:f.mid??f.ask??0,date:f.effectiveDate}:null},l=await i(a),d=await i(s);if(!l||!d||l.rate===0)throw new Error(`NBP: missing rate for ${a} or ${s}`);const y={base:a,quote:s,rate:l.rate/d.rate,asOf:l.date};return this.setCached(y),y}}class Ze extends ze{constructor(){super(...arguments);z(this,"id","ecb")}}class Je extends Ye{constructor(){super(...arguments);z(this,"id","free-forex")}}const Rt=(t={})=>new Ge(t),$t=(t={})=>new Ze(t),At=t=>new He(t.apiKey,t),Ut=(t={})=>new Je(t);async function Ve(t,e,r){const c=e.toUpperCase();if(t.currency.toUpperCase()===c)return t;const a=X(t.currency),s=X(c),m=(a==null?void 0:a.decimals)??2,i=(s==null?void 0:s.decimals)??2,{rate:l}=await r.getRate(t.currency,c),y=t.amount/Math.pow(10,m)*l;return{currency:c,amount:Math.round(y*Math.pow(10,i))}}class Xe{constructor(e={}){z(this,"id");z(this,"name");z(this,"supportedCurrencies");z(this,"minimums");z(this,"counter",0);this.id=e.id??"mock",this.name=e.name??"Mock Processor",this.supportedCurrencies=e.supportedCurrencies??"*"}newId(e){return this.counter+=1,`${e}_${Date.now().toString(36)}_${this.counter}`}async authorize(e){return{id:this.newId("auth"),status:"authorized",processor:this.id,amount:e.amount,raw:{mock:!0,request:e}}}async capture(e,r){return{id:e.replace("auth_","cap_"),status:"captured",processor:this.id,amount:r}}async cancel(e){return{id:e,status:"cancelled",processor:this.id}}async refund(e,r){return{id:e.replace(/^[a-z]+_/,"ref_"),status:"refunded",processor:this.id,amount:r}}}function J(t,e,r,c,a){const s=m=>{const i=c==null?void 0:c[m];return i||(async()=>{throw new Error(`[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(m)}\` implementation that calls the ${e} SDK.`)})};return{id:t,name:e,supportedCurrencies:r,minimums:a,authorize:s("authorize"),capture:s("capture"),cancel:s("cancel"),refund:s("refund")}}function Qe(t){return J("stripe","Stripe","*",t,{USD:50,EUR:50,GBP:30,JPY:50,AUD:50,CAD:50,CHF:50,DKK:250,NOK:300,SEK:300,PLN:200})}function We(t){return J("paypal","PayPal",["USD","EUR","GBP","AUD","CAD","JPY","CHF","NZD","SEK","NOK","DKK","PLN","CZK","HUF","BRL","MXN","HKD","SGD","TWD","THB","PHP","ILS"],t)}function et(t){return J("adyen","Adyen","*",t)}function tt(t){return J("square","Square",["USD","CAD","GBP","AUD","JPY","EUR"],t)}function rt(t){return J("mollie","Mollie","*",t)}function nt(t){return J("braintree","Braintree","*",t)}function at(t){return J("razorpay","Razorpay",["INR","USD","EUR","GBP","AED"],t)}function ct(t){return J("payu","PayU",["PLN","EUR","USD","CZK","HUF","RON","BGN","TRY"],t)}function st(t){return J("przelewy24","Przelewy24",["PLN","EUR"],t)}function it(t={}){return J("tpay","Tpay",["PLN","EUR","USD","GBP"],t)}function ot(t={}){return J("autopay","Autopay",["PLN","EUR","USD","GBP","CZK"],t)}function lt(t={}){const{acquirer:e="native",...r}=t;return J(`blik:${e}`,`BLIK (${e})`,["PLN"],r)}function dt(t){return J("klarna","Klarna",["USD","EUR","GBP","SEK","NOK","DKK","CHF","AUD","CAD","NZD","PLN"],t)}function ut(t){return J("coinbase-commerce","Coinbase Commerce",["BTC","ETH","USDC","USDT","USD","EUR"],t)}const mt={mock:()=>new Xe,stripe:()=>Qe(),paypal:()=>We(),adyen:()=>et(),square:()=>tt(),mollie:()=>rt(),braintree:()=>nt(),razorpay:()=>at(),payu:()=>ct(),przelewy24:()=>st(),tpay:()=>it(),autopay:()=>ot(),blik:()=>lt(),klarna:()=>dt(),"coinbase-commerce":()=>ut()};function Et(t){const e=mt[t];return e?e().supportedCurrencies:"*"}function Tt(t){return`/api/payments/${t}/webhook`}const Ot=[{id:"stripe",name:"Stripe",type:"card",credentials:[{key:"apiKey",label:"Secret API key",secret:!0,required:!0,help:"sk_live_… / sk_test_…"},{key:"publishableKey",label:"Publishable key",required:!0,help:"pk_live_… / pk_test_…"},{key:"webhookSecret",label:"Webhook signing secret",secret:!0,help:"whsec_…"}],supportedMethods:["card","applepay","googlepay","link"],allowedDomains:["api.stripe.com"],hasTestMode:!0},{id:"paypal",name:"PayPal",type:"wallet",credentials:[{key:"clientId",label:"Client ID",required:!0},{key:"clientSecret",label:"Client secret",secret:!0,required:!0},{key:"webhookId",label:"Webhook ID"}],supportedMethods:["paypal","card","paylater"],allowedDomains:["api-m.paypal.com","api-m.sandbox.paypal.com"],hasTestMode:!0},{id:"adyen",name:"Adyen",type:"aggregator",credentials:[{key:"apiKey",label:"API key",secret:!0,required:!0},{key:"merchantAccount",label:"Merchant account",required:!0},{key:"hmacKey",label:"HMAC key (webhooks)",secret:!0},{key:"clientKey",label:"Client key"}],supportedMethods:["card","ideal","bancontact","applepay","googlepay"],allowedDomains:["checkout-test.adyen.com","checkout-live.adyen.com"],hasTestMode:!0},{id:"square",name:"Square",type:"card",credentials:[{key:"accessToken",label:"Access token",secret:!0,required:!0},{key:"applicationId",label:"Application ID",required:!0},{key:"locationId",label:"Location ID",required:!0}],supportedMethods:["card","applepay","googlepay"],allowedDomains:["connect.squareup.com","connect.squareupsandbox.com"],hasTestMode:!0},{id:"mollie",name:"Mollie",type:"aggregator",credentials:[{key:"apiKey",label:"API key",secret:!0,required:!0,help:"live_… / test_…"}],supportedMethods:["card","ideal","bancontact","blik","applepay"],allowedDomains:["api.mollie.com"],hasTestMode:!0},{id:"braintree",name:"Braintree",type:"card",credentials:[{key:"merchantId",label:"Merchant ID",required:!0},{key:"publicKey",label:"Public key",required:!0},{key:"privateKey",label:"Private key",secret:!0,required:!0}],supportedMethods:["card","paypal","applepay","googlepay"],allowedDomains:["api.braintreegateway.com","api.sandbox.braintreegateway.com"],hasTestMode:!0},{id:"razorpay",name:"Razorpay",type:"aggregator",credentials:[{key:"keyId",label:"Key ID",required:!0},{key:"keySecret",label:"Key secret",secret:!0,required:!0},{key:"webhookSecret",label:"Webhook secret",secret:!0}],supportedMethods:["card","upi","netbanking","wallet"],allowedDomains:["api.razorpay.com"],hasTestMode:!0},{id:"payu",name:"PayU",type:"aggregator",credentials:[{key:"posId",label:"POS ID",required:!0},{key:"clientId",label:"OAuth client ID",required:!0},{key:"clientSecret",label:"OAuth client secret",secret:!0,required:!0},{key:"secondKey",label:"Second key (MD5)",secret:!0}],supportedMethods:["card","blik","transfer","googlepay"],allowedDomains:["secure.payu.com","secure.snd.payu.com"],hasTestMode:!0},{id:"przelewy24",name:"Przelewy24",type:"bank",credentials:[{key:"merchantId",label:"Merchant ID",required:!0},{key:"posId",label:"POS ID",required:!0},{key:"crcKey",label:"CRC key",secret:!0,required:!0},{key:"apiKey",label:"API key",secret:!0,required:!0}],supportedMethods:["transfer","blik","card"],allowedDomains:["secure.przelewy24.pl","sandbox.przelewy24.pl"],hasTestMode:!0},{id:"tpay",name:"Tpay",type:"aggregator",credentials:[{key:"merchantId",label:"Merchant ID",required:!0},{key:"apiKey",label:"API key",secret:!0,required:!0},{key:"apiPassword",label:"API password",secret:!0,required:!0}],supportedMethods:["card","blik","transfer","applepay"],allowedDomains:["api.tpay.com","secure.tpay.com"],hasTestMode:!0},{id:"autopay",name:"Autopay",type:"aggregator",credentials:[{key:"serviceId",label:"Service ID",required:!0},{key:"sharedSecret",label:"Shared secret",secret:!0,required:!0}],supportedMethods:["card","blik","transfer"],allowedDomains:["pay.autopay.eu","testpay.autopay.eu"],hasTestMode:!0},{id:"blik",name:"BLIK",type:"bank",credentials:[{key:"acquirer",label:"Acquirer (p24 / tpay / payu / native)",required:!0,help:"Underlying acquirer routing BLIK."}],supportedMethods:["blik"],hasTestMode:!0},{id:"klarna",name:"Klarna",type:"bnpl",credentials:[{key:"username",label:"API username (UID)",required:!0},{key:"password",label:"API password",secret:!0,required:!0},{key:"region",label:"Region (eu / na / oc)",help:"Selects the Klarna API host."}],supportedMethods:["paylater","installments","paynow"],allowedDomains:["api.klarna.com","api.playground.klarna.com"],hasTestMode:!0},{id:"coinbase-commerce",name:"Coinbase Commerce",type:"crypto",credentials:[{key:"apiKey",label:"API key",secret:!0,required:!0},{key:"webhookSharedSecret",label:"Webhook shared secret",secret:!0}],supportedMethods:["crypto"],allowedDomains:["api.commerce.coinbase.com"],hasTestMode:!1},{id:"wallet",name:"In-app Wallet",type:"wallet",currencyKey:"mock",credentials:[{key:"ledgerAccount",label:"Ledger account",required:!0,help:"Account the wallet debits/credits."}],supportedMethods:["wallet"],hasTestMode:!0}],pe=Object.fromEntries(Ot.map(t=>{const{currencyKey:e,...r}=t,c={...r,supportedCurrencies:Et(e??t.id),webhookPath:Tt(t.id)};return[t.id,c]})),pt=Object.values(pe);function qt(t){return pe[t]}function Ft(t,e){const r=o.useMemo(()=>"amount"in t?t:W(t.major,t.currency),[]),[c,a]=o.useState(r),s=o.useCallback(h=>a(u=>W(h,u.currency)),[]),m=o.useCallback(h=>{a(u=>({...u,currency:h.toUpperCase()}))},[]),i=o.useCallback(h=>a(u=>oe(u,h)),[]),l=o.useCallback(h=>a(u=>Ke(u,h)),[]),d=o.useCallback(h=>a(u=>_e(u,h)),[]),y=o.useMemo(()=>ee(c,{locale:e}),[c,e]),g=o.useMemo(()=>we(c),[c]);return{money:c,setMoney:a,setMajor:s,setCurrency:m,add:i,subtract:l,scale:d,formatted:y,major:g}}function xe(t,e,r){const[c,a]=o.useState(null),[s,m]=o.useState(null),[i,l]=o.useState(!1),d=o.useRef(0);return o.useEffect(()=>{if(!t){a(null);return}const y=++d.current;l(!0),m(null),Ve(t,e,r).then(g=>{d.current===y&&a(g)}).catch(g=>{d.current===y&&(m(g instanceof Error?g:new Error(String(g))),a(null))}).finally(()=>{d.current===y&&l(!1)})},[t==null?void 0:t.amount,t==null?void 0:t.currency,e,r]),{converted:c,loading:i,error:s}}function yt(t){const[e,r]=o.useState("idle"),[c,a]=o.useState(null),[s,m]=o.useState(null),i=o.useCallback(()=>{r("idle"),a(null),m(null)},[]),l=o.useCallback(async h=>{r("authorizing"),m(null);try{const u=await t.authorize(h);return a(u),r(u.status),u}catch(u){const b=u instanceof Error?u:new Error(String(u));throw m(b),r("failed"),b}},[t]),d=o.useCallback(async(h,u)=>{const b=h??(c==null?void 0:c.id);if(!b)throw new Error("No authorization id to capture");r("capturing");try{const f=await t.capture(b,u);return a(f),r(f.status),f}catch(f){const x=f instanceof Error?f:new Error(String(f));throw m(x),r("failed"),x}},[t,c==null?void 0:c.id]),y=o.useCallback(async h=>{const u=h??(c==null?void 0:c.id);if(!u)throw new Error("No payment id to cancel");const b=await t.cancel(u);return a(b),r(b.status),b},[t,c==null?void 0:c.id]),g=o.useCallback(async(h,u)=>{const b=h??(c==null?void 0:c.id);if(!b)throw new Error("No payment id to refund");const f=await t.refund(b,u);return a(f),r(f.status),f},[t,c==null?void 0:c.id]);return{status:e,response:c,error:s,authorize:l,capture:d,cancel:y,refund:g,reset:i}}const ke=o.forwardRef(function({value:e,amount:r,currency:c,locale:a,display:s="symbol",highlightNegative:m=!0,zeroPlaceholder:i,convertTo:l,exchangeProvider:d,className:y,style:g,"aria-label":h},u){const b=o.useMemo(()=>{if(e)return e;if(r!=null&&c){const N=X(c),C=(N==null?void 0:N.decimals)??2;return{amount:Math.round(r*Math.pow(10,C)),currency:c.toUpperCase()}}return null},[e,r,c]),f=o.useMemo(()=>b?b.amount===0&&i!=null?i:ee(b,{locale:a,currencyDisplay:s}):"",[b,a,s,i]),{converted:x}=xe(l&&d?b:null,l??"",d);if(!b)return null;const _=b.amount<0,v="nice-money"+(m&&_?" nice-money--negative":"")+(y?` ${y}`:"");return n.jsxs("span",{ref:u,className:v,style:g,"aria-label":h,children:[n.jsx("span",{className:"nice-money__value",children:f}),x&&n.jsxs("span",{className:"nice-money__converted","aria-label":`Converted to ${x.currency}`,children:[" ≈ ",ee(x,{locale:a})]})]})}),Kt=ue.map(t=>t.code).sort(),Se=o.forwardRef(function({value:e,onChange:r,options:c=ue,recents:a=[],searchable:s,showCode:m=!0,showSymbol:i=!0,compact:l=!1,disabled:d,readOnly:y,loading:g,accessMode:h,label:u,helperText:b,error:f,required:x,size:_="md",labelPlacement:v="top",labelWidth:N,controlWidth:C,className:I,style:A,id:P,name:j,title:R,"data-testid":G,"aria-label":O,placeholder:k},q){const E=h==="hidden",Z=d||h==="disabled"||g,te=y||h==="readOnly",F=o.useId(),re=P??`nice-cs-${F}`,[H,$]=o.useState(""),U=s??c.length>8,L=o.useMemo(()=>{if(!H.trim())return c;const M=H.trim().toLowerCase();return c.filter(S=>S.code.toLowerCase().includes(M)||S.name.toLowerCase().includes(M)||S.symbol.toLowerCase().includes(M))},[c,H]),p=o.useMemo(()=>{const M=new Set;return a.map(S=>X(S)).filter(S=>!!S&&!M.has(S.code)&&!!M.add(S.code))},[a]),K=o.useCallback(M=>{const S=M.target.value,ae=X(S);ae&&(r==null||r(S,ae))},[r]),B=M=>{if(l)return`${i?M.symbol+" ":""}${M.code}`;const S=[];return i&&S.push(M.symbol),m&&S.push(M.code),S.push("—",M.name),S.join(" ")},w=`nice-currency-selector nice-currency-selector--${_} nice-currency-selector--label-${v}`+(l?" nice-currency-selector--compact":"")+(f?" nice-currency-selector--error":"")+(Z?" nice-currency-selector--disabled":"")+(I?` ${I}`:""),T=v==="left"&&N!=null?{width:typeof N=="number"?`${N}px`:N,flex:"none"}:void 0,ne=C!=null?{width:typeof C=="number"?`${C}px`:C,flex:"none"}:void 0;return E?null:n.jsxs("div",{ref:q,className:w,style:A,title:R,"data-testid":G,children:[u&&n.jsxs("label",{htmlFor:re,className:"nice-currency-selector__label",style:T,children:[u,x&&n.jsx("span",{className:"nice-currency-selector__required","aria-hidden":!0,children:"*"})]}),n.jsxs("div",{className:"nice-currency-selector__inner",style:ne,children:[U&&n.jsx("input",{type:"search",className:"nice-currency-selector__search",placeholder:"Search currency…",value:H,onChange:M=>$(M.target.value),disabled:Z||te,"aria-label":"Search currency"}),n.jsxs("select",{id:re,name:j,className:"nice-currency-selector__select",value:e??"",onChange:K,disabled:Z||te,required:x,"aria-invalid":!!f,"aria-label":O??(typeof u=="string"?u:"Currency"),children:[!e&&n.jsx("option",{value:"",children:k??"Select currency…"}),p.length>0&&n.jsx("optgroup",{label:"Recent",children:p.map(M=>n.jsx("option",{value:M.code,children:B(M)},`r-${M.code}`))}),n.jsx("optgroup",{label:p.length>0?"All":"",children:L.map(M=>n.jsx("option",{value:M.code,children:B(M)},M.code))})]})]}),(f||b)&&n.jsx("span",{className:f?"nice-currency-selector__error":"nice-currency-selector__helper",children:f??b})]})}),De=o.forwardRef(function({value:e,onChange:r,currency:c,onCurrencyChange:a,currencies:s,hideCurrencySelector:m,min:i,max:l,step:d,locale:y,placeholder:g,label:h,helperText:u,error:b,size:f="md",disabled:x,readOnly:_,required:v,loading:N,accessMode:C,labelPlacement:I="top",errorPlacement:A="bottom",labelWidth:P,controlWidth:j,submitOnEnter:R,onSubmit:G,showFormattedPreview:O=!0,showSteppers:k=!1,className:q,style:E,id:Z,name:te,title:F,"data-testid":re,onBlur:H,onFocus:$,liveGrouping:U,multiplierShortcuts:L=!0,onValidationError:p},K){const B=x||C==="disabled"||N,w=_||C==="readOnly",T=C==="hidden",ne=o.useId(),M=Z??`nice-money-${ne}`,S=((e==null?void 0:e.currency)??c??"USD").toUpperCase(),ae=X(S),V=(ae==null?void 0:ae.decimals)??2,Ie=d??1/Math.pow(10,V),[Ne,he]=o.useState(()=>e?(e.amount/Math.pow(10,V)).toFixed(V):""),[be,Re]=o.useState(!1);o.useEffect(()=>{if(be)return;if(e==null){he("");return}const D=X(e.currency),Y=(D==null?void 0:D.decimals)??2;he((e.amount/Math.pow(10,Y)).toFixed(Y))},[e,be]);const $e=o.useCallback(D=>{let Y=D;if(L){const se=D.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);if(se){const ie=se[2].toLowerCase()==="k"?1e3:se[2].toLowerCase()==="m"?1e6:1e9,Te=Number(se[1].replace(",","."))*ie;if(!Number.isFinite(Te)){p==null||p(new Error("overflow"));return}Y=String(Te)}}const Q=Be(Y,S);if(!Q){r==null||r(null);return}if(!Number.isSafeInteger(Q.amount)){p==null||p(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));return}const ce=Q.amount/Math.pow(10,V);if(i!=null&&ce<i){p==null||p(new Error(`min: ${i}`)),r==null||r(W(i,S));return}if(l!=null&&ce>l){p==null||p(new Error(`max: ${l}`)),r==null||r(W(l,S));return}r==null||r(Q)},[S,V,i,l,r,L,p]),bt=o.useCallback(D=>{const Y=D.target.value;he(Y),$e(Y)},[$e]),Ae=o.useCallback(D=>{const Q=(e?e.amount/Math.pow(10,V):0)+D,ce=Math.min(l??1/0,Math.max(i??-1/0,Q));r==null||r(W(ce,S))},[e,V,i,l,S,r]),fe=o.useMemo(()=>{var D,Y;try{const Q=new Intl.NumberFormat(y).formatToParts(12345.6),ce=((D=Q.find(ie=>ie.type==="group"))==null?void 0:D.value)??",",se=((Y=Q.find(ie=>ie.type==="decimal"))==null?void 0:Y.value)??".";return{group:ce,decimal:se}}catch{return{group:",",decimal:"."}}},[y]),Ue=U??!!fe.group,ft=o.useMemo(()=>{if(!Ue||be===!1)return Ne;const D=fe.decimal,Y=fe.group,Q=Ne.replace(new RegExp(`[${Y.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}]`,"g"),""),[ce,se]=Q.split(D);if(!ce)return Q;const ie=ce.replace(/\B(?=(\d{3})+(?!\d))/g,Y);return se!=null?`${ie}${D}${se}`:ie},[Ne,be,Ue,fe]),Ee=o.useMemo(()=>e?ee(e,{locale:y}):"",[e,y]),me=typeof b=="string"?b:void 0,_t=`nice-money-input nice-money-input--${f} nice-money-input--label-${I} nice-money-input--error-${A}`+(me?" nice-money-input--error":"")+(B?" nice-money-input--disabled":"")+(N?" nice-money-input--loading":"")+(q?` ${q}`:""),xt=D=>{R&&D.key==="Enter"&&G&&(D.preventDefault(),G())},gt=I==="left"&&P!=null?{width:typeof P=="number"?`${P}px`:P,flex:"none"}:void 0,Nt=j!=null?{width:typeof j=="number"?`${j}px`:j,flex:"none"}:void 0;return T?null:n.jsxs("div",{ref:K,className:_t,style:E,title:F,"data-testid":re,children:[h&&n.jsxs("label",{htmlFor:M,className:"nice-money-input__label",style:gt,children:[h,v&&n.jsx("span",{className:"nice-money-input__required","aria-hidden":!0,children:"*"})]}),n.jsxs("div",{className:"nice-money-input__row",style:Nt,children:[!m&&n.jsx(Se,{value:S,compact:!0,options:s?s.map(X).filter(D=>!!D):void 0,onChange:D=>a==null?void 0:a(D),disabled:B||w,className:"nice-money-input__currency","aria-label":"Currency"}),m&&n.jsx("span",{className:"nice-money-input__symbol","aria-hidden":!0,children:(ae==null?void 0:ae.symbol)??S}),k&&n.jsx("button",{type:"button",className:"nice-money-input__step nice-money-input__step--down",onClick:()=>Ae(-Ie),disabled:B||w||i!=null&&e!=null&&e.amount/Math.pow(10,V)<=i,"aria-label":"Decrease amount",tabIndex:-1,children:"−"}),n.jsx("input",{id:M,name:te,type:"text",inputMode:"decimal",autoComplete:"transaction-amount",className:"nice-money-input__amount",value:ft,onChange:bt,onKeyDown:xt,onFocus:D=>{Re(!0),$==null||$(D)},onBlur:D=>{Re(!1),e&&he((e.amount/Math.pow(10,V)).toFixed(V)),H==null||H(D)},placeholder:g??`0${V>0?"."+"0".repeat(V):""}`,disabled:B,readOnly:w,required:v,"aria-invalid":!!me,"aria-describedby":me||u?`${M}-help`:void 0}),k&&n.jsx("button",{type:"button",className:"nice-money-input__step nice-money-input__step--up",onClick:()=>Ae(Ie),disabled:B||w||l!=null&&e!=null&&e.amount/Math.pow(10,V)>=l,"aria-label":"Increase amount",tabIndex:-1,children:"+"}),N&&n.jsx("span",{className:"nice-money-input__spinner","aria-hidden":!0,children:n.jsx(le.NiceIcon,{name:"refresh",size:14})})]}),O&&Ee&&n.jsx("span",{className:"nice-money-input__preview","aria-live":"polite",children:Ee}),(me||u)&&n.jsx("span",{id:`${M}-help`,className:me?"nice-money-input__error":"nice-money-input__helper",children:me??u})]})}),Bt={number:"",expiry:"",cvc:""},ht=o.forwardRef(function({value:e=Bt,onChange:r,showHolderName:c=!0,requireHolderName:a,showPostalCode:s=!1,acceptedBrands:m,showBrandIcon:i=!0,size:l="md",disabled:d,readOnly:y,loading:g,accessMode:h,label:u,helperText:b,error:f,required:x,className:_,style:v,id:N,title:C,"data-testid":I},A){const P=h==="hidden",j=d||h==="disabled"||g,R=y||h==="readOnly",G=o.useId(),O=N??`nice-cc-${G}`,[k,q]=o.useState({number:!1,expiry:!1,cvc:!1,holder:!1,postal:!1}),E=o.useMemo(()=>ye(e.number),[e.number]),Z=o.useMemo(()=>ve(e,{requireHolder:a??c}),[e,a,c]),te=!m||m.includes(E)||E==="unknown",F=o.useCallback(w=>{const T={...e,...w},ne=ve(T,{requireHolder:a??c});r==null||r(T,ne)},[e,a,c,r]),re=o.useCallback(w=>{const T=w.target.value.replace(/\D/g,"").slice(0,19);F({number:T})},[F]),H=o.useCallback(w=>{const T=w.target.value.replace(/\D/g,"").slice(0,4);let ne=T;T.length>=3?ne=`${T.slice(0,2)}/${T.slice(2)}`:T.length===2&&(ne=`${T}/`),F({expiry:ne})},[F]),$=o.useCallback(w=>{const T=w.target.value.replace(/\D/g,"").slice(0,de(E));F({cvc:T})},[E,F]),U=o.useMemo(()=>Le(e.number,E),[e.number,E]),L=k.number&&e.number.length>0&&(je(e.number)?te?void 0:"Card brand not accepted":Z.errors.number),p=k.expiry&&e.expiry.length>0&&!Pe(e.expiry)?Z.errors.expiry:void 0,K=k.cvc&&e.cvc.length>0&&e.cvc.length!==de(E)?Z.errors.cvc:void 0,B=`nice-credit-card nice-credit-card--${l}`+(j?" nice-credit-card--disabled":"")+(g?" nice-credit-card--loading":"")+(f?" nice-credit-card--error":"")+(_?` ${_}`:"");return P?null:n.jsxs("div",{ref:A,className:B,style:v,title:C,"data-testid":I,children:[u&&n.jsxs("div",{className:"nice-credit-card__title",children:[u,x&&n.jsx("span",{className:"nice-credit-card__required","aria-hidden":!0,children:"*"})]}),n.jsx("div",{className:"nice-credit-card__row",children:n.jsxs("label",{className:"nice-credit-card__field nice-credit-card__field--number",children:[n.jsx("span",{className:"nice-credit-card__label",children:"Card number"}),n.jsxs("span",{className:"nice-credit-card__input-wrapper",children:[n.jsx("input",{id:`${O}-number`,type:"text",inputMode:"numeric",autoComplete:"cc-number",placeholder:E==="amex"?"3782 822463 10005":"1234 1234 1234 1234",value:U,onChange:re,onBlur:()=>q(w=>({...w,number:!0})),disabled:j,readOnly:R,"aria-invalid":!!L,"aria-describedby":L?`${O}-number-err`:void 0,className:"nice-credit-card__input",maxLength:E==="amex"?17:23}),i&&n.jsx(Lt,{brand:E})]}),L&&n.jsx("span",{id:`${O}-number-err`,className:"nice-credit-card__error",children:L})]})}),n.jsxs("div",{className:"nice-credit-card__row nice-credit-card__row--split",children:[n.jsxs("label",{className:"nice-credit-card__field",children:[n.jsx("span",{className:"nice-credit-card__label",children:"Expiry"}),n.jsx("input",{id:`${O}-expiry`,type:"text",inputMode:"numeric",autoComplete:"cc-exp",placeholder:"MM/YY",value:e.expiry,onChange:H,onBlur:()=>{q(T=>({...T,expiry:!0}));const w=Me(e.expiry);w&&w!==e.expiry&&F({expiry:w})},disabled:j,readOnly:R,"aria-invalid":!!p,"aria-describedby":p?`${O}-expiry-err`:void 0,className:"nice-credit-card__input",maxLength:5}),p&&n.jsx("span",{id:`${O}-expiry-err`,className:"nice-credit-card__error",children:p})]}),n.jsxs("label",{className:"nice-credit-card__field",children:[n.jsx("span",{className:"nice-credit-card__label",children:E==="amex"?"CID":"CVC"}),n.jsx("input",{id:`${O}-cvc`,type:"text",inputMode:"numeric",autoComplete:"cc-csc",placeholder:"•".repeat(de(E)),value:e.cvc,onChange:$,onBlur:()=>q(w=>({...w,cvc:!0})),disabled:j,readOnly:R,"aria-invalid":!!K,"aria-describedby":K?`${O}-cvc-err`:void 0,className:"nice-credit-card__input",maxLength:de(E)}),K&&n.jsx("span",{id:`${O}-cvc-err`,className:"nice-credit-card__error",children:K})]})]}),c&&n.jsx("div",{className:"nice-credit-card__row",children:n.jsxs("label",{className:"nice-credit-card__field",children:[n.jsx("span",{className:"nice-credit-card__label",children:"Cardholder name"}),n.jsx("input",{id:`${O}-holder`,type:"text",autoComplete:"cc-name",placeholder:"Jane Doe",value:e.holderName??"",onChange:w=>F({holderName:w.target.value}),onBlur:()=>q(w=>({...w,holder:!0})),disabled:j,readOnly:R,className:"nice-credit-card__input",maxLength:120})]})}),s&&n.jsx("div",{className:"nice-credit-card__row",children:n.jsxs("label",{className:"nice-credit-card__field",children:[n.jsx("span",{className:"nice-credit-card__label",children:"Postal code"}),n.jsx("input",{id:`${O}-postal`,type:"text",autoComplete:"postal-code",value:e.postalCode??"",onChange:w=>F({postalCode:w.target.value}),onBlur:()=>q(w=>({...w,postal:!0})),disabled:j,readOnly:R,className:"nice-credit-card__input",maxLength:16})]})}),(f||b)&&n.jsx("div",{className:f?"nice-credit-card__form-error":"nice-credit-card__helper",role:f?"alert":void 0,children:f??b})]})}),Oe={visa:"VISA",mastercard:"MasterCard",amex:"AMEX",discover:"Discover",diners:"Diners",jcb:"JCB",unionpay:"UnionPay",maestro:"Maestro",mir:"MIR",elo:"Elo",hipercard:"Hipercard",unknown:""};function Lt({brand:t}){return t==="unknown"?null:n.jsx("span",{className:`nice-credit-card__brand nice-credit-card__brand--${t}`,"aria-label":Oe[t],children:Oe[t]})}const zt=o.forwardRef(function({processor:e,amount:r,editableAmount:c,customer:a,currencies:s,description:m,metadata:i,autoCapture:l=!0,submitLabel:d="Pay",onSuccess:y,onError:g,consents:h,className:u,style:b},f){const[x,_]=o.useState(r),[v,N]=o.useState(r.currency),[C,I]=o.useState({number:"",expiry:"",cvc:""}),[A,P]=o.useState(null),[j,R]=o.useState(!1),[G,O]=o.useState(null),k=yt(e),q=o.useMemo(()=>e.supportedCurrencies==="*"?!0:e.supportedCurrencies.includes(x.currency.toUpperCase()),[e,x.currency]),E=o.useMemo(()=>{var U;const $=(U=e.minimums)==null?void 0:U[x.currency.toUpperCase()];return $==null||x.amount>=$},[e,x]),Z=o.useMemo(()=>{var U;const $=(U=e.minimums)==null?void 0:U[x.currency.toUpperCase()];return $==null?null:{amount:$,currency:x.currency}},[e,x.currency]),te=!!(A!=null&&A.isValid),F=!j&&q&&E&&te,re=o.useCallback(async $=>{if($.preventDefault(),!!F){O(null),R(!0);try{const U={amount:x,card:C,customer:a,description:m,metadata:i,idempotencyKey:Ht()},L=await k.authorize(U);if(l&&L.status==="authorized"){const p=await k.capture(L.id,x);y==null||y(p)}else y==null||y(L)}catch(U){const L=U instanceof Error?U:new Error(String(U));O(L.message),g==null||g(L)}finally{R(!1)}}},[F,x,C,a,m,i,l,k,y,g]),H=X(x.currency);return n.jsxs("form",{ref:f,className:"nice-payment-form"+(u?` ${u}`:""),style:b,onSubmit:re,"aria-busy":j,children:[n.jsx("div",{className:"nice-payment-form__amount",children:c?n.jsx(De,{label:"Amount",value:x,currency:v,currencies:s,onChange:$=>$&&_($),onCurrencyChange:$=>{N($),_(U=>({...U,currency:$}))},disabled:j,required:!0,showFormattedPreview:!0}):n.jsxs("div",{className:"nice-payment-form__total",children:[n.jsx("span",{className:"nice-payment-form__total-label",children:"Total"}),n.jsx(ke,{value:x})]})}),m&&n.jsx("p",{className:"nice-payment-form__description",children:m}),n.jsx("div",{className:"nice-payment-form__card",children:n.jsx(ht,{value:C,onChange:($,U)=>{I($),P(U)},disabled:j})}),!q&&n.jsxs("div",{className:"nice-payment-form__warning",role:"alert",children:[e.name," does not accept ",(H==null?void 0:H.name)??x.currency,"."]}),!E&&Z&&n.jsxs("div",{className:"nice-payment-form__warning",role:"alert",children:["Minimum charge for ",e.name," is ",n.jsx(ke,{value:Z}),"."]}),h&&n.jsx("div",{className:"nice-payment-form__consents",children:h}),G&&n.jsx("div",{className:"nice-payment-form__error",role:"alert",children:G}),n.jsx("button",{type:"submit",className:"nice-payment-form__submit",disabled:!F,"aria-disabled":!F,children:j?"Processing…":d}),n.jsxs("p",{className:"nice-payment-form__processor",children:["Secured by ",n.jsx("strong",{children:e.name})]})]})});function Ht(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`}const Yt=o.forwardRef(function({price:e,originalPrice:r,period:c,prefix:a,suffix:s,showDiscountBadge:m=!0,size:i="md",locale:l,className:d,style:y},g){const h=r&&r.currency===e.currency&&r.amount>e.amount,u=o.useMemo(()=>!h||!r?null:Math.round((r.amount-e.amount)/r.amount*100),[h,r,e.amount]),b=`nice-price-tag nice-price-tag--${i}`+(d?` ${d}`:"");return n.jsxs("div",{ref:g,className:b,style:y,children:[a&&n.jsx("span",{className:"nice-price-tag__prefix",children:a}),n.jsxs("span",{className:"nice-price-tag__main",children:[n.jsx("span",{className:"nice-price-tag__amount",children:ee(e,{locale:l})}),c&&n.jsx("span",{className:"nice-price-tag__period",children:c})]}),h&&r&&n.jsx("span",{className:"nice-price-tag__original","aria-label":"Original price",children:n.jsx("s",{children:ee(r,{locale:l})})}),h&&m&&u!=null&&u>0&&n.jsxs("span",{className:"nice-price-tag__discount","aria-label":`${u} percent off`,children:["−",u,"%"]}),s&&n.jsx("span",{className:"nice-price-tag__suffix",children:s})]})}),Gt={amount:0,currency:"USD"},Zt=o.forwardRef(function({source:e,defaultSource:r,onSourceChange:c,targetCurrency:a,defaultTargetCurrency:s,onTargetCurrencyChange:m,provider:i,locale:l,showRateLine:d=!0,className:y,style:g},h){const[u,b]=le.useControllableState({value:e,defaultValue:r,fallbackValue:Gt,onChange:c,componentName:"NiceCurrencyConverter"}),[f,x]=le.useControllableState({value:a,defaultValue:s,fallbackValue:u.currency,onChange:m,componentName:"NiceCurrencyConverter"}),{converted:_,loading:v,error:N}=xe(u,f,i),C=o.useMemo(()=>({amount:Math.pow(10,2),currency:u.currency}),[u.currency]),{converted:I}=xe(d?C:null,f,i);return n.jsxs("div",{ref:h,className:"nice-currency-converter"+(y?` ${y}`:""),style:g,children:[n.jsx("div",{className:"nice-currency-converter__row",children:n.jsx(De,{label:"From",value:u,onChange:A=>A&&b(A),currency:u.currency,onCurrencyChange:A=>b({...u,currency:A}),showFormattedPreview:!1})}),n.jsxs("div",{className:"nice-currency-converter__row",children:[n.jsx("label",{className:"nice-currency-converter__label",children:"To"}),n.jsxs("div",{className:"nice-currency-converter__output",children:[n.jsx(Se,{value:f,onChange:A=>x(A),compact:!0}),n.jsx("span",{className:"nice-currency-converter__amount",children:v?"…":N?"—":_?ee(_,{locale:l}):""})]})]}),d&&I&&n.jsxs("p",{className:"nice-currency-converter__rate",children:["1 ",u.currency," = ",ee(I,{locale:l})," ",n.jsxs("span",{className:"nice-currency-converter__inverse",children:["· 1 ",f," ="," ",ee(W(1/we(I),u.currency),{locale:l})]})]}),N&&n.jsx("p",{className:"nice-currency-converter__error",role:"alert",children:N.message})]})});function qe(t){return{amount:Math.round(t.amount),currency:t.currency}}const Jt=o.forwardRef(function({lines:e,locale:r,rounding:c="line",showTotals:a=!0,showGrandTotal:s=!0,hideRateColumn:m=!1,labels:i,density:l="comfortable",className:d,style:y,id:g},h){const u={label:(i==null?void 0:i.label)??"Item",rate:(i==null?void 0:i.rate)??"VAT",net:(i==null?void 0:i.net)??"Net",vat:(i==null?void 0:i.vat)??"Tax",gross:(i==null?void 0:i.gross)??"Gross",total:(i==null?void 0:i.total)??"Total"},b=o.useMemo(()=>{if(c==="total"){const _=new Map;for(const N of e){let C=_.get(N.vatRate);C||(C=[],_.set(N.vatRate,C)),C.push(N.netAmount)}const v=[];for(const[N,C]of _){const I=C.reduce((j,R)=>oe(j,R),W(0,C[0].currency)),A=qe(_e(I,N)),P=oe(I,A);v.push({rate:N,net:I,vat:A,gross:P})}return v}return e.map(_=>{const v=qe(_e(_.netAmount,_.vatRate)),N=oe(_.netAmount,v);return{label:_.label,rate:_.vatRate,net:_.netAmount,vat:v,gross:N}})},[e,c]),f=o.useMemo(()=>{if(b.length===0)return null;const _=b[0].net.currency;let v=W(0,_),N=W(0,_),C=W(0,_);for(const I of b)v=oe(v,I.net),N=oe(N,I.vat),C=oe(C,I.gross);return{net:v,vat:N,gross:C}},[b]),x=_=>ee(_,{locale:r});return n.jsxs("table",{ref:h,id:g,className:`nice-tax-breakdown nice-tax-breakdown--${l} ${d??""}`,style:y,role:"table","aria-label":u.total,children:[n.jsx("thead",{children:n.jsxs("tr",{children:[b.some(_=>_.label!==void 0)&&n.jsx("th",{scope:"col",children:u.label}),!m&&n.jsx("th",{scope:"col",className:"nice-tax-breakdown__rate",children:u.rate}),n.jsx("th",{scope:"col",className:"nice-tax-breakdown__num",children:u.net}),n.jsx("th",{scope:"col",className:"nice-tax-breakdown__num",children:u.vat}),n.jsx("th",{scope:"col",className:"nice-tax-breakdown__num",children:u.gross})]})}),n.jsx("tbody",{children:b.map((_,v)=>n.jsxs("tr",{children:[b.some(N=>N.label!==void 0)&&n.jsx("td",{children:_.label??""}),!m&&n.jsxs("td",{className:"nice-tax-breakdown__rate",children:[(_.rate*100).toLocaleString(r,{maximumFractionDigits:2}),"%"]}),n.jsx("td",{className:"nice-tax-breakdown__num",children:x(_.net)}),n.jsx("td",{className:"nice-tax-breakdown__num",children:x(_.vat)}),n.jsx("td",{className:"nice-tax-breakdown__num",children:x(_.gross)})]},`${_.rate}-${v}`))}),a&&f&&n.jsx("tfoot",{children:s&&n.jsxs("tr",{className:"nice-tax-breakdown__totals",children:[b.some(_=>_.label!==void 0)&&n.jsx("td",{children:u.total}),!m&&n.jsx("td",{children:b.some(_=>_.label!==void 0)?null:u.total}),n.jsx("td",{className:"nice-tax-breakdown__num",children:x(f.net)}),n.jsx("td",{className:"nice-tax-breakdown__num",children:x(f.vat)}),n.jsx("td",{className:"nice-tax-breakdown__num",children:x(f.gross)})]})})]})}),Vt=o.forwardRef(function(e,r){const{methods:c,value:a,onChange:s,layout:m="list",columns:i=2,currency:l,label:d,name:y,readOnly:g=!1,className:h,style:u,id:b,accessMode:f,"data-testid":x}=e,_=o.useId(),v=y??`nice-pm-${_}`,N=o.useMemo(()=>{if(!l)return c;const P=l.toUpperCase();return c.filter(j=>!j.currencies||j.currencies.map(R=>R.toUpperCase()).includes(P))},[c,l]);if(f==="hidden")return null;const C=g||f==="disabled"||f==="readOnly",I=`nice-payment-method-selector nice-payment-method-selector--${m}`+(h?` ${h}`:""),A=m==="grid"?{gridTemplateColumns:`repeat(${i}, minmax(0, 1fr))`}:void 0;return n.jsxs("div",{ref:r,id:b,className:I,style:u,"data-testid":x,children:[d&&n.jsx("div",{className:"nice-payment-method-selector__label",children:d}),n.jsxs("div",{className:"nice-payment-method-selector__options",style:A,role:"radiogroup","aria-label":d??"Payment method",children:[N.map(P=>{const j=P.id===a,R=C||P.disabled;return n.jsxs("label",{className:"nice-payment-method-selector__option"+(j?" nice-payment-method-selector__option--selected":"")+(R?" nice-payment-method-selector__option--disabled":""),children:[n.jsx("input",{type:"radio",className:"nice-payment-method-selector__radio",name:v,value:P.id,checked:j,disabled:R,onChange:()=>s==null?void 0:s(P.id)}),P.icon&&n.jsx("span",{className:"nice-payment-method-selector__icon",children:P.icon}),n.jsxs("span",{className:"nice-payment-method-selector__text",children:[n.jsx("span",{className:"nice-payment-method-selector__name",children:P.label}),P.description&&n.jsx("span",{className:"nice-payment-method-selector__desc",children:P.description})]})]},P.id)}),N.length===0&&n.jsx("div",{className:"nice-payment-method-selector__empty",children:"No methods available."})]})]})}),Xt=[{target:".nice-payment-provider-config",titleKey:"tutorial.paymentProviderConfig.intro.title",title:"Payment provider",contentKey:"tutorial.paymentProviderConfig.intro.content",content:"Pick a provider, fill its credentials (secrets are masked), choose test/live, enable methods and copy the webhook URL.",placement:"auto"}],Qt={providerId:"",mode:"test",credentials:{},enabledMethods:[]},Wt=o.forwardRef(function(e,r){const{value:c,defaultValue:a,onChange:s,providers:m,onTestConnection:i,showWebhookUrl:l=!0,baseUrl:d,readOnly:y=!1,testLabel:g="Test connection",tutorial:h,className:u,style:b,id:f,accessMode:x,"data-testid":_}=e,[v,N]=le.useControllableState({value:c,defaultValue:a,fallbackValue:Qt,onChange:s,componentName:"NicePaymentProviderConfig"}),C=o.useId(),[I,A]=o.useState(new Set),[P,j]=o.useState(!1),[R,G]=o.useState(null),O=o.useMemo(()=>m?m.map(p=>pe[p]).filter(p=>!!p):pt,[m]),k=pe[v.providerId];if(x==="hidden")return null;const q=y||x==="disabled"||x==="readOnly",E=p=>{G(null),A(new Set),N({providerId:p,mode:v.mode,credentials:{},enabledMethods:[]})},Z=(p,K)=>{N({...v,credentials:{...v.credentials,[p]:K}})},te=p=>{const K=new Set(v.enabledMethods??[]);K.has(p)?K.delete(p):K.add(p),N({...v,enabledMethods:[...K]})},F=p=>{A(K=>{const B=new Set(K);return B.has(p)?B.delete(p):B.add(p),B})},re=async()=>{if(i){j(!0),G(null);try{G(await i(v))}catch(p){G({ok:!1,message:p instanceof Error?p.message:String(p)})}finally{j(!1)}}},H=k!=null&&k.webhookPath?`${(d??"").replace(/\/$/,"")}${k.webhookPath}`:"",$=(k==null?void 0:k.supportedCurrencies)==="*"?"All currencies":((k==null?void 0:k.supportedCurrencies)??[]).join(", "),U="nice-payment-provider-config"+(u?` ${u}`:""),L=((k==null?void 0:k.credentials)??[]).filter(p=>!p.testOnly||v.mode==="test");return n.jsxs("div",{ref:r,id:f,className:U,style:b,"data-testid":_,children:[h&&n.jsx("div",{className:"nice-payment-provider-config__tutorial",children:n.jsx(le.NiceTutorialButton,{steps:le.resolveTutorial(h,Xt)})}),n.jsxs("div",{className:"nice-payment-provider-config__row",children:[n.jsxs("label",{className:"nice-payment-provider-config__field",children:[n.jsx("span",{className:"nice-payment-provider-config__field-label",children:"Provider"}),n.jsxs("select",{className:"nice-payment-provider-config__select",value:v.providerId,disabled:q,onChange:p=>E(p.target.value),children:[n.jsx("option",{value:"",children:"— select provider —"}),O.map(p=>n.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(k==null?void 0:k.hasTestMode)&&n.jsxs("div",{className:"nice-payment-provider-config__mode",role:"group","aria-label":"Mode",children:[n.jsx("button",{type:"button",className:"nice-payment-provider-config__mode-btn"+(v.mode==="test"?" nice-payment-provider-config__mode-btn--active":""),onClick:()=>N({...v,mode:"test"}),disabled:q,children:"Test"}),n.jsx("button",{type:"button",className:"nice-payment-provider-config__mode-btn"+(v.mode==="live"?" nice-payment-provider-config__mode-btn--active":""),onClick:()=>N({...v,mode:"live"}),disabled:q,children:"Live"})]})]}),k&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"nice-payment-provider-config__meta",children:[n.jsx("span",{className:"nice-payment-provider-config__badge",children:k.type}),n.jsx("span",{className:"nice-payment-provider-config__currencies",children:$})]}),n.jsx("div",{className:"nice-payment-provider-config__credentials",children:L.map(p=>{const K=`${C}-${p.key}`,B=p.secret,w=I.has(p.key);return n.jsxs("div",{className:"nice-payment-provider-config__field",children:[n.jsxs("label",{className:"nice-payment-provider-config__field-label",htmlFor:K,children:[p.label,p.required&&n.jsx("span",{className:"nice-payment-provider-config__required",children:" *"})]}),n.jsxs("div",{className:"nice-payment-provider-config__input-wrap",children:[n.jsx("input",{id:K,type:B&&!w?"password":"text",className:"nice-payment-provider-config__input",value:v.credentials[p.key]??"",readOnly:q,autoComplete:B?"new-password":"off",onChange:T=>Z(p.key,T.target.value)}),B&&n.jsx("button",{type:"button",className:"nice-payment-provider-config__reveal",onClick:()=>F(p.key),"aria-label":w?"Hide":"Reveal","aria-pressed":w,children:n.jsx(le.NiceIcon,{name:w?"eye-off":"eye",size:14})})]}),p.help&&n.jsx("span",{className:"nice-payment-provider-config__help",children:p.help})]},p.key)})}),k.supportedMethods&&k.supportedMethods.length>0&&n.jsxs("div",{className:"nice-payment-provider-config__methods",children:[n.jsx("span",{className:"nice-payment-provider-config__field-label",children:"Enabled methods"}),n.jsx("div",{className:"nice-payment-provider-config__method-list",children:k.supportedMethods.map(p=>n.jsxs("label",{className:"nice-payment-provider-config__method",children:[n.jsx("input",{type:"checkbox",checked:(v.enabledMethods??[]).includes(p),disabled:q,onChange:()=>te(p)}),p]},p))})]}),l&&k.webhookPath&&n.jsxs("div",{className:"nice-payment-provider-config__field",children:[n.jsx("span",{className:"nice-payment-provider-config__field-label",children:"Webhook URL"}),n.jsx("code",{className:"nice-payment-provider-config__webhook",children:H})]}),i&&n.jsxs("div",{className:"nice-payment-provider-config__test",children:[n.jsx("button",{type:"button",className:"nice-payment-provider-config__test-btn",onClick:()=>void re(),disabled:q||P,children:P?"Testing…":g}),R&&n.jsxs("span",{className:"nice-payment-provider-config__test-result nice-payment-provider-config__test-result--"+(R.ok?"ok":"error"),children:[n.jsx(le.NiceIcon,{name:R.ok?"check":"close",size:14})," ",R.message??(R.ok?"OK":"Failed")]})]})]})]})});exports.EcbRatesProvider=Ze;exports.ExchangeRateHostProvider=Ye;exports.FrankfurterProvider=ze;exports.FreeForexApiProvider=Je;exports.MockPaymentProcessor=Xe;exports.NICE_CURRENCY_CATALOG=ue;exports.NICE_CURRENCY_CODES=Kt;exports.NICE_PAYMENT_PROCESSORS=mt;exports.NICE_PAYMENT_PROVIDER_LIST=pt;exports.NICE_PAYMENT_PROVIDER_PROFILES=pe;exports.NbpRatesProvider=Ge;exports.NiceCreditCardInput=ht;exports.NiceCurrencyConverter=Zt;exports.NiceCurrencySelector=Se;exports.NiceMoney=ke;exports.NiceMoneyInput=De;exports.NicePaymentForm=zt;exports.NicePaymentMethodSelector=Vt;exports.NicePaymentProviderConfig=Wt;exports.NicePriceTag=Yt;exports.NiceTaxBreakdown=Jt;exports.OpenExchangeRatesProvider=He;exports.StaticExchangeRateProvider=It;exports.addMoney=oe;exports.compareMoney=jt;exports.convertMoney=Ve;exports.createEcbRatesProvider=$t;exports.createFreeForexApiProvider=Ut;exports.createNbpRatesProvider=Rt;exports.createOpenExchangeRatesProvider=At;exports.detectCardBrand=ye;exports.expectedCvcLength=de;exports.findCurrency=X;exports.findPaymentProviderProfile=qt;exports.formatCardNumber=Le;exports.formatMoney=ee;exports.fromMoney=we;exports.isExpiryValid=Pe;exports.isNegative=Pt;exports.isZero=Mt;exports.luhnCheck=je;exports.makeAdyenAdapter=et;exports.makeAutopayAdapter=ot;exports.makeBlikAdapter=lt;exports.makeBraintreeAdapter=nt;exports.makeCoinbaseCommerceAdapter=ut;exports.makeKlarnaAdapter=dt;exports.makeMollieAdapter=rt;exports.makePayPalAdapter=We;exports.makePayUAdapter=ct;exports.makePrzelewy24Adapter=st;exports.makeRazorpayAdapter=at;exports.makeSquareAdapter=tt;exports.makeStripeAdapter=Qe;exports.makeTpayAdapter=it;exports.maskCardNumber=Dt;exports.multiplyMoney=_e;exports.negateMoney=St;exports.normaliseExpiry=Me;exports.parseMoney=Be;exports.registerCurrency=wt;exports.subtractMoney=Ke;exports.toMoney=W;exports.useNiceExchangeRate=xe;exports.useNiceMoney=Ft;exports.useNicePayment=yt;exports.validateCreditCard=ve;