@arcblock/payment-service 1.29.8 → 1.29.9
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.d.ts +31 -0
- package/dist/cf.js +79 -60
- package/dist/index.js +163 -44
- package/package.json +4 -4
- package/web/assets/{account-DETfFe4_.js → account-Clbqiiw3.js} +1 -1
- package/web/assets/{action-B_DQJlip.js → action-DENqSeOa.js} +1 -1
- package/web/assets/{actions-BtaoyTWt.js → actions-0iWP2mcx.js} +1 -1
- package/web/assets/{actions-QPa-8lfB.js → actions-BD9BAp3M.js} +1 -1
- package/web/assets/{actions-jxGAdGfb.js → actions-BJDN6Op2.js} +1 -1
- package/web/assets/{actions-DJyfN5OU.js → actions-BSNy5bOd.js} +1 -1
- package/web/assets/{actions-Bt_jST94.js → actions-CDsj5j8l.js} +1 -1
- package/web/assets/{actions-D9MHLBFH.js → actions-CSpJGOX7.js} +1 -1
- package/web/assets/{actions-BknL4OyZ.js → actions-CZL47E9r.js} +1 -1
- package/web/assets/{actions-EPYeS5p4.js → actions-D3tJgrUn.js} +1 -1
- package/web/assets/{actions-BaDh4xWX.js → actions-DGQs8fFF.js} +1 -1
- package/web/assets/{add-price-CD-utowo.js → add-price-BpnICuHO.js} +1 -1
- package/web/assets/{admin-_nEB-lHn.js → admin-CD8ViZ7D.js} +1 -1
- package/web/assets/{assign-CkV5Q2LP.js → assign-0vMUDW_C.js} +1 -1
- package/web/assets/{attempts-DySeqBYU.js → attempts-CKlxkJuE.js} +1 -1
- package/web/assets/browser-DDv4_sgY.js +1 -0
- package/web/assets/{change-payment-CPUCUEER.js → change-payment-gAlRmJpv.js} +1 -1
- package/web/assets/{change-plan-CxE-XfWc.js → change-plan-C47wfWH8.js} +1 -1
- package/web/assets/{click-boundary-y8dVA_tr.js → click-boundary-CafubiPp.js} +1 -1
- package/web/assets/{connect-CC_l_f6Q.js → connect-BHHzrwLA.js} +1 -1
- package/web/assets/{copyable-DpX04wZz.js → copyable-QrCyyiou.js} +1 -1
- package/web/assets/{create-3SsWCAOC.js → create-0PUtkJZY.js} +1 -1
- package/web/assets/{create-BkQAaSvD.js → create-BJ1asdcy.js} +1 -1
- package/web/assets/{create-kG09X9gl.js → create-Bgv5ux17.js} +1 -1
- package/web/assets/{create-BmcRybZ5.js → create-C7GOgZZM.js} +1 -1
- package/web/assets/{create-tYebjhr9.js → create-DNar5UQD.js} +1 -1
- package/web/assets/{create-Bs65p5Ne.js → create-ke4FrPx1.js} +1 -1
- package/web/assets/{credit-grant-item-list-Bk27jIc7.js → credit-grant-item-list-CeDAM3qV.js} +1 -1
- package/web/assets/{credit-overview-DmMSEs14.js → credit-overview-4zh0H02x.js} +2 -2
- package/web/assets/{currency-restrictions-DYLv4YyW.js → currency-restrictions-BcEm8W45.js} +1 -1
- package/web/assets/{currency-select-DGS-62-L.js → currency-select-B4ieQBvv.js} +1 -1
- package/web/assets/{dayjs-B9tvQIKg.js → dayjs-DUTDpcNU.js} +1 -1
- package/web/assets/{description-Ym17DL48.js → description-SnR5WxWT.js} +1 -1
- package/web/assets/detail-46aLUdJj.js +1 -0
- package/web/assets/{detail-Cr2wG4Th.js → detail-B-ceWfZr.js} +1 -1
- package/web/assets/detail-B0IHl4MI.js +1 -0
- package/web/assets/detail-B8eOBVSQ.js +15 -0
- package/web/assets/{detail-DE3OOC5M.js → detail-BO3zglCn.js} +1 -1
- package/web/assets/{detail-DG4l2CqN.js → detail-BQpDGZJQ.js} +1 -1
- package/web/assets/{detail-CxYQYu_l.js → detail-BXTsnQny.js} +1 -1
- package/web/assets/{detail-CT9Unyrf.js → detail-B_lpOomD.js} +1 -1
- package/web/assets/{detail-Do9QO5L2.js → detail-Bfnkg0A1.js} +1 -1
- package/web/assets/detail-BwH0DwAi.js +1 -0
- package/web/assets/{detail-OZeeKI69.js → detail-C1FupF1D.js} +2 -2
- package/web/assets/{detail-cwHZbY62.js → detail-CMBRd4Ct.js} +1 -1
- package/web/assets/detail-C_Zdfa0y.js +1 -0
- package/web/assets/{detail-Cb9HBSMw.js → detail-Cg505nKX.js} +1 -1
- package/web/assets/{detail-DB56SG-k.js → detail-CsGZMimg.js} +1 -1
- package/web/assets/{detail-K9EVY3r2.js → detail-Ct5QNBqu.js} +1 -1
- package/web/assets/{detail-DuO_Jn5X.js → detail-CyMhK5K_.js} +1 -1
- package/web/assets/{detail-DuWdZIyp.js → detail-DACnmls3.js} +1 -1
- package/web/assets/{detail-BJTcK7mx.js → detail-DCTb8R7F.js} +1 -1
- package/web/assets/{detail-DPCTQLOx.js → detail-DNcp_u5S.js} +1 -1
- package/web/assets/detail-DbU3p040.js +1 -0
- package/web/assets/{detail-D5KRrQDx.js → detail-Tn2R5C8i.js} +1 -1
- package/web/assets/{detail-15zxCbV9.js → detail-wU4wNf4s.js} +1 -1
- package/web/assets/{drawer-form-Cl0T1Yyt.js → drawer-form-DspWWj3x.js} +1 -1
- package/web/assets/{edit-3HUAnaXW.js → edit-Bkj-OTJh.js} +1 -1
- package/web/assets/{editor-BF5I0siU.js → editor-AmthipP2.js} +1 -1
- package/web/assets/{embed-CsNqeCd0.js → embed-rRKjDoHi.js} +1 -1
- package/web/assets/{filter-toolbar-BydfQ-79.js → filter-toolbar-DXGSTq57.js} +1 -1
- package/web/assets/{form-DSzMo9UD.js → form-B5WW-lS5.js} +1 -1
- package/web/assets/form-BmQlJZ84.js +9 -0
- package/web/assets/{form-BGm5NPDn.js → form-CAPjlw7l.js} +1 -1
- package/web/assets/{form-CKfKLGXP.js → form-DD-EiA7W.js} +3 -3
- package/web/assets/{form-P4luyUpY.js → form-cX026J4G.js} +1 -1
- package/web/assets/{gas-Qf0SSUfS.js → gas-nyR96dB0.js} +1 -1
- package/web/assets/{generateCategoricalChart-BaWwaXky.js → generateCategoricalChart-BadryV3H.js} +1 -1
- package/web/assets/{home-HbrLyxJL.js → home-_eX1aim8.js} +1 -1
- package/web/assets/index-BBHMsIxJ.js +1 -0
- package/web/assets/{index-Dr_MwbKt.js → index-BQjlhCSt.js} +1 -1
- package/web/assets/{index-DPodCQ9c.js → index-BRENdB5m.js} +1 -1
- package/web/assets/{index-9xBRL_33.js → index-BTfJ08JU.js} +1 -1
- package/web/assets/{index-DgSc1Qy8.js → index-BarN7DfU.js} +17 -17
- package/web/assets/index-BhcoukR2.js +1 -0
- package/web/assets/index-BturOfxo.js +1 -0
- package/web/assets/{index-SYTpMMMH.js → index-BzABukCz.js} +1 -1
- package/web/assets/{index-2l22EYw9.js → index-C-RT84yb.js} +1 -1
- package/web/assets/{index-C0JaS08f.js → index-C136x0O2.js} +1 -1
- package/web/assets/{index-Cw0ugaQL.js → index-CCVDDX0c.js} +1 -1
- package/web/assets/index-CDVogp6E.js +1 -0
- package/web/assets/{index-Br7_mvEw.js → index-CW8VfoJO.js} +1 -1
- package/web/assets/{index-BIoSdRvX.js → index-CbSXdD6E.js} +3 -3
- package/web/assets/{index-CdkYrABk.js → index-Cd_BD9TM.js} +1 -1
- package/web/assets/index-D-bx9Kam.js +1 -0
- package/web/assets/index-D0mynT6_.js +1 -0
- package/web/assets/index-DEiuhiEo.js +14 -0
- package/web/assets/{index-DE2KzqXl.js → index-DNGmCIRP.js} +1 -1
- package/web/assets/{index-CI_EY4YS.js → index-DSe7Dot_.js} +1 -1
- package/web/assets/{index-BFML4-2u.js → index-DcddP3R9.js} +1 -1
- package/web/assets/index-DcrGSDby.js +1 -0
- package/web/assets/{index-fByZjxLy.js → index-DeK5Pqjv.js} +1 -1
- package/web/assets/{index-Clbt8nRm.js → index-DoX0A-rP.js} +1 -1
- package/web/assets/index-Du0Ieh1F.js +49 -0
- package/web/assets/index-Dybqd298.js +1 -0
- package/web/assets/index-EXZPddtw.js +1 -0
- package/web/assets/{index-Drav4oDH.js → index-Kd_qCyRG.js} +2 -2
- package/web/assets/{index-Dc954mDP.js → index-SOzRg0yJ.js} +1 -1
- package/web/assets/{index-BMKZToMM.js → index-UYeD8rTJ.js} +2 -2
- package/web/assets/{index-DZpJPE1Z.js → index-W2uZUlFs.js} +1 -1
- package/web/assets/{index-1y9kjPIr.js → index-XaFn2ySq.js} +1 -1
- package/web/assets/{index-fswPX_qe.js → index-YG5oc8O3.js} +1 -1
- package/web/assets/{index-B1pTTyGZ.js → index-ajD9Iotk.js} +1 -1
- package/web/assets/index-brUCsnBA.js +1 -0
- package/web/assets/{index-BP53rZV9.js → index-mn5Zdrtn.js} +1 -1
- package/web/assets/index-qulrJQ4J.js +1 -0
- package/web/assets/{index.es-BWnfUzLb.js → index.es-C8dcCHdW.js} +1 -1
- package/web/assets/{info-card-C1yxhxJG.js → info-card-BvIMFQo5.js} +1 -1
- package/web/assets/{info-metric-CNse3r66.js → info-metric-Dl4ZDm0Z.js} +1 -1
- package/web/assets/{info-row-group-BeUhWnnY.js → info-row-group-CFuMWJf1.js} +1 -1
- package/web/assets/{info-row-DOK2whMn.js → info-row-jI0h_hv4.js} +1 -1
- package/web/assets/{libphonenumber-CyphiuxQ.js → libphonenumber-Qs8PCdM-.js} +1 -1
- package/web/assets/{link-3eeclTeS.js → link-CmPoIweR.js} +1 -1
- package/web/assets/{list-DnePqZ2K.js → list-BdSkPjIa.js} +1 -1
- package/web/assets/{list-jHj_5yy3.js → list-CWMEf-_C.js} +1 -1
- package/web/assets/{list-C521zE_7.js → list-CkHExntK.js} +1 -1
- package/web/assets/{list-CO0X4L3-.js → list-DLB_hd0Q.js} +1 -1
- package/web/assets/{list-D-I0msRW.js → list-DVFJwd_I.js} +2 -2
- package/web/assets/{list-D1aevUOI.js → list-DaK9287Y.js} +2 -2
- package/web/assets/{list-1OG83xc4.js → list-DghnUOc4.js} +1 -1
- package/web/assets/{list-CNmzJKIQ.js → list-eFkvVlp5.js} +1 -1
- package/web/assets/metadata-BmQTVFku.js +55 -0
- package/web/assets/{meter-event-lmNMgmIu.js → meter-event-B1JIhVpb.js} +1 -1
- package/web/assets/{metrics-C7U41HWk.js → metrics-UvxyQbUF.js} +1 -1
- package/web/assets/{overview-Cs3-8n4e.js → overview-Cxc6WKba.js} +1 -1
- package/web/assets/{overview-CH1HnSP-.js → overview-DrMaIptb.js} +1 -1
- package/web/assets/{past-due-CGGRZmXY.js → past-due-CUXkxns0.js} +1 -1
- package/web/assets/pay-omLYkqRA.js +4 -0
- package/web/assets/{payment-method-info-BsOBbA3m.js → payment-method-info-Bsf89VxV.js} +2 -2
- package/web/assets/{preview-DjYRpRA8.js → preview-BifsgUGT.js} +1 -1
- package/web/assets/{preview-CjYh9dTg.js → preview-C-H8pGVw.js} +1 -1
- package/web/assets/{pricing-table-C3Lkhq46.js → pricing-table-B3QOaAB5.js} +2 -2
- package/web/assets/{pricing-table-edE6TJGX.js → pricing-table-BUJdtkMq.js} +1 -1
- package/web/assets/{product-select-0ScZE2e8.js → product-select-ChEyoJqJ.js} +1 -1
- package/web/assets/{recharge-DcPtT8vt.js → recharge-BVT4USAO.js} +1 -1
- package/web/assets/{related-credit-grants-BygNGPfb.js → related-credit-grants-JV2ICsR5.js} +22 -22
- package/web/assets/{safe-did-address-B0fFbUph.js → safe-did-address-CiG_V6Gy.js} +1 -1
- package/web/assets/{source-data-viewer-By_Utay-.js → source-data-viewer-i1q9wNIG.js} +1 -1
- package/web/assets/{status-l6pD08fw.js → status-CUVYrUIG.js} +1 -1
- package/web/assets/subscription-BYz_k9dq.js +1 -0
- package/web/assets/{subscription-Dq22e3D1.js → subscription-DrnSPIfs.js} +1 -1
- package/web/assets/table-BrtHemkA.js +1 -0
- package/web/assets/{tax-code-select-CWhIIiXi.js → tax-code-select-TS07I0rB.js} +1 -1
- package/web/assets/{tax-utils-DqNX34-r.js → tax-utils-bPjALcVG.js} +1 -1
- package/web/assets/{uploader-DRXDz_r0.js → uploader-CsQNHG4I.js} +1 -1
- package/web/assets/{usage-records-jjJMZ6DI.js → usage-records-DAUQMJAW.js} +1 -1
- package/web/assets/{util-mDHAL0lx.js → util-DxXTXkeY.js} +1 -1
- package/web/assets/{vendor-arcblock-ChFCRdyx.js → vendor-arcblock-BTCAQSUK.js} +1 -1
- package/web/assets/{vendor-blocklet-D_i_QeSo.js → vendor-blocklet-DcLR2Cyf.js} +43 -43
- package/web/index.html +1 -1
- package/web/assets/browser-DSLTxXlL.js +0 -1
- package/web/assets/detail-ASPdMJoW.js +0 -1
- package/web/assets/detail-CIx9vkir.js +0 -1
- package/web/assets/detail-D5NbV29V.js +0 -1
- package/web/assets/detail-DVVzYhdV.js +0 -1
- package/web/assets/detail-Dqc0OfCQ.js +0 -1
- package/web/assets/detail-uhlID8jD.js +0 -15
- package/web/assets/form-BXAuSawq.js +0 -9
- package/web/assets/index-0HK7CYm4.js +0 -1
- package/web/assets/index-BJ_E6bEO.js +0 -1
- package/web/assets/index-Bnyh4rlV.js +0 -1
- package/web/assets/index-BoQ7wf3O.js +0 -1
- package/web/assets/index-C68x-aau.js +0 -1
- package/web/assets/index-C8s2QKoe.js +0 -1
- package/web/assets/index-Cn7O-OP7.js +0 -49
- package/web/assets/index-DU39aG5u.js +0 -1
- package/web/assets/index-DtbqgSK4.js +0 -1
- package/web/assets/index-DuRu9NWB.js +0 -14
- package/web/assets/index-WMKOiUez.js +0 -1
- package/web/assets/index-dmHgoplS.js +0 -1
- package/web/assets/index-txVTkoDD.js +0 -1
- package/web/assets/metadata-CMSHcSXi.js +0 -55
- package/web/assets/pay-CSpHBUh_.js +0 -4
- package/web/assets/subscription-DcwhSOpa.js +0 -1
- package/web/assets/table-BRU4Enia.js +0 -1
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as p,j as t,u as We,B as b,ah as ce,p as An,a7 as Ge,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 Kn,bC as Gn}from"./vendor-mui-BXZut9Pz.js";import{a2 as L,aM as Yn,y as Xn,S as Zn,F as z,G as Te,K as Xe,aa as gt,Y as Fe,V as be,O as ut,U as Jn,E as an}from"./vendor-blocklet-D_i_QeSo.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 vr}from"./index-DgSc1Qy8.js";import{b as wr}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),m=e?.startsWith("plink_"),d=L(async()=>{if(!m)return e;if(u.current)return u.current;const{data:w}=await ee.post(X.START_PAYMENT_LINK(e)),C=w?.checkoutSession?.id;if(!C)throw new Error("Failed to start payment link session");return u.current=C,C}),f=L(async(w=!1)=>{if(c.current&&c.current.abort(),c.current=new AbortController,!e){r(!1),s("Session ID is required");return}try{w||r(!0),s(null);const C=await d(),E=w?`${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)}}),_=p.useCallback(async(w=!1)=>{await f(w)},[f]);p.useEffect(()=>(l.current=!0,f(),()=>{l.current=!1,c.current&&c.current.abort()}),[e]);const h=o?.checkoutSession,x=u.current||(m?"":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((w,C)=>w+(C?.price?.product?.vendor_config?.length||0),0)||0;return{isLoading:n,error:i,errorCode:k,refresh:_,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),m=p.useRef(null);p.useEffect(()=>{o&&!a&&c(Ft(o,s))},[o?.id]);const{method:d,currency:f}=p.useMemo(()=>$t(s,a),[s,a]),_=p.useMemo(()=>Er(s),[s]),h=d?.type==="stripe",x=d?.type!=="stripe"&&d?.type!==void 0,k=f?.type==="credit",F=p.useMemo(()=>Pr(s,d),[s,d]),w=L(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=L(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||m.current===o.id)return;m.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:f,available:s,currencies:_,isStripe:h,isCrypto:x,isCredit:k,switching:l,setType:w,types:F,setCurrency:C,stripe:E}}const ve=/^\d{4}$/,we=/^\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:we,JP:/^\d{3}-?\d{4}$/,FR:/^\d{2}[ ]?\d{3}$/,AU:ve,IT:we,CH:ve,AT:ve,ES:we,NL:/^\d{4}[ ]?[A-Z]{2}$/i,BE:ve,DK:ve,SE:/^\d{3}[ ]?\d{2}$/,NO:ve,BR:/^\d{5}-?\d{3}$/,PT:/^\d{4}(-\d{3})?$/,FI:we,KR:we,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:ve,RO:Me,BG:ve,HR:we,SK:/^\d{3}[ ]?\d{2}$/,SI:ve,TR:we,IL:we,ZA:ve,MX:we,AR:/^([A-HJ-NP-Z])?\d{4}([A-Z]{3})?$/i,CL:/^\d{7}$/,CO:Me,NZ:ve,MY:we,TH:we,PH:ve,ID:we,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-CyphiuxQ.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,m=u?.postal_code,d=u?.country,f=u?.state,_=u?.line1,h=u?.city;if(!m)r["billing_address.postal_code"]="Required";else if(!Dr(m,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(m)&&(r["billing_address.postal_code"]=x.pattern.message)}if(!f)r["billing_address.state"]="Required";else{const x=Pe("billing_address.state",o,a);x.pattern&&!x.pattern.value.test(f)&&(r["billing_address.state"]=x.pattern.message)}if(s==="required"){if(d||(r["billing_address.country"]="Required"),!_)r["billing_address.line1"]="Required";else{const x=Pe("billing_address.line1",o,a);x.pattern&&!x.pattern.value.test(_)&&(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({}),[m,d]=p.useState({}),[f,_]=p.useState(!1);p.useEffect(()=>{i&&!f&&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||f||i.status==="complete")return;(async()=>{try{const{data:y}=await ee.get(`${X.CUSTOMER_ME}?fallback=1&skipSummary=1`);y&&(_(!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{}})()},[i?.id]);const h=L((E,y)=>{c(I=>xn(I,E,y)),d(I=>({...I,[E]:!0}))}),x=L(()=>({phoneEnabled:!!i?.phone_number_collection?.enabled,addressMode:i?.billing_address_collection,fieldValidation:i?.metadata?.page_info?.field_validation})),k=L(async()=>{const E=await st(a,x());return u(E.errors),E.valid}),F=L(async()=>(await st(a,x())).valid),w=L(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=L(async()=>{try{const{data:E}=await ee.get(`${X.CUSTOMER_ME}?fallback=1&skipSummary=1`);E&&(_(!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{}});return{fields:o,values:a,onChange:h,errors:l,touched:m,validate:k,checkValid:F,validateField:w,prefetched:f,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 Kr(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 Gr(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 m=e?.checkoutSession,[d,f]=p.useState("idle"),[_,h]=p.useState(null),[x,k]=p.useState(null),[F,w]=p.useState(!1),C=L(()=>w(!0)),E=L(()=>w(!1)),y=p.useRef(!0),I=p.useRef(!1),N=p.useRef(null),$=p.useRef(null),R=p.useRef(null),[B,H]=p.useState(null),G=p.useRef(null),V=p.useRef(0),Q=2,te=p.useRef(""),O=p.useRef(""),oe=p.useRef(!1);p.useEffect(()=>{if(oe.current||!m||!e)return;m.status==="complete"&&["paid","no_payment_required"].includes(m.payment_status)&&d==="idle"&&(oe.current=!0,k(e),f("completed"))},[m,e]),p.useEffect(()=>{if(y.current=!0,!n||!gn())return;const v=new Zn(`${Vr()}//${Qr()}${Hr}`,{longpollerTimeout:5e3,heartbeatIntervalMs:30*1e3});v.connect(),N.current=v;const T=v.subscribe(Ot("events"));return T.channel="events",$.current=T,()=>{y.current=!1,I.current=!0,$.current&&(v.unsubscribe(Ot($.current.channel)),$.current=null),v.disconnect(),N.current=null}},[n]);const Y=L(async({response:v})=>{v.id===n&&d!=="completed"&&(I.current=!0,await W())});p.useEffect(()=>{const v=$.current;return v&&v.on("checkout.session.completed",Y),()=>{if(v)try{v.off?.("checkout.session.completed",Y)}catch{}}},[$.current,d]);const W=L(async()=>{try{const v=await qr(n);if(!y.current)return;k(v),u?.(v),f("completed"),h(null)}catch(v){if(!y.current)return;f("failed"),h({type:"error",message:je(v)||"Payment verification failed"})}});p.useEffect(()=>{if(d!=="completed"||!n||!m?.line_items?.some(re=>!!re?.price?.product?.vendor_config?.length))return;const T=Date.now(),q=async()=>{try{const{data:re}=await ee.get(X.VENDOR_ORDER_STATUS(n));if(!y.current)return;const Z=Array.isArray(re?.vendors)?re.vendors:[],ge=Date.now()-T>6e3,ke=Z.every(M=>M.progress>=100),S=Z.some(M=>M.status==="failed"||ge&&!!M.error&&!!M.error_message);if(H({...re,vendors:Z,isAllCompleted:!S&&ke,hasFailed:S}),S||ke)return;G.current=setTimeout(q,5e3)}catch{}};return q(),()=>{G.current&&clearTimeout(G.current)}},[d,n]);const se=L(async(v,T)=>{try{if(await l(!0),!y.current)return}catch{}if(v==="QUOTE_UPDATED"&&T?.checkoutSession){V.current=0,f("failed"),h({type:"error",message:"Price updated, please resubmit",code:v});return}if(["QUOTE_LOCK_EXPIRED","QUOTE_EXPIRED_OR_USED","QUOTE_NOT_FOUND","QUOTE_REQUIRED"].includes(v)&&V.current<Q){V.current+=1,f("idle"),h(null),await U(!0);return}V.current=0,f("failed"),h({type:"error",message:"Price updated, please resubmit",code:v})}),J=L(async v=>{if(i){const Z=v.stripeContext;if(Z?.status==="succeeded"){await W();return}const ge=v.paymentIntent,ke=Z?.client_secret||ge?.client_secret;if(ke){const S=Z?.intent_type||"payment_intent";f("waiting_stripe"),h({type:"stripe",clientSecret:ke,intentType:S,noPaymentRequired:!!v.noPaymentRequired});return}if(v.noPaymentRequired)try{const S=await ot(n),M=S.checkoutSession;if(S.fastPaid||M?.status==="complete"){await W();return}}catch{}await W();return}if(v.noPaymentRequired){try{const Z=await ot(n),ge=Z.checkoutSession;Z.fastPaid||ge?.status==="complete"?await W():(f("waiting_did"),h({type:"did_connect",action:m?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:m?.user?.did}}))}catch{if(!y.current)return;f("waiting_did"),h({type:"did_connect",action:m?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:m?.user?.did}})}return}const T=v.fastPayInfo,q=v.balance,re=v.delegation;if(s){if(v.creditSufficient===!0&&T){f("confirming_fast_pay"),h({type:"fast_pay",payType:"credit",amount:T.amount||"0",payer:T.payer||""});return}f("credit_insufficient"),h({type:"credit_insufficient",available:"0",required:"0"});return}if((q?.sufficient||re?.sufficient)&&!o&&T){f("confirming_fast_pay"),h({type:"fast_pay",payType:T.type||"balance",amount:T.amount||"",payer:T.payer||""});return}f("waiting_did"),h({type:"did_connect",action:m?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:m?.user?.did}})}),ne=L(async v=>{const{code:T,data:q,message:re}=pt(v);if(T&&Lt(T)){await se(T,q);return}if(T==="RATE_BELOW_SLIPPAGE_LIMIT"){try{await l(!0)}catch{}if(!y.current)return;te.current="",O.current="",f("failed"),h({type:"error",message:q?.error||"Exchange rate below acceptable limit, please retry",code:T});return}if(T==="RATE_UNAVAILABLE"){try{await l(!0)}catch{}if(!y.current)return;f("failed"),h({type:"error",message:q?.rateError||"Exchange rate unavailable",code:T});return}if(T==="PRICE_CHANGED"){f("confirming_price"),h({type:"price_change",changePercent:q?.change_percent||0});return}if(T==="PRICE_UNAVAILABLE"||T==="PRICE_UNSTABLE"){try{await l(!0)}catch{}if(!y.current)return;f("failed"),h({type:"error",message:q?.error||"Price unavailable, please retry",code:T});return}if(T==="STOP_ACCEPTING_ORDERS"){f("service_suspended"),h({type:"service_suspended"});return}if(T==="UNIFIED_APP_REQUIRED"||T==="CUSTOMER_LIMITED"){f("failed"),h({type:"error",message:q?.error||re||"Cannot complete payment",code:T});return}const Z=q?.error||re||"Payment failed";f("failed"),h({type:"error",message:Z,code:T})}),U=L(async(v=!1)=>{if(!v&&d!=="idle")return;if(v||(V.current=0),!await c()){f("failed"),h({type:"error",message:"Please complete the required fields",code:"VALIDATION_FAILED"});return}if(!m?.user?.sourceAppPid&&m?.line_items?.some(ge=>!!ge?.price?.product?.vendor_config?.length)){f("failed"),h({type:"error",message:"Vendor account required",code:"VENDOR_ACCOUNT_REQUIRED"});return}f("submitting"),h(null),k(null),I.current=!1;const q=Kr(m,r);(q!==O.current||!te.current)&&(O.current=q,te.current=hn(n,r||""));const re=Ut(n,r,a,m,!1,te.current);R.current=re;try{const Z=await qt(n,o,re);if(!y.current)return;await J(Z)}catch(Z){if(!y.current)return;await ne(Z)}}),pe=L(async()=>{if(d==="confirming_fast_pay"){f("submitting");try{const v=await ot(n);if(!y.current)return;v.fastPaid?await W():(f("waiting_did"),h({type:"did_connect",action:m?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:m?.user?.did}}))}catch(v){if(!y.current)return;const{code:T,data:q,message:re}=pt(v);if(T&&Lt(T)){await se(T,q);return}if(T==="RATE_UNAVAILABLE"){try{await l(!0)}catch{}if(!y.current)return;f("failed"),h({type:"error",message:q?.rateError||"Exchange rate unavailable",code:T});return}f("failed"),h({type:"error",message:q?.error||re||"Fast pay confirmation failed",code:T})}return}if(d==="confirming_price"){f("submitting"),h(null),I.current=!1;const v=Ut(n,r,a,m,!0,te.current);R.current=v;try{const T=await qt(n,o,v);if(!y.current)return;await J(T)}catch(T){if(!y.current)return;await ne(T)}}}),he=L(()=>{(d==="confirming_price"||d==="confirming_fast_pay"||d==="credit_insufficient"||d==="service_suspended")&&(f("idle"),h(null),E())}),le=L(async()=>{d==="failed"&&(f("idle"),h(null),k(null),await U(!0))}),P=L(()=>{I.current=!0,f("idle"),h(null),k(null),E()}),fe=L(async()=>{d==="waiting_stripe"&&(f("submitting"),h(null),await W())}),me=L(async()=>{d==="waiting_stripe"&&(await Gr(n),f("idle"),h(null))}),j=L(async()=>{if(d==="waiting_stripe")try{f("submitting");const v=await Yr(n);if(!y.current)return;v.skipped||v.checkoutSession?.status==="complete"?await W():(f("failed"),h({type:"error",message:"Failed to skip payment method",code:"SKIP_FAILED"}))}catch(v){if(!y.current)return;f("failed"),h({type:"error",message:v.message||"Failed to skip payment method",code:"SKIP_FAILED"})}}),K=L(async()=>{d==="submitting"||d==="completed"||(I.current=!1,f("submitting"),h(null),await W())});return{status:d,context:_,execute:U,confirm:pe,cancel:he,result:x,retry:le,reset:P,stripeConfirm:fe,stripeCancel:me,stripeSkip:j,didConnectComplete:K,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 m=await De(s,e,i);m&&(u=m)}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 m=await De(i,e,s);m&&(u=m)}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 m=await De(i,e,s);m&&(u=m)}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:m,subscription:d,pageInfo:f}=Ir(e),_=c?.checkoutSession,h=l||e,x=p.useMemo(()=>_?.line_items||[],[_?.line_items]),k=_?.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:_||null,isDonation:k,vendorCount:u,product:m,subscription:d,pageInfo:f}),[c,a,e,h,r,i,s,o,x,_,k,u,m,d,f]),w=Tr(c,h,o,a),C=p.useRef(null);p.useEffect(()=>{const U=w.currency?.id||null;!U||!_||_.status==="complete"||(C.current===null||U!==C.current)&&(C.current=U,De(_,h,U).then(pe=>{pe&&o(!0)}))},[w.currency?.id,_?.id]);const E=p.useMemo(()=>({current:w.current,currency:w.currency,available:w.available,currencies:w.currencies,isStripe:w.isStripe,isCrypto:w.isCrypto,isCredit:w.isCredit,switching:w.switching,setType:w.setType,types:w.types,setCurrency:w.setCurrency,stripe:w.stripe}),[w.current,w.currency,w.available,w.currencies,w.isStripe,w.isCrypto,w.isCredit,w.switching,w.setType,w.types,w.setCurrency,w.stripe]),[y,I]=p.useState(null),[N,$]=p.useState(null),[R,B]=p.useState(null),[H,G]=p.useState(null),[V,Q]=p.useState("loading"),te=p.useRef(null),O=p.useRef(!1),oe=p.useRef(!0),Y=p.useMemo(()=>ei(x),[x]),W=L(async()=>{if(!h||!Y||w.isStripe||w.switching){Q(Y?"unavailable":"available"),w.isStripe&&(I(null),$(null),B(null),G(null));return}if(!O.current){O.current=!0;try{Q("loading");const U=await ti(h,w.currency?.id);if(!oe.current)return;U.rate?(I(U.rate),$(U.provider),B(U.providerDisplay),G(U.fetchedAt),Q("available")):Q("unavailable")}catch{if(!oe.current)return;Q("unavailable")}finally{O.current=!1}}});p.useEffect(()=>{if(oe.current=!0,!Y||w.isStripe||w.switching||!h||_?.status==="complete"){w.isStripe&&(I(null),$(null),B(null),G(null)),w.switching||(_?.status==="complete"?Q("available"):Q(Y?"unavailable":"available"));return}W(),te.current=setInterval(W,Jr);const U=()=>{document.hidden||W()};return document.addEventListener("visibilitychange",U),()=>{oe.current=!1,te.current&&clearInterval(te.current),document.removeEventListener("visibilitychange",U)}},[Y,w.isStripe,w.switching,h,w.currency?.id,_?.status]);const se=p.useMemo(()=>({rate:y,provider:N,providerDisplay:R,fetchedAt:H,status:V,hasDynamicPricing:Y,refresh:W}),[y,N,R,H,V,Y,W]),J=Wr(c,w.currency?.id||null,w.current?.id||null),ne=Zr(c,h,w.currency?.id||null,w.isStripe,w.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:se,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 f=Number(s.base_amount);if(f>0&&Number.isFinite(f)){const _=f/d,h=Xe(_.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 f=n.decimal||2,_=Xe(d.toFixed(f),f);return{unitAmount:_,totalAmount:_.mul(o),isDynamicQuote:!1}}}const m=new z(bt(s,n));return{unitAmount:m,totalAmount:m.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 m;l.custom_amount&&u&&u===n.id?m=new z(l.custom_amount):{totalAmount:m}=mi(l,n,{useUpsell:i,exchangeRate:s});const d=i&&l.upsell_price||l.price;return d?.type==="recurring"&&(o=o.add(m),r||d.recurring?.usage_type==="metered")?c:c.add(m)},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(f=>!(f.discountable===!1||(f.upsell_price||f.price)?.recurring?.usage_type==="metered")),m=_t(u,n,o,!0,{exchangeRate:i?s:null}),d=new z(m.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 f=l.currency_options?.[n.id]?.amount_off||l.amount_off;if(f&&f!=="0"){const _=new z(f);return _.lt(d)?_: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}),m=new z(u.total),d=_n(e,n,r,s,i,l,!1),f=d.gt(new z(0))?ze(Te(d.toString(),n.decimal),s):null,_=r?.total_details?.amount_tax,h=new z(_||"0"),x=r?.total_details,k=_&&_!=="0"?{amount:Te(_,n.decimal),rate:x?.tax_rate||0,inclusive:x?.tax_inclusive||!1}:null,F=a?.no_stake||!1,w=Math.max(Number(a?.billing_threshold_amount||0),Number(a?.min_stake_amount||0)),E=o==="arcblock"&&n.type!=="credit"&&!F?fi(e,n,w):"0",y=new z(E),I=m.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),R=I,B=ze(Te(R,n.decimal),s);let H=null,G=null;if(s&&i&&n){const Q=Vt(N.toString(),n.decimal,i);Q&&(H=Qt(Q)||null);const te=Vt(R.toString(),n.decimal,i);te&&(G=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:f?`${f} ${n.symbol}`:null,tax:k,staking:V,usdEquivalent:H?`$${H}`:null,subtotalUsdEquivalent:G?`$${G}`: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(_=>{const h=_.upsell_price||_.price;!s&&h?.base_currency&&(s=h.base_currency);const x=_.expires_at;x&&(o=o===null?x:Math.min(o,x));const k=_.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,m=!!u,d=Date.now(),f=o?d>o:!1;return{locked:m,lockedAt:u,expiresAt:o,expired:f,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(f=>f.trim()).filter(Boolean);d.length>0&&!d.includes(n)&&(c=0)}const l=c>0;let u=null,m=null;if(l&&i&&r.length>0){const d=_t(r,i,!1,!0,{exchangeRate:s?o:null});let f=new z(d.total);const _=_n(r,i,e,s,o,!1,!0);_.gt(new z(0))&&(f=f.sub(_),f.isNeg()&&(f=new z(0))),u=`${ze(Te(f,i.decimal),s)} ${i.symbol}`;const h=r.find(x=>{const k=x.upsell_price||x.price;return k?.type==="recurring"&&k?.recurring});h&&(m=(h.upsell_price||h.price)?.recurring?.interval||null)}return{active:l,days:c,afterTrialPrice:u,afterTrialInterval:m}}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 vn(){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 R=new URLSearchParams(window.location.search);for(const B of e){const H=R.get(`qty_${B.price_id}`)||R.get(`qty_${B.price?.id}`)||R.get("qty");if(H){const G=Math.max(1,parseInt(H,10));if(Number.isFinite(G)&&G!==B.quantity){u.current=!0,Bt(r,B.price_id,G,l,n,s,o,a);break}}}}catch{}},[r,e,l]);const m=L(async(R,B)=>{if(n?.status!=="complete")try{await Bt(r,R,B,l,n,s,o,a)}catch(H){console.error("Failed to update quantity:",je(H))}}),d=L(async(R,B)=>{n?.status!=="complete"&&await yn(r,R,B,n,l,s,o,a)}),f=L(async R=>{n?.status!=="complete"&&await bn(r,R,n,l,s,o,a)}),_=p.useMemo(()=>ci(e),[e]),[h,x]=p.useState(null),k=p.useMemo(()=>e.map(R=>R.price_id).join(","),[e]),F=p.useMemo(()=>e.some(R=>R.cross_sell),[e]);p.useEffect(()=>{if(!r||!n||n.status==="complete")return;if(_){x(null);return}if(F)return;let R=!1;return bi(r).then(B=>{R||x(B)}),()=>{R=!0}},[r,n?.id,_,k,F]);const w=_||h,C=p.useMemo(()=>e.some(R=>R.cross_sell_required),[e]),E=L(async()=>{if(n?.status!=="complete"&&w)try{await gi(r,w.id,n,l,s,o,a)}catch(R){console.error("Failed to add cross-sell:",je(R))}}),y=L(async()=>{if(n?.status!=="complete")try{await yi(r,n,l,s,o,a)}catch(R){console.error("Failed to remove cross-sell:",je(R))}}),I=L(async(R,B)=>{if(n?.status!=="complete"&&i)try{await ai(r,R,B,n,l,s,o,a)}catch(H){console.error("Failed to change amount:",je(H))}}),N=p.useMemo(()=>e.map(R=>({...R,adjustable_quantity:R.adjustable_quantity})),[e]),$=p.useMemo(()=>e.every(R=>{const{price:B}=R;if(!B)return!0;const H=Number(R.quantity)||0,G=B.quantity_available||0,V=B.quantity_sold||0,Q=B.quantity_limit_per_checkout||0;return!(G>0&&V+H>G||Q>0&&Q<H)}),[e]);return{items:N,inventoryOk:$,updateQuantity:m,upsell:d,downsell:f,crossSellItem:w,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),[m,d]=p.useState(null),f=L(async(h,x)=>{try{await yn(r,h,x,n,c,i,s,o)}catch(k){console.error("Failed to upsell:",je(k))}}),_=L(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:m||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 f(h.firstItem.price_id,k.priceId):h.firstItem.upsell_price_id&&await _(h.firstItem.upsell_price_id)}finally{u(!1),d(null)}}}}:null},[e,r,l,m])}function vi(){const{session:e,effectiveSessionId:n,refresh:r}=_e(),{currency:i}=Ie(),[s,o]=p.useState(null);p.useEffect(()=>{if(!e||s)return;const m=ni(e);m&&o(m)},[e?.id]);const a=L(async m=>{if(e?.status==="complete")return{success:!1,error:"Session already completed"};const d=await ri(n,m,i?.id);return d.success&&(o(m),await r(!0)),d}),c=L(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 vt(){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 wn(){const{items:e,sessionData:n,effectiveSessionId:r,refresh:i}=_e(),{hasDynamicPricing:s}=yt(),o=p.useMemo(()=>Sn(e,s,n),[e,s,n]),a=L(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 wt(){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 m=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:m}}function wi(){return Ie()}function jn(){return sr()}function et(){return or()}const ki={overflowY:"auto","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},Kt={"@keyframes mobileFadeIn":{from:{opacity:0},to:{opacity:1}},animation:{xs:"mobileFadeIn 0.4s ease both",md:"none"}},Gt={"@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(b,{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",...Kt},children:[!c&&t.jsx(b,{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",...Gt},children:e}),t.jsx(b,{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],m=a?o.palette.background.default:"#f8faff";return t.jsxs(b,{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:m,...Kt},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(_=>["locale-selector","theme-mode-toggle","session-user"].includes(_.key))}),!c&&t.jsx(b,{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(b,{sx:{width:"100%",maxWidth:{md:640},p:{xs:3,md:5},pt:{xs:3,md:10},display:"flex",flexDirection:"column",flex:1,...Gt},children:e})}),t.jsx(b,{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(b,{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:m=!1,hideUpsell:d=!1,isRateLoading:f=!1,showFeatures:_=!0,children:h=void 0}){const x=e.upsell_price||e.price,k=x?.product,F=k?.name||"Item",w=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),R=!!E,B=u(R?"payment.checkout.typeBadge.subscription":"payment.checkout.typeBadge.oneTime"),H=E?.interval?` / ${u(`common.${E.interval}`)}`:"",G=y>1&&$&&n?`${y} × ${$} ${n.symbol}`:I?N.trim():"",V=(()=>{const S=e.quote_currency_id;if(e.custom_amount&&S&&S===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 ie=Number(x.base_amount);if(ie>0&&Number.isFinite(ie)){const ae=ie*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 ie=BigInt(M)*BigInt(y);return He(ie.toString(),n)}}return"0"})(),Q=r?.[0],te=Q?.promotion_code_details?.code||Q?.verification_data?.code||Q?.promotion_code||"",O=(()=>{if(!te||!Q)return null;const S=Q?.coupon_details;if(S?.percent_off>0){const M=parseFloat(String(V).replace(/,/g,""));if(!Number.isNaN(M)&&M>0){const ie=M*S.percent_off/100,ae=Math.abs(ie),ue=ae>0&&ae<.01?6:2;return`${ie.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})(),oe=e.adjustable_quantity?.enabled,Y=e.adjustable_quantity?.minimum||1,W=e.adjustable_quantity?.maximum,[se,J]=p.useState(String(y)),[ne,U]=p.useState(!1),pe=We(),he=An(pe.breakpoints.down("md")),[le,P]=p.useState(!he);p.useEffect(()=>{ne||J(String(y))},[y,ne]);const fe=p.useRef(null),me=p.useCallback((S,M)=>{fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{s(S,M)},400)},[s]);p.useEffect(()=>()=>{fe.current&&clearTimeout(fe.current)},[]);const j=!!e.price?.upsell?.upsells_to,K=!!e.upsell_price,v=e.price?.upsell?.upsells_to;let T=0;if(j&&v){const S=parseFloat(e.price?.base_amount||e.price?.unit_amount||"0"),M=parseFloat(v?.base_amount||v?.unit_amount||"0"),ie=e.price?.recurring?.interval,ae=v?.recurring?.interval;if(S>0&&M>0&&ie&&ae){const ue={day:365,week:52,month:12,year:1},de=S*(ue[ie]||1),Se=M*(ue[ae]||1);de>Se&&(T=Math.round((de-Se)/de*100))}}const q=v?.recurring?.interval,re=(()=>{if(!v)return"";const S=q?u("common.slash",{interval:u(`common.${q}`)}):"";if(v.pricing_type==="dynamic"&&v.base_amount&&i){const ie=Number(i);if(ie>0&&Number.isFinite(ie)){const ae=parseFloat(v.base_amount);if(ae>0&&Number.isFinite(ae)){const ue=ae/ie,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||""} ${S}`}}}if(v.pricing_type==="dynamic"&&v.base_amount&&v.base_currency==="USD")return`$${parseFloat(v.base_amount).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})} ${S}`;const M=Ye(v,n,i);return M?`${M} ${n?.symbol||""} ${S}`:""})(),Z=e.price?.recurring?.interval,ge=(()=>{if(!e.price||!K)return"";const S=e.price,M=Z?u("common.slash",{interval:u(`common.${Z}`)}):"";if(S.pricing_type==="dynamic"&&S.base_amount&&i){const ae=Number(i);if(ae>0&&Number.isFinite(ae)){const ue=parseFloat(S.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(S.pricing_type==="dynamic"&&S.base_amount&&S.base_currency==="USD")return`$${parseFloat(S.base_amount).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})} ${M}`;const ie=Ye(S,n,i);return ie?`${ie} ${n?.symbol||""} ${M}`:""})(),ke=(()=>{if(K){const M=Z?u(Ae[Z]||""):"";return u("payment.checkout.upsell.revert",{recurring:M})}const S=q?u(Ae[q]||""):"";return u("payment.checkout.upsell.save",{recurring:S})})();return t.jsxs(b,{sx:{position:"relative"},children:[m&&t.jsx(Ge,{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:S=>$e(S),boxShadow:"0 4px 12px rgba(45,124,243,0.2)","& .MuiChip-label":{px:1.5}}}),t.jsxs(b,{sx:{p:{xs:2,md:3},bgcolor:"background.paper",borderRadius:{xs:"16px",md:"24px"},border:"1px solid",borderColor:"divider",boxShadow:S=>S.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:S=>S.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:[w?t.jsx(Ce,{src:w,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:S=>S.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(b,{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(b,{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:S=>S.palette.mode==="dark"?`${S.palette.primary.main}1A`:`${S.palette.primary.main}0D`,px:.75,py:.4,borderRadius:"3px"},children:B}),G&&t.jsx(g,{sx:{color:"text.disabled",fontSize:13,fontWeight:500,mt:.25},children:G})]}),t.jsx(D,{alignItems:"flex-end",sx:{flexShrink:0,ml:1.5},children:c&&R?t.jsx(g,{sx:{fontWeight:800,color:"text.primary",whiteSpace:"nowrap",fontSize:{xs:15,md:18}},children:cn(u,l,E?.interval||"day")}):f?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)]})]})})]})})]}),_&&C.length>0&&t.jsxs(b,{sx:{mt:{xs:2,md:2.5},pt:{xs:2,md:2.5},borderTop:"1px solid",borderColor:S=>S.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.100"},children:[t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",onClick:()=>P(S=>!S),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(S=>t.jsxs(D,{direction:"row",spacing:1.5,alignItems:"center",children:[t.jsx(b,{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:S.name})]},S.name))})})]}),te&&O&&t.jsx(b,{sx:{mt:1.5},children:f?t.jsx(Ne,{variant:"rounded",width:160,height:22,sx:{borderRadius:"6px"}}):t.jsx(Ge,{icon:t.jsx(en,{sx:{color:"warning.main",fontSize:"small"}}),label:`${te} (-${O})`,size:"small",sx:{height:22,borderRadius:"6px","& .MuiChip-label":{fontSize:12}}})}),oe&&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(se,10)||y)-1;M<Y||(J(String(M)),me(e.price_id,M))},disabled:(parseInt(se,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:se,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:()=>U(!0),onChange:S=>J(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),S.stopPropagation(),S.target.blur())},onBlur:()=>{U(!1);const S=parseInt(se,10);!Number.isNaN(S)&&S>=Y&&(!W||S<=W)&&S!==y?s(e.price_id,S):J(String(y))}}),t.jsx(Ve,{size:"small",onClick:()=>{const M=(parseInt(se,10)||y)+1;W&&M>W||(J(String(M)),me(e.price_id,M))},disabled:W?(parseInt(se,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(b,{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:S=>S.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(b,{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:K,onChange:async()=>{try{K?await a(e.upsell_price?.id||e.price.id):await o(e.price_id,v.id)}catch(S){Fe.error(S?.response?.data?.error||S?.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{K?await a(e.upsell_price?.id||e.price.id):await o(e.price_id,v.id)}catch(S){Fe.error(S?.response?.data?.error||S?.message||"Failed")}},children:ke}),!K&&T>0&&t.jsx(Ge,{label:u("payment.checkout.upsell.off",{saving:T}),size:"small",sx:{height:22,fontSize:11,fontWeight:700,bgcolor:S=>S.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",border:"1px solid",borderColor:S=>S.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:K?ge:re})]})]})]})}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(b,{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,m=u?.interval?Ae[u.interval]:null,d=a?.description||"",f=d&&d!==l?d:m?o(m):"";return t.jsxs(b,{sx:{position:"relative"},children:[i&&t.jsx(Ge,{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:_=>$e(_),boxShadow:"0 4px 12px rgba(45,124,243,0.2)","& .MuiChip-label":{px:1.5}}}),t.jsx(b,{sx:{p:{xs:2,md:3},bgcolor:"background.paper",borderRadius:{xs:"16px",md:"24px"},border:"2px dashed",borderColor:_=>_.palette.mode==="dark"?"rgba(255,255,255,0.15)":"rgba(45,124,243,0.25)",boxShadow:_=>_.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:_=>_.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(b,{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)]})]})]}),f&&t.jsx(g,{sx:{fontSize:{xs:12,md:14},color:"text.secondary",fontWeight:500,lineHeight:1.4},noWrap:!0,children:f}),t.jsx(b,{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:_=>$e(_),borderColor:"primary.main"},"&:active":{transform:"scale(0.95)"}},onClick:_=>{_.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}=wt(),{product:a,pageInfo:c}=vn(),l=St(),u=Si(),m=kn(),d=vt(),f=wn(),{isMobile:_}=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||"",w=_||l.items.length>=4,[C,E]=p.useState(_?l.items.length<=1:l.items.length<4),y=l.crossSellItem&&!l.items.some(P=>P.price_id===l.crossSellItem?.id),I=l.items.filter(P=>!P.cross_sell),N=l.items.filter(P=>P.price?.upsell?.upsells_to),$=N.length===1?N[0]:null,R=$?$.price?.upsell?.upsells_to:null,B=I.length<=1,H=B&&!!$&&["subscription","setup"].includes(h),G=!!$?.upsell_price,[V,Q]=p.useState(!1),[te,O]=p.useState(null),oe=te!==null?te:G,Y=H?$.price?.recurring?.interval:null,W=H?R?.recurring?.interval:null;let se=0;if(H&&Y&&W){const P=parseFloat($.price?.base_amount||$.price?.unit_amount||"0"),fe=parseFloat(R?.base_amount||R?.unit_amount||"0"),me={day:365,week:52,month:12,year:1},j=P*(me[Y]||1),K=fe*(me[W]||1);j>K&&j>0&&(se=Math.round((j-K)/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),U=l.items.length>1,pe={bgcolor:"primary.main",color:P=>$e(P),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=P=>({px:3.5,py:1,borderRadius:"9999px",cursor:"pointer",transition:"all 0.3s ease",userSelect:"none",...P?pe:he});return t.jsxs(b,{sx:{display:"flex",flexDirection:"column",flex:1},children:[!_&&(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})]}),!_&&t.jsx(b,{sx:{flexGrow:1,flexShrink:1,flexBasis:0}}),t.jsxs(b,{sx:{flexShrink:0},children:[t.jsxs(b,{sx:{mb:{xs:3,md:4}},children:[_&&(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:P=>P.palette.mode==="dark"?`${P.palette.primary.main}1A`:`${P.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:ne.badgeLabel}),m.trial.active&&m.trial.days>0&&t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:P=>P.palette.mode==="dark"?`${P.palette.primary.main}1A`:`${P.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:cn(e,m.trial.days,m.trial.afterTrialInterval||"day")}),!o&&t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:P=>P.palette.mode==="dark"?P.palette.grey[500]:P.palette.grey[400],bgcolor:P=>P.palette.mode==="dark"?"rgba(255,255,255,0.06)":P.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:U?xe(e,"payment.checkout.orderSummary","Order Summary"):ne.title}),(U||ne.subtitle)&&t.jsx(g,{sx:{color:"text.secondary",fontSize:{xs:14,md:16},fontWeight:500,lineHeight:1.5},children:U?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:P=>P.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(b,{onClick:async()=>{if(G&&!V){O(!1),Q(!0);try{await l.downsell($.upsell_price?.id||$.price_id)}catch(P){O(null),Fe.error(P?.response?.data?.error||P?.message||"Failed")}finally{Q(!1),O(null)}}},sx:le(!oe),children:t.jsx(g,{component:"span",sx:{fontSize:14,fontWeight:700,color:"inherit",lineHeight:1},children:e(Ae[Y]||"")})}),t.jsx(b,{onClick:async()=>{if(!G&&!V){O(!0),Q(!0);try{await l.upsell($.price_id,R.id)}catch(P){O(null),Fe.error(P?.response?.data?.error||P?.message||"Failed")}finally{Q(!1),O(null)}}},sx:le(oe),children:t.jsx(g,{component:"span",sx:{fontSize:14,fontWeight:700,color:"inherit",lineHeight:1},children:e(Ae[W]||"")})})]}),se>0&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,sx:{px:1.5,py:.75,bgcolor:P=>P.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",fontSize:11,fontWeight:700,borderRadius:"9999px",border:"1px solid",borderColor:P=>P.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 ",se,"%"]})]})]})]}),t.jsx(Ri,{billingInterval:u})]}),t.jsxs(b,{sx:{flexGrow:0,flexShrink:1,flexBasis:"auto",minHeight:{md:0},overflowY:{md:"auto"},"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},children:[w&&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||!w,children:[t.jsx(D,{spacing:2,sx:{mb:2},children:l.items.map(P=>t.jsx(Ei,{item:P,currency:r,discounts:x,exchangeRate:d.value,onQuantityChange:l.updateQuantity,onUpsell:l.upsell,onDownsell:l.downsell,trialActive:m.trial.active,trialDays:m.trial.days,hideUpsell:H||!B,isRateLoading:s||d.hasDynamicPricing&&d.status==="loading",showFeatures:c?.showProductFeatures??!1,t:e,children:P.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")})},P.id))}),y&&t.jsx(b,{sx:{mb:2},children:t.jsx(Pi,{crossSellItem:l.crossSellItem,currency:r,exchangeRate:d.value,crossSellRequired:l.crossSellRequired,onAdd:l.addCrossSell})})]})]}),t.jsx(b,{sx:{flexShrink:0},children:t.jsx(Ti,{trial:{active:m.trial.active,days:m.trial.days,afterTrialPrice:m.trial.afterTrialPrice,afterTrialInterval:m.trial.afterTrialInterval},mode:h,items:l.items})}),t.jsx(b,{sx:{flexGrow:1,flexShrink:1,flexBasis:0}}),t.jsxs(b,{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:f.percent,set:f.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}=wt(),{product:o}=vn(),{currency:a,isStripe:c}=Ie(),l=St(),u=vt(),m=wn(),{locked:d}=et(),f=l.items[0],_=f?f.upsell_price||f.price:null,h=_?.metadata?.credit_config,x=h?.credit_amount?Number(h.credit_amount):0,k=h?.currency_id,{session:F,getCurrency:w}=un(),C=k?w(k):null,E=F?.user?.did||i?.customer?.did,y=C?.decimal,I=C?.symbol||"Credits",N="Credits",$=_?.metadata?.meter_id,{data:R}=ut(async()=>{if(!$)return null;try{const{data:A}=await dt.get(`/api/meters/public/${$}`);return A}catch{return null}},{refreshDeps:[$]}),B=R?.name||o?.name||"Credits",H=h?.valid_duration_value,G=h?.valid_duration_unit||"days",V=h?.schedule,Q=V?.enabled&&V?.delivery_mode&&V.delivery_mode!=="invoice",te=H&&H>0,O=Math.max(x,1),oe=f?.adjustable_quantity,Y=oe?.enabled!==!1,W=Math.max(oe?.minimum||1,1),se=Math.min(_?.quantity_limit_per_checkout??1/0,_?.quantity_available??1/0),J=se?Math.min(oe?.maximum||1/0,se):oe?.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]}),U=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=U?U*O:0,P=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.${G}`)}):"",[te,H,G,e]),j=!!fe,K=f?.quantity||1,[v,T]=p.useState(K),[q,re]=p.useState(K*O),[Z,ge]=p.useState(!1),[ke,S]=p.useState(""),M=p.useRef(null);p.useEffect(()=>{d||r?.status==="complete"||f?.quantity&&f.quantity!==v&&(T(f.quantity),re(f.quantity*O))},[f?.quantity]);const ie=p.useRef(!1);p.useEffect(()=>{if(!(d||r?.status==="complete")&&!ie.current&&U&&U>v){ie.current=!0;const A=Math.min(Math.max(U,W),J);T(A),re(A*O),f&&l.updateQuantity(f.price_id,A)}},[U]);const ae=J*O,ue=W*O,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/O),qe=Math.max(W,Math.min(J,Le));T(qe),re(ye),f&&(de.current&&clearTimeout(de.current),de.current=setTimeout(()=>{l.updateQuantity(f.price_id,qe)},400))},[O,W,J,ue,ae,f,l]),Oe=p.useCallback(A=>{const ye=q+A*O;ye<O*W||Math.ceil(ye/O)>J||Se(ye)},[q,O,W,J,Se]),Ue=Math.max(W,Math.min(J,Math.ceil(q/O))),Qe=Ue*O,kt=Re(Qe,6,!0,!0),En=Re(q,6,!0,!0),jt=Y&&O>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:P}):"",[pe,Qe,le,he,I,n,P,e]),Pn=p.useCallback(()=>{Y&&(S(String(q)),ge(!0),setTimeout(()=>M.current?.select(),0))},[Y,q]),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(b,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[t.jsxs(b,{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(b,{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(b,{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(b,{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(b,{component:"span",sx:{fontSize:{xs:22,md:28},fontWeight:300,lineHeight:1,mt:"-1px"},children:"−"})}),t.jsxs(b,{sx:{flex:1,minWidth:0,textAlign:"center",cursor:Y?"text":"default"},onClick:Pn,children:[t.jsx(b,{sx:{height:Ct,display:"flex",alignItems:"center",justifyContent:"center"},children:Z?t.jsx(xt,{inputRef:M,value:ke,onChange:A=>S(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(b,{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(b,{component:"span",sx:{fontSize:{xs:22,md:28},fontWeight:300,lineHeight:1},children:"+"})})]}),O>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(O,6,!0,!0),symbol:N})}),jt&&t.jsxs(b,{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(b,{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(b,{component:"span",sx:{fontWeight:800},children:Be(kt,N,n)})]}),t.jsxs(b,{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(O,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(b,{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(b,{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(b,{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(b,{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(b,{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(b,{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(b,{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:m.percent,set:m.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:m,inputRef:d,country:f,setCountry:_}=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===f||l(()=>{_(n)})},[n,f,_,l]);const h=p.useCallback(x=>{l(()=>{_(x),i(x)})},[_,l,i]);return t.jsxs(b,{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:m,onBlur:a,type:"tel",inputRef:d,startAdornment:t.jsx(ht,{position:"start",sx:{mr:.25,ml:-.5},children:t.jsx(dn,{value:f,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(m=>{o(!m),c(!0)}))},[e.prefetched]);const u=p.useCallback((m,d)=>e.onChange(m,d),[e.onChange]);return p.useEffect(()=>{a&&!s&&Object.keys(e.errors).length>0&&o(!0)},[e.errors]),!n||!a?null:s?t.jsxs(b,{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(m=>m.name!=="billing_address.country").map(m=>{const{name:d}=m,f=i[d]||d,_=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:_||"",country:e.values.billing_address?.country||"",onChange:k=>u("customer_phone",k),onCountryChange:k=>u("billing_address.country",k),onBlur:()=>e.validateField(d),label:f,error:e.errors[d]},d):t.jsxs(b,{sx:{mb:1.5},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.primary",mb:.5},children:f}),t.jsx(xt,{fullWidth:!0,value:_||"",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(b,{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(m=>m.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(b,{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),[m,d]=p.useState(""),[f,_]=p.useState(!1),[h,x]=p.useState(""),k=s||l,F=async()=>{if(!m.trim())return;_(!0),x("");const C=await e.apply(m.trim());C.success?(d(""),u(!1)):x(C.error||"Invalid code"),_(!1)},w=C=>{C.key==="Enter"&&!f&&m.trim()&&F()};return n?.length>0?t.jsx(b,{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(b,{sx:{minHeight:36},children:k?t.jsxs(b,{onBlur:C=>{s||!C.currentTarget.contains(C.relatedTarget)&&!m.trim()&&u(!1)},children:[t.jsx(tn,{fullWidth:!0,size:"small",value:m,onChange:C=>d(C.target.value),onKeyPress:w,placeholder:a("payment.checkout.promotion.placeholder"),disabled:f,autoFocus:!0,slotProps:{input:{endAdornment:t.jsx(ht,{position:"end",children:t.jsx(Ee,{size:"small",onClick:F,disabled:!m.trim()||f,variant:"text",sx:{color:"primary.main",fontSize:13,textTransform:"none",minWidth:"auto",fontWeight:600},children:f?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}=wt(),c=wi(),l=jn(),u=et(),m=kn(),{session:d,connect:f,prefix:_}=un(),{inventoryOk:h}=St(),x=vi(),k=vt(),{isMobile:F}=Ze(),w=c.switching||k.hasDynamicPricing&&k.status==="loading",{currency:C,types:E,isStripe:y,isCrypto:I}=c,N=r?.mode||"payment",$=r?.discounts||[],R=!!d?.user,B=e(a?"payment.checkout.donate":`payment.checkout.${N}`),H=R?B:e("payment.checkout.connect",{action:B}),[G,V]=p.useState(!1),[Q,te]=p.useState(!1),[O,oe]=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),se=p.useCallback(()=>{if(Y){if(u.lock(),R||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,R,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]),U=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=K=>{if(K.key==="Enter"&&Y&&u.status==="idle"){if(K.target?.tagName?.toLowerCase()==="textarea")return;se()}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[Y,u.status,se]);const he=p.useRef(!1),le=p.useRef(!1),P=p.useRef(u.status);p.useEffect(()=>{P.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"||!f||he.current)return;he.current=!0;const K=`${_||window.location.origin}/api/did`.replace(/([^:])\/\//g,"$1/");f.open({locale:n,action:j.action,prefix:K,saveConnect:!1,extraParams:j.extraParams,onSuccess:async()=>{le.current=!0,f.close(),await u.didConnectComplete()},onClose:()=>{f.close(),P.current==="waiting_did"&&(le.current||u.reset())},onError:v=>{console.error("DID Connect error:",v),P.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,f,n,e,H]);const fe=E.find(j=>j.active)?.type||"crypto",me=E.length>1;return t.jsxs(b,{sx:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[t.jsxs(b,{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,K)=>K&&c.setType(K),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&&U.length>0&&t.jsxs(D,{direction:"row",spacing:1.5,sx:{mb:2.5},children:[U.length>1&&t.jsxs(b,{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 K=U.find(v=>v.id===j.target.value);K?.currencies?.[0]&&c.setCurrency(K.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:U.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(b,{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&&U.length>1?U.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(b,{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:R})]}),t.jsxs(b,{className:"cko-v2-submit-btn",sx:{flexShrink:0},children:[F&&m.staking&&t.jsxs(t.Fragment,{children:[t.jsxs(b,{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"}})]}),w?t.jsx(Ne,{variant:"text",width:60,height:18}):t.jsxs(g,{sx:{fontSize:13,fontWeight:600},children:["+",m.staking]})]}),t.jsx(lt,{sx:{mb:1}})]})]}),!F&&t.jsxs(t.Fragment,{children:[t.jsx(lt,{sx:{mb:2}}),m.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"}})})]}),w?t.jsx(Ne,{variant:"text",width:80,height:22}):t.jsxs(g,{sx:{fontSize:14,fontWeight:600},children:["+",m.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:m.discount,currency:C,isAmountLoading:w})]}),(()=>{const K=(m.total||"0").split(/\s+/),v=K[0]||"0",T=K.slice(1).join(" ")||C?.symbol||"",q=v.indexOf("."),re=q>=0?v.slice(0,q):v,Z=q>=0?v.slice(q):"";return t.jsxs(b,{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")}),w?t.jsx(Ne,{variant:"text",width:140,height:44}):t.jsxs(b,{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:re}),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:T})]})]}),(m.usdEquivalent||F&&x.active)&&!w&&t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mt:.25},children:[F&&!x.applied&&x.active?t.jsxs(b,{onClick:()=>oe(!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}),m.discount&&t.jsxs(g,{sx:{fontSize:11,color:"text.secondary"},children:["(-",m.discount,")"]}),t.jsx(on,{onClick:x.remove,sx:{fontSize:14,color:"error.main",cursor:"pointer",ml:.25}})]}):t.jsx(b,{}),m.usdEquivalent&&t.jsxs(g,{sx:{fontSize:13,color:"text.secondary"},children:["≈ ",m.usdEquivalent]})]})]})})(),t.jsxs(Ee,{variant:"contained",size:"large",fullWidth:!0,disabled:!Y||u.status==="waiting_stripe",onClick:se,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(b,{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(b,{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(Kn,{anchor:"bottom",open:O,onClose:()=>oe(!1),PaperProps:{sx:{borderRadius:"16px 16px 0 0",p:3,pb:4,minHeight:"30vh"}},children:[t.jsx(b,{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 K=await x.apply(...j);return K.success&&oe(!1),K},remove:x.remove},discounts:$,discountAmount:m.discount,currency:C})]}),t.jsxs(b,{sx:{flexShrink:0},children:[t.jsx(Wi,{mode:N,subscription:s,staking:m.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}),G&&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:G,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(b,{sx:{display:"flex",gap:2,mt:4},children:[0,1,2].map(e=>t.jsx(b,{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(b,{sx:{position:"relative",width:{xs:160,md:200},height:{xs:160,md:200}},children:[t.jsx(b,{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(b,{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(b,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1},children:[t.jsx(Hi,{}),t.jsx(Bi,{})]});return n?t.jsxs(b,{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(b,{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(b,{sx:{position:"relative",width:{xs:200,md:260},height:{xs:200,md:260},mb:{xs:4,md:6}},children:[t.jsx(b,{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(b,{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(b,{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(Gn,{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 Ki({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(b,{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(b,{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(b,{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 Ke={};function Gi(e,n){return Ke[e]||(Ke[e]=dt.post(`/api/checkout-sessions/start/${e}?${mn(n)}`).then(r=>r?.data).finally(()=>{setTimeout(()=>{delete Ke[e]},3e3)})),Ke[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(Ki,{error:s,errorCode:o,mode:r});const u=c.status==="completed",m=u&&l;return t.jsxs(t.Fragment,{children:[t.jsx(Ci,{left:m?null:t.jsx(b,{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(vr,{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 m=await Gi(e,o),d=m?.checkoutSession?.id;return d&&(l(d),s==="standalone"&&window.history.replaceState(null,"",an(pn(),`/checkout/pay/${d}?${mn(o)}`))),m},{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]=wr(),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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as a,j as e,w as xe,A as g,a3 as c,bv as he,q as i,B as d,x as L,Y as S,bL as fe,bx as ye,$ as k,bg as $,bl as z,a2 as ge,bf as H}from"./vendor-mui-BXZut9Pz.js";import{V as be,G as O,F as U,Y,E as je}from"./vendor-blocklet-D_i_QeSo.js";import{a as ve,u as Ce,i as we,a4 as Se,j as G,e as A,k as V,l as ke,G as Ae}from"./index-DgSc1Qy8.js";import{R as Ie}from"./recharge-DcPtT8vt.js";import{S as Re}from"./description-Ym17DL48.js";import{I as b}from"./info-row-DOK2whMn.js";import{C as X}from"./currency-GstdXsJf.js";import{S as _e}from"./metrics-C7U41HWk.js";import{g as Ne,M as K}from"./util-mDHAL0lx.js";import{C as Be}from"./link-3eeclTeS.js";import{f as Te}from"./dayjs-B9tvQIKg.js";import{u as We}from"./browser-DSLTxXlL.js";import{e as De,a as Ee}from"./vendor-react-BPknnnEA.js";import"./table-BRU4Enia.js";import"./info-metric-CNse3r66.js";import"./status-l6pD08fw.js";import"./lodash-B4Ozcv0x.js";const Pe=H(c)(({theme:t})=>({marginBottom:t.spacing(3),gap:t.spacing(3),flexDirection:"column",margin:"0 auto"})),q=H(d)(({theme:t})=>({padding:t.spacing(2),backgroundColor:t.palette.background.paper,border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadius,marginBottom:t.spacing(2)}));function et(){const{t,locale:I}=be(),{id:u}=De(),J=Ee(),{connect:j}=ve(),Q=We(),[r,Z]=a.useState(null),[n,v]=a.useState(""),[h,ee]=a.useState(""),[te,R]=a.useState(!0),[_,re]=a.useState(""),N=a.useRef(null),[C,se]=a.useState(null),[p,B]=a.useState(!1),[ne,oe]=a.useState([]),{session:T}=Ce(),[f,ae]=a.useState("0"),{paymentCurrency:W,payment_details:ie,payment_settings:ce,paymentMethod:y}=r||{paymentCurrency:null,payment_details:null,paymentMethod:null,payment_settings:null},D=ie?.[y?.type]?.payer||ce?.payment_method_options?.[y?.type]?.payer,E=async()=>{try{R(!0);const[s,o,m]=await Promise.all([A.get(`/api/subscriptions/${u}`),A.get(`/api/subscriptions/${u}/payer-token`),A.get(`/api/subscriptions/${u}/cycle-amount`)]);Z(s.data),se(o.data);const l=F=>O(new U(m.data.amount).mul(new U(F)).toString(),m.data?.currency?.decimal);oe([{amount:l(1),cycles:1},{amount:l(2),cycles:2},{amount:l(3),cycles:3},{amount:l(5),cycles:5},{amount:l(10),cycles:10}]),ae(O(m.data.amount||"0",m.data?.currency?.decimal)||"0"),!n&&!p&&P(l(10))}catch(s){re(V(s)||t("common.fetchError")),console.error(s)}finally{R(!1)}},w=a.useRef(null);a.useEffect(()=>{E()},[u]),a.useEffect(()=>{w.current&&r&&setTimeout(()=>{const s=w.current.getBoundingClientRect(),m=window.scrollY+s.top-20;window.scrollTo({top:m,behavior:"smooth"})},200)},[r]);const le=()=>{r&&(Number.isNaN(Number(n))||j.open({containerEl:void 0,saveConnect:!1,action:"recharge",locale:I,prefix:je(ke(),"/api/did"),extraParams:{subscriptionId:u,amount:Number(n)},messages:{scan:t("common.connect.defaultScan"),title:t("customer.recharge.title"),confirm:t("common.connect.confirm")},onSuccess:()=>{j.close(),Y.success(t("customer.recharge.success")),E()},onClose:()=>{j.close()},onError:s=>{Y.error(V(s))}}))},me=s=>{const{value:o}=s.target;if(!r||!/^\d*\.?\d*$/.test(o)||o.startsWith(".")||Number(o)>K)return;const m=r.paymentCurrency.maximum_precision||6,l=Ae(o,I,m);ee(l||""),v(o)},P=s=>{v(s),B(!1)},ue=()=>{B(!0),v(""),setTimeout(()=>{N.current?.focus()},0)};if(te)return e.jsx(xe,{});if(_)return e.jsx(g,{severity:"error",children:_});if(!r)return e.jsx(g,{severity:"info",children:t("common.dataNotFound")});if(r?.customer?.did&&T?.user?.did&&r.customer.did!==T.user.did)return e.jsx(g,{severity:"error",children:t("common.accessDenied")});const de=we(C?.token||"0",W?.decimal,6,!1),pe=["arcblock","ethereum","base"].includes(y?.type||""),M=s=>{const{interval:o,interval_count:m}=r.pending_invoice_item_interval,l=s*m;return["hour","day","week","month","year"].includes(o)?t("common.estimatedDuration",{duration:Te(l,o,{t})}):t("customer.recharge.estimatedDuration",{duration:l,unit:t("customer.recharge.intervals").toLowerCase()})},x=Se(y,C?.paymentAddress||D);return e.jsxs(Pe,{children:[e.jsxs(c,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center",position:"relative"},children:[Q?e.jsx(d,{}):e.jsxs(c,{direction:"row",onClick:()=>Ne("/customer"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(he,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(i,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:t("common.previous")})]}),e.jsx(L,{variant:"outlined",onClick:()=>J(`/customer/subscription/${u}`),children:t("customer.recharge.view")})]}),e.jsxs(d,{children:[e.jsxs(d,{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(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(Re,{subscription:r,variant:"h1"})})}),e.jsx(c,{sx:{justifyContent:"flex-start",flexWrap:"wrap",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(_e,{subscription:r,showBalance:!1})})]}),e.jsx(S,{sx:{my:2}}),e.jsxs(d,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",sm:"repeat(1, 1fr)",md:"repeat(1, 1fr)"},gap:{xs:0,md:2},".currency-name":{color:"text.secondary"},".info-row-label":{fontWeight:500}},children:[e.jsx(b,{label:t("common.customer"),value:e.jsx(Be,{customer:r?.customer,linked:!1}),direction:"column",alignItems:"flex-start"}),e.jsx(b,{label:t("admin.subscription.currentPeriod"),value:`${G(r.current_period_start*1e3)} ~ ${G(r.current_period_end*1e3)}`,direction:"column",alignItems:"flex-start"}),e.jsx(b,{label:t("admin.paymentMethod._name"),value:e.jsx(X,{logo:r.paymentMethod?.logo,name:r.paymentMethod?.name}),direction:"column",alignItems:"flex-start"}),e.jsx(b,{label:t("admin.paymentCurrency.name"),value:e.jsx(c,{direction:"row",spacing:2,children:e.jsx(X,{logo:r.paymentCurrency.logo,name:r.paymentCurrency.symbol})}),direction:"column",alignItems:"flex-start"})]})]}),e.jsx(S,{}),e.jsxs(d,{sx:{maxWidth:600},ref:w,children:[e.jsx(i,{variant:"h4",gutterBottom:!0,children:t("customer.recharge.title")}),pe?e.jsxs(e.Fragment,{children:[e.jsxs(q,{children:[e.jsx(i,{variant:"subtitle1",children:t("customer.recharge.receiveAddress")}),e.jsx(i,{variant:"h4",sx:{wordBreak:"break-all"},children:C?.paymentAddress||D})]}),e.jsx(q,{onClick:()=>x&&window.open(x,"_blank"),sx:{color:"text.primary",borderRadius:1,transition:"all 0.2s ease-in-out",cursor:x?"pointer":"default",position:"relative","&:hover":x?{"& .MuiSvgIcon-root":{opacity:1,transform:"translateX(0)"}}:void 0},children:e.jsxs(c,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsxs(c,{sx:{flex:1},children:[e.jsxs(i,{variant:"body1",color:"inherit",sx:{display:"flex",alignItems:"center",gap:1,color:"text.secondary"},children:[e.jsx(fe,{color:"success",fontSize:"small"}),t("admin.customer.summary.balance")]}),e.jsxs(i,{variant:"h3",sx:{fontWeight:"bold",mt:1,color:"text.primary"},children:[de," ",r.paymentCurrency.symbol]})]}),x&&e.jsx(ye,{sx:{opacity:0,transform:"translateX(-10px)",transition:"all 0.2s ease-in-out",color:"inherit"}})]})}),e.jsx(c,{sx:{mb:2,mt:2,backgroundColor:"background.default"},children:e.jsxs(k,{container:!0,spacing:2,children:[ne.map(({amount:s,cycles:o})=>e.jsx(k,{size:{xs:6,sm:4},children:e.jsx($,{variant:"outlined",sx:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"center",transition:"all 0.3s",cursor:"pointer","&:hover":{transform:"translateY(-4px)",boxShadow:3},...n===s&&!p?{borderColor:"primary.main",borderWidth:1}:{}},children:e.jsx(z,{onClick:()=>P(s),sx:{height:"100%"},children:e.jsxs(c,{direction:"column",spacing:1,sx:{alignItems:"center",justifyContent:"center",p:1},children:[e.jsxs(i,{variant:"h6",sx:{fontWeight:600,color:n===s&&!p?"primary.main":"text.primary"},children:[s," ",r.paymentCurrency.symbol]}),e.jsx(i,{variant:"caption",sx:{color:"text.secondary"},children:M(o)})]})})})},s)),e.jsx(k,{size:{xs:6,sm:4},children:e.jsx($,{variant:"outlined",sx:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"center",transition:"all 0.3s",cursor:"pointer","&:hover":{transform:"translateY(-4px)",boxShadow:3},...p?{borderColor:"primary.main",borderWidth:1}:{}},children:e.jsx(z,{onClick:ue,sx:{height:"100%"},children:e.jsx(c,{direction:"column",spacing:1,sx:{alignItems:"center",justifyContent:"center",p:1},children:e.jsx(i,{variant:"h6",sx:{fontWeight:600,color:p?"primary.main":"text.primary"},children:t("customer.recharge.custom")})})})})})]})}),p&&e.jsxs(d,{children:[e.jsx(ge,{fullWidth:!0,label:t("customer.recharge.amount"),variant:"outlined",type:"text",value:n,error:!!h,helperText:h,onChange:me,sx:{mt:1},inputRef:N,slotProps:{input:{endAdornment:e.jsx(i,{children:r.paymentCurrency.symbol})},htmlInput:{min:0,max:K,autoComplete:"off"}}}),n&&Number(n)>0&&Number(f)>0&&!h&&e.jsx(i,{variant:"body2",sx:{fontSize:12,color:"text.lighter",mt:"8px !important"},children:M(Math.floor(Number(n)/Number(f))<1?parseFloat((Number(n)/Number(f)).toFixed(1)):Math.floor(Number(n)/Number(f)))})]}),e.jsx(L,{fullWidth:!0,size:"large",variant:"contained",color:"primary",onClick:le,sx:{mt:2},disabled:!n||parseFloat(n)<=0||!!h,children:t("customer.recharge.submit")})]}):e.jsx(g,{severity:"info",children:t("customer.recharge.unsupported")})]}),e.jsx(S,{}),e.jsx(i,{variant:"h4",gutterBottom:!0,children:t("customer.recharge.history")}),e.jsx(Ie,{subscription_id:u,currency_id:W?.id})]})}export{et as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as i}from"./index-DgSc1Qy8.js";function t(e=10){const{isMobile:o}=i();return o?5:e}export{t as u};
|