@arcblock/payment-service 1.29.9 → 1.29.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/dist/cf.js +51 -51
- package/dist/index.js +195 -43
- package/package.json +3 -3
- package/web/assets/{account-Clbqiiw3.js → account-DrsnH5wP.js} +1 -1
- package/web/assets/{action-DENqSeOa.js → action-C2c0yWuW.js} +1 -1
- package/web/assets/{actions-CDsj5j8l.js → actions--FNKSNIs.js} +1 -1
- package/web/assets/{actions-BJDN6Op2.js → actions-BEUwbsq1.js} +1 -1
- package/web/assets/{actions-CSpJGOX7.js → actions-C9AfME83.js} +1 -1
- package/web/assets/{actions-BD9BAp3M.js → actions-D2-s31n3.js} +1 -1
- package/web/assets/{actions-BSNy5bOd.js → actions-DXMceTgd.js} +1 -1
- package/web/assets/{actions-0iWP2mcx.js → actions-DeCPtfTK.js} +1 -1
- package/web/assets/{actions-DGQs8fFF.js → actions-DtNZGZWf.js} +1 -1
- package/web/assets/{actions-D3tJgrUn.js → actions-JHsqbHpB.js} +1 -1
- package/web/assets/{actions-CZL47E9r.js → actions-izdZ2Mn4.js} +1 -1
- package/web/assets/{add-price-BpnICuHO.js → add-price-TdXAR3NW.js} +1 -1
- package/web/assets/{admin-CD8ViZ7D.js → admin-BpFv3eF5.js} +1 -1
- package/web/assets/{assign-0vMUDW_C.js → assign-DKRfmN7W.js} +1 -1
- package/web/assets/{attempts-CKlxkJuE.js → attempts-BfbYfiJa.js} +1 -1
- package/web/assets/browser-DF2vfpBa.js +1 -0
- package/web/assets/{change-payment-gAlRmJpv.js → change-payment-j5UC8_h0.js} +1 -1
- package/web/assets/{change-plan-C47wfWH8.js → change-plan-CtXvsIDw.js} +1 -1
- package/web/assets/{click-boundary-CafubiPp.js → click-boundary-Bi28Y0Fq.js} +1 -1
- package/web/assets/{connect-BHHzrwLA.js → connect-CXek4LAE.js} +1 -1
- package/web/assets/{copyable-QrCyyiou.js → copyable-CprMHdhV.js} +1 -1
- package/web/assets/{create-ke4FrPx1.js → create-B-Ubepl_.js} +1 -1
- package/web/assets/{create-DNar5UQD.js → create-BVt_sQ_7.js} +1 -1
- package/web/assets/{create-0PUtkJZY.js → create-BWviSWbC.js} +1 -1
- package/web/assets/{create-BJ1asdcy.js → create-C6jihslA.js} +1 -1
- package/web/assets/{create-C7GOgZZM.js → create-IaalYGmm.js} +1 -1
- package/web/assets/{create-Bgv5ux17.js → create-jzl1m8ZK.js} +1 -1
- package/web/assets/{credit-grant-item-list-CeDAM3qV.js → credit-grant-item-list-DQcvdSRs.js} +1 -1
- package/web/assets/{credit-overview-4zh0H02x.js → credit-overview-CPId2vzk.js} +1 -1
- package/web/assets/{currency-restrictions-BcEm8W45.js → currency-restrictions-Dsupz2ce.js} +1 -1
- package/web/assets/{currency-select-B4ieQBvv.js → currency-select-C8j7QQMP.js} +1 -1
- package/web/assets/{dayjs-DUTDpcNU.js → dayjs-DUNWtvju.js} +1 -1
- package/web/assets/{description-SnR5WxWT.js → description-BHxdy5I3.js} +1 -1
- package/web/assets/{detail-DNcp_u5S.js → detail-B17BN6kU.js} +1 -1
- package/web/assets/detail-BJ-hl5PK.js +10 -0
- package/web/assets/{detail-46aLUdJj.js → detail-BJEqTXDS.js} +1 -1
- package/web/assets/{detail-BQpDGZJQ.js → detail-BdC9VIc6.js} +1 -1
- package/web/assets/{detail-DbU3p040.js → detail-BkRkrKyw.js} +1 -1
- package/web/assets/{detail-DACnmls3.js → detail-BvcI9cB_.js} +1 -1
- package/web/assets/detail-C--ATvwm.js +24 -0
- package/web/assets/{detail-Cg505nKX.js → detail-CHJqYZ0W.js} +1 -1
- package/web/assets/{detail-B0IHl4MI.js → detail-CfvKZ7IV.js} +1 -1
- package/web/assets/{detail-Ct5QNBqu.js → detail-CmIweOLE.js} +1 -1
- package/web/assets/{detail-BXTsnQny.js → detail-D729Bgs6.js} +1 -1
- package/web/assets/{detail-C_Zdfa0y.js → detail-DD1YBtex.js} +1 -1
- package/web/assets/detail-DOcm4Kqg.js +15 -0
- package/web/assets/{detail-Bfnkg0A1.js → detail-DQj1mbhA.js} +1 -1
- package/web/assets/detail-DTXDMIR9.js +15 -0
- package/web/assets/{detail-CsGZMimg.js → detail-DUAJzKsu.js} +1 -1
- package/web/assets/{detail-BwH0DwAi.js → detail-De8PyTyx.js} +1 -1
- package/web/assets/{detail-B_lpOomD.js → detail-DqfxOHky.js} +1 -1
- package/web/assets/{detail-CMBRd4Ct.js → detail-Dzt5tfyZ.js} +1 -1
- package/web/assets/{detail-Tn2R5C8i.js → detail-H0dkKVyS.js} +1 -1
- package/web/assets/{detail-CyMhK5K_.js → detail-MgdgGj5J.js} +1 -1
- package/web/assets/{detail-DCTb8R7F.js → detail-WAmPM6yq.js} +1 -1
- package/web/assets/{detail-B-ceWfZr.js → detail-g6el9Fxj.js} +1 -1
- package/web/assets/did-Bqcz-NjH.js +1 -0
- package/web/assets/{drawer-form-DspWWj3x.js → drawer-form-CQjNFFWk.js} +1 -1
- package/web/assets/{edit-Bkj-OTJh.js → edit-DAU8AWzT.js} +1 -1
- package/web/assets/{editor-AmthipP2.js → editor-vZvxDUTl.js} +1 -1
- package/web/assets/{embed-rRKjDoHi.js → embed-ClYNqZbf.js} +1 -1
- package/web/assets/{filter-toolbar-DXGSTq57.js → filter-toolbar-VvmMATj0.js} +1 -1
- package/web/assets/{form-BmQlJZ84.js → form-4_MzglPj.js} +1 -1
- package/web/assets/{form-cX026J4G.js → form-AFzUvoFE.js} +1 -1
- package/web/assets/{form-B5WW-lS5.js → form-Bro99BjK.js} +1 -1
- package/web/assets/{form-CAPjlw7l.js → form-CnrBCyTJ.js} +1 -1
- package/web/assets/form-Cuvruf4H.js +16 -0
- package/web/assets/{gas-nyR96dB0.js → gas-kw2KMH1u.js} +1 -1
- package/web/assets/{generateCategoricalChart-BadryV3H.js → generateCategoricalChart-BCpuUeC_.js} +1 -1
- package/web/assets/{home-_eX1aim8.js → home-ZNJREzbw.js} +1 -1
- package/web/assets/{index-CbSXdD6E.js → index-ASk8vU2H.js} +1 -1
- package/web/assets/{index-ajD9Iotk.js → index-B4n6PvPu.js} +1 -1
- package/web/assets/{index-BarN7DfU.js → index-B4yaPb7B.js} +5 -5
- package/web/assets/{index-DSe7Dot_.js → index-BHwID_s4.js} +1 -1
- package/web/assets/index-BMcnd_jZ.js +1 -0
- package/web/assets/{index-BTfJ08JU.js → index-BRmN8ViQ.js} +1 -1
- package/web/assets/index-BdbLl6St.js +1 -0
- package/web/assets/{index-CCVDDX0c.js → index-BjKRyxNQ.js} +1 -1
- package/web/assets/index-BjLJQRKY.js +1 -0
- package/web/assets/index-BkNCPnTn.js +1 -0
- package/web/assets/index-BlAwTTmu.js +1 -0
- package/web/assets/{index-C136x0O2.js → index-BtWfmATr.js} +1 -1
- package/web/assets/{index-DNGmCIRP.js → index-C-5n472s.js} +1 -1
- package/web/assets/{index-CW8VfoJO.js → index-C3AP4jq0.js} +1 -1
- package/web/assets/{index-C-RT84yb.js → index-C3Rh1SaB.js} +1 -1
- package/web/assets/index-CDyxbCzc.js +1 -0
- package/web/assets/{index-SOzRg0yJ.js → index-CH_k9MVv.js} +1 -1
- package/web/assets/{index-XaFn2ySq.js → index-CKPfOW6M.js} +1 -1
- package/web/assets/{index-BQjlhCSt.js → index-CPFlZhA2.js} +1 -1
- package/web/assets/{index-Du0Ieh1F.js → index-CPyGjEd3.js} +2 -2
- package/web/assets/index-ChC-jsE2.js +1 -0
- package/web/assets/{index-D-bx9Kam.js → index-CiWvs3j9.js} +1 -1
- package/web/assets/{index-mn5Zdrtn.js → index-D6gv9jHh.js} +1 -1
- package/web/assets/{index-Cd_BD9TM.js → index-D7pWd60Z.js} +1 -1
- package/web/assets/{index-YG5oc8O3.js → index-DAen2-cr.js} +1 -1
- package/web/assets/{index-BRENdB5m.js → index-DNobX-Tr.js} +1 -1
- package/web/assets/{index-Kd_qCyRG.js → index-DY-g0BPU.js} +1 -1
- package/web/assets/{index-D0mynT6_.js → index-DZkpxY-C.js} +1 -1
- package/web/assets/{index-DcddP3R9.js → index-Dh9agU9O.js} +1 -1
- package/web/assets/{index-BBHMsIxJ.js → index-Dju8k6mq.js} +1 -1
- package/web/assets/{index-DeK5Pqjv.js → index-DwDNPqjF.js} +1 -1
- package/web/assets/{index-DEiuhiEo.js → index-Dze0CpfQ.js} +1 -1
- package/web/assets/{index-UYeD8rTJ.js → index-eDERHpkr.js} +1 -1
- package/web/assets/{index-BzABukCz.js → index-mgPU1lyd.js} +1 -1
- package/web/assets/{index-W2uZUlFs.js → index-olGOY5KB.js} +1 -1
- package/web/assets/{index-DoX0A-rP.js → index-oy7LrXGT.js} +1 -1
- package/web/assets/{index-qulrJQ4J.js → index-x7sBb6oM.js} +1 -1
- package/web/assets/{index.es-C8dcCHdW.js → index.es-C2Q6Owow.js} +1 -1
- package/web/assets/{info-card-BvIMFQo5.js → info-card-C9dRgztS.js} +1 -1
- package/web/assets/{info-metric-Dl4ZDm0Z.js → info-metric-ukWq8INi.js} +1 -1
- package/web/assets/{info-row-jI0h_hv4.js → info-row-CaPaNF4L.js} +1 -1
- package/web/assets/{info-row-group-CFuMWJf1.js → info-row-group-Cxo-4Gk5.js} +1 -1
- package/web/assets/{libphonenumber-Qs8PCdM-.js → libphonenumber-CTvobi0D.js} +1 -1
- package/web/assets/{link-CmPoIweR.js → link-DsltSF2Q.js} +1 -1
- package/web/assets/{list-CkHExntK.js → list-B2b-s8wM.js} +1 -1
- package/web/assets/{list-DLB_hd0Q.js → list-BzgF4i3i.js} +1 -1
- package/web/assets/{list-BdSkPjIa.js → list-Cd1O-aDi.js} +1 -1
- package/web/assets/{list-DaK9287Y.js → list-CvM46TsP.js} +1 -1
- package/web/assets/{list-CWMEf-_C.js → list-DtEjqlED.js} +1 -1
- package/web/assets/{list-DVFJwd_I.js → list-O_uCSLFq.js} +1 -1
- package/web/assets/{list-DghnUOc4.js → list-YNWVqjwW.js} +1 -1
- package/web/assets/{list-eFkvVlp5.js → list-ZaBapEXW.js} +1 -1
- package/web/assets/{metadata-BmQTVFku.js → metadata-_hV0ZaVh.js} +1 -1
- package/web/assets/{meter-event-B1JIhVpb.js → meter-event-CPVBpekF.js} +1 -1
- package/web/assets/{metrics-UvxyQbUF.js → metrics-DVPdwpyf.js} +1 -1
- package/web/assets/{overview-Cxc6WKba.js → overview-CGdVIJrJ.js} +1 -1
- package/web/assets/{overview-DrMaIptb.js → overview-CN59I5Sc.js} +1 -1
- package/web/assets/{past-due-CUXkxns0.js → past-due-C3PtU8uo.js} +1 -1
- package/web/assets/pay-XVdSNq__.js +4 -0
- package/web/assets/{payment-method-info-Bsf89VxV.js → payment-method-info-D_qR04xC.js} +1 -1
- package/web/assets/{preview-C-H8pGVw.js → preview-Bdtbh-xk.js} +1 -1
- package/web/assets/{preview-BifsgUGT.js → preview-F3lma170.js} +1 -1
- package/web/assets/{pricing-table-BUJdtkMq.js → pricing-table-Bt2WljzE.js} +1 -1
- package/web/assets/{pricing-table-B3QOaAB5.js → pricing-table-D9FGYBVa.js} +1 -1
- package/web/assets/{product-select-ChEyoJqJ.js → product-select-_72p-5lF.js} +1 -1
- package/web/assets/{recharge-BVT4USAO.js → recharge-CSlKshbU.js} +1 -1
- package/web/assets/{related-credit-grants-JV2ICsR5.js → related-credit-grants-DnKdAit6.js} +3 -3
- package/web/assets/{safe-did-address-CiG_V6Gy.js → safe-did-address-CRTPYo34.js} +1 -1
- package/web/assets/{source-data-viewer-i1q9wNIG.js → source-data-viewer-D1GShrs5.js} +1 -1
- package/web/assets/{status-CUVYrUIG.js → status-3Swm2gK5.js} +1 -1
- package/web/assets/subscription-BX00k6FU.js +1 -0
- package/web/assets/{subscription-DrnSPIfs.js → subscription-Bzeblscr.js} +1 -1
- package/web/assets/table-BN3WBnr3.js +1 -0
- package/web/assets/{tax-code-select-TS07I0rB.js → tax-code-select-j2arPbaE.js} +1 -1
- package/web/assets/{tax-utils-bPjALcVG.js → tax-utils-B8J0Kfnz.js} +1 -1
- package/web/assets/{uploader-CsQNHG4I.js → uploader-BLdAbLR6.js} +1 -1
- package/web/assets/{usage-records-DAUQMJAW.js → usage-records-BAwNs1y8.js} +1 -1
- package/web/assets/{util-DxXTXkeY.js → util-B8B3fsMa.js} +1 -1
- package/web/assets/{vendor-arcblock-BTCAQSUK.js → vendor-arcblock-D1drrE7q.js} +1 -1
- package/web/assets/{vendor-blocklet-DcLR2Cyf.js → vendor-blocklet-B67R14so.js} +2 -2
- package/web/index.html +1 -1
- package/web/assets/browser-DDv4_sgY.js +0 -1
- package/web/assets/detail-B8eOBVSQ.js +0 -15
- package/web/assets/detail-BO3zglCn.js +0 -15
- package/web/assets/detail-C1FupF1D.js +0 -24
- package/web/assets/detail-wU4wNf4s.js +0 -10
- package/web/assets/form-DD-EiA7W.js +0 -16
- package/web/assets/index-BhcoukR2.js +0 -1
- package/web/assets/index-BturOfxo.js +0 -1
- package/web/assets/index-CDVogp6E.js +0 -1
- package/web/assets/index-DcrGSDby.js +0 -1
- package/web/assets/index-Dybqd298.js +0 -1
- package/web/assets/index-EXZPddtw.js +0 -1
- package/web/assets/index-brUCsnBA.js +0 -1
- package/web/assets/pay-omLYkqRA.js +0 -4
- package/web/assets/subscription-BYz_k9dq.js +0 -1
- package/web/assets/table-BrtHemkA.js +0 -1
package/web/index.html
CHANGED
|
@@ -60,7 +60,7 @@ if (!window.blocklet) {
|
|
|
60
60
|
<link rel="dns-prefetch" href="https://js.stripe.com" />
|
|
61
61
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
62
62
|
<meta name="theme-color" content="#4F6AF5" />
|
|
63
|
-
<script type="module" crossorigin src="/.well-known/payment/assets/index-
|
|
63
|
+
<script type="module" crossorigin src="/.well-known/payment/assets/index-B4yaPb7B.js"></script>
|
|
64
64
|
<link rel="stylesheet" crossorigin href="/.well-known/payment/assets/style-BWb904Pt.css">
|
|
65
65
|
</head>
|
|
66
66
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a0 as r}from"./vendor-blocklet-DcLR2Cyf.js";function s(){return r().arcSphere}export{s as u};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import{r as p,u as _e,j as e,A as v,w as Ce,B as a,a3 as c,bv as Se,q as o,ai as we,O as w,b4 as Q,bL as ke,Y as k,x as P,bM as X,v as Pe,a4 as Ie,D as De,bh as ze,N as Me,I as Ne,bf as Ae}from"./vendor-mui-BXZut9Pz.js";import{V as Te,P as W,Z as j,F as Re,G as O,H as ee}from"./vendor-blocklet-DcLR2Cyf.js";import{d as We,u as Oe,a as Le,i as L,j as g,y as $e,z as Ue,p as te,A as Fe,m as Ee,B as Be,e as D,k as re,l as He}from"./index-BarN7DfU.js";import{e as Ge,a as qe,L as Ve}from"./vendor-react-BPknnnEA.js";import{C as ne}from"./currency-GstdXsJf.js";import{C as Ke}from"./link-CmPoIweR.js";import{I as se}from"./info-metric-Dl4ZDm0Z.js";import{I as l}from"./info-row-jI0h_hv4.js";import{I as Ye}from"./info-row-group-CFuMWJf1.js";import{S as Ze}from"./description-SnR5WxWT.js";import{P as Je,D as Qe,S as Xe,V as et}from"./payment-method-info-Bsf89VxV.js";import{S as tt}from"./metrics-UvxyQbUF.js";import{S as rt}from"./actions-DGQs8fFF.js";import{u as nt,a as st,b as at}from"./subscription-DrnSPIfs.js";import{f as it}from"./dayjs-DUTDpcNU.js";import{c as ot}from"./util-DxXTXkeY.js";import{u as ct}from"./browser-DDv4_sgY.js";import"./copyable-QrCyyiou.js";import"./usage-records-DAUQMJAW.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";import"./generateCategoricalChart-BadryV3H.js";import"./status-CUVYrUIG.js";import"./lodash-B4Ozcv0x.js";const I={mode:"percent",percent:.5},lt=s=>D.get(`/api/subscriptions/${s}`).then(x=>x.data),dt=s=>D.get(`/api/subscriptions/${s}/overdraft-protection`).then(x=>x.data),mt=(s,x)=>D.get(`/api/subscriptions/${s}/cycle-amount`,{params:x}).then(r=>r.data);function Lt(){const{id:s}=Ge(),x=qe(),{t:r,locale:ae}=Te(),{isMobile:d}=We(),{session:$}=Oe(),{connect:z}=Le(),ie=ct(),{loading:oe,error:U,data:t,refresh:_}=W(()=>lt(s)),{hasUnpaid:ce,checkUnpaidInvoices:M}=nt(s),{hasPendingAmount:F,pendingAmount:N}=st(s,t?.paymentCurrency),E=["active","trialing","past_due"].includes(t?.status||"")&&t?.paymentMethod?.type==="arcblock",[le,A]=p.useState(!1),[m,b]=p.useState(I),[B,T]=p.useState(I),[H,G]=p.useState(!1),{liveRateInfo:f}=at({subscriptionId:s,currencyId:t?.paymentCurrency?.id,enabled:!!t?.paymentCurrency?.id});p.useEffect(()=>{const n=t?.slippage_config;if(n&&typeof n=="object"){const i=n.mode==="rate"?"rate":"percent",u=Number(n.percent),y=Number.isFinite(u)&&u>=0?u:.5,S={mode:i,percent:y,...n.min_acceptable_rate?{min_acceptable_rate:String(n.min_acceptable_rate)}:{},...n.base_currency?{base_currency:String(n.base_currency)}:{},...n.updated_at_ms?{updated_at_ms:Number(n.updated_at_ms)}:{}};b(S),T(S);return}b(I),T(I)},[t]);const de=p.useMemo(()=>(t?.items||[]).some(n=>{const i=n.upsell_price||n.price;return i&&i?.pricing_type==="dynamic"}),[t?.items]),q=p.useMemo(()=>{if(m.min_acceptable_rate)return m.min_acceptable_rate;if(f?.rate&&m.percent!==void 0){const n=Number(f.rate),{percent:i}=m;if(Number.isFinite(n)&&n>0&&Number.isFinite(i))return(n*(1-i/100)).toFixed(8).replace(/\.?0+$/,"")}return null},[m.min_acceptable_rate,m.percent,f?.rate]),{data:h=null,loading:me,run:pe}=W(()=>dt(s),{ready:E}),V=_e(),{data:ue={amount:"0",gas:"0"}}=W(()=>mt(s,{overdraftProtection:!0}),{refreshDeps:[s],ready:E}),C=p.useRef(void 0),xe=!!h?.enabled,he=p.useCallback(n=>{C.current=n},[]),K=p.useCallback(()=>{A(!1),b(B)},[B]),fe=async()=>{if(s){G(!0);try{const n={...m,...m.base_currency?{}:{base_currency:f?.base_currency||"USD"}},i=await D.put(`/api/subscriptions/${s}/slippage`,{slippage_config:n});T(n),await _(),A(!1);const u=i.data?.delegation_warning;u&&!u.sufficient?(j.info(r("payment.customer.changePayment.reauthorizationRequired")),z.open({locale:ae,containerEl:void 0,action:"delegation",prefix:Re(He(),"/api/did"),saveConnect:!1,extraParams:{subscriptionId:s},messages:{scan:r("common.connect.defaultScan"),title:r("payment.customer.changePayment.reauthorizationTitle"),confirm:r("common.connect.confirm")},onSuccess:async()=>{z.close(),j.success(r("payment.customer.changePayment.reauthorizationCompleted")),await _()},onClose:()=>{z.close()},onError:y=>{console.error("Delegation failed:",y),j.error(re(y))}})):j.success(r("common.saved"))}catch(n){j.error(re(n))}finally{G(!1)}}};if(t?.customer?.did&&$?.user?.did&&t.customer.did!==$.user.did)return e.jsx(v,{severity:"error",children:r("common.accessDenied")});if(U)return e.jsx(v,{severity:"error",children:U.message});if(oe||!t)return e.jsx(Ce,{});const R=t?.serviceType==="credit"||t?.paymentCurrency?.type==="credit"||t?.items?.some(n=>n?.price?.product?.type==="credit"||n?.price?.metadata?.credit_config),Y=t?.paymentMethod?.type==="arcblock"&&!me&&!!h&&["active","trialing","past_due"].includes(t.status)&&!R,ye=()=>{const n=t?.overdraft_protection?.enabled,i=h?.upcoming?.amount||"0",u=h?.gas||"0",y=!xe||h.unused==="0"||new O(h.unused).lt(new O(i).add(new O(u))),S=+ee(ue.amount||"0",t.paymentCurrency?.decimal),ge=+ee(h?.unused||"0",t.paymentCurrency?.decimal),be=ve=>{if(!t?.pending_invoice_item_interval)return"";const{interval:Z,interval_count:je}=t.pending_invoice_item_interval,J=ve*je;return["hour","day","week","month","year"].includes(Z)?r("common.estimatedDuration",{duration:it(J,Z,{t:r})}):r("customer.overdraftProtection.estimatedDuration",{duration:J,unit:r("customer.overdraftProtection.intervals").toLowerCase()})};return n?n&&y?e.jsx(P,{size:"small",color:"error",sx:{fontSize:"12px",textAlign:"left"},onClick:()=>C.current?.openOverdraftProtection({enabled:!0}),children:r("customer.overdraftProtection.insufficient")}):e.jsxs(c,{direction:"row",sx:{alignItems:"center",flexWrap:"wrap",justifyContent:"flex-end",columnGap:.5},children:[e.jsxs(c,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:[e.jsx(ze,{sx:{fontSize:"16px",color:"success.main",verticalAlign:"middle"}}),e.jsx(o,{sx:{color:"success.main",fontWeight:500},children:r("customer.overdraftProtection.enabled")})]}),!d&&e.jsx(k,{orientation:"vertical",flexItem:!0,sx:{mx:1,borderColor:"divider"}}),e.jsxs(o,{sx:{color:"text.primary",display:"flex",alignItems:"center",gap:.5,fontWeight:500},children:[e.jsx(Me,{src:t.paymentCurrency?.logo,sx:{width:16,height:16},alt:t.paymentCurrency?.symbol}),e.jsxs(a,{sx:{display:"flex",alignItems:"baseline"},children:[L(h?.unused,t.paymentCurrency.decimal),e.jsxs(o,{sx:{color:"text.secondary",fontSize:"14px",ml:.5},children:[t.paymentCurrency.symbol,"(",be(Math.ceil(ge/S)),")"]})]})]}),t?.overdraft_protection?.enabled&&e.jsx(w,{title:r("customer.overdraftProtection.setting"),placement:"top",children:e.jsx(Ne,{size:"small",sx:{ml:-1,color:"text.disabled","&:hover":{color:"primary.main",backgroundColor:"transparent"}},onClick:()=>C.current?.openOverdraftProtection({enabled:!0}),children:e.jsx(X,{fontSize:"small",sx:{fontSize:16}})})})]}):e.jsxs(c,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(o,{sx:{color:"text.lighter"},children:r("customer.overdraftProtection.disabled")}),e.jsx(P,{size:"small",sx:{fontSize:"13px",pt:0,pb:0,height:3,color:"text.link","&:hover":{backgroundColor:"primary.lighter"}},onClick:()=>C.current?.openOverdraftProtection({enabled:!0}),children:r("customer.overdraftProtection.open")})]})};return e.jsxs(e.Fragment,{children:[e.jsxs(pt,{children:[e.jsxs(a,{children:[!t.paymentMethodDetails&&["active","trialing"].includes(t.status)&&e.jsx(v,{severity:"warning",sx:{mb:2},children:r("admin.subscription.noPaymentMethodWarning")}),ce&&e.jsx(v,{severity:"error",sx:{mb:2},children:r("customer.unpaidInvoicesWarningTip")}),F&&N&&e.jsx(v,{severity:"error",sx:{mb:2},children:r("customer.pendingAmountWarningTip",{amount:L(N,t?.paymentCurrency?.decimal),symbol:t?.paymentCurrency?.symbol})}),e.jsxs(c,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",position:"relative"},children:[ie?e.jsx(a,{}):e.jsxs(c,{direction:"row",onClick:()=>x("/customer",{replace:!0}),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(Se,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(o,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:r("payment.customer.subscriptions.title")})]}),e.jsx(c,{direction:"row",sx:{gap:1},children:e.jsx(rt,{subscription:t,onChange:n=>{_(),n==="batch-pay"&&M()},showExtra:!0,showDelegation:!0,showOverdraftProtection:{show:Y,onChange:()=>pe()},showRecharge:!0,mode:d?"menu-only":"primary-buttons",actionProps:{cancel:{variant:"outlined",color:"primary"},recover:{variant:"outlined",color:"info"},pastDue:{variant:"outlined",color:"primary"}},setUp:he})})]}),e.jsxs(a,{sx:{mt:d?2:4,display:"flex",border:d?`1px solid ${V.palette.divider}`:"none",borderRadius:d?1:0,p:d?2:0,gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(c,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(c,{direction:"row",sx:{alignItems:"center",flexWrap:"wrap",gap:1},children:e.jsx(Ze,{subscription:t,variant:"h1"})})}),e.jsxs(c,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap",flex:1,width:"100%","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(tt,{subscription:t}),Y&&e.jsx(se,{label:e.jsxs(c,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:[e.jsx(o,{component:"span",sx:{fontSize:14,fontWeight:500},children:r("customer.overdraftProtection.title")}),e.jsx(we,{href:"https://www.arcblock.io/content/blog/en/payment-kit-v117-sub-guard#listen-to-the-audio-overview",target:"_blank",rel:"noopener noreferrer",sx:{display:"flex",alignItems:"center"},children:e.jsx(w,{title:r("customer.overdraftProtection.learnMore"),placement:"top",children:e.jsx(Q,{fontSize:"small",sx:{fontSize:"14px",ml:-.2,color:"text.secondary",cursor:"pointer",opacity:.8,"&:hover":{color:"primary.main"}}})})}),t.overdraft_protection?.payment_details?.arcblock?.staking?.address&&e.jsx(w,{title:e.jsxs(o,{sx:{fontFamily:"monospace",fontSize:"13px"},children:[r("customer.overdraftProtection.stakingAddress"),":",t.overdraft_protection?.payment_details?.arcblock?.staking?.address]}),arrow:!0,placement:"top",children:e.jsx(ke,{sx:{fontSize:"16px",color:"text.secondary",cursor:"pointer",ml:1,"&:hover":{color:"primary.main"},display:{xs:"none",md:"block"}}})})]}),value:ye()}),R&&F&&e.jsx(se,{label:r("admin.customer.creditGrants.pendingAmount"),value:e.jsx(o,{sx:{color:"error.main"},children:`${L(N,t?.paymentCurrency?.decimal)} ${t?.paymentCurrency?.symbol}`})})]})]})]}),d?null:e.jsx(k,{}),e.jsxs(a,{className:"section",sx:{containerType:"inline-size",border:d?`1px solid ${V.palette.divider}`:"none",borderRadius:d?1:0,p:d?2:0},children:[e.jsx(o,{variant:"h3",className:"section-header",sx:{mb:3},children:r("admin.details")}),e.jsxs(Ye,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 980px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:d?.5:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 980px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary",lineHeight:1,fontSize:14},".tx-link-text":{fontSize:14,lineHeight:1}},children:[e.jsx(l,{label:r("common.customer"),value:e.jsx(Ke,{customer:t.customer,linked:!1,size:"small"})}),e.jsx(l,{label:r("common.createdAt"),value:g(t.created_at)}),e.jsx(l,{label:r("admin.subscription.currentPeriod"),value:[g(t.current_period_start*1e3),g(t.current_period_end*1e3)].join(" ~ ")}),e.jsx(l,{label:r("admin.subscription.trialingPeriod"),value:t.trial_end&&t.trial_start?[g(t.trial_start*1e3),g(t.trial_end*1e3)].join(" ~ "):""}),t.status==="paused"&&!!t.pause_collection?.resumes_at&&e.jsx(l,{label:r("common.resumesAt"),value:g(t.pause_collection.resumes_at*1e3)}),e.jsx(l,{label:r("admin.subscription.collectionMethod"),value:t.collection_method}),e.jsx(l,{label:r("admin.paymentMethod._name"),value:e.jsx(ne,{logo:t.paymentMethod?.logo,name:t.paymentMethod?.name,size:16})}),e.jsx(l,{label:r("admin.paymentCurrency.name"),value:e.jsxs(c,{direction:"row",spacing:2,children:[e.jsx(ne,{logo:t.paymentCurrency.logo,name:t.paymentCurrency.symbol,size:16}),ot(t)&&e.jsx(P,{variant:"text",sx:{color:"text.link"},size:"small",onClick:async()=>{t?.overdraft_protection?.enabled&&await M()||x(`/customer/subscription/${t.id}/change-payment`)},children:r("payment.customer.subscriptions.changePayment")})]})}),de&&t.paymentMethod?.type!=="stripe"&&e.jsx(l,{label:e.jsxs(c,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:[e.jsx("span",{children:r("common.slippage")}),e.jsx(w,{title:r("common.slippageTooltip"),placement:"top",children:e.jsx(Q,{sx:{fontSize:"0.875rem",color:"text.secondary",cursor:"help"}})})]}),value:e.jsxs(c,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(o,{color:q?"text.primary":"text.secondary",children:$e(q)||"—"}),e.jsx(P,{variant:"text",size:"small",sx:{color:"text.link",minWidth:"auto",p:.5},onClick:()=>A(!0),disabled:H,children:e.jsx(X,{sx:{fontSize:"1rem"}})})]})}),e.jsx(l,{label:r("admin.subscription.payerAddress"),value:e.jsx(Je,{subscriptionId:s,customer:t.customer,paymentMethodDetails:t.paymentMethodDetails,editable:["active","trialing","past_due"].includes(t.status),onUpdate:()=>{_(),M()},paymentMethodType:t.paymentMethod?.type})}),t.payment_details&&Ue(t.payment_details,t.paymentMethod)&&e.jsx(l,{label:r("common.delegateTxHash"),value:e.jsx(te,{details:t.payment_details,method:t.paymentMethod,size:16})}),t.paymentMethod?.type==="arcblock"&&t.payment_details?.arcblock?.staking?.tx_hash&&e.jsx(l,{label:r("common.stakeTxHash"),value:e.jsx(a,{sx:{".MuiTypography-root":{color:"text.link"}},children:e.jsx(te,{details:{arcblock:{tx_hash:t.payment_details?.arcblock?.staking?.tx_hash,payer:""}},method:t.paymentMethod,size:16})})}),!!t.recovered_from&&e.jsx(l,{label:r("common.recoverFrom"),value:e.jsx(Ve,{to:`/customer/subscription/${t.recovered_from}`,target:"_blank",children:t.recovered_from})})]})]}),e.jsx(k,{}),t.discountStats&&e.jsxs(a,{className:"section",children:[e.jsx(o,{variant:"h3",className:"section-header",sx:{mb:1.5},children:r("admin.subscription.discount")}),e.jsx(a,{className:"section-body",children:e.jsx(Qe,{discountStats:t.discountStats})})]}),e.jsx(a,{className:"divider"}),e.jsxs(a,{className:"section",children:[e.jsx(o,{variant:"h3",className:"section-header",sx:{mb:1.5},children:r("admin.products")}),e.jsx(a,{className:"section-body",children:e.jsx(Xe,{data:t.items,currency:t.paymentCurrency,mode:"customer"})})]}),(()=>{const n=t.items?.map(i=>i.price?.product?.vendor_config||[]).flat();return!n||n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsx(a,{className:"section",children:e.jsx(et,{vendorServices:n,subscriptionId:s,isCanceled:t.status==="canceled"})})]})})(),e.jsx(a,{className:"divider"}),R?e.jsxs(a,{className:"section",children:[e.jsx(o,{variant:"h3",className:"section-header",children:r("admin.creditTransactions.title")}),e.jsx(a,{className:"section-body",children:e.jsx(Fe,{customer_id:t.customer_id,subscription_id:t.id,showAdminColumns:!1,includeGrants:!0})})]}):e.jsxs(a,{className:"section",children:[e.jsx(o,{variant:"h3",className:"section-header",children:r("customer.invoiceHistory")}),e.jsx(a,{className:"section-body",children:e.jsx(Ee,{subscription_id:t.id,type:"table",include_staking:!0,status:"open,paid,uncollectible,void"})})]})]}),e.jsxs(Pe,{open:le,onClose:K,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:2}},children:[e.jsx(Ie,{children:r("payment.checkout.quote.slippageLimit.title")}),e.jsx(De,{sx:{pb:3},children:e.jsx(Be,{value:m.percent,onChange:n=>b(i=>({...i,percent:n})),config:m,onConfigChange:b,exchangeRate:f?.rate||null,baseCurrency:f?.base_currency||"USD",disabled:H,onCancel:K,onSave:fe})})]})]})}const pt=Ae(c)`
|
|
2
|
-
margin-bottom: 24px;
|
|
3
|
-
gap: 24px;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
@media (max-width: ${({theme:s})=>s.breakpoints.values.md}px) {
|
|
6
|
-
. {
|
|
7
|
-
border: none;
|
|
8
|
-
box-shadow: none;
|
|
9
|
-
padding: 0;
|
|
10
|
-
}
|
|
11
|
-
.section-header {
|
|
12
|
-
font-size: 18px;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`;export{Lt as default};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import{r as A,j as e,A as j,w as G,B as i,a3 as s,bv as N,q as a,x as T,N as d,Y as u,bf as k}from"./vendor-mui-BXZut9Pz.js";import{V as S,P as Y}from"./vendor-blocklet-DcLR2Cyf.js";import{u as M,a2 as P,a3 as g,i as f,j as x,N as B,p as H,A as F,e as R}from"./index-BarN7DfU.js";import{I as n}from"./info-metric-Dl4ZDm0Z.js";import{S as y}from"./header-ivXuPt06.js";import{C as W}from"./credit-grant-item-list-CeDAM3qV.js";import{I as l}from"./info-row-jI0h_hv4.js";import{I as z}from"./info-row-group-CFuMWJf1.js";import{u as L}from"./browser-DDv4_sgY.js";import{e as $,a as q}from"./vendor-react-BPknnnEA.js";import"./util-DxXTXkeY.js";import"./lodash-B4Ozcv0x.js";import"./copyable-QrCyyiou.js";const E=o=>R.get(`/api/credit-grants/${o}`).then(c=>c.data);function ne(){const{id:o}=$(),c=q(),{t:r}=S(),{session:p}=M(),v=L(),{loading:b,error:h,data:t}=Y(()=>E(o)),w=A.useCallback(()=>{c("/customer",{replace:!0})},[c]);if(t?.customer?.did&&p?.user?.did&&t.customer.did!==p.user.did)return e.jsx(j,{severity:"error",children:r("common.accessDenied")});if(h)return e.jsx(j,{severity:"error",children:h.message});if(b||!t)return e.jsx(G,{});const C=t?.status==="depleted",I=m=>{switch(m){case"granted":return r("admin.customer.creditGrants.status.granted");case"pending":return r("admin.customer.creditGrants.status.pending");case"depleted":return r("admin.customer.creditGrants.status.depleted");case"expired":return r("admin.customer.creditGrants.status.expired");case"voided":return r("admin.customer.creditGrants.status.voided");default:return m}},_=()=>{if(!t.amount||!t.remaining_amount)return 0;const m=parseFloat(t.amount),D=parseFloat(t.remaining_amount);return(m-D)/m*100};return e.jsxs(O,{children:[e.jsxs(i,{children:[e.jsxs(s,{className:"page-header",direction:"row",justifyContent:"space-between",alignItems:"center",sx:{position:"relative"},children:[v?e.jsx(i,{}):e.jsxs(s,{direction:"row",onClick:w,alignItems:"center",sx:{fontWeight:"normal",cursor:"pointer"},children:[e.jsx(N,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(a,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:r("admin.customer.creditGrants.title")})]}),t.metadata?.invoice_id&&e.jsx(T,{variant:"outlined",size:"small",onClick:()=>c(`/customer/invoice/${t.metadata.invoice_id}`),children:r("admin.customer.creditGrants.viewInvoice")})]}),e.jsxs(i,{mt:4,sx:{display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(s,{direction:"row",justifyContent:"space-between",alignItems:"center",children:e.jsx(s,{direction:"row",alignItems:"center",flexWrap:"wrap",gap:1,children:e.jsx(s,{direction:"column",alignItems:"flex-start",justifyContent:"space-around",children:e.jsx(a,{variant:"h2",color:"text.primary",children:t.name||t.id})})})}),e.jsxs(s,{className:"section-body",justifyContent:"flex-start",flexWrap:"wrap",sx:{"hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(n,{label:r("common.status"),value:e.jsx(P,{status:t.status,label:I(t.status)})}),e.jsx(n,{label:r("admin.customer.creditGrants.originalAmount"),value:e.jsxs(s,{direction:"row",alignItems:"center",spacing:.5,children:[e.jsx(d,{src:t.paymentCurrency?.logo,sx:{width:16,height:16},alt:t.paymentCurrency?.symbol}),e.jsx(a,{variant:"body2",children:g(f(t.amount,t.paymentCurrency.decimal),t.paymentCurrency.symbol)})]}),divider:!0}),e.jsx(n,{label:r("common.remainingCredit"),value:e.jsxs(s,{direction:"row",alignItems:"center",spacing:.5,children:[e.jsx(d,{src:t.paymentCurrency?.logo,sx:{width:16,height:16},alt:t.paymentCurrency?.symbol}),e.jsx(a,{variant:"body2",children:g(f(t.remaining_amount,t.paymentCurrency.decimal),t.paymentCurrency.symbol)})]}),divider:!0}),e.jsx(n,{label:r("admin.customer.creditGrants.usage"),value:e.jsxs(a,{variant:"body2",color:C?"error.main":"text.primary",children:[_().toFixed(1),"%"]}),divider:!0}),e.jsx(n,{label:r("common.effectiveDate"),value:x(t.effective_at?t.effective_at*1e3:t.created_at,"YYYY-MM-DD HH:mm:ss")}),t.expires_at?e.jsx(n,{label:r("common.expirationDate"),value:x(t.expires_at*1e3,"YYYY-MM-DD HH:mm:ss")}):null]})]})]}),e.jsxs(i,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(y,{title:r("admin.details")}),e.jsxs(z,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(l,{label:r("common.customer"),value:e.jsxs(s,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(d,{src:B(t.customer?.did,t.customer?.updated_at?new Date(t.customer.updated_at).toISOString():"",24),alt:t.customer?.name,sx:{width:24,height:24}}),e.jsx(a,{children:t.customer?.name})]})}),e.jsx(l,{label:r("common.scope"),value:e.jsx(a,{children:t.applicability_config?.scope?.prices?r("common.specific"):r("common.general")})}),e.jsx(l,{label:r("admin.creditProduct.priority.label"),value:e.jsx(a,{children:t.priority})}),e.jsx(l,{label:r("common.createdAt"),value:x(t.created_at)}),t.chain_detail?.mint?.hash&&t.paymentMethod?.type==="arcblock"&&e.jsx(l,{label:r("common.mintTxHash"),value:e.jsx(H,{details:{arcblock:{tx_hash:t.chain_detail.mint.hash,payer:""}},method:t.paymentMethod,mode:"customer"})})]})]}),e.jsx(u,{}),t.items&&t.items.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{className:"section",children:[e.jsx(y,{title:r("admin.creditProduct.associatedPrices.label")}),e.jsx(i,{className:"section-body",children:e.jsx(W,{data:t.items,currency:t.paymentCurrency})})]}),e.jsx(u,{})]}),e.jsx(u,{}),e.jsxs(i,{className:"section",children:[e.jsx(a,{variant:"h3",className:"section-header",children:r("admin.creditTransactions.title")}),e.jsx(i,{className:"section-body",children:e.jsx(F,{customer_id:t.customer_id,credit_grant_id:t.id,showAdminColumns:!1,showTimeFilter:!0})})]})]})}const O=k(s)`
|
|
2
|
-
margin-bottom: 24px;
|
|
3
|
-
gap: 24px;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
@media (max-width: ${({theme:o})=>o.breakpoints.values.md}px) {
|
|
6
|
-
. {
|
|
7
|
-
border: none;
|
|
8
|
-
box-shadow: none;
|
|
9
|
-
padding: 0;
|
|
10
|
-
}
|
|
11
|
-
.section-header {
|
|
12
|
-
font-size: 18px;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`;export{ne as default};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import{j as e,r as T,q as l,B as c,w as G,a3 as x,x as S,bf as H,u as Q,A as P,bv as X,O as E,Y as k}from"./vendor-mui-BXZut9Pz.js";import{V as $,P as F,ah as ee,Y as te,Z as N,F as se}from"./vendor-blocklet-DcLR2Cyf.js";import{i as O,n as w,o as q,j as b,p as A,T as ae,q as ne,e as K,d as oe,a as ie,u as re,k as W,r as ce,s as le,t as de,v as me,l as pe,w as ue}from"./index-BarN7DfU.js";import{T as xe}from"./gas-nyR96dB0.js";import{b as he,e as ye,L as fe}from"./vendor-react-BPknnnEA.js";import{l as j}from"./lodash-B4Ozcv0x.js";import{C as ge}from"./currency-GstdXsJf.js";import{C as be}from"./link-CmPoIweR.js";import{I as h}from"./info-row-jI0h_hv4.js";import{D as je,R as ve,I as _e}from"./related-credit-grants-JV2ICsR5.js";import{g as we}from"./util-DxXTXkeY.js";import{I}from"./info-metric-Dl4ZDm0Z.js";import{I as Ce}from"./info-row-group-CFuMWJf1.js";import{u as ke}from"./browser-DDv4_sgY.js";import"./browser-Bb9g-cvG.js";import"./usage-records-DAUQMJAW.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";import"./generateCategoricalChart-BadryV3H.js";const Ie=s=>{const o={};return s.forEach(a=>{const r=new Date(a.created_at).toLocaleDateString();o[r]||(o[r]=[]),o[r]?.push(a)}),o},U=(s={})=>{const o=new URLSearchParams;return Object.keys(s).forEach(a=>{o.set(a,String(s[a]))}),K.get(`/api/refunds?${o.toString()}`).then(a=>a.data)},R=10,Se=T.memo(({invoice_id:s})=>{const o="invoice-table",{t:a,locale:r}=$(),[m,y]=T.useState({pageSize:R,page:1}),{loading:f,data:p={list:[],count:0}}=F(()=>U({...m,invoice_id:s}),{refreshDeps:[m]}),u=[{label:a("common.amount"),name:"id",width:80,align:"right",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsxs(l,{component:"strong",sx:{fontWeight:600},children:[O(t?.amount,t?.paymentCurrency.decimal),t?.paymentCurrency.symbol]})}}},{label:a("common.status"),name:"status",width:100,options:{filter:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsx(w,{label:t.status,color:q(t.status)})}}},{label:a("common.type"),name:"type",width:80,options:{filter:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return e.jsx(w,{label:a(`refund.type.${t.type}`)})}}},{label:a("common.description"),name:"description",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i];return t.description?j.capitalize(j.toLower(t.description.replace(/_/g," "))):t.id}}},{label:a("common.createdAt"),name:"created_at",options:{sort:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return b(t.created_at)}}},{label:a("common.updatedAt"),name:"updated_at",options:{sort:!0,customBodyRenderLite:(n,i)=>{const t=p.list[i];return b(t.updated_at)}}},{label:a("common.txHash"),name:"",options:{customBodyRenderLite:(n,i)=>{const t=p.list[i],v=t.payment_details;return["arcblock","ethereum","base"].map(C=>!!v?.[C]?.tx_hash).find(Boolean)?e.jsx(c,{sx:{".MuiTypography-root":{color:"text.link"}},children:e.jsx(A,{details:v,method:t.paymentMethod,mode:"customer"})}):a("common.none")}}}],d=({page:n,rowsPerPage:i})=>{m.pageSize!==i?y(t=>({...t,pageSize:i,page:1})):m.page!==n+1&&y(t=>({...t,page:n+1}))};return e.jsx(Re,{children:e.jsx(ae,{hasRowLink:!0,durable:`__${o}__`,durableKeys:["page","rowsPerPage","searchText"],data:p.list,columns:u,options:{count:p.count,page:m.page-1,rowsPerPage:m.pageSize},loading:f,onChange:d,toolbar:!1,sx:{mt:2},showMobile:!1,locale:r,mobileTDFlexDirection:"row",emptyNodeText:a("payment.customer.refund.emptyList")})})}),Re=H(c)`
|
|
2
|
-
@media (max-width: ${({theme:s})=>s.breakpoints.values.md}px) {
|
|
3
|
-
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root {
|
|
4
|
-
> div {
|
|
5
|
-
width: fit-content;
|
|
6
|
-
flex: inherit;
|
|
7
|
-
font-size: 14px;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
.invoice-summary {
|
|
11
|
-
padding-right: 20px;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
`,Te=T.memo(({invoice_id:s})=>{const{t:o}=$(),{data:a,loadMore:r,loadingMore:m,loading:y}=ee(u=>{const d=u?Math.ceil(u.list.length/R)+1:1;return U({page:d,pageSize:R,invoice_id:s})},{reloadDeps:[s]});if(y||!a)return e.jsx(G,{});if(a&&a.list.length===0)return e.jsx(l,{sx:{color:"text.secondary"},children:o("payment.customer.refund.empty")});const f=a&&a.list.length<a.count,p=Ie(a.list);return e.jsxs(x,{direction:"column",sx:{gap:1,mt:1},children:[Object.entries(p).map(([u,d])=>e.jsxs(c,{children:[e.jsx(l,{sx:{fontWeight:"bold",color:"text.secondary",mt:2,mb:1},children:u}),d.map(n=>e.jsxs(x,{direction:{xs:"column",sm:"row"},sx:{gap:{xs:.5,sm:1.5,md:3},flexWrap:"nowrap",my:1},children:[e.jsx(c,{sx:{flex:3},children:e.jsx(l,{children:ne(n.created_at)})}),e.jsx(c,{sx:{flex:2},children:e.jsxs(l,{sx:{textAlign:"right"},children:[O(n.amount,n.paymentCurrency.decimal)," ",n.paymentCurrency.symbol]})}),e.jsx(c,{sx:{flex:3},children:e.jsx(w,{label:n.status,color:q(n.status)})}),e.jsx(c,{sx:{flex:3},children:e.jsx(l,{children:n.description?j.capitalize(j.toLower(n.description.replace(/_/g," "))):"-"})}),e.jsx(c,{sx:{flex:3,minWidth:"220px"},children:(n.payment_details?.arcblock?.tx_hash||n.payment_details?.ethereum?.tx_hash||n.payment_details?.base?.tx_hash)&&e.jsx(A,{details:n.payment_details,method:n.paymentMethod,mode:"customer"})})]},n.id))]},u)),e.jsxs(c,{children:[f&&e.jsx(S,{variant:"text",type:"button",color:"inherit",onClick:r,disabled:m,children:m?o("common.loadingMore",{resource:o("payment.customer.payments")}):o("common.loadMore",{resource:o("payment.customer.payments")})}),!f&&a.count>R&&e.jsx(l,{sx:{color:"text.secondary"},children:o("common.noMore",{resource:o("payment.customer.payments")})})]})]})});function De({type:s="list",...o}){return s==="table"?e.jsx(Se,{...o}):e.jsx(Te,{...o})}const Me=s=>K.get(`/api/invoices/${s}`).then(o=>o.data);function Qe(){const{t:s,locale:o}=$(),[a]=he(),{isMobile:r}=oe(),{connect:m}=ie(),y=ye(),f=Q(),p=ke(),[u,d]=te({downloading:!1,paying:!1}),{loading:n,error:i,data:t,runAsync:v}=F(()=>Me(y.id)),g=a.get("action"),{session:C}=re(),D=t?.checkoutSession?.submit_type==="donate",z=()=>{d({paying:!0}),m.open({action:"collect",saveConnect:!1,locale:o,extraParams:{invoiceId:y.id,action:g,allowCreatePI:t?.status==="uncollectible"},messages:{scan:"",title:s(`payment.customer.invoice.${g||"pay"}`),success:s(`payment.customer.invoice.${g||"pay"}Success`),error:s(`payment.customer.invoice.${g||"pay"}Error`),confirm:""},onSuccess:async()=>{m.close(),d({paying:!1}),await v()},onClose:()=>{m.close(),d({paying:!1})},onError:_=>{d({paying:!1}),N.error(W(_))}})},Y=()=>{d({paying:!0}),m.close()};if(T.useEffect(()=>{i?.response?.status===403?Y():["pay","renew"].includes(g)&&["open","uncollectible"].includes(t?.status)&&z()},[i]),t?.customer?.did&&C?.user?.did&&t.customer.did!==C.user.did)return e.jsx(P,{severity:"error",children:s("common.accessDenied")});if(i)return e.jsx(P,{severity:"error",children:W(i)});if(n||!t)return e.jsx(G,{});const M=t.paymentMethod?.type==="arcblock"&&["stake","stake_overdraft_protection"].includes(t.billing_reason),L=t.paymentMethod?.type==="arcblock"&&t.billing_reason.includes("slash_stake"),V=t.billing_reason==="overdraft_protection",B=t.paymentIntent?.payment_details||t.metadata?.payment_details,Z=["open","paid","uncollectible"].includes(t.status)&&!D&&!j.isEmpty(t.lines);return e.jsxs(Le,{direction:"column",spacing:3,children:[e.jsxs(x,{direction:"row",sx:{justifyContent:"space-between"},children:[p?e.jsx(c,{}):e.jsxs(x,{direction:"row",onClick:()=>we("/customer"),sx:{alignItems:"center",fontWeight:"normal",padding:"10px 0",cursor:"pointer"},children:[e.jsx(X,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(l,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:s("common.previous")})]}),e.jsxs(x,{direction:"row",spacing:1,sx:{justifyContent:"flex-end",alignItems:"center"},children:[Z&&e.jsx(je,{data:t}),t?.paymentLink?.donation_settings?.reference&&e.jsx(S,{variant:"outlined",onClick:()=>{window.open(t?.paymentLink?.donation_settings?.reference,"_blank")},children:s("customer.payout.viewReference")}),["open","uncollectible"].includes(t.status)&&!V&&(t.paymentMethod?.type==="stripe"?e.jsx(ce,{invoice:t,paymentMethod:t.paymentMethod,onSuccess:async()=>{N.close(),d({paying:!1}),await v()},onError:()=>{d({paying:!1})},onClose:()=>{d({paying:!1})},children:(_,J)=>e.jsx(S,{variant:"outlined",color:"primary",size:"small",sx:{borderColor:"divider"},disabled:u.paying||J,onClick:()=>{d({paying:!0}),_()},children:s("payment.customer.invoice.pay")})}):e.jsx(S,{variant:"outlined",color:"primary",size:"small",sx:{borderColor:"divider"},disabled:u.paying,onClick:z,children:s("payment.customer.invoice.pay")}))]})]}),t.status==="uncollectible"&&t.metadata?.slippage?.below_threshold&&e.jsx(P,{severity:"warning",sx:{mt:2},children:e.jsx(l,{variant:"body2",children:s("payment.customer.invoice.slippageExceededDetail",{currentRate:t.metadata.slippage.rate_at_invoice||"—",minRate:t.metadata.slippage.min_acceptable_rate||"—"})})}),e.jsxs(c,{sx:{mt:r?"0 !important":4,display:"flex",border:r?`1px solid ${f.palette.divider}`:"none",borderRadius:r?1:0,p:r?2:0,gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(x,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsx(x,{direction:"row",sx:{alignItems:"center",flexWrap:"wrap",gap:1},children:e.jsx(l,{variant:"h1",children:t.number})})}),e.jsxs(x,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},".info-metric-label":{mb:r?.5:1},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"},gap:{xs:1,sm:1,md:3}},children:[e.jsx(I,{label:s("common.status"),value:e.jsxs(x,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(E,{title:t.status==="void"?s("payment.customer.invoice.noPaymentRequired"):"",arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(w,{label:t.status,color:le(t.status)})})}),t.status==="uncollectible"&&t.metadata?.slippage?.below_threshold&&e.jsx(E,{title:s("payment.customer.invoice.slippageExceededDetail",{currentRate:t.metadata.slippage.rate_at_invoice||"—",minRate:t.metadata.slippage.min_acceptable_rate||"—"}),arrow:!0,placement:"top",children:e.jsx("span",{children:e.jsx(w,{label:s("payment.customer.invoice.slippageExceeded"),color:"warning"})})})]}),divider:!0}),t.subscription&&e.jsx(I,{label:s("admin.subscription.name"),value:e.jsx(fe,{to:`/customer/subscription/${t.subscription.id}`,children:e.jsx(l,{variant:"body1",sx:{color:"text.link"},children:t.subscription.description||t.subscription.id})}),divider:!0}),e.jsx(I,{label:s("common.createdAt"),value:b(t.created_at),divider:!0}),t.period_start>0&&t.period_end>0&&e.jsx(I,{label:s("admin.subscription.currentPeriod"),value:[b(t.period_start*1e3),b(t.period_end*1e3)].join(" ~ "),divider:!0})]})]}),e.jsx(k,{}),e.jsxs(c,{className:"section",sx:{containerType:"inline-size",border:r?_=>`1px solid ${_.palette.divider}`:"none",borderRadius:r?1:0,p:r?2:0},children:[e.jsx(l,{variant:"h3",className:"section-header",sx:{mb:3},children:s("payment.customer.invoice.details")}),e.jsxs(Ce,{sx:{display:"grid",columnGap:16,gridTemplateColumns:{xs:"repeat(1, 1fr)",lg:"repeat(2, 1fr)"},"@container (min-width: 980px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:r?.5:1,flexDirection:{xs:"column",lg:"row"},alignItems:{xs:"flex-start",lg:"center"},"@container (min-width: 980px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary",fontSize:14,lineHeight:1},".tx-link-text":{fontSize:14,lineHeight:1}},children:[e.jsx(h,{label:s("admin.invoice.billTo"),value:e.jsx(be,{customer:t.customer,linked:!1,size:"small"})}),e.jsx(h,{label:s("admin.invoice.from"),value:t.statement_descriptor||blocklet.appName}),e.jsx(h,{label:s("admin.invoice.description"),value:de(t,o)?.description}),t.status_transitions?.paid_at&&e.jsx(h,{label:s("admin.invoice.paidAt"),value:b(t.status_transitions.paid_at*1e3)}),e.jsx(h,{label:s("admin.paymentCurrency.name"),value:e.jsx(ge,{logo:t.paymentCurrency.logo,name:`${t.paymentCurrency.symbol} (${t.paymentMethod.name})`})}),(M||L)&&e.jsx(h,{label:s(L?"common.slashStakeAmount":"common.stakeAmount"),value:`${me(t.total,t.paymentCurrency.decimal)} ${t.paymentCurrency.symbol}`}),(!!t.paymentIntent?.payment_details?.ethereum||!!t.paymentIntent?.payment_details?.base)&&e.jsx(h,{label:s("common.txGas"),value:e.jsx(xe,{details:t.paymentIntent.payment_details,method:t.paymentMethod})}),B&&e.jsx(h,{label:s(M?"common.stakeTxHash":`common.${B?.arcblock?.type||"transfer"}TxHash`),value:e.jsx(A,{details:B,method:t.paymentMethod,mode:"customer"})}),t?.relatedInvoice&&e.jsx(h,{label:s("customer.invoice.relatedInvoice"),value:e.jsx(l,{variant:"body1",component:"a",onClick:()=>{window.open(se(pe(),`/customer/invoice/${t.relatedInvoice?.id}`),"_self")},sx:{color:"text.link",cursor:"pointer"},children:t.relatedInvoice?.number})})]})]}),D&&!j.isEmpty(t.paymentIntent?.beneficiaries)&&e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsx(c,{className:"section",children:e.jsx(l,{variant:"h3",className:"section-header",children:s("customer.invoice.donation")})}),e.jsx(c,{sx:{maxWidth:800},children:e.jsx(ue,{data:t?.paymentIntent?.beneficiaries,currency:t.paymentCurrency,totalAmount:t?.amount_paid})})]}),t?.relatedCreditGrants&&t.relatedCreditGrants.length>0&&e.jsx(ve,{grants:t.relatedCreditGrants}),!L&&!D&&e.jsxs(e.Fragment,{children:[!M&&e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsxs(c,{className:"section",children:[e.jsx(l,{variant:"h3",className:"section-header",sx:{mb:1.5},children:s("admin.invoiceItems")}),e.jsx(_e,{invoice:t,simple:!0})]})]}),e.jsx(k,{}),e.jsxs(c,{className:"section",children:[e.jsx(l,{variant:"h3",className:"section-header",children:s("admin.refunds")}),e.jsx(c,{className:"section-body",children:e.jsx(De,{invoice_id:t.id,type:"table"})})]})]})]})}const Le=H(x)`
|
|
15
|
-
.invoice-summary-wrapper {
|
|
16
|
-
display: 'grid';
|
|
17
|
-
grid-template-columns: '50% 50%';
|
|
18
|
-
}
|
|
19
|
-
@media (max-width: ${({theme:s})=>s.breakpoints.values.md}px) {
|
|
20
|
-
.section-header {
|
|
21
|
-
font-size: 18px;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`;export{Qe as default};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{r as y,j as e,A as f,w as _,B as i,a3 as s,bv as C,q as n,x as h,N as I,Y as k,a7 as S,bf as A}from"./vendor-mui-BXZut9Pz.js";import{V as D,P as E}from"./vendor-blocklet-DcLR2Cyf.js";import{u as T,a3 as N,i as G,j as m,N as z,p as B,e as $}from"./index-BarN7DfU.js";import{S as R}from"./source-data-viewer-i1q9wNIG.js";import{I as d}from"./info-metric-Dl4ZDm0Z.js";import{S as j}from"./header-ivXuPt06.js";import{I as o}from"./info-row-jI0h_hv4.js";import{I as M}from"./info-row-group-CFuMWJf1.js";import{u as W}from"./browser-DDv4_sgY.js";import{e as P,a as q}from"./vendor-react-BPknnnEA.js";import"./util-DxXTXkeY.js";import"./lodash-B4Ozcv0x.js";const H=c=>$.get(`/api/credit-transactions/${c}`).then(a=>a.data);function se(){const{id:c}=P(),a=q(),{t:r}=D(),{session:x}=T(),g=W(),{loading:v,error:u,data:t}=E(()=>H(c)),b=y.useCallback(()=>{a("/customer",{replace:!0})},[a]);if(t?.customer?.did&&x?.user?.did&&t.customer.did!==x.user.did)return e.jsx(f,{severity:"error",children:r("common.accessDenied")});if(u)return e.jsx(f,{severity:"error",children:u.message});if(v||!t)return e.jsx(_,{});const w=l=>{if(!l)return null;const p={pending:{label:r("common.pending"),color:"warning"},completed:{label:r("common.completed"),color:"success"},failed:{label:r("common.failed"),color:"error"}}[l]||{label:l,color:"default"};return e.jsx(S,{label:p.label,size:"small",color:p.color})};return e.jsxs(O,{children:[e.jsxs(i,{children:[e.jsxs(s,{className:"page-header",direction:"row",justifyContent:"space-between",alignItems:"center",sx:{position:"relative"},children:[g?e.jsx(i,{}):e.jsxs(s,{direction:"row",onClick:b,alignItems:"center",sx:{fontWeight:"normal",cursor:"pointer"},children:[e.jsx(C,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(n,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:r("admin.creditTransactions.title")})]}),e.jsxs(s,{direction:"row",spacing:1,children:[t.creditGrant&&e.jsx(h,{variant:"outlined",size:"small",onClick:()=>a(`/customer/credit-grant/${t.credit_grant_id}`),children:r("common.viewGrant")}),t.subscription&&e.jsx(h,{variant:"outlined",size:"small",onClick:()=>a(`/customer/subscription/${t.subscription_id}`),children:r("common.viewSubscription")})]})]}),e.jsxs(i,{mt:4,sx:{display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(s,{direction:"row",justifyContent:"space-between",alignItems:"center",children:e.jsxs(s,{direction:"column",alignItems:"flex-start",justifyContent:"space-around",children:[e.jsx(n,{variant:"h2",color:"text.primary",children:t.description||r("common.creditTransaction")}),e.jsx(n,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:t.id})]})}),e.jsxs(s,{className:"section-body",justifyContent:"flex-start",flexWrap:"wrap",sx:{"hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(d,{label:r("common.creditAmount"),value:e.jsx(s,{direction:"row",alignItems:"center",spacing:.5,children:e.jsxs(n,{variant:"body2",sx:{color:"error.main"},children:["-",N(G(t.credit_amount,t.creditGrant?.paymentCurrency?.decimal||0),t.creditGrant?.paymentCurrency?.symbol||"")]})}),divider:!0}),t.transfer_status&&e.jsx(d,{label:r("common.transferStatus"),value:w(t.transfer_status),divider:!0}),e.jsx(d,{label:r("common.createdAt"),value:m(t.created_at)})]})]})]}),e.jsxs(i,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(j,{title:r("admin.details")}),e.jsxs(M,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}}},children:[e.jsx(o,{label:r("common.customer"),value:e.jsxs(s,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(I,{src:z(t.customer?.did,t.customer?.updated_at?new Date(t.customer.updated_at).toISOString():"",24),alt:t.customer?.name,sx:{width:24,height:24}}),e.jsx(n,{children:t.customer?.name})]})}),e.jsx(o,{label:r("common.creditGrant"),value:e.jsx(n,{component:"span",onClick:()=>a(`/customer/credit-grant/${t.credit_grant_id}`),sx:{color:"text.link",cursor:"pointer"},children:t.creditGrant?.name||t.credit_grant_id})}),t.subscription&&e.jsx(o,{label:r("admin.subscription.name"),value:e.jsx(n,{component:"span",onClick:()=>a(`/customer/subscription/${t.subscription_id}`),sx:{color:"text.link",cursor:"pointer"},children:t.subscription.description||t.subscription_id})}),t.transfer_hash&&t.paymentMethod&&e.jsx(o,{label:r("common.transferTxHash"),value:e.jsx(B,{details:{arcblock:{tx_hash:t.transfer_hash,payer:""}},method:t.paymentMethod,mode:"customer"})}),e.jsx(o,{label:r("admin.meterEvent.reportedAt"),value:m(t.meterEvent?.timestamp?t.meterEvent.timestamp*1e3:t.meterEvent?.created_at||t.created_at)}),e.jsx(o,{label:r("admin.meterEvent.processedAt"),value:m(t.meterEvent?.processed_at?t.meterEvent.processed_at*1e3:t.created_at)})]})]}),t.meterEvent?.source_data&&e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsxs(i,{className:"section",children:[e.jsx(j,{title:r("common.sourceData")}),e.jsx(i,{className:"section-body",children:e.jsx(R,{data:t.meterEvent.source_data})})]})]})]})}const O=A(s)`
|
|
2
|
-
margin-bottom: 24px;
|
|
3
|
-
gap: 24px;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
@media (max-width: ${({theme:c})=>c.breakpoints.values.md}px) {
|
|
6
|
-
.section-header {
|
|
7
|
-
font-size: 18px;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
`;export{se as default};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{u as P,j as a,r as w,w as F,q as T,bf as j}from"./vendor-mui-BXZut9Pz.js";import{V as v,Y as E,$ as I,X as D}from"./vendor-blocklet-DcLR2Cyf.js";import{d as R,L as S}from"./index-BarN7DfU.js";import"./vendor-react-BPknnnEA.js";const{Elements:z,PaymentElement:N,useElements:V,useStripe:W,loadStripe:q,LinkAuthenticationElement:L}=globalThis.__STRIPE_COMPONENTS__,O=j("div")`
|
|
2
|
-
width: 100%;
|
|
3
|
-
opacity: 0;
|
|
4
|
-
transition: opacity 300ms ease;
|
|
5
|
-
&.visible {
|
|
6
|
-
opacity: 1;
|
|
7
|
-
}
|
|
8
|
-
`;function $({clientSecret:p,intentType:u,customer:e,mode:f,onConfirm:x,onSkip:g=null,returnUrl:y="",submitButtonText:C=""}){const r=W(),l=V(),{t:m}=v(),d=P(),[t,n]=E({message:"",confirming:!1,loaded:!1,showBillingForm:!1,isTransitioning:!1,paymentMethod:"card"}),_=i=>{const o=i.value?.type;(o==="google_pay"||o==="apple_pay")&&!s(e.address)&&!t.showBillingForm?(n({isTransitioning:!0}),setTimeout(()=>{n({isTransitioning:!1,paymentMethod:o,showBillingForm:!0})},300)):n({showBillingForm:!1,paymentMethod:o,isTransitioning:!1})},s=i=>i&&i.line1&&i.city&&i.state&&i.postal_code&&i.country;w.useEffect(()=>{if(!r||!p)return;r[u==="payment_intent"?"retrievePaymentIntent":"retrieveSetupIntent"](p).then(({paymentIntent:o,setupIntent:h})=>{switch((o||h)?.status){case"succeeded":n({message:m("paymentCredit.preparePayMessage.succeeded")});break;case"processing":n({message:m("paymentCredit.preparePayMessage.processing")});break}})},[r,p]);const b=w.useCallback(async i=>{if(i.preventDefault(),!(!r||!l))try{n({confirming:!0,message:""});const o=u==="payment_intent"?"confirmPayment":"confirmSetup",{error:h}=await l.submit();if(h){n({confirming:!1});return}const{error:c,paymentIntent:B,setupIntent:M}=await r[o]({elements:l,redirect:"if_required",confirmParams:{return_url:y||window.location.href,...t.showBillingForm?{}:{payment_method_data:{billing_details:{name:e.name,phone:e.phone,email:e.email,address:{...e.address||{},country:e.address?.country||"us",line1:e.address?.line1||"",line2:e.address?.line2||"",city:e.address?.city||"",state:e.address?.state||"",postal_code:e.address?.postal_code||"00000"}}}}}}),k=B||M;if(k?.status==="canceled"||k?.status==="requires_payment_method"){n({confirming:!1});return}if(n({confirming:!1}),c){if(c.type==="validation_error")return;n({message:c.message});return}x()}catch(o){console.error(o),n({confirming:!1,message:o.message})}},[e,u,r,t.showBillingForm,y]);return a.jsxs(A,{onSubmit:b,children:[(!t.paymentMethod||["link","card"].includes(t.paymentMethod))&&a.jsx(L,{options:{defaultValues:{email:e.email}}}),a.jsx(O,{className:t.isTransitioning?"":"visible",children:a.jsx(N,{options:{layout:"auto",fields:{billingDetails:t.showBillingForm?"auto":"never"},readOnly:t.confirming,defaultValues:{billingDetails:{name:e.name,phone:e.phone,email:e.email,address:e.address}},appearance:{theme:d.palette.mode,variables:{colorPrimary:d.palette.primary.main,colorBackground:d.palette.background.paper,colorText:d.palette.text.primary,colorDanger:d.palette.error.main,borderRadius:"4px"}}},onChange:_,onReady:()=>n({loaded:!0})})}),(!r||!l||!t.loaded)&&a.jsx(D,{relative:"parent",children:a.jsx(F,{})}),r&&l&&t.loaded&&a.jsxs(a.Fragment,{children:[a.jsx(S,{fullWidth:!0,sx:{mt:2,mb:1,borderRadius:0,fontSize:"0.875rem"},type:"submit",disabled:t.confirming||!t.loaded,loading:t.confirming,variant:"contained",color:"primary",size:"large",children:C||m("payment.checkout.continue",{action:m(`payment.checkout.${f}`)})}),g&&a.jsx(S,{fullWidth:!0,sx:{mb:1,borderRadius:0,fontSize:"0.875rem",borderColor:"divider"},disabled:t.confirming,variant:"outlined",color:"primary",onClick:()=>g(),children:m("payment.checkout.skipPaymentMethod",{defaultValue:"Skip, bind later"})})]}),t.message&&a.jsx(T,{sx:{mt:1,color:"error.main"},children:t.message})]})}const A=j("form")`
|
|
9
|
-
display: flex;
|
|
10
|
-
flex-direction: column;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
align-items: center;
|
|
13
|
-
width: 100%;
|
|
14
|
-
height: 100%;
|
|
15
|
-
min-height: 320px;
|
|
16
|
-
`;function H({clientSecret:p,intentType:u,publicKey:e,mode:f,customer:x,onConfirm:g,onCancel:y,onSkip:C=null,returnUrl:r="",title:l="",submitButtonText:m=""}){const d=q(e),{isMobile:t}=R(),{t:n,locale:_}=v(),s=P(),[b,i]=E({open:!0,closable:!0}),o=(h,c)=>{c!=="backdropClick"&&(i({open:!1}),y())};return a.jsx(I,{title:l||n("payment.checkout.cardPay",{action:n(`payment.checkout.${f}`)}),showCloseButton:b.closable,open:b.open,onClose:o,disableEscapeKeyDown:!0,sx:{".StripeElement":{minWidth:t?"100%":"500px",py:1},form:{justifyContent:"flex-start"},".StripeElement--focus":{borderColor:s.palette.primary.main},".StripeElement--invalid":{borderColor:s.palette.error.main},".StripeElement--complete":{borderColor:s.palette.success.main}},PaperProps:{style:{minWidth:t?"100%":"500px"}},children:a.jsx(z,{options:{clientSecret:p,locale:_==="zh"?"zh-CN":"en",appearance:{theme:s.palette.mode,variables:{colorPrimary:s.palette.primary.main,colorBackground:s.palette.background.paper,colorText:s.palette.text.primary,colorDanger:s.palette.error.main}}},stripe:d,children:a.jsx($,{clientSecret:p,intentType:u,mode:f,customer:x,onConfirm:g,onSkip:C,returnUrl:r,submitButtonText:m})})})}export{H as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./vendor-mui-BXZut9Pz.js";import{E as r}from"./list-DaK9287Y.js";import"./vendor-blocklet-DcLR2Cyf.js";import"./vendor-react-BPknnnEA.js";import"./index-BarN7DfU.js";import"./table-BrtHemkA.js";function a(){return t.jsx(r,{features:{toolbar:!1}})}export{a as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./vendor-mui-BXZut9Pz.js";import{I as r}from"./list-eFkvVlp5.js";import"./vendor-blocklet-DcLR2Cyf.js";import"./vendor-react-BPknnnEA.js";import"./index-BarN7DfU.js";import"./table-BrtHemkA.js";import"./cache-state-lld4zuDg.js";import"./link-CmPoIweR.js";import"./filter-toolbar-DXGSTq57.js";import"./lodash-B4Ozcv0x.js";import"./product-select-ChEyoJqJ.js";import"./info-card-BvIMFQo5.js";import"./action-DENqSeOa.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";function d(){return t.jsx(r,{features:{customer:!0,toolbar:!0,filter:!0},include_staking:!0})}export{d as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./vendor-mui-BXZut9Pz.js";import{S as i}from"./list-CWMEf-_C.js";import"./vendor-blocklet-DcLR2Cyf.js";import"./vendor-react-BPknnnEA.js";import"./index-BarN7DfU.js";import"./table-BrtHemkA.js";import"./cache-state-lld4zuDg.js";import"./link-CmPoIweR.js";import"./filter-toolbar-DXGSTq57.js";import"./lodash-B4Ozcv0x.js";import"./product-select-ChEyoJqJ.js";import"./info-card-BvIMFQo5.js";import"./index-CbSXdD6E.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";import"./description-SnR5WxWT.js";import"./status-CUVYrUIG.js";function l(){return t.jsx(i,{})}export{l as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./vendor-mui-BXZut9Pz.js";import{R as r}from"./list-DLB_hd0Q.js";import"./vendor-blocklet-DcLR2Cyf.js";import"./vendor-react-BPknnnEA.js";import"./index-BarN7DfU.js";import"./table-BrtHemkA.js";import"./lodash-B4Ozcv0x.js";import"./link-CmPoIweR.js";import"./filter-toolbar-DXGSTq57.js";import"./product-select-ChEyoJqJ.js";import"./info-card-BvIMFQo5.js";import"./actions-0iWP2mcx.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";import"./cache-state-lld4zuDg.js";function c(){return t.jsx(r,{})}export{c as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./vendor-mui-BXZut9Pz.js";import{P as o}from"./list-BdSkPjIa.js";import"./vendor-blocklet-DcLR2Cyf.js";import"./vendor-react-BPknnnEA.js";import"./index-BarN7DfU.js";import"./table-BrtHemkA.js";import"./util-DxXTXkeY.js";import"./lodash-B4Ozcv0x.js";import"./cache-state-lld4zuDg.js";import"./link-CmPoIweR.js";import"./filter-toolbar-DXGSTq57.js";import"./product-select-ChEyoJqJ.js";import"./info-card-BvIMFQo5.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";function c(){return t.jsx(o,{})}export{c as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as n}from"./vendor-blocklet-DcLR2Cyf.js";import{j as e,e as r}from"./vendor-mui-BXZut9Pz.js";import{u as i,P as a}from"./index-BarN7DfU.js";import{e as c}from"./vendor-react-BPknnnEA.js";const m={pay:r.lazy(()=>n(()=>import("./pay-omLYkqRA.js"),[])),"pricing-table":r.lazy(()=>n(()=>import("./pricing-table-BUJdtkMq.js"),[]))};function p(){const{action:o,id:t}=c(),s=m[o];return e.jsx(s,{id:t})}function x(){const{session:o,connectApi:t}=i();return e.jsx(a,{session:o,connect:t,children:e.jsx(p,{})})}export{x as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./vendor-mui-BXZut9Pz.js";import{P as r}from"./list-DghnUOc4.js";import"./vendor-blocklet-DcLR2Cyf.js";import"./vendor-react-BPknnnEA.js";import"./index-BarN7DfU.js";import"./table-BrtHemkA.js";import"./util-DxXTXkeY.js";import"./lodash-B4Ozcv0x.js";import"./cache-state-lld4zuDg.js";import"./link-CmPoIweR.js";import"./filter-toolbar-DXGSTq57.js";import"./product-select-ChEyoJqJ.js";import"./info-card-BvIMFQo5.js";import"./actions-D3tJgrUn.js";import"./actions-BJDN6Op2.js";import"./click-boundary-CafubiPp.js";function d(){return t.jsx(r,{})}export{d as default};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as p,j as t,u as We,B as _,ah as ce,p as An,a7 as Ke,a3 as D,N as Ce,bO as Jt,q as g,a1 as Ne,aV as Dn,i as mt,Q as Mn,bn as en,I as Ve,bo as zn,a2 as tn,bp as nn,aY as Nn,w as ft,bP as rn,x as Ee,bQ as Fn,L as sn,bj as $n,bR as xt,bS as Wn,bT as Pt,be as On,aZ as ht,o as on,A as Un,bs as Ln,bt as qn,bU as Bn,bV as Hn,aT as nt,ad as rt,b4 as Tt,Y as lt,O as Vn,bW as At,M as Qn,bX as Dt,F as Gn,bC as Kn}from"./vendor-mui-BXZut9Pz.js";import{a3 as q,aN as Yn,A as Xn,U as Zn,G as z,H as Te,L as Xe,ab as gt,Z as Fe,V as be,P as ut,W as Jn,F as an}from"./vendor-blocklet-DcLR2Cyf.js";import{ae as ee,af as X,ag as er,ah as tr,ai as nr,aj as rr,ak as ir,al as _e,am as Ie,an as yt,ao as sr,ap as or,d as Ze,aq as Ye,ar as He,as as Ae,at as $e,au as cn,av as xe,aw as ar,ax as ln,a as un,e as dt,ay as Be,i as cr,a8 as Re,a3 as lr,ad as ur,R as dr,az as pr,aA as dn,aa as mr,aB as fr,aC as xr,aD as hr,U as gr,O as yr,l as pn,a0 as br,aE as _r,I as Mt,aF as Sr,aG as mn,aH as zt,aI as wr}from"./index-BarN7DfU.js";import{b as vr}from"./vendor-react-BPknnnEA.js";function je(e){const n=e;return n?.response?.data?.error?n.response.data.error:e instanceof Error?e.message:typeof e=="string"?e:n?.message||"Unknown error"}function pt(e){const n=e,r=n?.response?.data;return{message:r?.error||n?.message||"Unknown error",code:r?.code,data:r,isCancelled:n?.name==="CanceledError"||n?.name==="AbortError"}}function kr(e){const n=e.line_items||[];if(n.length===0)return null;const r=n[0],i=r.upsell_price||r.price,s=i?.product;if(!s)return null;const o=i?.recurring,a=e.mode==="subscription"?"subscription":"payment",c={day:"daily",week:"weekly",month:"monthly",year:"yearly"};return{name:s.name||"",description:s.description||"",images:s.images||[],features:(s.features||[]).map(l=>({name:l.name||"",icon:l.icon})),billing:{mode:a,interval:o?.interval||null,intervalCount:o?.interval_count||1,displayInterval:o?c[o.interval]||o.interval:""},metadata:s.metadata||{}}}function jr(e){const n=e.subscription_data;return!n&&e.mode==="payment"?null:{mode:e.mode||"payment",showStake:!n?.no_stake,confirmMessage:""}}function Cr(e){const n=e.metadata,r=n?.page_info,i=n?.show_product_features??r?.show_product_features;return{formPurposeDescription:r?.form_purpose_description,showProductFeatures:`${i}`=="true"}}function Ir(e){const[n,r]=p.useState(!0),[i,s]=p.useState(null),[o,a]=p.useState(null),c=p.useRef(null),l=p.useRef(!0),u=p.useRef(null),f=e?.startsWith("plink_"),d=q(async()=>{if(!f)return e;if(u.current)return u.current;const{data:v}=await ee.post(X.START_PAYMENT_LINK(e)),C=v?.checkoutSession?.id;if(!C)throw new Error("Failed to start payment link session");return u.current=C,C}),m=q(async(v=!1)=>{if(c.current&&c.current.abort(),c.current=new AbortController,!e){r(!1),s("Session ID is required");return}try{v||r(!0),s(null);const C=await d(),E=v?`${X.RETRIEVE_SESSION(C)}?forceRefresh=1`:X.RETRIEVE_SESSION(C),{data:y}=await ee.get(E,{signal:c.current.signal});if(!l.current)return;const I=y?.checkoutSession;if(I){if(I.status!=="complete"&&I.expires_at&&I.expires_at<=Math.round(Date.now()/1e3)){s("SESSION_EXPIRED"),r(!1);return}if(!I.line_items?.length){s("EMPTY_LINE_ITEMS"),r(!1);return}}if(y?.stopAcceptingOrders&&I?.status!=="complete"){s("STOP_ACCEPTING_ORDERS"),r(!1);return}a(y),r(!1)}catch(C){if(!l.current)return;const{isCancelled:E,message:y}=pt(C);if(E)return;s(y||"Failed to load checkout session"),r(!1)}}),b=p.useCallback(async(v=!1)=>{await m(v)},[m]);p.useEffect(()=>(l.current=!0,m(),()=>{l.current=!1,c.current&&c.current.abort()}),[e]);const h=o?.checkoutSession,x=u.current||(f?"":e);let k=null;i==="SESSION_EXPIRED"?k="SESSION_EXPIRED":i==="EMPTY_LINE_ITEMS"?k="EMPTY_LINE_ITEMS":i==="STOP_ACCEPTING_ORDERS"&&(k="STOP_ACCEPTING_ORDERS");const F=h?.line_items?.reduce((v,C)=>v+(C?.price?.product?.vendor_config?.length||0),0)||0;return{isLoading:n,error:i,errorCode:k,refresh:b,setSessionData:a,sessionData:o,resolvedSessionId:x,vendorCount:F,product:h?kr(h):null,subscription:h?jr(h):null,pageInfo:h?Cr(h):null}}function Er(e){const n=[];return e.forEach(r=>{(r.payment_currencies||[]).forEach(s=>{const o={...s,method:{id:r.id,name:r.name,type:r.type}};n.push(o)})}),n}function Rr(e){return(e?.connectedAccounts||e?.extraConfigs?.connectedAccounts||[]).some(r=>r.provider==="wallet")}const Nt="payment-currency-preference";function fn(e){return e?`${Nt}:${e}`:Nt}function Ft(e,n){const r=new Set(n.flatMap(s=>(s.payment_currencies||[]).map(o=>o.id)).filter(Boolean)),i=s=>!!s&&r.has(s);if(e?.discounts?.length&&i(e.currency_id))return e.currency_id;if(typeof window<"u"){try{const o=new URLSearchParams(window.location.search),a=o.get("currencyId")||o.get("currency_id");if(i(a))return a}catch{}const s=e?.user;if(s&&!Rr(s)){const a=n.find(c=>c.type==="stripe")?.payment_currencies?.[0];if(i(a?.id))return a?.id}try{const o=e?.user?.did,a=localStorage.getItem(fn(o));if(i(a))return a}catch{}}return i(e?.currency_id)?e?.currency_id:n[0]?.payment_currencies?.[0]?.id||null}function $t(e,n){if(!n)return{method:null,currency:null};for(const i of e)for(const s of i.payment_currencies||[])if(s.id===n)return{method:i,currency:s};const r=e[0];return{method:r||null,currency:r?.payment_currencies?.[0]||null}}function Pr(e,n){const r=new Map;return e.forEach(i=>{const s=i.type==="stripe"?"stripe":"crypto";r.has(s)||r.set(s,{currencies:[],active:!1});const o=r.get(s),a=(i.payment_currencies||[]).map(c=>({...c,method:{id:i.id,name:i.name,type:i.type}}));o.currencies.push(...a),i===n&&(o.active=!0)}),Array.from(r.entries()).map(([i,s])=>({type:i,label:i==="stripe"?"Card":"Crypto",currencies:s.currencies,active:s.active}))}function Tr(e,n,r,i){const s=p.useMemo(()=>e?.paymentMethods||[],[e?.paymentMethods]),o=e?.checkoutSession,[a,c]=p.useState(()=>Ft(o,s)),[l,u]=p.useState(!1),f=p.useRef(null);p.useEffect(()=>{o&&!a&&c(Ft(o,s))},[o?.id]);const{method:d,currency:m}=p.useMemo(()=>$t(s,a),[s,a]),b=p.useMemo(()=>Er(s),[s]),h=d?.type==="stripe",x=d?.type!=="stripe"&&d?.type!==void 0,k=m?.type==="credit",F=p.useMemo(()=>Pr(s,d),[s,d]),v=q(async y=>{const I=s.find($=>y==="stripe"?$.type==="stripe":$.type!=="stripe");if(!I)return;const N=I.payment_currencies?.[0];N&&await C(N.id)}),C=q(async y=>{if(o?.status==="complete")return;const{method:I}=$t(s,y);if(!(!I||!n)){u(!0);try{const{data:N}=await ee.put(X.SWITCH_CURRENCY(n),{currency_id:y,payment_method_id:I.id});c(y);try{localStorage.setItem(fn(o?.user?.did),y)}catch{}e&&i?i({...e,checkoutSession:N,quotes:void 0}):await r(!0)}catch(N){console.error("Failed to switch currency:",je(N)),o?.currency_id&&c(o.currency_id)}finally{u(!1)}}});p.useEffect(()=>{if(!o?.id||!a||!s.length||f.current===o.id)return;f.current=o.id;const y=o.currency_id;o.status!=="complete"&&y&&y!==a&&C(a)},[o?.id,a,s.length]);const E=p.useMemo(()=>!d||d.type!=="stripe"?null:{publishableKey:d.settings?.stripe?.publishable_key||null,clientSecret:e?.paymentIntent?.client_secret||null,status:"idle"},[d,e?.paymentIntent]);return{current:d,currency:m,available:s,currencies:b,isStripe:h,isCrypto:x,isCredit:k,switching:l,setType:v,types:F,setCurrency:C,stripe:E}}const we=/^\d{4}$/,ve=/^\d{5}$/,Me=/^\d{6}$/,Ar={GB:/^GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}$/i,JE:/^JE\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/i,GG:/^GY\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/i,IM:/^IM\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/i,US:/^\d{5}([ -]\d{4})?$/,CA:/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ ]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,DE:ve,JP:/^\d{3}-?\d{4}$/,FR:/^\d{2}[ ]?\d{3}$/,AU:we,IT:ve,CH:we,AT:we,ES:ve,NL:/^\d{4}[ ]?[A-Z]{2}$/i,BE:we,DK:we,SE:/^\d{3}[ ]?\d{2}$/,NO:we,BR:/^\d{5}-?\d{3}$/,PT:/^\d{4}(-\d{3})?$/,FI:ve,KR:ve,CN:Me,TW:/^\d{3}(\d{2})?$/,SG:Me,IN:/^[1-9]\d{5}$/,RU:Me,PL:/^\d{2}-\d{3}$/,CZ:/^\d{3}[ ]?\d{2}$/,HU:we,RO:Me,BG:we,HR:ve,SK:/^\d{3}[ ]?\d{2}$/,SI:we,TR:ve,IL:ve,ZA:we,MX:ve,AR:/^([A-HJ-NP-Z])?\d{4}([A-Z]{3})?$/i,CL:/^\d{7}$/,CO:Me,NZ:we,MY:ve,TH:ve,PH:we,ID:ve,VN:Me};function Dr(e,n){if(!e)return!0;try{const r=n?.toUpperCase();if(!r)return!1;const i=Ar[r];return!i||i.test(e)}catch{return!1}}function Pe(e,n,r="en"){if(!n||!n[e])return{};const i=n[e],s={};return i.pattern&&(s.pattern={value:new RegExp(i.pattern),message:i.pattern_message?.[r]||"Invalid format"}),s}let it=null;async function Mr(){if(!it){const e=await Xn(()=>import("./libphonenumber-Qs8PCdM-.js").then(r=>r.l),[]),n=(e.default||e)?.PhoneNumberUtil;if(!n)throw new Error("PhoneNumberUtil not found");it=n.getInstance()}return it}const zr=/^[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4,6}$/im;async function Nr(e){if(!e||e.trim()==="")return!1;try{const n=await Mr(),r=n.parseAndKeepRawInput(e);return n.isValidNumber(r)}catch{return zr.test(e)}}function Fr(e){return!e||e.trim()===""?!1:Yn(e)}async function st(e,n){const r={},{phoneEnabled:i,addressMode:s,fieldValidation:o,locale:a="en"}=n;if(!e)return{valid:!1,errors:{customer_name:"Required"}};const c=e.customer_name;if(!c||c.trim()==="")r.customer_name="Required";else{const x=Pe("customer_name",o,a);x.pattern&&!x.pattern.value.test(c)&&(r.customer_name=x.pattern.message)}const l=e.customer_email;if(!l||!Fr(l))r.customer_email=l?"Invalid email":"Required";else{const x=Pe("customer_email",o,a);x.pattern&&!x.pattern.value.test(l)&&(r.customer_email=x.pattern.message)}if(i){const x=e.customer_phone;if(!x||x.trim()==="")r.customer_phone="Required";else if(!await Nr(x))r.customer_phone="Invalid phone number";else{const k=Pe("customer_phone",o,a);k.pattern&&!k.pattern.value.test(x)&&(r.customer_phone=k.pattern.message)}}const u=e.billing_address,f=u?.postal_code,d=u?.country,m=u?.state,b=u?.line1,h=u?.city;if(!f)r["billing_address.postal_code"]="Required";else if(!Dr(f,d))r["billing_address.postal_code"]="Invalid postal code";else{const x=Pe("billing_address.postal_code",o,a);x.pattern&&!x.pattern.value.test(f)&&(r["billing_address.postal_code"]=x.pattern.message)}if(!m)r["billing_address.state"]="Required";else{const x=Pe("billing_address.state",o,a);x.pattern&&!x.pattern.value.test(m)&&(r["billing_address.state"]=x.pattern.message)}if(s==="required"){if(d||(r["billing_address.country"]="Required"),!b)r["billing_address.line1"]="Required";else{const x=Pe("billing_address.line1",o,a);x.pattern&&!x.pattern.value.test(b)&&(r["billing_address.line1"]=x.pattern.message)}if(!h)r["billing_address.city"]="Required";else{const x=Pe("billing_address.city",o,a);x.pattern&&!x.pattern.value.test(h)&&(r["billing_address.city"]=x.pattern.message)}}return{valid:Object.keys(r).length===0,errors:r}}function $r(e){const n=[];n.push({name:"customer_name",type:"text",required:!0}),n.push({name:"customer_email",type:"email",required:!0}),e?.phone_number_collection?.enabled&&n.push({name:"customer_phone",type:"phone",required:!0});const r=e?.billing_address_collection;return r==="required"?n.push({name:"billing_address.country",type:"country",required:!0,group:"address"},{name:"billing_address.line1",type:"text",required:!0,group:"address"},{name:"billing_address.city",type:"text",required:!0,group:"address"},{name:"billing_address.state",type:"text",required:!0,group:"address"},{name:"billing_address.postal_code",type:"text",required:!0,group:"address"}):r==="auto"&&n.push({name:"billing_address.state",type:"text",required:!1,group:"address"},{name:"billing_address.postal_code",type:"text",required:!1,group:"address"}),n}function Wt(e,n){return{customer_name:n?.name||"",customer_email:e?.customer_details?.email||n?.email||"",customer_phone:n?.phone||"",payment_method:"",payment_currency:e?.currency_id||"",billing_address:{country:n?.address?.country||"us",state:n?.address?.state||"",city:n?.address?.city||"",line1:n?.address?.line1||"",line2:n?.address?.line2||"",postal_code:n?.address?.postal_code||""}}}function xn(e,n,r){const i=n.split(".");if(i.length===1)return{...e,[n]:r};const[s,...o]=i;return{...e,[s]:xn(e[s]||{},o.join("."),r)}}function Wr(e,n,r){const i=e?.checkoutSession,s=e?.customer,o=p.useMemo(()=>$r(i),[i?.id]),[a,c]=p.useState(()=>Wt(i,s)),[l,u]=p.useState({}),[f,d]=p.useState({}),[m,b]=p.useState(!1);p.useEffect(()=>{i&&!m&&c(Wt(i,s))},[i?.id]),p.useEffect(()=>{(n||r)&&c(E=>({...E,...n&&{payment_currency:n},...r&&{payment_method:r}}))},[n,r]),p.useEffect(()=>{if(!i||m||i.status==="complete")return;(async()=>{try{const{data:y}=await ee.get(`${X.CUSTOMER_ME}?fallback=1&skipSummary=1`);y&&(b(!0),c(I=>({...I,customer_name:I.customer_name||y.name||"",customer_email:I.customer_email||y.email||"",customer_phone:I.customer_phone||y.phone||"",billing_address:{...I.billing_address,country:I.billing_address?.country||y.address?.country||"",state:I.billing_address?.state||y.address?.state||"",city:I.billing_address?.city||y.address?.city||"",line1:I.billing_address?.line1||y.address?.line1||"",line2:I.billing_address?.line2||y.address?.line2||"",postal_code:I.billing_address?.postal_code||y.address?.postal_code||""}})))}catch{b(!0)}})()},[i?.id]);const h=q((E,y)=>{c(I=>xn(I,E,y)),d(I=>({...I,[E]:!0}))}),x=q(()=>({phoneEnabled:!!i?.phone_number_collection?.enabled,addressMode:i?.billing_address_collection,fieldValidation:i?.metadata?.page_info?.field_validation})),k=q(async()=>{const E=await st(a,x());return u(E.errors),E.valid}),F=q(async()=>(await st(a,x())).valid),v=q(async E=>{const y=await st(a,x());u(I=>{const N={...I};return y.errors[E]?N[E]=y.errors[E]:delete N[E],N})}),C=q(async()=>{try{const{data:E}=await ee.get(`${X.CUSTOMER_ME}?fallback=1&skipSummary=1`);E&&(b(!0),c(y=>({...y,customer_name:E.name||y.customer_name||"",customer_email:E.email||y.customer_email||"",customer_phone:E.phone||y.customer_phone||"",billing_address:{...y.billing_address,country:E.address?.country||y.billing_address?.country||"",state:E.address?.state||y.billing_address?.state||"",city:E.address?.city||y.billing_address?.city||"",line1:E.address?.line1||y.billing_address?.line1||"",line2:E.address?.line2||y.billing_address?.line2||"",postal_code:E.address?.postal_code||y.billing_address?.postal_code||""}})))}catch{b(!0)}});return{fields:o,values:a,onChange:h,errors:l,touched:f,validate:k,checkValid:F,validateField:v,prefetched:m,refetchCustomer:C}}const Or=300*1e3;function Ur(e){return e<5e3?500:e<3e4?1500:3e3}const Lr=e=>new Promise(n=>setTimeout(n,e));async function qr(e){const n=Date.now();for(;;){const{data:i}=await ee.get(X.STATUS_SESSION(e));if(i.paymentIntent&&i.paymentIntent.status==="requires_action"&&i.paymentIntent.last_payment_error)throw new Error(i.paymentIntent.last_payment_error.message);if(i.checkoutSession?.status==="complete"&&["paid","no_payment_required"].includes(i.checkoutSession?.payment_status))break;const o=Date.now()-n;if(o>=Or)throw new Error("waitForCheckoutComplete: timed out");await Lr(Ur(o))}const{data:r}=await ee.get(X.RETRIEVE_SESSION(e));return r}function hn(e,n){return`${e}-${n}-${Date.now()}-${Math.random().toString(36).substring(2,10)}`}const Br=["QUOTE_LOCK_EXPIRED","QUOTE_AMOUNT_MISMATCH","QUOTE_EXPIRED_OR_USED","QUOTE_NOT_FOUND","QUOTE_REQUIRED","QUOTE_MAX_PAYABLE_EXCEEDED","quote_validation_failed"],Hr="/.well-known/service/relay";function gn(){const e=window.blocklet;return e?.appPid||e?.appId||""}function Ot(e){return`relay:${gn()}:${e}`}function Vr(){return window.location.protocol==="https:"?"wss:":"ws:"}function Qr(){return new URL(window.location.href).host}function Gr(e,n){if(!e)return"";const i=(e.line_items||[]).map(s=>`${s.upsell_price_id||s.price_id}:${s.quantity}`).join("|");return`${e.id}-${n}-${i}`}function Ut(e,n,r,i,s=!1,o){const l=(i?.line_items||[]).find(u=>u.exchange_rate)?.exchange_rate;return{...r,idempotency_key:o||hn(e,n||""),preview_rate:l||void 0,...s&&{price_confirmed:!0}}}function Lt(e){return Br.includes(e)||e==="QUOTE_UPDATED"}async function Kr(e){try{await ee.post(X.ABORT_STRIPE(e))}catch{}}async function qt(e,n,r){const i=n?X.DONATE_SUBMIT(e):X.SUBMIT(e),{data:s}=await ee.put(i,r);return s}async function ot(e){const{data:n}=await ee.post(X.FAST_CHECKOUT_CONFIRM(e),{});return n}async function Yr(e){const{data:n}=await ee.post(X.SKIP_PAYMENT_METHOD(e),{});return n}async function Xr(e,n){const{data:r}=await ee.put(X.SLIPPAGE(e),{slippage_config:n});return r}function Zr(e,n,r,i,s,o,a,c,l,u){const f=e?.checkoutSession,[d,m]=p.useState("idle"),[b,h]=p.useState(null),[x,k]=p.useState(null),[F,v]=p.useState(!1),C=q(()=>v(!0)),E=q(()=>v(!1)),y=p.useRef(!0),I=p.useRef(!1),N=p.useRef(null),$=p.useRef(null),P=p.useRef(null),[B,H]=p.useState(null),K=p.useRef(null),V=p.useRef(0),Q=2,te=p.useRef(""),U=p.useRef(""),re=p.useRef(!1);p.useEffect(()=>{if(re.current||!f||!e)return;f.status==="complete"&&["paid","no_payment_required"].includes(f.payment_status)&&d==="idle"&&(re.current=!0,k(e),m("completed"))},[f,e]),p.useEffect(()=>{if(y.current=!0,!n||!gn())return;const S=new Zn(`${Vr()}//${Qr()}${Hr}`,{longpollerTimeout:5e3,heartbeatIntervalMs:30*1e3});S.connect(),N.current=S;const R=S.subscribe(Ot("events"));return R.channel="events",$.current=R,()=>{y.current=!1,I.current=!0,$.current&&(S.unsubscribe(Ot($.current.channel)),$.current=null),S.disconnect(),N.current=null}},[n]);const Y=q(async({response:S})=>{S.id===n&&d!=="completed"&&(I.current=!0,await W())});p.useEffect(()=>{const S=$.current;return S&&S.on("checkout.session.completed",Y),()=>{if(S)try{S.off?.("checkout.session.completed",Y)}catch{}}},[$.current,d]);const W=q(async()=>{try{const S=await qr(n);if(!y.current)return;k(S),u?.(S),m("completed"),h(null)}catch(S){if(!y.current)return;m("failed"),h({type:"error",message:je(S)||"Payment verification failed"})}});p.useEffect(()=>{if(re.current||!n||d!=="idle"&&d!=="waiting_stripe")return;let S=null,R=!1;try{const O=new URLSearchParams(window.location.search);S=O.get("redirect_status"),R=!!O.get("payment_intent")}catch{return}if(!(!S&&!R)){if(re.current=!0,S==="failed"||S==="canceled"){m("failed"),h({type:"error",message:"Payment was not completed. Please try again."});return}m("submitting"),h(null),W()}},[n]),p.useEffect(()=>{if(d!=="completed"||!n||!f?.line_items?.some(ie=>!!ie?.price?.product?.vendor_config?.length))return;const R=Date.now(),O=async()=>{try{const{data:ie}=await ee.get(X.VENDOR_ORDER_STATUS(n));if(!y.current)return;const Z=Array.isArray(ie?.vendors)?ie.vendors:[],ge=Date.now()-R>6e3,ke=Z.every(M=>M.progress>=100),w=Z.some(M=>M.status==="failed"||ge&&!!M.error&&!!M.error_message);if(H({...ie,vendors:Z,isAllCompleted:!w&&ke,hasFailed:w}),w||ke)return;K.current=setTimeout(O,5e3)}catch{}};return O(),()=>{K.current&&clearTimeout(K.current)}},[d,n]);const oe=q(async(S,R)=>{try{if(await l(!0),!y.current)return}catch{}if(S==="QUOTE_UPDATED"&&R?.checkoutSession){V.current=0,m("failed"),h({type:"error",message:"Price updated, please resubmit",code:S});return}if(["QUOTE_LOCK_EXPIRED","QUOTE_EXPIRED_OR_USED","QUOTE_NOT_FOUND","QUOTE_REQUIRED"].includes(S)&&V.current<Q){V.current+=1,m("idle"),h(null),await L(!0);return}V.current=0,m("failed"),h({type:"error",message:"Price updated, please resubmit",code:S})}),J=q(async S=>{if(i){const Z=S.stripeContext;if(Z?.status==="succeeded"){await W();return}const ge=S.paymentIntent,ke=Z?.client_secret||ge?.client_secret;if(ke){const w=Z?.intent_type||"payment_intent";m("waiting_stripe"),h({type:"stripe",clientSecret:ke,intentType:w,noPaymentRequired:!!S.noPaymentRequired});return}if(S.noPaymentRequired)try{const w=await ot(n),M=w.checkoutSession;if(w.fastPaid||M?.status==="complete"){await W();return}}catch{}await W();return}if(S.noPaymentRequired){try{const Z=await ot(n),ge=Z.checkoutSession;Z.fastPaid||ge?.status==="complete"?await W():(m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}}))}catch{if(!y.current)return;m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}})}return}const R=S.fastPayInfo,O=S.balance,ie=S.delegation;if(s){if(S.creditSufficient===!0&&R){m("confirming_fast_pay"),h({type:"fast_pay",payType:"credit",amount:R.amount||"0",payer:R.payer||""});return}m("credit_insufficient"),h({type:"credit_insufficient",available:"0",required:"0"});return}if((O?.sufficient||ie?.sufficient)&&!o&&R){m("confirming_fast_pay"),h({type:"fast_pay",payType:R.type||"balance",amount:R.amount||"",payer:R.payer||""});return}m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}})}),ne=q(async S=>{const{code:R,data:O,message:ie}=pt(S);if(R&&Lt(R)){await oe(R,O);return}if(R==="RATE_BELOW_SLIPPAGE_LIMIT"){try{await l(!0)}catch{}if(!y.current)return;te.current="",U.current="",m("failed"),h({type:"error",message:O?.error||"Exchange rate below acceptable limit, please retry",code:R});return}if(R==="RATE_UNAVAILABLE"){try{await l(!0)}catch{}if(!y.current)return;m("failed"),h({type:"error",message:O?.rateError||"Exchange rate unavailable",code:R});return}if(R==="PRICE_CHANGED"){m("confirming_price"),h({type:"price_change",changePercent:O?.change_percent||0});return}if(R==="PRICE_UNAVAILABLE"||R==="PRICE_UNSTABLE"){try{await l(!0)}catch{}if(!y.current)return;m("failed"),h({type:"error",message:O?.error||"Price unavailable, please retry",code:R});return}if(R==="STOP_ACCEPTING_ORDERS"){m("service_suspended"),h({type:"service_suspended"});return}if(R==="UNIFIED_APP_REQUIRED"||R==="CUSTOMER_LIMITED"){m("failed"),h({type:"error",message:O?.error||ie||"Cannot complete payment",code:R});return}const Z=O?.error||ie||"Payment failed";m("failed"),h({type:"error",message:Z,code:R})}),L=q(async(S=!1)=>{if(!S&&d!=="idle")return;if(S||(V.current=0),!await c()){m("failed"),h({type:"error",message:"Please complete the required fields",code:"VALIDATION_FAILED"});return}if(!f?.user?.sourceAppPid&&f?.line_items?.some(ge=>!!ge?.price?.product?.vendor_config?.length)){m("failed"),h({type:"error",message:"Vendor account required",code:"VENDOR_ACCOUNT_REQUIRED"});return}m("submitting"),h(null),k(null),I.current=!1;const O=Gr(f,r);(O!==U.current||!te.current)&&(U.current=O,te.current=hn(n,r||""));const ie=Ut(n,r,a,f,!1,te.current);P.current=ie;try{const Z=await qt(n,o,ie);if(!y.current)return;await J(Z)}catch(Z){if(!y.current)return;await ne(Z)}}),pe=q(async()=>{if(d==="confirming_fast_pay"){m("submitting");try{const S=await ot(n);if(!y.current)return;S.fastPaid?await W():(m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}}))}catch(S){if(!y.current)return;const{code:R,data:O,message:ie}=pt(S);if(R&&Lt(R)){await oe(R,O);return}if(R==="RATE_UNAVAILABLE"){try{await l(!0)}catch{}if(!y.current)return;m("failed"),h({type:"error",message:O?.rateError||"Exchange rate unavailable",code:R});return}m("failed"),h({type:"error",message:O?.error||ie||"Fast pay confirmation failed",code:R})}return}if(d==="confirming_price"){m("submitting"),h(null),I.current=!1;const S=Ut(n,r,a,f,!0,te.current);P.current=S;try{const R=await qt(n,o,S);if(!y.current)return;await J(R)}catch(R){if(!y.current)return;await ne(R)}}}),he=q(()=>{(d==="confirming_price"||d==="confirming_fast_pay"||d==="credit_insufficient"||d==="service_suspended")&&(m("idle"),h(null),E())}),le=q(async()=>{d==="failed"&&(m("idle"),h(null),k(null),await L(!0))}),T=q(()=>{I.current=!0,m("idle"),h(null),k(null),E()}),fe=q(async()=>{d==="waiting_stripe"&&(m("submitting"),h(null),await W())}),me=q(async()=>{d==="waiting_stripe"&&(await Kr(n),m("idle"),h(null))}),j=q(async()=>{if(d==="waiting_stripe")try{m("submitting");const S=await Yr(n);if(!y.current)return;S.skipped||S.checkoutSession?.status==="complete"?await W():(m("failed"),h({type:"error",message:"Failed to skip payment method",code:"SKIP_FAILED"}))}catch(S){if(!y.current)return;m("failed"),h({type:"error",message:S.message||"Failed to skip payment method",code:"SKIP_FAILED"})}}),G=q(async()=>{d==="submitting"||d==="completed"||(I.current=!1,m("submitting"),h(null),await W())});return{status:d,context:b,execute:L,confirm:pe,cancel:he,result:x,retry:le,reset:T,stripeConfirm:fe,stripeCancel:me,stripeSkip:j,didConnectComplete:G,vendorStatus:B,locked:F,lock:C}}const Jr=3e4;function ei(e){return e.some(n=>(n.upsell_price||n.price)?.pricing_type==="dynamic")}async function ti(e,n){const{data:r}=await ee.get(X.EXCHANGE_RATE(e),{params:n?{currency_id:n}:void 0}),i=r.rate||r.exchange_rate;if(i){const s=r.provider_display||r.provider_name||r.provider_id||null;return{rate:i,provider:r.provider_name||r.rate_provider_name||null,providerDisplay:s,fetchedAt:r.fetched_at||r.timestamp_ms||null}}return{rate:null,provider:null,providerDisplay:null,fetchedAt:null}}function ni(e){const n=e?.discounts||[];if(n.length===0)return null;const r=n[0],i=r.promotion_code_details,s=r.verification_data;return i?.code||s?.code||r.promotion_code||r.coupon||null}async function ri(e,n,r){try{const{data:i}=await ee.post(X.APPLY_PROMOTION(e),{promotion_code:n,currency_id:r});return i.error?{success:!1,error:i.error}:{success:!0}}catch(i){return{success:!1,error:je(i)||"Invalid promotion code"}}}async function ii(e){await ee.delete(X.REMOVE_PROMOTION(e))}async function si(e,n){const{data:r}=await ee.post(X.RECALCULATE_PROMOTION_SESSION(e),{currency_id:n});return r}function oi(e){return e?.allow_promotion_codes!==!1}function Je(e){return(e?.discounts||[]).length>0}async function De(e,n,r){if(!Je(e))return null;try{return await si(n,r)}catch{return null}}async function Bt(e,n,r,i,s,o,a,c){const{data:l}=await ee.put(X.ADJUST_QUANTITY(e),{itemId:n,quantity:r,currency_id:i});let u=l;if(l.discounts?.length||Je(s)){const f=await De(s,e,i);f&&(u=f)}a&&c?c({...a,checkoutSession:u,quotes:void 0}):await o(!0)}async function yn(e,n,r,i,s,o,a,c){if((i?.line_items?.length||0)>1)try{await ee.delete(X.CROSS_SELL(e))}catch{}const{data:l}=await ee.put(X.UPSELL(e),{from:n,to:r});let u=l;if(l.discounts?.length||Je(i)){const f=await De(i,e,s);f&&(u=f)}a&&c?c({...a,checkoutSession:u,quotes:void 0}):await o(!0)}async function bn(e,n,r,i,s,o,a){if((r?.line_items?.length||0)>1)try{await ee.delete(X.CROSS_SELL(e))}catch{}const{data:c}=await ee.put(X.DOWNSELL(e),{from:n});let l=c;if(c.discounts?.length||Je(r)){const u=await De(r,e,i);u&&(l=u)}o&&a?a({...o,checkoutSession:l,quotes:void 0}):await s(!0)}async function ai(e,n,r,i,s,o,a,c){const{data:l}=await ee.put(X.CHANGE_AMOUNT(e),{priceId:n,amount:r});let u=l;if(l?.discounts?.length){const f=await De(i,e,s);f&&(u=f)}a&&c?c({...a,checkoutSession:u,quotes:void 0}):await o(!0)}function ci(e){for(const n of e){const r=n.price?.cross_sell;if(r?.cross_sells_to)return r.cross_sells_to}return null}function li({sessionId:e,children:n}){const{isLoading:r,error:i,errorCode:s,refresh:o,setSessionData:a,sessionData:c,resolvedSessionId:l,vendorCount:u,product:f,subscription:d,pageInfo:m}=Ir(e),b=c?.checkoutSession,h=l||e,x=p.useMemo(()=>b?.line_items||[],[b?.line_items]),k=b?.submit_type==="donate",F=p.useMemo(()=>({sessionData:c,setSessionData:a,sessionId:e,effectiveSessionId:h,isLoading:r,error:i,errorCode:s,refresh:o,items:x,session:b||null,isDonation:k,vendorCount:u,product:f,subscription:d,pageInfo:m}),[c,a,e,h,r,i,s,o,x,b,k,u,f,d,m]),v=Tr(c,h,o,a),C=p.useRef(null);p.useEffect(()=>{const L=v.currency?.id||null;!L||!b||b.status==="complete"||(C.current===null||L!==C.current)&&(C.current=L,De(b,h,L).then(pe=>{pe&&o(!0)}))},[v.currency?.id,b?.id]);const E=p.useMemo(()=>({current:v.current,currency:v.currency,available:v.available,currencies:v.currencies,isStripe:v.isStripe,isCrypto:v.isCrypto,isCredit:v.isCredit,switching:v.switching,setType:v.setType,types:v.types,setCurrency:v.setCurrency,stripe:v.stripe}),[v.current,v.currency,v.available,v.currencies,v.isStripe,v.isCrypto,v.isCredit,v.switching,v.setType,v.types,v.setCurrency,v.stripe]),[y,I]=p.useState(null),[N,$]=p.useState(null),[P,B]=p.useState(null),[H,K]=p.useState(null),[V,Q]=p.useState("loading"),te=p.useRef(null),U=p.useRef(!1),re=p.useRef(!0),Y=p.useMemo(()=>ei(x),[x]),W=q(async()=>{if(!h||!Y||v.isStripe||v.switching){Q(Y?"unavailable":"available"),v.isStripe&&(I(null),$(null),B(null),K(null));return}if(!U.current){U.current=!0;try{Q("loading");const L=await ti(h,v.currency?.id);if(!re.current)return;L.rate?(I(L.rate),$(L.provider),B(L.providerDisplay),K(L.fetchedAt),Q("available")):Q("unavailable")}catch{if(!re.current)return;Q("unavailable")}finally{U.current=!1}}});p.useEffect(()=>{if(re.current=!0,!Y||v.isStripe||v.switching||!h||b?.status==="complete"){v.isStripe&&(I(null),$(null),B(null),K(null)),v.switching||(b?.status==="complete"?Q("available"):Q(Y?"unavailable":"available"));return}W(),te.current=setInterval(W,Jr);const L=()=>{document.hidden||W()};return document.addEventListener("visibilitychange",L),()=>{re.current=!1,te.current&&clearInterval(te.current),document.removeEventListener("visibilitychange",L)}},[Y,v.isStripe,v.switching,h,v.currency?.id,b?.status]);const oe=p.useMemo(()=>({rate:y,provider:N,providerDisplay:P,fetchedAt:H,status:V,hasDynamicPricing:Y,refresh:W}),[y,N,P,H,V,Y,W]),J=Wr(c,v.currency?.id||null,v.current?.id||null),ne=Zr(c,h,v.currency?.id||null,v.isStripe,v.isCredit,k,J.values,J.validate,o,a);return t.jsx(er.Provider,{value:F,children:t.jsx(tr.Provider,{value:E,children:t.jsx(nr.Provider,{value:oe,children:t.jsx(rr.Provider,{value:J,children:t.jsx(ir.Provider,{value:ne,children:n})})})})})}function at(e,n=6,r=!0,i=!0){if(!e||e==="0")return"0";const s=Number(e);if(!Number.isFinite(s))return"0";let o;if(i?o=s.toLocaleString("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}):o=s.toFixed(n),!r)return o;const[a,c]=o.split(".");if(!c)return a;const l=c.replace(/0+$/,"");return l?`${a}.${l}`:a}function ze(e,n,r=6,i=!0,s=!0){if(!n)return at(e,r,i,s);const o=Number(e);if(!Number.isFinite(o))return at(e,r,i,s);const a=Math.abs(o),c=a>0&&a<.01?r:2;return at(e,c,i,s)}const Ht=8;function Vt(e,n,r){if(!r&&r!=="0"||n==null)return null;try{const i=e instanceof z?e:new z(e||"0"),s=new z(10).pow(new z(n));if(s.isZero())return null;const o=new z(r.replace(".","")),a=r.includes(".")&&r.split(".")[1]?.length||0,c=new z(10).pow(new z(a)),l=new z(10).pow(new z(Ht)),u=i.mul(o).mul(l).div(s.mul(c));return Te(u.toString(),Ht)}catch{return null}}function Qt(e,n="en"){if(!e&&e!=="0")return null;const r=Number(e);return Number.isFinite(r)?new Intl.NumberFormat(n,{minimumFractionDigits:2,maximumFractionDigits:2}).format(r):null}function ui(e){if(!e&&e!=="0")return null;const n=String(e),r=Number(n);return Number.isFinite(r)?n:null}function di(e,n="USD",r=2){if(e==null)return null;const i=Number(e);if(!Number.isFinite(i))return null;const s=i.toFixed(r);return n==="USD"?`$${s}`:`${s} ${n}`}function pi(e){return Array.isArray(e.currency_options)?e.currency_options:[{currency_id:e.currency_id,unit_amount:e.unit_amount,custom_unit_amount:e.custom_unit_amount||null,tiers:null}]}function bt(e,n){const i=pi(e).find(s=>s.currency_id===n?.id);return i?i.custom_unit_amount?i.custom_unit_amount.preset||i.custom_unit_amount.presets[0]:i.unit_amount:e.currency_id===n?.id?e.custom_unit_amount?e.custom_unit_amount.preset||e.custom_unit_amount.presets[0]:e.unit_amount:"0"}function mi(e,n,{useUpsell:r=!0,exchangeRate:i=null}={}){if(!n)return{unitAmount:new z(0),totalAmount:new z(0),isDynamicQuote:!1};const s=r&&e.upsell_price||e.price,o=new z(e.quantity||0),a=e.quoted_amount,c=e.quote_currency_id,l=s?.pricing_type==="dynamic";if(l&&a&&c===n.id){const d=new z(a||"0");return{unitAmount:o.gt(new z(0))?d.add(o).sub(new z(1)).div(o):new z(0),totalAmount:d,isDynamicQuote:!0}}if(l&&i&&s?.base_amount){const d=Number(i);if(d>0&&Number.isFinite(d)){const m=Number(s.base_amount);if(m>0&&Number.isFinite(m)){const b=m/d,h=Xe(b.toFixed(n.decimal||8),n.decimal||8);return{unitAmount:h,totalAmount:h.mul(o),isDynamicQuote:!1}}}}if(!i&&s?.base_amount!=null){const d=Number(s.base_amount);if(d>=0&&Number.isFinite(d)){const m=n.decimal||2,b=Xe(d.toFixed(m),m);return{unitAmount:b,totalAmount:b.mul(o),isDynamicQuote:!1}}}const f=new z(bt(s,n));return{unitAmount:f,totalAmount:f.mul(o),isDynamicQuote:!1}}function _t(e,n,r=!1,i=!0,{exchangeRate:s=null}={}){let o=new z(0);const a=e.filter(c=>(i&&c.upsell_price||c.price)!=null).reduce((c,l)=>{const u=l.quote_currency_id;let f;l.custom_amount&&u&&u===n.id?f=new z(l.custom_amount):{totalAmount:f}=mi(l,n,{useUpsell:i,exchangeRate:s});const d=i&&l.upsell_price||l.price;return d?.type==="recurring"&&(o=o.add(f),r||d.recurring?.usage_type==="metered")?c:c.add(f)},new z(0)).toString();return{subtotal:a,total:a,renew:ze(o.toString(),!!s),discount:"0",shipping:"0",tax:"0"}}function fi(e,n,r=0){const i={licensed:new z(0),metered:new z(0)};return e.map(o=>o.upsell_price||o.price).filter(o=>o?.type==="recurring"&&o?.recurring).length>0?+r?Xe(r,n.decimal).toString():(e.forEach(o=>{const a=o.upsell_price||o.price,c=bt(a,n),l=new z(c).mul(new z(o.quantity));a?.type==="recurring"&&a?.recurring&&(a.recurring.usage_type==="licensed"&&(i.licensed=i.licensed.add(l)),a.recurring.usage_type==="metered"&&(i.metered=i.metered.add(l)))}),i.licensed.add(i.metered).toString()):"0"}function _n(e,n,r,i,s,o,a){const c=r?.discounts||[];if(c.length===0)return new z(0);const l=c[0].coupon_details||{};if(a&&l.duration==="once")return new z(0);const u=e.filter(m=>!(m.discountable===!1||(m.upsell_price||m.price)?.recurring?.usage_type==="metered")),f=_t(u,n,o,!0,{exchangeRate:i?s:null}),d=new z(f.total);if(d.lte(new z(0)))return new z(0);if(l.percent_off&&l.percent_off>0)return d.mul(new z(l.percent_off)).div(new z(100));if(l.amount_off&&l.amount_off!=="0"){const m=l.currency_options?.[n.id]?.amount_off||l.amount_off;if(m&&m!=="0"){const b=new z(m);return b.lt(d)?b:d}}return new z(0)}function xi(e,n,r,i,s,o){if(!n||e.length===0)return{subtotal:"0",paymentAmount:"0",total:"0",discount:null,tax:null,staking:null,usdEquivalent:null};const a=r?.subscription_data,l=Number(a?.trial_period_days||0)>0,u=_t(e,n,l,!0,{exchangeRate:s?i:null}),f=new z(u.total),d=_n(e,n,r,s,i,l,!1),m=d.gt(new z(0))?ze(Te(d.toString(),n.decimal),s):null,b=r?.total_details?.amount_tax,h=new z(b||"0"),x=r?.total_details,k=b&&b!=="0"?{amount:Te(b,n.decimal),rate:x?.tax_rate||0,inclusive:x?.tax_inclusive||!1}:null,F=a?.no_stake||!1,v=Math.max(Number(a?.billing_threshold_amount||0),Number(a?.min_stake_amount||0)),E=o==="arcblock"&&n.type!=="credit"&&!F?fi(e,n,v):"0",y=new z(E),I=f.add(y);let N=I.sub(d);h.gt(new z(0))&&!k?.inclusive&&(N=N.add(h)),N.isNeg()&&(N=new z(0));const $=ze(Te(N,n.decimal),s),P=I,B=ze(Te(P,n.decimal),s);let H=null,K=null;if(s&&i&&n){const Q=Vt(N.toString(),n.decimal,i);Q&&(H=Qt(Q)||null);const te=Vt(P.toString(),n.decimal,i);te&&(K=Qt(te)||null)}const V=y.gt(new z(0))?`${ze(Te(y.toString(),n.decimal),s)} ${n.symbol}`:null;return{subtotal:`${B} ${n.symbol}`,paymentAmount:`${$} ${n.symbol}`,total:`${$} ${n.symbol}`,discount:m?`${m} ${n.symbol}`:null,tax:k,staking:V,usdEquivalent:H?`$${H}`:null,subtotalUsdEquivalent:K?`$${K}`:null}}function Sn(e,n,r){if(!e.length||!n)return{locked:!1,lockedAt:null,expiresAt:null,expired:!1,baseCurrency:null,slippagePercent:null};const i=r?.checkoutSession;let s=null,o=null,a=null;e.forEach(b=>{const h=b.upsell_price||b.price;!s&&h?.base_currency&&(s=h.base_currency);const x=b.expires_at;x&&(o=o===null?x:Math.min(o,x));const k=b.slippage_percent;a===null&&Number.isFinite(Number(k))&&(a=Number(k))});const c=r?.paymentIntent?.created_at?new Date(r.paymentIntent.created_at).getTime():null,l=i?.quote_locked_at,u=c||l||null,f=!!u,d=Date.now(),m=o?d>o:!1;return{locked:f,lockedAt:u,expiresAt:o,expired:m,baseCurrency:s,slippagePercent:a}}function hi(e,n,r,i,s,o){const a=e?.subscription_data;let c=Number(a?.trial_period_days||0);if(c>0&&n){const d=(a?.trial_currency||"").split(",").map(m=>m.trim()).filter(Boolean);d.length>0&&!d.includes(n)&&(c=0)}const l=c>0;let u=null,f=null;if(l&&i&&r.length>0){const d=_t(r,i,!1,!0,{exchangeRate:s?o:null});let m=new z(d.total);const b=_n(r,i,e,s,o,!1,!0);b.gt(new z(0))&&(m=m.sub(b),m.isNeg()&&(m=new z(0))),u=`${ze(Te(m,i.decimal),s)} ${i.symbol}`;const h=r.find(x=>{const k=x.upsell_price||x.price;return k?.type==="recurring"&&k?.recurring});h&&(f=(h.upsell_price||h.price)?.recurring?.interval||null)}return{active:l,days:c,afterTrialPrice:u,afterTrialInterval:f}}async function gi(e,n,r,i,s,o,a){const{data:c}=await ee.put(X.CROSS_SELL(e),{to:n});let l=c;if(c.discounts?.length){const u=await De(r,e,i);u&&(l=u)}o&&a?a({...o,checkoutSession:l,quotes:void 0}):await s(!0)}async function yi(e,n,r,i,s,o){const{data:a}=await ee.delete(X.CROSS_SELL(e));let c=a;if(a.discounts?.length){const l=await De(n,e,r);l&&(c=l)}s&&o?o({...s,checkoutSession:c,quotes:void 0}):await i(!0)}const ct=new Map;function bi(e){const n=ct.get(e);if(n)return n;const r=(async()=>{try{const{data:i}=await ee.get(`${X.CROSS_SELL(e)}?skipError=true`);if(i&&!i.error)return i}catch{}return null})();return ct.set(e,r),r.finally(()=>ct.delete(e)),r}function _i(e){if(!e.length)return null;const n=e[0],r=n.upsell_price||n.price,i=r?.recurring;if(!i)return null;const s=i.interval,o=r?.upsell,a=o?.upsells_to,c=[];if(a?.recurring?.interval&&a.recurring.interval!==s&&c.push({interval:a.recurring.interval,priceId:o?.upsells_to_id||"",amount:a.unit_amount||"0",savings:null}),n.upsell_price_id&&n.price?.recurring){const l=n.price.recurring.interval;l&&l!==s&&c.push({interval:l,priceId:n.price_id,amount:n.price.unit_amount||"0",savings:null})}return c.length===0?null:{current:s,available:c,firstItem:n}}function wn(){const{product:e,subscription:n,pageInfo:r,vendorCount:i}=_e();return{product:e,subscription:n,pageInfo:r,vendorCount:i}}function St(){const{items:e,session:n,effectiveSessionId:r,isDonation:i,refresh:s,sessionData:o,setSessionData:a}=_e(),{currency:c}=Ie(),l=c?.id||null,u=p.useRef(!1);p.useEffect(()=>{if(!(u.current||!r||!e.length||!l||n?.status==="complete"))try{const P=new URLSearchParams(window.location.search);for(const B of e){const H=P.get(`qty_${B.price_id}`)||P.get(`qty_${B.price?.id}`)||P.get("qty");if(H){const K=Math.max(1,parseInt(H,10));if(Number.isFinite(K)&&K!==B.quantity){u.current=!0,Bt(r,B.price_id,K,l,n,s,o,a);break}}}}catch{}},[r,e,l]);const f=q(async(P,B)=>{if(n?.status!=="complete")try{await Bt(r,P,B,l,n,s,o,a)}catch(H){console.error("Failed to update quantity:",je(H))}}),d=q(async(P,B)=>{n?.status!=="complete"&&await yn(r,P,B,n,l,s,o,a)}),m=q(async P=>{n?.status!=="complete"&&await bn(r,P,n,l,s,o,a)}),b=p.useMemo(()=>ci(e),[e]),[h,x]=p.useState(null),k=p.useMemo(()=>e.map(P=>P.price_id).join(","),[e]),F=p.useMemo(()=>e.some(P=>P.cross_sell),[e]);p.useEffect(()=>{if(!r||!n||n.status==="complete")return;if(b){x(null);return}if(F)return;let P=!1;return bi(r).then(B=>{P||x(B)}),()=>{P=!0}},[r,n?.id,b,k,F]);const v=b||h,C=p.useMemo(()=>e.some(P=>P.cross_sell_required),[e]),E=q(async()=>{if(n?.status!=="complete"&&v)try{await gi(r,v.id,n,l,s,o,a)}catch(P){console.error("Failed to add cross-sell:",je(P))}}),y=q(async()=>{if(n?.status!=="complete")try{await yi(r,n,l,s,o,a)}catch(P){console.error("Failed to remove cross-sell:",je(P))}}),I=q(async(P,B)=>{if(n?.status!=="complete"&&i)try{await ai(r,P,B,n,l,s,o,a)}catch(H){console.error("Failed to change amount:",je(H))}}),N=p.useMemo(()=>e.map(P=>({...P,adjustable_quantity:P.adjustable_quantity})),[e]),$=p.useMemo(()=>e.every(P=>{const{price:B}=P;if(!B)return!0;const H=Number(P.quantity)||0,K=B.quantity_available||0,V=B.quantity_sold||0,Q=B.quantity_limit_per_checkout||0;return!(K>0&&V+H>K||Q>0&&Q<H)}),[e]);return{items:N,inventoryOk:$,updateQuantity:f,upsell:d,downsell:m,crossSellItem:v,crossSellRequired:C,addCrossSell:E,removeCrossSell:y,isDonation:i,setDonationAmount:I}}function Si(){const{items:e,session:n,effectiveSessionId:r,refresh:i,sessionData:s,setSessionData:o}=_e(),{currency:a}=Ie(),c=a?.id||null,[l,u]=p.useState(!1),[f,d]=p.useState(null),m=q(async(h,x)=>{try{await yn(r,h,x,n,c,i,s,o)}catch(k){console.error("Failed to upsell:",je(k))}}),b=q(async h=>{try{await bn(r,h,n,c,i,s,o)}catch(x){console.error("Failed to downsell:",je(x))}});return p.useMemo(()=>{const h=_i(e);return h?{current:f||h.current,available:h.available,switching:l,switch:async x=>{const k=h.available.find(F=>F.interval===x);if(!(!k||l)){d(x),u(!0);try{!h.firstItem.upsell_price_id&&k.priceId?await m(h.firstItem.price_id,k.priceId):h.firstItem.upsell_price_id&&await b(h.firstItem.upsell_price_id)}finally{u(!1),d(null)}}}}:null},[e,r,l,f])}function wi(){const{session:e,effectiveSessionId:n,refresh:r}=_e(),{currency:i}=Ie(),[s,o]=p.useState(null);p.useEffect(()=>{if(!e||s)return;const f=ni(e);f&&o(f)},[e?.id]);const a=q(async f=>{if(e?.status==="complete")return{success:!1,error:"Session already completed"};const d=await ri(n,f,i?.id);return d.success&&(o(f),await r(!0)),d}),c=q(async()=>{if(e?.status!=="complete")try{await ii(n),o(null),await r(!0)}catch{}}),l=(e?.discounts||[]).length>0,u=oi(e);return{applied:l,code:s,active:u,inactiveReason:u?null:"Promotions not allowed",apply:a,remove:c}}function wt(){const{rate:e,provider:n,providerDisplay:r,fetchedAt:i,status:s,hasDynamicPricing:o,refresh:a}=yt();return{value:ui(e),display:e?di(e):null,provider:n,providerDisplay:r,fetchedAt:i,status:s,hasDynamicPricing:o,refresh:a}}function vn(){const{items:e,sessionData:n,effectiveSessionId:r,refresh:i}=_e(),{hasDynamicPricing:s}=yt(),o=p.useMemo(()=>Sn(e,s,n),[e,s,n]),a=q(async c=>{try{const l=await Xr(r,c);(l?.checkoutSession||l?.quotes)&&await i(!0)}catch(l){console.error("Failed to update slippage:",je(l))}});return{percent:o.slippagePercent??.5,set:a}}function vt(){const{isLoading:e,error:n,errorCode:r,session:i,isDonation:s}=_e(),o=!e&&!n&&i?.status==="open",a=i?.status==="complete",c=!!i?.livemode;return{isLoading:e,error:n,errorCode:r,canSubmit:o,isCompleted:a,isDonation:s,livemode:c}}function kn(){const{items:e,session:n,sessionData:r,refresh:i}=_e(),{currency:s}=Ie(),{rate:o,hasDynamicPricing:a}=yt(),{current:c}=Ie(),l=p.useMemo(()=>xi(e,s,n,o,a,c?.type||null),[e,s,o,a,n,c?.type]),u=p.useMemo(()=>Sn(e,a,r),[e,a,r]);p.useEffect(()=>{!u.expired||!u.expiresAt||n?.status==="complete"||i(!0)},[u.expired]);const f=hi(n,s?.id,e,s,a,o);return{...l,hasDynamicPricing:a,quote:{locked:u.locked,lockedAt:u.lockedAt,expiresAt:u.expiresAt,expired:u.expired,baseCurrency:u.baseCurrency},trial:f}}function vi(){return Ie()}function jn(){return sr()}function et(){return or()}const ki={overflowY:"auto","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},Gt={"@keyframes mobileFadeIn":{from:{opacity:0},to:{opacity:1}},animation:{xs:"mobileFadeIn 0.4s ease both",md:"none"}},Kt={"@keyframes fadeIn":{from:{opacity:0,transform:"translateY(12px)"},to:{opacity:1,transform:"translateY(0)"}},animation:{xs:"none",md:"fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both"}},ji=typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent),Yt=ji?{"@keyframes panelFadeIn":{from:{opacity:0,transform:"translateX(24px)"},to:{opacity:1,transform:"none"}},animation:{xs:"none",md:"panelFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both"}}:{"@keyframes slideInRight":{from:{transform:"translateX(100%)"},to:{transform:"translateX(0)"}},animation:{xs:"none",md:"slideInRight 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards"}};function Ci({left:e,right:n,mode:r="inline"}){const i=r==="standalone",{isMobile:s}=Ze(),o=We(),a=o.palette.mode==="dark",c=e===null,l={};if(s&&!c&&(l["& .cko-v2-submit-btn"]={position:"fixed",bottom:0,left:0,right:0,zIndex:999,bgcolor:a?"rgba(30,30,30,0.82)":"background.paper",backdropFilter:a?"blur(12px)":"none",p:1.5,borderTop:"1px solid",borderColor:"divider",boxShadow:a?"0 -4px 20px rgba(0,0,0,0.4)":"0 -2px 10px rgba(0,0,0,0.08)"}),!i)return t.jsxs(_,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},width:"100%",minHeight:{md:640},maxWidth:1120,mx:"auto",borderRadius:"16px",overflow:"hidden",boxShadow:1,border:1,borderColor:"divider",borderLeft:"4px solid",borderLeftColor:"primary.main",bgcolor:d=>d.palette.mode==="dark"?"background.default":"#f8faff",...Gt},children:[!c&&t.jsx(_,{sx:{flex:1,minWidth:0,bgcolor:d=>d.palette.mode==="dark"?"background.default":"#f8faff",p:{xs:3,md:5},pt:{xs:3,md:4},display:"flex",flexDirection:"column",...Kt},children:e}),t.jsx(_,{sx:{width:c?"100%":{xs:"100%",md:480},flexShrink:0,bgcolor:"background.paper",p:{xs:3,md:4},pt:{xs:3,md:4},display:"flex",flexDirection:"column",overflow:{md:"hidden"},...c?{}:Yt},children:n})]});const u=a?o.palette.background.default:o.palette.grey[100],f=a?o.palette.background.default:"#f8faff";return t.jsxs(_,{sx:{width:"100%",height:{xs:"auto",md:"100vh"},minHeight:{xs:"100vh"},overflow:{md:"hidden"},display:"flex",flexDirection:{xs:"column",md:"row"},position:"relative",background:s?u:`linear-gradient(160deg, ${ce(o.palette.primary.main,.03)} 0%, ${ce(o.palette.primary.main,.07)} 50%, ${ce(o.palette.primary.main,.04)} 100%)`,bgcolor:f,...Gt},children:[t.jsx(gt,{sx:{position:"absolute",top:20,left:0,right:0,zIndex:10,background:"transparent","& .header-container":{height:"auto"}},hideNavMenu:!0,brand:null,description:null,addons:d=>d.filter(b=>["locale-selector","theme-mode-toggle","session-user"].includes(b.key))}),!c&&t.jsx(_,{sx:{flex:{xs:"none",md:"0 0 50%"},width:{xs:"100%"},height:{xs:"auto",md:"100vh"},display:"flex",justifyContent:{md:"center"},...s?{bgcolor:"background.paper",mt:9}:{},...ki},children:t.jsx(_,{sx:{width:"100%",maxWidth:{md:640},p:{xs:3,md:5},pt:{xs:3,md:10},display:"flex",flexDirection:"column",flex:1,...Kt},children:e})}),t.jsx(_,{sx:{flex:c?"none":{xs:"none",md:"0 0 50%"},width:c?"100%":{xs:"100%"},height:c?"100vh":{xs:"auto",md:"100vh"},bgcolor:"background.paper",boxShadow:c?"none":{md:"-4px 0 16px rgba(0,0,0,0.04)"},position:"relative",display:"flex",flexDirection:"column",...c?{}:Yt,...s&&!c?{pb:"180px",mt:2}:{},overflowY:{xs:"auto",md:"hidden"},"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none",...l},children:t.jsx(_,{sx:{width:"100%",maxWidth:{md:600},mx:"auto",p:{xs:3,md:4},pt:c?{xs:10,md:"10vh"}:{xs:3,md:"10vh"},display:"flex",flexDirection:"column",flex:1,minHeight:0,justifyContent:c?"center":void 0},children:n})})]})}function Ii(e,n){if(!e)return"composite";const r=n.length===1,i=e.mode==="payment",s=["subscription","setup"].includes(e.mode||"");if(r&&i){const o=n[0];if(o.price?.product?.type==="credit"&&o.price?.metadata?.credit_config)return"credit-topup"}return r&&s&&!n.some(o=>o.cross_sell)?"subscription":"composite"}function Ei({item:e,currency:n,discounts:r,exchangeRate:i,onQuantityChange:s,onUpsell:o,onDownsell:a,trialActive:c,trialDays:l,t:u,recommended:f=!1,hideUpsell:d=!1,isRateLoading:m=!1,showFeatures:b=!0,children:h=void 0}){const x=e.upsell_price||e.price,k=x?.product,F=k?.name||"Item",v=k?.images?.[0]||"",C=k?.features||[],E=x?.recurring,y=e.quantity||1,I=E?.usage_type==="metered",N=I?` ${u("common.metered")}`:"",$=Ye(x,n,i),P=!!E,B=u(P?"payment.checkout.typeBadge.subscription":"payment.checkout.typeBadge.oneTime"),H=E?.interval?` / ${u(`common.${E.interval}`)}`:"",K=y>1&&$&&n?`${y} × ${$} ${n.symbol}`:I?N.trim():"",V=(()=>{const w=e.quote_currency_id;if(e.custom_amount&&w&&w===n?.id)return He(e.custom_amount,n);if(x?.pricing_type==="dynamic"&&i&&x.base_amount){const M=Number(i);if(M>0&&Number.isFinite(M)){const se=Number(x.base_amount);if(se>0&&Number.isFinite(se)){const ae=se*y/M,ue=Math.abs(ae),de=ue>0&&ue<.01?6:2;return ae.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:de}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"}}}if(!i&&x?.base_amount!=null){const M=Number(x.base_amount);if(M>=0&&Number.isFinite(M))return(M*y).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}if(x&&n){const M=bt(x,n);if(M&&M!=="0"){const se=BigInt(M)*BigInt(y);return He(se.toString(),n)}}return"0"})(),Q=r?.[0],te=Q?.promotion_code_details?.code||Q?.verification_data?.code||Q?.promotion_code||"",U=(()=>{if(!te||!Q)return null;const w=Q?.coupon_details;if(w?.percent_off>0){const M=parseFloat(String(V).replace(/,/g,""));if(!Number.isNaN(M)&&M>0){const se=M*w.percent_off/100,ae=Math.abs(se),ue=ae>0&&ae<.01?6:2;return`${se.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:ue}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"} ${n?.symbol||""}`}}return e.discount_amounts?.length>0&&n?`${He(e.discount_amounts[0].amount,n)} ${n.symbol}`:null})(),re=e.adjustable_quantity?.enabled,Y=e.adjustable_quantity?.minimum||1,W=e.adjustable_quantity?.maximum,[oe,J]=p.useState(String(y)),[ne,L]=p.useState(!1),pe=We(),he=An(pe.breakpoints.down("md")),[le,T]=p.useState(!he);p.useEffect(()=>{ne||J(String(y))},[y,ne]);const fe=p.useRef(null),me=p.useCallback((w,M)=>{fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{s(w,M)},400)},[s]);p.useEffect(()=>()=>{fe.current&&clearTimeout(fe.current)},[]);const j=!!e.price?.upsell?.upsells_to,G=!!e.upsell_price,S=e.price?.upsell?.upsells_to;let R=0;if(j&&S){const w=parseFloat(e.price?.base_amount||e.price?.unit_amount||"0"),M=parseFloat(S?.base_amount||S?.unit_amount||"0"),se=e.price?.recurring?.interval,ae=S?.recurring?.interval;if(w>0&&M>0&&se&&ae){const ue={day:365,week:52,month:12,year:1},de=w*(ue[se]||1),Se=M*(ue[ae]||1);de>Se&&(R=Math.round((de-Se)/de*100))}}const O=S?.recurring?.interval,ie=(()=>{if(!S)return"";const w=O?u("common.slash",{interval:u(`common.${O}`)}):"";if(S.pricing_type==="dynamic"&&S.base_amount&&i){const se=Number(i);if(se>0&&Number.isFinite(se)){const ae=parseFloat(S.base_amount);if(ae>0&&Number.isFinite(ae)){const ue=ae/se,de=Math.abs(ue),Se=de>0&&de<.01?6:2;return`${ue.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:Se}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"} ${n?.symbol||""} ${w}`}}}if(S.pricing_type==="dynamic"&&S.base_amount&&S.base_currency==="USD")return`$${parseFloat(S.base_amount).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})} ${w}`;const M=Ye(S,n,i);return M?`${M} ${n?.symbol||""} ${w}`:""})(),Z=e.price?.recurring?.interval,ge=(()=>{if(!e.price||!G)return"";const w=e.price,M=Z?u("common.slash",{interval:u(`common.${Z}`)}):"";if(w.pricing_type==="dynamic"&&w.base_amount&&i){const ae=Number(i);if(ae>0&&Number.isFinite(ae)){const ue=parseFloat(w.base_amount);if(ue>0&&Number.isFinite(ue)){const de=ue/ae,Se=Math.abs(de),Oe=Se>0&&Se<.01?6:2;return`${de.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:Oe}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"} ${n?.symbol||""} ${M}`}}}if(w.pricing_type==="dynamic"&&w.base_amount&&w.base_currency==="USD")return`$${parseFloat(w.base_amount).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})} ${M}`;const se=Ye(w,n,i);return se?`${se} ${n?.symbol||""} ${M}`:""})(),ke=(()=>{if(G){const M=Z?u(Ae[Z]||""):"";return u("payment.checkout.upsell.revert",{recurring:M})}const w=O?u(Ae[O]||""):"";return u("payment.checkout.upsell.save",{recurring:w})})();return t.jsxs(_,{sx:{position:"relative"},children:[f&&t.jsx(Ke,{label:"RECOMMENDED",size:"small",sx:{position:"absolute",top:0,right:40,transform:"translateY(-50%)",zIndex:1,height:22,fontSize:9,fontWeight:900,letterSpacing:"0.12em",bgcolor:"primary.main",color:w=>$e(w),boxShadow:"0 4px 12px rgba(45,124,243,0.2)","& .MuiChip-label":{px:1.5}}}),t.jsxs(_,{sx:{p:{xs:2,md:3},bgcolor:"background.paper",borderRadius:{xs:"16px",md:"24px"},border:"1px solid",borderColor:"divider",boxShadow:w=>w.palette.mode==="dark"?"0 12px 40px -8px rgba(0,0,0,0.3)":"0 12px 40px -8px rgba(0,0,0,0.06)",transition:"all 0.3s ease",...j&&!d?{borderRadius:{xs:"16px 16px 0 0",md:"24px 24px 0 0"}}:{},"&:hover":{borderColor:w=>w.palette.mode==="dark"?"rgba(255,255,255,0.12)":"rgba(45,124,243,0.15)"}},children:[t.jsxs(D,{direction:"row",spacing:{xs:1.5,md:2.5},sx:{alignItems:"center",width:"100%"},children:[v?t.jsx(Ce,{src:v,alt:F,variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},flexShrink:0}}):t.jsx(Ce,{variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},bgcolor:w=>w.palette.mode==="dark"?"rgba(255,255,255,0.06)":"#eff6ff",flexShrink:0},children:t.jsx(Jt,{sx:{fontSize:{xs:22,md:28},color:"primary.main",opacity:.45}})}),t.jsx(_,{sx:{flex:1,minWidth:0,overflow:"hidden"},children:t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",sx:{mb:.25},children:[t.jsxs(_,{sx:{minWidth:0},children:[t.jsx(g,{sx:{color:"text.primary",fontWeight:800,fontSize:{xs:15,md:18},lineHeight:1.3},children:F}),t.jsx(g,{component:"span",sx:{display:"inline-block",mt:.5,fontSize:10,fontWeight:700,letterSpacing:"0.08em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:w=>w.palette.mode==="dark"?`${w.palette.primary.main}1A`:`${w.palette.primary.main}0D`,px:.75,py:.4,borderRadius:"3px"},children:B}),K&&t.jsx(g,{sx:{color:"text.disabled",fontSize:13,fontWeight:500,mt:.25},children:K})]}),t.jsx(D,{alignItems:"flex-end",sx:{flexShrink:0,ml:1.5},children:c&&P?t.jsx(g,{sx:{fontWeight:800,color:"text.primary",whiteSpace:"nowrap",fontSize:{xs:15,md:18}},children:cn(u,l,E?.interval||"day")}):m?t.jsx(Ne,{variant:"text",width:100,height:28}):t.jsxs(t.Fragment,{children:[t.jsxs(g,{sx:{fontWeight:800,color:"text.primary",whiteSpace:"nowrap",fontSize:{xs:15,md:18},transition:"opacity 0.3s ease"},children:[V," ",n?.symbol,H]}),i&&x?.base_amount&&t.jsxs(g,{sx:{fontSize:12,color:"text.disabled",fontWeight:600,lineHeight:1},children:["≈ $",(Number(x.base_amount)*y).toFixed(2)]})]})})]})})]}),b&&C.length>0&&t.jsxs(_,{sx:{mt:{xs:2,md:2.5},pt:{xs:2,md:2.5},borderTop:"1px solid",borderColor:w=>w.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.100"},children:[t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",onClick:()=>T(w=>!w),sx:{cursor:"pointer",userSelect:"none",mb:le?1.25:0},children:[t.jsx(g,{sx:{fontSize:14,fontWeight:700,color:"text.primary"},children:u("payment.checkout.planFeatures")}),t.jsx(Dn,{sx:{fontSize:20,color:"text.secondary",transition:"transform 0.2s ease",transform:le?"rotate(0deg)":"rotate(180deg)"}})]}),t.jsx(mt,{in:le,children:t.jsx(D,{spacing:1.25,children:C.map(w=>t.jsxs(D,{direction:"row",spacing:1.5,alignItems:"center",children:[t.jsx(_,{sx:{width:20,height:20,borderRadius:"50%",bgcolor:M=>M.palette.mode==="dark"?"rgba(16,185,129,0.15)":"rgba(16,185,129,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(Mn,{sx:{fontSize:14,color:"success.main"}})}),t.jsx(g,{sx:{fontSize:14,fontWeight:500,color:"text.secondary"},children:w.name})]},w.name))})})]}),te&&U&&t.jsx(_,{sx:{mt:1.5},children:m?t.jsx(Ne,{variant:"rounded",width:160,height:22,sx:{borderRadius:"6px"}}):t.jsx(Ke,{icon:t.jsx(en,{sx:{color:"warning.main",fontSize:"small"}}),label:`${te} (-${U})`,size:"small",sx:{height:22,borderRadius:"6px","& .MuiChip-label":{fontSize:12}}})}),re&&t.jsxs(D,{direction:"row",spacing:1,alignItems:"center",sx:{mt:2},children:[t.jsx(g,{sx:{color:"text.secondary",minWidth:"fit-content",fontSize:13,fontWeight:500},children:u("common.quantity")}),t.jsx(Ve,{size:"small",onClick:()=>{const M=(parseInt(oe,10)||y)-1;M<Y||(J(String(M)),me(e.price_id,M))},disabled:(parseInt(oe,10)||y)<=Y,sx:{width:36,height:36,border:"1px solid",borderColor:"divider",borderRadius:"50%","&:hover":{bgcolor:"action.hover"}},children:t.jsx(zn,{sx:{fontSize:20}})}),t.jsx(tn,{value:oe,size:"small",type:"number",slotProps:{htmlInput:{style:{textAlign:"center",padding:"6px 4px",fontWeight:700,fontSize:16,MozAppearance:"textfield"},min:Y,max:W||void 0}},sx:{minWidth:64,"& input":{textAlign:"center"},"& .MuiOutlinedInput-root":{borderRadius:"12px"},"& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button":{WebkitAppearance:"none",margin:0},"& input[type=number]":{MozAppearance:"textfield"}},onFocus:()=>L(!0),onChange:w=>J(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),w.stopPropagation(),w.target.blur())},onBlur:()=>{L(!1);const w=parseInt(oe,10);!Number.isNaN(w)&&w>=Y&&(!W||w<=W)&&w!==y?s(e.price_id,w):J(String(y))}}),t.jsx(Ve,{size:"small",onClick:()=>{const M=(parseInt(oe,10)||y)+1;W&&M>W||(J(String(M)),me(e.price_id,M))},disabled:W?(parseInt(oe,10)||y)>=W:!1,sx:{width:36,height:36,border:"1px solid",borderColor:"divider",borderRadius:"50%","&:hover":{bgcolor:"action.hover"}},children:t.jsx(nn,{sx:{fontSize:20}})})]}),h]}),j&&!d&&t.jsxs(_,{sx:{px:{xs:2,md:3},py:1.5,bgcolor:"background.paper",border:"1px solid",borderTop:0,borderColor:"divider",borderRadius:{xs:"0 0 16px 16px",md:"0 0 24px 24px"},boxShadow:w=>w.palette.mode==="dark"?"0 12px 40px -8px rgba(0,0,0,0.3)":"0 12px 40px -8px rgba(0,0,0,0.06)"},children:[t.jsx(_,{sx:{borderTop:"1px solid",borderColor:"divider",mb:1.5}}),t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[t.jsxs(D,{direction:"row",alignItems:"center",spacing:1,children:[t.jsx(Nn,{checked:G,onChange:async()=>{try{G?await a(e.upsell_price?.id||e.price.id):await o(e.price_id,S.id)}catch(w){Fe.error(w?.response?.data?.error||w?.message||"Failed")}},size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#12b886"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"#12b886"}}}),t.jsx(g,{sx:{fontSize:13,color:"text.secondary",cursor:"pointer",fontWeight:600},onClick:async()=>{try{G?await a(e.upsell_price?.id||e.price.id):await o(e.price_id,S.id)}catch(w){Fe.error(w?.response?.data?.error||w?.message||"Failed")}},children:ke}),!G&&R>0&&t.jsx(Ke,{label:u("payment.checkout.upsell.off",{saving:R}),size:"small",sx:{height:22,fontSize:11,fontWeight:700,bgcolor:w=>w.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",border:"1px solid",borderColor:w=>w.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8",borderRadius:"9999px","& .MuiChip-label":{px:1}}})]}),t.jsx(g,{sx:{fontSize:13,color:"text.primary",whiteSpace:"nowrap",fontWeight:700},children:G?ge:ie})]})]})]})}function Ri({billingInterval:e}){const{t:n}=be();if(!e?.available?.length||e.available.length<=1)return null;const r=e.available.reduce((i,s)=>Number(s.savings||0)>Number(i.savings||0)?s:i);return t.jsxs(D,{direction:"row",alignItems:"center",spacing:2,sx:{mb:3},children:[t.jsx(D,{direction:"row",alignItems:"center",sx:{bgcolor:"background.paper",borderRadius:"9999px",border:"1px solid",borderColor:"divider",p:"4px",display:"inline-flex",boxShadow:i=>i.palette.mode==="dark"?"0 1px 2px 0 rgba(0,0,0,0.3)":"0 1px 2px 0 rgba(0,0,0,0.05)"},children:e.available.map(i=>{const s=i.interval===e.current,o={bgcolor:c=>c.palette.mode==="dark"?"rgba(156,106,222,0.25)":"rgba(156,106,222,0.15)",color:"primary.main",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",boxShadow:c=>c.palette.mode==="dark"?"0 2px 8px rgba(156,106,222,0.2), inset 0 1px 0 rgba(255,255,255,0.06)":"0 2px 8px rgba(156,106,222,0.15), inset 0 1px 0 rgba(255,255,255,0.5)",border:"1px solid",borderColor:c=>c.palette.mode==="dark"?"rgba(156,106,222,0.3)":"rgba(156,106,222,0.2)"},a={color:"text.secondary",border:"1px solid transparent","&:hover":{color:"text.primary"}};return t.jsx(_,{onClick:()=>{i.interval!==e.current&&!e.switching&&e.switch(i.interval)},sx:{px:3.5,py:1,borderRadius:"9999px",cursor:"pointer",transition:"all 0.3s ease",userSelect:"none",...s?o:a},children:e.switching&&s?t.jsx(ft,{size:14,color:"inherit",sx:{my:"1px"}}):t.jsx(g,{component:"span",sx:{fontSize:14,fontWeight:700,color:"inherit",lineHeight:1},children:n(Ae[i.interval]||i.interval)})},i.interval)})}),r.savings&&Number(r.savings)>0&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,sx:{px:1.5,py:.75,bgcolor:i=>i.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",fontSize:11,fontWeight:700,borderRadius:"9999px",border:"1px solid",borderColor:i=>i.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8",textTransform:"uppercase",letterSpacing:"0.05em"},children:[t.jsx(rn,{sx:{fontSize:14}}),t.jsxs(g,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit",color:"inherit",lineHeight:1},children:["SAVE ",r.savings,"%"]})]})]})}function Pi({crossSellItem:e,currency:n,exchangeRate:r,crossSellRequired:i,onAdd:s}){const{t:o}=be();if(!e)return null;const{product:a}=e,c=a?.images?.[0]||"",l=a?.name||o("payment.checkout.cross_sell.add"),{recurring:u}=e,f=u?.interval?Ae[u.interval]:null,d=a?.description||"",m=d&&d!==l?d:f?o(f):"";return t.jsxs(_,{sx:{position:"relative"},children:[i&&t.jsx(Ke,{label:xe(o,"payment.checkout.cross_sell.recommended","RECOMMENDED"),size:"small",sx:{position:"absolute",top:0,right:40,transform:"translateY(-50%)",zIndex:1,height:22,fontSize:9,fontWeight:900,letterSpacing:"0.12em",bgcolor:"primary.main",color:b=>$e(b),boxShadow:"0 4px 12px rgba(45,124,243,0.2)","& .MuiChip-label":{px:1.5}}}),t.jsx(_,{sx:{p:{xs:2,md:3},bgcolor:"background.paper",borderRadius:{xs:"16px",md:"24px"},border:"2px dashed",borderColor:b=>b.palette.mode==="dark"?"rgba(255,255,255,0.15)":"rgba(45,124,243,0.25)",boxShadow:b=>b.palette.mode==="dark"?"0 12px 40px -8px rgba(0,0,0,0.3)":"0 12px 40px -8px rgba(0,0,0,0.06)",transition:"all 0.3s ease",cursor:"pointer","&:hover":{borderColor:"primary.main",boxShadow:"0 12px 40px -8px rgba(0,0,0,0.1)"}},onClick:s,children:t.jsxs(D,{direction:"row",spacing:{xs:1.5,md:2.5},sx:{alignItems:"center",width:"100%"},children:[c?t.jsx(Ce,{src:c,variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},flexShrink:0}}):t.jsx(Ce,{variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},bgcolor:b=>b.palette.mode==="dark"?"rgba(255,255,255,0.06)":"#eff6ff",flexShrink:0},children:t.jsx(Jt,{sx:{fontSize:{xs:22,md:28},color:"primary.main",opacity:.45}})}),t.jsxs(_,{sx:{flex:1,minWidth:0},children:[t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",sx:{mb:.25},children:[t.jsx(g,{sx:{fontWeight:800,fontSize:{xs:15,md:18},color:"text.primary",lineHeight:1.3},children:l}),t.jsxs(D,{alignItems:"flex-end",sx:{flexShrink:0,ml:{xs:1,md:2}},children:[t.jsxs(g,{sx:{fontWeight:800,color:"text.primary",whiteSpace:"nowrap",fontSize:{xs:15,md:18}},children:[Ye(e,n,r)," ",n?.symbol]}),r&&e.base_amount&&t.jsxs(g,{sx:{fontSize:10,color:"text.disabled",fontWeight:700,lineHeight:1},children:["≈ $",Number(e.base_amount||0).toFixed(2)]})]})]}),m&&t.jsx(g,{sx:{fontSize:{xs:12,md:14},color:"text.secondary",fontWeight:500,lineHeight:1.4},noWrap:!0,children:m}),t.jsx(_,{sx:{pt:{xs:1.5,md:2}},children:t.jsx(Ee,{size:"small",variant:"outlined",startIcon:t.jsx(Fn,{sx:{fontSize:"14px !important"}}),sx:{textTransform:"none",fontSize:{xs:11,md:12},fontWeight:700,borderRadius:"8px",border:"1px solid",borderColor:"divider",color:"primary.main",bgcolor:"background.paper",boxShadow:1,px:1.5,py:.5,transition:"all 0.2s","&:hover":{bgcolor:"primary.main",color:b=>$e(b),borderColor:"primary.main"},"&:active":{transform:"scale(0.95)"}},onClick:b=>{b.stopPropagation(),s()},children:xe(o,"payment.checkout.cross_sell.addToOrder","Add to order")})})]})]})})]})}function Ti({trial:e,mode:n,items:r}){const{t:i}=be();if(e.active&&e.afterTrialPrice)return t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{borderTop:"1px solid",borderColor:"divider",pt:1,mt:1},children:[t.jsx(g,{sx:{color:"text.secondary",fontSize:14},children:i("common.nextCharge")}),t.jsxs(g,{sx:{fontSize:16,color:"text.secondary"},children:[e.afterTrialPrice,e.afterTrialInterval?` ${i(Ae[e.afterTrialInterval]||"")}`:""]})]});if(!e.active&&["subscription","setup"].includes(n)){const s=r.find(c=>(c.upsell_price||c.price)?.recurring?.usage_type==="metered");if(!s)return null;const o=(s.upsell_price||s.price)?.recurring?.interval;if(!o)return null;const a=i("common.per",{interval:i(`common.${o}`)});return t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{borderTop:"1px solid",borderColor:"divider",pt:1,mt:1},children:[t.jsx(g,{sx:{color:"text.secondary",fontSize:14,fontWeight:600},children:i("common.nextCharge")}),t.jsx(g,{sx:{fontSize:16,color:"text.secondary"},children:i("payment.checkout.metered",{recurring:a})})]})}return null}function Cn(){const{t:e}=be(),{session:n}=_e(),{currency:r,isStripe:i,switching:s}=Ie(),{livemode:o}=vt(),{product:a,pageInfo:c}=wn(),l=St(),u=Si(),f=kn(),d=wt(),m=vn(),{isMobile:b}=Ze(),h=n?.mode||"payment",x=n?.discounts||[],k=n?.app_name||n?.payment_link?.app_name||"",F=n?.app_logo||n?.payment_link?.app_logo||"",v=b||l.items.length>=4,[C,E]=p.useState(b?l.items.length<=1:l.items.length<4),y=l.crossSellItem&&!l.items.some(T=>T.price_id===l.crossSellItem?.id),I=l.items.filter(T=>!T.cross_sell),N=l.items.filter(T=>T.price?.upsell?.upsells_to),$=N.length===1?N[0]:null,P=$?$.price?.upsell?.upsells_to:null,B=I.length<=1,H=B&&!!$&&["subscription","setup"].includes(h),K=!!$?.upsell_price,[V,Q]=p.useState(!1),[te,U]=p.useState(null),re=te!==null?te:K,Y=H?$.price?.recurring?.interval:null,W=H?P?.recurring?.interval:null;let oe=0;if(H&&Y&&W){const T=parseFloat($.price?.base_amount||$.price?.unit_amount||"0"),fe=parseFloat(P?.base_amount||P?.unit_amount||"0"),me={day:365,week:52,month:12,year:1},j=T*(me[Y]||1),G=fe*(me[W]||1);j>G&&j>0&&(oe=Math.round((j-G)/j*100))}const J=p.useRef(d.status);p.useEffect(()=>{J.current!=="unavailable"&&d.status==="unavailable"&&!i&&Fe.error(e("payment.dynamicPricing.unavailable.message")),J.current=d.status},[d.status,i,e]);const ne=ar(e,n,a,l.items),L=l.items.length>1,pe={bgcolor:"primary.main",color:T=>$e(T),boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)"},he={color:"text.secondary","&:hover":{color:"text.primary"}},le=T=>({px:3.5,py:1,borderRadius:"9999px",cursor:"pointer",transition:"all 0.3s ease",userSelect:"none",...T?pe:he});return t.jsxs(_,{sx:{display:"flex",flexDirection:"column",flex:1},children:[!b&&(k||F)&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:1,sx:{mb:5},children:[F&&t.jsx(Ce,{src:F,alt:k,sx:{width:48,height:48,borderRadius:"16px",bgcolor:"background.paper",boxShadow:1,border:"1px solid",borderColor:"divider"}}),k&&t.jsx(g,{sx:{fontWeight:600,fontSize:15,color:"text.primary"},children:k})]}),!b&&t.jsx(_,{sx:{flexGrow:1,flexShrink:1,flexBasis:0}}),t.jsxs(_,{sx:{flexShrink:0},children:[t.jsxs(_,{sx:{mb:{xs:3,md:4}},children:[b&&(k||F)&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:1,sx:{mb:1},children:[F&&t.jsx(Ce,{src:F,alt:k,sx:{width:24,height:24,borderRadius:"6px"}}),k&&t.jsx(g,{sx:{fontWeight:600,fontSize:13,color:"text.secondary"},children:k})]}),t.jsxs(D,{direction:"row",alignItems:"center",spacing:1,sx:{mb:1.5},children:[t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:T=>T.palette.mode==="dark"?`${T.palette.primary.main}1A`:`${T.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:ne.badgeLabel}),f.trial.active&&f.trial.days>0&&t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:T=>T.palette.mode==="dark"?`${T.palette.primary.main}1A`:`${T.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:cn(e,f.trial.days,f.trial.afterTrialInterval||"day")}),!o&&t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:T=>T.palette.mode==="dark"?T.palette.grey[500]:T.palette.grey[400],bgcolor:T=>T.palette.mode==="dark"?"rgba(255,255,255,0.06)":T.palette.grey[100],px:1,py:.5,borderRadius:"4px"},children:e("common.livemode")})]}),t.jsx(g,{sx:{fontWeight:800,fontSize:{xs:24,md:36},lineHeight:1.1,letterSpacing:"-0.03em",color:"text.primary",mb:.75},children:L?xe(e,"payment.checkout.orderSummary","Order Summary"):ne.title}),(L||ne.subtitle)&&t.jsx(g,{sx:{color:"text.secondary",fontSize:{xs:14,md:16},fontWeight:500,lineHeight:1.5},children:L?xe(e,"payment.checkout.orderSummarySubtitle","Items included in this purchase"):ne.subtitle}),H&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:2,sx:{mt:2.5},children:[t.jsxs(D,{direction:"row",alignItems:"center",sx:{bgcolor:"background.paper",borderRadius:"9999px",border:"1px solid",borderColor:"divider",p:"4px",display:"inline-flex",boxShadow:T=>T.palette.mode==="dark"?"0 1px 2px 0 rgba(0,0,0,0.3)":"0 1px 2px 0 rgba(0,0,0,0.05)"},children:[t.jsx(_,{onClick:async()=>{if(K&&!V){U(!1),Q(!0);try{await l.downsell($.upsell_price?.id||$.price_id)}catch(T){U(null),Fe.error(T?.response?.data?.error||T?.message||"Failed")}finally{Q(!1),U(null)}}},sx:le(!re),children:t.jsx(g,{component:"span",sx:{fontSize:14,fontWeight:700,color:"inherit",lineHeight:1},children:e(Ae[Y]||"")})}),t.jsx(_,{onClick:async()=>{if(!K&&!V){U(!0),Q(!0);try{await l.upsell($.price_id,P.id)}catch(T){U(null),Fe.error(T?.response?.data?.error||T?.message||"Failed")}finally{Q(!1),U(null)}}},sx:le(re),children:t.jsx(g,{component:"span",sx:{fontSize:14,fontWeight:700,color:"inherit",lineHeight:1},children:e(Ae[W]||"")})})]}),oe>0&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,sx:{px:1.5,py:.75,bgcolor:T=>T.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",fontSize:11,fontWeight:700,borderRadius:"9999px",border:"1px solid",borderColor:T=>T.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8",textTransform:"uppercase",letterSpacing:"0.05em"},children:[t.jsx(rn,{sx:{fontSize:14}}),t.jsxs(g,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit",color:"inherit",lineHeight:1},children:["SAVE ",oe,"%"]})]})]})]}),t.jsx(Ri,{billingInterval:u})]}),t.jsxs(_,{sx:{flexGrow:0,flexShrink:1,flexBasis:"auto",minHeight:{md:0},overflowY:{md:"auto"},"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},children:[v&&t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",onClick:()=>E(!C),sx:{cursor:"pointer",mb:1.5},children:[t.jsx(g,{sx:{fontSize:14,fontWeight:600},children:e("payment.checkout.productListTotal",{total:l.items.length})}),t.jsx(sn,{sx:{transform:C?"rotate(180deg)":"rotate(0deg)",transition:"0.3s"}})]}),t.jsxs(mt,{in:C||!v,children:[t.jsx(D,{spacing:2,sx:{mb:2},children:l.items.map(T=>t.jsx(Ei,{item:T,currency:r,discounts:x,exchangeRate:d.value,onQuantityChange:l.updateQuantity,onUpsell:l.upsell,onDownsell:l.downsell,trialActive:f.trial.active,trialDays:f.trial.days,hideUpsell:H||!B,isRateLoading:s||d.hasDynamicPricing&&d.status==="loading",showFeatures:c?.showProductFeatures??!1,t:e,children:T.cross_sell&&t.jsx(Ee,{size:"small",color:"error",variant:"text",onClick:l.removeCrossSell,sx:{mt:1,ml:-.5,textTransform:"none",fontSize:12},children:e("payment.checkout.cross_sell.remove")})},T.id))}),y&&t.jsx(_,{sx:{mb:2},children:t.jsx(Pi,{crossSellItem:l.crossSellItem,currency:r,exchangeRate:d.value,crossSellRequired:l.crossSellRequired,onAdd:l.addCrossSell})})]})]}),t.jsx(_,{sx:{flexShrink:0},children:t.jsx(Ti,{trial:{active:f.trial.active,days:f.trial.days,afterTrialPrice:f.trial.afterTrialPrice,afterTrialInterval:f.trial.afterTrialInterval},mode:h,items:l.items})}),t.jsx(_,{sx:{flexGrow:1,flexShrink:1,flexBasis:0}}),t.jsxs(_,{sx:{flexShrink:0},children:[d.hasDynamicPricing&&d.status==="unavailable"&&!i&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,sx:{mb:2},children:[t.jsx(g,{sx:{fontSize:13,color:"text.secondary",fontWeight:500},children:e("payment.dynamicPricing.unavailable.title")}),t.jsx(g,{component:"span",onClick:d.refresh,sx:{fontSize:13,color:"primary.main",fontWeight:600,cursor:"pointer","&:hover":{textDecoration:"underline"}},children:e("payment.dynamicPricing.unavailable.retry")})]}),t.jsx(ln,{hasDynamicPricing:d.hasDynamicPricing,rate:{value:d.value,display:d.display,provider:d.provider,providerDisplay:d.providerDisplay,fetchedAt:d.fetchedAt,status:d.status},slippage:{percent:m.percent,set:m.set},currencySymbol:r?.symbol||"",isSubscription:["subscription","setup"].includes(h)})]})]})}function Ai({livemode:e,label:n=void 0}){const{t:r}=be();return t.jsxs(D,{direction:"row",alignItems:"center",spacing:1,sx:{mb:1.5},children:[t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:i=>i.palette.mode==="dark"?`${i.palette.primary.main}1A`:`${i.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:n||xe(r,"payment.checkout.orderSummary","Order Summary")}),!e&&t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:i=>i.palette.mode==="dark"?i.palette.grey[500]:i.palette.grey[400],bgcolor:i=>i.palette.mode==="dark"?"rgba(255,255,255,0.06)":i.palette.grey[100],px:1,py:.5,borderRadius:"4px"},children:r("common.livemode")})]})}function Di(){const{t:e,locale:n}=be(),{session:r,sessionData:i}=_e(),{livemode:s}=vt(),{product:o}=wn(),{currency:a,isStripe:c}=Ie(),l=St(),u=wt(),f=vn(),{locked:d}=et(),m=l.items[0],b=m?m.upsell_price||m.price:null,h=b?.metadata?.credit_config,x=h?.credit_amount?Number(h.credit_amount):0,k=h?.currency_id,{session:F,getCurrency:v}=un(),C=k?v(k):null,E=F?.user?.did||i?.customer?.did,y=C?.decimal,I=C?.symbol||"Credits",N="Credits",$=b?.metadata?.meter_id,{data:P}=ut(async()=>{if(!$)return null;try{const{data:A}=await dt.get(`/api/meters/public/${$}`);return A}catch{return null}},{refreshDeps:[$]}),B=P?.name||o?.name||"Credits",H=h?.valid_duration_value,K=h?.valid_duration_unit||"days",V=h?.schedule,Q=V?.enabled&&V?.delivery_mode&&V.delivery_mode!=="invoice",te=H&&H>0,U=Math.max(x,1),re=m?.adjustable_quantity,Y=re?.enabled!==!1,W=Math.max(re?.minimum||1,1),oe=Math.min(b?.quantity_limit_per_checkout??1/0,b?.quantity_available??1/0),J=oe?Math.min(re?.maximum||1/0,oe):re?.maximum||1/0,{data:ne}=ut(async()=>{if(!h||!E||!k||y==null)return null;try{const{data:A}=await dt.get("/api/meter-events/pending-amount",{params:{customer_id:E,currency_id:k}});return A?.[k]}catch{return null}},{refreshDeps:[h,E,k,y]}),L=p.useMemo(()=>{if(!ne||!x||x<=0)return null;const A=new z(ne||"0");if(!A.gt(new z(0)))return null;const ye=Xe(x,y);return!ye||ye.isZero()?null:Math.ceil(A.mul(new z(100)).div(ye).toNumber()/100)},[ne,x,y]),pe=ne&&new z(ne||"0").gt(new z(0)),he=p.useMemo(()=>pe?Be(cr(ne,y),I,n):"",[pe,ne,y,I,n]),le=L?L*U:0,T=le?Be(Re(le),I,n):"",fe=p.useMemo(()=>{if(Q&&V){const A=V.interval_unit,ye=V.interval_value;let Le;V.amount_per_grant?Le=Number(V.amount_per_grant):Le=x;const qe=lr(Re(Le),N),Rt=ye===1?e(`common.${A}`):`${ye} ${e(`common.${A}s`)}`;return V.expire_with_next_grant?e("payment.checkout.credit.schedule.withRefresh",{amount:qe,interval:Rt}):e("payment.checkout.credit.schedule.periodic",{amount:qe,interval:Rt})}return""},[x,N,Q,V,e]),me=p.useMemo(()=>te?e("payment.checkout.creditTopup.validFor",{duration:H,unit:e(`common.${K}`)}):"",[te,H,K,e]),j=!!fe,G=m?.quantity||1,[S,R]=p.useState(G),[O,ie]=p.useState(G*U),[Z,ge]=p.useState(!1),[ke,w]=p.useState(""),M=p.useRef(null);p.useEffect(()=>{d||r?.status==="complete"||m?.quantity&&m.quantity!==S&&(R(m.quantity),ie(m.quantity*U))},[m?.quantity]);const se=p.useRef(!1);p.useEffect(()=>{if(!(d||r?.status==="complete")&&!se.current&&L&&L>S){se.current=!0;const A=Math.min(Math.max(L,W),J);R(A),ie(A*U),m&&l.updateQuantity(m.price_id,A)}},[L]);const ae=J*U,ue=W*U,de=p.useRef(null);p.useEffect(()=>()=>{de.current&&clearTimeout(de.current)},[]);const Se=p.useCallback(A=>{if(A<=0)return;const ye=Math.max(ue,Math.min(ae,A)),Le=Math.ceil(ye/U),qe=Math.max(W,Math.min(J,Le));R(qe),ie(ye),m&&(de.current&&clearTimeout(de.current),de.current=setTimeout(()=>{l.updateQuantity(m.price_id,qe)},400))},[U,W,J,ue,ae,m,l]),Oe=p.useCallback(A=>{const ye=O+A*U;ye<U*W||Math.ceil(ye/U)>J||Se(ye)},[O,U,W,J,Se]),Ue=Math.max(W,Math.min(J,Math.ceil(O/U))),Qe=Ue*U,kt=Re(Qe,6,!0,!0),En=Re(O,6,!0,!0),jt=Y&&U>1,Rn=p.useMemo(()=>pe?Qe>=le?e("payment.checkout.creditTopup.pendingEnough",{pendingAmount:he,availableAmount:Be(Re(Qe-le),I,n)}):e("payment.checkout.creditTopup.pendingWarning",{pendingAmount:he,minCredits:T}):"",[pe,Qe,le,he,I,n,T,e]),Pn=p.useCallback(()=>{Y&&(w(String(O)),ge(!0),setTimeout(()=>M.current?.select(),0))},[Y,O]),tt=p.useCallback(()=>{ge(!1);const A=parseInt(ke.replace(/,/g,""),10);!Number.isFinite(A)||A<=0||Se(A)},[ke,Se]),Tn=p.useCallback(A=>{A.key==="Enter"?tt():A.key==="Escape"&&ge(!1)},[tt]),Ct={xs:48,md:72},It={fontSize:Ct,fontWeight:800,lineHeight:1,letterSpacing:"-0.03em"},Et={width:{xs:40,md:56},height:{xs:40,md:56},borderRadius:"50%",bgcolor:"background.paper",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(255,255,255,0.12)":"divider",color:"text.secondary",transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",color:"primary.main",bgcolor:"background.paper"},"&.Mui-disabled":{borderColor:A=>A.palette.mode==="dark"?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",color:A=>A.palette.mode==="dark"?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.12)"}};return t.jsxs(_,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[t.jsxs(_,{sx:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center"},children:[t.jsx(Ai,{livemode:s,label:xe(e,"payment.checkout.typeBadge.topup","TOP-UP")}),t.jsx(g,{sx:{fontWeight:800,fontSize:{xs:28,md:48},lineHeight:1.1,letterSpacing:"-0.03em",color:"text.primary",mb:{xs:.5,md:1}},children:e("payment.checkout.creditTopup.title",{name:B})}),j&&t.jsx(_,{sx:{display:"flex",alignItems:"flex-start",gap:1,mb:{xs:1.5,md:2.5}},children:t.jsx(g,{sx:{fontSize:{xs:13,md:15},fontWeight:500,color:"text.secondary",lineHeight:1.5},children:fe})}),pe&&t.jsxs(D,{direction:"row",alignItems:"flex-start",spacing:1.5,sx:{mb:{xs:1.5,md:2.5},p:{xs:1.5,md:2},borderRadius:"12px",bgcolor:A=>A.palette.mode==="dark"?"rgba(255,152,0,0.12)":"rgba(255,152,0,0.08)",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(255,152,0,0.25)":"rgba(255,152,0,0.2)"},children:[t.jsx($n,{sx:{fontSize:18,color:"warning.main",mt:.25,flexShrink:0}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:600,lineHeight:1.5,color:"text.primary"},children:Rn})]}),Y?t.jsxs(_,{sx:{display:"flex",flexDirection:"column",maxWidth:480},children:[t.jsx(g,{sx:{fontSize:{xs:14,md:17},fontWeight:700,color:"text.secondary",mt:{xs:3,md:5},mb:{xs:2,md:3}},children:e("payment.checkout.creditTopup.question",{symbol:N})}),t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:{xs:1.5,md:2}},children:[t.jsx(Ve,{onClick:()=>Oe(-1),disabled:Ue<=W,sx:Et,children:t.jsx(_,{component:"span",sx:{fontSize:{xs:22,md:28},fontWeight:300,lineHeight:1,mt:"-1px"},children:"−"})}),t.jsxs(_,{sx:{flex:1,minWidth:0,textAlign:"center",cursor:Y?"text":"default"},onClick:Pn,children:[t.jsx(_,{sx:{height:Ct,display:"flex",alignItems:"center",justifyContent:"center"},children:Z?t.jsx(xt,{inputRef:M,value:ke,onChange:A=>w(A.target.value.replace(/\D/g,"")),onBlur:tt,onKeyDown:Tn,autoFocus:!0,inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{width:"100%",bgcolor:"transparent","&.Mui-focused":{bgcolor:"transparent"},"& input":{textAlign:"center",...It,p:0,fontFamily:"inherit",bgcolor:"transparent","&:focus":{bgcolor:"transparent"}}}}):t.jsx(g,{sx:{...It,color:"text.primary",userSelect:"none"},children:En})}),t.jsx(_,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.75,mt:1},children:t.jsx(g,{sx:{fontSize:{xs:12,md:14},fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.05em"},children:N})})]}),t.jsx(Ve,{onClick:()=>Oe(1),disabled:Ue>=J,sx:Et,children:t.jsx(_,{component:"span",sx:{fontSize:{xs:22,md:28},fontWeight:300,lineHeight:1},children:"+"})})]}),U>1&&t.jsx(g,{sx:{fontSize:11,fontWeight:600,color:"grey.500",textTransform:"uppercase",letterSpacing:"0.08em",textAlign:"center",mt:{xs:1.5,md:2}},children:e("payment.checkout.creditTopup.increment",{step:Re(U,6,!0,!0),symbol:N})}),jt&&t.jsxs(_,{sx:{display:"flex",flexDirection:"column",mt:{xs:3,md:4},borderRadius:"20px",backdropFilter:"blur(12px)",bgcolor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.08)":"rgba(59,130,246,0.04)",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.18)":"rgba(59,130,246,0.10)",boxShadow:A=>A.palette.mode==="dark"?"0 8px 32px rgba(59,130,246,0.06)":"0 8px 32px rgba(59,130,246,0.04)"},children:[t.jsxs(_,{sx:{p:{xs:2.5,md:3.5}},children:[t.jsxs(g,{sx:{fontSize:{xs:16,md:20},fontWeight:700,color:"primary.main",mb:.5},children:[e("payment.checkout.creditTopup.willReceive"),": ",t.jsx(_,{component:"span",sx:{fontWeight:800},children:Be(kt,N,n)})]}),t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.5},children:[t.jsx(Wn,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:14},fontWeight:600,color:"text.secondary"},children:e("payment.checkout.creditTopup.packInfo",{packs:Ue,perPack:Re(U,6,!0,!0)})})]}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:e("payment.checkout.creditTopup.autoMatch")})]}),me&&t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,px:{xs:2.5,md:3.5},py:{xs:1.5,md:2},borderTop:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.15)":"rgba(59,130,246,0.08)"},children:[t.jsx(Pt,{sx:{fontSize:14,color:"grey.500"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:me})]})]}),!jt&&me&&t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,mt:{xs:2.5,md:3.5}},children:[t.jsx(On,{sx:{fontSize:14,color:"grey.500"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:me})]})]}):t.jsxs(_,{sx:{display:"flex",flexDirection:"column",mt:{xs:2,md:3},borderRadius:"20px",backdropFilter:"blur(12px)",bgcolor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.08)":"rgba(59,130,246,0.04)",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.18)":"rgba(59,130,246,0.10)",boxShadow:A=>A.palette.mode==="dark"?"0 8px 32px rgba(59,130,246,0.06)":"0 8px 32px rgba(59,130,246,0.04)"},children:[t.jsxs(_,{sx:{p:{xs:2.5,md:3.5}},children:[t.jsx(g,{sx:{fontSize:{xs:13,md:14},fontWeight:600,color:"text.secondary",mb:1},children:e("payment.checkout.creditTopup.willReceive")}),t.jsx(_,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(g,{sx:{fontSize:{xs:32,md:48},fontWeight:800,lineHeight:1,letterSpacing:"-0.03em",color:"primary.main"},children:Be(kt,N,n)})})]}),me&&t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,px:{xs:2.5,md:3.5},py:{xs:1.5,md:2},borderTop:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.15)":"rgba(59,130,246,0.08)"},children:[t.jsx(Pt,{sx:{fontSize:14,color:"grey.500"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:me})]})]})]}),t.jsxs(_,{sx:{flexShrink:0},children:[u.hasDynamicPricing&&u.status==="unavailable"&&!c&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,sx:{mb:2},children:[t.jsx(g,{sx:{fontSize:13,color:"text.secondary",fontWeight:500},children:e("payment.dynamicPricing.unavailable.title")}),t.jsx(g,{component:"span",onClick:u.refresh,sx:{fontSize:13,color:"primary.main",fontWeight:600,cursor:"pointer","&:hover":{textDecoration:"underline"}},children:e("payment.dynamicPricing.unavailable.retry")})]}),t.jsx(ln,{hasDynamicPricing:u.hasDynamicPricing,rate:{value:u.value,display:u.display,provider:u.provider,providerDisplay:u.providerDisplay,fetchedAt:u.fetchedAt,status:u.status},slippage:{percent:f.percent,set:f.set},currencySymbol:a?.symbol||"",isSubscription:["subscription","setup"].includes(r?.mode||"payment")})]})]})}const Mi=Cn;function zi(){const{session:e,items:n}=_e();switch(Ii(e,n)){case"subscription":return t.jsx(Mi,{});case"credit-topup":return t.jsx(Di,{});default:return t.jsx(Cn,{})}}function Ni({value:e,country:n,onChange:r,onCountryChange:i,label:s,error:o=void 0,onBlur:a=void 0}){const c=p.useRef(!1),l=p.useCallback(x=>{if(!c.current)try{c.current=!0,x()}finally{requestAnimationFrame(()=>{c.current=!1})}},[]),{phone:u,handlePhoneValueChange:f,inputRef:d,country:m,setCountry:b}=ur({defaultCountry:dr(n)?n:"us",value:e||"",countries:mr,onChange:x=>{l(()=>{r(x.phone),i(x.country)})}});Jn(()=>{pr().catch(x=>{console.error("Failed to preload phone validator:",x)})}),p.useEffect(()=>{!n||n===m||l(()=>{b(n)})},[n,m,b,l]);const h=p.useCallback(x=>{l(()=>{b(x),i(x)})},[b,l,i]);return t.jsxs(_,{sx:{mb:1.5},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.primary",mb:.5},children:s}),t.jsx(xt,{fullWidth:!0,value:u,onChange:f,onBlur:a,type:"tel",inputRef:d,startAdornment:t.jsx(ht,{position:"start",sx:{mr:.25,ml:-.5},children:t.jsx(dn,{value:m,onChange:h,sx:{".MuiOutlinedInput-notchedOutline":{borderColor:"transparent !important"},"& .MuiSelect-select":{py:0,pr:"20px !important"}},showDialCode:!0})}),sx:{bgcolor:x=>x.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50",borderRadius:"8px",px:1.5,py:.75,fontSize:14,"& .MuiInputBase-input":{p:0}}}),o&&t.jsx(g,{sx:{fontSize:12,color:"error.main",mt:.25},children:o})]})}const Fi=e=>({customer_name:e("payment.checkout.customer.name"),customer_email:e("payment.checkout.customer.email"),customer_phone:e("payment.checkout.customer.phone"),"billing_address.country":e("payment.checkout.billing.country"),"billing_address.state":e("payment.checkout.billing.state"),"billing_address.city":e("payment.checkout.billing.city"),"billing_address.line1":e("payment.checkout.billing.line1"),"billing_address.line2":e("payment.checkout.billing.line2"),"billing_address.postal_code":e("payment.checkout.billing.postal_code")});function $i({form:e,isLoggedIn:n}){const{t:r}=be(),i=Fi(r),[s,o]=p.useState(!1),[a,c]=p.useState(!1),l=p.useRef(!1);p.useEffect(()=>{l.current||!e.prefetched&&!e.values.customer_name&&!e.values.customer_email||(l.current=!0,e.checkValid().then(f=>{o(!f),c(!0)}))},[e.prefetched]);const u=p.useCallback((f,d)=>e.onChange(f,d),[e.onChange]);return p.useEffect(()=>{a&&!s&&Object.keys(e.errors).length>0&&o(!0)},[e.errors]),!n||!a?null:s?t.jsxs(_,{sx:{mt:2},children:[t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.secondary"},children:r("payment.checkout.customerInfo")}),t.jsx(Ee,{size:"small",variant:"text",onClick:()=>o(!1),sx:{minWidth:0,fontSize:13,fontWeight:600,p:0},children:r("common.confirm")})]}),t.jsx(D,{spacing:0,sx:{p:2,backgroundColor:"background.paper",borderRadius:1,border:"1px solid",borderColor:"divider"},children:e.fields.filter(f=>f.name!=="billing_address.country").map(f=>{const{name:d}=f,m=i[d]||d,b=d.includes(".")?d.split(".").reduce((k,F)=>k?.[F],e.values):e.values[d],h=d==="billing_address.postal_code";return d==="customer_phone"?t.jsx(Ni,{value:b||"",country:e.values.billing_address?.country||"",onChange:k=>u("customer_phone",k),onCountryChange:k=>u("billing_address.country",k),onBlur:()=>e.validateField(d),label:m,error:e.errors[d]},d):t.jsxs(_,{sx:{mb:1.5},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.primary",mb:.5},children:m}),t.jsx(xt,{fullWidth:!0,value:b||"",onChange:k=>u(d,k.target.value),onBlur:()=>e.validateField(d),startAdornment:h?t.jsx(ht,{position:"start",sx:{mr:.5,ml:-.5},children:t.jsx(dn,{value:e.values.billing_address?.country||"",onChange:k=>u("billing_address.country",k),sx:{".MuiOutlinedInput-notchedOutline":{borderColor:"transparent !important"},"& .MuiSelect-select":{py:0,pr:"20px !important"}}})}):void 0,sx:{bgcolor:k=>k.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50",borderRadius:"8px",px:1.5,py:.75,fontSize:14,"& .MuiInputBase-input":{p:0}}}),e.errors[d]&&t.jsx(g,{sx:{fontSize:12,color:"error.main",mt:.25},children:e.errors[d]})]},d)})})]}):t.jsxs(_,{sx:{mt:2},children:[t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.secondary"},children:r("payment.checkout.customerInfo")}),t.jsx(Ee,{size:"small",variant:"text",onClick:()=>o(!0),sx:{minWidth:0,fontSize:13,fontWeight:600,p:0},children:r("common.edit")})]}),t.jsxs(D,{spacing:.5,sx:{p:2,backgroundColor:"background.paper",borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.values.customer_name&&t.jsx(g,{variant:"body2",sx:{color:"text.primary",fontWeight:600,fontSize:"0.9375rem"},children:e.values.customer_name}),e.values.customer_email&&t.jsx(g,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:e.values.customer_email}),e.fields.some(f=>f.name==="customer_phone")&&e.values.customer_phone&&t.jsx(g,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:e.values.customer_phone}),(e.values.billing_address?.country||e.values.billing_address?.state||e.values.billing_address?.postal_code)&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,children:[e.values.billing_address?.country&&t.jsx(_,{component:"span",sx:{fontSize:14,lineHeight:1},children:fr(e.values.billing_address.country)}),t.jsxs(g,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[e.values.billing_address?.state||"",e.values.billing_address?.postal_code?` [ ${r("payment.checkout.billing.postal_code")}: ${e.values.billing_address.postal_code} ]`:""]})]})]})]})}function Wi({mode:e,subscription:n,staking:r,appName:i}){const{t:s}=be();return!["subscription","setup"].includes(e)||!n?null:t.jsx(g,{sx:{mt:2.5,color:"text.secondary",fontSize:"0.7875rem",lineHeight:"0.9625rem"},children:n.confirmMessage||(n.showStake&&r?s("payment.checkout.confirm.withStake",{payee:i||"New Payment Kit"}):s("payment.checkout.confirm.withoutStake",{payee:i||"New Payment Kit"}))})}function Oi({status:e,context:n,onReset:r}){const{t:i}=be(),s=p.useRef(e);return p.useEffect(()=>{if(e!==s.current&&(s.current=e,e==="failed"&&n?.type==="error")){if(n.code==="CUSTOMER_LIMITED"||n.code==="STOP_ACCEPTING_ORDERS")return;Fe.error(n.message||"Payment failed"),r()}},[e,n,i,r]),null}function Xt({promotion:e,discounts:n,discountAmount:r,currency:i=null,initialShowInput:s=!1,isAmountLoading:o=!1}){const{t:a,locale:c}=be(),[l,u]=p.useState(!1),[f,d]=p.useState(""),[m,b]=p.useState(!1),[h,x]=p.useState(""),k=s||l,F=async()=>{if(!f.trim())return;b(!0),x("");const C=await e.apply(f.trim());C.success?(d(""),u(!1)):x(C.error||"Invalid code"),b(!1)},v=C=>{C.key==="Enter"&&!m&&f.trim()&&F()};return n?.length>0?t.jsx(_,{children:n.map((C,E)=>{const y=C.promotion_code_details?.code||C.verification_data?.code||C.promotion_code||"",I=C.coupon_details||{},N=I&&i?xr(I,i,c):"";return t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[t.jsxs(D,{direction:"row",alignItems:"center",spacing:.5,sx:{bgcolor:$=>$.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",px:1.5,py:.5,borderRadius:"8px",border:"1px solid",borderColor:$=>$.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8"},children:[t.jsx(en,{sx:{color:"#12b886",fontSize:14}}),t.jsx(g,{sx:{fontWeight:700,fontSize:13,color:"#12b886"},children:y}),N&&t.jsxs(g,{sx:{fontSize:12,color:"#12b886",fontWeight:500,opacity:.8},children:["· ",N]}),t.jsx(Ve,{size:"small",onClick:e.remove,sx:{width:18,height:18,ml:.25},children:t.jsx(on,{sx:{fontSize:12,color:"#12b886"}})})]}),o?t.jsx(Ne,{variant:"text",width:80,height:22}):t.jsxs(g,{sx:{color:"text.primary",fontWeight:600,fontSize:14},children:["-",r||"0"]})]},C.promotion_code||C.coupon||E)})}):e.active?t.jsx(_,{sx:{minHeight:36},children:k?t.jsxs(_,{onBlur:C=>{s||!C.currentTarget.contains(C.relatedTarget)&&!f.trim()&&u(!1)},children:[t.jsx(tn,{fullWidth:!0,size:"small",value:f,onChange:C=>d(C.target.value),onKeyPress:v,placeholder:a("payment.checkout.promotion.placeholder"),disabled:m,autoFocus:!0,slotProps:{input:{endAdornment:t.jsx(ht,{position:"end",children:t.jsx(Ee,{size:"small",onClick:F,disabled:!f.trim()||m,variant:"text",sx:{color:"primary.main",fontSize:13,textTransform:"none",minWidth:"auto",fontWeight:600},children:m?t.jsx(ft,{size:16}):a("payment.checkout.promotion.apply")})})}},sx:{"& .MuiOutlinedInput-root":{pr:1,borderRadius:"8px",height:36},"& .MuiOutlinedInput-input":{py:"6px",fontSize:13}}}),h&&t.jsx(Un,{severity:"error",sx:{mt:.5,py:0,fontSize:12,borderRadius:"6px"},children:h})]}):t.jsx(Ee,{onClick:()=>u(!0),startIcon:t.jsx(nn,{sx:{fontSize:18}}),variant:"text",sx:{fontWeight:600,fontSize:13,textTransform:"none",justifyContent:"flex-start",p:0,height:36,color:"primary.main","&:hover":{backgroundColor:"transparent",textDecoration:"underline"}},children:a("payment.checkout.promotion.add_code")})}):null}function Ui(){const{t:e,locale:n}=be(),{session:r,sessionData:i,subscription:s,refresh:o}=_e(),{isDonation:a}=vt(),c=vi(),l=jn(),u=et(),f=kn(),{session:d,connect:m,prefix:b}=un(),{inventoryOk:h}=St(),x=wi(),k=wt(),{isMobile:F}=Ze(),v=c.switching||k.hasDynamicPricing&&k.status==="loading",{currency:C,types:E,isStripe:y,isCrypto:I}=c,N=r?.mode||"payment",$=r?.discounts||[],P=!!d?.user,B=e(a?"payment.checkout.donate":`payment.checkout.${N}`),H=P?B:e("payment.checkout.connect",{action:B}),[K,V]=p.useState(!1),[Q,te]=p.useState(!1),[U,re]=p.useState(!1);p.useEffect(()=>{u.status==="failed"&&u.context?.code==="CUSTOMER_LIMITED"&&V(!0)},[u.status,u.context]);const Y=u.status==="idle"&&r?.status==="open"&&h,W=["submitting","waiting_did"].includes(u.status),oe=p.useCallback(()=>{if(Y){if(u.lock(),P||a){u.execute();return}d?.login?.(()=>{Promise.all([o(!0),l.refetchCustomer()]).then(()=>u.execute()).catch(j=>{console.error("Post-login refresh failed:",j)})})}},[Y,P,a,d,o,l,u]);p.useEffect(()=>{d?.user&&!u.status.startsWith("submitting")&&l.refetchCustomer()},[d?.user]);const J=E.find(j=>j.type==="crypto"),ne=p.useMemo(()=>c.available.filter(j=>j.type!=="stripe"),[c.available]),L=p.useMemo(()=>ne.length?ne.map(j=>({id:j.id,name:j.name,logo:j.logo||"",currencies:j.payment_currencies||[]})):[],[ne]),pe=c.current?.id||"";p.useEffect(()=>{const j=G=>{if(G.key==="Enter"&&Y&&u.status==="idle"){if(G.target?.tagName?.toLowerCase()==="textarea")return;oe()}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[Y,u.status,oe]);const he=p.useRef(!1),le=p.useRef(!1),T=p.useRef(u.status);p.useEffect(()=>{T.current=u.status},[u.status]),p.useEffect(()=>{if(u.status!=="waiting_did"){he.current=!1,le.current=!1;return}const j=u.context;if(j?.type!=="did_connect"||!m||he.current)return;he.current=!0;const G=`${b||window.location.origin}/api/did`.replace(/([^:])\/\//g,"$1/");m.open({locale:n,action:j.action,prefix:G,saveConnect:!1,extraParams:j.extraParams,onSuccess:async()=>{le.current=!0,m.close(),await u.didConnectComplete()},onClose:()=>{m.close(),T.current==="waiting_did"&&(le.current||u.reset())},onError:S=>{console.error("DID Connect error:",S),T.current==="waiting_did"&&u.reset()},messages:{title:e("payment.checkout.connectModal.title",{action:H}),scan:e("payment.checkout.connectModal.scan"),confirm:e("payment.checkout.connectModal.confirm")}})},[u.status,u.context,m,n,e,H]);const fe=E.find(j=>j.active)?.type||"crypto",me=E.length>1;return t.jsxs(_,{sx:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[t.jsxs(_,{sx:{flex:1,display:"flex",flexDirection:"column",overflowY:"auto",minHeight:0,"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:700,letterSpacing:"0.02em",color:"text.primary",mb:2.5},children:e("payment.checkout.paymentDetails")}),me&&t.jsx(Ln,{value:fe,exclusive:!0,onChange:(j,G)=>G&&c.setType(G),fullWidth:!0,size:"small",sx:{mb:2.5,bgcolor:j=>j.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.100",borderRadius:"10px",p:.5,"& .MuiToggleButton-root":{textTransform:"none",borderRadius:"8px !important",py:.75,border:"none",fontSize:14,fontWeight:500,gap:.75,color:"text.secondary"},"& .Mui-selected":{bgcolor:"background.paper !important",color:"text.primary",fontWeight:600,boxShadow:j=>j.palette.mode==="dark"?"0 1px 3px rgba(0,0,0,0.3)":"0 1px 3px rgba(0,0,0,0.08)","&:hover":{bgcolor:"background.paper !important"}}},children:E.map(j=>t.jsxs(qn,{value:j.type,children:[j.type==="stripe"?t.jsx(Bn,{sx:{fontSize:18}}):t.jsx(Hn,{sx:{fontSize:18}}),j.label||(j.type==="stripe"?"Card":"Crypto")]},j.type))}),I&&L.length>0&&t.jsxs(D,{direction:"row",spacing:1.5,sx:{mb:2.5},children:[L.length>1&&t.jsxs(_,{sx:{flex:1},children:[t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"text.secondary",mb:.5,letterSpacing:"0.02em"},children:e("common.network")}),t.jsx(nt,{value:pe,onChange:j=>{const G=L.find(S=>S.id===j.target.value);G?.currencies?.[0]&&c.setCurrency(G.currencies[0].id)},fullWidth:!0,size:"small",sx:{borderRadius:"8px",bgcolor:j=>j.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50","& .MuiOutlinedInput-notchedOutline":{borderColor:"transparent"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:1},"& .MuiSelect-select":{display:"flex",alignItems:"center",gap:1,py:1}},children:L.map(j=>t.jsxs(rt,{value:j.id,sx:{gap:1},children:[j.logo&&t.jsx(Ce,{src:j.logo,sx:{width:20,height:20}}),t.jsx(g,{sx:{fontSize:14},children:j.name})]},j.id))})]}),t.jsxs(_,{sx:{flex:1},children:[t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"text.secondary",mb:.5,letterSpacing:"0.02em"},children:e("common.currency")}),t.jsx(nt,{value:C?.id||"",onChange:j=>c.setCurrency(j.target.value),fullWidth:!0,size:"small",sx:{borderRadius:"8px",bgcolor:j=>j.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50","& .MuiOutlinedInput-notchedOutline":{borderColor:"transparent"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:1},"& .MuiSelect-select":{display:"flex",alignItems:"center",gap:1,py:1}},children:(I&&L.length>1?L.find(j=>j.id===pe)?.currencies||[]:J?.currencies||[]).map(j=>t.jsxs(rt,{value:j.id,sx:{gap:1},children:[j.logo&&t.jsx(Ce,{src:j.logo,sx:{width:20,height:20}}),t.jsx(g,{sx:{fontSize:14},children:j.symbol}),t.jsx(g,{sx:{fontSize:12,color:"text.secondary",ml:.5},children:j.name})]},j.id))})]})]}),y&&C&&t.jsxs(_,{sx:{mb:2.5},children:[t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"text.secondary",mb:.5,letterSpacing:"0.02em"},children:e("common.currency")}),t.jsx(nt,{value:C.id||"usd",readOnly:!0,fullWidth:!0,size:"small",IconComponent:()=>null,sx:{borderRadius:"8px",bgcolor:j=>j.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50","& .MuiOutlinedInput-notchedOutline":{borderColor:"transparent !important"},"& .MuiSelect-select":{display:"flex",alignItems:"center",gap:1,py:1}},children:t.jsxs(rt,{value:C.id||"usd",sx:{gap:1},children:[C.logo&&t.jsx(Ce,{src:C.logo,sx:{width:20,height:20}}),t.jsx(g,{sx:{fontSize:14,fontWeight:600},children:C.symbol}),t.jsx(g,{sx:{fontSize:12,color:"text.secondary",ml:.5},children:C.name})]})})]}),t.jsx($i,{form:l,isLoggedIn:P})]}),t.jsxs(_,{className:"cko-v2-submit-btn",sx:{flexShrink:0},children:[F&&f.staking&&t.jsxs(t.Fragment,{children:[t.jsxs(_,{onClick:()=>te(!Q),sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",mb:1},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.secondary"},children:e("payment.checkout.orderSummary")}),t.jsx(sn,{sx:{fontSize:18,color:"text.secondary",transition:"0.2s",transform:Q?"rotate(180deg)":"rotate(0deg)"}})]}),t.jsxs(mt,{in:Q,children:[t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[t.jsxs(D,{direction:"row",spacing:.5,alignItems:"center",children:[t.jsx(g,{sx:{fontSize:13,color:"text.secondary"},children:e("payment.checkout.staking.title")}),t.jsx(Tt,{sx:{fontSize:14,color:"text.disabled"}})]}),v?t.jsx(Ne,{variant:"text",width:60,height:18}):t.jsxs(g,{sx:{fontSize:13,fontWeight:600},children:["+",f.staking]})]}),t.jsx(lt,{sx:{mb:1}})]})]}),!F&&t.jsxs(t.Fragment,{children:[t.jsx(lt,{sx:{mb:2}}),f.staking&&t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[t.jsxs(D,{direction:"row",spacing:.5,alignItems:"center",children:[t.jsx(g,{sx:{fontSize:14,color:"text.secondary"},children:e("payment.checkout.staking.title")}),t.jsx(Vn,{title:e("payment.checkout.staking.tooltip"),placement:"top",arrow:!0,slotProps:{popper:{sx:hr}},children:t.jsx(Tt,{sx:{fontSize:16,color:"text.disabled"}})})]}),v?t.jsx(Ne,{variant:"text",width:80,height:22}):t.jsxs(g,{sx:{fontSize:14,fontWeight:600},children:["+",f.staking]})]}),t.jsx(Xt,{promotion:{applied:x.applied,code:x.code,active:x.active,inactiveReason:x.inactiveReason,apply:x.apply,remove:x.remove},discounts:$,discountAmount:f.discount,currency:C,isAmountLoading:v})]}),(()=>{const G=(f.total||"0").split(/\s+/),S=G[0]||"0",R=G.slice(1).join(" ")||C?.symbol||"",O=S.indexOf("."),ie=O>=0?S.slice(0,O):S,Z=O>=0?S.slice(O):"";return t.jsxs(_,{sx:{mb:F?1.5:2.5},children:[t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"flex-end",children:[t.jsx(g,{sx:{fontWeight:700,fontSize:14,color:"text.secondary",pb:.5},children:e("common.totalDue")}),v?t.jsx(Ne,{variant:"text",width:140,height:44}):t.jsxs(_,{sx:{textAlign:"right"},children:[t.jsx(g,{component:"span",sx:{fontSize:{xs:28,md:36},fontWeight:800,color:"text.primary",lineHeight:1,transition:"opacity 0.3s ease"},children:ie}),Z&&t.jsx(g,{component:"span",sx:{fontSize:{xs:16,md:20},fontWeight:700,color:"text.secondary",lineHeight:1},children:Z}),t.jsx(g,{component:"span",sx:{fontSize:{xs:14,md:16},fontWeight:600,color:"text.secondary",ml:.75},children:R})]})]}),(f.usdEquivalent||F&&x.active)&&!v&&t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mt:.25},children:[F&&!x.applied&&x.active?t.jsxs(_,{onClick:()=>re(!0),sx:{display:"flex",alignItems:"center",gap:.5,cursor:"pointer"},children:[t.jsx(At,{sx:{fontSize:14,color:"primary.main"}}),t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"primary.main"},children:xe(e,"payment.checkout.promotion.add","Add promo code")})]}):F&&x.applied?t.jsxs(D,{direction:"row",alignItems:"center",spacing:.5,children:[t.jsx(At,{sx:{fontSize:14,color:"success.main"}}),t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"success.main"},children:x.code}),f.discount&&t.jsxs(g,{sx:{fontSize:11,color:"text.secondary"},children:["(-",f.discount,")"]}),t.jsx(on,{onClick:x.remove,sx:{fontSize:14,color:"error.main",cursor:"pointer",ml:.25}})]}):t.jsx(_,{}),f.usdEquivalent&&t.jsxs(g,{sx:{fontSize:13,color:"text.secondary"},children:["≈ ",f.usdEquivalent]})]})]})})(),t.jsxs(Ee,{variant:"contained",size:"large",fullWidth:!0,disabled:!Y||u.status==="waiting_stripe",onClick:oe,startIcon:W?t.jsx(ft,{size:20,color:"inherit"}):null,sx:{py:1.5,fontSize:"1.1rem",fontWeight:600,textTransform:"none",borderRadius:"12px",color:j=>$e(j),position:"relative",overflow:"hidden","&:hover":{bgcolor:"primary.main"},"&:hover .arrow-icon":{transform:"translateX(4px)"},"&:hover .shine-layer":{transform:"translateX(100%)"}},children:[t.jsx(_,{component:"span",sx:{position:"relative",zIndex:1},children:W?`${e("payment.checkout.processing")}...`:H}),!W&&t.jsx(Qn,{className:"arrow-icon",sx:{ml:1,position:"relative",zIndex:1,transition:"transform 0.2s ease"}}),t.jsx(_,{className:"shine-layer",sx:{position:"absolute",inset:0,background:"linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent)",transform:"translateX(-100%)",transition:"transform 0.7s ease",pointerEvents:"none"}})]}),F&&t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"center",spacing:.75,sx:{mt:1.5,opacity:.55},children:[t.jsx(Dt,{sx:{fontSize:13,color:"text.secondary"}}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"payment.checkout.ssl","SSL Secure")}),t.jsx(g,{sx:{fontSize:11,color:"text.disabled"},children:"·"}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"common.terms","Terms")}),t.jsx(g,{sx:{fontSize:11,color:"text.disabled"},children:"|"}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"common.privacy","Privacy")})]})]}),F&&t.jsxs(Gn,{anchor:"bottom",open:U,onClose:()=>re(!1),PaperProps:{sx:{borderRadius:"16px 16px 0 0",p:3,pb:4,minHeight:"30vh"}},children:[t.jsx(_,{sx:{width:40,height:4,bgcolor:"divider",borderRadius:2,mx:"auto",mb:3}}),t.jsx(g,{sx:{fontWeight:700,fontSize:16,mb:2},children:xe(e,"payment.checkout.promotion.add","Add promo code")}),t.jsx(Xt,{initialShowInput:!0,promotion:{applied:x.applied,code:x.code,active:x.active,inactiveReason:x.inactiveReason,apply:async(...j)=>{const G=await x.apply(...j);return G.success&&re(!1),G},remove:x.remove},discounts:$,discountAmount:f.discount,currency:C})]}),t.jsxs(_,{sx:{flexShrink:0},children:[t.jsx(Wi,{mode:N,subscription:s,staking:f.staking,appName:gr(r?.line_items||[])}),!F&&t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"center",spacing:.75,sx:{mt:2.5,opacity:.55},children:[t.jsx(Dt,{sx:{fontSize:13,color:"text.secondary"}}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"payment.checkout.ssl","SSL Secure")}),t.jsx(g,{sx:{fontSize:11,color:"text.disabled"},children:"·"}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"common.terms","Terms")}),t.jsx(g,{sx:{fontSize:11,color:"text.disabled"},children:"|"}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"common.privacy","Privacy")})]})]}),t.jsx(Oi,{status:u.status,context:u.context,onReset:u.reset}),K&&t.jsx(yr,{customerId:i?.customer?.id||r?.user?.did,onPaid:()=>{V(!1),u.retry()},alertMessage:e("payment.customer.pastDue.alert.customMessage"),detailLinkOptions:{enabled:!0,onClick:()=>{V(!1),window.open(an(pn(),`/customer/invoice/past-due?referer=${encodeURIComponent(window.location.href)}`),"_self")}},dialogProps:{open:K,onClose:()=>{V(!1),u.reset()},title:e("payment.customer.pastDue.alert.title")}})]})}function Li(e){try{const r=new URLSearchParams(window.location.search).get("redirect");if(r)return decodeURIComponent(r)}catch{}if(e?.success_url)return e.success_url;if(e?.payment_link?.after_completion?.redirect?.url)return e.payment_link.after_completion.redirect.url}function qi(){const{t:e}=be(),{session:n}=_e(),{currency:r,stripe:i}=Ie(),s=et(),o=jn(),a=n?.mode||"payment",c=s.context?.type==="stripe"?s.context:null,l=s.status==="waiting_stripe"&&c?.clientSecret;return t.jsxs(t.Fragment,{children:[l&&t.jsx(br,{clientSecret:c.clientSecret,intentType:c.intentType||"payment_intent",publicKey:i?.publishableKey||"",mode:a,customer:{name:o.values.customer_name,email:o.values.customer_email,phone:o.values.customer_phone,address:o.values.billing_address},returnUrl:Li(n),onConfirm:s.stripeConfirm,onCancel:s.stripeCancel,onSkip:c.noPaymentRequired&&`${n?.metadata?.allow_skip_payment_method}`=="true"?s.stripeSkip:void 0}),s.status==="confirming_price"&&s.context?.type==="price_change"&&t.jsx(_r,{open:!0,changePercent:s.context.changePercent,onConfirm:s.confirm,onCancel:s.cancel,loading:!1}),s.status==="confirming_fast_pay"&&s.context?.type==="fast_pay"&&t.jsx(Mt,{onConfirm:s.confirm,onCancel:s.cancel,title:s.context.payType==="credit"?e("payment.checkout.fastPay.credit.title"):e("payment.checkout.fastPay.title"),message:s.context.payType==="credit"?t.jsx(g,{children:e("payment.checkout.fastPay.credit.meteringSubscriptionMessage",{available:`${He(s.context.amount||"0",r)} ${r?.symbol||""}`})}):t.jsxs(D,{children:[t.jsx(g,{children:e("payment.checkout.fastPay.autoPaymentReason")}),t.jsx(lt,{sx:{mt:1.5,mb:1.5}}),t.jsxs(D,{spacing:1,children:[t.jsxs(D,{sx:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[t.jsx(g,{sx:{color:"text.primary",whiteSpace:"nowrap"},children:e("payment.checkout.fastPay.payer")}),t.jsx(g,{sx:{color:"text.secondary",fontSize:14},children:s.context.payer?`${s.context.payer.slice(0,10)}...${s.context.payer.slice(-6)}`:""})]}),t.jsxs(D,{sx:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[t.jsx(g,{sx:{color:"text.primary"},children:e("payment.checkout.fastPay.amount")}),t.jsxs(g,{children:[He(s.context.amount||"0",r)," ",r?.symbol||""]})]})]})]}),loading:!1,color:"primary"}),s.context?.type==="service_suspended"&&t.jsx(Sr,{open:!0,onClose:s.cancel}),s.status==="credit_insufficient"&&s.context?.type==="credit_insufficient"&&t.jsx(Mt,{onConfirm:s.cancel,onCancel:s.cancel,title:e("payment.checkout.fastPay.credit.insufficientTitle"),message:t.jsx(g,{children:e("payment.checkout.fastPay.credit.insufficientMessage")}),confirm:e("common.confirm")})]})}function Bi(){return t.jsx(_,{sx:{display:"flex",gap:2,mt:4},children:[0,1,2].map(e=>t.jsx(_,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"primary.main",opacity:.4,animation:`pulse 1.4s ease-in-out ${e*.2}s infinite`,"@keyframes pulse":{"0%, 80%, 100%":{transform:"scale(0.6)",opacity:.3},"40%":{transform:"scale(1)",opacity:.7}}}},e))})}function Hi(){return t.jsxs(_,{sx:{position:"relative",width:{xs:160,md:200},height:{xs:160,md:200}},children:[t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:e=>`linear-gradient(45deg, ${ce(e.palette.primary.main,.1)}, ${ce(e.palette.primary.main,.03)})`,filter:"blur(1px)",animation:"spin 20s linear infinite","@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}}}),t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:e=>`linear-gradient(135deg, ${ce(e.palette.primary.main,.07)}, ${ce(e.palette.primary.main,.01)})`,filter:"blur(1px)",transform:"scale(0.88)",opacity:.6,animation:"spinReverse 15s linear infinite","@keyframes spinReverse":{from:{transform:"scale(0.88) rotate(0deg)"},to:{transform:"scale(0.88) rotate(-360deg)"}}}})]})}function In({mode:e="inline"}){const n=e==="standalone",i=We().palette.primary.main,s={background:{xs:"none",md:`linear-gradient(160deg, ${ce(i,.03)} 0%, ${ce(i,.07)} 50%, ${ce(i,.04)} 100%)`},bgcolor:a=>a.palette.mode==="dark"?"background.default":"#f8faff"},o=t.jsxs(_,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1},children:[t.jsx(Hi,{}),t.jsx(Bi,{})]});return n?t.jsxs(_,{sx:{width:"100%",height:"100vh",minHeight:"100vh",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",...s},children:[t.jsx(gt,{sx:{position:"absolute",top:20,left:0,right:0,zIndex:10,background:"transparent","& .header-container":{height:"auto"}},hideNavMenu:!0,brand:null,description:null,addons:a=>a.filter(c=>["locale-selector","theme-mode-toggle","session-user"].includes(c.key))}),o]}):t.jsx(_,{sx:{display:"flex",width:"100%",minHeight:{xs:400,md:640},maxWidth:1120,mx:"auto",borderRadius:"16px",overflow:"hidden",boxShadow:1,border:1,borderColor:"divider",borderLeft:"4px solid",borderLeftColor:"primary.main",...s},children:o})}function Vi(){const e=We(),n=ce(e.palette.primary.main,.06);return t.jsxs(_,{sx:{position:"relative",width:{xs:200,md:260},height:{xs:200,md:260},mb:{xs:4,md:6}},children:[t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:r=>`linear-gradient(45deg, ${ce(r.palette.primary.main,.1)}, ${ce(r.palette.primary.main,.03)})`,filter:"blur(1px)",animation:"spin 20s linear infinite","@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}}}),t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:r=>`linear-gradient(135deg, ${ce(r.palette.primary.main,.07)}, ${ce(r.palette.primary.main,.01)})`,filter:"blur(1px)",transform:"scale(0.88)",opacity:.6,animation:"spinReverse 15s linear infinite","@keyframes spinReverse":{from:{transform:"scale(0.88) rotate(0deg)"},to:{transform:"scale(0.88) rotate(-360deg)"}}}}),t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",overflow:"hidden",animation:"spin 20s linear infinite"},children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 260 260",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{position:"absolute",inset:0},children:[[52,87,122,157,192].map(r=>t.jsx("line",{x1:"30",y1:r,x2:"230",y2:r,stroke:n,strokeWidth:"0.5"},`h${r}`)),[52,87,122,157,192].map(r=>t.jsx("line",{x1:r,y1:"30",x2:r,y2:"230",stroke:n,strokeWidth:"0.5"},`v${r}`)),t.jsx("line",{x1:"52",y1:"52",x2:"192",y2:"192",stroke:n,strokeWidth:"0.5"}),t.jsx("line",{x1:"192",y1:"52",x2:"52",y2:"192",stroke:n,strokeWidth:"0.5"}),t.jsx("circle",{cx:"130",cy:"130",r:"40",stroke:n,strokeWidth:"0.5"}),t.jsx("circle",{cx:"130",cy:"130",r:"75",stroke:n,strokeWidth:"0.5"}),[[122,87],[157,87],[87,122],[122,122],[157,122],[192,122],[87,157],[122,157],[157,157],[122,192],[157,192]].map(([r,i])=>t.jsx("circle",{cx:r,cy:i,r:"1.5",fill:n},`d${r}-${i}`))]})})]})}function Qi(e,n,r){return e==="SESSION_EXPIRED"?{title:r("payment.checkout.expired.title"),description:r("payment.checkout.expired.description"),color:"#f59e0b"}:e==="EMPTY_LINE_ITEMS"?{title:r("payment.checkout.emptyItems.title"),description:r("payment.checkout.emptyItems.description"),color:"#94a3b8"}:e==="STOP_ACCEPTING_ORDERS"?{title:r("payment.checkout.stopAcceptingOrders.title"),description:r("payment.checkout.stopAcceptingOrders.description"),color:"#f59e0b"}:{title:r("payment.checkout.error.title"),description:n,color:"#ef4444"}}function Zt({error:e,errorCode:n=void 0}){const{t:r}=be(),i=We(),{title:s,description:o}=Qi(n,e,r),a=i.palette.primary.main,c=typeof window<"u"?window.blocklet?.appUrl:"/";return t.jsxs(D,{alignItems:"center",justifyContent:"center",sx:{flex:1,textAlign:"center",px:3},children:[t.jsx(Vi,{}),t.jsx(g,{component:"h1",sx:{fontWeight:800,fontSize:{xs:36,md:52},lineHeight:1.05,letterSpacing:"-0.03em",color:"text.primary",mb:2},children:s}),t.jsx(g,{sx:{color:"text.secondary",fontSize:{xs:15,md:17},fontWeight:300,lineHeight:1.7,maxWidth:420,letterSpacing:"0.01em"},children:o}),c&&t.jsx(Ee,{href:c,variant:"contained",disableElevation:!0,startIcon:t.jsx(Kn,{sx:{fontSize:"20px !important"}}),sx:{mt:5,minWidth:240,height:56,px:6,borderRadius:"9999px",textTransform:"none",fontWeight:600,fontSize:16,letterSpacing:"0.02em",color:l=>$e(l),boxShadow:`0 8px 32px -4px ${ce(a,.3)}`,"&:hover":{boxShadow:`0 12px 40px -4px ${ce(a,.4)}`,transform:"translateY(-1px)"},transition:"all 0.2s ease"},children:r("common.back")})]})}function Gi({error:e,errorCode:n=void 0,mode:r="inline"}){const s=We().palette.primary.main,o=r==="standalone",a={bgcolor:c=>c.palette.mode==="dark"?"background.default":"#f8faff",backgroundImage:c=>c.palette.mode==="dark"?"none":`radial-gradient(at 0% 0%, ${ce(s,.06)} 0px, transparent 50%),
|
|
2
|
-
radial-gradient(at 100% 0%, ${ce(s,.04)} 0px, transparent 50%),
|
|
3
|
-
radial-gradient(at 100% 100%, ${ce(s,.06)} 0px, transparent 50%),
|
|
4
|
-
radial-gradient(at 0% 100%, rgba(203,213,225,0.3) 0px, transparent 50%)`};return o?t.jsxs(_,{sx:{width:"100%",height:"100vh",minHeight:"100vh",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",...a},children:[t.jsx(gt,{sx:{position:"absolute",top:20,left:0,right:0,zIndex:10,background:"transparent","& .header-container":{height:"auto"}},hideNavMenu:!0,brand:null,description:null,addons:c=>c.filter(l=>["locale-selector","theme-mode-toggle","session-user"].includes(l.key))}),t.jsx(Zt,{error:e,errorCode:n})]}):t.jsx(_,{sx:{display:"flex",width:"100%",minHeight:{xs:400,md:520},maxWidth:1120,mx:"auto",borderRadius:"16px",overflow:"hidden",boxShadow:1,border:1,borderColor:"divider",...a},children:t.jsx(_,{sx:{flex:1,p:{xs:4,md:6},display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:t.jsx(Zt,{error:e,errorCode:n})})})}const Ge={};function Ki(e,n){return Ge[e]||(Ge[e]=dt.post(`/api/checkout-sessions/start/${e}?${mn(n)}`).then(r=>r?.data).finally(()=>{setTimeout(()=>{delete Ge[e]},3e3)})),Ge[e]}function Yi({onPaid:e=void 0,onError:n=void 0,mode:r="inline"}){const{isLoading:i,error:s,errorCode:o,session:a}=_e(),c=et(),{isMobile:l}=Ze();if(p.useEffect(()=>{s&&n&&n(new Error(s))},[s,n]),p.useEffect(()=>{c.status==="completed"&&c.result&&e&&e(c.result)},[c.status,c.result,e]),i)return t.jsx(In,{mode:r});if(s)return t.jsx(Gi,{error:s,errorCode:o,mode:r});const u=c.status==="completed",f=u&&l;return t.jsxs(t.Fragment,{children:[t.jsx(Ci,{left:f?null:t.jsx(_,{sx:{flex:1,display:"flex",flexDirection:"column",...u?{opacity:.45,pointerEvents:"none",filter:"grayscale(0.3)",transition:"all 0.5s ease"}:{}},children:t.jsx(zi,{})}),right:u?t.jsx(wr,{submit:c,session:a}):t.jsx(Ui,{}),mode:r}),!u&&t.jsx(qi,{})]})}function Xi({id:e,onPaid:n,onError:r,theme:i="default",mode:s="inline",extraParams:o={}}){if(!e.startsWith("plink_")&&!e.startsWith("cs_"))throw new Error("Either a checkoutSession or a paymentLink id is required.");const a=e.startsWith("plink_"),[c,l]=p.useState(a?null:e);if(ut(async()=>{if(!a)return null;const f=await Ki(e,o),d=f?.checkoutSession?.id;return d&&(l(d),s==="standalone"&&window.history.replaceState(null,"",an(pn(),`/checkout/pay/${d}?${mn(o)}`))),f},{ready:a}),!c)return t.jsx(In,{mode:s});const u=t.jsx(li,{sessionId:c,children:t.jsx(Yi,{onPaid:n,onError:r,mode:s})});return i==="inherit"?u:i&&typeof i=="object"?t.jsx(zt,{theme:i,children:u}):t.jsx(zt,{children:u})}function ns({id:e}){const[n]=vr(),r=n.get("redirect"),i=s=>{if(s?.checkoutSession?.success_url){setTimeout(()=>{const o=new URL(s.checkoutSession.success_url,window.location.origin);o.searchParams.set("checkout_session_id",s.checkoutSession.id),window.location.replace(o.href)},1e3);return}if(s?.paymentLink&&s.paymentLink.after_completion?.type==="redirect"&&s.paymentLink.after_completion?.redirect?.url){setTimeout(()=>{const o=new URL(s.paymentLink?.after_completion?.redirect?.url,window.location.origin);o.searchParams.set("checkout_session_id",s.checkoutSession.id),window.location.replace(o.href)},1e3);return}r&&setTimeout(()=>{window.location.replace(r)},1e3)};return t.jsx(Xi,{mode:"standalone",id:e,onPaid:i})}export{ns as default};
|