@lockerverse/react 0.2.160 → 0.2.161

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 +1 @@
1
- {"version":3,"file":"auction-item.d.ts","names":[],"sources":["../src/auction-item-types.ts","../src/lockerverse-auction-item.tsx"],"mappings":";;;;;KAaY;EACV;EACA;EACA,MAAM;EACN,SAAS,YAAY;EACrB,SAAS;EACT,YAAY;;KAGF;EACV,SAAS;EACT,QAAQ;EACR;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;EAGA,2BAA2B;EAC3B;EACA;EACA,QAAQ;EACR,QAAQ;EACR,eAAe;;EAEf,kBAAkB,QAAQ;;EAE1B,sBAAsB,QAAQ;EAC9B,4BACE,UAAU;EAEZ,eAAe;;EAEf,iBAAiB;;;;iBCiYH,uBAAuB,OAAO,8CAA2B,IAAA"}
1
+ {"version":3,"file":"auction-item.d.ts","names":[],"sources":["../src/auction-item-types.ts","../src/lockerverse-auction-item.tsx"],"mappings":";;;;;KAaY;EACV;EACA;EACA,MAAM;EACN,SAAS,YAAY;EACrB,SAAS;EACT,YAAY;;KAGF;EACV,SAAS;EACT,QAAQ;EACR;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;EAGA,2BAA2B;EAC3B;EACA;EACA,QAAQ;EACR,QAAQ;EACR,eAAe;;EAEf,kBAAkB,QAAQ;;EAE1B,sBAAsB,QAAQ;EAC9B,4BACE,UAAU;EAEZ,eAAe;;EAEf,iBAAiB;;;;iBC4OH,uBAAuB,OAAO,8CAA2B,IAAA"}
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,i as n,l as r,n as i,r as a,s as o,t as s}from"./use-auction-boundary.js";import{n as c,t as l}from"./auction-image.js";import{d as u,n as d,p as f,r as p,t as m,u as h}from"./phone-field.js";import{t as g}from"./host-callback.js";import{i as _,n as v,t as y}from"./stripe-loader.js";import{t as b}from"./auction-result2.js";import{ArrowRight as x,ChevronDown as S,ChevronLeft as C,ChevronRight as w,Clock3 as T,Gavel as E,Pause as ee,Play as D,ShieldCheck as O,TimerReset as k,X as A}from"lucide-react";import{useCallback as j,useEffect as M,useId as N,useMemo as P,useRef as F,useState as I}from"react";import{Fragment as L,jsx as R,jsxs as z}from"react/jsx-runtime";import{LockerverseSdkError as B,calculateLockerverseAuctionPricing as V,getLockerverseAuctionMinimumBid as H}from"@lockerverse/sdk/auctions";import{AddressElement as U,Elements as W,PaymentElement as G,useElements as K,useStripe as te}from"@stripe/react-stripe-js";import{Dialog as q}from"@base-ui/react/dialog";import J from"embla-carousel-autoplay";import Y from"embla-carousel-react";function X(e){return{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},terms:{applePay:e?`auto`:`never`,auBecsDebit:`never`,bancontact:`never`,card:`always`,cashapp:`never`,googlePay:`never`,ideal:`never`,paypal:e?`auto`:`never`,sepaDebit:`never`,sofort:`never`,usBankAccount:`never`},wallets:{applePay:e?`auto`:`never`,googlePay:`never`}}}function ne(e){let{isPurchase:t,item:r,pricing:i,id:a}=e;return z(`form`,{className:`lockerverse-auctions__checkout`,noValidate:!0,onSubmit:e.onSubmit,children:[z(`div`,{className:`lockerverse-auctions__checkout-header`,children:[z(`div`,{className:`lockerverse-auctions__checkout-navigation`,children:[R(`button`,{"aria-label":`Back`,className:`lockerverse-auctions__checkout-back`,disabled:!e.onBack,onClick:e.onBack,type:`button`,children:R(C,{"aria-hidden":`true`,size:20})}),z(`div`,{children:[R(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Step 2 of 2`}),R(`p`,{children:t?`Secure checkout`:`Secure payment method`})]})]}),R(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:e.communityName}),R(`h2`,{children:t?`Finalize your purchase.`:`Finalize your bid authorization.`}),R(`p`,{className:`lockerverse-auctions__checkout-summary`,children:t?z(L,{children:[`Pay `,R(`strong`,{children:n(i.totalCents)}),` for`,` `,e.quantity,` `,e.quantity===1?`item`:`items`,` of`,` `,R(`strong`,{children:r.name}),`. Your card is charged immediately once checkout succeeds.`]}):z(L,{children:[`Authorize a payment method for your bid of`,` `,R(`strong`,{children:n(i.subtotalCents)}),` on`,` `,R(`strong`,{children:r.name}),`. Your card is only charged if this bid wins the item.`]})}),r.collectShippingAddress&&z(`div`,{className:`lockerverse-auctions__checkout-physical`,children:[R(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Physical item`}),R(`p`,{children:`This item requires a delivery address. Billing details are used by default, and you can switch to a separate delivery address below if needed.`})]})]}),z(`div`,{className:`lockerverse-auctions__checkout-body`,children:[e.showFields&&z(`fieldset`,{disabled:e.locked,children:[z(`div`,{className:`lockerverse-auctions__checkout-contact`,children:[R(u,{error:e.contactErrors.email,id:`${a}-email`,label:`Email`,name:`email`,onChange:t=>e.onEmailChange(t.target.value),required:!0,value:e.email}),R(f,{error:e.contactErrors.phone,id:`${a}-phone`,label:`Phone`,children:R(m,{country:e.phoneCountry,error:e.contactErrors.phone,errorId:`${a}-phone-error`,id:`${a}-phone`,name:`phone`,onChange:e.onPhoneChange,required:!0,value:e.phone})})]}),z(`section`,{"aria-label":`Payment Information`,className:`lockerverse-auctions__checkout-section`,children:[z(`div`,{className:`lockerverse-auctions__checkout-section-heading`,children:[R(`h3`,{children:`Payment Information`}),R(`p`,{children:t?`Processed securely and charged immediately for this purchase.`:`Stored securely and charged only if your bid finishes on top.`})]}),R(G,{onLoadError:e.onPaymentLoadError,options:X(t)})]}),z(`section`,{"aria-label":`Billing Details`,className:`lockerverse-auctions__checkout-section`,children:[R(`h3`,{children:`Billing Details`}),R(U,{onChange:e.onBillingChange,options:{mode:`billing`}}),R(`p`,{children:t?`Use your full name here. We use the email and phone above for purchase confirmation and fulfillment updates.`:`Use the bidder's full name here. We use the email and phone above to contact you if this bid is outbid or wins.`})]}),r.collectShippingAddress&&z(`section`,{"aria-label":`Delivery Details`,className:`lockerverse-auctions__checkout-section`,children:[z(`label`,{className:`lockerverse-auctions__checkout-checkbox lockerverse-auctions__checkout-delivery`,htmlFor:`${a}-delivery-same-as-billing`,children:[R(h,{checked:e.sameAsBilling,id:`${a}-delivery-same-as-billing`,onChange:t=>e.onSameAsBillingChange(t.target.checked)}),z(`span`,{children:[R(`strong`,{children:`Delivery address is the same as billing`}),R(`span`,{children:`Leave this on for the fastest flow. Turn it off only if the delivery address should differ from the billing details above.`})]})]}),!e.sameAsBilling&&z(L,{children:[R(`h3`,{children:`Delivery Address`}),R(U,{onChange:e.onShippingChange,options:{mode:`shipping`}})]})]}),e.serviceFeeEnabled&&R(re,{...e})]}),e.message&&R(`p`,{"aria-live":`polite`,className:`lockerverse-auctions__notice`,role:`status`,children:e.message}),!e.isTerminal&&z(`div`,{className:`lockerverse-auctions__checkout-footer`,children:[z(`p`,{children:[t?`By continuing, you agree to be charged for this purchase.`:`By continuing, you agree to have this payment method stored for item settlement if your bid is the winning offer.`,r.collectShippingAddress?` Your delivery details are stored with the ${t?`order`:`bid`} so the seller can fulfill the item after payment.`:``]}),z(`button`,{className:`lockerverse-auctions__button lockerverse-auctions__checkout-submit`,disabled:e.submitDisabled,type:`submit`,children:[e.buttonText,R(x,{"aria-hidden":`true`,size:16})]})]})]})]})}function re(e){let{isPurchase:t,pricing:r}=e;return R(`section`,{"aria-label":`Processing fees`,className:`lockerverse-auctions__checkout-section`,children:e.onIncludeServiceFeeChange?z(`label`,{className:`lockerverse-auctions__checkout-checkbox`,htmlFor:`${e.id}-service-fee`,children:[R(h,{checked:e.includeServiceFee,id:`${e.id}-service-fee`,onChange:t=>e.onIncludeServiceFeeChange?.(t.target.checked)}),z(`span`,{children:[z(`strong`,{children:[t?`Add`:`If I win, add`,` `,n(e.serviceFeeCents),` to help cover processing fees`]}),z(`span`,{children:[t?`Total`:`Total if I win`,`:`,` `,n(r.totalCents)]})]})]}):z(`p`,{children:[t?`Total`:`Total if I win`,`:`,` `,n(r.totalCents)]})})}function Z(e,t,n){return V(e,t.saleMode===`buy_now`?(t.buyNowPriceAmount??0)*n.quantity:n.amount,n.includeServiceFee)}function ie(t,n,r){if(e(t,n)!==`active`)return`This item is not accepting bids or purchases.`;if(n.saleMode===`hybrid`)return`This item type is not supported for checkout.`;if(n.saleMode===`buy_now`){if(n.isSoldOut||n.availableQuantity===0)return`This item is sold out.`;if(!(n.buyNowPriceAmount&&Number.isSafeInteger(r.quantity))||r.quantity<1||n.availableQuantity!==null&&r.quantity>n.availableQuantity)return`Select an available quantity.`}else if(!Number.isSafeInteger(r.amount)||r.amount%100!=0||r.amount<H(n))return`Enter a whole-dollar bid at or above the minimum bid.`;return null}function ae(e,t,n,r,i){return e.payment?.publishableKey!==t.payment?.publishableKey||e.payment?.connectedAccountId!==t.payment?.connectedAccountId||e.serviceFeeEnabled!==t.serviceFeeEnabled||n.saleMode!==r.saleMode||n.collectShippingAddress!==r.collectShippingAddress||JSON.stringify(Z(e,n,i))!==JSON.stringify(Z(t,r,i))}function oe(e){return{expectedServiceFeeCents:e.serviceFeeCents,expectedSubtotalCents:e.subtotalCents,expectedTotalCents:e.totalCents}}async function se({stripe:e,elements:t,email:n,phone:r,billing:i,shipping:a,collectShippingAddress:o}){if(!(i?.complete&&i.value.name.trim()))throw Error(`Complete your billing name and address.`);if(o&&!(a?.complete&&a.value.name.trim()))throw Error(`Complete your shipping name and address.`);let s=await t.submit();if(s.error)throw Error(s.error.message??`Check your payment details.`);let c=await e.createConfirmationToken({elements:t,params:{payment_method_data:{allow_redisplay:`always`,billing_details:{address:i.value.address,email:n,name:i.value.name,phone:r}},return_url:window.location.href,...o&&a?{shipping:{address:a.value.address,name:a.value.name,phone:r}}:void 0}});if(c.error||!c.confirmationToken)throw Error(c.error?.message??`Unable to prepare payment details.`);return c.confirmationToken.id}async function ce(e,t){if(!t.requiresAction)return;if(!t.clientSecret)throw Error(`Payment confirmation is incomplete. Check its status before trying again.`);let n=await e.handleNextAction({clientSecret:t.clientSecret});if(n.error)throw Error(n.error.message??`Payment confirmation is incomplete.`)}function le(e,t,n){return e===`busy`?n?`Processing...`:`Authorizing...`:e===`retry`?`Retry original purchase`:t?`Check purchase status`:n?`Buy Now`:`Authorize Bid`}function Q(e){let{auction:t,item:n,selection:r,client:i,onReview:a,onBack:o}=e,s=te(),c=K(),l=N(),[u,f]=I(e.contact?.email??``),[m,h]=I(e.contact?.phone??``),[v,y]=I(()=>p(e.contact?.phone??``)),[b,x]=I({}),[S,C]=I(!0),[w,T]=I(null),[E,ee]=I(null),[D,O]=I(e.resumePurchase??null),[k,A]=I(e.resumePurchase?`pending`:`ready`),[j,P]=I(null),L=F(e.resumePurchase?.submission.clientRequestId??null),z=k===`complete`||k===`uncertain`,V=F(!1),H=F(!0),U=F(e);U.current=e;let W=F(!1);function G(e){H.current&&A(e),g(U.current.onInteractionLockChange,e!==`ready`&&e!==`complete`)}function q(e){H.current&&P(e)}function J(e){G(e===`bid`?`uncertain`:`pending`),q(e===`bid`?`We could not confirm your bid. Do not submit another bid until you check your email or contact the auction organizer.`:`We could not confirm the purchase result. Check its status using the same purchase request.`),W.current||(W.current=!0,g(U.current.onUncertain,e))}M(()=>(H.current=!0,()=>{H.current=!1}),[]);let Y=!!(D??e.resumePurchase)||n.saleMode===`buy_now`,X=D?.pricing??e.resumePurchase?.pricing??Z(t,n,r),re=D?.payment??e.resumePurchase?.payment??t.payment;function Q(e){H.current&&O(e),g(U.current.onPurchaseRecoveryChange,e)}function $(e){e.status===`paid`?(L.current=null,Q(null),G(`complete`),g(U.current.onResult,{kind:`purchase`,purchaseId:e.purchaseId,quantity:e.quantity,serviceFeeCents:e.serviceFeeCents,status:`paid`,subtotalCents:e.subtotalCents,totalCents:e.totalCents,unitAmountCents:e.subtotalCents/e.quantity}),W.current||(W.current=!0,g(U.current.onPurchaseComplete,e))):e.status===`pending_payment`?(G(`pending`),q(`Your purchase is pending. Check its status before making another payment.`)):(L.current=null,Q(null),G(`ready`),q(`This purchase is ${e.status.replaceAll(`_`,` `)}. You can start a new purchase.`))}function ue(){let e=d(m,v),t=_({email:u,phone:e},!0);return x(t.errors),t.value?{email:t.value.email,phone:e}:(document.getElementById(`${l}-${t.errors.email?`email`:`phone`}`)?.focus(),null)}async function de(e){if(!e)throw Error(`Check the contact fields below.`);if(!(s&&c&&t.payment))throw Error(`Payment details are still loading.`);let o=await i.load(t.slug);if(!H.current)return null;let l=o.items.find(e=>e.id===n.id);if(!l)return a(o,`This item is no longer available.`),null;let u=ie(o,l,r);if(u||ae(t,o,n,l,r))return a(o,u??`The checkout details changed. Review them before continuing.`),null;let d=await se({billing:w,collectShippingAddress:n.collectShippingAddress,elements:c,email:e.email,phone:e.phone,shipping:S?w:E,stripe:s});return H.current?{confirmationToken:d,email:e.email,includeServiceFee:r.includeServiceFee,phone:e.phone,...oe(X)}:null}async function fe(e){let a=await i.createBid(t.slug,n.id,{...e,amount:r.amount});if(a.requiresAction){if(!(H.current&&s)){J(`bid`);return}await ce(s,a)}G(`complete`),g(U.current.onResult,{amountCents:a.subtotalCents,kind:`bid`}),W.current||(W.current=!0,g(U.current.onBidSubmitted,a))}async function pe(e,r){if(e.requiresAction){if(!(H.current&&s)){J(`purchase`);return}await ce(s,e);let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);a?$(a):(G(`pending`),q(`Payment status is not available yet. Check again shortly.`));return}$(e),!H.current&&e.status===`pending_payment`&&J(`purchase`)}async function me(e){let r=await i.getPurchaseStatus(t.slug,n.id,e.submission.clientRequestId);if(r)await pe(r,e);else{if(!H.current){J(`purchase`);return}G(`retry`),q(`No purchase is recorded yet. You can retry the original purchase with the same request ID.`)}}async function he(e,r){let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);if(a){await pe(a,r);return}Q(null),G(`ready`),q(`The purchase was rejected. Review the item and payment details before trying again. (${e.status??`validation`})`)}async function ge(e,t,n,r){let i=t&&(!(e instanceof B)||e.recoveryRecommended);if(q(e instanceof Error?e.message:`Unable to complete this request.`),Y&&n){if(!r&&e instanceof B&&!e.recoveryRecommended)try{await he(e,n);return}catch{}J(`purchase`)}else i?J(`bid`):G(`ready`)}function _e(){return L.current??=globalThis.crypto.randomUUID(),L.current}function ve(){return H.current?!0:(D||(Q(null),G(`ready`)),!1)}async function ye(e,r){if(r){await me(e);return}ve()&&await pe(await i.createPurchase(t.slug,n.id,e.submission),e)}let be=s&&c&&re;function xe(){if(V.current||z)return null;if(!be)return q(`Payment details are still loading.`),null;let e=D?null:ue();return D||e?{checkoutPayment:be,contact:e,retryOriginal:k===`retry`}:null}async function Se(e){e.preventDefault();let i=xe();if(!i)return;let{contact:a,checkoutPayment:o,retryOriginal:s}=i;V.current=!0,W.current=!1,G(`busy`),q(null);let c=!1,l=D;try{if(!l){let e=await de(a);if(!(e&&H.current)){G(`ready`);return}if(!Y){c=!0,await fe(e);return}l=Object.freeze({auctionId:t.id,item:n,itemId:n.id,payment:Object.freeze({...o}),pricing:X,submission:Object.freeze({...e,clientRequestId:_e(),paymentMethodTypes:Object.freeze([`card`]),quantity:r.quantity})}),Q(l)}c=!0,await ye(l,!!D&&!s)}catch(e){await ge(e,c,l,D!==null&&!s)}finally{V.current=!1}}let Ce=le(k,D!==null,Y),we=k!==`ready`;return R(ne,{buttonText:Ce,communityName:e.communityName??t.name,contactErrors:b,email:u,id:l,includeServiceFee:r.includeServiceFee,isPurchase:Y,isTerminal:z,item:n,locked:we,message:j,onBack:k===`ready`?o:void 0,onBillingChange:T,onEmailChange:t=>{f(t),e.onContactChange?.({email:t,phone:d(m,v)})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>q(`Unable to load payment form.`),onPhoneChange:({value:t,country:n})=>{h(t),y(n),e.onContactChange?.({email:u,phone:d(t,n)})},onSameAsBillingChange:C,onShippingChange:ee,onSubmit:Se,phone:m,phoneCountry:v,pricing:X,quantity:r.quantity,sameAsBilling:S,serviceFeeCents:D?X.serviceFeeCents:Z(t,n,{...r,includeServiceFee:t.serviceFeeEnabled}).serviceFeeCents,serviceFeeEnabled:t.serviceFeeEnabled,showFields:!(D||z),submitDisabled:k===`busy`||!s||!c})}const $=6e3;function ue(e,t){let n=F($),r=F(null),[i,a]=I($),o=P(()=>J({delay:i,playOnInit:!1,stopOnFocusIn:!1,stopOnInteraction:!0,stopOnMouseEnter:!1}),[i]),[s,c]=Y({duration:t?0:25,loop:!0},[o]),l=j(()=>{r.current&&(r.current.style.transform=`scaleX(${1-n.current/$})`)},[]),u=j(()=>{let e=o.timeUntilNext();e!==null&&(n.current=Math.max(1,Math.min($,e))),o.stop(),l()},[o,l]),d=j(()=>{n.current=$,a($),o.reset(),l()},[o,l]);return M(()=>{c&&(e?i===n.current?o.play():a(n.current):u())},[c,e,o,i,a,n,u]),M(()=>{if(!c)return;let t=0,r=()=>{let i=o.timeUntilNext();!e||i===null||(n.current=Math.max(0,Math.min($,i)),l(),t=requestAnimationFrame(r))},i=()=>{cancelAnimationFrame(t),e&&(t=requestAnimationFrame(r))},a=()=>cancelAnimationFrame(t),s=()=>{e&&o.play()};return c.on(`select`,d).on(`reInit`,s).on(`autoplay:timerset`,i).on(`autoplay:timerstopped`,a),l(),i(),()=>{a(),c.off(`select`,d).off(`reInit`,s).off(`autoplay:timerset`,i).off(`autoplay:timerstopped`,a)}},[c,o,e,n,d,l]),{embla:c,freeze:u,progressRef:r,reset:d,viewportRef:s}}function de({photos:e,name:t,imageSizes:n=`(max-width: 1279px) 100vw, 45vw`,selected:r,paused:a=!1,photoButtonRef:o,onSelect:s,onExpand:c}){let u=F(null),d=F(null),f=F([]),[p,m]=I(!0),[h,g]=I(!1),[_,v]=I(!1),[y,b]=I(!1),[x,S]=I(!1),{ref:T,visible:E}=i(),[O,k]=I(!1),[A,j]=I(!0),N=F(null),P=`lockerverse-auction-gallery__control ${A||O||_?`is-visible`:``}`,B=()=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>k(!1),2e3)},V=e=>{if(e.pointerType!==`mouse`){j(!0);return}k(!0),N.current&&clearTimeout(N.current),e.target instanceof Element&&e.target.closest(`[data-gallery-control]`)||B()};M(()=>{let e=window.matchMedia(`(hover: none), (pointer: coarse)`),t=()=>j(e.matches);return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),clearTimeout(N.current??void 0)}},[]);let H=!(a||p||h||_||y||x)&&E,U=e.length,W=U?(r%U+U)%U:0,{viewportRef:G,embla:K,progressRef:te,freeze:q,reset:J}=ue(H&&U>1,p);M(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>m(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),M(()=>{if(!K)return;let e=()=>s(K.selectedScrollSnap());return K.on(`select`,e).on(`reInit`,e),()=>{K.off(`select`,e).off(`reInit`,e)}},[K,s]),M(()=>{K&&K.selectedScrollSnap()!==W&&K.scrollTo(W,!0)},[K,W]),M(()=>{let e=()=>{document.hidden&&q()},t=()=>S(!1);return e(),document.addEventListener(`visibilitychange`,e,!0),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{document.removeEventListener(`visibilitychange`,e,!0),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[q]);let Y=e=>{K?.scrollTo((e+U)%U,p),J()};return M(()=>{let e=d.current;d.current=null,e&&document.activeElement===e&&T.current?.querySelector(`.lockerverse-auction-gallery__photo[tabindex="0"]`)?.focus({preventScroll:!0})},[W,T]),M(()=>{let e=u.current,t=f.current[W];if(!(e&&t))return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();r.left<n.left?e.scrollLeft-=n.left-r.left:r.right>n.right&&(e.scrollLeft+=r.right-n.right)},[W,U]),z(`section`,{"aria-label":`${t} photos`,className:`lockerverse-auction-gallery`,onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||v(!1)},onFocusCapture:e=>v(e.target.matches(`:focus-visible`)),onKeyDown:e=>{U<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),e.target instanceof HTMLButtonElement&&e.target.classList.contains(`lockerverse-auction-gallery__photo`)&&(d.current=e.target),Y(W+(e.key===`ArrowRight`?1:-1)))},onPointerEnter:e=>{e.pointerType===`mouse`&&g(!0)},onPointerLeave:e=>{e.pointerType===`mouse`&&g(!1)},ref:T,children:[U?z(`div`,{className:`lockerverse-auction-gallery__stage`,onPointerEnter:V,onPointerLeave:B,onPointerMove:V,children:[R(`div`,{className:`lockerverse-auction-gallery__viewport`,onPointerDownCapture:()=>{q(),S(!0)},ref:G,children:R(`div`,{className:`lockerverse-auction-gallery__track`,children:e.map((e,r)=>R(`div`,{"aria-hidden":r!==W,className:`lockerverse-auction-gallery__slide`,children:R(`button`,{"aria-label":`View photo ${r+1} of ${t} at full size`,className:`lockerverse-auction-gallery__photo`,onClick:()=>{c(r)},ref:r===W?o:void 0,tabIndex:r===W?0:-1,type:`button`,children:R(l,{alt:`${t}, ${r+1} of ${U}`,className:`lockerverse-auction-gallery__image`,draggable:!1,fetchPriority:r===0?`high`:`auto`,height:900,loading:r===W?`eager`:`lazy`,maxWidth:1280,sizes:r===W?n:`auto, ${n}`,src:e,width:1200})})},`${e}-${r}`))})}),U>1&&!p&&z(`div`,{className:`lockerverse-auction-gallery__rotation`,children:[R(`div`,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__progress-track`,children:R(`div`,{className:`lockerverse-auction-gallery__progress`,ref:te,style:{transform:`scaleX(0)`}})}),R(`button`,{"aria-label":y?`Play photo rotation`:`Pause photo rotation`,className:`lockerverse-auction-gallery__play ${P}`,"data-gallery-control":!0,onClick:()=>b(e=>!e),title:y?`Play photo rotation`:`Pause photo rotation`,type:`button`,children:R(y?D:ee,{"aria-hidden":`true`,size:13})})]}),U>1&&z(L,{children:[R(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__previous ${P}`,"data-gallery-control":!0,onClick:()=>Y(W-1),type:`button`,children:R(C,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})}),R(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__next ${P}`,"data-gallery-control":!0,onClick:()=>Y(W+1),type:`button`,children:R(w,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})})]})]}):R(`div`,{className:`lockerverse-auction-gallery__empty`,children:`No photo available`}),U>1&&R(`section`,{"aria-label":`Choose a photo`,className:`lockerverse-auction-gallery__strip`,ref:u,children:R(`div`,{className:`lockerverse-auction-gallery__thumbnails`,children:e.map((e,t)=>R(`button`,{"aria-label":`Show photo ${t+1} of ${U}`,"aria-pressed":W===t,className:`lockerverse-auction-gallery__thumbnail ${W===t?`is-selected`:``}`,onClick:()=>Y(t),ref:e=>{f.current[t]=e},type:`button`,children:R(l,{alt:``,className:`lockerverse-auction-gallery__thumbnail-image`,height:66,loading:`lazy`,maxWidth:192,sizes:`88px`,src:e,width:88})},`${e}-${t}`))})})]})}function fe({images:e,fallbackImage:t,name:n,imageSizes:r}){let i=[...new Set(e.filter(Boolean))];!i.length&&t&&i.push(t);let[a,o]=I(0),[s,c]=I(!1),u=F(null),d=F(null),f=i.length,p=f?(a%f+f)%f:0;return z(L,{children:[R(de,{imageSizes:r,name:n,onExpand:e=>{o(e),c(!0)},onSelect:o,paused:s,photoButtonRef:u,photos:i,selected:p}),f>0&&R(q.Root,{onOpenChange:c,open:s,children:z(q.Portal,{children:[R(q.Backdrop,{className:`lockerverse-auction-gallery__backdrop`}),z(q.Popup,{"aria-describedby":void 0,className:`lockerverse-auction-gallery__viewer`,finalFocus:u,onKeyDown:e=>{f<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),o((p+(e.key===`ArrowRight`?1:-1)+f)%f))},children:[z(q.Title,{className:`lockerverse-auction-gallery__sr-only`,children:[n,` · Photo `,p+1,` of `,f]}),z(`div`,{className:`lockerverse-auction-gallery__full-image`,onTouchCancel:()=>{d.current=null},onTouchEnd:e=>{let t=d.current;d.current=null;let n=e.changedTouches.item(0);if(!(t&&n)||f<2)return;let r=n.clientX-t.x,i=n.clientY-t.y;Math.abs(r)>=45&&Math.abs(r)>Math.abs(i)*1.3&&o((p+(r<0?1:-1)+f)%f)},onTouchMove:e=>{e.touches.length!==1&&(d.current=null)},onTouchStart:e=>{let t=e.touches.item(0);d.current=e.touches.length===1&&t?{x:t.clientX,y:t.clientY}:null},children:[R(l,{alt:`${n}, ${p+1} of ${f}`,height:900,maxWidth:1920,sizes:`100vw`,src:i[p],width:1200}),s&&f>1&&R(l,{alt:``,"aria-hidden":`true`,className:`lockerverse-auction-gallery__preload`,height:900,loading:`eager`,maxWidth:1920,sizes:`100vw`,src:i[(p+1)%f],width:1200})]}),R(q.Close,{"aria-label":`Close photo viewer`,className:`lockerverse-auction-gallery__viewer-close`,children:R(A,{"aria-hidden":`true`,size:22})}),f>1&&z(L,{children:[R(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__viewer-previous`,onClick:()=>o((p-1+f)%f),type:`button`,children:R(C,{"aria-hidden":`true`,size:28})}),R(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__viewer-next`,onClick:()=>o((p+1)%f),type:`button`,children:R(w,{"aria-hidden":`true`,size:28})})]})]})]})})]})}const pe={1:`h1`,2:`h2`};function me(e){return R(e===`Buy Now`?O:e===`Available`||e===`Increment`?k:E,{"aria-hidden":`true`,size:16})}function he(e,t){return e.saleMode===`buy_now`?[[`Buy Now`,n(e.buyNowPriceAmount??0)],[`Available`,e.availableQuantity===null?`Available`:String(e.availableQuantity)]]:t===`finished`?[[`Final bid`,e.maxBidAmount?n(e.maxBidAmount):`No bids`]]:[[`Current bid`,n(e.maxBidAmount??0)],[`Floor`,n(e.minBidAmount??0)],[`Increment`,n(e.bidIncrementAmount??100)]]}function ge({auction:r,item:i,itemHeadingLevel:o=2,galleryImageSizes:c}){s(i.startAt??r.startAt,i.endAt??r.endAt);let[l,u]=I(!1),d=N(),f=e(r,i),p={active:`Closes`,draft:`Opens`,finished:`Closed`}[f],m=a(r,f,i),h=i.saleMode===`buy_now`,g=(i.description??``).trim().length>240,_=he(i,f),v=pe[o];return z(`section`,{className:`lockerverse-auctions__item-summary`,children:[R(fe,{fallbackImage:i.image??r.configuration.image??r.community?.banner??r.community?.thumbnail??null,imageSizes:c,images:i.images,name:i.name}),z(`div`,{className:`lockerverse-auctions__item-copy`,children:[R(v,{children:i.name}),i.description?z(`div`,{className:`lockerverse-auctions__item-description`,children:[R(t,{className:!l&&g?`lockerverse-auctions__description-clamped`:void 0,description:i.description,id:d}),g?z(`button`,{"aria-controls":d,"aria-expanded":l,className:`lockerverse-auctions__description-toggle`,onClick:()=>u(!l),type:`button`,children:[l?`Hide description`:`Read full description`,` `,R(S,{"aria-hidden":`true`,size:16,style:{transform:l?`rotate(180deg)`:void 0}})]}):null]}):null,z(`dl`,{className:`lockerverse-auctions__stat-panel`,children:[_.map(([e,t])=>z(`div`,{className:`lockerverse-auctions__stat-row`,children:[z(`dt`,{children:[me(e),e]}),R(`dd`,{children:t})]},e)),z(`div`,{className:`lockerverse-auctions__stat-row`,children:[z(`dt`,{children:[R(T,{"aria-hidden":`true`,size:16}),p]}),R(`dd`,{className:`lockerverse-auctions__stat-date`,children:m})]}),!h&&f===`finished`?z(`div`,{className:`lockerverse-auctions__stat-footer`,children:[z(`div`,{children:[R(`dt`,{children:`Floor`}),R(`dd`,{children:n(i.minBidAmount??0)})]}),z(`div`,{children:[R(`dt`,{children:`Bid increment`}),R(`dd`,{children:n(i.bidIncrementAmount??100)})]})]}):null]})]})]})}const _e={1:`h2`,2:`h3`},ve=/^\d+$/;function ye(e,t){return ve.test(e)&&Number.isSafeInteger(Number(e)*t)?`Total: ${n(Number(e)*t)}`:`Enter a whole-number quantity.`}function be(e,t,n){return String(e?t?t.quantity:1:t?t.amount/100:n)}function xe(e,t){return o(e)?`This item is sold out.`:t===`draft`?`This item is not open yet.`:t===`finished`?e.saleMode===`buy_now`?`Purchases are closed for this item.`:`Bidding is closed for this item.`:`This item is not available.`}function Se(e,t,n){return o(t)?`All available quantities have been purchased.`:n===`draft`?`This item opens ${a(e,`draft`,t)}.`:t.saleMode===`buy_now`?`This item is no longer available to purchase.`:`Bidding has closed for this item.`}function Ce(e,t,n,r){return{amount:t?0:Number(r)*100,includeServiceFee:n?n.includeServiceFee:e.serviceFeeEnabled&&e.serviceFeeDefaultChecked,quantity:t?Number(r):1}}function we({auction:t,item:i,initialSelection:a,onContinue:c,onError:l,onBack:u,backHref:d,itemHeadingLevel:f=2}){let p=_e[f],m=i.saleMode===`buy_now`,h=Math.ceil(H(i)/100),[g,_]=I(be(m,a,h)),[v,y]=I(null),b=N();s(i.startAt??t.startAt,i.endAt??t.endAt);let S=e(t,i),C=S===`active`&&!o(i)&&i.saleMode!==`hybrid`;function w(e){if(e.preventDefault(),!ve.test(g)){y(m?`Enter a whole-number quantity.`:`Enter a whole-dollar bid amount.`);return}let n=Ce(t,m,a,g),r=ie(t,i,n);if(r){y(r),l(r);return}try{Z(t,i,n)}catch{y(`Enter a valid amount or quantity.`);return}c(n)}return C?z(`form`,{className:`lockerverse-auctions__selection`,onSubmit:w,children:[R(Te,{buyNow:m,headingTag:p,item:i,minimum:h}),z(`div`,{className:`lockerverse-auctions__selection-body`,children:[z(`label`,{className:`lockerverse-auctions__field`,htmlFor:b,children:[m?`Quantity`:`Your bid amount`,z(`span`,{className:`lockerverse-auctions__amount-control`,children:[m?null:R(`span`,{"aria-hidden":`true`,children:`$`}),R(`input`,{"aria-describedby":`${b}-help`,"aria-invalid":!!v,autoComplete:`off`,id:b,inputMode:`numeric`,onChange:e=>{_(e.target.value),y(null)},placeholder:m?`1`:String(h),required:!0,value:g})]})]}),v?R(`p`,{role:`alert`,children:v}):null,R(`p`,{id:`${b}-help`,children:m?ye(g,i.buyNowPriceAmount??0):`Enter a whole-dollar bid of at least ${n(h*100)}. Bid increment: ${n(i.bidIncrementAmount??100)}.`}),z(`div`,{className:`lockerverse-auctions__selection-footer`,children:[R(`p`,{children:m?`Continuing moves you into secure checkout where your payment is processed immediately.`:`Continuing moves you into the secure payment step where your card is stored for settlement only if your bid wins.`}),z(`button`,{className:`lockerverse-auctions__button`,disabled:!t.payment,type:`submit`,children:[m?`Continue to Checkout`:`Continue to Payment`,` `,R(x,{"aria-hidden":`true`,size:16})]})]}),t.payment?null:R(`p`,{role:`alert`,children:`Payments are not configured for this auction.`})]})]}):z(`div`,{className:`lockerverse-auctions__selection lockerverse-auctions__read-only`,children:[R(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Item status`}),R(p,{children:xe(i,S)}),R(`p`,{children:Se(t,i,S)}),z(r,{className:`lockerverse-auctions__button`,href:d,onBack:u,children:[`Browse auction items `,R(x,{"aria-hidden":`true`,size:16})]})]})}function Te({headingTag:e,item:t,buyNow:r,minimum:i}){return z(`div`,{className:`lockerverse-auctions__selection-header`,children:[R(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Step 1 of 2`}),R(e,{children:r?`Buy this item now.`:`Place your bid.`}),R(`p`,{children:r?`Choose how many you want, then complete the secure checkout.`:`Enter the bid amount you want to place for this item. You are only charged if this bid wins after bidding closes.`}),z(`p`,{children:[r?`Price: `:`Minimum qualifying bid: `,R(`strong`,{children:n(r?t.buyNowPriceAmount??0:i*100)})]}),r&&t.availableQuantity!==null?z(`p`,{children:[t.availableQuantity,` available`]}):null,t.collectShippingAddress?R(`p`,{children:`The next step will also collect a delivery address for seller fulfillment.`}):null]})}function Ee(e){let{auction:t,item:n,selection:r,theme:i=`dark`,stripeLoader:a=y,style:o,onBack:s,resumePurchase:c}=e,[l,u]=I(null),[d,f]=I(!1),[p,m]=I(0),h=v(e.appearanceRoot,i,o,e.interactionLocked),g=c?.payment??t.payment;if(M(()=>{let e=!0;if(!g){f(!0);return}return Promise.resolve().then(()=>a(g.publishableKey,g.connectedAccountId?{stripeAccount:g.connectedAccountId}:void 0)).then(t=>{e&&(u(t),f(!t))},()=>{e&&f(!0)}),()=>{e=!1}},[g,a,p]),d)return z(`div`,{children:[R(`p`,{role:`alert`,children:`Payment details could not load.`}),c?null:R(`button`,{onClick:s,type:`button`,children:`Back to item`}),R(`button`,{onClick:()=>{f(!1),u(null),m(e=>e+1)},type:`button`,children:`Try again`})]});if(!(l&&h))return z(`div`,{children:[R(`p`,{role:`status`,children:`Loading secure payment details…`}),c?null:R(`button`,{onClick:s,type:`button`,children:`Back to item`})]});let _={mode:`setup`,setupFutureUsage:`off_session`};c?_={amount:c.pricing.totalCents,currency:`usd`,mode:`payment`}:n.saleMode===`buy_now`&&(_={amount:Z(t,n,r).totalCents,currency:`usd`,mode:`payment`});let b={..._,appearance:h,currency:`usd`,paymentMethodTypes:[`card`],syncAddressCheckbox:`none`};return R(W,{options:b,stripe:l,children:R(Q,{...e})})}function De({buyNow:e}){return z(`div`,{className:`lockerverse-auctions__progress`,children:[z(`span`,{children:[R(e?O:E,{"aria-hidden":`true`,size:16}),e?`Choose quantity`:`Place bid`]}),z(`span`,{children:[R(O,{"aria-hidden":`true`,size:16}),e?`Pay securely`:`Secure card`]}),z(`span`,{children:[R(k,{"aria-hidden":`true`,size:16}),e?`Get confirmation`:`Wait for close`]})]})}function Oe(e){let{auction:t,item:n,outcome:r}=e,i;return e.backHref?i={href:e.backHref,label:`View auction items`}:e.onBack&&(i={label:`View auction items`,onClick:e.onBack}),R(b,{auctionName:t.name,className:e.className,closesAtLabel:a(t,`active`,n),communityName:e.communityName??t.community?.name,focusHeading:!0,imageUrl:n.image??n.images[0]??t.configuration.image??void 0,itemName:n.name,outcome:r,primaryAction:e.returnToItemHref?{href:e.returnToItemHref,label:`Return to item`}:i,secondaryAction:e.returnToItemHref?i:void 0,style:{"--lockerverse-accent":t.community?.color??`#6f8f6d`,...e.style},theme:e.theme})}function ke(t){let{auction:n,itemId:i,resumePurchase:a,className:o,theme:c=`dark`,style:l}=t,u=F(null),[d,f]=I(n),p=F(n),m=d.items.find(e=>e.id===i)??a?.item;s(m?.startAt??d.startAt,m?.endAt??d.endAt);let[h,_]=I(()=>a?{amount:0,includeServiceFee:a.submission.includeServiceFee??!1,quantity:a.submission.quantity}:null),[v,y]=I(!!a),b=F(!0),S=F(t);S.current=t;let w=F(null),T=j(e=>{b.current&&y(e),w.current!==e&&(w.current=e,g(S.current.onInteractionLockChange,e))},[]),E=!!a;M(()=>(b.current=!0,T(E),()=>{b.current=!1}),[E,T]);let[ee,D]=I({email:``,phone:``}),[O,k]=I(!!a),[A,N]=I(null),[P,L]=I(null);M(()=>{!(O||v||a)&&p.current!==n&&(p.current=n,f(n))},[n,O,v,a]);function B(e,t){T(!1),p.current=S.current.auction,f(e),_(null),k(!1),N(t)}function V(e){N(null),_(e),k(!0)}return m?P?R(Oe,{...t,auction:d,item:m,outcome:P}):z(`section`,{className:[`lockerverse-auctions`,o].filter(Boolean).join(` `),"data-lockerverse-theme":c,ref:u,style:{"--lockerverse-accent":d.community?.color??`#6f8f6d`,...l},children:[v?null:z(r,{className:`lockerverse-auctions__back`,href:t.backHref,onBack:t.onBack,children:[R(C,{"aria-hidden":`true`,size:16}),` All items`]}),z(`div`,{className:`lockerverse-auctions__detail`,children:[R(ge,{auction:d,galleryImageSizes:t.galleryImageSizes,item:m,itemHeadingLevel:t.itemHeadingLevel}),z(`div`,{className:`lockerverse-auctions__transaction`,children:[e(d,m)===`active`?R(De,{buyNow:m.saleMode===`buy_now`}):null,A?R(`p`,{className:`lockerverse-auctions__notice`,role:`alert`,children:A}):null,O&&h?R(Ee,{...t,appearanceRoot:u,auction:d,communityName:t.communityName??d.community?.name,contact:ee,interactionLocked:v,item:m,onBack:()=>k(!1),onContactChange:D,onIncludeServiceFeeChange:e=>_(t=>t&&{...t,includeServiceFee:d.serviceFeeEnabled&&e}),onInteractionLockChange:T,onResult:L,onReview:B,selection:h}):R(we,{auction:d,backHref:t.backHref,initialSelection:h,item:m,itemHeadingLevel:t.itemHeadingLevel,onBack:t.onBack,onContinue:V,onError:N}),v?null:z(r,{className:`lockerverse-auctions__footer-back`,href:t.backHref,onBack:t.onBack,children:[`Back to auction items `,R(x,{"aria-hidden":`true`,size:16})]})]})]})]}):z(`div`,{children:[R(`p`,{role:`alert`,children:`This auction item is no longer available.`}),R(r,{href:t.backHref,onBack:t.onBack,children:`Back to auction items`})]})}function Ae(e){let t=F({auctionId:e.auction.id,client:e.client,itemId:e.itemId});if(t.current.client!==e.client||t.current.auctionId!==e.auction.id||t.current.itemId!==e.itemId)throw TypeError(`Auction item identity cannot change. Remount with a new React key.`);if(e.resumePurchase&&(e.resumePurchase.auctionId!==e.auction.id||e.resumePurchase.itemId!==e.itemId||e.resumePurchase.item.id!==e.itemId||e.resumePurchase.item.auctionId!==e.auction.id))throw TypeError(`The purchase recovery record belongs to a different auction item.`);return R(c.Provider,{value:e.auction.mediaBaseUrl,children:R(ke,{...e})})}export{Ae as LockerverseAuctionItem};
1
+ import{a as e,c as t,i as n,l as r,n as i,r as a,s as o,t as s}from"./use-auction-boundary.js";import{n as c,t as l}from"./auction-image.js";import{a as u,i as d}from"./auction-payment.js";import{t as f}from"./auction-result2.js";import{t as p}from"./host-callback.js";import{ArrowRight as m,ChevronDown as h,ChevronLeft as g,ChevronRight as _,Clock3 as v,Gavel as y,Pause as b,Play as x,ShieldCheck as S,TimerReset as C,X as w}from"lucide-react";import{useCallback as T,useEffect as E,useId as D,useMemo as O,useRef as k,useState as A}from"react";import{Fragment as j,jsx as M,jsxs as N}from"react/jsx-runtime";import{getLockerverseAuctionMinimumBid as P}from"@lockerverse/sdk/auctions";import{Dialog as F}from"@base-ui/react/dialog";import I from"embla-carousel-autoplay";import L from"embla-carousel-react";const R=6e3;function z(e,t){let n=k(R),r=k(null),[i,a]=A(R),o=O(()=>I({delay:i,playOnInit:!1,stopOnFocusIn:!1,stopOnInteraction:!0,stopOnMouseEnter:!1}),[i]),[s,c]=L({duration:t?0:25,loop:!0},[o]),l=T(()=>{r.current&&(r.current.style.transform=`scaleX(${1-n.current/R})`)},[]),u=T(()=>{let e=o.timeUntilNext();e!==null&&(n.current=Math.max(1,Math.min(R,e))),o.stop(),l()},[o,l]),d=T(()=>{n.current=R,a(R),o.reset(),l()},[o,l]);return E(()=>{c&&(e?i===n.current?o.play():a(n.current):u())},[c,e,o,i,a,n,u]),E(()=>{if(!c)return;let t=0,r=()=>{let i=o.timeUntilNext();!e||i===null||(n.current=Math.max(0,Math.min(R,i)),l(),t=requestAnimationFrame(r))},i=()=>{cancelAnimationFrame(t),e&&(t=requestAnimationFrame(r))},a=()=>cancelAnimationFrame(t),s=()=>{e&&o.play()};return c.on(`select`,d).on(`reInit`,s).on(`autoplay:timerset`,i).on(`autoplay:timerstopped`,a),l(),i(),()=>{a(),c.off(`select`,d).off(`reInit`,s).off(`autoplay:timerset`,i).off(`autoplay:timerstopped`,a)}},[c,o,e,n,d,l]),{embla:c,freeze:u,progressRef:r,reset:d,viewportRef:s}}function B({photos:e,name:t,imageSizes:n=`(max-width: 1279px) 100vw, 45vw`,selected:r,paused:a=!1,photoButtonRef:o,onSelect:s,onExpand:c}){let u=k(null),d=k(null),f=k([]),[p,m]=A(!0),[h,v]=A(!1),[y,S]=A(!1),[C,w]=A(!1),[T,D]=A(!1),{ref:O,visible:P}=i(),[F,I]=A(!1),[L,R]=A(!0),B=k(null),V=`lockerverse-auction-gallery__control ${L||F||y?`is-visible`:``}`,H=()=>{B.current&&clearTimeout(B.current),B.current=setTimeout(()=>I(!1),2e3)},U=e=>{if(e.pointerType!==`mouse`){R(!0);return}I(!0),B.current&&clearTimeout(B.current),e.target instanceof Element&&e.target.closest(`[data-gallery-control]`)||H()};E(()=>{let e=window.matchMedia(`(hover: none), (pointer: coarse)`),t=()=>R(e.matches);return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),clearTimeout(B.current??void 0)}},[]);let W=!(a||p||h||y||C||T)&&P,G=e.length,K=G?(r%G+G)%G:0,{viewportRef:q,embla:J,progressRef:Y,freeze:X,reset:Z}=z(W&&G>1,p);E(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>m(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),E(()=>{if(!J)return;let e=()=>s(J.selectedScrollSnap());return J.on(`select`,e).on(`reInit`,e),()=>{J.off(`select`,e).off(`reInit`,e)}},[J,s]),E(()=>{J&&J.selectedScrollSnap()!==K&&J.scrollTo(K,!0)},[J,K]),E(()=>{let e=()=>{document.hidden&&X()},t=()=>D(!1);return e(),document.addEventListener(`visibilitychange`,e,!0),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{document.removeEventListener(`visibilitychange`,e,!0),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[X]);let Q=e=>{J?.scrollTo((e+G)%G,p),Z()};return E(()=>{let e=d.current;d.current=null,e&&document.activeElement===e&&O.current?.querySelector(`.lockerverse-auction-gallery__photo[tabindex="0"]`)?.focus({preventScroll:!0})},[K,O]),E(()=>{let e=u.current,t=f.current[K];if(!(e&&t))return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();r.left<n.left?e.scrollLeft-=n.left-r.left:r.right>n.right&&(e.scrollLeft+=r.right-n.right)},[K,G]),N(`section`,{"aria-label":`${t} photos`,className:`lockerverse-auction-gallery`,onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||S(!1)},onFocusCapture:e=>S(e.target.matches(`:focus-visible`)),onKeyDown:e=>{G<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),e.target instanceof HTMLButtonElement&&e.target.classList.contains(`lockerverse-auction-gallery__photo`)&&(d.current=e.target),Q(K+(e.key===`ArrowRight`?1:-1)))},onPointerEnter:e=>{e.pointerType===`mouse`&&v(!0)},onPointerLeave:e=>{e.pointerType===`mouse`&&v(!1)},ref:O,children:[G?N(`div`,{className:`lockerverse-auction-gallery__stage`,onPointerEnter:U,onPointerLeave:H,onPointerMove:U,children:[M(`div`,{className:`lockerverse-auction-gallery__viewport`,onPointerDownCapture:()=>{X(),D(!0)},ref:q,children:M(`div`,{className:`lockerverse-auction-gallery__track`,children:e.map((e,r)=>M(`div`,{"aria-hidden":r!==K,className:`lockerverse-auction-gallery__slide`,children:M(`button`,{"aria-label":`View photo ${r+1} of ${t} at full size`,className:`lockerverse-auction-gallery__photo`,onClick:()=>{c(r)},ref:r===K?o:void 0,tabIndex:r===K?0:-1,type:`button`,children:M(l,{alt:`${t}, ${r+1} of ${G}`,className:`lockerverse-auction-gallery__image`,draggable:!1,fetchPriority:r===0?`high`:`auto`,height:900,loading:r===K?`eager`:`lazy`,maxWidth:1280,sizes:r===K?n:`auto, ${n}`,src:e,width:1200})})},`${e}-${r}`))})}),G>1&&!p&&N(`div`,{className:`lockerverse-auction-gallery__rotation`,children:[M(`div`,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__progress-track`,children:M(`div`,{className:`lockerverse-auction-gallery__progress`,ref:Y,style:{transform:`scaleX(0)`}})}),M(`button`,{"aria-label":C?`Play photo rotation`:`Pause photo rotation`,className:`lockerverse-auction-gallery__play ${V}`,"data-gallery-control":!0,onClick:()=>w(e=>!e),title:C?`Play photo rotation`:`Pause photo rotation`,type:`button`,children:M(C?x:b,{"aria-hidden":`true`,size:13})})]}),G>1&&N(j,{children:[M(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__previous ${V}`,"data-gallery-control":!0,onClick:()=>Q(K-1),type:`button`,children:M(g,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})}),M(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__next ${V}`,"data-gallery-control":!0,onClick:()=>Q(K+1),type:`button`,children:M(_,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})})]})]}):M(`div`,{className:`lockerverse-auction-gallery__empty`,children:`No photo available`}),G>1&&M(`section`,{"aria-label":`Choose a photo`,className:`lockerverse-auction-gallery__strip`,ref:u,children:M(`div`,{className:`lockerverse-auction-gallery__thumbnails`,children:e.map((e,t)=>M(`button`,{"aria-label":`Show photo ${t+1} of ${G}`,"aria-pressed":K===t,className:`lockerverse-auction-gallery__thumbnail ${K===t?`is-selected`:``}`,onClick:()=>Q(t),ref:e=>{f.current[t]=e},type:`button`,children:M(l,{alt:``,className:`lockerverse-auction-gallery__thumbnail-image`,height:66,loading:`lazy`,maxWidth:192,sizes:`88px`,src:e,width:88})},`${e}-${t}`))})})]})}function V({images:e,fallbackImage:t,name:n,imageSizes:r}){let i=[...new Set(e.filter(Boolean))];!i.length&&t&&i.push(t);let[a,o]=A(0),[s,c]=A(!1),u=k(null),d=k(null),f=i.length,p=f?(a%f+f)%f:0;return N(j,{children:[M(B,{imageSizes:r,name:n,onExpand:e=>{o(e),c(!0)},onSelect:o,paused:s,photoButtonRef:u,photos:i,selected:p}),f>0&&M(F.Root,{onOpenChange:c,open:s,children:N(F.Portal,{children:[M(F.Backdrop,{className:`lockerverse-auction-gallery__backdrop`}),N(F.Popup,{"aria-describedby":void 0,className:`lockerverse-auction-gallery__viewer`,finalFocus:u,onKeyDown:e=>{f<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),o((p+(e.key===`ArrowRight`?1:-1)+f)%f))},children:[N(F.Title,{className:`lockerverse-auction-gallery__sr-only`,children:[n,` · Photo `,p+1,` of `,f]}),N(`div`,{className:`lockerverse-auction-gallery__full-image`,onTouchCancel:()=>{d.current=null},onTouchEnd:e=>{let t=d.current;d.current=null;let n=e.changedTouches.item(0);if(!(t&&n)||f<2)return;let r=n.clientX-t.x,i=n.clientY-t.y;Math.abs(r)>=45&&Math.abs(r)>Math.abs(i)*1.3&&o((p+(r<0?1:-1)+f)%f)},onTouchMove:e=>{e.touches.length!==1&&(d.current=null)},onTouchStart:e=>{let t=e.touches.item(0);d.current=e.touches.length===1&&t?{x:t.clientX,y:t.clientY}:null},children:[M(l,{alt:`${n}, ${p+1} of ${f}`,height:900,maxWidth:1920,sizes:`100vw`,src:i[p],width:1200}),s&&f>1&&M(l,{alt:``,"aria-hidden":`true`,className:`lockerverse-auction-gallery__preload`,height:900,loading:`eager`,maxWidth:1920,sizes:`100vw`,src:i[(p+1)%f],width:1200})]}),M(F.Close,{"aria-label":`Close photo viewer`,className:`lockerverse-auction-gallery__viewer-close`,children:M(w,{"aria-hidden":`true`,size:22})}),f>1&&N(j,{children:[M(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__viewer-previous`,onClick:()=>o((p-1+f)%f),type:`button`,children:M(g,{"aria-hidden":`true`,size:28})}),M(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__viewer-next`,onClick:()=>o((p+1)%f),type:`button`,children:M(_,{"aria-hidden":`true`,size:28})})]})]})]})})]})}const H={1:`h1`,2:`h2`};function U(e){return M(e===`Buy Now`?S:e===`Available`||e===`Increment`?C:y,{"aria-hidden":`true`,size:16})}function W(e,t){return e.saleMode===`buy_now`?[[`Buy Now`,n(e.buyNowPriceAmount??0)],[`Available`,e.availableQuantity===null?`Available`:String(e.availableQuantity)]]:t===`finished`?[[`Final bid`,e.maxBidAmount?n(e.maxBidAmount):`No bids`]]:[[`Current bid`,n(e.maxBidAmount??0)],[`Floor`,n(e.minBidAmount??0)],[`Increment`,n(e.bidIncrementAmount??100)]]}function G({auction:r,item:i,itemHeadingLevel:o=2,galleryImageSizes:c}){s(i.startAt??r.startAt,i.endAt??r.endAt);let[l,u]=A(!1),d=D(),f=e(r,i),p={active:`Closes`,draft:`Opens`,finished:`Closed`}[f],m=a(r,f,i),g=i.saleMode===`buy_now`,_=(i.description??``).trim().length>240,y=W(i,f),b=H[o];return N(`section`,{className:`lockerverse-auctions__item-summary`,children:[M(V,{fallbackImage:i.image??r.configuration.image??r.community?.banner??r.community?.thumbnail??null,imageSizes:c,images:i.images,name:i.name}),N(`div`,{className:`lockerverse-auctions__item-copy`,children:[M(b,{children:i.name}),i.description?N(`div`,{className:`lockerverse-auctions__item-description`,children:[M(t,{className:!l&&_?`lockerverse-auctions__description-clamped`:void 0,description:i.description,id:d}),_?N(`button`,{"aria-controls":d,"aria-expanded":l,className:`lockerverse-auctions__description-toggle`,onClick:()=>u(!l),type:`button`,children:[l?`Hide description`:`Read full description`,` `,M(h,{"aria-hidden":`true`,size:16,style:{transform:l?`rotate(180deg)`:void 0}})]}):null]}):null,N(`dl`,{className:`lockerverse-auctions__stat-panel`,children:[y.map(([e,t])=>N(`div`,{className:`lockerverse-auctions__stat-row`,children:[N(`dt`,{children:[U(e),e]}),M(`dd`,{children:t})]},e)),N(`div`,{className:`lockerverse-auctions__stat-row`,children:[N(`dt`,{children:[M(v,{"aria-hidden":`true`,size:16}),p]}),M(`dd`,{className:`lockerverse-auctions__stat-date`,children:m})]}),!g&&f===`finished`?N(`div`,{className:`lockerverse-auctions__stat-footer`,children:[N(`div`,{children:[M(`dt`,{children:`Floor`}),M(`dd`,{children:n(i.minBidAmount??0)})]}),N(`div`,{children:[M(`dt`,{children:`Bid increment`}),M(`dd`,{children:n(i.bidIncrementAmount??100)})]})]}):null]})]})]})}const K={1:`h2`,2:`h3`},q=/^\d+$/;function J(e,t){return q.test(e)&&Number.isSafeInteger(Number(e)*t)?`Total: ${n(Number(e)*t)}`:`Enter a whole-number quantity.`}function Y(e,t,n){return String(e?t?t.quantity:1:t?t.amount/100:n)}function X(e,t){return o(e)?`This item is sold out.`:t===`draft`?`This item is not open yet.`:t===`finished`?e.saleMode===`buy_now`?`Purchases are closed for this item.`:`Bidding is closed for this item.`:`This item is not available.`}function Z(e,t,n){return o(t)?`All available quantities have been purchased.`:n===`draft`?`This item opens ${a(e,`draft`,t)}.`:t.saleMode===`buy_now`?`This item is no longer available to purchase.`:`Bidding has closed for this item.`}function Q(e,t,n,r){return{amount:t?0:Number(r)*100,includeServiceFee:n?n.includeServiceFee:e.serviceFeeEnabled&&e.serviceFeeDefaultChecked,quantity:t?Number(r):1}}function $({auction:t,item:i,initialSelection:a,onContinue:c,onError:l,onBack:f,backHref:p,itemHeadingLevel:h=2}){let g=K[h],_=i.saleMode===`buy_now`,v=Math.ceil(P(i)/100),[y,b]=A(Y(_,a,v)),[x,S]=A(null),C=D();s(i.startAt??t.startAt,i.endAt??t.endAt);let w=e(t,i),T=w===`active`&&!o(i)&&i.saleMode!==`hybrid`;function E(e){if(e.preventDefault(),!q.test(y)){S(_?`Enter a whole-number quantity.`:`Enter a whole-dollar bid amount.`);return}let n=Q(t,_,a,y),r=d(t,i,n);if(r){S(r),l(r);return}try{u(t,i,n)}catch{S(`Enter a valid amount or quantity.`);return}c(n)}return T?N(`form`,{className:`lockerverse-auctions__selection`,onSubmit:E,children:[M(ee,{buyNow:_,headingTag:g,item:i,minimum:v}),N(`div`,{className:`lockerverse-auctions__selection-body`,children:[N(`label`,{className:`lockerverse-auctions__field`,htmlFor:C,children:[_?`Quantity`:`Your bid amount`,N(`span`,{className:`lockerverse-auctions__amount-control`,children:[_?null:M(`span`,{"aria-hidden":`true`,children:`$`}),M(`input`,{"aria-describedby":`${C}-help`,"aria-invalid":!!x,autoComplete:`off`,id:C,inputMode:`numeric`,onChange:e=>{b(e.target.value),S(null)},placeholder:_?`1`:String(v),required:!0,value:y})]})]}),x?M(`p`,{role:`alert`,children:x}):null,M(`p`,{id:`${C}-help`,children:_?J(y,i.buyNowPriceAmount??0):`Enter a whole-dollar bid of at least ${n(v*100)}. Bid increment: ${n(i.bidIncrementAmount??100)}.`}),N(`div`,{className:`lockerverse-auctions__selection-footer`,children:[M(`p`,{children:_?`Continuing moves you into secure checkout where your payment is processed immediately.`:`Continuing moves you into the secure payment step where your card is stored for settlement only if your bid wins.`}),N(`button`,{className:`lockerverse-auctions__button`,disabled:!t.payment,type:`submit`,children:[_?`Continue to Checkout`:`Continue to Payment`,` `,M(m,{"aria-hidden":`true`,size:16})]})]}),t.payment?null:M(`p`,{role:`alert`,children:`Payments are not configured for this auction.`})]})]}):N(`div`,{className:`lockerverse-auctions__selection lockerverse-auctions__read-only`,children:[M(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Item status`}),M(g,{children:X(i,w)}),M(`p`,{children:Z(t,i,w)}),N(r,{className:`lockerverse-auctions__button`,href:p,onBack:f,children:[`Browse auction items `,M(m,{"aria-hidden":`true`,size:16})]})]})}function ee({headingTag:e,item:t,buyNow:r,minimum:i}){return N(`div`,{className:`lockerverse-auctions__selection-header`,children:[M(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Step 1 of 2`}),M(e,{children:r?`Buy this item now.`:`Place your bid.`}),M(`p`,{children:r?`Choose how many you want, then complete the secure checkout.`:`Enter the bid amount you want to place for this item. You are only charged if this bid wins after bidding closes.`}),N(`p`,{children:[r?`Price: `:`Minimum qualifying bid: `,M(`strong`,{children:n(r?t.buyNowPriceAmount??0:i*100)})]}),r&&t.availableQuantity!==null?N(`p`,{children:[t.availableQuantity,` available`]}):null,t.collectShippingAddress?M(`p`,{children:`The next step will also collect a delivery address for seller fulfillment.`}):null]})}function te(e){let[t,n]=A(null),[r,i]=A(!1),a=!!(e.resumePurchase||e.interactionLocked);return E(()=>{let e=!0;return import(`./auction-payment-view.js`).then(({AuctionPayment:t})=>{e&&n(()=>t)},()=>{e&&i(!0)}),()=>{e=!1}},[]),t?M(t,{...e}):N(`div`,{children:[M(`p`,{role:r?`alert`:`status`,children:r?`Payment details could not load.`:`Loading secure payment details…`}),r&&a&&M(`p`,{children:`Your purchase status is not confirmed. Keep this page open and contact the auction organizer before you try another purchase.`}),a?null:M(`button`,{onClick:e.onBack,type:`button`,children:`Back to item`}),r&&!a&&M(`button`,{onClick:()=>window.location.reload(),type:`button`,children:`Reload page to try again`})]})}function ne({buyNow:e}){return N(`div`,{className:`lockerverse-auctions__progress`,children:[N(`span`,{children:[M(e?S:y,{"aria-hidden":`true`,size:16}),e?`Choose quantity`:`Place bid`]}),N(`span`,{children:[M(S,{"aria-hidden":`true`,size:16}),e?`Pay securely`:`Secure card`]}),N(`span`,{children:[M(C,{"aria-hidden":`true`,size:16}),e?`Get confirmation`:`Wait for close`]})]})}function re(e){let{auction:t,item:n,outcome:r}=e,i;return e.backHref?i={href:e.backHref,label:`View auction items`}:e.onBack&&(i={label:`View auction items`,onClick:e.onBack}),M(f,{auctionName:t.name,className:e.className,closesAtLabel:a(t,`active`,n),communityName:e.communityName??t.community?.name,focusHeading:!0,imageUrl:n.image??n.images[0]??t.configuration.image??void 0,itemName:n.name,outcome:r,primaryAction:e.returnToItemHref?{href:e.returnToItemHref,label:`Return to item`}:i,secondaryAction:e.returnToItemHref?i:void 0,style:{"--lockerverse-accent":t.community?.color??`#6f8f6d`,...e.style},theme:e.theme})}function ie(t){let{auction:n,itemId:i,resumePurchase:a,className:o,theme:c=`dark`,style:l}=t,u=k(null),[d,f]=A(n),h=k(n),_=d.items.find(e=>e.id===i)??a?.item;s(_?.startAt??d.startAt,_?.endAt??d.endAt);let[v,y]=A(()=>a?{amount:0,includeServiceFee:a.submission.includeServiceFee??!1,quantity:a.submission.quantity}:null),[b,x]=A(!!a),S=k(!0),C=k(t);C.current=t;let w=k(null),D=T(e=>{S.current&&x(e),w.current!==e&&(w.current=e,p(C.current.onInteractionLockChange,e))},[]),O=!!a;E(()=>(S.current=!0,D(O),()=>{S.current=!1}),[O,D]);let[j,P]=A({email:``,phone:``}),[F,I]=A(!!a),[L,R]=A(null),[z,B]=A(null);E(()=>{!(F||b||a)&&h.current!==n&&(h.current=n,f(n))},[n,F,b,a]);function V(e,t){D(!1),h.current=C.current.auction,f(e),y(null),I(!1),R(t)}function H(e){R(null),y(e),I(!0)}return _?z?M(re,{...t,auction:d,item:_,outcome:z}):N(`section`,{className:[`lockerverse-auctions`,o].filter(Boolean).join(` `),"data-lockerverse-theme":c,ref:u,style:{"--lockerverse-accent":d.community?.color??`#6f8f6d`,...l},children:[b?null:N(r,{className:`lockerverse-auctions__back`,href:t.backHref,onBack:t.onBack,children:[M(g,{"aria-hidden":`true`,size:16}),` All items`]}),N(`div`,{className:`lockerverse-auctions__detail`,children:[M(G,{auction:d,galleryImageSizes:t.galleryImageSizes,item:_,itemHeadingLevel:t.itemHeadingLevel}),N(`div`,{className:`lockerverse-auctions__transaction`,children:[e(d,_)===`active`?M(ne,{buyNow:_.saleMode===`buy_now`}):null,L?M(`p`,{className:`lockerverse-auctions__notice`,role:`alert`,children:L}):null,F&&v?M(te,{...t,appearanceRoot:u,auction:d,communityName:t.communityName??d.community?.name,contact:j,interactionLocked:b,item:_,onBack:()=>I(!1),onContactChange:P,onIncludeServiceFeeChange:e=>y(t=>t&&{...t,includeServiceFee:d.serviceFeeEnabled&&e}),onInteractionLockChange:D,onResult:B,onReview:V,selection:v}):M($,{auction:d,backHref:t.backHref,initialSelection:v,item:_,itemHeadingLevel:t.itemHeadingLevel,onBack:t.onBack,onContinue:H,onError:R}),b?null:N(r,{className:`lockerverse-auctions__footer-back`,href:t.backHref,onBack:t.onBack,children:[`Back to auction items `,M(m,{"aria-hidden":`true`,size:16})]})]})]})]}):N(`div`,{children:[M(`p`,{role:`alert`,children:`This auction item is no longer available.`}),M(r,{href:t.backHref,onBack:t.onBack,children:`Back to auction items`})]})}function ae(e){let t=k({auctionId:e.auction.id,client:e.client,itemId:e.itemId});if(t.current.client!==e.client||t.current.auctionId!==e.auction.id||t.current.itemId!==e.itemId)throw TypeError(`Auction item identity cannot change. Remount with a new React key.`);if(e.resumePurchase&&(e.resumePurchase.auctionId!==e.auction.id||e.resumePurchase.itemId!==e.itemId||e.resumePurchase.item.id!==e.itemId||e.resumePurchase.item.auctionId!==e.auction.id))throw TypeError(`The purchase recovery record belongs to a different auction item.`);return M(c.Provider,{value:e.auction.mediaBaseUrl,children:M(ie,{...e})})}export{ae as LockerverseAuctionItem};
2
2
  //# sourceMappingURL=auction-item.js.map