@arcblock/payment-service 1.29.9 → 1.29.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cf.js +51 -51
- package/dist/index.js +196 -43
- package/package.json +3 -3
- package/web/assets/{account-Clbqiiw3.js → account-DrsnH5wP.js} +1 -1
- package/web/assets/{action-DENqSeOa.js → action-C2c0yWuW.js} +1 -1
- package/web/assets/{actions-CDsj5j8l.js → actions--FNKSNIs.js} +1 -1
- package/web/assets/{actions-BJDN6Op2.js → actions-BEUwbsq1.js} +1 -1
- package/web/assets/{actions-CSpJGOX7.js → actions-C9AfME83.js} +1 -1
- package/web/assets/{actions-BD9BAp3M.js → actions-D2-s31n3.js} +1 -1
- package/web/assets/{actions-BSNy5bOd.js → actions-DXMceTgd.js} +1 -1
- package/web/assets/{actions-0iWP2mcx.js → actions-DeCPtfTK.js} +1 -1
- package/web/assets/{actions-DGQs8fFF.js → actions-DtNZGZWf.js} +1 -1
- package/web/assets/{actions-D3tJgrUn.js → actions-JHsqbHpB.js} +1 -1
- package/web/assets/{actions-CZL47E9r.js → actions-izdZ2Mn4.js} +1 -1
- package/web/assets/{add-price-BpnICuHO.js → add-price-TdXAR3NW.js} +1 -1
- package/web/assets/{admin-CD8ViZ7D.js → admin-BpFv3eF5.js} +1 -1
- package/web/assets/{assign-0vMUDW_C.js → assign-DKRfmN7W.js} +1 -1
- package/web/assets/{attempts-CKlxkJuE.js → attempts-BfbYfiJa.js} +1 -1
- package/web/assets/browser-DF2vfpBa.js +1 -0
- package/web/assets/{change-payment-gAlRmJpv.js → change-payment-j5UC8_h0.js} +1 -1
- package/web/assets/{change-plan-C47wfWH8.js → change-plan-CtXvsIDw.js} +1 -1
- package/web/assets/{click-boundary-CafubiPp.js → click-boundary-Bi28Y0Fq.js} +1 -1
- package/web/assets/{connect-BHHzrwLA.js → connect-CXek4LAE.js} +1 -1
- package/web/assets/{copyable-QrCyyiou.js → copyable-CprMHdhV.js} +1 -1
- package/web/assets/{create-ke4FrPx1.js → create-B-Ubepl_.js} +1 -1
- package/web/assets/{create-DNar5UQD.js → create-BVt_sQ_7.js} +1 -1
- package/web/assets/{create-0PUtkJZY.js → create-BWviSWbC.js} +1 -1
- package/web/assets/{create-BJ1asdcy.js → create-C6jihslA.js} +1 -1
- package/web/assets/{create-C7GOgZZM.js → create-IaalYGmm.js} +1 -1
- package/web/assets/{create-Bgv5ux17.js → create-jzl1m8ZK.js} +1 -1
- package/web/assets/{credit-grant-item-list-CeDAM3qV.js → credit-grant-item-list-DQcvdSRs.js} +1 -1
- package/web/assets/{credit-overview-4zh0H02x.js → credit-overview-CPId2vzk.js} +1 -1
- package/web/assets/{currency-restrictions-BcEm8W45.js → currency-restrictions-Dsupz2ce.js} +1 -1
- package/web/assets/{currency-select-B4ieQBvv.js → currency-select-C8j7QQMP.js} +1 -1
- package/web/assets/{dayjs-DUTDpcNU.js → dayjs-DUNWtvju.js} +1 -1
- package/web/assets/{description-SnR5WxWT.js → description-BHxdy5I3.js} +1 -1
- package/web/assets/{detail-DNcp_u5S.js → detail-B17BN6kU.js} +1 -1
- package/web/assets/detail-BJ-hl5PK.js +10 -0
- package/web/assets/{detail-46aLUdJj.js → detail-BJEqTXDS.js} +1 -1
- package/web/assets/{detail-BQpDGZJQ.js → detail-BdC9VIc6.js} +1 -1
- package/web/assets/{detail-DbU3p040.js → detail-BkRkrKyw.js} +1 -1
- package/web/assets/{detail-DACnmls3.js → detail-BvcI9cB_.js} +1 -1
- package/web/assets/detail-C--ATvwm.js +24 -0
- package/web/assets/{detail-Cg505nKX.js → detail-CHJqYZ0W.js} +1 -1
- package/web/assets/{detail-B0IHl4MI.js → detail-CfvKZ7IV.js} +1 -1
- package/web/assets/{detail-Ct5QNBqu.js → detail-CmIweOLE.js} +1 -1
- package/web/assets/{detail-BXTsnQny.js → detail-D729Bgs6.js} +1 -1
- package/web/assets/{detail-C_Zdfa0y.js → detail-DD1YBtex.js} +1 -1
- package/web/assets/detail-DOcm4Kqg.js +15 -0
- package/web/assets/{detail-Bfnkg0A1.js → detail-DQj1mbhA.js} +1 -1
- package/web/assets/detail-DTXDMIR9.js +15 -0
- package/web/assets/{detail-CsGZMimg.js → detail-DUAJzKsu.js} +1 -1
- package/web/assets/{detail-BwH0DwAi.js → detail-De8PyTyx.js} +1 -1
- package/web/assets/{detail-B_lpOomD.js → detail-DqfxOHky.js} +1 -1
- package/web/assets/{detail-CMBRd4Ct.js → detail-Dzt5tfyZ.js} +1 -1
- package/web/assets/{detail-Tn2R5C8i.js → detail-H0dkKVyS.js} +1 -1
- package/web/assets/{detail-CyMhK5K_.js → detail-MgdgGj5J.js} +1 -1
- package/web/assets/{detail-DCTb8R7F.js → detail-WAmPM6yq.js} +1 -1
- package/web/assets/{detail-B-ceWfZr.js → detail-g6el9Fxj.js} +1 -1
- package/web/assets/did-Bqcz-NjH.js +1 -0
- package/web/assets/{drawer-form-DspWWj3x.js → drawer-form-CQjNFFWk.js} +1 -1
- package/web/assets/{edit-Bkj-OTJh.js → edit-DAU8AWzT.js} +1 -1
- package/web/assets/{editor-AmthipP2.js → editor-vZvxDUTl.js} +1 -1
- package/web/assets/{embed-rRKjDoHi.js → embed-ClYNqZbf.js} +1 -1
- package/web/assets/{filter-toolbar-DXGSTq57.js → filter-toolbar-VvmMATj0.js} +1 -1
- package/web/assets/{form-BmQlJZ84.js → form-4_MzglPj.js} +1 -1
- package/web/assets/{form-cX026J4G.js → form-AFzUvoFE.js} +1 -1
- package/web/assets/{form-B5WW-lS5.js → form-Bro99BjK.js} +1 -1
- package/web/assets/{form-CAPjlw7l.js → form-CnrBCyTJ.js} +1 -1
- package/web/assets/form-Cuvruf4H.js +16 -0
- package/web/assets/{gas-nyR96dB0.js → gas-kw2KMH1u.js} +1 -1
- package/web/assets/{generateCategoricalChart-BadryV3H.js → generateCategoricalChart-BCpuUeC_.js} +1 -1
- package/web/assets/{home-_eX1aim8.js → home-ZNJREzbw.js} +1 -1
- package/web/assets/{index-CbSXdD6E.js → index-ASk8vU2H.js} +1 -1
- package/web/assets/{index-ajD9Iotk.js → index-B4n6PvPu.js} +1 -1
- package/web/assets/{index-BarN7DfU.js → index-B4yaPb7B.js} +5 -5
- package/web/assets/{index-DSe7Dot_.js → index-BHwID_s4.js} +1 -1
- package/web/assets/index-BMcnd_jZ.js +1 -0
- package/web/assets/{index-BTfJ08JU.js → index-BRmN8ViQ.js} +1 -1
- package/web/assets/index-BdbLl6St.js +1 -0
- package/web/assets/{index-CCVDDX0c.js → index-BjKRyxNQ.js} +1 -1
- package/web/assets/index-BjLJQRKY.js +1 -0
- package/web/assets/index-BkNCPnTn.js +1 -0
- package/web/assets/index-BlAwTTmu.js +1 -0
- package/web/assets/{index-C136x0O2.js → index-BtWfmATr.js} +1 -1
- package/web/assets/{index-DNGmCIRP.js → index-C-5n472s.js} +1 -1
- package/web/assets/{index-CW8VfoJO.js → index-C3AP4jq0.js} +1 -1
- package/web/assets/{index-C-RT84yb.js → index-C3Rh1SaB.js} +1 -1
- package/web/assets/index-CDyxbCzc.js +1 -0
- package/web/assets/{index-SOzRg0yJ.js → index-CH_k9MVv.js} +1 -1
- package/web/assets/{index-XaFn2ySq.js → index-CKPfOW6M.js} +1 -1
- package/web/assets/{index-BQjlhCSt.js → index-CPFlZhA2.js} +1 -1
- package/web/assets/{index-Du0Ieh1F.js → index-CPyGjEd3.js} +2 -2
- package/web/assets/index-ChC-jsE2.js +1 -0
- package/web/assets/{index-D-bx9Kam.js → index-CiWvs3j9.js} +1 -1
- package/web/assets/{index-mn5Zdrtn.js → index-D6gv9jHh.js} +1 -1
- package/web/assets/{index-Cd_BD9TM.js → index-D7pWd60Z.js} +1 -1
- package/web/assets/{index-YG5oc8O3.js → index-DAen2-cr.js} +1 -1
- package/web/assets/{index-BRENdB5m.js → index-DNobX-Tr.js} +1 -1
- package/web/assets/{index-Kd_qCyRG.js → index-DY-g0BPU.js} +1 -1
- package/web/assets/{index-D0mynT6_.js → index-DZkpxY-C.js} +1 -1
- package/web/assets/{index-DcddP3R9.js → index-Dh9agU9O.js} +1 -1
- package/web/assets/{index-BBHMsIxJ.js → index-Dju8k6mq.js} +1 -1
- package/web/assets/{index-DeK5Pqjv.js → index-DwDNPqjF.js} +1 -1
- package/web/assets/{index-DEiuhiEo.js → index-Dze0CpfQ.js} +1 -1
- package/web/assets/{index-UYeD8rTJ.js → index-eDERHpkr.js} +1 -1
- package/web/assets/{index-BzABukCz.js → index-mgPU1lyd.js} +1 -1
- package/web/assets/{index-W2uZUlFs.js → index-olGOY5KB.js} +1 -1
- package/web/assets/{index-DoX0A-rP.js → index-oy7LrXGT.js} +1 -1
- package/web/assets/{index-qulrJQ4J.js → index-x7sBb6oM.js} +1 -1
- package/web/assets/{index.es-C8dcCHdW.js → index.es-C2Q6Owow.js} +1 -1
- package/web/assets/{info-card-BvIMFQo5.js → info-card-C9dRgztS.js} +1 -1
- package/web/assets/{info-metric-Dl4ZDm0Z.js → info-metric-ukWq8INi.js} +1 -1
- package/web/assets/{info-row-jI0h_hv4.js → info-row-CaPaNF4L.js} +1 -1
- package/web/assets/{info-row-group-CFuMWJf1.js → info-row-group-Cxo-4Gk5.js} +1 -1
- package/web/assets/{libphonenumber-Qs8PCdM-.js → libphonenumber-CTvobi0D.js} +1 -1
- package/web/assets/{link-CmPoIweR.js → link-DsltSF2Q.js} +1 -1
- package/web/assets/{list-CkHExntK.js → list-B2b-s8wM.js} +1 -1
- package/web/assets/{list-DLB_hd0Q.js → list-BzgF4i3i.js} +1 -1
- package/web/assets/{list-BdSkPjIa.js → list-Cd1O-aDi.js} +1 -1
- package/web/assets/{list-DaK9287Y.js → list-CvM46TsP.js} +1 -1
- package/web/assets/{list-CWMEf-_C.js → list-DtEjqlED.js} +1 -1
- package/web/assets/{list-DVFJwd_I.js → list-O_uCSLFq.js} +1 -1
- package/web/assets/{list-DghnUOc4.js → list-YNWVqjwW.js} +1 -1
- package/web/assets/{list-eFkvVlp5.js → list-ZaBapEXW.js} +1 -1
- package/web/assets/{metadata-BmQTVFku.js → metadata-_hV0ZaVh.js} +1 -1
- package/web/assets/{meter-event-B1JIhVpb.js → meter-event-CPVBpekF.js} +1 -1
- package/web/assets/{metrics-UvxyQbUF.js → metrics-DVPdwpyf.js} +1 -1
- package/web/assets/{overview-Cxc6WKba.js → overview-CGdVIJrJ.js} +1 -1
- package/web/assets/{overview-DrMaIptb.js → overview-CN59I5Sc.js} +1 -1
- package/web/assets/{past-due-CUXkxns0.js → past-due-C3PtU8uo.js} +1 -1
- package/web/assets/pay-XVdSNq__.js +4 -0
- package/web/assets/{payment-method-info-Bsf89VxV.js → payment-method-info-D_qR04xC.js} +1 -1
- package/web/assets/{preview-C-H8pGVw.js → preview-Bdtbh-xk.js} +1 -1
- package/web/assets/{preview-BifsgUGT.js → preview-F3lma170.js} +1 -1
- package/web/assets/{pricing-table-BUJdtkMq.js → pricing-table-Bt2WljzE.js} +1 -1
- package/web/assets/{pricing-table-B3QOaAB5.js → pricing-table-D9FGYBVa.js} +1 -1
- package/web/assets/{product-select-ChEyoJqJ.js → product-select-_72p-5lF.js} +1 -1
- package/web/assets/{recharge-BVT4USAO.js → recharge-CSlKshbU.js} +1 -1
- package/web/assets/{related-credit-grants-JV2ICsR5.js → related-credit-grants-DnKdAit6.js} +3 -3
- package/web/assets/{safe-did-address-CiG_V6Gy.js → safe-did-address-CRTPYo34.js} +1 -1
- package/web/assets/{source-data-viewer-i1q9wNIG.js → source-data-viewer-D1GShrs5.js} +1 -1
- package/web/assets/{status-CUVYrUIG.js → status-3Swm2gK5.js} +1 -1
- package/web/assets/subscription-BX00k6FU.js +1 -0
- package/web/assets/{subscription-DrnSPIfs.js → subscription-Bzeblscr.js} +1 -1
- package/web/assets/table-BN3WBnr3.js +1 -0
- package/web/assets/{tax-code-select-TS07I0rB.js → tax-code-select-j2arPbaE.js} +1 -1
- package/web/assets/{tax-utils-bPjALcVG.js → tax-utils-B8J0Kfnz.js} +1 -1
- package/web/assets/{uploader-CsQNHG4I.js → uploader-BLdAbLR6.js} +1 -1
- package/web/assets/{usage-records-DAUQMJAW.js → usage-records-BAwNs1y8.js} +1 -1
- package/web/assets/{util-DxXTXkeY.js → util-B8B3fsMa.js} +1 -1
- package/web/assets/{vendor-arcblock-BTCAQSUK.js → vendor-arcblock-D1drrE7q.js} +1 -1
- package/web/assets/{vendor-blocklet-DcLR2Cyf.js → vendor-blocklet-B67R14so.js} +2 -2
- package/web/index.html +1 -1
- package/web/assets/browser-DDv4_sgY.js +0 -1
- package/web/assets/detail-B8eOBVSQ.js +0 -15
- package/web/assets/detail-BO3zglCn.js +0 -15
- package/web/assets/detail-C1FupF1D.js +0 -24
- package/web/assets/detail-wU4wNf4s.js +0 -10
- package/web/assets/form-DD-EiA7W.js +0 -16
- package/web/assets/index-BhcoukR2.js +0 -1
- package/web/assets/index-BturOfxo.js +0 -1
- package/web/assets/index-CDVogp6E.js +0 -1
- package/web/assets/index-DcrGSDby.js +0 -1
- package/web/assets/index-Dybqd298.js +0 -1
- package/web/assets/index-EXZPddtw.js +0 -1
- package/web/assets/index-brUCsnBA.js +0 -1
- package/web/assets/pay-omLYkqRA.js +0 -4
- package/web/assets/subscription-BYz_k9dq.js +0 -1
- package/web/assets/table-BrtHemkA.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as y,w as v,B as r,a3 as a,bv as w,q as i,a7 as j,Y as m,O as C,be as _,bf as I}from"./vendor-mui-BXZut9Pz.js";import{V as N,P as k}from"./vendor-blocklet-
|
|
1
|
+
import{j as e,A as y,w as v,B as r,a3 as a,bv as w,q as i,a7 as j,Y as m,O as C,be as _,bf as I}from"./vendor-mui-BXZut9Pz.js";import{V as N,P as k}from"./vendor-blocklet-B67R14so.js";import{d as D,i as d,j as c,A as E,e as S}from"./index-B4yaPb7B.js";import{L as h}from"./vendor-react-BPknnnEA.js";import{C as T}from"./copyable-CprMHdhV.js";import{C as $}from"./link-DsltSF2Q.js";import{E as A}from"./list-CvM46TsP.js";import{I as n}from"./info-row-CaPaNF4L.js";import{I as l}from"./info-metric-ukWq8INi.js";import{S as x}from"./header-ivXuPt06.js";import{g as M}from"./util-B8B3fsMa.js";import{I as z}from"./info-row-group-Cxo-4Gk5.js";import{M as L}from"./list-B2b-s8wM.js";import"./table-BN3WBnr3.js";import"./lodash-B4Ozcv0x.js";const O=o=>S.get(`/api/meter-events/${o}`).then(s=>s.data);function ee(o){const{t:s}=N(),{isMobile:u}=D(),{loading:g,error:p,data:t}=k(()=>O(o.id));if(p)return e.jsx(y,{severity:"error",children:p.message});if(g||!t)return e.jsx(v,{});const f=b=>{switch(b){case"pending":return"info";case"requires_action":return"warning";case"requires_capture":return"warning";case"completed":return"success";case"processing":return"info";default:return"default"}};return e.jsxs(W,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(r,{children:[e.jsx(a,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(a,{direction:"row",onClick:()=>M("/admin/billing/meters"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(w,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(i,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:s("admin.meterEvents.title")})]})}),e.jsxs(r,{sx:{mt:4,mb:3,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(a,{direction:"column",sx:{gap:1},children:e.jsx(T,{text:o.id})}),e.jsxs(a,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(l,{label:s("common.status"),value:e.jsx(j,{label:t.status,color:f(t.status),size:"small"}),divider:!0}),e.jsx(l,{label:s("common.meterEvent"),value:e.jsx(h,{to:`/admin/billing/meters/${t.meter.id}`,style:{color:"inherit"},children:e.jsx(i,{sx:{color:"text.link"},children:t.meter.event_name})}),divider:!0}),t.subscription&&e.jsx(l,{label:s("common.subscription"),value:e.jsx(h,{to:`/admin/billing/${t.subscription.id}`,style:{color:"inherit"},children:e.jsx(i,{sx:{color:"text.link"},children:t.subscription.description||t.subscription.id})}),divider:!0}),e.jsx(l,{label:s("admin.meterEvent.creditConsumed"),value:`${d(t.credit_consumed,t.paymentCurrency?.decimal)} ${t.paymentCurrency?.symbol}`,divider:!0}),t.credit_pending!=="0"&&e.jsx(l,{label:s("admin.customer.creditGrants.pendingAmount"),value:e.jsx(i,{sx:{color:"error.main"},children:`${d(t.credit_pending,t.paymentCurrency?.decimal)} ${t.paymentCurrency?.symbol}`}),divider:!0})]})]}),e.jsx(m,{})]}),e.jsxs(a,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".meter-event-column-1":{minWidth:{xs:"100%",lg:"600px"}},".meter-event-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(r,{className:"meter-event-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(r,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(x,{title:s("admin.details")}),e.jsxs(z,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary"}},children:[e.jsx(n,{label:s("admin.meterEvent.usageValue"),value:`${d(t.payload.value,t.paymentCurrency?.decimal)} ${t.paymentCurrency?.symbol}`}),e.jsx(n,{label:s("admin.meterEvent.reportedAt"),value:c(t.timestamp*1e3)}),e.jsx(n,{label:s("common.customer"),value:e.jsx($,{customer:t.customer,size:u?"default":"small"})}),e.jsx(n,{label:s("common.createdAt"),value:c(t.created_at)}),e.jsx(n,{label:s("common.status"),value:e.jsxs(a,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(j,{label:t.status,color:f(t.status),size:"small",sx:{textTransform:"capitalize"}}),t.metadata?.last_error&&e.jsx(C,{title:e.jsx("pre",{style:{whiteSpace:"break-spaces"},children:JSON.stringify({error:t.metadata.last_error,failed_at:t.metadata.failed_at?c(t.metadata.failed_at*1e3):void 0,attempt_count:t.attempt_count,next_attempt:t.next_attempt?c(t.next_attempt*1e3):void 0},null,2)}),children:e.jsx(_,{fontSize:"small",color:"error"})})]})})]})]}),e.jsx(m,{}),e.jsxs(r,{className:"section",children:[e.jsx(i,{variant:"h3",className:"section-header",children:s("admin.creditTransactions.title")}),e.jsx(r,{className:"section-body",children:e.jsx(E,{customer_id:t.payload.customer_id,source:t.id,showAdminColumns:!0,mode:"dashboard"})})]}),e.jsx(m,{}),e.jsxs(r,{className:"section",children:[e.jsx(x,{title:s("admin.events.title")}),e.jsx(r,{className:"section-body",children:e.jsx(A,{features:{toolbar:!1},object_id:t.id})})]})]}),u&&e.jsx(m,{}),e.jsx(r,{className:"meter-event-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:t.metadata&&Object.keys(t.metadata).length>0&&e.jsxs(r,{className:"section",children:[e.jsx(x,{title:s("common.metadata.label")}),e.jsx(r,{className:"section-body",children:e.jsx(L,{data:t.metadata,handleEditMetadata:()=>{}})})]})})]})]})}const W=I(a)``;export{ee as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,q as c,O as x,be as b,a3 as g,bL as k,a1 as A,w as $,x as _,M,N as W,B as R}from"./vendor-mui-BXZut9Pz.js";import{V as N,P as d,G as h}from"./vendor-blocklet-
|
|
1
|
+
import{j as t,q as c,O as x,be as b,a3 as g,bL as k,a1 as A,w as $,x as _,M,N as W,B as R}from"./vendor-mui-BXZut9Pz.js";import{V as N,P as d,G as h}from"./vendor-blocklet-B67R14so.js";import{d as T,j as y,i as f,e as m}from"./index-B4yaPb7B.js";import{I as r}from"./info-metric-ukWq8INi.js";import{S as F}from"./status-3Swm2gK5.js";import{a as L}from"./vendor-react-BPknnnEA.js";const O=e=>m.get(`/api/subscriptions/${e}/upcoming`).then(n=>n.data),P=e=>m.get(`/api/subscriptions/${e}/payer-token`).then(n=>n.data),V=({customerId:e,subscriptionId:n})=>m.get(`/api/credit-grants/summary?customer_id=${e}&subscription_id=${n}`).then(i=>i.data);function K({subscription:e,showBalance:n=!0,mode:i="portal"}){const{t:a}=N(),o=e.paymentCurrency?.type==="credit",{data:s,loading:j}=d(()=>O(e.id)),u=L(),{isMobile:v}=T(),{data:l,loading:p}=d(()=>P(e.id),{ready:n}),{data:S}=d(()=>V({customerId:e.customer_id,subscriptionId:e.id}),{ready:o}),C=n&&["arcblock","ethereum","base"].includes(e.paymentMethod.type),I=new h(l?.token||"0").lt(new h(s?.amount||"0")),B=()=>{o||i!=="portal"||u(`/customer/subscription/${e.id}/recharge`)},w=()=>{const z=o?S?.[e.paymentCurrency.id]?.remainingAmount:l?.token;return j||p?t.jsx($,{size:16}):I&&!o&&i==="portal"?t.jsxs(_,{component:"a",color:"error",sx:{height:24,pt:0,pb:0,...v?{textAlign:"right",maxWidth:160}:{}},onClick:()=>u(`/customer/subscription/${e.id}/recharge`),children:[a("admin.subscription.insufficientBalance"),t.jsx(M,{sx:{fontSize:14}})]}):t.jsxs(g,{sx:{flexDirection:"row",alignItems:"center",gap:.5,fontSize:"16px",fontWeight:500,cursor:"pointer","&:hover":{color:"primary.main"}},onClick:B,children:[t.jsx(W,{src:e.paymentCurrency?.logo,sx:{width:16,height:16},alt:e.paymentCurrency?.name}),t.jsxs(R,{sx:{display:"flex",alignItems:"baseline"},children:[f(z,e.paymentCurrency.decimal),t.jsx(c,{sx:{fontSize:14,ml:.5},children:e.paymentCurrency.symbol})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(r,{label:a("common.status"),value:t.jsx(F,{subscription:e}),divider:!0}),e.status==="active"&&!e.cancel_at&&t.jsx(r,{label:a("admin.subscription.nextInvoice"),value:y(e.current_period_end*1e3),divider:!0}),["active","trialing"].includes(e.status)&&s?.amount&&s.amount!=="0"&&t.jsx(r,{label:t.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:.5,fontSize:14,fontWeight:500},children:[a("admin.subscription.nextInvoiceAmount"),t.jsx(x,{title:a("admin.subscription.nextInvoiceAmountTip"),placement:"top",arrow:!0,children:t.jsx(b,{fontSize:"small",sx:{color:"text.secondary",cursor:"pointer",fontSize:"16px"}})})]}),value:`${f(s.amount,e.paymentCurrency.decimal)} ${e.paymentCurrency.symbol} (${a("common.estimated")})`,divider:!0}),C&&["active","trialing"].includes(e.status)&&t.jsx(r,{label:t.jsxs(g,{direction:"row",spacing:1,sx:{alignItems:"center",fontWeight:500},children:[t.jsx(c,{sx:{fontWeight:500,fontSize:14},children:a("admin.subscription.currentBalance")}),t.jsx(x,{title:t.jsxs(c,{sx:{fontFamily:"monospace",fontSize:"13px"},children:[a("admin.subscription.paymentAddress"),":",p?t.jsx(A,{width:120}):l?.paymentAddress]}),placement:"top",arrow:!0,children:t.jsx(k,{sx:{fontSize:"16px",color:"text.secondary",cursor:"pointer","&:hover":{color:"primary.main"},display:{xs:"none",md:"block"}}})})]}),value:w(),divider:!0}),e.status==="canceled"&&e.canceled_at&&t.jsx(r,{label:a("admin.subscription.cancel.done"),value:y(e.canceled_at*1e3),divider:!0})]})}export{K as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as M,e as f,K as pt,u as Jt,j as l,a1 as ee,B as Y,a0 as Zt,$ as V,Y as Be,q as T,c8 as qn,a8 as Gn,a9 as Xn,aH as Kn,I as _e,c9 as Qn,aQ as St,aT as Pt,ad as jt,ca as Un,cb as Jn,cc as Zn,cd as er,ce as tr,cf as nr,ah as Z,aF as rr,a3 as _,x as Mt,cg as ar,bq as ir,bg as oe,N as Ze,M as Ct,bj as or,aV as sr,aW as cr,aN as lr,aM as et}from"./vendor-mui-BXZut9Pz.js";import{cs as ur,c8 as De,bp as Et,V as dr,B as H,Y as hr,J as fr,P as tt,a7 as mr,G as gr}from"./vendor-blocklet-
|
|
1
|
+
import{r as M,e as f,K as pt,u as Jt,j as l,a1 as ee,B as Y,a0 as Zt,$ as V,Y as Be,q as T,c8 as qn,a8 as Gn,a9 as Xn,aH as Kn,I as _e,c9 as Qn,aQ as St,aT as Pt,ad as jt,ca as Un,cb as Jn,cc as Zn,cd as er,ce as tr,cf as nr,ah as Z,aF as rr,a3 as _,x as Mt,cg as ar,bq as ir,bg as oe,N as Ze,M as Ct,bj as or,aV as sr,aW as cr,aN as lr,aM as et}from"./vendor-mui-BXZut9Pz.js";import{cs as ur,c8 as De,bp as Et,V as dr,B as H,Y as hr,J as fr,P as tt,a7 as mr,G as gr}from"./vendor-blocklet-B67R14so.js";import{a as yr,e as nt,q as ct,i as rt,a3 as pr}from"./index-B4yaPb7B.js";import{L as Fe}from"./vendor-react-BPknnnEA.js";import{w as Re,i as Le,a as vr,u as br,b as xr,c as wr,d as U,e as Dr,h as Or,j as en,k as tn,l as nn,C as rn,m as fe,L as Me,n as ze,o as at,A as kr,p as be,q as Sr,r as Pr,s as jr,t as Mr,G as Cr,v as At,x as Tt,D as Er,g as Ar,X as an,Y as on,f as Tr,T as Nr,y as Wr}from"./generateCategoricalChart-BCpuUeC_.js";import{h as Nt,s as Rr}from"./util-B8B3fsMa.js";import{C as _r}from"./currency-select-C8j7QQMP.js";function Ie(e){"@babel/helpers - typeof";return Ie=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ie(e)}function Wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function $e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Wt(Object(n),!0).forEach(function(r){Ir(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wt(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Ir(e,t,n){return t=Yr(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yr(e){var t=Fr(e,"string");return Ie(t)=="symbol"?t:t+""}function Fr(e,t){if(Ie(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Ie(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Lr(e,t){return Br(e)||Hr(e,t)||$r(e,t)||zr()}function zr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $r(e,t){if(e){if(typeof e=="string")return Rt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Rt(e,t)}}function Rt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Hr(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,a,i,o,d=[],u=!0,h=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(u=(r=i.call(n)).done)&&(d.push(r.value),d.length!==t);u=!0);}catch(c){h=!0,a=c}finally{try{if(!u&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(h)throw a}}return d}}function Br(e){if(Array.isArray(e))return e}var Vr=M.forwardRef(function(e,t){var n=e.aspect,r=e.initialDimension,a=r===void 0?{width:-1,height:-1}:r,i=e.width,o=i===void 0?"100%":i,d=e.height,u=d===void 0?"100%":d,h=e.minWidth,c=h===void 0?0:h,m=e.minHeight,g=e.maxHeight,p=e.children,O=e.debounce,b=O===void 0?0:O,y=e.id,w=e.className,P=e.onResize,j=e.style,k=j===void 0?{}:j,x=M.useRef(null),C=M.useRef();C.current=P,M.useImperativeHandle(t,function(){return Object.defineProperty(x.current,"current",{get:function(){return console.warn("The usage of ref.current.current is deprecated and will no longer be supported."),x.current},configurable:!0})});var z=M.useState({containerWidth:a.width,containerHeight:a.height}),N=Lr(z,2),$=N[0],q=N[1],W=M.useCallback(function(X,Q){q(function(F){var v=Math.round(X),L=Math.round(Q);return F.containerWidth===v&&F.containerHeight===L?F:{containerWidth:v,containerHeight:L}})},[]);M.useEffect(function(){var X=function(ve){var ke,Se=ve[0].contentRect,Pe=Se.width,je=Se.height;W(Pe,je),(ke=C.current)===null||ke===void 0||ke.call(C,Pe,je)};b>0&&(X=ur(X,b,{trailing:!0,leading:!1}));var Q=new ResizeObserver(X),F=x.current.getBoundingClientRect(),v=F.width,L=F.height;return W(v,L),Q.observe(x.current),function(){Q.disconnect()}},[W,b]);var te=M.useMemo(function(){var X=$.containerWidth,Q=$.containerHeight;if(X<0||Q<0)return null;Re(Le(o)||Le(u),`The width(%s) and height(%s) are both fixed numbers,
|
|
3
3
|
maybe you don't need to use a ResponsiveContainer.`,o,u),Re(!n||n>0,"The aspect(%s) must be greater than zero.",n);var F=Le(o)?X:o,v=Le(u)?Q:u;n&&n>0&&(F?v=F/n:v&&(F=v*n),g&&v>g&&(v=g)),Re(F>0||v>0,`The width(%s) and height(%s) of chart should be greater than 0,
|
|
4
4
|
please check the style of container, or the props width(%s) and height(%s),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as g,j as t,B as n,q as o,$ as s,Y as h,O as m,ai as l,b4 as u,x as d,bS as f,cs as b,ct as j,cu as y,bW as v,cv as k,cw as w,cx as S}from"./vendor-mui-BXZut9Pz.js";import{V as C,$ as z}from"./vendor-blocklet-
|
|
1
|
+
import{r as g,j as t,B as n,q as o,$ as s,Y as h,O as m,ai as l,b4 as u,x as d,bS as f,cs as b,ct as j,cu as y,bW as v,cv as k,cw as w,cx as S}from"./vendor-mui-BXZut9Pz.js";import{V as C,$ as z}from"./vendor-blocklet-B67R14so.js";import{a as O}from"./vendor-react-BPknnnEA.js";const W=[{title:"integrations.features.products.title",description:"integrations.features.products.intro",icon:t.jsx(f,{sx:{fontSize:32,color:"text.lighter"}}),path:"/admin/products"},{title:"integrations.features.paymentLinks.title",description:"integrations.features.paymentLinks.intro",icon:t.jsx(b,{sx:{fontSize:32,color:"text.lighter"}}),path:"/admin/products/links"},{title:"integrations.features.pricingTables.title",description:"integrations.features.pricingTables.intro",icon:t.jsx(j,{sx:{fontSize:32,color:"text.lighter"}}),path:"/admin/products/pricing-tables"}],I=[{title:"integrations.features.metering.title",description:"integrations.features.metering.intro",icon:t.jsx(y,{sx:{fontSize:32,color:"text.lighter"}}),dialog:"metering",doc:{url:"https://www.arcblock.io/blog/en/payment-kit-enhanced-credit-management"}},{title:"integrations.features.promotions.title",description:"integrations.features.promotions.intro",icon:t.jsx(v,{sx:{fontSize:32,color:"text.lighter"}}),path:"/admin/products/coupons",doc:{url:"https://www.arcblock.io/content/blog/en/payment-kit-promotion-code-discounts-support"}},{title:"integrations.features.donate.title",description:"integrations.features.donate.intro",icon:t.jsx(k,{sx:{fontSize:32,color:"text.lighter"}}),path:"/integrations/donations"},{title:"integrations.features.paymentMethods.title",description:"integrations.features.paymentMethods.intro",icon:t.jsx(w,{sx:{fontSize:32,color:"text.lighter"}}),path:"/admin/settings/payment-methods"},{title:"integrations.features.api.title",description:"integrations.features.api.intro",icon:t.jsx(S,{sx:{fontSize:32,color:"text.lighter"}}),path:"https://www.staging.arcblock.io/content/docs/payment-kit-sdk",external:!0}];function F(){const{t:i}=C(),a=O(),[x,r]=g.useState(!1),c=e=>{if(e.dialog==="metering"){r(!0);return}e.external?window.open(e.path,"_blank"):a(e.path)};return t.jsxs(n,{children:[t.jsx(n,{sx:{mb:4},children:t.jsx(o,{variant:"body2",sx:{color:"text.secondary",mb:2},children:i("common.welcomeDesc")})}),t.jsxs(o,{variant:"h3",gutterBottom:!0,sx:{mb:2},children:[i("integrations.basicFeatures")," 🚀"]}),t.jsx(s,{container:!0,spacing:2,sx:{mb:4,maxWidth:1200},children:W.map(e=>t.jsx(s,{size:{xs:12,sm:6,md:4},children:t.jsxs(n,{className:"base-card",onClick:()=>c(e),sx:{height:"100%",cursor:"pointer","&:hover":{boxShadow:2}},children:[t.jsxs(n,{sx:{mb:1},children:[e.icon,t.jsx(o,{variant:"h4",sx:{mt:1.5},children:i(e.title)})]}),t.jsx(o,{variant:"body2",sx:{color:"text.secondary"},children:i(e.description)})]})},e.path))}),t.jsx(h,{sx:{my:4}}),t.jsxs(o,{variant:"h3",gutterBottom:!0,sx:{mb:2},children:[i("integrations.advancedFeatures")," 🔥"]}),t.jsx(s,{container:!0,spacing:2,sx:{maxWidth:1200},children:I.map(e=>t.jsx(s,{size:{xs:12,sm:6,md:4},children:t.jsxs(n,{className:"base-card",onClick:()=>c(e),sx:{height:"100%",cursor:"pointer","&:hover":{boxShadow:2}},children:[t.jsxs(n,{sx:{mb:1},children:[e.icon,t.jsxs(n,{sx:{display:"flex",alignItems:"center",mt:1.5},children:[t.jsx(o,{variant:"h4",children:i(e.title)}),e.doc?.url&&t.jsx(m,{title:i("integrations.viewDocs"),placement:"top",children:t.jsx(l,{href:e.doc.url,target:"_blank",rel:"noopener",onClick:p=>p.stopPropagation(),sx:{display:"flex",alignItems:"center",ml:1,color:"text.secondary","&:hover":{color:"primary.main"}},children:t.jsx(u,{fontSize:"small",sx:{cursor:"pointer"}})})})]})]}),t.jsx(o,{variant:"body2",sx:{color:"text.secondary"},children:i(e.description)})]})},e.path))}),t.jsxs(z,{open:x,onClose:()=>r(!1),maxWidth:"sm",fullWidth:!0,className:"base-dialog",title:i("integrations.features.metering.dialog.title"),actions:t.jsxs(n,{sx:{display:"flex",gap:2},children:[t.jsx(d,{onClick:()=>r(!1),children:i("common.cancel")}),t.jsx(d,{onClick:()=>a("/admin/billing/meters"),variant:"contained",children:i("common.goToConfigure")})]}),children:[t.jsx(o,{variant:"body2",sx:{color:"text.secondary",mb:3},children:i("integrations.features.metering.dialog.description")}),t.jsx(n,{component:"ol",sx:{pl:0,mb:3,listStyle:"none",counterReset:"step-counter"},children:["step1","step2","step3","step4"].map(e=>t.jsx(n,{component:"li",sx:{mb:3,pl:3,position:"relative",counterIncrement:"step-counter","&::before":{content:"counter(step-counter)",position:"absolute",left:0,top:0,width:24,height:24,borderRadius:"50%",backgroundColor:"primary.main",color:"white",fontSize:"12px",fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"}},children:t.jsxs(n,{sx:{ml:.5},children:[t.jsx(o,{variant:"subtitle2",sx:{fontWeight:600,mb:.5},children:i(`integrations.features.metering.dialog.steps.${e}.title`)}),t.jsx(o,{variant:"body2",sx:{color:"text.secondary",lineHeight:1.5},children:i(`integrations.features.metering.dialog.steps.${e}.description`)})]})},e))}),t.jsx(n,{sx:{p:2,backgroundColor:"action.hover",borderRadius:1,border:"1px solid",borderColor:"divider"},children:t.jsx(l,{href:"https://www.staging.arcblock.io/content/docs/payment-kit-sdk/en/payment-kit-sdk-core-concepts-credit-billing",target:"_blank",rel:"noopener",underline:"hover",sx:{color:"primary.main",fontWeight:500,display:"flex",alignItems:"center",gap:.5},children:i("integrations.features.metering.dialog.docText")})})]})]})}export{F as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as i,j as e,A as l,w as B,a3 as r,bv as O,q as A,B as m,x as D,bf as R}from"./vendor-mui-BXZut9Pz.js";import{V as _,P as z,Z as H,F as L}from"./vendor-blocklet-
|
|
1
|
+
import{r as i,j as e,A as l,w as B,a3 as r,bv as O,q as A,B as m,x as D,bf as R}from"./vendor-mui-BXZut9Pz.js";import{V as _,P as z,Z as H,F as L}from"./vendor-blocklet-B67R14so.js";import{u as T,a as U,k as g,O as q,m as F,l as N,x as W,e as Q}from"./index-B4yaPb7B.js";import{b as V}from"./vendor-react-BPknnnEA.js";import{l as Z}from"./lodash-B4Ozcv0x.js";import{S as G}from"./header-ivXuPt06.js";import{g as j}from"./util-B8B3fsMa.js";import{u as J}from"./browser-DF2vfpBa.js";const K=()=>Q.get("/api/customers/me").then(s=>s.data);function ne(){const{t:s,locale:v}=_(),{events:b}=T(),{connect:n,session:P}=U(),[u]=V(),w=J(),[d,p]=i.useState(!1),[f,a]=i.useState(!1),{loading:S,error:x,data:h,runAsync:C}=z(K);if(i.useEffect(()=>{b.on("switch-did",()=>{C().catch(console.error)})},[]),x)return e.jsx(l,{severity:"error",children:g(x)});if(S)return e.jsx(B,{});if(!h)return e.jsx(l,{sx:{mt:3},severity:"info",children:s("payment.customer.empty")});const t=u.get("subscription")||"",c=u.get("currency")||"",I=()=>{t&&c?n.open({containerEl:void 0,saveConnect:!1,action:"collect-batch",locale:v,prefix:L(N(),"/api/did"),extraParams:{subscriptionId:t,currencyId:c},messages:{scan:s("common.connect.defaultScan"),title:s("payment.customer.invoice.payBatch"),confirm:s("common.connect.confirm")},onSuccess:()=>{n.close()},onClose:()=>{n.close()},onError:o=>{H.error(g(o))}}):a(!0)},k=(o,E)=>{if(Z.isEmpty(o)||o?.count===0){if(p(!1),E?.count>0){const y=W(window.location.href)?.referer;y?window.location.replace(y):j("/customer")}return}p(!0)};return e.jsxs(r,{direction:"column",spacing:3,sx:{my:2},children:[e.jsx(r,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between"},children:w?e.jsx(m,{}):e.jsxs(r,{direction:"row",onClick:()=>j("/customer"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(O,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(A,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:s("common.previous")})]})}),e.jsxs(M,{direction:"column",spacing:3,children:[d&&e.jsx(l,{severity:"error",children:s("payment.customer.pastDue.warning")}),f&&e.jsx(q,{customerId:P.user.did,subscriptionId:t,onPaid:()=>{a(!1)},successToast:!1,dialogProps:{open:f,onClose:()=>a(!1)},detailLinkOptions:{enabled:!1}}),e.jsxs(m,{className:"section",children:[e.jsx(G,{title:s("payment.customer.pastDue.invoices"),mb:0,children:d&&e.jsx(D,{size:"small",variant:"contained",color:"primary",onClick:I,children:s("admin.subscription.batchPay.button")})}),e.jsx(m,{className:"section-body",children:e.jsx(F,{customer_id:h.id,subscription_id:t,currency_id:c,pageSize:10,status:"uncollectible",target:"_blank",action:"pay",type:"table",onTableDataChange:k,relatedSubscription:!0})})]})]})]})}const M=R(r)`
|
|
2
2
|
a {
|
|
3
3
|
text-decoration: underline;
|
|
4
4
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as p,j as t,u as We,B as _,ah as le,p as Dn,a7 as Ge,a3 as M,N as Ce,bO as en,q as g,a1 as Ne,aV as Mn,i as mt,Q as zn,bn as tn,I as Ve,bo as Nn,a2 as nn,bp as rn,aY as Fn,w as ft,bP as sn,x as Ee,bQ as $n,L as on,bj as Wn,bR as xt,bS as On,bT as Pt,be as Un,aZ as ht,o as an,A as Ln,bs as qn,bt as Bn,bU as Hn,bV as Vn,aT as nt,ad as rt,b4 as Tt,Y as lt,O as Qn,bW as At,M as Kn,bX as Dt,F as Gn,bC as Yn}from"./vendor-mui-BXZut9Pz.js";import{a3 as W,aN as Xn,A as Zn,U as Jn,G as z,H as Te,L as Xe,ab as gt,Z as Fe,V as _e,P as ut,W as er,F as cn}from"./vendor-blocklet-B67R14so.js";import{ae as te,af as ee,ag as tr,ah as nr,ai as rr,aj as ir,ak as sr,al as Se,am as Ie,an as yt,ao as or,ap as ar,d as Ze,aq as Ye,ar as He,as as Ae,at as $e,au as ln,av as he,aw as cr,ax as un,a as dn,e as dt,ay as Be,i as lr,a8 as Re,a3 as ur,ad as dr,R as pr,az as mr,aA as pn,aa as fr,aB as xr,aC as hr,aD as gr,U as yr,O as br,l as mn,a0 as _r,aE as Sr,I as Mt,aF as wr,aG as fn,aH as zt,aI as vr}from"./index-B4yaPb7B.js";import{b as kr}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 jr(e){const n=e.line_items||[];if(n.length===0)return null;const r=n[0],s=r.upsell_price||r.price,i=s?.product;if(!i)return null;const o=s?.recurring,c=e.mode==="subscription"?"subscription":"payment",a={day:"daily",week:"weekly",month:"monthly",year:"yearly"};return{name:i.name||"",description:i.description||"",images:i.images||[],features:(i.features||[]).map(l=>({name:l.name||"",icon:l.icon})),billing:{mode:c,interval:o?.interval||null,intervalCount:o?.interval_count||1,displayInterval:o?a[o.interval]||o.interval:""},metadata:i.metadata||{}}}function Cr(e){const n=e.subscription_data;return!n&&e.mode==="payment"?null:{mode:e.mode||"payment",showStake:!n?.no_stake,confirmMessage:""}}function Ir(e){const n=e.metadata,r=n?.page_info,s=n?.show_product_features??r?.show_product_features;return{formPurposeDescription:r?.form_purpose_description,showProductFeatures:`${s}`=="true"}}function Er(e){const[n,r]=p.useState(!0),[s,i]=p.useState(null),[o,c]=p.useState(null),a=p.useRef(null),l=p.useRef(!0),u=p.useRef(null),f=e?.startsWith("plink_"),d=W(async()=>{if(!f)return e;if(u.current)return u.current;const{data:S}=await te.post(ee.START_PAYMENT_LINK(e)),C=S?.checkoutSession?.id;if(!C)throw new Error("Failed to start payment link session");return u.current=C,C}),m=W(async(S=!1)=>{if(a.current&&a.current.abort(),a.current=new AbortController,!e){r(!1),i("Session ID is required");return}try{S||r(!0),i(null);const C=await d(),R=S?`${ee.RETRIEVE_SESSION(C)}?forceRefresh=1`:ee.RETRIEVE_SESSION(C),{data:y}=await te.get(R,{signal:a.current.signal});if(!l.current)return;const E=y?.checkoutSession;if(E){if(E.status!=="complete"&&E.expires_at&&E.expires_at<=Math.round(Date.now()/1e3)){i("SESSION_EXPIRED"),r(!1);return}if(!E.line_items?.length){i("EMPTY_LINE_ITEMS"),r(!1);return}}if(y?.stopAcceptingOrders&&E?.status!=="complete"){i("STOP_ACCEPTING_ORDERS"),r(!1);return}c(y),r(!1)}catch(C){if(!l.current)return;const{isCancelled:R,message:y}=pt(C);if(R)return;i(y||"Failed to load checkout session"),r(!1)}}),b=p.useCallback(async(S=!1)=>{await m(S)},[m]);p.useEffect(()=>(l.current=!0,m(),()=>{l.current=!1,a.current&&a.current.abort()}),[e]);const h=o?.checkoutSession,x=u.current||(f?"":e);let v=null;s==="SESSION_EXPIRED"?v="SESSION_EXPIRED":s==="EMPTY_LINE_ITEMS"?v="EMPTY_LINE_ITEMS":s==="STOP_ACCEPTING_ORDERS"&&(v="STOP_ACCEPTING_ORDERS");const F=h?.line_items?.reduce((S,C)=>S+(C?.price?.product?.vendor_config?.length||0),0)||0;return{isLoading:n,error:s,errorCode:v,refresh:b,setSessionData:c,sessionData:o,resolvedSessionId:x,vendorCount:F,product:h?jr(h):null,subscription:h?Cr(h):null,pageInfo:h?Ir(h):null}}function Rr(e){const n=[];return e.forEach(r=>{(r.payment_currencies||[]).forEach(i=>{const o={...i,method:{id:r.id,name:r.name,type:r.type}};n.push(o)})}),n}function Pr(e){return(e?.connectedAccounts||e?.extraConfigs?.connectedAccounts||[]).some(r=>r.provider==="wallet")}const Nt="payment-currency-preference";function xn(e){return e?`${Nt}:${e}`:Nt}function Ft(e,n){const r=new Set(n.flatMap(i=>(i.payment_currencies||[]).map(o=>o.id)).filter(Boolean)),s=i=>!!i&&r.has(i);if(e?.discounts?.length&&s(e.currency_id))return e.currency_id;if(typeof window<"u"){try{const o=new URLSearchParams(window.location.search),c=o.get("currencyId")||o.get("currency_id");if(s(c))return c}catch{}const i=e?.user;if(i&&!Pr(i)){const c=n.find(a=>a.type==="stripe")?.payment_currencies?.[0];if(s(c?.id))return c?.id}try{const o=e?.user?.did,c=localStorage.getItem(xn(o));if(s(c))return c}catch{}}return s(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 s of e)for(const i of s.payment_currencies||[])if(i.id===n)return{method:s,currency:i};const r=e[0];return{method:r||null,currency:r?.payment_currencies?.[0]||null}}function Tr(e,n){const r=new Map;return e.forEach(s=>{const i=s.type==="stripe"?"stripe":"crypto";r.has(i)||r.set(i,{currencies:[],active:!1});const o=r.get(i),c=(s.payment_currencies||[]).map(a=>({...a,method:{id:s.id,name:s.name,type:s.type}}));o.currencies.push(...c),s===n&&(o.active=!0)}),Array.from(r.entries()).map(([s,i])=>({type:s,label:s==="stripe"?"Card":"Crypto",currencies:i.currencies,active:i.active}))}function Ar(e,n,r,s){const i=p.useMemo(()=>e?.paymentMethods||[],[e?.paymentMethods]),o=e?.checkoutSession,[c,a]=p.useState(()=>Ft(o,i)),[l,u]=p.useState(!1),f=p.useRef(null);p.useEffect(()=>{o&&!c&&a(Ft(o,i))},[o?.id]);const{method:d,currency:m}=p.useMemo(()=>$t(i,c),[i,c]),b=p.useMemo(()=>Rr(i),[i]),h=d?.type==="stripe",x=d?.type!=="stripe"&&d?.type!==void 0,v=m?.type==="credit",F=p.useMemo(()=>Tr(i,d),[i,d]),S=W(async y=>{const E=i.find($=>y==="stripe"?$.type==="stripe":$.type!=="stripe");if(!E)return;const N=E.payment_currencies?.[0];N&&await C(N.id)}),C=W(async y=>{if(o?.status==="complete")return;const{method:E}=$t(i,y);if(!(!E||!n)){u(!0);try{const{data:N}=await te.put(ee.SWITCH_CURRENCY(n),{currency_id:y,payment_method_id:E.id});a(y);try{localStorage.setItem(xn(o?.user?.did),y)}catch{}e&&s?s({...e,checkoutSession:N,quotes:void 0}):await r(!0)}catch(N){console.error("Failed to switch currency:",je(N)),o?.currency_id&&a(o.currency_id)}finally{u(!1)}}});p.useEffect(()=>{if(!o?.id||!c||!i.length||f.current===o.id)return;f.current=o.id;const y=o.currency_id;o.status!=="complete"&&y&&y!==c&&C(c)},[o?.id,c,i.length]);const R=p.useMemo(()=>!d||d.type!=="stripe"?null:{publishableKey:d.settings?.stripe?.publishable_key||null,clientSecret:e?.paymentIntent?.client_secret||null,status:"idle"},[d,e?.paymentIntent]);return{current:d,currency:m,available:i,currencies:b,isStripe:h,isCrypto:x,isCredit:v,switching:l,setType:S,types:F,setCurrency:C,stripe:R}}const ve=/^\d{4}$/,ke=/^\d{5}$/,Me=/^\d{6}$/,Dr={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:ke,JP:/^\d{3}-?\d{4}$/,FR:/^\d{2}[ ]?\d{3}$/,AU:ve,IT:ke,CH:ve,AT:ve,ES:ke,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:ke,KR:ke,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:ke,SK:/^\d{3}[ ]?\d{2}$/,SI:ve,TR:ke,IL:ke,ZA:ve,MX:ke,AR:/^([A-HJ-NP-Z])?\d{4}([A-Z]{3})?$/i,CL:/^\d{7}$/,CO:Me,NZ:ve,MY:ke,TH:ke,PH:ve,ID:ke,VN:Me};function Mr(e,n){if(!e)return!0;try{const r=n?.toUpperCase();if(!r)return!1;const s=Dr[r];return!s||s.test(e)}catch{return!1}}function Pe(e,n,r="en"){if(!n||!n[e])return{};const s=n[e],i={};return s.pattern&&(i.pattern={value:new RegExp(s.pattern),message:s.pattern_message?.[r]||"Invalid format"}),i}let it=null;async function zr(){if(!it){const e=await Zn(()=>import("./libphonenumber-CTvobi0D.js").then(r=>r.l),[]),n=(e.default||e)?.PhoneNumberUtil;if(!n)throw new Error("PhoneNumberUtil not found");it=n.getInstance()}return it}const Nr=/^[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4,6}$/im;async function Fr(e){if(!e||e.trim()==="")return!1;try{const n=await zr(),r=n.parseAndKeepRawInput(e);return n.isValidNumber(r)}catch{return Nr.test(e)}}function $r(e){return!e||e.trim()===""?!1:Xn(e)}async function st(e,n){const r={},{phoneEnabled:s,addressMode:i,fieldValidation:o,locale:c="en"}=n;if(!e)return{valid:!1,errors:{customer_name:"Required"}};const a=e.customer_name;if(!a||a.trim()==="")r.customer_name="Required";else{const x=Pe("customer_name",o,c);x.pattern&&!x.pattern.value.test(a)&&(r.customer_name=x.pattern.message)}const l=e.customer_email;if(!l||!$r(l))r.customer_email=l?"Invalid email":"Required";else{const x=Pe("customer_email",o,c);x.pattern&&!x.pattern.value.test(l)&&(r.customer_email=x.pattern.message)}if(s){const x=e.customer_phone;if(!x||x.trim()==="")r.customer_phone="Required";else if(!await Fr(x))r.customer_phone="Invalid phone number";else{const v=Pe("customer_phone",o,c);v.pattern&&!v.pattern.value.test(x)&&(r.customer_phone=v.pattern.message)}}const u=e.billing_address,f=u?.postal_code,d=u?.country,m=u?.state,b=u?.line1,h=u?.city;if(!f)r["billing_address.postal_code"]="Required";else if(!Mr(f,d))r["billing_address.postal_code"]="Invalid postal code";else{const x=Pe("billing_address.postal_code",o,c);x.pattern&&!x.pattern.value.test(f)&&(r["billing_address.postal_code"]=x.pattern.message)}if(!m)r["billing_address.state"]="Required";else{const x=Pe("billing_address.state",o,c);x.pattern&&!x.pattern.value.test(m)&&(r["billing_address.state"]=x.pattern.message)}if(i==="required"){if(d||(r["billing_address.country"]="Required"),!b)r["billing_address.line1"]="Required";else{const x=Pe("billing_address.line1",o,c);x.pattern&&!x.pattern.value.test(b)&&(r["billing_address.line1"]=x.pattern.message)}if(!h)r["billing_address.city"]="Required";else{const x=Pe("billing_address.city",o,c);x.pattern&&!x.pattern.value.test(h)&&(r["billing_address.city"]=x.pattern.message)}}return{valid:Object.keys(r).length===0,errors:r}}function Wr(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 hn(e,n,r){const s=n.split(".");if(s.length===1)return{...e,[n]:r};const[i,...o]=s;return{...e,[i]:hn(e[i]||{},o.join("."),r)}}function Or(e,n,r){const s=e?.checkoutSession,i=e?.customer,o=p.useMemo(()=>Wr(s),[s?.id]),[c,a]=p.useState(()=>Wt(s,i)),[l,u]=p.useState({}),[f,d]=p.useState({}),[m,b]=p.useState(!1);p.useEffect(()=>{s&&!m&&a(Wt(s,i))},[s?.id]),p.useEffect(()=>{(n||r)&&a(R=>({...R,...n&&{payment_currency:n},...r&&{payment_method:r}}))},[n,r]),p.useEffect(()=>{if(!s||m||s.status==="complete")return;(async()=>{try{const{data:y}=await te.get(`${ee.CUSTOMER_ME}?fallback=1&skipSummary=1`);y&&(b(!0),a(E=>({...E,customer_name:E.customer_name||y.name||"",customer_email:E.customer_email||y.email||"",customer_phone:E.customer_phone||y.phone||"",billing_address:{...E.billing_address,country:E.billing_address?.country||y.address?.country||"",state:E.billing_address?.state||y.address?.state||"",city:E.billing_address?.city||y.address?.city||"",line1:E.billing_address?.line1||y.address?.line1||"",line2:E.billing_address?.line2||y.address?.line2||"",postal_code:E.billing_address?.postal_code||y.address?.postal_code||""}})))}catch{b(!0)}})()},[s?.id]);const h=W((R,y)=>{a(E=>hn(E,R,y)),d(E=>({...E,[R]:!0}))}),x=W(()=>({phoneEnabled:!!s?.phone_number_collection?.enabled,addressMode:s?.billing_address_collection,fieldValidation:s?.metadata?.page_info?.field_validation})),v=W(async()=>{const R=await st(c,x());return u(R.errors),R.valid}),F=W(async()=>(await st(c,x())).valid),S=W(async R=>{const y=await st(c,x());u(E=>{const N={...E};return y.errors[R]?N[R]=y.errors[R]:delete N[R],N})}),C=W(async()=>{try{const{data:R}=await te.get(`${ee.CUSTOMER_ME}?fallback=1&skipSummary=1`);R&&(b(!0),a(y=>({...y,customer_name:R.name||y.customer_name||"",customer_email:R.email||y.customer_email||"",customer_phone:R.phone||y.customer_phone||"",billing_address:{...y.billing_address,country:R.address?.country||y.billing_address?.country||"",state:R.address?.state||y.billing_address?.state||"",city:R.address?.city||y.billing_address?.city||"",line1:R.address?.line1||y.billing_address?.line1||"",line2:R.address?.line2||y.billing_address?.line2||"",postal_code:R.address?.postal_code||y.billing_address?.postal_code||""}})))}catch{b(!0)}});return{fields:o,values:c,onChange:h,errors:l,touched:f,validate:v,checkValid:F,validateField:S,prefetched:m,refetchCustomer:C}}const Ur=300*1e3,Ot=[2e3,5e3,1e4];function Lr(e){return e<5e3?500:e<3e4?1500:3e3}const qr=e=>new Promise(n=>setTimeout(n,e));async function Br(e,n={}){const r=n.now??Date.now,s=n.sleep??qr,i=r();let o=0;for(;;){const{data:a}=await te.get(ee.STATUS_SESSION(e));if(a.paymentIntent&&a.paymentIntent.status==="requires_action"&&a.paymentIntent.last_payment_error)throw new Error(a.paymentIntent.last_payment_error.message);if(a.checkoutSession?.status==="complete"&&["paid","no_payment_required"].includes(a.checkoutSession?.payment_status))break;const u=r()-i;if(u>=Ur)throw new Error("waitForCheckoutComplete: timed out");if(n.reconcile&&o<Ot.length&&u>=Ot[o]){o+=1;try{await n.reconcile()}catch{}}await s(Lr(u))}const{data:c}=await te.get(ee.RETRIEVE_SESSION(e));return c}function gn(e,n){return`${e}-${n}-${Date.now()}-${Math.random().toString(36).substring(2,10)}`}const Hr=["QUOTE_LOCK_EXPIRED","QUOTE_AMOUNT_MISMATCH","QUOTE_EXPIRED_OR_USED","QUOTE_NOT_FOUND","QUOTE_REQUIRED","QUOTE_MAX_PAYABLE_EXCEEDED","quote_validation_failed"],Vr="/.well-known/service/relay";function yn(){const e=window.blocklet;return e?.appPid||e?.appId||""}function Ut(e){return`relay:${yn()}:${e}`}function Qr(){return window.location.protocol==="https:"?"wss:":"ws:"}function Kr(){return new URL(window.location.href).host}function Gr(e,n){if(!e)return"";const s=(e.line_items||[]).map(i=>`${i.upsell_price_id||i.price_id}:${i.quantity}`).join("|");return`${e.id}-${n}-${s}`}function Lt(e,n,r,s,i=!1,o){const l=(s?.line_items||[]).find(u=>u.exchange_rate)?.exchange_rate;return{...r,idempotency_key:o||gn(e,n||""),preview_rate:l||void 0,...i&&{price_confirmed:!0}}}function qt(e){return Hr.includes(e)||e==="QUOTE_UPDATED"}async function Yr(e){try{await te.post(ee.ABORT_STRIPE(e))}catch{}}async function Bt(e,n,r){const s=n?ee.DONATE_SUBMIT(e):ee.SUBMIT(e),{data:i}=await te.put(s,r);return i}async function ot(e){const{data:n}=await te.post(ee.FAST_CHECKOUT_CONFIRM(e),{});return n}async function Xr(e){const{data:n}=await te.post(ee.SKIP_PAYMENT_METHOD(e),{});return n}async function Zr(e,n){const{data:r}=await te.put(ee.SLIPPAGE(e),{slippage_config:n});return r}function Jr(e,n,r,s,i,o,c,a,l,u){const f=e?.checkoutSession,[d,m]=p.useState("idle"),[b,h]=p.useState(null),[x,v]=p.useState(null),[F,S]=p.useState(!1),C=W(()=>S(!0)),R=W(()=>S(!1)),y=p.useRef(!0),E=p.useRef(!1),N=p.useRef(null),$=p.useRef(null),P=p.useRef(null),[L,q]=p.useState(null),K=p.useRef(null),B=p.useRef(0),H=2,ie=p.useRef(""),O=p.useRef(""),oe=p.useRef(!1);p.useEffect(()=>{if(oe.current||!f||!e)return;f.status==="complete"&&["paid","no_payment_required"].includes(f.payment_status)&&d==="idle"&&(oe.current=!0,v(e),m("completed"))},[f,e]),p.useEffect(()=>{if(y.current=!0,!n||!yn())return;const I=new Jn(`${Qr()}//${Kr()}${Vr}`,{longpollerTimeout:5e3,heartbeatIntervalMs:30*1e3});I.connect(),N.current=I;const j=I.subscribe(Ut("events"));return j.channel="events",$.current=j,()=>{y.current=!1,E.current=!0,$.current&&(I.unsubscribe(Ut($.current.channel)),$.current=null),I.disconnect(),N.current=null}},[n]);const G=W(async({response:I})=>{I.id===n&&d!=="completed"&&(E.current=!0,await J())});p.useEffect(()=>{const I=$.current;return I&&I.on("checkout.session.completed",G),()=>{if(I)try{I.off?.("checkout.session.completed",G)}catch{}}},[$.current,d]);const V=W(async()=>{await te.post(ee.RECONCILE_STRIPE_SESSION(n))}),J=W(async(I=!1)=>{try{if(I)try{await V()}catch{}const j=await Br(n,{reconcile:I?V:void 0});if(!y.current)return;v(j),u?.(j),m("completed"),h(null)}catch(j){if(!y.current)return;m("failed"),h({type:"error",message:je(j)||"Payment verification failed"})}});p.useEffect(()=>{if(oe.current||!n||d!=="idle"&&d!=="waiting_stripe")return;let I=null,j=!1;try{const X=new URLSearchParams(window.location.search);I=X.get("redirect_status"),j=!!X.get("payment_intent")}catch{return}if(!(!I&&!j)){if(oe.current=!0,I==="failed"||I==="canceled"){m("failed"),h({type:"error",message:"Payment was not completed. Please try again."});return}m("submitting"),h(null),J(!0)}},[n]),p.useEffect(()=>{if(d!=="completed"||!n||!f?.line_items?.some(re=>!!re?.price?.product?.vendor_config?.length))return;const j=Date.now(),X=async()=>{try{const{data:re}=await te.get(ee.VENDOR_ORDER_STATUS(n));if(!y.current)return;const ae=Array.isArray(re?.vendors)?re.vendors:[],ye=Date.now()-j>6e3,w=ae.every(Z=>Z.progress>=100),D=ae.some(Z=>Z.status==="failed"||ye&&!!Z.error&&!!Z.error_message);if(q({...re,vendors:ae,isAllCompleted:!D&&w,hasFailed:D}),D||w)return;K.current=setTimeout(X,5e3)}catch{}};return X(),()=>{K.current&&clearTimeout(K.current)}},[d,n]);const ne=W(async(I,j)=>{try{if(await l(!0),!y.current)return}catch{}if(I==="QUOTE_UPDATED"&&j?.checkoutSession){B.current=0,m("failed"),h({type:"error",message:"Price updated, please resubmit",code:I});return}if(["QUOTE_LOCK_EXPIRED","QUOTE_EXPIRED_OR_USED","QUOTE_NOT_FOUND","QUOTE_REQUIRED"].includes(I)&&B.current<H){B.current+=1,m("idle"),h(null),await ue(!0);return}B.current=0,m("failed"),h({type:"error",message:"Price updated, please resubmit",code:I})}),se=W(async I=>{if(s){const ae=I.stripeContext;if(ae?.status==="succeeded"){await J();return}const ye=I.paymentIntent,w=ae?.client_secret||ye?.client_secret;if(w){const D=ae?.intent_type||"payment_intent";m("waiting_stripe"),h({type:"stripe",clientSecret:w,intentType:D,noPaymentRequired:!!I.noPaymentRequired});return}if(I.noPaymentRequired)try{const D=await ot(n),Z=D.checkoutSession;if(D.fastPaid||Z?.status==="complete"){await J();return}}catch{}await J();return}if(I.noPaymentRequired){try{const ae=await ot(n),ye=ae.checkoutSession;ae.fastPaid||ye?.status==="complete"?await J():(m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}}))}catch{if(!y.current)return;m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}})}return}const j=I.fastPayInfo,X=I.balance,re=I.delegation;if(i){if(I.creditSufficient===!0&&j){m("confirming_fast_pay"),h({type:"fast_pay",payType:"credit",amount:j.amount||"0",payer:j.payer||""});return}m("credit_insufficient"),h({type:"credit_insufficient",available:"0",required:"0"});return}if((X?.sufficient||re?.sufficient)&&!o&&j){m("confirming_fast_pay"),h({type:"fast_pay",payType:j.type||"balance",amount:j.amount||"",payer:j.payer||""});return}m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}})}),U=W(async I=>{const{code:j,data:X,message:re}=pt(I);if(j&&qt(j)){await ne(j,X);return}if(j==="RATE_BELOW_SLIPPAGE_LIMIT"){try{await l(!0)}catch{}if(!y.current)return;ie.current="",O.current="",m("failed"),h({type:"error",message:X?.error||"Exchange rate below acceptable limit, please retry",code:j});return}if(j==="RATE_UNAVAILABLE"){try{await l(!0)}catch{}if(!y.current)return;m("failed"),h({type:"error",message:X?.rateError||"Exchange rate unavailable",code:j});return}if(j==="PRICE_CHANGED"){m("confirming_price"),h({type:"price_change",changePercent:X?.change_percent||0});return}if(j==="PRICE_UNAVAILABLE"||j==="PRICE_UNSTABLE"){try{await l(!0)}catch{}if(!y.current)return;m("failed"),h({type:"error",message:X?.error||"Price unavailable, please retry",code:j});return}if(j==="STOP_ACCEPTING_ORDERS"){m("service_suspended"),h({type:"service_suspended"});return}if(j==="UNIFIED_APP_REQUIRED"||j==="CUSTOMER_LIMITED"){m("failed"),h({type:"error",message:X?.error||re||"Cannot complete payment",code:j});return}const ae=X?.error||re||"Payment failed";m("failed"),h({type:"error",message:ae,code:j})}),ue=W(async(I=!1)=>{if(!I&&d!=="idle")return;if(I||(B.current=0),!await a()){m("failed"),h({type:"error",message:"Please complete the required fields",code:"VALIDATION_FAILED"});return}if(!f?.user?.sourceAppPid&&f?.line_items?.some(ye=>!!ye?.price?.product?.vendor_config?.length)){m("failed"),h({type:"error",message:"Vendor account required",code:"VENDOR_ACCOUNT_REQUIRED"});return}m("submitting"),h(null),v(null),E.current=!1;const X=Gr(f,r);(X!==O.current||!ie.current)&&(O.current=X,ie.current=gn(n,r||""));const re=Lt(n,r,c,f,!1,ie.current);P.current=re;try{const ae=await Bt(n,o,re);if(!y.current)return;await se(ae)}catch(ae){if(!y.current)return;await U(ae)}}),ge=W(async()=>{if(d==="confirming_fast_pay"){m("submitting");try{const I=await ot(n);if(!y.current)return;I.fastPaid?await J():(m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}}))}catch(I){if(!y.current)return;const{code:j,data:X,message:re}=pt(I);if(j&&qt(j)){await ne(j,X);return}if(j==="RATE_UNAVAILABLE"){try{await l(!0)}catch{}if(!y.current)return;m("failed"),h({type:"error",message:X?.rateError||"Exchange rate unavailable",code:j});return}m("failed"),h({type:"error",message:X?.error||re||"Fast pay confirmation failed",code:j})}return}if(d==="confirming_price"){m("submitting"),h(null),E.current=!1;const I=Lt(n,r,c,f,!0,ie.current);P.current=I;try{const j=await Bt(n,o,I);if(!y.current)return;await se(j)}catch(j){if(!y.current)return;await U(j)}}}),de=W(()=>{(d==="confirming_price"||d==="confirming_fast_pay"||d==="credit_insufficient"||d==="service_suspended")&&(m("idle"),h(null),R())}),T=W(async()=>{d==="failed"&&(m("idle"),h(null),v(null),await ue(!0))}),xe=W(()=>{E.current=!0,m("idle"),h(null),v(null),R()}),fe=W(async()=>{d==="waiting_stripe"&&(m("submitting"),h(null),await J(!0))}),k=W(async()=>{d==="waiting_stripe"&&(await Yr(n),m("idle"),h(null))}),Q=W(async()=>{if(d==="waiting_stripe")try{m("submitting");const I=await Xr(n);if(!y.current)return;I.skipped||I.checkoutSession?.status==="complete"?await J():(m("failed"),h({type:"error",message:"Failed to skip payment method",code:"SKIP_FAILED"}))}catch(I){if(!y.current)return;m("failed"),h({type:"error",message:I.message||"Failed to skip payment method",code:"SKIP_FAILED"})}}),Y=W(async()=>{d==="submitting"||d==="completed"||(E.current=!1,m("submitting"),h(null),await J())});return{status:d,context:b,execute:ue,confirm:ge,cancel:de,result:x,retry:T,reset:xe,stripeConfirm:fe,stripeCancel:k,stripeSkip:Q,didConnectComplete:Y,vendorStatus:L,locked:F,lock:C}}const ei=3e4;function ti(e){return e.some(n=>(n.upsell_price||n.price)?.pricing_type==="dynamic")}async function ni(e,n){const{data:r}=await te.get(ee.EXCHANGE_RATE(e),{params:n?{currency_id:n}:void 0}),s=r.rate||r.exchange_rate;if(s){const i=r.provider_display||r.provider_name||r.provider_id||null;return{rate:s,provider:r.provider_name||r.rate_provider_name||null,providerDisplay:i,fetchedAt:r.fetched_at||r.timestamp_ms||null}}return{rate:null,provider:null,providerDisplay:null,fetchedAt:null}}function ri(e){const n=e?.discounts||[];if(n.length===0)return null;const r=n[0],s=r.promotion_code_details,i=r.verification_data;return s?.code||i?.code||r.promotion_code||r.coupon||null}async function ii(e,n,r){try{const{data:s}=await te.post(ee.APPLY_PROMOTION(e),{promotion_code:n,currency_id:r});return s.error?{success:!1,error:s.error}:{success:!0}}catch(s){return{success:!1,error:je(s)||"Invalid promotion code"}}}async function si(e){await te.delete(ee.REMOVE_PROMOTION(e))}async function oi(e,n){const{data:r}=await te.post(ee.RECALCULATE_PROMOTION_SESSION(e),{currency_id:n});return r}function ai(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 oi(n,r)}catch{return null}}async function Ht(e,n,r,s,i,o,c,a){const{data:l}=await te.put(ee.ADJUST_QUANTITY(e),{itemId:n,quantity:r,currency_id:s});let u=l;if(l.discounts?.length||Je(i)){const f=await De(i,e,s);f&&(u=f)}c&&a?a({...c,checkoutSession:u,quotes:void 0}):await o(!0)}async function bn(e,n,r,s,i,o,c,a){if((s?.line_items?.length||0)>1)try{await te.delete(ee.CROSS_SELL(e))}catch{}const{data:l}=await te.put(ee.UPSELL(e),{from:n,to:r});let u=l;if(l.discounts?.length||Je(s)){const f=await De(s,e,i);f&&(u=f)}c&&a?a({...c,checkoutSession:u,quotes:void 0}):await o(!0)}async function _n(e,n,r,s,i,o,c){if((r?.line_items?.length||0)>1)try{await te.delete(ee.CROSS_SELL(e))}catch{}const{data:a}=await te.put(ee.DOWNSELL(e),{from:n});let l=a;if(a.discounts?.length||Je(r)){const u=await De(r,e,s);u&&(l=u)}o&&c?c({...o,checkoutSession:l,quotes:void 0}):await i(!0)}async function ci(e,n,r,s,i,o,c,a){const{data:l}=await te.put(ee.CHANGE_AMOUNT(e),{priceId:n,amount:r});let u=l;if(l?.discounts?.length){const f=await De(s,e,i);f&&(u=f)}c&&a?a({...c,checkoutSession:u,quotes:void 0}):await o(!0)}function li(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 ui({sessionId:e,children:n}){const{isLoading:r,error:s,errorCode:i,refresh:o,setSessionData:c,sessionData:a,resolvedSessionId:l,vendorCount:u,product:f,subscription:d,pageInfo:m}=Er(e),b=a?.checkoutSession,h=l||e,x=p.useMemo(()=>b?.line_items||[],[b?.line_items]),v=b?.submit_type==="donate",F=p.useMemo(()=>({sessionData:a,setSessionData:c,sessionId:e,effectiveSessionId:h,isLoading:r,error:s,errorCode:i,refresh:o,items:x,session:b||null,isDonation:v,vendorCount:u,product:f,subscription:d,pageInfo:m}),[a,c,e,h,r,s,i,o,x,b,v,u,f,d,m]),S=Ar(a,h,o,c),C=p.useRef(null);p.useEffect(()=>{const U=S.currency?.id||null;!U||!b||b.status==="complete"||(C.current===null||U!==C.current)&&(C.current=U,De(b,h,U).then(ue=>{ue&&o(!0)}))},[S.currency?.id,b?.id]);const R=p.useMemo(()=>({current:S.current,currency:S.currency,available:S.available,currencies:S.currencies,isStripe:S.isStripe,isCrypto:S.isCrypto,isCredit:S.isCredit,switching:S.switching,setType:S.setType,types:S.types,setCurrency:S.setCurrency,stripe:S.stripe}),[S.current,S.currency,S.available,S.currencies,S.isStripe,S.isCrypto,S.isCredit,S.switching,S.setType,S.types,S.setCurrency,S.stripe]),[y,E]=p.useState(null),[N,$]=p.useState(null),[P,L]=p.useState(null),[q,K]=p.useState(null),[B,H]=p.useState("loading"),ie=p.useRef(null),O=p.useRef(!1),oe=p.useRef(!0),G=p.useMemo(()=>ti(x),[x]),V=W(async()=>{if(!h||!G||S.isStripe||S.switching){H(G?"unavailable":"available"),S.isStripe&&(E(null),$(null),L(null),K(null));return}if(!O.current){O.current=!0;try{H("loading");const U=await ni(h,S.currency?.id);if(!oe.current)return;U.rate?(E(U.rate),$(U.provider),L(U.providerDisplay),K(U.fetchedAt),H("available")):H("unavailable")}catch{if(!oe.current)return;H("unavailable")}finally{O.current=!1}}});p.useEffect(()=>{if(oe.current=!0,!G||S.isStripe||S.switching||!h||b?.status==="complete"){S.isStripe&&(E(null),$(null),L(null),K(null)),S.switching||(b?.status==="complete"?H("available"):H(G?"unavailable":"available"));return}V(),ie.current=setInterval(V,ei);const U=()=>{document.hidden||V()};return document.addEventListener("visibilitychange",U),()=>{oe.current=!1,ie.current&&clearInterval(ie.current),document.removeEventListener("visibilitychange",U)}},[G,S.isStripe,S.switching,h,S.currency?.id,b?.status]);const J=p.useMemo(()=>({rate:y,provider:N,providerDisplay:P,fetchedAt:q,status:B,hasDynamicPricing:G,refresh:V}),[y,N,P,q,B,G,V]),ne=Or(a,S.currency?.id||null,S.current?.id||null),se=Jr(a,h,S.currency?.id||null,S.isStripe,S.isCredit,v,ne.values,ne.validate,o,c);return t.jsx(tr.Provider,{value:F,children:t.jsx(nr.Provider,{value:R,children:t.jsx(rr.Provider,{value:J,children:t.jsx(ir.Provider,{value:ne,children:t.jsx(sr.Provider,{value:se,children:n})})})})})}function at(e,n=6,r=!0,s=!0){if(!e||e==="0")return"0";const i=Number(e);if(!Number.isFinite(i))return"0";let o;if(s?o=i.toLocaleString("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}):o=i.toFixed(n),!r)return o;const[c,a]=o.split(".");if(!a)return c;const l=a.replace(/0+$/,"");return l?`${c}.${l}`:c}function ze(e,n,r=6,s=!0,i=!0){if(!n)return at(e,r,s,i);const o=Number(e);if(!Number.isFinite(o))return at(e,r,s,i);const c=Math.abs(o),a=c>0&&c<.01?r:2;return at(e,a,s,i)}const Vt=8;function Qt(e,n,r){if(!r&&r!=="0"||n==null)return null;try{const s=e instanceof z?e:new z(e||"0"),i=new z(10).pow(new z(n));if(i.isZero())return null;const o=new z(r.replace(".","")),c=r.includes(".")&&r.split(".")[1]?.length||0,a=new z(10).pow(new z(c)),l=new z(10).pow(new z(Vt)),u=s.mul(o).mul(l).div(i.mul(a));return Te(u.toString(),Vt)}catch{return null}}function Kt(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 di(e){if(!e&&e!=="0")return null;const n=String(e),r=Number(n);return Number.isFinite(r)?n:null}function pi(e,n="USD",r=2){if(e==null)return null;const s=Number(e);if(!Number.isFinite(s))return null;const i=s.toFixed(r);return n==="USD"?`$${i}`:`${i} ${n}`}function mi(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 s=mi(e).find(i=>i.currency_id===n?.id);return s?s.custom_unit_amount?s.custom_unit_amount.preset||s.custom_unit_amount.presets[0]:s.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 fi(e,n,{useUpsell:r=!0,exchangeRate:s=null}={}){if(!n)return{unitAmount:new z(0),totalAmount:new z(0),isDynamicQuote:!1};const i=r&&e.upsell_price||e.price,o=new z(e.quantity||0),c=e.quoted_amount,a=e.quote_currency_id,l=i?.pricing_type==="dynamic";if(l&&c&&a===n.id){const d=new z(c||"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&&s&&i?.base_amount){const d=Number(s);if(d>0&&Number.isFinite(d)){const m=Number(i.base_amount);if(m>0&&Number.isFinite(m)){const b=m/d,h=Xe(b.toFixed(n.decimal||8),n.decimal||8);return{unitAmount:h,totalAmount:h.mul(o),isDynamicQuote:!1}}}}if(!s&&i?.base_amount!=null){const d=Number(i.base_amount);if(d>=0&&Number.isFinite(d)){const m=n.decimal||2,b=Xe(d.toFixed(m),m);return{unitAmount:b,totalAmount:b.mul(o),isDynamicQuote:!1}}}const f=new z(bt(i,n));return{unitAmount:f,totalAmount:f.mul(o),isDynamicQuote:!1}}function _t(e,n,r=!1,s=!0,{exchangeRate:i=null}={}){let o=new z(0);const c=e.filter(a=>(s&&a.upsell_price||a.price)!=null).reduce((a,l)=>{const u=l.quote_currency_id;let f;l.custom_amount&&u&&u===n.id?f=new z(l.custom_amount):{totalAmount:f}=fi(l,n,{useUpsell:s,exchangeRate:i});const d=s&&l.upsell_price||l.price;return d?.type==="recurring"&&(o=o.add(f),r||d.recurring?.usage_type==="metered")?a:a.add(f)},new z(0)).toString();return{subtotal:c,total:c,renew:ze(o.toString(),!!i),discount:"0",shipping:"0",tax:"0"}}function xi(e,n,r=0){const s={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 c=o.upsell_price||o.price,a=bt(c,n),l=new z(a).mul(new z(o.quantity));c?.type==="recurring"&&c?.recurring&&(c.recurring.usage_type==="licensed"&&(s.licensed=s.licensed.add(l)),c.recurring.usage_type==="metered"&&(s.metered=s.metered.add(l)))}),s.licensed.add(s.metered).toString()):"0"}function Sn(e,n,r,s,i,o,c){const a=r?.discounts||[];if(a.length===0)return new z(0);const l=a[0].coupon_details||{};if(c&&l.duration==="once")return new z(0);const u=e.filter(m=>!(m.discountable===!1||(m.upsell_price||m.price)?.recurring?.usage_type==="metered")),f=_t(u,n,o,!0,{exchangeRate:s?i:null}),d=new z(f.total);if(d.lte(new z(0)))return new z(0);if(l.percent_off&&l.percent_off>0)return d.mul(new z(l.percent_off)).div(new z(100));if(l.amount_off&&l.amount_off!=="0"){const m=l.currency_options?.[n.id]?.amount_off||l.amount_off;if(m&&m!=="0"){const b=new z(m);return b.lt(d)?b:d}}return new z(0)}function hi(e,n,r,s,i,o){if(!n||e.length===0)return{subtotal:"0",paymentAmount:"0",total:"0",discount:null,tax:null,staking:null,usdEquivalent:null};const c=r?.subscription_data,l=Number(c?.trial_period_days||0)>0,u=_t(e,n,l,!0,{exchangeRate:i?s:null}),f=new z(u.total),d=Sn(e,n,r,i,s,l,!1),m=d.gt(new z(0))?ze(Te(d.toString(),n.decimal),i):null,b=r?.total_details?.amount_tax,h=new z(b||"0"),x=r?.total_details,v=b&&b!=="0"?{amount:Te(b,n.decimal),rate:x?.tax_rate||0,inclusive:x?.tax_inclusive||!1}:null,F=c?.no_stake||!1,S=Math.max(Number(c?.billing_threshold_amount||0),Number(c?.min_stake_amount||0)),R=o==="arcblock"&&n.type!=="credit"&&!F?xi(e,n,S):"0",y=new z(R),E=f.add(y);let N=E.sub(d);h.gt(new z(0))&&!v?.inclusive&&(N=N.add(h)),N.isNeg()&&(N=new z(0));const $=ze(Te(N,n.decimal),i),P=E,L=ze(Te(P,n.decimal),i);let q=null,K=null;if(i&&s&&n){const H=Qt(N.toString(),n.decimal,s);H&&(q=Kt(H)||null);const ie=Qt(P.toString(),n.decimal,s);ie&&(K=Kt(ie)||null)}const B=y.gt(new z(0))?`${ze(Te(y.toString(),n.decimal),i)} ${n.symbol}`:null;return{subtotal:`${L} ${n.symbol}`,paymentAmount:`${$} ${n.symbol}`,total:`${$} ${n.symbol}`,discount:m?`${m} ${n.symbol}`:null,tax:v,staking:B,usdEquivalent:q?`$${q}`:null,subtotalUsdEquivalent:K?`$${K}`:null}}function wn(e,n,r){if(!e.length||!n)return{locked:!1,lockedAt:null,expiresAt:null,expired:!1,baseCurrency:null,slippagePercent:null};const s=r?.checkoutSession;let i=null,o=null,c=null;e.forEach(b=>{const h=b.upsell_price||b.price;!i&&h?.base_currency&&(i=h.base_currency);const x=b.expires_at;x&&(o=o===null?x:Math.min(o,x));const v=b.slippage_percent;c===null&&Number.isFinite(Number(v))&&(c=Number(v))});const a=r?.paymentIntent?.created_at?new Date(r.paymentIntent.created_at).getTime():null,l=s?.quote_locked_at,u=a||l||null,f=!!u,d=Date.now(),m=o?d>o:!1;return{locked:f,lockedAt:u,expiresAt:o,expired:m,baseCurrency:i,slippagePercent:c}}function gi(e,n,r,s,i,o){const c=e?.subscription_data;let a=Number(c?.trial_period_days||0);if(a>0&&n){const d=(c?.trial_currency||"").split(",").map(m=>m.trim()).filter(Boolean);d.length>0&&!d.includes(n)&&(a=0)}const l=a>0;let u=null,f=null;if(l&&s&&r.length>0){const d=_t(r,s,!1,!0,{exchangeRate:i?o:null});let m=new z(d.total);const b=Sn(r,s,e,i,o,!1,!0);b.gt(new z(0))&&(m=m.sub(b),m.isNeg()&&(m=new z(0))),u=`${ze(Te(m,s.decimal),i)} ${s.symbol}`;const h=r.find(x=>{const v=x.upsell_price||x.price;return v?.type==="recurring"&&v?.recurring});h&&(f=(h.upsell_price||h.price)?.recurring?.interval||null)}return{active:l,days:a,afterTrialPrice:u,afterTrialInterval:f}}async function yi(e,n,r,s,i,o,c){const{data:a}=await te.put(ee.CROSS_SELL(e),{to:n});let l=a;if(a.discounts?.length){const u=await De(r,e,s);u&&(l=u)}o&&c?c({...o,checkoutSession:l,quotes:void 0}):await i(!0)}async function bi(e,n,r,s,i,o){const{data:c}=await te.delete(ee.CROSS_SELL(e));let a=c;if(c.discounts?.length){const l=await De(n,e,r);l&&(a=l)}i&&o?o({...i,checkoutSession:a,quotes:void 0}):await s(!0)}const ct=new Map;function _i(e){const n=ct.get(e);if(n)return n;const r=(async()=>{try{const{data:s}=await te.get(`${ee.CROSS_SELL(e)}?skipError=true`);if(s&&!s.error)return s}catch{}return null})();return ct.set(e,r),r.finally(()=>ct.delete(e)),r}function Si(e){if(!e.length)return null;const n=e[0],r=n.upsell_price||n.price,s=r?.recurring;if(!s)return null;const i=s.interval,o=r?.upsell,c=o?.upsells_to,a=[];if(c?.recurring?.interval&&c.recurring.interval!==i&&a.push({interval:c.recurring.interval,priceId:o?.upsells_to_id||"",amount:c.unit_amount||"0",savings:null}),n.upsell_price_id&&n.price?.recurring){const l=n.price.recurring.interval;l&&l!==i&&a.push({interval:l,priceId:n.price_id,amount:n.price.unit_amount||"0",savings:null})}return a.length===0?null:{current:i,available:a,firstItem:n}}function vn(){const{product:e,subscription:n,pageInfo:r,vendorCount:s}=Se();return{product:e,subscription:n,pageInfo:r,vendorCount:s}}function St(){const{items:e,session:n,effectiveSessionId:r,isDonation:s,refresh:i,sessionData:o,setSessionData:c}=Se(),{currency:a}=Ie(),l=a?.id||null,u=p.useRef(!1);p.useEffect(()=>{if(!(u.current||!r||!e.length||!l||n?.status==="complete"))try{const P=new URLSearchParams(window.location.search);for(const L of e){const q=P.get(`qty_${L.price_id}`)||P.get(`qty_${L.price?.id}`)||P.get("qty");if(q){const K=Math.max(1,parseInt(q,10));if(Number.isFinite(K)&&K!==L.quantity){u.current=!0,Ht(r,L.price_id,K,l,n,i,o,c);break}}}}catch{}},[r,e,l]);const f=W(async(P,L)=>{if(n?.status!=="complete")try{await Ht(r,P,L,l,n,i,o,c)}catch(q){console.error("Failed to update quantity:",je(q))}}),d=W(async(P,L)=>{n?.status!=="complete"&&await bn(r,P,L,n,l,i,o,c)}),m=W(async P=>{n?.status!=="complete"&&await _n(r,P,n,l,i,o,c)}),b=p.useMemo(()=>li(e),[e]),[h,x]=p.useState(null),v=p.useMemo(()=>e.map(P=>P.price_id).join(","),[e]),F=p.useMemo(()=>e.some(P=>P.cross_sell),[e]);p.useEffect(()=>{if(!r||!n||n.status==="complete")return;if(b){x(null);return}if(F)return;let P=!1;return _i(r).then(L=>{P||x(L)}),()=>{P=!0}},[r,n?.id,b,v,F]);const S=b||h,C=p.useMemo(()=>e.some(P=>P.cross_sell_required),[e]),R=W(async()=>{if(n?.status!=="complete"&&S)try{await yi(r,S.id,n,l,i,o,c)}catch(P){console.error("Failed to add cross-sell:",je(P))}}),y=W(async()=>{if(n?.status!=="complete")try{await bi(r,n,l,i,o,c)}catch(P){console.error("Failed to remove cross-sell:",je(P))}}),E=W(async(P,L)=>{if(n?.status!=="complete"&&s)try{await ci(r,P,L,n,l,i,o,c)}catch(q){console.error("Failed to change amount:",je(q))}}),N=p.useMemo(()=>e.map(P=>({...P,adjustable_quantity:P.adjustable_quantity})),[e]),$=p.useMemo(()=>e.every(P=>{const{price:L}=P;if(!L)return!0;const q=Number(P.quantity)||0,K=L.quantity_available||0,B=L.quantity_sold||0,H=L.quantity_limit_per_checkout||0;return!(K>0&&B+q>K||H>0&&H<q)}),[e]);return{items:N,inventoryOk:$,updateQuantity:f,upsell:d,downsell:m,crossSellItem:S,crossSellRequired:C,addCrossSell:R,removeCrossSell:y,isDonation:s,setDonationAmount:E}}function wi(){const{items:e,session:n,effectiveSessionId:r,refresh:s,sessionData:i,setSessionData:o}=Se(),{currency:c}=Ie(),a=c?.id||null,[l,u]=p.useState(!1),[f,d]=p.useState(null),m=W(async(h,x)=>{try{await bn(r,h,x,n,a,s,i,o)}catch(v){console.error("Failed to upsell:",je(v))}}),b=W(async h=>{try{await _n(r,h,n,a,s,i,o)}catch(x){console.error("Failed to downsell:",je(x))}});return p.useMemo(()=>{const h=Si(e);return h?{current:f||h.current,available:h.available,switching:l,switch:async x=>{const v=h.available.find(F=>F.interval===x);if(!(!v||l)){d(x),u(!0);try{!h.firstItem.upsell_price_id&&v.priceId?await m(h.firstItem.price_id,v.priceId):h.firstItem.upsell_price_id&&await b(h.firstItem.upsell_price_id)}finally{u(!1),d(null)}}}}:null},[e,r,l,f])}function vi(){const{session:e,effectiveSessionId:n,refresh:r}=Se(),{currency:s}=Ie(),[i,o]=p.useState(null);p.useEffect(()=>{if(!e||i)return;const f=ri(e);f&&o(f)},[e?.id]);const c=W(async f=>{if(e?.status==="complete")return{success:!1,error:"Session already completed"};const d=await ii(n,f,s?.id);return d.success&&(o(f),await r(!0)),d}),a=W(async()=>{if(e?.status!=="complete")try{await si(n),o(null),await r(!0)}catch{}}),l=(e?.discounts||[]).length>0,u=ai(e);return{applied:l,code:i,active:u,inactiveReason:u?null:"Promotions not allowed",apply:c,remove:a}}function wt(){const{rate:e,provider:n,providerDisplay:r,fetchedAt:s,status:i,hasDynamicPricing:o,refresh:c}=yt();return{value:di(e),display:e?pi(e):null,provider:n,providerDisplay:r,fetchedAt:s,status:i,hasDynamicPricing:o,refresh:c}}function kn(){const{items:e,sessionData:n,effectiveSessionId:r,refresh:s}=Se(),{hasDynamicPricing:i}=yt(),o=p.useMemo(()=>wn(e,i,n),[e,i,n]),c=W(async a=>{try{const l=await Zr(r,a);(l?.checkoutSession||l?.quotes)&&await s(!0)}catch(l){console.error("Failed to update slippage:",je(l))}});return{percent:o.slippagePercent??.5,set:c}}function vt(){const{isLoading:e,error:n,errorCode:r,session:s,isDonation:i}=Se(),o=!e&&!n&&s?.status==="open",c=s?.status==="complete",a=!!s?.livemode;return{isLoading:e,error:n,errorCode:r,canSubmit:o,isCompleted:c,isDonation:i,livemode:a}}function jn(){const{items:e,session:n,sessionData:r,refresh:s}=Se(),{currency:i}=Ie(),{rate:o,hasDynamicPricing:c}=yt(),{current:a}=Ie(),l=p.useMemo(()=>hi(e,i,n,o,c,a?.type||null),[e,i,o,c,n,a?.type]),u=p.useMemo(()=>wn(e,c,r),[e,c,r]);p.useEffect(()=>{!u.expired||!u.expiresAt||n?.status==="complete"||s(!0)},[u.expired]);const f=gi(n,i?.id,e,i,c,o);return{...l,hasDynamicPricing:c,quote:{locked:u.locked,lockedAt:u.lockedAt,expiresAt:u.expiresAt,expired:u.expired,baseCurrency:u.baseCurrency},trial:f}}function ki(){return Ie()}function Cn(){return or()}function et(){return ar()}const ji={overflowY:"auto","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},Gt={"@keyframes mobileFadeIn":{from:{opacity:0},to:{opacity:1}},animation:{xs:"mobileFadeIn 0.4s ease both",md:"none"}},Yt={"@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"}},Ci=typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent),Xt=Ci?{"@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 Ii({left:e,right:n,mode:r="inline"}){const s=r==="standalone",{isMobile:i}=Ze(),o=We(),c=o.palette.mode==="dark",a=e===null,l={};if(i&&!a&&(l["& .cko-v2-submit-btn"]={position:"fixed",bottom:0,left:0,right:0,zIndex:999,bgcolor:c?"rgba(30,30,30,0.82)":"background.paper",backdropFilter:c?"blur(12px)":"none",p:1.5,borderTop:"1px solid",borderColor:"divider",boxShadow:c?"0 -4px 20px rgba(0,0,0,0.4)":"0 -2px 10px rgba(0,0,0,0.08)"}),!s)return t.jsxs(_,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},width:"100%",minHeight:{md:640},maxWidth:1120,mx:"auto",borderRadius:"16px",overflow:"hidden",boxShadow:1,border:1,borderColor:"divider",borderLeft:"4px solid",borderLeftColor:"primary.main",bgcolor:d=>d.palette.mode==="dark"?"background.default":"#f8faff",...Gt},children:[!a&&t.jsx(_,{sx:{flex:1,minWidth:0,bgcolor:d=>d.palette.mode==="dark"?"background.default":"#f8faff",p:{xs:3,md:5},pt:{xs:3,md:4},display:"flex",flexDirection:"column",...Yt},children:e}),t.jsx(_,{sx:{width:a?"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"},...a?{}:Xt},children:n})]});const u=c?o.palette.background.default:o.palette.grey[100],f=c?o.palette.background.default:"#f8faff";return t.jsxs(_,{sx:{width:"100%",height:{xs:"auto",md:"100vh"},minHeight:{xs:"100vh"},overflow:{md:"hidden"},display:"flex",flexDirection:{xs:"column",md:"row"},position:"relative",background:i?u:`linear-gradient(160deg, ${le(o.palette.primary.main,.03)} 0%, ${le(o.palette.primary.main,.07)} 50%, ${le(o.palette.primary.main,.04)} 100%)`,bgcolor:f,...Gt},children:[t.jsx(gt,{sx:{position:"absolute",top:20,left:0,right:0,zIndex:10,background:"transparent","& .header-container":{height:"auto"}},hideNavMenu:!0,brand:null,description:null,addons:d=>d.filter(b=>["locale-selector","theme-mode-toggle","session-user"].includes(b.key))}),!a&&t.jsx(_,{sx:{flex:{xs:"none",md:"0 0 50%"},width:{xs:"100%"},height:{xs:"auto",md:"100vh"},display:"flex",justifyContent:{md:"center"},...i?{bgcolor:"background.paper",mt:9}:{},...ji},children:t.jsx(_,{sx:{width:"100%",maxWidth:{md:640},p:{xs:3,md:5},pt:{xs:3,md:10},display:"flex",flexDirection:"column",flex:1,...Yt},children:e})}),t.jsx(_,{sx:{flex:a?"none":{xs:"none",md:"0 0 50%"},width:a?"100%":{xs:"100%"},height:a?"100vh":{xs:"auto",md:"100vh"},bgcolor:"background.paper",boxShadow:a?"none":{md:"-4px 0 16px rgba(0,0,0,0.04)"},position:"relative",display:"flex",flexDirection:"column",...a?{}:Xt,...i&&!a?{pb:"180px",mt:2}:{},overflowY:{xs:"auto",md:"hidden"},"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none",...l},children:t.jsx(_,{sx:{width:"100%",maxWidth:{md:600},mx:"auto",p:{xs:3,md:4},pt:a?{xs:10,md:"10vh"}:{xs:3,md:"10vh"},display:"flex",flexDirection:"column",flex:1,minHeight:0,justifyContent:a?"center":void 0},children:n})})]})}function Ei(e,n){if(!e)return"composite";const r=n.length===1,s=e.mode==="payment",i=["subscription","setup"].includes(e.mode||"");if(r&&s){const o=n[0];if(o.price?.product?.type==="credit"&&o.price?.metadata?.credit_config)return"credit-topup"}return r&&i&&!n.some(o=>o.cross_sell)?"subscription":"composite"}function Ri({item:e,currency:n,discounts:r,exchangeRate:s,onQuantityChange:i,onUpsell:o,onDownsell:c,trialActive:a,trialDays:l,t:u,recommended:f=!1,hideUpsell:d=!1,isRateLoading:m=!1,showFeatures:b=!0,children:h=void 0}){const x=e.upsell_price||e.price,v=x?.product,F=v?.name||"Item",S=v?.images?.[0]||"",C=v?.features||[],R=x?.recurring,y=e.quantity||1,E=R?.usage_type==="metered",N=E?` ${u("common.metered")}`:"",$=Ye(x,n,s),P=!!R,L=u(P?"payment.checkout.typeBadge.subscription":"payment.checkout.typeBadge.oneTime"),q=R?.interval?` / ${u(`common.${R.interval}`)}`:"",K=y>1&&$&&n?`${y} × ${$} ${n.symbol}`:E?N.trim():"",B=(()=>{const w=e.quote_currency_id;if(e.custom_amount&&w&&w===n?.id)return He(e.custom_amount,n);if(x?.pricing_type==="dynamic"&&s&&x.base_amount){const D=Number(s);if(D>0&&Number.isFinite(D)){const Z=Number(x.base_amount);if(Z>0&&Number.isFinite(Z)){const ce=Z*y/D,pe=Math.abs(ce),me=pe>0&&pe<.01?6:2;return ce.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:me}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"}}}if(!s&&x?.base_amount!=null){const D=Number(x.base_amount);if(D>=0&&Number.isFinite(D))return(D*y).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}if(x&&n){const D=bt(x,n);if(D&&D!=="0"){const Z=BigInt(D)*BigInt(y);return He(Z.toString(),n)}}return"0"})(),H=r?.[0],ie=H?.promotion_code_details?.code||H?.verification_data?.code||H?.promotion_code||"",O=(()=>{if(!ie||!H)return null;const w=H?.coupon_details;if(w?.percent_off>0){const D=parseFloat(String(B).replace(/,/g,""));if(!Number.isNaN(D)&&D>0){const Z=D*w.percent_off/100,ce=Math.abs(Z),pe=ce>0&&ce<.01?6:2;return`${Z.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:pe}).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,G=e.adjustable_quantity?.minimum||1,V=e.adjustable_quantity?.maximum,[J,ne]=p.useState(String(y)),[se,U]=p.useState(!1),ue=We(),ge=Dn(ue.breakpoints.down("md")),[de,T]=p.useState(!ge);p.useEffect(()=>{se||ne(String(y))},[y,se]);const xe=p.useRef(null),fe=p.useCallback((w,D)=>{xe.current&&clearTimeout(xe.current),xe.current=setTimeout(()=>{i(w,D)},400)},[i]);p.useEffect(()=>()=>{xe.current&&clearTimeout(xe.current)},[]);const k=!!e.price?.upsell?.upsells_to,Q=!!e.upsell_price,Y=e.price?.upsell?.upsells_to;let I=0;if(k&&Y){const w=parseFloat(e.price?.base_amount||e.price?.unit_amount||"0"),D=parseFloat(Y?.base_amount||Y?.unit_amount||"0"),Z=e.price?.recurring?.interval,ce=Y?.recurring?.interval;if(w>0&&D>0&&Z&&ce){const pe={day:365,week:52,month:12,year:1},me=w*(pe[Z]||1),we=D*(pe[ce]||1);me>we&&(I=Math.round((me-we)/me*100))}}const j=Y?.recurring?.interval,X=(()=>{if(!Y)return"";const w=j?u("common.slash",{interval:u(`common.${j}`)}):"";if(Y.pricing_type==="dynamic"&&Y.base_amount&&s){const Z=Number(s);if(Z>0&&Number.isFinite(Z)){const ce=parseFloat(Y.base_amount);if(ce>0&&Number.isFinite(ce)){const pe=ce/Z,me=Math.abs(pe),we=me>0&&me<.01?6:2;return`${pe.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:we}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"} ${n?.symbol||""} ${w}`}}}if(Y.pricing_type==="dynamic"&&Y.base_amount&&Y.base_currency==="USD")return`$${parseFloat(Y.base_amount).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})} ${w}`;const D=Ye(Y,n,s);return D?`${D} ${n?.symbol||""} ${w}`:""})(),re=e.price?.recurring?.interval,ae=(()=>{if(!e.price||!Q)return"";const w=e.price,D=re?u("common.slash",{interval:u(`common.${re}`)}):"";if(w.pricing_type==="dynamic"&&w.base_amount&&s){const ce=Number(s);if(ce>0&&Number.isFinite(ce)){const pe=parseFloat(w.base_amount);if(pe>0&&Number.isFinite(pe)){const me=pe/ce,we=Math.abs(me),Oe=we>0&&we<.01?6:2;return`${me.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:Oe}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"} ${n?.symbol||""} ${D}`}}}if(w.pricing_type==="dynamic"&&w.base_amount&&w.base_currency==="USD")return`$${parseFloat(w.base_amount).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})} ${D}`;const Z=Ye(w,n,s);return Z?`${Z} ${n?.symbol||""} ${D}`:""})(),ye=(()=>{if(Q){const D=re?u(Ae[re]||""):"";return u("payment.checkout.upsell.revert",{recurring:D})}const w=j?u(Ae[j]||""):"";return u("payment.checkout.upsell.save",{recurring:w})})();return t.jsxs(_,{sx:{position:"relative"},children:[f&&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:w=>$e(w),boxShadow:"0 4px 12px rgba(45,124,243,0.2)","& .MuiChip-label":{px:1.5}}}),t.jsxs(_,{sx:{p:{xs:2,md:3},bgcolor:"background.paper",borderRadius:{xs:"16px",md:"24px"},border:"1px solid",borderColor:"divider",boxShadow:w=>w.palette.mode==="dark"?"0 12px 40px -8px rgba(0,0,0,0.3)":"0 12px 40px -8px rgba(0,0,0,0.06)",transition:"all 0.3s ease",...k&&!d?{borderRadius:{xs:"16px 16px 0 0",md:"24px 24px 0 0"}}:{},"&:hover":{borderColor:w=>w.palette.mode==="dark"?"rgba(255,255,255,0.12)":"rgba(45,124,243,0.15)"}},children:[t.jsxs(M,{direction:"row",spacing:{xs:1.5,md:2.5},sx:{alignItems:"center",width:"100%"},children:[S?t.jsx(Ce,{src:S,alt:F,variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},flexShrink:0}}):t.jsx(Ce,{variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},bgcolor:w=>w.palette.mode==="dark"?"rgba(255,255,255,0.06)":"#eff6ff",flexShrink:0},children:t.jsx(en,{sx:{fontSize:{xs:22,md:28},color:"primary.main",opacity:.45}})}),t.jsx(_,{sx:{flex:1,minWidth:0,overflow:"hidden"},children:t.jsxs(M,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",sx:{mb:.25},children:[t.jsxs(_,{sx:{minWidth:0},children:[t.jsx(g,{sx:{color:"text.primary",fontWeight:800,fontSize:{xs:15,md:18},lineHeight:1.3},children:F}),t.jsx(g,{component:"span",sx:{display:"inline-block",mt:.5,fontSize:10,fontWeight:700,letterSpacing:"0.08em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:w=>w.palette.mode==="dark"?`${w.palette.primary.main}1A`:`${w.palette.primary.main}0D`,px:.75,py:.4,borderRadius:"3px"},children:L}),K&&t.jsx(g,{sx:{color:"text.disabled",fontSize:13,fontWeight:500,mt:.25},children:K})]}),t.jsx(M,{alignItems:"flex-end",sx:{flexShrink:0,ml:1.5},children:a&&P?t.jsx(g,{sx:{fontWeight:800,color:"text.primary",whiteSpace:"nowrap",fontSize:{xs:15,md:18}},children:ln(u,l,R?.interval||"day")}):m?t.jsx(Ne,{variant:"text",width:100,height:28}):t.jsxs(t.Fragment,{children:[t.jsxs(g,{sx:{fontWeight:800,color:"text.primary",whiteSpace:"nowrap",fontSize:{xs:15,md:18},transition:"opacity 0.3s ease"},children:[B," ",n?.symbol,q]}),s&&x?.base_amount&&t.jsxs(g,{sx:{fontSize:12,color:"text.disabled",fontWeight:600,lineHeight:1},children:["≈ $",(Number(x.base_amount)*y).toFixed(2)]})]})})]})})]}),b&&C.length>0&&t.jsxs(_,{sx:{mt:{xs:2,md:2.5},pt:{xs:2,md:2.5},borderTop:"1px solid",borderColor:w=>w.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.100"},children:[t.jsxs(M,{direction:"row",alignItems:"center",justifyContent:"space-between",onClick:()=>T(w=>!w),sx:{cursor:"pointer",userSelect:"none",mb:de?1.25:0},children:[t.jsx(g,{sx:{fontSize:14,fontWeight:700,color:"text.primary"},children:u("payment.checkout.planFeatures")}),t.jsx(Mn,{sx:{fontSize:20,color:"text.secondary",transition:"transform 0.2s ease",transform:de?"rotate(0deg)":"rotate(180deg)"}})]}),t.jsx(mt,{in:de,children:t.jsx(M,{spacing:1.25,children:C.map(w=>t.jsxs(M,{direction:"row",spacing:1.5,alignItems:"center",children:[t.jsx(_,{sx:{width:20,height:20,borderRadius:"50%",bgcolor:D=>D.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(zn,{sx:{fontSize:14,color:"success.main"}})}),t.jsx(g,{sx:{fontSize:14,fontWeight:500,color:"text.secondary"},children:w.name})]},w.name))})})]}),ie&&O&&t.jsx(_,{sx:{mt:1.5},children:m?t.jsx(Ne,{variant:"rounded",width:160,height:22,sx:{borderRadius:"6px"}}):t.jsx(Ge,{icon:t.jsx(tn,{sx:{color:"warning.main",fontSize:"small"}}),label:`${ie} (-${O})`,size:"small",sx:{height:22,borderRadius:"6px","& .MuiChip-label":{fontSize:12}}})}),oe&&t.jsxs(M,{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 D=(parseInt(J,10)||y)-1;D<G||(ne(String(D)),fe(e.price_id,D))},disabled:(parseInt(J,10)||y)<=G,sx:{width:36,height:36,border:"1px solid",borderColor:"divider",borderRadius:"50%","&:hover":{bgcolor:"action.hover"}},children:t.jsx(Nn,{sx:{fontSize:20}})}),t.jsx(nn,{value:J,size:"small",type:"number",slotProps:{htmlInput:{style:{textAlign:"center",padding:"6px 4px",fontWeight:700,fontSize:16,MozAppearance:"textfield"},min:G,max:V||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:w=>ne(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),w.stopPropagation(),w.target.blur())},onBlur:()=>{U(!1);const w=parseInt(J,10);!Number.isNaN(w)&&w>=G&&(!V||w<=V)&&w!==y?i(e.price_id,w):ne(String(y))}}),t.jsx(Ve,{size:"small",onClick:()=>{const D=(parseInt(J,10)||y)+1;V&&D>V||(ne(String(D)),fe(e.price_id,D))},disabled:V?(parseInt(J,10)||y)>=V:!1,sx:{width:36,height:36,border:"1px solid",borderColor:"divider",borderRadius:"50%","&:hover":{bgcolor:"action.hover"}},children:t.jsx(rn,{sx:{fontSize:20}})})]}),h]}),k&&!d&&t.jsxs(_,{sx:{px:{xs:2,md:3},py:1.5,bgcolor:"background.paper",border:"1px solid",borderTop:0,borderColor:"divider",borderRadius:{xs:"0 0 16px 16px",md:"0 0 24px 24px"},boxShadow:w=>w.palette.mode==="dark"?"0 12px 40px -8px rgba(0,0,0,0.3)":"0 12px 40px -8px rgba(0,0,0,0.06)"},children:[t.jsx(_,{sx:{borderTop:"1px solid",borderColor:"divider",mb:1.5}}),t.jsxs(M,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[t.jsxs(M,{direction:"row",alignItems:"center",spacing:1,children:[t.jsx(Fn,{checked:Q,onChange:async()=>{try{Q?await c(e.upsell_price?.id||e.price.id):await o(e.price_id,Y.id)}catch(w){Fe.error(w?.response?.data?.error||w?.message||"Failed")}},size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#12b886"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"#12b886"}}}),t.jsx(g,{sx:{fontSize:13,color:"text.secondary",cursor:"pointer",fontWeight:600},onClick:async()=>{try{Q?await c(e.upsell_price?.id||e.price.id):await o(e.price_id,Y.id)}catch(w){Fe.error(w?.response?.data?.error||w?.message||"Failed")}},children:ye}),!Q&&I>0&&t.jsx(Ge,{label:u("payment.checkout.upsell.off",{saving:I}),size:"small",sx:{height:22,fontSize:11,fontWeight:700,bgcolor:w=>w.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",border:"1px solid",borderColor:w=>w.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8",borderRadius:"9999px","& .MuiChip-label":{px:1}}})]}),t.jsx(g,{sx:{fontSize:13,color:"text.primary",whiteSpace:"nowrap",fontWeight:700},children:Q?ae:X})]})]})]})}function Pi({billingInterval:e}){const{t:n}=_e();if(!e?.available?.length||e.available.length<=1)return null;const r=e.available.reduce((s,i)=>Number(i.savings||0)>Number(s.savings||0)?i:s);return t.jsxs(M,{direction:"row",alignItems:"center",spacing:2,sx:{mb:3},children:[t.jsx(M,{direction:"row",alignItems:"center",sx:{bgcolor:"background.paper",borderRadius:"9999px",border:"1px solid",borderColor:"divider",p:"4px",display:"inline-flex",boxShadow:s=>s.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(s=>{const i=s.interval===e.current,o={bgcolor:a=>a.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:a=>a.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:a=>a.palette.mode==="dark"?"rgba(156,106,222,0.3)":"rgba(156,106,222,0.2)"},c={color:"text.secondary",border:"1px solid transparent","&:hover":{color:"text.primary"}};return t.jsx(_,{onClick:()=>{s.interval!==e.current&&!e.switching&&e.switch(s.interval)},sx:{px:3.5,py:1,borderRadius:"9999px",cursor:"pointer",transition:"all 0.3s ease",userSelect:"none",...i?o:c},children:e.switching&&i?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[s.interval]||s.interval)})},s.interval)})}),r.savings&&Number(r.savings)>0&&t.jsxs(M,{direction:"row",alignItems:"center",spacing:.75,sx:{px:1.5,py:.75,bgcolor:s=>s.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",fontSize:11,fontWeight:700,borderRadius:"9999px",border:"1px solid",borderColor:s=>s.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8",textTransform:"uppercase",letterSpacing:"0.05em"},children:[t.jsx(sn,{sx:{fontSize:14}}),t.jsxs(g,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit",color:"inherit",lineHeight:1},children:["SAVE ",r.savings,"%"]})]})]})}function Ti({crossSellItem:e,currency:n,exchangeRate:r,crossSellRequired:s,onAdd:i}){const{t:o}=_e();if(!e)return null;const{product:c}=e,a=c?.images?.[0]||"",l=c?.name||o("payment.checkout.cross_sell.add"),{recurring:u}=e,f=u?.interval?Ae[u.interval]:null,d=c?.description||"",m=d&&d!==l?d:f?o(f):"";return t.jsxs(_,{sx:{position:"relative"},children:[s&&t.jsx(Ge,{label:he(o,"payment.checkout.cross_sell.recommended","RECOMMENDED"),size:"small",sx:{position:"absolute",top:0,right:40,transform:"translateY(-50%)",zIndex:1,height:22,fontSize:9,fontWeight:900,letterSpacing:"0.12em",bgcolor:"primary.main",color:b=>$e(b),boxShadow:"0 4px 12px rgba(45,124,243,0.2)","& .MuiChip-label":{px:1.5}}}),t.jsx(_,{sx:{p:{xs:2,md:3},bgcolor:"background.paper",borderRadius:{xs:"16px",md:"24px"},border:"2px dashed",borderColor:b=>b.palette.mode==="dark"?"rgba(255,255,255,0.15)":"rgba(45,124,243,0.25)",boxShadow:b=>b.palette.mode==="dark"?"0 12px 40px -8px rgba(0,0,0,0.3)":"0 12px 40px -8px rgba(0,0,0,0.06)",transition:"all 0.3s ease",cursor:"pointer","&:hover":{borderColor:"primary.main",boxShadow:"0 12px 40px -8px rgba(0,0,0,0.1)"}},onClick:i,children:t.jsxs(M,{direction:"row",spacing:{xs:1.5,md:2.5},sx:{alignItems:"center",width:"100%"},children:[a?t.jsx(Ce,{src:a,variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},flexShrink:0}}):t.jsx(Ce,{variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},bgcolor:b=>b.palette.mode==="dark"?"rgba(255,255,255,0.06)":"#eff6ff",flexShrink:0},children:t.jsx(en,{sx:{fontSize:{xs:22,md:28},color:"primary.main",opacity:.45}})}),t.jsxs(_,{sx:{flex:1,minWidth:0},children:[t.jsxs(M,{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(M,{alignItems:"flex-end",sx:{flexShrink:0,ml:{xs:1,md:2}},children:[t.jsxs(g,{sx:{fontWeight:800,color:"text.primary",whiteSpace:"nowrap",fontSize:{xs:15,md:18}},children:[Ye(e,n,r)," ",n?.symbol]}),r&&e.base_amount&&t.jsxs(g,{sx:{fontSize:10,color:"text.disabled",fontWeight:700,lineHeight:1},children:["≈ $",Number(e.base_amount||0).toFixed(2)]})]})]}),m&&t.jsx(g,{sx:{fontSize:{xs:12,md:14},color:"text.secondary",fontWeight:500,lineHeight:1.4},noWrap:!0,children:m}),t.jsx(_,{sx:{pt:{xs:1.5,md:2}},children:t.jsx(Ee,{size:"small",variant:"outlined",startIcon:t.jsx($n,{sx:{fontSize:"14px !important"}}),sx:{textTransform:"none",fontSize:{xs:11,md:12},fontWeight:700,borderRadius:"8px",border:"1px solid",borderColor:"divider",color:"primary.main",bgcolor:"background.paper",boxShadow:1,px:1.5,py:.5,transition:"all 0.2s","&:hover":{bgcolor:"primary.main",color:b=>$e(b),borderColor:"primary.main"},"&:active":{transform:"scale(0.95)"}},onClick:b=>{b.stopPropagation(),i()},children:he(o,"payment.checkout.cross_sell.addToOrder","Add to order")})})]})]})})]})}function Ai({trial:e,mode:n,items:r}){const{t:s}=_e();if(e.active&&e.afterTrialPrice)return t.jsxs(M,{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:s("common.nextCharge")}),t.jsxs(g,{sx:{fontSize:16,color:"text.secondary"},children:[e.afterTrialPrice,e.afterTrialInterval?` ${s(Ae[e.afterTrialInterval]||"")}`:""]})]});if(!e.active&&["subscription","setup"].includes(n)){const i=r.find(a=>(a.upsell_price||a.price)?.recurring?.usage_type==="metered");if(!i)return null;const o=(i.upsell_price||i.price)?.recurring?.interval;if(!o)return null;const c=s("common.per",{interval:s(`common.${o}`)});return t.jsxs(M,{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:s("common.nextCharge")}),t.jsx(g,{sx:{fontSize:16,color:"text.secondary"},children:s("payment.checkout.metered",{recurring:c})})]})}return null}function In(){const{t:e}=_e(),{session:n}=Se(),{currency:r,isStripe:s,switching:i}=Ie(),{livemode:o}=vt(),{product:c,pageInfo:a}=vn(),l=St(),u=wi(),f=jn(),d=wt(),m=kn(),{isMobile:b}=Ze(),h=n?.mode||"payment",x=n?.discounts||[],v=n?.app_name||n?.payment_link?.app_name||"",F=n?.app_logo||n?.payment_link?.app_logo||"",S=b||l.items.length>=4,[C,R]=p.useState(b?l.items.length<=1:l.items.length<4),y=l.crossSellItem&&!l.items.some(T=>T.price_id===l.crossSellItem?.id),E=l.items.filter(T=>!T.cross_sell),N=l.items.filter(T=>T.price?.upsell?.upsells_to),$=N.length===1?N[0]:null,P=$?$.price?.upsell?.upsells_to:null,L=E.length<=1,q=L&&!!$&&["subscription","setup"].includes(h),K=!!$?.upsell_price,[B,H]=p.useState(!1),[ie,O]=p.useState(null),oe=ie!==null?ie:K,G=q?$.price?.recurring?.interval:null,V=q?P?.recurring?.interval:null;let J=0;if(q&&G&&V){const T=parseFloat($.price?.base_amount||$.price?.unit_amount||"0"),xe=parseFloat(P?.base_amount||P?.unit_amount||"0"),fe={day:365,week:52,month:12,year:1},k=T*(fe[G]||1),Q=xe*(fe[V]||1);k>Q&&k>0&&(J=Math.round((k-Q)/k*100))}const ne=p.useRef(d.status);p.useEffect(()=>{ne.current!=="unavailable"&&d.status==="unavailable"&&!s&&Fe.error(e("payment.dynamicPricing.unavailable.message")),ne.current=d.status},[d.status,s,e]);const se=cr(e,n,c,l.items),U=l.items.length>1,ue={bgcolor:"primary.main",color:T=>$e(T),boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)"},ge={color:"text.secondary","&:hover":{color:"text.primary"}},de=T=>({px:3.5,py:1,borderRadius:"9999px",cursor:"pointer",transition:"all 0.3s ease",userSelect:"none",...T?ue:ge});return t.jsxs(_,{sx:{display:"flex",flexDirection:"column",flex:1},children:[!b&&(v||F)&&t.jsxs(M,{direction:"row",alignItems:"center",spacing:1,sx:{mb:5},children:[F&&t.jsx(Ce,{src:F,alt:v,sx:{width:48,height:48,borderRadius:"16px",bgcolor:"background.paper",boxShadow:1,border:"1px solid",borderColor:"divider"}}),v&&t.jsx(g,{sx:{fontWeight:600,fontSize:15,color:"text.primary"},children:v})]}),!b&&t.jsx(_,{sx:{flexGrow:1,flexShrink:1,flexBasis:0}}),t.jsxs(_,{sx:{flexShrink:0},children:[t.jsxs(_,{sx:{mb:{xs:3,md:4}},children:[b&&(v||F)&&t.jsxs(M,{direction:"row",alignItems:"center",spacing:1,sx:{mb:1},children:[F&&t.jsx(Ce,{src:F,alt:v,sx:{width:24,height:24,borderRadius:"6px"}}),v&&t.jsx(g,{sx:{fontWeight:600,fontSize:13,color:"text.secondary"},children:v})]}),t.jsxs(M,{direction:"row",alignItems:"center",spacing:1,sx:{mb:1.5},children:[t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:T=>T.palette.mode==="dark"?`${T.palette.primary.main}1A`:`${T.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:se.badgeLabel}),f.trial.active&&f.trial.days>0&&t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:T=>T.palette.mode==="dark"?`${T.palette.primary.main}1A`:`${T.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:ln(e,f.trial.days,f.trial.afterTrialInterval||"day")}),!o&&t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:T=>T.palette.mode==="dark"?T.palette.grey[500]:T.palette.grey[400],bgcolor:T=>T.palette.mode==="dark"?"rgba(255,255,255,0.06)":T.palette.grey[100],px:1,py:.5,borderRadius:"4px"},children:e("common.livemode")})]}),t.jsx(g,{sx:{fontWeight:800,fontSize:{xs:24,md:36},lineHeight:1.1,letterSpacing:"-0.03em",color:"text.primary",mb:.75},children:U?he(e,"payment.checkout.orderSummary","Order Summary"):se.title}),(U||se.subtitle)&&t.jsx(g,{sx:{color:"text.secondary",fontSize:{xs:14,md:16},fontWeight:500,lineHeight:1.5},children:U?he(e,"payment.checkout.orderSummarySubtitle","Items included in this purchase"):se.subtitle}),q&&t.jsxs(M,{direction:"row",alignItems:"center",spacing:2,sx:{mt:2.5},children:[t.jsxs(M,{direction:"row",alignItems:"center",sx:{bgcolor:"background.paper",borderRadius:"9999px",border:"1px solid",borderColor:"divider",p:"4px",display:"inline-flex",boxShadow:T=>T.palette.mode==="dark"?"0 1px 2px 0 rgba(0,0,0,0.3)":"0 1px 2px 0 rgba(0,0,0,0.05)"},children:[t.jsx(_,{onClick:async()=>{if(K&&!B){O(!1),H(!0);try{await l.downsell($.upsell_price?.id||$.price_id)}catch(T){O(null),Fe.error(T?.response?.data?.error||T?.message||"Failed")}finally{H(!1),O(null)}}},sx:de(!oe),children:t.jsx(g,{component:"span",sx:{fontSize:14,fontWeight:700,color:"inherit",lineHeight:1},children:e(Ae[G]||"")})}),t.jsx(_,{onClick:async()=>{if(!K&&!B){O(!0),H(!0);try{await l.upsell($.price_id,P.id)}catch(T){O(null),Fe.error(T?.response?.data?.error||T?.message||"Failed")}finally{H(!1),O(null)}}},sx:de(oe),children:t.jsx(g,{component:"span",sx:{fontSize:14,fontWeight:700,color:"inherit",lineHeight:1},children:e(Ae[V]||"")})})]}),J>0&&t.jsxs(M,{direction:"row",alignItems:"center",spacing:.75,sx:{px:1.5,py:.75,bgcolor:T=>T.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",fontSize:11,fontWeight:700,borderRadius:"9999px",border:"1px solid",borderColor:T=>T.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8",textTransform:"uppercase",letterSpacing:"0.05em"},children:[t.jsx(sn,{sx:{fontSize:14}}),t.jsxs(g,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit",color:"inherit",lineHeight:1},children:["SAVE ",J,"%"]})]})]})]}),t.jsx(Pi,{billingInterval:u})]}),t.jsxs(_,{sx:{flexGrow:0,flexShrink:1,flexBasis:"auto",minHeight:{md:0},overflowY:{md:"auto"},"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},children:[S&&t.jsxs(M,{direction:"row",alignItems:"center",justifyContent:"space-between",onClick:()=>R(!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(on,{sx:{transform:C?"rotate(180deg)":"rotate(0deg)",transition:"0.3s"}})]}),t.jsxs(mt,{in:C||!S,children:[t.jsx(M,{spacing:2,sx:{mb:2},children:l.items.map(T=>t.jsx(Ri,{item:T,currency:r,discounts:x,exchangeRate:d.value,onQuantityChange:l.updateQuantity,onUpsell:l.upsell,onDownsell:l.downsell,trialActive:f.trial.active,trialDays:f.trial.days,hideUpsell:q||!L,isRateLoading:i||d.hasDynamicPricing&&d.status==="loading",showFeatures:a?.showProductFeatures??!1,t:e,children:T.cross_sell&&t.jsx(Ee,{size:"small",color:"error",variant:"text",onClick:l.removeCrossSell,sx:{mt:1,ml:-.5,textTransform:"none",fontSize:12},children:e("payment.checkout.cross_sell.remove")})},T.id))}),y&&t.jsx(_,{sx:{mb:2},children:t.jsx(Ti,{crossSellItem:l.crossSellItem,currency:r,exchangeRate:d.value,crossSellRequired:l.crossSellRequired,onAdd:l.addCrossSell})})]})]}),t.jsx(_,{sx:{flexShrink:0},children:t.jsx(Ai,{trial:{active:f.trial.active,days:f.trial.days,afterTrialPrice:f.trial.afterTrialPrice,afterTrialInterval:f.trial.afterTrialInterval},mode:h,items:l.items})}),t.jsx(_,{sx:{flexGrow:1,flexShrink:1,flexBasis:0}}),t.jsxs(_,{sx:{flexShrink:0},children:[d.hasDynamicPricing&&d.status==="unavailable"&&!s&&t.jsxs(M,{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(un,{hasDynamicPricing:d.hasDynamicPricing,rate:{value:d.value,display:d.display,provider:d.provider,providerDisplay:d.providerDisplay,fetchedAt:d.fetchedAt,status:d.status},slippage:{percent:m.percent,set:m.set},currencySymbol:r?.symbol||"",isSubscription:["subscription","setup"].includes(h)})]})]})}function Di({livemode:e,label:n=void 0}){const{t:r}=_e();return t.jsxs(M,{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:s=>s.palette.mode==="dark"?`${s.palette.primary.main}1A`:`${s.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:n||he(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:s=>s.palette.mode==="dark"?s.palette.grey[500]:s.palette.grey[400],bgcolor:s=>s.palette.mode==="dark"?"rgba(255,255,255,0.06)":s.palette.grey[100],px:1,py:.5,borderRadius:"4px"},children:r("common.livemode")})]})}function Mi(){const{t:e,locale:n}=_e(),{session:r,sessionData:s}=Se(),{livemode:i}=vt(),{product:o}=vn(),{currency:c,isStripe:a}=Ie(),l=St(),u=wt(),f=kn(),{locked:d}=et(),m=l.items[0],b=m?m.upsell_price||m.price:null,h=b?.metadata?.credit_config,x=h?.credit_amount?Number(h.credit_amount):0,v=h?.currency_id,{session:F,getCurrency:S}=dn(),C=v?S(v):null,R=F?.user?.did||s?.customer?.did,y=C?.decimal,E=C?.symbol||"Credits",N="Credits",$=b?.metadata?.meter_id,{data:P}=ut(async()=>{if(!$)return null;try{const{data:A}=await dt.get(`/api/meters/public/${$}`);return A}catch{return null}},{refreshDeps:[$]}),L=P?.name||o?.name||"Credits",q=h?.valid_duration_value,K=h?.valid_duration_unit||"days",B=h?.schedule,H=B?.enabled&&B?.delivery_mode&&B.delivery_mode!=="invoice",ie=q&&q>0,O=Math.max(x,1),oe=m?.adjustable_quantity,G=oe?.enabled!==!1,V=Math.max(oe?.minimum||1,1),J=Math.min(b?.quantity_limit_per_checkout??1/0,b?.quantity_available??1/0),ne=J?Math.min(oe?.maximum||1/0,J):oe?.maximum||1/0,{data:se}=ut(async()=>{if(!h||!R||!v||y==null)return null;try{const{data:A}=await dt.get("/api/meter-events/pending-amount",{params:{customer_id:R,currency_id:v}});return A?.[v]}catch{return null}},{refreshDeps:[h,R,v,y]}),U=p.useMemo(()=>{if(!se||!x||x<=0)return null;const A=new z(se||"0");if(!A.gt(new z(0)))return null;const be=Xe(x,y);return!be||be.isZero()?null:Math.ceil(A.mul(new z(100)).div(be).toNumber()/100)},[se,x,y]),ue=se&&new z(se||"0").gt(new z(0)),ge=p.useMemo(()=>ue?Be(lr(se,y),E,n):"",[ue,se,y,E,n]),de=U?U*O:0,T=de?Be(Re(de),E,n):"",xe=p.useMemo(()=>{if(H&&B){const A=B.interval_unit,be=B.interval_value;let Le;B.amount_per_grant?Le=Number(B.amount_per_grant):Le=x;const qe=ur(Re(Le),N),Rt=be===1?e(`common.${A}`):`${be} ${e(`common.${A}s`)}`;return B.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,H,B,e]),fe=p.useMemo(()=>ie?e("payment.checkout.creditTopup.validFor",{duration:q,unit:e(`common.${K}`)}):"",[ie,q,K,e]),k=!!xe,Q=m?.quantity||1,[Y,I]=p.useState(Q),[j,X]=p.useState(Q*O),[re,ae]=p.useState(!1),[ye,w]=p.useState(""),D=p.useRef(null);p.useEffect(()=>{d||r?.status==="complete"||m?.quantity&&m.quantity!==Y&&(I(m.quantity),X(m.quantity*O))},[m?.quantity]);const Z=p.useRef(!1);p.useEffect(()=>{if(!(d||r?.status==="complete")&&!Z.current&&U&&U>Y){Z.current=!0;const A=Math.min(Math.max(U,V),ne);I(A),X(A*O),m&&l.updateQuantity(m.price_id,A)}},[U]);const ce=ne*O,pe=V*O,me=p.useRef(null);p.useEffect(()=>()=>{me.current&&clearTimeout(me.current)},[]);const we=p.useCallback(A=>{if(A<=0)return;const be=Math.max(pe,Math.min(ce,A)),Le=Math.ceil(be/O),qe=Math.max(V,Math.min(ne,Le));I(qe),X(be),m&&(me.current&&clearTimeout(me.current),me.current=setTimeout(()=>{l.updateQuantity(m.price_id,qe)},400))},[O,V,ne,pe,ce,m,l]),Oe=p.useCallback(A=>{const be=j+A*O;be<O*V||Math.ceil(be/O)>ne||we(be)},[j,O,V,ne,we]),Ue=Math.max(V,Math.min(ne,Math.ceil(j/O))),Qe=Ue*O,kt=Re(Qe,6,!0,!0),Rn=Re(j,6,!0,!0),jt=G&&O>1,Pn=p.useMemo(()=>ue?Qe>=de?e("payment.checkout.creditTopup.pendingEnough",{pendingAmount:ge,availableAmount:Be(Re(Qe-de),E,n)}):e("payment.checkout.creditTopup.pendingWarning",{pendingAmount:ge,minCredits:T}):"",[ue,Qe,de,ge,E,n,T,e]),Tn=p.useCallback(()=>{G&&(w(String(j)),ae(!0),setTimeout(()=>D.current?.select(),0))},[G,j]),tt=p.useCallback(()=>{ae(!1);const A=parseInt(ye.replace(/,/g,""),10);!Number.isFinite(A)||A<=0||we(A)},[ye,we]),An=p.useCallback(A=>{A.key==="Enter"?tt():A.key==="Escape"&&ae(!1)},[tt]),Ct={xs:48,md:72},It={fontSize:Ct,fontWeight:800,lineHeight:1,letterSpacing:"-0.03em"},Et={width:{xs:40,md:56},height:{xs:40,md:56},borderRadius:"50%",bgcolor:"background.paper",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(255,255,255,0.12)":"divider",color:"text.secondary",transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",color:"primary.main",bgcolor:"background.paper"},"&.Mui-disabled":{borderColor:A=>A.palette.mode==="dark"?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",color:A=>A.palette.mode==="dark"?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.12)"}};return t.jsxs(_,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[t.jsxs(_,{sx:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center"},children:[t.jsx(Di,{livemode:i,label:he(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:L})}),k&&t.jsx(_,{sx:{display:"flex",alignItems:"flex-start",gap:1,mb:{xs:1.5,md:2.5}},children:t.jsx(g,{sx:{fontSize:{xs:13,md:15},fontWeight:500,color:"text.secondary",lineHeight:1.5},children:xe})}),ue&&t.jsxs(M,{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(Wn,{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:Pn})]}),G?t.jsxs(_,{sx:{display:"flex",flexDirection:"column",maxWidth:480},children:[t.jsx(g,{sx:{fontSize:{xs:14,md:17},fontWeight:700,color:"text.secondary",mt:{xs:3,md:5},mb:{xs:2,md:3}},children:e("payment.checkout.creditTopup.question",{symbol:N})}),t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:{xs:1.5,md:2}},children:[t.jsx(Ve,{onClick:()=>Oe(-1),disabled:Ue<=V,sx:Et,children:t.jsx(_,{component:"span",sx:{fontSize:{xs:22,md:28},fontWeight:300,lineHeight:1,mt:"-1px"},children:"−"})}),t.jsxs(_,{sx:{flex:1,minWidth:0,textAlign:"center",cursor:G?"text":"default"},onClick:Tn,children:[t.jsx(_,{sx:{height:Ct,display:"flex",alignItems:"center",justifyContent:"center"},children:re?t.jsx(xt,{inputRef:D,value:ye,onChange:A=>w(A.target.value.replace(/\D/g,"")),onBlur:tt,onKeyDown:An,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:Rn})}),t.jsx(_,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.75,mt:1},children:t.jsx(g,{sx:{fontSize:{xs:12,md:14},fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.05em"},children:N})})]}),t.jsx(Ve,{onClick:()=>Oe(1),disabled:Ue>=ne,sx:Et,children:t.jsx(_,{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(_,{sx:{display:"flex",flexDirection:"column",mt:{xs:3,md:4},borderRadius:"20px",backdropFilter:"blur(12px)",bgcolor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.08)":"rgba(59,130,246,0.04)",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.18)":"rgba(59,130,246,0.10)",boxShadow:A=>A.palette.mode==="dark"?"0 8px 32px rgba(59,130,246,0.06)":"0 8px 32px rgba(59,130,246,0.04)"},children:[t.jsxs(_,{sx:{p:{xs:2.5,md:3.5}},children:[t.jsxs(g,{sx:{fontSize:{xs:16,md:20},fontWeight:700,color:"primary.main",mb:.5},children:[e("payment.checkout.creditTopup.willReceive"),": ",t.jsx(_,{component:"span",sx:{fontWeight:800},children:Be(kt,N,n)})]}),t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.5},children:[t.jsx(On,{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")})]}),fe&&t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,px:{xs:2.5,md:3.5},py:{xs:1.5,md:2},borderTop:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.15)":"rgba(59,130,246,0.08)"},children:[t.jsx(Pt,{sx:{fontSize:14,color:"grey.500"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:fe})]})]}),!jt&&fe&&t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,mt:{xs:2.5,md:3.5}},children:[t.jsx(Un,{sx:{fontSize:14,color:"grey.500"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:fe})]})]}):t.jsxs(_,{sx:{display:"flex",flexDirection:"column",mt:{xs:2,md:3},borderRadius:"20px",backdropFilter:"blur(12px)",bgcolor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.08)":"rgba(59,130,246,0.04)",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.18)":"rgba(59,130,246,0.10)",boxShadow:A=>A.palette.mode==="dark"?"0 8px 32px rgba(59,130,246,0.06)":"0 8px 32px rgba(59,130,246,0.04)"},children:[t.jsxs(_,{sx:{p:{xs:2.5,md:3.5}},children:[t.jsx(g,{sx:{fontSize:{xs:13,md:14},fontWeight:600,color:"text.secondary",mb:1},children:e("payment.checkout.creditTopup.willReceive")}),t.jsx(_,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(g,{sx:{fontSize:{xs:32,md:48},fontWeight:800,lineHeight:1,letterSpacing:"-0.03em",color:"primary.main"},children:Be(kt,N,n)})})]}),fe&&t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,px:{xs:2.5,md:3.5},py:{xs:1.5,md:2},borderTop:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.15)":"rgba(59,130,246,0.08)"},children:[t.jsx(Pt,{sx:{fontSize:14,color:"grey.500"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:fe})]})]})]}),t.jsxs(_,{sx:{flexShrink:0},children:[u.hasDynamicPricing&&u.status==="unavailable"&&!a&&t.jsxs(M,{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(un,{hasDynamicPricing:u.hasDynamicPricing,rate:{value:u.value,display:u.display,provider:u.provider,providerDisplay:u.providerDisplay,fetchedAt:u.fetchedAt,status:u.status},slippage:{percent:f.percent,set:f.set},currencySymbol:c?.symbol||"",isSubscription:["subscription","setup"].includes(r?.mode||"payment")})]})]})}const zi=In;function Ni(){const{session:e,items:n}=Se();switch(Ei(e,n)){case"subscription":return t.jsx(zi,{});case"credit-topup":return t.jsx(Mi,{});default:return t.jsx(In,{})}}function Fi({value:e,country:n,onChange:r,onCountryChange:s,label:i,error:o=void 0,onBlur:c=void 0}){const a=p.useRef(!1),l=p.useCallback(x=>{if(!a.current)try{a.current=!0,x()}finally{requestAnimationFrame(()=>{a.current=!1})}},[]),{phone:u,handlePhoneValueChange:f,inputRef:d,country:m,setCountry:b}=dr({defaultCountry:pr(n)?n:"us",value:e||"",countries:fr,onChange:x=>{l(()=>{r(x.phone),s(x.country)})}});er(()=>{mr().catch(x=>{console.error("Failed to preload phone validator:",x)})}),p.useEffect(()=>{!n||n===m||l(()=>{b(n)})},[n,m,b,l]);const h=p.useCallback(x=>{l(()=>{b(x),s(x)})},[b,l,s]);return t.jsxs(_,{sx:{mb:1.5},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.primary",mb:.5},children:i}),t.jsx(xt,{fullWidth:!0,value:u,onChange:f,onBlur:c,type:"tel",inputRef:d,startAdornment:t.jsx(ht,{position:"start",sx:{mr:.25,ml:-.5},children:t.jsx(pn,{value:m,onChange:h,sx:{".MuiOutlinedInput-notchedOutline":{borderColor:"transparent !important"},"& .MuiSelect-select":{py:0,pr:"20px !important"}},showDialCode:!0})}),sx:{bgcolor:x=>x.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50",borderRadius:"8px",px:1.5,py:.75,fontSize:14,"& .MuiInputBase-input":{p:0}}}),o&&t.jsx(g,{sx:{fontSize:12,color:"error.main",mt:.25},children:o})]})}const $i=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 Wi({form:e,isLoggedIn:n}){const{t:r}=_e(),s=$i(r),[i,o]=p.useState(!1),[c,a]=p.useState(!1),l=p.useRef(!1);p.useEffect(()=>{l.current||!e.prefetched&&!e.values.customer_name&&!e.values.customer_email||(l.current=!0,e.checkValid().then(f=>{o(!f),a(!0)}))},[e.prefetched]);const u=p.useCallback((f,d)=>e.onChange(f,d),[e.onChange]);return p.useEffect(()=>{c&&!i&&Object.keys(e.errors).length>0&&o(!0)},[e.errors]),!n||!c?null:i?t.jsxs(_,{sx:{mt:2},children:[t.jsxs(M,{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(M,{spacing:0,sx:{p:2,backgroundColor:"background.paper",borderRadius:1,border:"1px solid",borderColor:"divider"},children:e.fields.filter(f=>f.name!=="billing_address.country").map(f=>{const{name:d}=f,m=s[d]||d,b=d.includes(".")?d.split(".").reduce((v,F)=>v?.[F],e.values):e.values[d],h=d==="billing_address.postal_code";return d==="customer_phone"?t.jsx(Fi,{value:b||"",country:e.values.billing_address?.country||"",onChange:v=>u("customer_phone",v),onCountryChange:v=>u("billing_address.country",v),onBlur:()=>e.validateField(d),label:m,error:e.errors[d]},d):t.jsxs(_,{sx:{mb:1.5},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.primary",mb:.5},children:m}),t.jsx(xt,{fullWidth:!0,value:b||"",onChange:v=>u(d,v.target.value),onBlur:()=>e.validateField(d),startAdornment:h?t.jsx(ht,{position:"start",sx:{mr:.5,ml:-.5},children:t.jsx(pn,{value:e.values.billing_address?.country||"",onChange:v=>u("billing_address.country",v),sx:{".MuiOutlinedInput-notchedOutline":{borderColor:"transparent !important"},"& .MuiSelect-select":{py:0,pr:"20px !important"}}})}):void 0,sx:{bgcolor:v=>v.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50",borderRadius:"8px",px:1.5,py:.75,fontSize:14,"& .MuiInputBase-input":{p:0}}}),e.errors[d]&&t.jsx(g,{sx:{fontSize:12,color:"error.main",mt:.25},children:e.errors[d]})]},d)})})]}):t.jsxs(_,{sx:{mt:2},children:[t.jsxs(M,{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(M,{spacing:.5,sx:{p:2,backgroundColor:"background.paper",borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.values.customer_name&&t.jsx(g,{variant:"body2",sx:{color:"text.primary",fontWeight:600,fontSize:"0.9375rem"},children:e.values.customer_name}),e.values.customer_email&&t.jsx(g,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:e.values.customer_email}),e.fields.some(f=>f.name==="customer_phone")&&e.values.customer_phone&&t.jsx(g,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:e.values.customer_phone}),(e.values.billing_address?.country||e.values.billing_address?.state||e.values.billing_address?.postal_code)&&t.jsxs(M,{direction:"row",alignItems:"center",spacing:.75,children:[e.values.billing_address?.country&&t.jsx(_,{component:"span",sx:{fontSize:14,lineHeight:1},children:xr(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 Oi({mode:e,subscription:n,staking:r,appName:s}){const{t:i}=_e();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?i("payment.checkout.confirm.withStake",{payee:s||"New Payment Kit"}):i("payment.checkout.confirm.withoutStake",{payee:s||"New Payment Kit"}))})}function Ui({status:e,context:n,onReset:r}){const{t:s}=_e(),i=p.useRef(e);return p.useEffect(()=>{if(e!==i.current&&(i.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,s,r]),null}function Zt({promotion:e,discounts:n,discountAmount:r,currency:s=null,initialShowInput:i=!1,isAmountLoading:o=!1}){const{t:c,locale:a}=_e(),[l,u]=p.useState(!1),[f,d]=p.useState(""),[m,b]=p.useState(!1),[h,x]=p.useState(""),v=i||l,F=async()=>{if(!f.trim())return;b(!0),x("");const C=await e.apply(f.trim());C.success?(d(""),u(!1)):x(C.error||"Invalid code"),b(!1)},S=C=>{C.key==="Enter"&&!m&&f.trim()&&F()};return n?.length>0?t.jsx(_,{children:n.map((C,R)=>{const y=C.promotion_code_details?.code||C.verification_data?.code||C.promotion_code||"",E=C.coupon_details||{},N=E&&s?hr(E,s,a):"";return t.jsxs(M,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[t.jsxs(M,{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(tn,{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(an,{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||R)})}):e.active?t.jsx(_,{sx:{minHeight:36},children:v?t.jsxs(_,{onBlur:C=>{i||!C.currentTarget.contains(C.relatedTarget)&&!f.trim()&&u(!1)},children:[t.jsx(nn,{fullWidth:!0,size:"small",value:f,onChange:C=>d(C.target.value),onKeyPress:S,placeholder:c("payment.checkout.promotion.placeholder"),disabled:m,autoFocus:!0,slotProps:{input:{endAdornment:t.jsx(ht,{position:"end",children:t.jsx(Ee,{size:"small",onClick:F,disabled:!f.trim()||m,variant:"text",sx:{color:"primary.main",fontSize:13,textTransform:"none",minWidth:"auto",fontWeight:600},children:m?t.jsx(ft,{size:16}):c("payment.checkout.promotion.apply")})})}},sx:{"& .MuiOutlinedInput-root":{pr:1,borderRadius:"8px",height:36},"& .MuiOutlinedInput-input":{py:"6px",fontSize:13}}}),h&&t.jsx(Ln,{severity:"error",sx:{mt:.5,py:0,fontSize:12,borderRadius:"6px"},children:h})]}):t.jsx(Ee,{onClick:()=>u(!0),startIcon:t.jsx(rn,{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:c("payment.checkout.promotion.add_code")})}):null}function Li(){const{t:e,locale:n}=_e(),{session:r,sessionData:s,subscription:i,refresh:o}=Se(),{isDonation:c}=vt(),a=ki(),l=Cn(),u=et(),f=jn(),{session:d,connect:m,prefix:b}=dn(),{inventoryOk:h}=St(),x=vi(),v=wt(),{isMobile:F}=Ze(),S=a.switching||v.hasDynamicPricing&&v.status==="loading",{currency:C,types:R,isStripe:y,isCrypto:E}=a,N=r?.mode||"payment",$=r?.discounts||[],P=!!d?.user,L=e(c?"payment.checkout.donate":`payment.checkout.${N}`),q=P?L:e("payment.checkout.connect",{action:L}),[K,B]=p.useState(!1),[H,ie]=p.useState(!1),[O,oe]=p.useState(!1);p.useEffect(()=>{u.status==="failed"&&u.context?.code==="CUSTOMER_LIMITED"&&B(!0)},[u.status,u.context]);const G=u.status==="idle"&&r?.status==="open"&&h,V=["submitting","waiting_did"].includes(u.status),J=p.useCallback(()=>{if(G){if(u.lock(),P||c){u.execute();return}d?.login?.(()=>{Promise.all([o(!0),l.refetchCustomer()]).then(()=>u.execute()).catch(k=>{console.error("Post-login refresh failed:",k)})})}},[G,P,c,d,o,l,u]);p.useEffect(()=>{d?.user&&!u.status.startsWith("submitting")&&l.refetchCustomer()},[d?.user]);const ne=R.find(k=>k.type==="crypto"),se=p.useMemo(()=>a.available.filter(k=>k.type!=="stripe"),[a.available]),U=p.useMemo(()=>se.length?se.map(k=>({id:k.id,name:k.name,logo:k.logo||"",currencies:k.payment_currencies||[]})):[],[se]),ue=a.current?.id||"";p.useEffect(()=>{const k=Q=>{if(Q.key==="Enter"&&G&&u.status==="idle"){if(Q.target?.tagName?.toLowerCase()==="textarea")return;J()}};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[G,u.status,J]);const ge=p.useRef(!1),de=p.useRef(!1),T=p.useRef(u.status);p.useEffect(()=>{T.current=u.status},[u.status]),p.useEffect(()=>{if(u.status!=="waiting_did"){ge.current=!1,de.current=!1;return}const k=u.context;if(k?.type!=="did_connect"||!m||ge.current)return;ge.current=!0;const Q=`${b||window.location.origin}/api/did`.replace(/([^:])\/\//g,"$1/");m.open({locale:n,action:k.action,prefix:Q,saveConnect:!1,extraParams:k.extraParams,onSuccess:async()=>{de.current=!0,m.close(),await u.didConnectComplete()},onClose:()=>{m.close(),T.current==="waiting_did"&&(de.current||u.reset())},onError:Y=>{console.error("DID Connect error:",Y),T.current==="waiting_did"&&u.reset()},messages:{title:e("payment.checkout.connectModal.title",{action:q}),scan:e("payment.checkout.connectModal.scan"),confirm:e("payment.checkout.connectModal.confirm")}})},[u.status,u.context,m,n,e,q]);const xe=R.find(k=>k.active)?.type||"crypto",fe=R.length>1;return t.jsxs(_,{sx:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[t.jsxs(_,{sx:{flex:1,display:"flex",flexDirection:"column",overflowY:"auto",minHeight:0,"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:700,letterSpacing:"0.02em",color:"text.primary",mb:2.5},children:e("payment.checkout.paymentDetails")}),fe&&t.jsx(qn,{value:xe,exclusive:!0,onChange:(k,Q)=>Q&&a.setType(Q),fullWidth:!0,size:"small",sx:{mb:2.5,bgcolor:k=>k.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:k=>k.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:R.map(k=>t.jsxs(Bn,{value:k.type,children:[k.type==="stripe"?t.jsx(Hn,{sx:{fontSize:18}}):t.jsx(Vn,{sx:{fontSize:18}}),k.label||(k.type==="stripe"?"Card":"Crypto")]},k.type))}),E&&U.length>0&&t.jsxs(M,{direction:"row",spacing:1.5,sx:{mb:2.5},children:[U.length>1&&t.jsxs(_,{sx:{flex:1},children:[t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"text.secondary",mb:.5,letterSpacing:"0.02em"},children:e("common.network")}),t.jsx(nt,{value:ue,onChange:k=>{const Q=U.find(Y=>Y.id===k.target.value);Q?.currencies?.[0]&&a.setCurrency(Q.currencies[0].id)},fullWidth:!0,size:"small",sx:{borderRadius:"8px",bgcolor:k=>k.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(k=>t.jsxs(rt,{value:k.id,sx:{gap:1},children:[k.logo&&t.jsx(Ce,{src:k.logo,sx:{width:20,height:20}}),t.jsx(g,{sx:{fontSize:14},children:k.name})]},k.id))})]}),t.jsxs(_,{sx:{flex:1},children:[t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"text.secondary",mb:.5,letterSpacing:"0.02em"},children:e("common.currency")}),t.jsx(nt,{value:C?.id||"",onChange:k=>a.setCurrency(k.target.value),fullWidth:!0,size:"small",sx:{borderRadius:"8px",bgcolor:k=>k.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:(E&&U.length>1?U.find(k=>k.id===ue)?.currencies||[]:ne?.currencies||[]).map(k=>t.jsxs(rt,{value:k.id,sx:{gap:1},children:[k.logo&&t.jsx(Ce,{src:k.logo,sx:{width:20,height:20}}),t.jsx(g,{sx:{fontSize:14},children:k.symbol}),t.jsx(g,{sx:{fontSize:12,color:"text.secondary",ml:.5},children:k.name})]},k.id))})]})]}),y&&C&&t.jsxs(_,{sx:{mb:2.5},children:[t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"text.secondary",mb:.5,letterSpacing:"0.02em"},children:e("common.currency")}),t.jsx(nt,{value:C.id||"usd",readOnly:!0,fullWidth:!0,size:"small",IconComponent:()=>null,sx:{borderRadius:"8px",bgcolor:k=>k.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(Wi,{form:l,isLoggedIn:P})]}),t.jsxs(_,{className:"cko-v2-submit-btn",sx:{flexShrink:0},children:[F&&f.staking&&t.jsxs(t.Fragment,{children:[t.jsxs(_,{onClick:()=>ie(!H),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(on,{sx:{fontSize:18,color:"text.secondary",transition:"0.2s",transform:H?"rotate(180deg)":"rotate(0deg)"}})]}),t.jsxs(mt,{in:H,children:[t.jsxs(M,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[t.jsxs(M,{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"}})]}),S?t.jsx(Ne,{variant:"text",width:60,height:18}):t.jsxs(g,{sx:{fontSize:13,fontWeight:600},children:["+",f.staking]})]}),t.jsx(lt,{sx:{mb:1}})]})]}),!F&&t.jsxs(t.Fragment,{children:[t.jsx(lt,{sx:{mb:2}}),f.staking&&t.jsxs(M,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[t.jsxs(M,{direction:"row",spacing:.5,alignItems:"center",children:[t.jsx(g,{sx:{fontSize:14,color:"text.secondary"},children:e("payment.checkout.staking.title")}),t.jsx(Qn,{title:e("payment.checkout.staking.tooltip"),placement:"top",arrow:!0,slotProps:{popper:{sx:gr}},children:t.jsx(Tt,{sx:{fontSize:16,color:"text.disabled"}})})]}),S?t.jsx(Ne,{variant:"text",width:80,height:22}):t.jsxs(g,{sx:{fontSize:14,fontWeight:600},children:["+",f.staking]})]}),t.jsx(Zt,{promotion:{applied:x.applied,code:x.code,active:x.active,inactiveReason:x.inactiveReason,apply:x.apply,remove:x.remove},discounts:$,discountAmount:f.discount,currency:C,isAmountLoading:S})]}),(()=>{const Q=(f.total||"0").split(/\s+/),Y=Q[0]||"0",I=Q.slice(1).join(" ")||C?.symbol||"",j=Y.indexOf("."),X=j>=0?Y.slice(0,j):Y,re=j>=0?Y.slice(j):"";return t.jsxs(_,{sx:{mb:F?1.5:2.5},children:[t.jsxs(M,{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")}),S?t.jsx(Ne,{variant:"text",width:140,height:44}):t.jsxs(_,{sx:{textAlign:"right"},children:[t.jsx(g,{component:"span",sx:{fontSize:{xs:28,md:36},fontWeight:800,color:"text.primary",lineHeight:1,transition:"opacity 0.3s ease"},children:X}),re&&t.jsx(g,{component:"span",sx:{fontSize:{xs:16,md:20},fontWeight:700,color:"text.secondary",lineHeight:1},children:re}),t.jsx(g,{component:"span",sx:{fontSize:{xs:14,md:16},fontWeight:600,color:"text.secondary",ml:.75},children:I})]})]}),(f.usdEquivalent||F&&x.active)&&!S&&t.jsxs(M,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mt:.25},children:[F&&!x.applied&&x.active?t.jsxs(_,{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:he(e,"payment.checkout.promotion.add","Add promo code")})]}):F&&x.applied?t.jsxs(M,{direction:"row",alignItems:"center",spacing:.5,children:[t.jsx(At,{sx:{fontSize:14,color:"success.main"}}),t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"success.main"},children:x.code}),f.discount&&t.jsxs(g,{sx:{fontSize:11,color:"text.secondary"},children:["(-",f.discount,")"]}),t.jsx(an,{onClick:x.remove,sx:{fontSize:14,color:"error.main",cursor:"pointer",ml:.25}})]}):t.jsx(_,{}),f.usdEquivalent&&t.jsxs(g,{sx:{fontSize:13,color:"text.secondary"},children:["≈ ",f.usdEquivalent]})]})]})})(),t.jsxs(Ee,{variant:"contained",size:"large",fullWidth:!0,disabled:!G||u.status==="waiting_stripe",onClick:J,startIcon:V?t.jsx(ft,{size:20,color:"inherit"}):null,sx:{py:1.5,fontSize:"1.1rem",fontWeight:600,textTransform:"none",borderRadius:"12px",color:k=>$e(k),position:"relative",overflow:"hidden","&:hover":{bgcolor:"primary.main"},"&:hover .arrow-icon":{transform:"translateX(4px)"},"&:hover .shine-layer":{transform:"translateX(100%)"}},children:[t.jsx(_,{component:"span",sx:{position:"relative",zIndex:1},children:V?`${e("payment.checkout.processing")}...`:q}),!V&&t.jsx(Kn,{className:"arrow-icon",sx:{ml:1,position:"relative",zIndex:1,transition:"transform 0.2s ease"}}),t.jsx(_,{className:"shine-layer",sx:{position:"absolute",inset:0,background:"linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent)",transform:"translateX(-100%)",transition:"transform 0.7s ease",pointerEvents:"none"}})]}),F&&t.jsxs(M,{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:he(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:he(e,"common.terms","Terms")}),t.jsx(g,{sx:{fontSize:11,color:"text.disabled"},children:"|"}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:he(e,"common.privacy","Privacy")})]})]}),F&&t.jsxs(Gn,{anchor:"bottom",open:O,onClose:()=>oe(!1),PaperProps:{sx:{borderRadius:"16px 16px 0 0",p:3,pb:4,minHeight:"30vh"}},children:[t.jsx(_,{sx:{width:40,height:4,bgcolor:"divider",borderRadius:2,mx:"auto",mb:3}}),t.jsx(g,{sx:{fontWeight:700,fontSize:16,mb:2},children:he(e,"payment.checkout.promotion.add","Add promo code")}),t.jsx(Zt,{initialShowInput:!0,promotion:{applied:x.applied,code:x.code,active:x.active,inactiveReason:x.inactiveReason,apply:async(...k)=>{const Q=await x.apply(...k);return Q.success&&oe(!1),Q},remove:x.remove},discounts:$,discountAmount:f.discount,currency:C})]}),t.jsxs(_,{sx:{flexShrink:0},children:[t.jsx(Oi,{mode:N,subscription:i,staking:f.staking,appName:yr(r?.line_items||[])}),!F&&t.jsxs(M,{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:he(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:he(e,"common.terms","Terms")}),t.jsx(g,{sx:{fontSize:11,color:"text.disabled"},children:"|"}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:he(e,"common.privacy","Privacy")})]})]}),t.jsx(Ui,{status:u.status,context:u.context,onReset:u.reset}),K&&t.jsx(br,{customerId:s?.customer?.id||r?.user?.did,onPaid:()=>{B(!1),u.retry()},alertMessage:e("payment.customer.pastDue.alert.customMessage"),detailLinkOptions:{enabled:!0,onClick:()=>{B(!1),window.open(cn(mn(),`/customer/invoice/past-due?referer=${encodeURIComponent(window.location.href)}`),"_self")}},dialogProps:{open:K,onClose:()=>{B(!1),u.reset()},title:e("payment.customer.pastDue.alert.title")}})]})}function qi(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 Bi(){const{t:e}=_e(),{session:n}=Se(),{currency:r,stripe:s}=Ie(),i=et(),o=Cn(),c=n?.mode||"payment",a=i.context?.type==="stripe"?i.context:null,l=i.status==="waiting_stripe"&&a?.clientSecret;return t.jsxs(t.Fragment,{children:[l&&t.jsx(_r,{clientSecret:a.clientSecret,intentType:a.intentType||"payment_intent",publicKey:s?.publishableKey||"",mode:c,customer:{name:o.values.customer_name,email:o.values.customer_email,phone:o.values.customer_phone,address:o.values.billing_address},returnUrl:qi(n),onConfirm:i.stripeConfirm,onCancel:i.stripeCancel,onSkip:a.noPaymentRequired&&`${n?.metadata?.allow_skip_payment_method}`=="true"?i.stripeSkip:void 0}),i.status==="confirming_price"&&i.context?.type==="price_change"&&t.jsx(Sr,{open:!0,changePercent:i.context.changePercent,onConfirm:i.confirm,onCancel:i.cancel,loading:!1}),i.status==="confirming_fast_pay"&&i.context?.type==="fast_pay"&&t.jsx(Mt,{onConfirm:i.confirm,onCancel:i.cancel,title:i.context.payType==="credit"?e("payment.checkout.fastPay.credit.title"):e("payment.checkout.fastPay.title"),message:i.context.payType==="credit"?t.jsx(g,{children:e("payment.checkout.fastPay.credit.meteringSubscriptionMessage",{available:`${He(i.context.amount||"0",r)} ${r?.symbol||""}`})}):t.jsxs(M,{children:[t.jsx(g,{children:e("payment.checkout.fastPay.autoPaymentReason")}),t.jsx(lt,{sx:{mt:1.5,mb:1.5}}),t.jsxs(M,{spacing:1,children:[t.jsxs(M,{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:i.context.payer?`${i.context.payer.slice(0,10)}...${i.context.payer.slice(-6)}`:""})]}),t.jsxs(M,{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(i.context.amount||"0",r)," ",r?.symbol||""]})]})]})]}),loading:!1,color:"primary"}),i.context?.type==="service_suspended"&&t.jsx(wr,{open:!0,onClose:i.cancel}),i.status==="credit_insufficient"&&i.context?.type==="credit_insufficient"&&t.jsx(Mt,{onConfirm:i.cancel,onCancel:i.cancel,title:e("payment.checkout.fastPay.credit.insufficientTitle"),message:t.jsx(g,{children:e("payment.checkout.fastPay.credit.insufficientMessage")}),confirm:e("common.confirm")})]})}function Hi(){return t.jsx(_,{sx:{display:"flex",gap:2,mt:4},children:[0,1,2].map(e=>t.jsx(_,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"primary.main",opacity:.4,animation:`pulse 1.4s ease-in-out ${e*.2}s infinite`,"@keyframes pulse":{"0%, 80%, 100%":{transform:"scale(0.6)",opacity:.3},"40%":{transform:"scale(1)",opacity:.7}}}},e))})}function Vi(){return t.jsxs(_,{sx:{position:"relative",width:{xs:160,md:200},height:{xs:160,md:200}},children:[t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:e=>`linear-gradient(45deg, ${le(e.palette.primary.main,.1)}, ${le(e.palette.primary.main,.03)})`,filter:"blur(1px)",animation:"spin 20s linear infinite","@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}}}),t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:e=>`linear-gradient(135deg, ${le(e.palette.primary.main,.07)}, ${le(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 En({mode:e="inline"}){const n=e==="standalone",s=We().palette.primary.main,i={background:{xs:"none",md:`linear-gradient(160deg, ${le(s,.03)} 0%, ${le(s,.07)} 50%, ${le(s,.04)} 100%)`},bgcolor:c=>c.palette.mode==="dark"?"background.default":"#f8faff"},o=t.jsxs(_,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1},children:[t.jsx(Vi,{}),t.jsx(Hi,{})]});return n?t.jsxs(_,{sx:{width:"100%",height:"100vh",minHeight:"100vh",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",...i},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(a=>["locale-selector","theme-mode-toggle","session-user"].includes(a.key))}),o]}):t.jsx(_,{sx:{display:"flex",width:"100%",minHeight:{xs:400,md:640},maxWidth:1120,mx:"auto",borderRadius:"16px",overflow:"hidden",boxShadow:1,border:1,borderColor:"divider",borderLeft:"4px solid",borderLeftColor:"primary.main",...i},children:o})}function Qi(){const e=We(),n=le(e.palette.primary.main,.06);return t.jsxs(_,{sx:{position:"relative",width:{xs:200,md:260},height:{xs:200,md:260},mb:{xs:4,md:6}},children:[t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:r=>`linear-gradient(45deg, ${le(r.palette.primary.main,.1)}, ${le(r.palette.primary.main,.03)})`,filter:"blur(1px)",animation:"spin 20s linear infinite","@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}}}),t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:r=>`linear-gradient(135deg, ${le(r.palette.primary.main,.07)}, ${le(r.palette.primary.main,.01)})`,filter:"blur(1px)",transform:"scale(0.88)",opacity:.6,animation:"spinReverse 15s linear infinite","@keyframes spinReverse":{from:{transform:"scale(0.88) rotate(0deg)"},to:{transform:"scale(0.88) rotate(-360deg)"}}}}),t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",overflow:"hidden",animation:"spin 20s linear infinite"},children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 260 260",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{position:"absolute",inset:0},children:[[52,87,122,157,192].map(r=>t.jsx("line",{x1:"30",y1:r,x2:"230",y2:r,stroke:n,strokeWidth:"0.5"},`h${r}`)),[52,87,122,157,192].map(r=>t.jsx("line",{x1:r,y1:"30",x2:r,y2:"230",stroke:n,strokeWidth:"0.5"},`v${r}`)),t.jsx("line",{x1:"52",y1:"52",x2:"192",y2:"192",stroke:n,strokeWidth:"0.5"}),t.jsx("line",{x1:"192",y1:"52",x2:"52",y2:"192",stroke:n,strokeWidth:"0.5"}),t.jsx("circle",{cx:"130",cy:"130",r:"40",stroke:n,strokeWidth:"0.5"}),t.jsx("circle",{cx:"130",cy:"130",r:"75",stroke:n,strokeWidth:"0.5"}),[[122,87],[157,87],[87,122],[122,122],[157,122],[192,122],[87,157],[122,157],[157,157],[122,192],[157,192]].map(([r,s])=>t.jsx("circle",{cx:r,cy:s,r:"1.5",fill:n},`d${r}-${s}`))]})})]})}function Ki(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 Jt({error:e,errorCode:n=void 0}){const{t:r}=_e(),s=We(),{title:i,description:o}=Ki(n,e,r),c=s.palette.primary.main,a=typeof window<"u"?window.blocklet?.appUrl:"/";return t.jsxs(M,{alignItems:"center",justifyContent:"center",sx:{flex:1,textAlign:"center",px:3},children:[t.jsx(Qi,{}),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:i}),t.jsx(g,{sx:{color:"text.secondary",fontSize:{xs:15,md:17},fontWeight:300,lineHeight:1.7,maxWidth:420,letterSpacing:"0.01em"},children:o}),a&&t.jsx(Ee,{href:a,variant:"contained",disableElevation:!0,startIcon:t.jsx(Yn,{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 ${le(c,.3)}`,"&:hover":{boxShadow:`0 12px 40px -4px ${le(c,.4)}`,transform:"translateY(-1px)"},transition:"all 0.2s ease"},children:r("common.back")})]})}function Gi({error:e,errorCode:n=void 0,mode:r="inline"}){const i=We().palette.primary.main,o=r==="standalone",c={bgcolor:a=>a.palette.mode==="dark"?"background.default":"#f8faff",backgroundImage:a=>a.palette.mode==="dark"?"none":`radial-gradient(at 0% 0%, ${le(i,.06)} 0px, transparent 50%),
|
|
2
|
+
radial-gradient(at 100% 0%, ${le(i,.04)} 0px, transparent 50%),
|
|
3
|
+
radial-gradient(at 100% 100%, ${le(i,.06)} 0px, transparent 50%),
|
|
4
|
+
radial-gradient(at 0% 100%, rgba(203,213,225,0.3) 0px, transparent 50%)`};return o?t.jsxs(_,{sx:{width:"100%",height:"100vh",minHeight:"100vh",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",...c},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(l=>["locale-selector","theme-mode-toggle","session-user"].includes(l.key))}),t.jsx(Jt,{error:e,errorCode:n})]}):t.jsx(_,{sx:{display:"flex",width:"100%",minHeight:{xs:400,md:520},maxWidth:1120,mx:"auto",borderRadius:"16px",overflow:"hidden",boxShadow:1,border:1,borderColor:"divider",...c},children:t.jsx(_,{sx:{flex:1,p:{xs:4,md:6},display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:t.jsx(Jt,{error:e,errorCode:n})})})}const Ke={};function Yi(e,n){return Ke[e]||(Ke[e]=dt.post(`/api/checkout-sessions/start/${e}?${fn(n)}`).then(r=>r?.data).finally(()=>{setTimeout(()=>{delete Ke[e]},3e3)})),Ke[e]}function Xi({onPaid:e=void 0,onError:n=void 0,mode:r="inline"}){const{isLoading:s,error:i,errorCode:o,session:c}=Se(),a=et(),{isMobile:l}=Ze();if(p.useEffect(()=>{i&&n&&n(new Error(i))},[i,n]),p.useEffect(()=>{a.status==="completed"&&a.result&&e&&e(a.result)},[a.status,a.result,e]),s)return t.jsx(En,{mode:r});if(i)return t.jsx(Gi,{error:i,errorCode:o,mode:r});const u=a.status==="completed",f=u&&l;return t.jsxs(t.Fragment,{children:[t.jsx(Ii,{left:f?null:t.jsx(_,{sx:{flex:1,display:"flex",flexDirection:"column",...u?{opacity:.45,pointerEvents:"none",filter:"grayscale(0.3)",transition:"all 0.5s ease"}:{}},children:t.jsx(Ni,{})}),right:u?t.jsx(vr,{submit:a,session:c}):t.jsx(Li,{}),mode:r}),!u&&t.jsx(Bi,{})]})}function Zi({id:e,onPaid:n,onError:r,theme:s="default",mode:i="inline",extraParams:o={}}){if(!e.startsWith("plink_")&&!e.startsWith("cs_"))throw new Error("Either a checkoutSession or a paymentLink id is required.");const c=e.startsWith("plink_"),[a,l]=p.useState(c?null:e);if(ut(async()=>{if(!c)return null;const f=await Yi(e,o),d=f?.checkoutSession?.id;return d&&(l(d),i==="standalone"&&window.history.replaceState(null,"",cn(mn(),`/checkout/pay/${d}?${fn(o)}`))),f},{ready:c}),!a)return t.jsx(En,{mode:i});const u=t.jsx(ui,{sessionId:a,children:t.jsx(Xi,{onPaid:n,onError:r,mode:i})});return s==="inherit"?u:s&&typeof s=="object"?t.jsx(zt,{theme:s,children:u}):t.jsx(zt,{children:u})}function rs({id:e}){const[n]=kr(),r=n.get("redirect"),s=i=>{if(i?.checkoutSession?.success_url){setTimeout(()=>{const o=new URL(i.checkoutSession.success_url,window.location.origin);o.searchParams.set("checkout_session_id",i.checkoutSession.id),window.location.replace(o.href)},1e3);return}if(i?.paymentLink&&i.paymentLink.after_completion?.type==="redirect"&&i.paymentLink.after_completion?.redirect?.url){setTimeout(()=>{const o=new URL(i.paymentLink?.after_completion?.redirect?.url,window.location.origin);o.searchParams.set("checkout_session_id",i.checkoutSession.id),window.location.replace(o.href)},1e3);return}r&&setTimeout(()=>{window.location.replace(r)},1e3)};return t.jsx(Zi,{mode:"standalone",id:e,onPaid:s})}export{rs as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,a3 as d,B as u,N as S,q as o,bf as N,O as C,I as P,c4 as K,c5 as V,bW as q,r as O,bU as U,c6 as H,c7 as Y}from"./vendor-mui-BXZut9Pz.js";import{V as _,F as L,Y as Z,a9 as D,Z as j,a7 as G}from"./vendor-blocklet-
|
|
1
|
+
import{j as e,a3 as d,B as u,N as S,q as o,bf as N,O as C,I as P,c4 as K,c5 as V,bW as q,r as O,bU as U,c6 as H,c7 as Y}from"./vendor-mui-BXZut9Pz.js";import{V as _,F as L,Y as Z,a9 as D,Z as j,a7 as G}from"./vendor-blocklet-B67R14so.js";import{d as A,aM as R,f as I,T as J,a as E,v as z,Y as Q,j as B,a0 as X,e as ee,k as M}from"./index-B4yaPb7B.js";import{L as $}from"./vendor-react-BPknnnEA.js";import{C as ne}from"./copyable-CprMHdhV.js";import{a as te,L as re}from"./usage-records-BAwNs1y8.js";const W={width:48,height:48};function ue({data:t,currency:s,mode:m="customer"}){const{t:a}=_(),{isMobile:c}=A(),r=m==="admin",i=[{label:a("admin.subscription.product"),name:"price_id",options:{customBodyRenderLite:(p,l)=>{const n=t[l];return e.jsxs(d,{sx:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:{xs:1,sm:2}},children:[e.jsx(u,{sx:{order:c?2:1},children:n.price.product.images.length>0?e.jsx(S,{src:n.price.product.images[0],alt:n.price.product.name,variant:"rounded",sx:W},n.price.product_id):e.jsx(S,{variant:"rounded",sx:W,children:n.price.product.name.slice(0,1)},n.price.product_id)}),e.jsx(u,{sx:{order:c?1:2},children:r?e.jsxs(e.Fragment,{children:[e.jsx(o,{sx:{color:"text.primary",fontWeight:600},children:e.jsx($,{to:`/admin/products/${n?.price.product_id}`,children:e.jsx(R,{text:n?.price.product.name,maxLength:c?20:50,useWidth:!0})})}),e.jsx(o,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:e.jsx($,{to:`/admin/products/${n?.price.id}`,children:I(n.price,s,n?.price.product.unit_label)})})]}):e.jsxs(u,{sx:c?{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:.5,flex:1}:{},children:[e.jsx(o,{sx:{color:"text.primary",fontWeight:600},children:e.jsx(R,{text:n?.price.product.name,maxLength:c?20:50,useWidth:!0})}),e.jsx(o,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:I(n.price,s,n?.price.product.unit_label)})]})})]})}}},{label:a("admin.subscription.itemId"),name:"id",options:{customBodyRenderLite:(p,l)=>{const n=t[l];return e.jsx(ne,{text:n.id})}}},s.type!=="credit"&&{label:a("common.quantity"),name:"quantity",options:{customBodyRenderLite:(p,l)=>{const n=t[l];return n.price.recurring?.usage_type==="metered"?e.jsx(te,{subscriptionId:n.subscription_id,id:n.id}):n.quantity}}},{label:a("common.total"),name:"id",align:"right",options:{sort:!1,customBodyRenderLite:(p,l)=>{const n=t[l];return n.price.recurring?.usage_type==="metered"?a("admin.subscription.usage.vary"):I(n.price,s,n?.price.product.unit_label,n?.quantity)}}},m==="admin"&&{label:a("common.actions"),name:"",align:"center",options:{sort:!1,customBodyRenderLite:(p,l)=>{const n=t[l];return e.jsx(re,{data:n})}}}].filter(Boolean);return e.jsx(ie,{children:e.jsx(J,{data:t,columns:i,loading:!1,footer:!1,toolbar:!1,components:{TableToolbar:()=>null,TableFooter:()=>null},mobileTDFlexDirection:"row",options:{count:t.length,page:0,rowsPerPage:100},emptyNodeText:a("customer.product.empty")})})}const ie=N(u)`
|
|
2
2
|
@media (max-width: ${({theme:t})=>t.breakpoints.values.md}px) {
|
|
3
3
|
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
|
|
4
4
|
align-items: center;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as p,r as s,j as t}from"./vendor-mui-BXZut9Pz.js";import{bn as u,cz as x}from"./vendor-blocklet-
|
|
1
|
+
import{u as p,r as s,j as t}from"./vendor-mui-BXZut9Pz.js";import{bn as u,cz as x}from"./vendor-blocklet-B67R14so.js";import{I as c,C as w}from"./chrome-BPS46pXA.js";function k({ref:l=void 0,id:d,version:h=1}){const e=p(),r=s.useRef(null),i=(u(r)?.width||0)/1280,[o,f]=s.useState(e.palette.mode),[n,{toggleFullscreen:m}]=x(r);s.useImperativeHandle(l,()=>({ref:r.current,fullscreen:n,toggleFullscreen:m})),s.useEffect(()=>{e.palette.mode!==o&&f(e.palette.mode)},[e.palette.mode,o]);const a=`${window.blocklet.prefix}checkout/pay/${d}?preview=1&version=${h}&theme=${o}`;return t.jsx("div",{ref:r,children:n?t.jsx("div",{style:{width:"100%",height:"100%",background:e.palette.background.paper||"#fff"},children:t.jsx(c,{style:{width:"100%",height:"100vh",overflow:"hidden",border:"none"},src:a})}):t.jsx(w,{sx:{width:"100%",height:800*i},children:t.jsx(c,{style:{width:"1280px",height:"800px",transform:`scale(${i})`,transformOrigin:"top left",border:"none"},src:a})})})}export{k as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,u,j as t}from"./vendor-mui-BXZut9Pz.js";import{bn as x,cz as g}from"./vendor-blocklet-
|
|
1
|
+
import{r as s,u,j as t}from"./vendor-mui-BXZut9Pz.js";import{bn as x,cz as g}from"./vendor-blocklet-B67R14so.js";import{I as l,C as w}from"./chrome-BPS46pXA.js";function $({ref:a=void 0,id:d,version:h=1}){const r=s.useRef(null),f=x(r),e=u(),[o,m]=s.useState(e.palette.mode),i=(f?.width||0)/1280,[n,{toggleFullscreen:p}]=g(r);s.useImperativeHandle(a,()=>({ref:r.current,fullscreen:n,toggleFullscreen:p})),s.useEffect(()=>{e.palette.mode!==o&&m(e.palette.mode)},[e.palette.mode,o]);const c=`${window.blocklet.prefix}checkout/pricing-table/${d}?preview=1&version=${h}&theme=${o}`;return t.jsx("div",{ref:r,children:n?t.jsx("div",{style:{width:"100%",height:"100%",background:e.palette.background.paper||"#fff"},children:t.jsx(l,{style:{width:"100%",height:"100vh",overflow:"hidden",border:"none"},src:c})}):t.jsx(w,{sx:{width:"100%",height:800*i},children:t.jsx(l,{style:{width:"1280px",height:"800px",transform:`scale(${i})`,transformOrigin:"top left",border:"none"},src:c})})})}export{$ as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as T,j as t,A as $,w as F,a3 as W,bY as L,q as A,B as D}from"./vendor-mui-BXZut9Pz.js";import{Y as H,P as C,F as q,aa as R,a5 as I,V as _,Z as B,ab as N}from"./vendor-blocklet-
|
|
1
|
+
import{r as T,j as t,A as $,w as F,a3 as W,bY as L,q as A,B as D}from"./vendor-mui-BXZut9Pz.js";import{Y as H,P as C,F as q,aa as R,a5 as I,V as _,Z as B,ab as N}from"./vendor-blocklet-B67R14so.js";import{aG as P,l as z,aJ as G,aK as Y,aH as S,e as w,aL as J,aM as K,aN as O}from"./index-B4yaPb7B.js";import{P as M}from"./pricing-table-D9FGYBVa.js";import"./vendor-react-BPknnnEA.js";const v={},U=(e,s)=>(v[e]||(v[e]=w.post(`/api/checkout-sessions/start/${e}?${P(s)}`).then(d=>d?.data).finally(()=>{setTimeout(()=>{delete v[e]},3e3)})),v[e]),V=async e=>{const{data:s}=await w.get(`/api/checkout-sessions/retrieve/${e}`);return s};function Z({id:e,mode:s="inline",onPaid:d=R,onError:b=console.error,onChange:x,goBack:f,extraParams:r={},action:y="",theme:c="default",formType:g="payment",...h}){if(!e.startsWith("plink_")&&!e.startsWith("cs_"))throw new Error("Either a checkoutSession or a paymentLink id is required.");const m=e.startsWith("plink_")?"paymentLink":"checkoutSession",[u,j]=H({completed:!1,appError:null}),{error:a,data:n}=C(()=>m==="paymentLink"?U(e,r):V(e));T.useEffect(()=>{m==="paymentLink"&&s==="standalone"&&n&&window.history.replaceState(null,"",q(z(),`/checkout/pay/${n.checkoutSession.id}?${P(r)}`))},[m,s,n,r]);const p=o=>{j({completed:!0}),d?.(o);const i={action:"paySuccess",mode:n?.checkoutSession?.mode,success:!0};I.event(i.action,i)},k=o=>{console.error(o),j({appError:o}),b?.(o);const i={action:"payFailed",mode:n?.checkoutSession?.mode,errorMessage:o.message,success:!1};I.event(i.action,i)},l=g==="donation"?t.jsx(G,{checkoutSession:n?.checkoutSession,paymentMethods:n?.paymentMethods,paymentIntent:n?.paymentIntent,paymentLink:n?.paymentLink,customer:n?.customer,completed:u.completed,error:a,onPaid:p,onError:k,onChange:x,goBack:f,mode:s,action:y,id:e,...h}):t.jsx(Y,{checkoutSession:n?.checkoutSession,paymentMethods:n?.paymentMethods,paymentIntent:n?.paymentIntent,paymentLink:n?.paymentLink,customer:n?.customer,completed:u.completed,error:a,onPaid:p,onError:k,onChange:x,goBack:f,mode:s,action:y,...h});return c==="inherit"?l:c&&typeof c=="object"?t.jsx(S,{theme:c,children:l}):t.jsx(S,{children:l})}const Q=async e=>{const{data:s}=await w.get(`/api/pricing-tables/${e}`);return s},X=e=>/^https?:\/\//i.test(e)?e:`https://${e}`;function E({id:e,mode:s,onPaid:d,onError:b,onChange:x,extraParams:f,goBack:r,theme:y}){if(!e.startsWith("prctbl_"))throw new Error("A valid pricing table id is required.");const[c,g]=T.useState(""),h=window.location.hash.slice(1),{t:m}=_(),{error:u,loading:j,data:a}=C(()=>Q(e));if(u)return t.jsx($,{severity:"error",children:u.message});if(j||!a)return t.jsx(F,{});if(a.items.length===0)return t.jsx($,{severity:"warning",children:m("payment.checkout.noPricing")});const n=(k,l)=>{w.post(`/api/pricing-tables/${a.id}/checkout/${k}?${P({...f,currencyId:l})}`).then(o=>{if(s==="standalone"){let{url:i}=o.data;i=i.indexOf("?")>-1?`${i}¤cyId=${l}`:`${i}?currencyId=${l}`,window.location.replace(X(i))}else window.location.hash=o.data.id,g(o.data.id)}).catch(o=>{console.error(o),B.error(o.message)})},p={};return r&&(p.goBack=()=>{window.location.hash="",typeof r<"u"&&r(),g("")}),!c&&!h?s==="standalone"?t.jsxs(W,{direction:"column",sx:{alignItems:"center",overflow:{xs:"auto",md:"hidden"},height:"100%",pt:{xs:2.5,md:7.5},px:2.5},children:[t.jsxs(L,{sx:{display:"flex",flexDirection:"column",fontSize:"24px",alignItems:"center",margin:{xs:"20px 0",md:"20px 20px"},maxWidth:{xs:"100%",md:400},textAlign:"center"},children:[!a.livemode&&t.jsx(J,{sx:{display:"flex",marginBottom:"8px",width:"fit-content",ml:0}}),t.jsx(A,{sx:{color:"text.primary",fontWeight:600,lineHeight:"32px",fontSize:"24px"},children:t.jsx(K,{text:a.name,maxLength:60,useWidth:!0})})]}),t.jsx(M,{table:a,onSelect:n})]}):t.jsx(M,{mode:"select",table:a,onSelect:n}):t.jsx(L,{sx:{height:"100%"},children:t.jsx(Z,{id:h||c,mode:s,onPaid:d,onError:b,onChange:x,theme:y,...p})})}function ee(e){return e.theme==="inherit"?t.jsx(E,{...e}):e.theme&&typeof e.theme=="object"?t.jsx(S,{theme:e.theme,children:t.jsx(E,{...e})}):t.jsx(S,{children:t.jsx(E,{...e})})}function ae({id:e}){const s=O();return t.jsxs(D,{sx:{width:"100vw",maxHeight:"100vh",minHeight:"90vh",display:"flex",flexDirection:"column",overflow:s?"visible":"hidden"},children:[t.jsx(N,{meta:void 0,addons:void 0,sessionManagerProps:void 0,homeLink:void 0,theme:void 0,hideNavMenu:void 0,maxWidth:!1,sx:{borderBottom:"1px solid",borderColor:"divider"}}),t.jsx(W,{sx:{pt:{xs:0},overflow:{xs:s?"visible":"hidden",md:"hidden"}},children:t.jsx(ee,{id:e,mode:"standalone",theme:{sx:{overflow:{xs:"auto",md:"hidden"},display:"flex",flexDirection:"column"}}})})]})}export{ae as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as c,bf as V,B as f,j as t,a3 as g,aT as I,ad as L,q as y,bs as G,bt as H,N as $,a7 as D,a8 as Z,a9 as q,aG as K,bZ as Q,aH as U}from"./vendor-mui-BXZut9Pz.js";import{V as Y,a6 as F,Y as J,G as X,Z as ee}from"./vendor-blocklet-
|
|
1
|
+
import{r as c,bf as V,B as f,j as t,a3 as g,aT as I,ad as L,q as y,bs as G,bt as H,N as $,a7 as D,a8 as Z,a9 as q,aG as K,bZ as Q,aH as U}from"./vendor-mui-BXZut9Pz.js";import{V as Y,a6 as F,Y as J,G as X,Z as ee}from"./vendor-blocklet-B67R14so.js";import{d as te,a as re,aN as ie,V as se,aO as ne,aP as B,aQ as ae,aM as oe,L as ce,k as le}from"./index-B4yaPb7B.js";const C={year:1,month:2,day:3,hour:4},de=(i,m)=>{const l={},o={};return(i||[]).forEach(n=>{const d=[n.price.recurring?.interval,n.price.recurring?.interval_count].join("-");n.price.currency_options?.find(p=>p.currency_id===m.id)&&(o[d]=n.price.recurring),l[d]||(l[d]=[]),l[d].push(n)}),{recurring:o,grouped:l}};function he({table:i,alignItems:m="center",interval:l="",mode:o="checkout",onSelect:n,hideCurrency:d=!1}){const{t:p,locale:b}=Y(),{isMobile:w}=te(),{settings:{paymentMethods:S=[]},livemode:W,setLivemode:M,refresh:P}=re(),N=ie();c.useEffect(()=>{i&&W!==i.livemode&&M(i.livemode)},[i,W,M,P]);const[x,O]=c.useState(i.currency||{}),{recurring:h,grouped:v}=c.useMemo(()=>de(i.items,x),[i.items,x]),z=c.useMemo(()=>F(h)?[]:Object.keys(h).sort((e,r)=>{const[a,u]=e.split("-"),[j,E]=r.split("-");return C[a]!==C[j]?C[a]-C[j]:u&&E?E-u:r-e}),[h]),[s,k]=J({interval:l}),T=c.useMemo(()=>{if(!S||S.length===0)return{};const e={};return S.forEach(r=>{const{payment_currencies:a=[]}=r;a&&a.length>0&&a.forEach(u=>{e[u.id]={...u,method:r.name}})}),e},[S]),_=c.useMemo(()=>{const e={};return s.interval?((v[s.interval]||[]).forEach(r=>{se(r.price).forEach(a=>{e[a?.currency_id]=!0})}),Object.keys(e).map(r=>T[r]).filter(r=>r)):[]},[T,v,s.interval]),R=c.useMemo(()=>(v[s.interval]||[]).filter(e=>{const r=ne(e.price,x);return!(new X(r).isZero()||!r)}),[v,s.interval,x]);c.useEffect(()=>{if(i&&(!s.interval||!v[s.interval])){const e=Object.keys(h);e[0]&&k({interval:e[0]})}},[i]);const A=V(f)`
|
|
2
2
|
.btn-row {
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-wrap: wrap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as M,w as k,r as l,aT as B,ad as S,bH as H,B as N,q as x,bN as V,a3 as E,N as q}from"./vendor-mui-BXZut9Pz.js";import{P as F,V as L,af as O,aI as T}from"./vendor-blocklet-
|
|
1
|
+
import{j as e,A as M,w as k,r as l,aT as B,ad as S,bH as H,B as N,q as x,bN as V,a3 as E,N as q}from"./vendor-mui-BXZut9Pz.js";import{P as F,V as L,af as O,aI as T}from"./vendor-blocklet-B67R14so.js";import{b9 as d,ba as $,e as w,a as D,Y as K,f as R,V as b}from"./index-B4yaPb7B.js";const A=l.createContext({api:w}),{Provider:W,Consumer:Z}=A,Y=(r=!1)=>{const s=`products-${localStorage.getItem("livemode")!=="false"}`;return new $(s,()=>w.get("/api/products?active=true&page=1&pageSize=100&donation=hide"),{ttl:1e3*60*10,strategy:"session"}).fetch(r)};function ee({children:r}){const{data:c,error:s,run:t,loading:i}=F((u=!1)=>Y(u));return d("product.created",()=>t(!0),[]),d("product.updated",()=>t(!0),[]),d("product.deleted",()=>t(!0),[]),d("price.created",()=>t(!0),[]),d("price.updated",()=>t(!0),[]),d("price.deleted",()=>t(!0),[]),s?e.jsx(M,{severity:"error",children:s.message}):i||!c?e.jsx(k,{}):e.jsx(W,{value:{products:c?.list??[],refresh:()=>t(!0)},children:r})}function _(){return l.useContext(A)}const G=(r,c,s)=>(r.prices=r.prices.filter(t=>{const i=t.active,u=!c(t),m=s?s(t):!0;return i&&u&&m}),r),J=(r,c,s)=>T(r).map(i=>G(i,c,s)).filter(i=>i.prices.length);function te({mode:r,hasSelected:c,onSelect:s,addProduct:t=!0,filterPrice:i=()=>!0}){const{t:u}=L(),[m,p]=l.useState(r),{products:I}=_(),{settings:f}=D(),[g,y]=l.useState(""),h=l.useRef(g),v={width:16,height:16},z=n=>{y(n.target.value),h.current=n.target.value,p("waiting"),s(n.target.value)};d(n=>n.type==="product.select.price.removed",n=>{h.current===n.priceId&&(y(""),h.current="")});const j=n=>{const P=J(I,c,i);return P.length===0?e.jsx(O,{children:u("admin.product.empty")}):P.map(o=>[e.jsx(V,{sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:"2.1875rem"},children:e.jsxs(E,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:[o.images[0]?e.jsx(q,{src:o.images[0],alt:o.name,variant:"square",sx:v}):e.jsx(q,{variant:"square",sx:v,children:o.name.slice(0,1)}),e.jsx(x,{component:"span",children:o.name})]})},o.id),...o.prices.map(a=>{const C=K(f.paymentMethods,a.currency_id??"")||f.baseCurrency;return e.jsxs(S,{sx:{pl:4.5},value:a.id,onClick:()=>{n&&(a.productName=o.name,a.displayPrice=R(a,C),n(a))},children:[e.jsx(x,{sx:{color:"text.primary"},children:R(a,C)}),e.jsx(x,{sx:{color:"text.secondary",ml:2},children:b(a).length>1?` +${b(a).length-1} more currencies`:""})]},a.id)})])};return m==="inline"?e.jsx(e.Fragment,{children:j(s)}):m==="selecting"?e.jsxs(B,{fullWidth:!0,size:"small",onChange:z,value:g,MenuProps:{style:{maxHeight:480}},children:[t&&e.jsxs(S,{value:"add",children:[e.jsx(H,{}),u("admin.product.add")]}),j()]}):e.jsx(N,{sx:{cursor:"pointer"},onClick:()=>p("selecting"),children:e.jsx(x,{color:"primary",children:u("admin.paymentLink.addProduct")})})}export{ee as P,te as a,_ as u};
|