@lockerverse/react 0.2.96 → 0.2.99
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,p as u,r as d,t as f,u as p}from"./host-callback.js";import{LockerverseSdkError as m,estimateLockerverseCheckout as h}from"@lockerverse/sdk/checkout";import{createContext as g,useCallback as _,useContext as v,useEffect as y,useId as b,useLayoutEffect as x,useMemo as S,useReducer as C,useRef as w,useState as T}from"react";import{AddressElement as E,Elements as D,PaymentElement as O,useElements as k,useStripe as A}from"@stripe/react-stripe-js";import{loadStripe as j}from"@stripe/stripe-js/pure/index.js";import{array as M,minLength as N,minValue as P,nonEmpty as F,number as I,object as L,pipe as R,regex as ee,safeInteger as te,safeParse as z,strictObject as B,string as V,trim as ne,union as re}from"valibot";import{Fragment as H,jsx as U,jsxs as W}from"react/jsx-runtime";import{Select as G}from"@base-ui/react/select";const ie=new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`});function K(e){return ie.format(e/100)}const q=g(void 0);function J({children:e,container:t}){return U(q.Provider,{value:t,children:e})}function ae(){return U(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:U(`path`,{d:`m4 6 4 4 4-4`})})}function oe(){return U(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:U(`path`,{d:`m3 8 3 3 7-7`})})}function Y({ariaDescribedBy:e,ariaLabel:t,ariaLabelledBy:n,className:r,id:i,invalid:a=!1,name:o,onValueChange:s,options:c,value:l}){let u=v(q),d=[`lockerverse-payment__select`,r].filter(Boolean).join(` `);return U(`div`,{className:d,children:W(G.Root,{id:i,items:c,name:o,onValueChange:e=>{e!==null&&s(e)},value:l,children:[W(G.Trigger,{"aria-describedby":e,"aria-invalid":a||void 0,"aria-label":t,"aria-labelledby":n,className:`lockerverse-payment__select-trigger`,children:[U(G.Value,{}),U(G.Icon,{"aria-hidden":`true`,className:`lockerverse-payment__select-icon`,children:U(ae,{})})]}),U(G.Portal,{container:u,children:U(G.Positioner,{alignItemWithTrigger:!1,className:`lockerverse-payment__select-positioner`,sideOffset:6,children:U(G.Popup,{className:`lockerverse-payment__select-popup`,children:U(G.List,{className:`lockerverse-payment__select-list`,children:c.map(e=>W(G.Item,{className:`lockerverse-payment__select-item`,value:e.value,children:[U(G.ItemText,{children:e.label}),U(G.ItemIndicator,{"aria-hidden":`true`,className:`lockerverse-payment__select-item-indicator`,children:U(oe,{})})]},e.value))})})})})]})})}const X=[`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`],se=[`15`,`12`,`10`,`5`],Z=[...se,`custom`];function ce({enabled:e,error:t,errorId:n,onChange:r,values:i}){if(!e)return null;let a=e=>r({...i,...e}),o=(e,t)=>{let n=Z.indexOf(t),r;switch(e.key){case`ArrowDown`:case`ArrowRight`:r=(n+1)%Z.length;break;case`ArrowLeft`:case`ArrowUp`:r=(n-1+Z.length)%Z.length;break;case`Home`:r=0;break;case`End`:r=Z.length-1;break;default:return}e.preventDefault();let i=Z[r];i&&((e.currentTarget.closest(`[role="radiogroup"]`)?.querySelectorAll(`input[type="radio"]`))?.[r]?.focus(),a({tipPercent:i}))};return W(`div`,{className:`lockerverse-payment__tip-box`,children:[U(`p`,{children:`Add a tip to support the Lockerverse platform`}),W(`div`,{"aria-label":`Tip amount`,role:`radiogroup`,children:[se.map(e=>W(`label`,{className:`lockerverse-payment__tip-choice`,children:[U(`input`,{checked:i.tipPercent===e,name:`tipPercent`,onChange:()=>a({tipPercent:e}),onKeyDown:t=>o(t,e),tabIndex:i.tipPercent===e?0:-1,type:`radio`,value:e}),W(`span`,{children:[e,`%`]})]},e)),W(`label`,{className:`lockerverse-payment__tip-choice`,children:[U(`input`,{checked:i.tipPercent===`custom`,name:`tipPercent`,onChange:()=>a({tipPercent:`custom`}),onKeyDown:e=>o(e,`custom`),tabIndex:i.tipPercent===`custom`?0:-1,type:`radio`,value:`custom`}),U(`span`,{children:`Other`})]})]}),i.tipPercent===`custom`?W(`label`,{children:[U(`span`,{children:`Custom tip`}),W(`span`,{className:`lockerverse-payment__money-input`,children:[U(`span`,{"aria-hidden":`true`,children:`$`}),U(`input`,{"aria-describedby":t?n:void 0,"aria-invalid":t?`true`:void 0,inputMode:`decimal`,name:`tip`,onChange:e=>a({customTip:e.currentTarget.value}),placeholder:`0.00`,value:i.customTip})]}),t?U(`span`,{className:`lockerverse-payment__field-message`,id:n,children:t}):null]}):U(`input`,{name:`tip`,type:`hidden`,value:i.tipPercent})]})}function le({checked:e,children:t,name:n,onChange:r}){return W(`label`,{className:`lockerverse-payment__check-row`,children:[U(`input`,{checked:e,name:n,onChange:e=>r(e.currentTarget.checked),type:`checkbox`}),U(`span`,{children:t})]})}function ue({customFields:e,errors:t,fields:r,idPrefix:i,isPromoApplying:a,onChange:o,onApplyPromo:s,promoError:c,values:l}){let u=e=>o({...l,...e});return W(`div`,{className:`lockerverse-payment__additional-fields`,children:[r.memberId?W(`label`,{children:[U(`span`,{children:`Member ID`}),U(`input`,{name:`memberId`,onChange:e=>u({memberId:e.currentTarget.value}),placeholder:`Optional`,value:l.memberId})]}):null,r.merchSize?W(`div`,{className:`lockerverse-payment__field`,children:[U(`span`,{id:`${i}-merch-size-label`,children:`Size`}),U(Y,{ariaLabelledBy:`${i}-merch-size-label`,name:`merchSize`,onValueChange:e=>{let t=X.find(t=>t===e);t&&u({merchSize:t})},options:X.map(e=>({label:e,value:e})),value:l.merchSize})]}):null,r.promoCode?W(`div`,{className:`lockerverse-payment__field`,children:[U(`span`,{id:`${i}-promo-code-label`,children:`Promo code`}),W(`div`,{className:`lockerverse-payment__promo-control`,children:[U(`input`,{"aria-describedby":c?`${i}-promo-code-error`:void 0,"aria-invalid":c?`true`:void 0,"aria-labelledby":`${i}-promo-code-label`,name:`promoCode`,onChange:e=>u({promoCode:e.currentTarget.value}),placeholder:`Optional`,value:l.promoCode}),U(`button`,{disabled:!l.promoCode.trim()||a,onClick:s,type:`button`,children:a?`Applying…`:`Apply`})]}),c?U(`p`,{className:`lockerverse-payment__field-message`,id:`${i}-promo-code-error`,role:`alert`,children:c}):null]}):null,U(n,{choiceClassName:`lockerverse-payment__check-row`,errorClassName:`lockerverse-payment__field-message`,errors:t,fields:e,idPrefix:i,onChange:e=>u({customFields:e}),values:l.customFields})]})}function de({amountCents:e,enabled:t,onChange:n,values:r}){return t?W(le,{checked:r.includeServiceFee,name:`includeServiceFee`,onChange:e=>n({...r,includeServiceFee:e}),children:[`Add `,K(e),` to help cover processing fees`]}):null}function fe(e){return{error:void 0,message:void 0,status:e?`recovering`:`editing`}}function Q(e,t,n){return t.includes(e.status)?{...e,...n}:e}function pe(e,t){if(e.status===`sold_out`||e.status===`succeeded`||e.status===`unresolved`)return e;switch(t.type){case`field_changed`:return Q(e,[`editing`,`invalid`,`refreshing_quote`],{error:void 0,status:`editing`});case`validation_failed`:return Q(e,[`editing`],{status:`invalid`});case`quote_refresh_started`:return Q(e,[`editing`,`invalid`],{status:`refreshing_quote`});case`quote_refresh_succeeded`:return Q(e,[`refreshing_quote`],{error:void 0,status:`editing`});case`quote_refresh_failed`:return Q(e,[`refreshing_quote`],{error:t.error??e.error,status:`editing`});case`submission_started`:return Q(e,[`editing`,`invalid`,`refreshing_quote`],{error:void 0,status:`submitting`});case`submission_validation_failed`:return Q(e,[`submitting`],{error:void 0,status:`invalid`});case`quote_changed`:return Q(e,[`submitting`],{status:`editing`});case`retryable_failure`:return Q(e,[`editing`,`invalid`,`submitting`],{error:t.error,status:`editing`});case`recovery_failed`:return Q(e,[`recovering`],{error:t.error,status:`editing`});case`sold_out`:return{error:void 0,message:void 0,status:`sold_out`};case`succeeded`:return Q(e,[`recovering`,`submitting`],{message:t.message,status:`succeeded`});case`unresolved`:return Q(e,[`recovering`,`submitting`],{message:t.message,status:`unresolved`});default:return e}}function me(e){return e.status===`editing`||e.status===`invalid`||e.status===`refreshing_quote`?e.error:void 0}function he(e){return e.status===`sold_out`?`sold_out`:e.status===`succeeded`?`success`:e.status===`unresolved`?`unresolved`:e.status===`submitting`||e.status===`recovering`?`submitting`:e.status===`invalid`?`invalid`:me(e)?`error`:`idle`}function ge(e){return e.status===`submitting`}function _e(t){return e(t)}function ve(e,n){let r=n?{...e,phone:_e(e.phone)}:e,i=L(n?{email:t,phone:s}:{email:t}),a=z(i,r);if(a.success)return{errors:{},value:a.output};let o={};for(let e of a.issues){let t=e.path?.[0]?.key;(t===`email`||t===`phone`)&&!o[t]&&(o[t]=e.message)}return{errors:o,value:null}}const ye=[`amountCents`,`discountableSubtotalCents`,`discountCents`,`serviceFeeCents`,`subtotalCents`,`tipCents`,`totalCents`],be=[`discountableSubtotalCents`,`discountCents`,`subtotalCents`];function xe(e,t,n,r){return(n===t.totalCents?be:ye).some(n=>e[n]!==t[n])||r!==t.payment.connectedAccountId||e.authoritative&&(e.payment.connectedAccountId!==r||e.payment.currency!==t.payment.currency)||JSON.stringify(e.appliedDiscount)!==JSON.stringify(t.appliedDiscount)||JSON.stringify(e.lineItems)!==JSON.stringify(t.lineItems)}function Se(e){return e.checkoutStatus===`success`?{kind:`success`,payment:e}:e.checkoutStatus===`failed`?{kind:`failed`,payment:e}:{kind:`unresolved`,paymentReference:e.paymentReference,reason:e.checkoutStatus===`action_required`?`action_required`:`pending`}}async function Ce(e,t,n){if(t.checkoutStatus!==`action_required`)return Se(t);if(!n)return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`};if(t.clientSecret)try{await n.handleNextAction({clientSecret:t.clientSecret})}catch{}try{return Se(await e.getPaymentStatus(t.paymentReference))}catch{return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`}}}async function we(e,t,n){let r;try{r=await e.submitPayment(t)}catch(n){if(!(n instanceof m&&n.recoveryRecommended))throw n;try{r=await e.getPaymentStatus(t.checkout.paymentReference)}catch{return{kind:`unresolved`,paymentReference:t.checkout.paymentReference,reason:`recovery_failed`}}}return Ce(e,r,n)}async function Te(e,t,n){try{return Ce(e,await e.getPaymentStatus(t),n)}catch{return{kind:`unresolved`,paymentReference:t,reason:`recovery_failed`}}}const Ee=R(V(),ne(),F()),De=R(I(),te(),P(1)),Oe=R(M(re([B({amountCents:De,productSlug:Ee}),B({productSlug:Ee,quantity:De}),B({productSlug:Ee})])),N(1)),ke=R(V(),ne(),ee(/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/,`Enter a valid tip amount.`));function Ae(e){let t=z(ke,e);if(!t.success)return{message:t.issues[0]?.message??`Enter a valid tip amount.`,success:!1};let[n=`0`,r=``]=t.output.split(`.`),i=BigInt(n)*100n+BigInt(r.padEnd(2,`0`));return i>BigInt(2**53-1)?{message:`Enter a valid tip amount.`,success:!1}:{cents:Number(i),success:!0}}function je(e){let t=z(Oe,e);return t.success?{success:!0,value:t.output}:{message:`Lockerverse payment configuration is invalid.`,success:!1}}const Me=`This promo code is invalid or cannot be applied.`;function Ne(e,t){return t.tipPercent===`custom`?t.customTip.trim()?Ae(t.customTip):{cents:0,success:!0}:{cents:Math.round(e*Number(t.tipPercent)/100),success:!0}}function Pe(e,t,n,r){let i={};return n&&(i.email=n),e.widget.fields.serviceFee&&(i.includeServiceFee=t.includeServiceFee),e.widget.fields.promoCode&&t.promoCode.trim()&&(i.promoCode=t.promoCode.trim()),e.widget.fields.tipping&&(i.tipCents=r),i}function Fe(e,t,n){let r=e.widget.fields.tipping?Ne(n.subtotalCents,t):{cents:0,success:!0};if(!r.success)return{parsedTip:r,totalCents:null};let i=e.widget.fields.serviceFee&&t.includeServiceFee?n.serviceFeeCents||Math.round(n.subtotalCents*e.pricingPolicy.serviceFeeRateBasisPoints/1e4):0;return{parsedTip:r,totalCents:n.totalCents-n.serviceFeeCents-n.tipCents+i+r.cents}}function Ie(e,t){return{displayedTotalCents:e.totalCents,promoError:t&&e.appliedDiscount?.source!==`promo_code`?Me:void 0}}function Le(e,t){let n;return t||(n=e instanceof Error?e.message:`The order total could not be updated.`),{paymentError:n,promoError:t?Me:void 0}}function Re(e,t){if(!e?.complete)throw Error(`${t} address is required.`);return e.value}function ze(e,t,n,r){if(e.widget.fields.shipping)return t.shippingMatchesBilling?n:Re(r.shipping,`Shipping`)}function Be({billingAddress:e,catalog:t,email:n,phone:r,shippingAddress:i}){let a={payment_method_data:{billing_details:t.widget.fields.phone?{address:e.address,email:n,name:e.name,phone:r}:{address:e.address,email:n,name:e.name}}};return i?{...a,shipping:{address:i.address,name:i.name,phone:t.widget.fields.phone?r:i.phone??null}}:a}function Ve({catalog:e,confirmationToken:t,email:n,fieldValues:i,metadata:a,phone:o,shippingAddress:s}){let c={customFieldAnswers:r(e.widget.customFields,i.customFields),email:n};if(t&&(c.confirmationToken=t),a&&(c.metadata=a),e.widget.fields.memberId&&i.memberId.trim()&&(c.memberId=i.memberId.trim()),e.widget.fields.merchSize&&(c.merchSize=i.merchSize),e.widget.fields.phone&&(c.phone=o),s){let e={city:s.address.city??``,country:s.address.country,line1:s.address.line1??``,postal_code:s.address.postal_code??``,state:s.address.state??``};s.address.line2&&(e.line2=s.address.line2),c.shipping={address:e,name:s.name}}return c}function He(e){if(!e())throw Error(`Payment component is no longer active.`)}function Ue(e,t){f(e,t)}function We(e,t,n,r){return e.kind===`failed`?{kind:`payment_failed`,message:r}:e.kind===`unresolved`?{kind:`payment_unresolved`,paymentReference:e.paymentReference,reason:e.reason}:{email:n,kind:`payment`,payment:e.payment,quote:t}}async function Ge({addresses:e,catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:o,isAttemptActive:s,locallyPreviewedTotalCents:c,metadata:l,onPaymentRecoveryChange:u,phone:d,quote:f,stripe:p,stripeConnectedAccountId:m}){let h=a.trim().toLowerCase(),g=_e(d),_=Ne(f.subtotalCents,o);if(!_.success)throw Error(_.message);let v=await r.calculateTotal({...Pe(t,o,h,_.cents),catalog:t,items:n});if(He(s),v.totalCents>0&&xe(f,v,c,m))return{kind:`quote_changed`,quote:v};let y,b;if(v.totalCents===0)t.widget.fields.shipping&&(y=ze(t,o,Re(e.billing,`Billing`),e));else{if(!(i&&p))throw Error(`Payment form is still loading.`);await i.update({amount:v.totalCents}),He(s);let n=await i.submit();if(He(s),n.error)throw Error(n.error.message);let r=Re(e.billing,`Billing`);y=ze(t,o,r,e);let a=await p.createConfirmationToken({elements:i,params:Be({billingAddress:r,catalog:t,email:h,phone:g,shippingAddress:y})});if(He(s),a.error)throw Error(a.error.message);b=a.confirmationToken.id}Ue(u,{connectedAccountId:v.payment.connectedAccountId,paymentReference:v.paymentReference});let x=await we(r,{checkout:v,submission:Ve({catalog:t,confirmationToken:b,email:h,fieldValues:o,metadata:l,phone:g,shippingAddress:y})},p);return He(s),We(x,v,h,v.totalCents===0?`Order could not be completed. Review the details and try again.`:`Payment was declined. Check your payment details and try again.`)}function Ke(e,t){f(e,t)}function qe(e,t){f(e,t)}function Je(e,t){return{...e,...t}}function Ye(e,t,n){return e.kind===`unresolved`&&e.reason===`action_required`&&!t&&!n}function Xe(e){return e instanceof m&&e.serverCode===`PAYMENT_WIDGET_SALES_LIMIT_REACHED`}function Ze({nextQuote:e,onQuoteChange:t,setDisplayedTotalCents:n,setPromoError:r,updateState:i,validatePromo:a}){let o=Ie(e,a);i({type:`quote_refresh_succeeded`}),n(o.displayedTotalCents),t(e),a&&r(o.promoError)}function Qe({error:e,setPromoError:t,updateState:n,validatePromo:r}){let i=Le(e,r);r&&t(i.promoError),n(i.paymentError===void 0?{type:`quote_refresh_failed`}:{error:i.paymentError,type:`quote_refresh_failed`})}function $e({onPaymentComplete:e,onPaymentRecoveryChange:t,onPaymentUncertain:n,onQuoteChange:r,result:i,setDisplayedTotalCents:a,dispatchState:o}){if(i.kind===`quote_changed`){let e=`The total changed to ${K(i.quote.totalCents)}. Review it and pay again.`;r(i.quote,e),a(i.quote.totalCents),o({type:`quote_changed`});return}if(i.kind===`payment_failed`){Ke(t,null),o({error:i.message,type:`retryable_failure`});return}if(i.kind===`payment_unresolved`){o({message:`Payment is still processing. Do not submit it again.`,type:`unresolved`}),qe(n,{paymentReference:i.paymentReference,reason:i.reason});return}r(i.quote),Ke(t,null),o({message:i.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`}),f(e,Je(i.payment,{email:i.email,lineItems:i.quote.lineItems}))}function et(e){let{catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:s,metadata:c,onPaymentComplete:l,onResumePaymentFailed:u,onPaymentRecoveryChange:d,onPaymentUncertain:p,onQuoteChange:h,onStateChange:g,quote:v,resumePayment:b,stripe:x,stripeConnectedAccountId:S,stripeLoadFailed:C,paymentState:E,updateState:D}=e,[O,k]=T(v.totalCents),[A,j]=T(),M=w(!1),N=w(0),P=w(0),F=_(e=>D(e,!0),[D]),I=_(()=>{let e=P.current+1;return P.current=e,()=>P.current===e},[]);y(()=>()=>{P.current+=1,N.current+=1},[]);let{parsedTip:L,totalCents:R}=Fe(t,s,v);y(()=>{R!==null&&(k(R),R>0&&i?.update({amount:R}))},[t.pricingPolicy.serviceFeeRateBasisPoints,t.widget.fields.serviceFee,i,s.includeServiceFee,R,v.serviceFeeCents,v.tipCents,v.totalCents,v.subtotalCents]),y(()=>{if(!b||M.current||E.status!==`recovering`)return;M.current=!0;let e=I();return g(he(E)),Te(r,b.paymentReference,x).then(t=>{if(e()&&!Ye(t,x,C)){if(t.kind===`failed`){Ke(d,null),u(),F({error:`The previous payment failed. Check your details and try again.`,type:`recovery_failed`});return}if(t.kind===`unresolved`){F({message:`Payment is still processing. Do not submit it again.`,type:`unresolved`}),qe(p,{paymentReference:t.paymentReference,reason:t.reason});return}Ke(d,null),F({message:t.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`}),f(l,Je(t.payment,{email:null,lineItems:null}))}}),()=>{e()&&(P.current+=1),M.current=!1}},[r,l,u,d,p,g,b,x,C,I,F,E]);let ee=_((e=!1,t=!1)=>{t||(N.current+=1),e&&j(void 0),D({type:`field_changed`})},[D]);async function te(e=!1,i=!1){let o=ve({email:a.trim().toLowerCase(),phone:``},!1);if(!(L.success&&(o.value||e)))return;N.current+=1;let c=N.current;D({type:`quote_refresh_started`});try{let e=await r.calculateTotal({...Pe(t,s,o.value?.email??``,L.cents),catalog:t,items:n});if(c!==N.current)return;Ze({nextQuote:e,onQuoteChange:h,setDisplayedTotalCents:k,setPromoError:j,updateState:D,validatePromo:i})}catch(e){if(c!==N.current)return;if(Xe(e)){D({type:`sold_out`});return}Qe({error:e,setPromoError:j,updateState:D,validatePromo:i})}}async function z(){j(void 0),await te(!0,!0)}async function B({addresses:e,phone:u}){F({type:`submission_started`});let f=I();try{let o=await Ge({addresses:e,catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:s,isAttemptActive:f,locallyPreviewedTotalCents:O,metadata:c,onPaymentRecoveryChange:d,phone:u,quote:v,stripe:x,stripeConnectedAccountId:S});if(!f())return;$e({dispatchState:F,onPaymentComplete:l,onPaymentRecoveryChange:d,onPaymentUncertain:p,onQuoteChange:h,result:o,setDisplayedTotalCents:k})}catch(e){if(!f())return;if(Ke(d,null),Xe(e)){F({type:`sold_out`});return}let t=e instanceof m?o(e.serverCode):void 0;if(t)return F({type:`submission_validation_failed`}),{phoneError:t};F({error:e instanceof Error?e.message:`Payment could not be completed.`,type:`retryable_failure`})}}let V=E.status===`succeeded`||E.status===`unresolved`?E.message:void 0;return{commands:{applyPromo:z,fieldChanged:ee,refreshAuthoritativeTotal:te,reportStripeLoadError:e=>F({error:e,type:`retryable_failure`}),reportValidationFailure:()=>F({type:`validation_failed`}),submit:B},state:{displayedTotalCents:O,isRecovering:E.status===`recovering`,isRefreshingQuote:E.status===`refreshing_quote`,isSubmitting:ge(E),parsedTip:L,paymentError:me(E),promoError:A,terminalMessage:V}}}const tt=new Map,nt=(e,t)=>{let n=t?.stripeAccount??null,r=tt.get(e);r||(r=new Map,tt.set(e,r));let i=r.get(n);if(i)return i;let a=j(e,t).catch(()=>(r?.get(n)===a&&(r.delete(n),r.size===0&&tt.delete(e)),null));return r.set(n,a),a};function rt(e){let{connectedAccountId:t,publishableKey:n}=e.payment;return nt(n,t?{stripeAccount:t}:void 0)}function it(e){return e===`monthly`?{interval:`month`,label:`Monthly`}:e===`annually`?{interval:`year`,label:`Annual`}:null}function at(e,t,n){if(n){let{connectedAccountId:e}=n;return e}if(`payment`in t){let{connectedAccountId:e}=t.payment;return e}let{connectedAccountId:r}=e.payment;return r}function ot({accentColor:e,catalog:t,checkoutItems:n,client:r,fontFamily:i,metadata:a,onPaymentComplete:o,onResumePaymentFailed:s,onPaymentRecoveryChange:c,onPaymentUncertain:l,onQuoteChange:u,quote:d,resumePayment:f,onStateChange:p,stripeLoader:m,theme:h,visualStyle:g}){let[v,b]=T(()=>fe(!!f)),x=w(v);x.current=v;let C=_((e,t=!1)=>{let n=pe(x.current,e);n!==x.current&&(x.current=n,b(n),t&&p(he(n)))},[p]),E=at(t,d,f),O=w({connectedAccountId:E,paymentOption:d.paymentOption});v.status!==`submitting`&&v.status!==`recovering`&&(O.current={connectedAccountId:E,paymentOption:d.paymentOption});let{connectedAccountId:k,paymentOption:A}=O.current,j=S(()=>m(t.payment.publishableKey,k?{stripeAccount:k}:void 0).catch(()=>null),[t.payment.publishableKey,k,m]),[M,N]=T(!1);return y(()=>{let e=!0;return N(!1),j.then(t=>{e&&t===null&&N(!0)}),()=>{e=!1}},[j]),U(D,{options:{amount:Math.max(d.totalCents,100),appearance:{rules:{".Input:focus":{borderColor:e,boxShadow:`0 0 0 1px ${e}`,outline:`none`}},theme:h===`light`?`stripe`:`night`,variables:{borderRadius:g?.[`--lockerverse-radius`]??`10px`,colorBackground:g?.[`--lockerverse-control`]??(h===`light`?`#f5f6f7`:`#121212`),colorDanger:g?.[`--lockerverse-danger`]??(h===`light`?`#c52b3e`:`#f08a98`),colorPrimary:e,colorText:g?.[`--lockerverse-text`]??(h===`light`?`#121416`:`#ffffff`),colorTextPlaceholder:g?.[`--lockerverse-placeholder`]??(h===`light`?`#72767d`:`#6b6b6b`),colorTextSecondary:g?.[`--lockerverse-muted`]??(h===`light`?`#62666d`:`#a1a1aa`),focusBoxShadow:`none`,focusOutline:`none`,fontFamily:i,fontSizeBase:`16px`}},currency:t.payment.currency,excludedPaymentMethodTypes:[`us_bank_account`],mode:A===`one-time`?`payment`:`subscription`,syncAddressCheckbox:`none`},stripe:j,children:U(_t,{catalog:t,checkoutItems:n,client:r,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:c,onPaymentUncertain:l,onQuoteChange:u,onResumePaymentFailed:s,onStateChange:p,paymentState:v,quote:d,resumePayment:f,stripeConnectedAccountId:k,stripeLoadFailed:M,updateState:C})},`${t.payment.publishableKey}:${k??`platform`}:${A}`)}function st({label:e}){return W(`div`,{className:`lockerverse-payment__stripe-loader`,role:`status`,children:[U(`p`,{children:e}),W(`div`,{"aria-hidden":`true`,children:[U(`span`,{}),U(`span`,{}),U(`span`,{})]})]})}function ct({onError:e,onReady:t,ready:n}){return W(`div`,{className:`lockerverse-payment__stripe-element`,"data-ready":n,children:[n?null:U(st,{label:`Loading payment form...`}),U(`div`,{className:`lockerverse-payment__stripe-mount`,children:U(O,{onLoadError:({error:t})=>e(t.message??`Payment form failed to load.`),onReady:t,options:{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},layout:`tabs`,terms:{applePay:`auto`,auBecsDebit:`never`,bancontact:`never`,card:`always`,cashapp:`never`,googlePay:`never`,ideal:`never`,paypal:`auto`,sepaDebit:`never`,sofort:`never`,usBankAccount:`never`},wallets:{applePay:`auto`,googlePay:`never`}}})})]})}function lt({label:e,mode:t,onChange:n,onError:r,onReady:i,ready:a}){return W(`div`,{className:`lockerverse-payment__address`,children:[U(`h2`,{children:e}),W(`div`,{className:`lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address`,"data-ready":a,children:[a?null:U(st,{label:`Loading ${e.toLowerCase()}...`}),U(`div`,{className:`lockerverse-payment__stripe-mount`,children:U(E,{onChange:n,onLoadError:({error:t})=>r(t.message??`${e} failed to load.`),onReady:i,options:{autocomplete:{mode:`automatic`},mode:t}})})]})]})}function ut({message:e}){return e?U(`p`,{className:`lockerverse-payment__field-message`,role:`alert`,children:e}):null}function dt({catalog:e,displayedTotalCents:t,fieldValues:n,isBillingAddressReady:r,isPaymentReady:i,isShippingAddressReady:a,onAddressChange:o,onFieldValuesChange:s,onStripeLoadError:c,setIsBillingAddressReady:l,setIsPaymentReady:u,setIsShippingAddressReady:d}){let f=t>0;return W(H,{children:[f?U(ct,{onError:c,onReady:()=>u(!0),ready:i}):null,f||e.widget.fields.shipping?U(lt,{label:f?`Billing address`:`Shipping address`,mode:`billing`,onChange:e=>o(`billing`,e),onError:c,onReady:()=>l(!0),ready:r}):null,e.widget.fields.shipping?W(`div`,{className:`lockerverse-payment__shipping`,children:[U(le,{checked:n.shippingMatchesBilling,name:`shippingMatchesBilling`,onChange:e=>{s({...n,shippingMatchesBilling:e}),e?o(`shipping`,null):d(!1)},children:`Shipping is same as billing information`}),n.shippingMatchesBilling?null:U(lt,{label:`Shipping address`,mode:`shipping`,onChange:e=>o(`shipping`,e),onError:c,onReady:()=>d(!0),ready:a})]}):null]})}function ft({displayedBaseCents:e,displayedTipCents:t,displayedTotalCents:n,quote:r}){let i=it(r.paymentOption),a=Math.max(0,e-r.subtotalCents+r.discountCents);return W(`section`,{"aria-label":`Payment summary`,className:`lockerverse-payment__payment-summary`,children:[U(`h2`,{children:`Order summary`}),U(`div`,{className:`lockerverse-payment__payment-summary-items`,children:r.lineItems.map(e=>W(`div`,{className:`lockerverse-payment__payment-summary-row`,children:[W(`span`,{children:[e.productName,e.quantity>1?W(H,{children:[` `,W(`small`,{children:[`× `,e.quantity]})]}):null,e.paymentOption===`monthly`?U(`small`,{children:` · Monthly`}):null,e.paymentOption===`annually`?U(`small`,{children:` · Annual`}):null]}),U(`strong`,{children:K(e.subtotalCents)})]},e.listingId))}),W(`div`,{className:`lockerverse-payment__payment-summary-totals`,children:[a>0?W(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-detail`,children:[U(`span`,{children:`Service fee`}),U(`strong`,{children:K(a)})]}):null,r.discountCents>0&&r.appliedDiscount?W(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-discount`,children:[W(`span`,{children:[r.appliedDiscount.source===`email_list`?`Email discount`:`Promo code discount`,` `,`(`,r.appliedDiscount.percentageOff,`% off)`]}),W(`strong`,{children:[`-`,K(r.discountCents)]})]}):null,t>0?W(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-detail lockerverse-payment__payment-summary-tip`,children:[U(`span`,{children:`Tip`}),U(`strong`,{children:K(t)})]}):null,W(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-total`,children:[U(`span`,{children:i?`${i.label} total`:`Total`}),U(`strong`,{children:K(n)})]})]})]})}function pt({catalog:e,displayedTotalCents:t,fieldValues:n,isBillingAddressReady:r,isPaymentReady:i,isRequiredShippingReady:a,isSubmitting:o,onFieldValuesChange:s,quote:c}){let l=t===0,u=l?!e.widget.fields.shipping||r&&a:i&&r&&a,d=it(c.paymentOption),f=l?`Complete order`:`Pay ${K(t)}`;!l&&d&&(f=`Subscribe for ${K(t)}/${d.interval}`),o&&(f=l?`Completing…`:`Processing…`);let p=`Process payment for ${K(t)} total`;return l?p=`Complete order`:d&&(p=`Start ${d.label.toLowerCase()} subscription for ${K(t)}`),W(`div`,{className:`lockerverse-payment__actions`,children:[U(de,{amountCents:c.serviceFeeCents||Math.round(c.subtotalCents*e.pricingPolicy.serviceFeeRateBasisPoints/1e4),enabled:e.widget.fields.serviceFee,onChange:s,values:n}),U(`button`,{"aria-busy":o,"aria-label":p,disabled:o||!u,type:`submit`,children:f})]})}function mt(e,t){let n=e.elements.namedItem(t);if(n instanceof HTMLElement){n.focus();return}n instanceof RadioNodeList&&Array.from(n).find(e=>e instanceof HTMLElement)?.focus()}function ht({customFieldErrors:e,emailRef:t,form:n,parsedTipSuccess:r,phoneRef:i,validationErrors:a}){if(a.email){t.current?.focus();return}if(a.phone){i.current?.focus();return}if(!r){n.querySelector(`[name="tip"]`)?.focus();return}let[o]=Object.keys(e);o&&mt(n,`custom:${o}`)}function gt({email:e,emailDiscountPercentOff:t,emailErrorId:n,emailId:r,emailRef:i,errors:a,onEmailBlur:o,onEmailChange:s,onPhoneChange:c,onPhoneCountryChange:u,phone:d,phoneCountry:f,phoneEnabled:p,phoneErrorId:m,phoneId:h,phoneRef:g}){return W(`div`,{className:`lockerverse-payment__contact`,children:[U(`label`,{htmlFor:r,children:`Email`}),U(`input`,{"aria-describedby":a.email?n:void 0,"aria-invalid":a.email?`true`:void 0,autoComplete:`email`,id:r,name:`email`,onBlur:o,onChange:e=>s(e.currentTarget.value),placeholder:`name@example.com`,ref:i,type:`email`,value:e}),a.email?U(`p`,{className:`lockerverse-payment__field-message`,id:n,children:a.email}):null,t===void 0?null:W(`p`,{className:`lockerverse-payment__discount-message`,role:`status`,children:[`Your email qualifies for `,t,`% off.`]}),p?W(H,{children:[U(`label`,{htmlFor:h,children:`Phone`}),W(`div`,{className:`lockerverse-payment__phone-control`,children:[U(Y,{ariaLabel:`Phone number country`,className:`lockerverse-payment__select--phone-country`,name:`phoneCountry`,onValueChange:u,options:l,value:f}),U(`input`,{"aria-describedby":a.phone?m:void 0,"aria-invalid":a.phone?`true`:void 0,autoComplete:`tel`,id:h,inputMode:`tel`,name:`phone`,onChange:e=>c(e.currentTarget.value),placeholder:`(201) 555-0123`,ref:g,type:`tel`,value:d})]}),a.phone?U(`p`,{className:`lockerverse-payment__field-message`,id:m,children:a.phone}):null]}):null]})}function _t({catalog:e,checkoutItems:t,client:n,metadata:r,onPaymentComplete:i,onResumePaymentFailed:a,onPaymentRecoveryChange:o,onPaymentUncertain:s,onQuoteChange:l,onStateChange:f,quote:p,resumePayment:m,stripeConnectedAccountId:h,stripeLoadFailed:g,paymentState:_,updateState:v}){let[x,S]=T(``),[C,E]=T(``),[D,O]=T(`US`),[j,M]=T({}),[N,P]=T({}),[F,I]=T(),[L,R]=T(!1),[ee,te]=T(!1),[z,B]=T(!1),[V,ne]=T({customFields:u(e.widget.customFields),customTip:``,includeServiceFee:e.widget.fields.serviceFee,memberId:``,merchSize:`M`,promoCode:``,shippingMatchesBilling:!0,tipPercent:`10`}),re=w({billing:null,shipping:null}),H=w(null),G=w(null),ie=w(null),K=w(p.totalCents>0),q=et({catalog:e,checkoutItems:t,client:n,elements:k(),email:x,fieldValues:V,metadata:r,onPaymentComplete:i,onPaymentRecoveryChange:o,onPaymentUncertain:s,onQuoteChange:l,onResumePaymentFailed:a,onStateChange:f,paymentState:_,quote:p,resumePayment:m,stripe:A(),stripeConnectedAccountId:h,stripeLoadFailed:g,updateState:v}),{displayedTotalCents:J,isRecovering:ae,isRefreshingQuote:oe,isSubmitting:Y,parsedTip:X,paymentError:se,promoError:Z,terminalMessage:le}=q.state,de=`lockerverse-${b()}`,fe=`${de}-email`,Q=`${fe}-error`,pe=`${de}-phone`,me=`${pe}-error`,he=`${de}-tip-error`,ge=(X.success?X.cents:null)??0,_e=J-ge,ye=!e.widget.fields.shipping||V.shippingMatchesBilling||z;y(()=>{Y&&ie.current?.focus({preventScroll:!0})},[Y]),y(()=>{Y||j.email||!j.phone||G.current?.focus()},[j.email,j.phone,Y]),y(()=>{let e=J>0;e&&!K.current&&(R(!1),te(!1)),K.current=e},[J]);function be(e){q.commands.fieldChanged(!1,e!==`email`),M(t=>{let n={...t};return delete n[e],n})}function xe(e){let t=e.promoCode!==V.promoCode,n=e.includeServiceFee!==V.includeServiceFee;q.commands.fieldChanged(t,!(t||n)),ne(e),P({}),I(void 0)}async function Se(t){t.preventDefault();let n=d(C,D),r=ve({email:x,phone:n},e.widget.fields.phone),i=c(e.widget.customFields,V.customFields);if(!(r.value&&X.success)||Object.keys(i).length>0){M(r.errors),P(i),I(X.success?void 0:X.message),q.commands.reportValidationFailure();let e=t.currentTarget;queueMicrotask(()=>{ht({customFieldErrors:i,emailRef:H,form:e,parsedTipSuccess:X.success,phoneRef:G,validationErrors:r.errors})});return}M({}),P({});let a=await q.commands.submit({addresses:re.current,phone:n});a?.phoneError&&M({phone:a.phoneError})}return le?U(`p`,{className:`lockerverse-payment__payment-status`,ref:ie,role:`status`,tabIndex:-1,children:le}):ae?U(`p`,{className:`lockerverse-payment__payment-status`,role:`status`,children:`Recovering payment…`}):W(`form`,{"aria-busy":Y,className:`lockerverse-payment__form`,noValidate:!0,onSubmit:Se,children:[U(`div`,{"data-lockerverse-input-region":``,inert:Y?!0:void 0,children:W(`fieldset`,{className:`lockerverse-payment__input-fieldset`,disabled:Y,children:[U(ft,{displayedBaseCents:_e,displayedTipCents:ge,displayedTotalCents:J,quote:p}),U(ce,{enabled:e.widget.fields.tipping,error:F,errorId:he,onChange:xe,values:V}),U(gt,{email:x,emailDiscountPercentOff:p.appliedDiscount?.source===`email_list`?p.appliedDiscount.percentageOff:void 0,emailErrorId:Q,emailId:fe,emailRef:H,errors:j,onEmailBlur:()=>q.commands.refreshAuthoritativeTotal(),onEmailChange:e=>{S(e),be(`email`)},onPhoneChange:e=>{E(e),be(`phone`)},onPhoneCountryChange:e=>{O(e),q.commands.fieldChanged(!1,!0)},phone:C,phoneCountry:D,phoneEnabled:e.widget.fields.phone,phoneErrorId:me,phoneId:pe,phoneRef:G}),U(dt,{catalog:e,displayedTotalCents:J,fieldValues:V,isBillingAddressReady:ee,isPaymentReady:L,isShippingAddressReady:z,onAddressChange:(e,t)=>{re.current[e]=t},onFieldValuesChange:xe,onStripeLoadError:q.commands.reportStripeLoadError,setIsBillingAddressReady:te,setIsPaymentReady:R,setIsShippingAddressReady:B}),U(ue,{customFields:e.widget.customFields,errors:N,fields:e.widget.fields,idPrefix:de,isPromoApplying:oe,onApplyPromo:q.commands.applyPromo,onChange:xe,promoError:Z,values:V}),U(pt,{catalog:e,displayedTotalCents:J,fieldValues:V,isBillingAddressReady:ee,isPaymentReady:L,isRequiredShippingReady:ye,isSubmitting:Y,onFieldValuesChange:xe,quote:p})]})}),Y?U(`p`,{className:`lockerverse-payment__sr-only`,ref:ie,role:`status`,tabIndex:-1,children:J===0?`Completing order…`:`Processing payment…`}):null,U(ut,{message:se})]})}function vt(){return U(p,{fieldCount:2,label:`Loading payment…`,sectionCount:2,showCheckbox:!0})}function yt(e,t){switch(t.type){case`loading`:return{phase:`loading`,revision:e.revision};case`ready`:return St(t.displayedQuote,e.revision+1);case`error`:return{failure:t.failure,phase:`error`,revision:e.revision};case`checkout`:return e.phase===`ready`?{...e,displayedQuote:t.checkout,quoteFailure:void 0}:e;case`quote-error`:return e.phase===`ready`?{...e,quoteFailure:t.failure}:e;default:return e}}function $(e,t){return e===t}function bt({checkout:e}){return{displayedQuote:e,type:`ready`}}function xt(e){return e instanceof Error?e.message:`Lockerverse payment could not load.`}function St(e,t){return{checkoutItems:[...e.items],displayedQuote:e,phase:`ready`,quoteFailure:void 0,revision:t}}function Ct(e,t){let n=e.widget.fields.serviceFee;return h(e,{includeServiceFee:n,selection:t})}function wt(e,t){try{return St(Ct(e,t),1)}catch(e){return{failure:xt(e),phase:`error`,revision:0}}}function Tt({catalog:e,client:t,paymentState:n,selection:r}){let i=je(r),a=i.success?JSON.stringify(i.value):`invalid-selection`,o=S(()=>i.success?i.value:[],[i.success,a]),[s,c]=C(yt,void 0,()=>i.success?wt(e,o):{phase:`loading`,revision:0}),l=w(void 0),u=w(0),d=w(s.phase===`ready`?a:void 0),f=w(s.phase===`error`?a:void 0),p=n===`submitting`||n===`success`||n===`unresolved`;y(()=>{if(!i.success||p||$(f.current,a)||$(l.current,a))return;let n=!0;l.current=a;let r=d.current===a;r||c({type:`loading`});function s(e){n&&c(e)}function m(){n&&(l.current=void 0,f.current=a)}let h;function g(e){if(!n||(l.current=void 0,f.current=a,r&&h!==void 0&&u.current!==h))return;let t=xt(e);if(t===`This option is sold out.`){c({failure:t,type:`error`});return}c(r?{failure:t,type:`quote-error`}:{failure:t,type:`error`})}async function _(){try{h=u.current;let n=e.widget.fields.serviceFee;if(!r){let t=Ct(e,o);r=!0,d.current=a,s(bt({checkout:t}))}let i=await t.calculateTotal({catalog:e,includeServiceFee:n,selection:o});m(),u.current===h&&s({checkout:i,type:`checkout`})}catch(e){g(e)}}return _(),()=>{n=!1,$(l.current,a)&&(l.current=void 0)}},[e,t,i.success,p,a,o]);let m=$(d.current,a)||$(f.current,a)||$(l.current,a),h=p||m?s:{phase:`loading`,revision:s.revision};return{selectionError:i.success?void 0:i.message,session:h,updateCheckout:e=>{u.current+=1,c({checkout:e,type:`checkout`})}}}function Et(e,t){let n=i(e?.[`--lockerverse-accent`]??t?.accentColor??`#38d77a`),r=a(n),o={...e};return(e?.[`--lockerverse-accent`]!==void 0||t?.accentColor)&&(o[`--lockerverse-accent`]=n),r&&e?.[`--lockerverse-accent-contrast`]===void 0&&(o[`--lockerverse-accent-contrast`]=r),{accent:n,rootStyle:o}}function Dt({catalog:e,client:t,...n}){let{branding:r,className:i,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:s,onPaymentUncertain:c,resumePayment:l,selection:u,style:d,stripeLoader:f=nt,theme:p=`dark`,...m}=n,[h,g]=T(l),v=w(null),[b,S]=T(),[C,E]=T(`idle`),D=w(void 0),{selectionError:O,session:k,updateCheckout:A}=Tt({catalog:e,client:t,paymentState:C,selection:u}),j=k.phase===`ready`?k.revision:void 0,M=_(e=>{j!==void 0&&(D.current=j),E(e)},[j]),N=_(e=>s?.(e),[s]),P=_(()=>{g(void 0)},[]);y(()=>{k.phase===`loading`&&S(void 0)},[k.phase]),x(()=>{k.phase===`ready`&&D.current!==k.revision&&E(e=>e===`success`||e===`unresolved`?e:`idle`)},[k.phase,k.revision]);let F=[`lockerverse-payment`,i].filter(Boolean).join(` `),I=r??e.community,{accent:L,rootStyle:R}=Et(d,I);return O?U(`section`,{...m,className:F,"data-lockerverse-theme":p,role:`alert`,style:R,children:O}):k.phase===`error`&&k.failure===`This option is sold out.`||C===`sold_out`?W(`section`,{...m,className:F,"data-lockerverse-theme":p,role:`alert`,style:R,children:[U(`h1`,{children:`Sold out`}),U(`p`,{children:`This option is sold out.`})]}):k.phase===`error`?U(`section`,{...m,className:F,"data-lockerverse-theme":p,style:R,children:U(`p`,{role:`alert`,children:k.failure})}):k.phase===`ready`?W(`section`,{...m,"aria-label":`Payment`,className:F,"data-lockerverse-theme":p,"data-payment-state":C,ref:v,style:R,children:[W(`header`,{children:[e.widget.showCommunityBranding&&I?W(`div`,{className:`lockerverse-payment__branding`,children:[I.imageUrl?U(`img`,{alt:I.name,height:`48`,src:I.imageUrl,width:`48`}):null,U(`strong`,{children:I.name})]}):null,U(`h1`,{children:e.widget.title??e.widget.name}),e.widget.description?U(`p`,{children:e.widget.description}):null]}),b?U(`p`,{className:`lockerverse-payment__payment-status`,role:`status`,children:b}):null,k.quoteFailure?W(`div`,{className:`lockerverse-payment__payment-status`,role:`alert`,children:[U(`span`,{children:k.quoteFailure}),U(`span`,{children:` The final total will be checked when you submit.`})]}):null,U(J,{container:v,children:U(ot,{accentColor:L,catalog:e,checkoutItems:k.checkoutItems,client:t,fontFamily:d?.[`--lockerverse-font-family`]??`ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:N,onPaymentUncertain:c,onQuoteChange:(e,t)=>{S(t),A(e)},onResumePaymentFailed:P,onStateChange:M,quote:k.displayedQuote,resumePayment:h,stripeLoader:f,theme:p,visualStyle:R},k.revision)})]}):U(`section`,{...m,"aria-busy":`true`,"aria-label":`Payment`,className:F,"data-lockerverse-theme":p,style:R,children:U(vt,{})})}function Ot({children:e,loading:t=!1,viewProps:n}){let{branding:r,className:o,metadata:s,onPaymentComplete:c,onPaymentRecoveryChange:l,onPaymentUncertain:u,resumePayment:d,selection:f,stripeLoader:p,style:m,theme:h=`dark`,...g}=n,_=i(m?.[`--lockerverse-accent`]??r?.accentColor??`#38d77a`),v=a(_),y={...m};return(m?.[`--lockerverse-accent`]!==void 0||r?.accentColor)&&(y[`--lockerverse-accent`]=_),v&&m?.[`--lockerverse-accent-contrast`]===void 0&&(y[`--lockerverse-accent-contrast`]=v),U(`section`,{...g,...t?{"aria-busy":!0,"aria-label":`Payment`}:{},className:[`lockerverse-payment`,o].filter(Boolean).join(` `),"data-lockerverse-theme":h,style:y,children:e})}function kt({widget:e,...t}){return e.error?W(Ot,{viewProps:t,children:[U(`p`,{role:`alert`,children:e.error.message}),U(`button`,{onClick:e.refresh,type:`button`,children:`Retry`})]}):e.loading||!e.catalog?U(Ot,{loading:!0,viewProps:t,children:U(vt,{})}):U(Dt,{catalog:e.catalog,client:e.client,...t})}export{rt as n,kt as t};
|
|
1
|
+
import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,p as u,r as d,t as f,u as p}from"./host-callback.js";import{LockerverseSdkError as m,estimateLockerverseCheckout as h}from"@lockerverse/sdk/checkout";import{createContext as g,useCallback as _,useContext as v,useEffect as y,useId as b,useLayoutEffect as x,useMemo as S,useReducer as C,useRef as w,useState as T}from"react";import{AddressElement as E,Elements as D,PaymentElement as O,useElements as k,useStripe as A}from"@stripe/react-stripe-js";import{loadStripe as j}from"@stripe/stripe-js/pure/index.js";import{array as M,minLength as N,minValue as P,nonEmpty as F,number as I,object as L,pipe as R,regex as ee,safeInteger as te,safeParse as z,strictObject as B,string as V,trim as ne,union as re}from"valibot";import{Fragment as H,jsx as U,jsxs as W}from"react/jsx-runtime";import{Select as G}from"@base-ui/react/select";const ie=new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`});function K(e){return ie.format(e/100)}const q=g(void 0);function J({children:e,container:t}){return U(q.Provider,{value:t,children:e})}function ae(){return U(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:U(`path`,{d:`m4 6 4 4 4-4`})})}function oe(){return U(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:U(`path`,{d:`m3 8 3 3 7-7`})})}function Y({ariaDescribedBy:e,ariaLabel:t,ariaLabelledBy:n,className:r,id:i,invalid:a=!1,name:o,onValueChange:s,options:c,value:l}){let u=v(q),d=[`lockerverse-payment__select`,r].filter(Boolean).join(` `);return U(`div`,{className:d,children:W(G.Root,{id:i,items:c,name:o,onValueChange:e=>{e!==null&&s(e)},value:l,children:[W(G.Trigger,{"aria-describedby":e,"aria-invalid":a||void 0,"aria-label":t,"aria-labelledby":n,className:`lockerverse-payment__select-trigger`,children:[U(G.Value,{}),U(G.Icon,{"aria-hidden":`true`,className:`lockerverse-payment__select-icon`,children:U(ae,{})})]}),U(G.Portal,{container:u,children:U(G.Positioner,{alignItemWithTrigger:!1,className:`lockerverse-payment__select-positioner`,sideOffset:6,children:U(G.Popup,{className:`lockerverse-payment__select-popup`,children:U(G.List,{className:`lockerverse-payment__select-list`,children:c.map(e=>W(G.Item,{className:`lockerverse-payment__select-item`,value:e.value,children:[U(G.ItemText,{children:e.label}),U(G.ItemIndicator,{"aria-hidden":`true`,className:`lockerverse-payment__select-item-indicator`,children:U(oe,{})})]},e.value))})})})})]})})}const X=[`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`],se=[`15`,`12`,`10`,`5`],Z=[...se,`custom`];function ce({enabled:e,error:t,errorId:n,onChange:r,values:i}){if(!e)return null;let a=e=>r({...i,...e}),o=(e,t)=>{let n=Z.indexOf(t),r;switch(e.key){case`ArrowDown`:case`ArrowRight`:r=(n+1)%Z.length;break;case`ArrowLeft`:case`ArrowUp`:r=(n-1+Z.length)%Z.length;break;case`Home`:r=0;break;case`End`:r=Z.length-1;break;default:return}e.preventDefault();let i=Z[r];i&&((e.currentTarget.closest(`[role="radiogroup"]`)?.querySelectorAll(`input[type="radio"]`))?.[r]?.focus(),a({tipPercent:i}))};return W(`div`,{className:`lockerverse-payment__tip-box`,children:[U(`p`,{children:`Add a tip to support the Lockerverse platform`}),W(`div`,{"aria-label":`Tip amount`,role:`radiogroup`,children:[se.map(e=>W(`label`,{className:`lockerverse-payment__tip-choice`,children:[U(`input`,{checked:i.tipPercent===e,name:`tipPercent`,onChange:()=>a({tipPercent:e}),onKeyDown:t=>o(t,e),tabIndex:i.tipPercent===e?0:-1,type:`radio`,value:e}),W(`span`,{children:[e,`%`]})]},e)),W(`label`,{className:`lockerverse-payment__tip-choice`,children:[U(`input`,{checked:i.tipPercent===`custom`,name:`tipPercent`,onChange:()=>a({tipPercent:`custom`}),onKeyDown:e=>o(e,`custom`),tabIndex:i.tipPercent===`custom`?0:-1,type:`radio`,value:`custom`}),U(`span`,{children:`Other`})]})]}),i.tipPercent===`custom`?W(`label`,{children:[U(`span`,{children:`Custom tip`}),W(`span`,{className:`lockerverse-payment__money-input`,children:[U(`span`,{"aria-hidden":`true`,children:`$`}),U(`input`,{"aria-describedby":t?n:void 0,"aria-invalid":t?`true`:void 0,inputMode:`decimal`,name:`tip`,onChange:e=>a({customTip:e.currentTarget.value}),placeholder:`0.00`,value:i.customTip})]}),t?U(`span`,{className:`lockerverse-payment__field-message`,id:n,children:t}):null]}):U(`input`,{name:`tip`,type:`hidden`,value:i.tipPercent})]})}function le({checked:e,children:t,name:n,onChange:r}){return W(`label`,{className:`lockerverse-payment__check-row`,children:[U(`input`,{checked:e,name:n,onChange:e=>r(e.currentTarget.checked),type:`checkbox`}),U(`span`,{children:t})]})}function ue({customFields:e,errors:t,fields:r,idPrefix:i,isPromoApplying:a,memberIdLabel:o,onChange:s,onApplyPromo:c,promoError:l,values:u}){let d=e=>s({...u,...e});return W(`div`,{className:`lockerverse-payment__additional-fields`,children:[r.memberId?W(`label`,{children:[U(`span`,{children:o?.trim()||`Member ID`}),U(`input`,{name:`memberId`,onChange:e=>d({memberId:e.currentTarget.value}),placeholder:`Optional`,value:u.memberId})]}):null,r.merchSize?W(`div`,{className:`lockerverse-payment__field`,children:[U(`span`,{id:`${i}-merch-size-label`,children:`Size`}),U(Y,{ariaLabelledBy:`${i}-merch-size-label`,name:`merchSize`,onValueChange:e=>{let t=X.find(t=>t===e);t&&d({merchSize:t})},options:X.map(e=>({label:e,value:e})),value:u.merchSize})]}):null,r.promoCode?W(`div`,{className:`lockerverse-payment__field`,children:[U(`span`,{id:`${i}-promo-code-label`,children:`Promo code`}),W(`div`,{className:`lockerverse-payment__promo-control`,children:[U(`input`,{"aria-describedby":l?`${i}-promo-code-error`:void 0,"aria-invalid":l?`true`:void 0,"aria-labelledby":`${i}-promo-code-label`,name:`promoCode`,onChange:e=>d({promoCode:e.currentTarget.value}),placeholder:`Optional`,value:u.promoCode}),U(`button`,{disabled:!u.promoCode.trim()||a,onClick:c,type:`button`,children:a?`Applying…`:`Apply`})]}),l?U(`p`,{className:`lockerverse-payment__field-message`,id:`${i}-promo-code-error`,role:`alert`,children:l}):null]}):null,U(n,{choiceClassName:`lockerverse-payment__check-row`,errorClassName:`lockerverse-payment__field-message`,errors:t,fields:e,idPrefix:i,onChange:e=>d({customFields:e}),values:u.customFields})]})}function de({amountCents:e,enabled:t,onChange:n,values:r}){return t?W(le,{checked:r.includeServiceFee,name:`includeServiceFee`,onChange:e=>n({...r,includeServiceFee:e}),children:[`Add `,K(e),` to help cover processing fees`]}):null}function fe(e){return{error:void 0,message:void 0,status:e?`recovering`:`editing`}}function Q(e,t,n){return t.includes(e.status)?{...e,...n}:e}function pe(e,t){if(e.status===`sold_out`||e.status===`succeeded`||e.status===`unresolved`)return e;switch(t.type){case`field_changed`:return Q(e,[`editing`,`invalid`,`refreshing_quote`],{error:void 0,status:`editing`});case`validation_failed`:return Q(e,[`editing`],{status:`invalid`});case`quote_refresh_started`:return Q(e,[`editing`,`invalid`],{status:`refreshing_quote`});case`quote_refresh_succeeded`:return Q(e,[`refreshing_quote`],{error:void 0,status:`editing`});case`quote_refresh_failed`:return Q(e,[`refreshing_quote`],{error:t.error??e.error,status:`editing`});case`submission_started`:return Q(e,[`editing`,`invalid`,`refreshing_quote`],{error:void 0,status:`submitting`});case`submission_validation_failed`:return Q(e,[`submitting`],{error:void 0,status:`invalid`});case`quote_changed`:return Q(e,[`submitting`],{status:`editing`});case`retryable_failure`:return Q(e,[`editing`,`invalid`,`submitting`],{error:t.error,status:`editing`});case`recovery_failed`:return Q(e,[`recovering`],{error:t.error,status:`editing`});case`sold_out`:return{error:void 0,message:void 0,status:`sold_out`};case`succeeded`:return Q(e,[`recovering`,`submitting`],{message:t.message,status:`succeeded`});case`unresolved`:return Q(e,[`recovering`,`submitting`],{message:t.message,status:`unresolved`});default:return e}}function me(e){return e.status===`editing`||e.status===`invalid`||e.status===`refreshing_quote`?e.error:void 0}function he(e){return e.status===`sold_out`?`sold_out`:e.status===`succeeded`?`success`:e.status===`unresolved`?`unresolved`:e.status===`submitting`||e.status===`recovering`?`submitting`:e.status===`invalid`?`invalid`:me(e)?`error`:`idle`}function ge(e){return e.status===`submitting`}function _e(t){return e(t)}function ve(e,n){let r=n?{...e,phone:_e(e.phone)}:e,i=L(n?{email:t,phone:s}:{email:t}),a=z(i,r);if(a.success)return{errors:{},value:a.output};let o={};for(let e of a.issues){let t=e.path?.[0]?.key;(t===`email`||t===`phone`)&&!o[t]&&(o[t]=e.message)}return{errors:o,value:null}}const ye=[`amountCents`,`discountableSubtotalCents`,`discountCents`,`serviceFeeCents`,`subtotalCents`,`tipCents`,`totalCents`],be=[`discountableSubtotalCents`,`discountCents`,`subtotalCents`];function xe(e,t,n,r){return(n===t.totalCents?be:ye).some(n=>e[n]!==t[n])||r!==t.payment.connectedAccountId||e.authoritative&&(e.payment.connectedAccountId!==r||e.payment.currency!==t.payment.currency)||JSON.stringify(e.appliedDiscount)!==JSON.stringify(t.appliedDiscount)||JSON.stringify(e.lineItems)!==JSON.stringify(t.lineItems)}function Se(e){return e.checkoutStatus===`success`?{kind:`success`,payment:e}:e.checkoutStatus===`failed`?{kind:`failed`,payment:e}:{kind:`unresolved`,paymentReference:e.paymentReference,reason:e.checkoutStatus===`action_required`?`action_required`:`pending`}}async function Ce(e,t,n){if(t.checkoutStatus!==`action_required`)return Se(t);if(!n)return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`};if(t.clientSecret)try{await n.handleNextAction({clientSecret:t.clientSecret})}catch{}try{return Se(await e.getPaymentStatus(t.paymentReference))}catch{return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`}}}async function we(e,t,n){let r;try{r=await e.submitPayment(t)}catch(n){if(!(n instanceof m&&n.recoveryRecommended))throw n;try{r=await e.getPaymentStatus(t.checkout.paymentReference)}catch{return{kind:`unresolved`,paymentReference:t.checkout.paymentReference,reason:`recovery_failed`}}}return Ce(e,r,n)}async function Te(e,t,n){try{return Ce(e,await e.getPaymentStatus(t),n)}catch{return{kind:`unresolved`,paymentReference:t,reason:`recovery_failed`}}}const Ee=R(V(),ne(),F()),De=R(I(),te(),P(1)),Oe=R(M(re([B({amountCents:De,productSlug:Ee}),B({productSlug:Ee,quantity:De}),B({productSlug:Ee})])),N(1)),ke=R(V(),ne(),ee(/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/,`Enter a valid tip amount.`));function Ae(e){let t=z(ke,e);if(!t.success)return{message:t.issues[0]?.message??`Enter a valid tip amount.`,success:!1};let[n=`0`,r=``]=t.output.split(`.`),i=BigInt(n)*100n+BigInt(r.padEnd(2,`0`));return i>BigInt(2**53-1)?{message:`Enter a valid tip amount.`,success:!1}:{cents:Number(i),success:!0}}function je(e){let t=z(Oe,e);return t.success?{success:!0,value:t.output}:{message:`Lockerverse payment configuration is invalid.`,success:!1}}const Me=`This promo code is invalid or cannot be applied.`;function Ne(e,t){return t.tipPercent===`custom`?t.customTip.trim()?Ae(t.customTip):{cents:0,success:!0}:{cents:Math.round(e*Number(t.tipPercent)/100),success:!0}}function Pe(e,t,n,r){let i={};return n&&(i.email=n),e.widget.fields.serviceFee&&(i.includeServiceFee=t.includeServiceFee),e.widget.fields.promoCode&&t.promoCode.trim()&&(i.promoCode=t.promoCode.trim()),e.widget.fields.tipping&&(i.tipCents=r),i}function Fe(e,t,n){let r=e.widget.fields.tipping?Ne(n.subtotalCents,t):{cents:0,success:!0};if(!r.success)return{parsedTip:r,totalCents:null};let i=e.widget.fields.serviceFee&&t.includeServiceFee?n.serviceFeeCents||Math.round(n.subtotalCents*e.pricingPolicy.serviceFeeRateBasisPoints/1e4):0;return{parsedTip:r,totalCents:n.totalCents-n.serviceFeeCents-n.tipCents+i+r.cents}}function Ie(e,t){return{displayedTotalCents:e.totalCents,promoError:t&&e.appliedDiscount?.source!==`promo_code`?Me:void 0}}function Le(e,t){let n;return t||(n=e instanceof Error?e.message:`The order total could not be updated.`),{paymentError:n,promoError:t?Me:void 0}}function Re(e,t){if(!e?.complete)throw Error(`${t} address is required.`);return e.value}function ze(e,t,n,r){if(e.widget.fields.shipping)return t.shippingMatchesBilling?n:Re(r.shipping,`Shipping`)}function Be({billingAddress:e,catalog:t,email:n,phone:r,shippingAddress:i}){let a={payment_method_data:{billing_details:t.widget.fields.phone?{address:e.address,email:n,name:e.name,phone:r}:{address:e.address,email:n,name:e.name}}};return i?{...a,shipping:{address:i.address,name:i.name,phone:t.widget.fields.phone?r:i.phone??null}}:a}function Ve({catalog:e,confirmationToken:t,email:n,fieldValues:i,metadata:a,phone:o,shippingAddress:s}){let c={customFieldAnswers:r(e.widget.customFields,i.customFields),email:n};if(t&&(c.confirmationToken=t),a&&(c.metadata=a),e.widget.fields.memberId&&i.memberId.trim()&&(c.memberId=i.memberId.trim()),e.widget.fields.merchSize&&(c.merchSize=i.merchSize),e.widget.fields.phone&&(c.phone=o),s){let e={city:s.address.city??``,country:s.address.country,line1:s.address.line1??``,postal_code:s.address.postal_code??``,state:s.address.state??``};s.address.line2&&(e.line2=s.address.line2),c.shipping={address:e,name:s.name}}return c}function He(e){if(!e())throw Error(`Payment component is no longer active.`)}function Ue(e,t){f(e,t)}function We(e,t,n,r){return e.kind===`failed`?{kind:`payment_failed`,message:r}:e.kind===`unresolved`?{kind:`payment_unresolved`,paymentReference:e.paymentReference,reason:e.reason}:{email:n,kind:`payment`,payment:e.payment,quote:t}}async function Ge({addresses:e,catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:o,isAttemptActive:s,locallyPreviewedTotalCents:c,metadata:l,onPaymentRecoveryChange:u,phone:d,quote:f,stripe:p,stripeConnectedAccountId:m}){let h=a.trim().toLowerCase(),g=_e(d),_=Ne(f.subtotalCents,o);if(!_.success)throw Error(_.message);let v=await r.calculateTotal({...Pe(t,o,h,_.cents),catalog:t,items:n});if(He(s),v.totalCents>0&&xe(f,v,c,m))return{kind:`quote_changed`,quote:v};let y,b;if(v.totalCents===0)t.widget.fields.shipping&&(y=ze(t,o,Re(e.billing,`Billing`),e));else{if(!(i&&p))throw Error(`Payment form is still loading.`);await i.update({amount:v.totalCents}),He(s);let n=await i.submit();if(He(s),n.error)throw Error(n.error.message);let r=Re(e.billing,`Billing`);y=ze(t,o,r,e);let a=await p.createConfirmationToken({elements:i,params:Be({billingAddress:r,catalog:t,email:h,phone:g,shippingAddress:y})});if(He(s),a.error)throw Error(a.error.message);b=a.confirmationToken.id}Ue(u,{connectedAccountId:v.payment.connectedAccountId,paymentReference:v.paymentReference});let x=await we(r,{checkout:v,submission:Ve({catalog:t,confirmationToken:b,email:h,fieldValues:o,metadata:l,phone:g,shippingAddress:y})},p);return He(s),We(x,v,h,v.totalCents===0?`Order could not be completed. Review the details and try again.`:`Payment was declined. Check your payment details and try again.`)}function Ke(e,t){f(e,t)}function qe(e,t){f(e,t)}function Je(e,t){return{...e,...t}}function Ye(e,t,n){return e.kind===`unresolved`&&e.reason===`action_required`&&!t&&!n}function Xe(e){return e instanceof m&&e.serverCode===`PAYMENT_WIDGET_SALES_LIMIT_REACHED`}function Ze({nextQuote:e,onQuoteChange:t,setDisplayedTotalCents:n,setPromoError:r,updateState:i,validatePromo:a}){let o=Ie(e,a);i({type:`quote_refresh_succeeded`}),n(o.displayedTotalCents),t(e),a&&r(o.promoError)}function Qe({error:e,setPromoError:t,updateState:n,validatePromo:r}){let i=Le(e,r);r&&t(i.promoError),n(i.paymentError===void 0?{type:`quote_refresh_failed`}:{error:i.paymentError,type:`quote_refresh_failed`})}function $e({onPaymentComplete:e,onPaymentRecoveryChange:t,onPaymentUncertain:n,onQuoteChange:r,result:i,setDisplayedTotalCents:a,dispatchState:o}){if(i.kind===`quote_changed`){let e=`The total changed to ${K(i.quote.totalCents)}. Review it and pay again.`;r(i.quote,e),a(i.quote.totalCents),o({type:`quote_changed`});return}if(i.kind===`payment_failed`){Ke(t,null),o({error:i.message,type:`retryable_failure`});return}if(i.kind===`payment_unresolved`){o({message:`Payment is still processing. Do not submit it again.`,type:`unresolved`}),qe(n,{paymentReference:i.paymentReference,reason:i.reason});return}r(i.quote),Ke(t,null),o({message:i.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`}),f(e,Je(i.payment,{email:i.email,lineItems:i.quote.lineItems}))}function et(e){let{catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:s,metadata:c,onPaymentComplete:l,onResumePaymentFailed:u,onPaymentRecoveryChange:d,onPaymentUncertain:p,onQuoteChange:h,onStateChange:g,quote:v,resumePayment:b,stripe:x,stripeConnectedAccountId:S,stripeLoadFailed:C,paymentState:E,updateState:D}=e,[O,k]=T(v.totalCents),[A,j]=T(),M=w(!1),N=w(0),P=w(0),F=_(e=>D(e,!0),[D]),I=_(()=>{let e=P.current+1;return P.current=e,()=>P.current===e},[]);y(()=>()=>{P.current+=1,N.current+=1},[]);let{parsedTip:L,totalCents:R}=Fe(t,s,v);y(()=>{R!==null&&(k(R),R>0&&i?.update({amount:R}))},[t.pricingPolicy.serviceFeeRateBasisPoints,t.widget.fields.serviceFee,i,s.includeServiceFee,R,v.serviceFeeCents,v.tipCents,v.totalCents,v.subtotalCents]),y(()=>{if(!b||M.current||E.status!==`recovering`)return;M.current=!0;let e=I();return g(he(E)),Te(r,b.paymentReference,x).then(t=>{if(e()&&!Ye(t,x,C)){if(t.kind===`failed`){Ke(d,null),u(),F({error:`The previous payment failed. Check your details and try again.`,type:`recovery_failed`});return}if(t.kind===`unresolved`){F({message:`Payment is still processing. Do not submit it again.`,type:`unresolved`}),qe(p,{paymentReference:t.paymentReference,reason:t.reason});return}Ke(d,null),F({message:t.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`}),f(l,Je(t.payment,{email:null,lineItems:null}))}}),()=>{e()&&(P.current+=1),M.current=!1}},[r,l,u,d,p,g,b,x,C,I,F,E]);let ee=_((e=!1,t=!1)=>{t||(N.current+=1),e&&j(void 0),D({type:`field_changed`})},[D]);async function te(e=!1,i=!1){let o=ve({email:a.trim().toLowerCase(),phone:``},!1);if(!(L.success&&(o.value||e)))return;N.current+=1;let c=N.current;D({type:`quote_refresh_started`});try{let e=await r.calculateTotal({...Pe(t,s,o.value?.email??``,L.cents),catalog:t,items:n});if(c!==N.current)return;Ze({nextQuote:e,onQuoteChange:h,setDisplayedTotalCents:k,setPromoError:j,updateState:D,validatePromo:i})}catch(e){if(c!==N.current)return;if(Xe(e)){D({type:`sold_out`});return}Qe({error:e,setPromoError:j,updateState:D,validatePromo:i})}}async function z(){j(void 0),await te(!0,!0)}async function B({addresses:e,phone:u}){F({type:`submission_started`});let f=I();try{let o=await Ge({addresses:e,catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:s,isAttemptActive:f,locallyPreviewedTotalCents:O,metadata:c,onPaymentRecoveryChange:d,phone:u,quote:v,stripe:x,stripeConnectedAccountId:S});if(!f())return;$e({dispatchState:F,onPaymentComplete:l,onPaymentRecoveryChange:d,onPaymentUncertain:p,onQuoteChange:h,result:o,setDisplayedTotalCents:k})}catch(e){if(!f())return;if(Ke(d,null),Xe(e)){F({type:`sold_out`});return}let t=e instanceof m?o(e.serverCode):void 0;if(t)return F({type:`submission_validation_failed`}),{phoneError:t};F({error:e instanceof Error?e.message:`Payment could not be completed.`,type:`retryable_failure`})}}let V=E.status===`succeeded`||E.status===`unresolved`?E.message:void 0;return{commands:{applyPromo:z,fieldChanged:ee,refreshAuthoritativeTotal:te,reportStripeLoadError:e=>F({error:e,type:`retryable_failure`}),reportValidationFailure:()=>F({type:`validation_failed`}),submit:B},state:{displayedTotalCents:O,isRecovering:E.status===`recovering`,isRefreshingQuote:E.status===`refreshing_quote`,isSubmitting:ge(E),parsedTip:L,paymentError:me(E),promoError:A,terminalMessage:V}}}const tt=new Map,nt=(e,t)=>{let n=t?.stripeAccount??null,r=tt.get(e);r||(r=new Map,tt.set(e,r));let i=r.get(n);if(i)return i;let a=j(e,t).catch(()=>(r?.get(n)===a&&(r.delete(n),r.size===0&&tt.delete(e)),null));return r.set(n,a),a};function rt(e){let{connectedAccountId:t,publishableKey:n}=e.payment;return nt(n,t?{stripeAccount:t}:void 0)}function it(e){return e===`monthly`?{interval:`month`,label:`Monthly`}:e===`annually`?{interval:`year`,label:`Annual`}:null}function at(e,t,n){if(n){let{connectedAccountId:e}=n;return e}if(`payment`in t){let{connectedAccountId:e}=t.payment;return e}let{connectedAccountId:r}=e.payment;return r}function ot({accentColor:e,catalog:t,checkoutItems:n,client:r,fontFamily:i,metadata:a,onPaymentComplete:o,onResumePaymentFailed:s,onPaymentRecoveryChange:c,onPaymentUncertain:l,onQuoteChange:u,quote:d,resumePayment:f,onStateChange:p,stripeLoader:m,theme:h,visualStyle:g}){let[v,b]=T(()=>fe(!!f)),x=w(v);x.current=v;let C=_((e,t=!1)=>{let n=pe(x.current,e);n!==x.current&&(x.current=n,b(n),t&&p(he(n)))},[p]),E=at(t,d,f),O=w({connectedAccountId:E,paymentOption:d.paymentOption});v.status!==`submitting`&&v.status!==`recovering`&&(O.current={connectedAccountId:E,paymentOption:d.paymentOption});let{connectedAccountId:k,paymentOption:A}=O.current,j=S(()=>m(t.payment.publishableKey,k?{stripeAccount:k}:void 0).catch(()=>null),[t.payment.publishableKey,k,m]),[M,N]=T(!1);return y(()=>{let e=!0;return N(!1),j.then(t=>{e&&t===null&&N(!0)}),()=>{e=!1}},[j]),U(D,{options:{amount:Math.max(d.totalCents,100),appearance:{rules:{".Input:focus":{borderColor:e,boxShadow:`0 0 0 1px ${e}`,outline:`none`}},theme:h===`light`?`stripe`:`night`,variables:{borderRadius:g?.[`--lockerverse-radius`]??`10px`,colorBackground:g?.[`--lockerverse-control`]??(h===`light`?`#f5f6f7`:`#121212`),colorDanger:g?.[`--lockerverse-danger`]??(h===`light`?`#c52b3e`:`#f08a98`),colorPrimary:e,colorText:g?.[`--lockerverse-text`]??(h===`light`?`#121416`:`#ffffff`),colorTextPlaceholder:g?.[`--lockerverse-placeholder`]??(h===`light`?`#72767d`:`#6b6b6b`),colorTextSecondary:g?.[`--lockerverse-muted`]??(h===`light`?`#62666d`:`#a1a1aa`),focusBoxShadow:`none`,focusOutline:`none`,fontFamily:i,fontSizeBase:`16px`}},currency:t.payment.currency,excludedPaymentMethodTypes:[`us_bank_account`],mode:A===`one-time`?`payment`:`subscription`,syncAddressCheckbox:`none`},stripe:j,children:U(_t,{catalog:t,checkoutItems:n,client:r,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:c,onPaymentUncertain:l,onQuoteChange:u,onResumePaymentFailed:s,onStateChange:p,paymentState:v,quote:d,resumePayment:f,stripeConnectedAccountId:k,stripeLoadFailed:M,updateState:C})},`${t.payment.publishableKey}:${k??`platform`}:${A}`)}function st({label:e}){return W(`div`,{className:`lockerverse-payment__stripe-loader`,role:`status`,children:[U(`p`,{children:e}),W(`div`,{"aria-hidden":`true`,children:[U(`span`,{}),U(`span`,{}),U(`span`,{})]})]})}function ct({onError:e,onReady:t,ready:n}){return W(`div`,{className:`lockerverse-payment__stripe-element`,"data-ready":n,children:[n?null:U(st,{label:`Loading payment form...`}),U(`div`,{className:`lockerverse-payment__stripe-mount`,children:U(O,{onLoadError:({error:t})=>e(t.message??`Payment form failed to load.`),onReady:t,options:{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},layout:`tabs`,terms:{applePay:`auto`,auBecsDebit:`never`,bancontact:`never`,card:`always`,cashapp:`never`,googlePay:`never`,ideal:`never`,paypal:`auto`,sepaDebit:`never`,sofort:`never`,usBankAccount:`never`},wallets:{applePay:`auto`,googlePay:`never`}}})})]})}function lt({label:e,mode:t,onChange:n,onError:r,onReady:i,ready:a}){return W(`div`,{className:`lockerverse-payment__address`,children:[U(`h2`,{children:e}),W(`div`,{className:`lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address`,"data-ready":a,children:[a?null:U(st,{label:`Loading ${e.toLowerCase()}...`}),U(`div`,{className:`lockerverse-payment__stripe-mount`,children:U(E,{onChange:n,onLoadError:({error:t})=>r(t.message??`${e} failed to load.`),onReady:i,options:{autocomplete:{mode:`automatic`},mode:t}})})]})]})}function ut({message:e}){return e?U(`p`,{className:`lockerverse-payment__field-message`,role:`alert`,children:e}):null}function dt({catalog:e,displayedTotalCents:t,fieldValues:n,isBillingAddressReady:r,isPaymentReady:i,isShippingAddressReady:a,onAddressChange:o,onFieldValuesChange:s,onStripeLoadError:c,setIsBillingAddressReady:l,setIsPaymentReady:u,setIsShippingAddressReady:d}){let f=t>0;return W(H,{children:[f?U(ct,{onError:c,onReady:()=>u(!0),ready:i}):null,f||e.widget.fields.shipping?U(lt,{label:f?`Billing address`:`Shipping address`,mode:`billing`,onChange:e=>o(`billing`,e),onError:c,onReady:()=>l(!0),ready:r}):null,e.widget.fields.shipping?W(`div`,{className:`lockerverse-payment__shipping`,children:[U(le,{checked:n.shippingMatchesBilling,name:`shippingMatchesBilling`,onChange:e=>{s({...n,shippingMatchesBilling:e}),e?o(`shipping`,null):d(!1)},children:`Shipping is same as billing information`}),n.shippingMatchesBilling?null:U(lt,{label:`Shipping address`,mode:`shipping`,onChange:e=>o(`shipping`,e),onError:c,onReady:()=>d(!0),ready:a})]}):null]})}function ft({displayedBaseCents:e,displayedTipCents:t,displayedTotalCents:n,quote:r}){let i=it(r.paymentOption),a=Math.max(0,e-r.subtotalCents+r.discountCents);return W(`section`,{"aria-label":`Payment summary`,className:`lockerverse-payment__payment-summary`,children:[U(`h2`,{children:`Order summary`}),U(`div`,{className:`lockerverse-payment__payment-summary-items`,children:r.lineItems.map(e=>W(`div`,{className:`lockerverse-payment__payment-summary-row`,children:[W(`span`,{children:[e.productName,e.quantity>1?W(H,{children:[` `,W(`small`,{children:[`× `,e.quantity]})]}):null,e.paymentOption===`monthly`?U(`small`,{children:` · Monthly`}):null,e.paymentOption===`annually`?U(`small`,{children:` · Annual`}):null]}),U(`strong`,{children:K(e.subtotalCents)})]},e.listingId))}),W(`div`,{className:`lockerverse-payment__payment-summary-totals`,children:[a>0?W(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-detail`,children:[U(`span`,{children:`Service fee`}),U(`strong`,{children:K(a)})]}):null,r.discountCents>0&&r.appliedDiscount?W(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-discount`,children:[W(`span`,{children:[r.appliedDiscount.source===`email_list`?`Email discount`:`Promo code discount`,` `,`(`,r.appliedDiscount.percentageOff,`% off)`]}),W(`strong`,{children:[`-`,K(r.discountCents)]})]}):null,t>0?W(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-detail lockerverse-payment__payment-summary-tip`,children:[U(`span`,{children:`Tip`}),U(`strong`,{children:K(t)})]}):null,W(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-total`,children:[U(`span`,{children:i?`${i.label} total`:`Total`}),U(`strong`,{children:K(n)})]})]})]})}function pt({catalog:e,displayedTotalCents:t,fieldValues:n,isBillingAddressReady:r,isPaymentReady:i,isRequiredShippingReady:a,isSubmitting:o,onFieldValuesChange:s,quote:c}){let l=t===0,u=l?!e.widget.fields.shipping||r&&a:i&&r&&a,d=it(c.paymentOption),f=l?`Complete order`:`Pay ${K(t)}`;!l&&d&&(f=`Subscribe for ${K(t)}/${d.interval}`),o&&(f=l?`Completing…`:`Processing…`);let p=`Process payment for ${K(t)} total`;return l?p=`Complete order`:d&&(p=`Start ${d.label.toLowerCase()} subscription for ${K(t)}`),W(`div`,{className:`lockerverse-payment__actions`,children:[U(de,{amountCents:c.serviceFeeCents||Math.round(c.subtotalCents*e.pricingPolicy.serviceFeeRateBasisPoints/1e4),enabled:e.widget.fields.serviceFee,onChange:s,values:n}),U(`button`,{"aria-busy":o,"aria-label":p,disabled:o||!u,type:`submit`,children:f})]})}function mt(e,t){let n=e.elements.namedItem(t);if(n instanceof HTMLElement){n.focus();return}n instanceof RadioNodeList&&Array.from(n).find(e=>e instanceof HTMLElement)?.focus()}function ht({customFieldErrors:e,emailRef:t,form:n,parsedTipSuccess:r,phoneRef:i,validationErrors:a}){if(a.email){t.current?.focus();return}if(a.phone){i.current?.focus();return}if(!r){n.querySelector(`[name="tip"]`)?.focus();return}let[o]=Object.keys(e);o&&mt(n,`custom:${o}`)}function gt({email:e,emailDiscountPercentOff:t,emailErrorId:n,emailId:r,emailRef:i,errors:a,onEmailBlur:o,onEmailChange:s,onPhoneChange:c,onPhoneCountryChange:u,phone:d,phoneCountry:f,phoneEnabled:p,phoneErrorId:m,phoneId:h,phoneRef:g}){return W(`div`,{className:`lockerverse-payment__contact`,children:[U(`label`,{htmlFor:r,children:`Email`}),U(`input`,{"aria-describedby":a.email?n:void 0,"aria-invalid":a.email?`true`:void 0,autoComplete:`email`,id:r,name:`email`,onBlur:o,onChange:e=>s(e.currentTarget.value),placeholder:`name@example.com`,ref:i,type:`email`,value:e}),a.email?U(`p`,{className:`lockerverse-payment__field-message`,id:n,children:a.email}):null,t===void 0?null:W(`p`,{className:`lockerverse-payment__discount-message`,role:`status`,children:[`Your email qualifies for `,t,`% off.`]}),p?W(H,{children:[U(`label`,{htmlFor:h,children:`Phone`}),W(`div`,{className:`lockerverse-payment__phone-control`,children:[U(Y,{ariaLabel:`Phone number country`,className:`lockerverse-payment__select--phone-country`,name:`phoneCountry`,onValueChange:u,options:l,value:f}),U(`input`,{"aria-describedby":a.phone?m:void 0,"aria-invalid":a.phone?`true`:void 0,autoComplete:`tel`,id:h,inputMode:`tel`,name:`phone`,onChange:e=>c(e.currentTarget.value),placeholder:`(201) 555-0123`,ref:g,type:`tel`,value:d})]}),a.phone?U(`p`,{className:`lockerverse-payment__field-message`,id:m,children:a.phone}):null]}):null]})}function _t({catalog:e,checkoutItems:t,client:n,metadata:r,onPaymentComplete:i,onResumePaymentFailed:a,onPaymentRecoveryChange:o,onPaymentUncertain:s,onQuoteChange:l,onStateChange:f,quote:p,resumePayment:m,stripeConnectedAccountId:h,stripeLoadFailed:g,paymentState:_,updateState:v}){let[x,S]=T(``),[C,E]=T(``),[D,O]=T(`US`),[j,M]=T({}),[N,P]=T({}),[F,I]=T(),[L,R]=T(!1),[ee,te]=T(!1),[z,B]=T(!1),[V,ne]=T({customFields:u(e.widget.customFields),customTip:``,includeServiceFee:e.widget.fields.serviceFee,memberId:``,merchSize:`M`,promoCode:``,shippingMatchesBilling:!0,tipPercent:`10`}),re=w({billing:null,shipping:null}),H=w(null),G=w(null),ie=w(null),K=w(p.totalCents>0),q=et({catalog:e,checkoutItems:t,client:n,elements:k(),email:x,fieldValues:V,metadata:r,onPaymentComplete:i,onPaymentRecoveryChange:o,onPaymentUncertain:s,onQuoteChange:l,onResumePaymentFailed:a,onStateChange:f,paymentState:_,quote:p,resumePayment:m,stripe:A(),stripeConnectedAccountId:h,stripeLoadFailed:g,updateState:v}),{displayedTotalCents:J,isRecovering:ae,isRefreshingQuote:oe,isSubmitting:Y,parsedTip:X,paymentError:se,promoError:Z,terminalMessage:le}=q.state,de=`lockerverse-${b()}`,fe=`${de}-email`,Q=`${fe}-error`,pe=`${de}-phone`,me=`${pe}-error`,he=`${de}-tip-error`,ge=(X.success?X.cents:null)??0,_e=J-ge,ye=!e.widget.fields.shipping||V.shippingMatchesBilling||z;y(()=>{Y&&ie.current?.focus({preventScroll:!0})},[Y]),y(()=>{Y||j.email||!j.phone||G.current?.focus()},[j.email,j.phone,Y]),y(()=>{let e=J>0;e&&!K.current&&(R(!1),te(!1)),K.current=e},[J]);function be(e){q.commands.fieldChanged(!1,e!==`email`),M(t=>{let n={...t};return delete n[e],n})}function xe(e){let t=e.promoCode!==V.promoCode,n=e.includeServiceFee!==V.includeServiceFee;q.commands.fieldChanged(t,!(t||n)),ne(e),P({}),I(void 0)}async function Se(t){t.preventDefault();let n=d(C,D),r=ve({email:x,phone:n},e.widget.fields.phone),i=c(e.widget.customFields,V.customFields);if(!(r.value&&X.success)||Object.keys(i).length>0){M(r.errors),P(i),I(X.success?void 0:X.message),q.commands.reportValidationFailure();let e=t.currentTarget;queueMicrotask(()=>{ht({customFieldErrors:i,emailRef:H,form:e,parsedTipSuccess:X.success,phoneRef:G,validationErrors:r.errors})});return}M({}),P({});let a=await q.commands.submit({addresses:re.current,phone:n});a?.phoneError&&M({phone:a.phoneError})}return le?U(`p`,{className:`lockerverse-payment__payment-status`,ref:ie,role:`status`,tabIndex:-1,children:le}):ae?U(`p`,{className:`lockerverse-payment__payment-status`,role:`status`,children:`Recovering payment…`}):W(`form`,{"aria-busy":Y,className:`lockerverse-payment__form`,noValidate:!0,onSubmit:Se,children:[U(`div`,{"data-lockerverse-input-region":``,inert:Y?!0:void 0,children:W(`fieldset`,{className:`lockerverse-payment__input-fieldset`,disabled:Y,children:[U(ft,{displayedBaseCents:_e,displayedTipCents:ge,displayedTotalCents:J,quote:p}),U(ce,{enabled:e.widget.fields.tipping,error:F,errorId:he,onChange:xe,values:V}),U(gt,{email:x,emailDiscountPercentOff:p.appliedDiscount?.source===`email_list`?p.appliedDiscount.percentageOff:void 0,emailErrorId:Q,emailId:fe,emailRef:H,errors:j,onEmailBlur:()=>q.commands.refreshAuthoritativeTotal(),onEmailChange:e=>{S(e),be(`email`)},onPhoneChange:e=>{E(e),be(`phone`)},onPhoneCountryChange:e=>{O(e),q.commands.fieldChanged(!1,!0),requestAnimationFrame(()=>G.current?.focus())},phone:C,phoneCountry:D,phoneEnabled:e.widget.fields.phone,phoneErrorId:me,phoneId:pe,phoneRef:G}),U(dt,{catalog:e,displayedTotalCents:J,fieldValues:V,isBillingAddressReady:ee,isPaymentReady:L,isShippingAddressReady:z,onAddressChange:(e,t)=>{re.current[e]=t},onFieldValuesChange:xe,onStripeLoadError:q.commands.reportStripeLoadError,setIsBillingAddressReady:te,setIsPaymentReady:R,setIsShippingAddressReady:B}),U(ue,{customFields:e.widget.customFields,errors:N,fields:e.widget.fields,idPrefix:de,isPromoApplying:oe,memberIdLabel:e.community?.memberIdLabel,onApplyPromo:q.commands.applyPromo,onChange:xe,promoError:Z,values:V}),U(pt,{catalog:e,displayedTotalCents:J,fieldValues:V,isBillingAddressReady:ee,isPaymentReady:L,isRequiredShippingReady:ye,isSubmitting:Y,onFieldValuesChange:xe,quote:p})]})}),Y?U(`p`,{className:`lockerverse-payment__sr-only`,ref:ie,role:`status`,tabIndex:-1,children:J===0?`Completing order…`:`Processing payment…`}):null,U(ut,{message:se})]})}function vt(){return U(p,{fieldCount:2,label:`Loading payment…`,sectionCount:2,showCheckbox:!0})}function yt(e,t){switch(t.type){case`loading`:return{phase:`loading`,revision:e.revision};case`ready`:return St(t.displayedQuote,e.revision+1);case`error`:return{failure:t.failure,phase:`error`,revision:e.revision};case`checkout`:return e.phase===`ready`?{...e,displayedQuote:t.checkout,quoteFailure:void 0}:e;case`quote-error`:return e.phase===`ready`?{...e,quoteFailure:t.failure}:e;default:return e}}function $(e,t){return e===t}function bt({checkout:e}){return{displayedQuote:e,type:`ready`}}function xt(e){return e instanceof Error?e.message:`Lockerverse payment could not load.`}function St(e,t){return{checkoutItems:[...e.items],displayedQuote:e,phase:`ready`,quoteFailure:void 0,revision:t}}function Ct(e,t){let n=e.widget.fields.serviceFee;return h(e,{includeServiceFee:n,selection:t})}function wt(e,t){try{return St(Ct(e,t),1)}catch(e){return{failure:xt(e),phase:`error`,revision:0}}}function Tt({catalog:e,client:t,paymentState:n,selection:r}){let i=je(r),a=i.success?JSON.stringify(i.value):`invalid-selection`,o=S(()=>i.success?i.value:[],[i.success,a]),[s,c]=C(yt,void 0,()=>i.success?wt(e,o):{phase:`loading`,revision:0}),l=w(void 0),u=w(0),d=w(s.phase===`ready`?a:void 0),f=w(s.phase===`error`?a:void 0),p=n===`submitting`||n===`success`||n===`unresolved`;y(()=>{if(!i.success||p||$(f.current,a)||$(l.current,a))return;let n=!0;l.current=a;let r=d.current===a;r||c({type:`loading`});function s(e){n&&c(e)}function m(){n&&(l.current=void 0,f.current=a)}let h;function g(e){if(!n||(l.current=void 0,f.current=a,r&&h!==void 0&&u.current!==h))return;let t=xt(e);if(t===`This option is sold out.`){c({failure:t,type:`error`});return}c(r?{failure:t,type:`quote-error`}:{failure:t,type:`error`})}async function _(){try{h=u.current;let n=e.widget.fields.serviceFee;if(!r){let t=Ct(e,o);r=!0,d.current=a,s(bt({checkout:t}))}let i=await t.calculateTotal({catalog:e,includeServiceFee:n,selection:o});m(),u.current===h&&s({checkout:i,type:`checkout`})}catch(e){g(e)}}return _(),()=>{n=!1,$(l.current,a)&&(l.current=void 0)}},[e,t,i.success,p,a,o]);let m=$(d.current,a)||$(f.current,a)||$(l.current,a),h=p||m?s:{phase:`loading`,revision:s.revision};return{selectionError:i.success?void 0:i.message,session:h,updateCheckout:e=>{u.current+=1,c({checkout:e,type:`checkout`})}}}function Et(e,t){let n=i(e?.[`--lockerverse-accent`]??t?.accentColor??`#38d77a`),r=a(n),o={...e};return(e?.[`--lockerverse-accent`]!==void 0||t?.accentColor)&&(o[`--lockerverse-accent`]=n),r&&e?.[`--lockerverse-accent-contrast`]===void 0&&(o[`--lockerverse-accent-contrast`]=r),{accent:n,rootStyle:o}}function Dt({catalog:e,client:t,...n}){let{branding:r,className:i,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:s,onPaymentUncertain:c,resumePayment:l,selection:u,style:d,stripeLoader:f=nt,theme:p=`dark`,...m}=n,[h,g]=T(l),v=w(null),[b,S]=T(),[C,E]=T(`idle`),D=w(void 0),{selectionError:O,session:k,updateCheckout:A}=Tt({catalog:e,client:t,paymentState:C,selection:u}),j=k.phase===`ready`?k.revision:void 0,M=_(e=>{j!==void 0&&(D.current=j),E(e)},[j]),N=_(e=>s?.(e),[s]),P=_(()=>{g(void 0)},[]);y(()=>{k.phase===`loading`&&S(void 0)},[k.phase]),x(()=>{k.phase===`ready`&&D.current!==k.revision&&E(e=>e===`success`||e===`unresolved`?e:`idle`)},[k.phase,k.revision]);let F=[`lockerverse-payment`,i].filter(Boolean).join(` `),I=r??e.community,{accent:L,rootStyle:R}=Et(d,I);return O?U(`section`,{...m,className:F,"data-lockerverse-theme":p,role:`alert`,style:R,children:O}):k.phase===`error`&&k.failure===`This option is sold out.`||C===`sold_out`?W(`section`,{...m,className:F,"data-lockerverse-theme":p,role:`alert`,style:R,children:[U(`h1`,{children:`Sold out`}),U(`p`,{children:`This option is sold out.`})]}):k.phase===`error`?U(`section`,{...m,className:F,"data-lockerverse-theme":p,style:R,children:U(`p`,{role:`alert`,children:k.failure})}):k.phase===`ready`?W(`section`,{...m,"aria-label":`Payment`,className:F,"data-lockerverse-theme":p,"data-payment-state":C,ref:v,style:R,children:[W(`header`,{children:[e.widget.showCommunityBranding&&I?W(`div`,{className:`lockerverse-payment__branding`,children:[I.imageUrl?U(`img`,{alt:I.name,height:`48`,src:I.imageUrl,width:`48`}):null,U(`strong`,{children:I.name})]}):null,U(`h1`,{children:e.widget.title??e.widget.name}),e.widget.description?U(`p`,{children:e.widget.description}):null]}),b?U(`p`,{className:`lockerverse-payment__payment-status`,role:`status`,children:b}):null,k.quoteFailure?W(`div`,{className:`lockerverse-payment__payment-status`,role:`alert`,children:[U(`span`,{children:k.quoteFailure}),U(`span`,{children:` The final total will be checked when you submit.`})]}):null,U(J,{container:v,children:U(ot,{accentColor:L,catalog:e,checkoutItems:k.checkoutItems,client:t,fontFamily:d?.[`--lockerverse-font-family`]??`ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:N,onPaymentUncertain:c,onQuoteChange:(e,t)=>{S(t),A(e)},onResumePaymentFailed:P,onStateChange:M,quote:k.displayedQuote,resumePayment:h,stripeLoader:f,theme:p,visualStyle:R},k.revision)})]}):U(`section`,{...m,"aria-busy":`true`,"aria-label":`Payment`,className:F,"data-lockerverse-theme":p,style:R,children:U(vt,{})})}function Ot({children:e,loading:t=!1,viewProps:n}){let{branding:r,className:o,metadata:s,onPaymentComplete:c,onPaymentRecoveryChange:l,onPaymentUncertain:u,resumePayment:d,selection:f,stripeLoader:p,style:m,theme:h=`dark`,...g}=n,_=i(m?.[`--lockerverse-accent`]??r?.accentColor??`#38d77a`),v=a(_),y={...m};return(m?.[`--lockerverse-accent`]!==void 0||r?.accentColor)&&(y[`--lockerverse-accent`]=_),v&&m?.[`--lockerverse-accent-contrast`]===void 0&&(y[`--lockerverse-accent-contrast`]=v),U(`section`,{...g,...t?{"aria-busy":!0,"aria-label":`Payment`}:{},className:[`lockerverse-payment`,o].filter(Boolean).join(` `),"data-lockerverse-theme":h,style:y,children:e})}function kt({widget:e,...t}){return e.error?W(Ot,{viewProps:t,children:[U(`p`,{role:`alert`,children:e.error.message}),U(`button`,{onClick:e.refresh,type:`button`,children:`Retry`})]}):e.loading||!e.catalog?U(Ot,{loading:!0,viewProps:t,children:U(vt,{})}):U(Dt,{catalog:e.catalog,client:e.client,...t})}export{rt as n,kt as t};
|
|
2
2
|
//# sourceMappingURL=lockerverse-payment.js.map
|