1import{_ as X}from"./eKmkQSTI.js";import{b as F,aS as Z,r as V,P as Q,n as ee,E as te,G as se,j as re,u as ae,z as oe,Y as K,H as ne,p as ie,o as n,U as u,V as t,K as l,m as r,$ as le,a9 as ce,X as h,a4 as I,a5 as E,a3 as C,a0 as ue,aR as de,a2 as me,W as M,w as b,Z as pe,k as B,aT as fe,f as _e}from"./vz5Qp00s.js";import{_ as ge}from"./BXl1l0aC.js";import{L as he}from"./MzYjGZjZ.js";import{_ as be}from"./C75PbHyq.js";import{S as ye}from"./CcPULRO9.js";import{u as W}from"./DWiWpFFW.js";import{u as xe}from"./DnSWJ5UG.js";import{f as Y}from"./CP2kOXHh.js";import{r as ve}from"./CgAIhBMA.js";import{u as ke}from"./6R5WVdS2.js";import{u as Ce,C as D}from"./BwMR8pVH.js";import"./BcBRrp0N.js";import"./B16WbmCk.js";import"./BsSW1B36.js";import"./CJX0juE4.js";import"./XXnsvtB-.js";import"./KIO2_aBB.js";import"./B4Ii8jg2.js";import"./BrwuDrku.js";import"./CHIgUVhi.js";import"./ChOKVcqp.js";import"./DBmBB10D.js";import"./6HhAiW1l.js";import"./hxwJoK7F.js";import"./BgjU8_Xz.js";import"./DlAUqK2U.js";import"./DGuGMk-V.js";import"./CIbSsRjk.js";import"./C7tsqqYQ.js";import"./DN0aNfNx.js";const z="pse_open_paddle_on_load";function we(){const y=W(),{isAuthenticated:f}=F(),x=Z(),i=V(!1),o=V(null),{paddle:L,ensureReady:O}=Ce({eventCallback(a){a.name===D.CHECKOUT_COMPLETED&&a.data&&A(a.data),a.name===D.CHECKOUT_CLOSED&&(i.value=!1),a.name===D.CHECKOUT_ERROR&&(i.value=!1,o.value="Checkout encountered an error. Please try again.")}});async function U(a){if(!f.value){try{sessionStorage.setItem(Q,"/cart"),sessionStorage.setItem(z,"1")}catch{}ee("/login");return}if(i.value)return;i.value=!0,o.value=null;const g=L.value??await O().catch(()=>null);if(!g){i.value=!1,o.value="Payment system is loading. Please try again in a moment.";return}const _=y.cart.filter(d=>d.isLibraryUpgrade),c=y.cart.filter(d=>!d.isLibraryUpgrade);if(_.length&&c.length){i.value=!1,o.value="Please check out upgrade offers separately from other library purchases.";return}if(y.cart.length===0){i.value=!1,o.value="Your cart is empty.";return}try{const d=a?{customer:{email:a}}:{};if(_.length>0){const m=te(),w=await se(m.POST("/v1/Library/upgrade-authorize",{body:{libraryIds:_.map(P=>P.id),checkout:!0}}));if(!w.transactionId)throw new Error("Could not create checkout transaction.");g.Checkout.open({transactionId:w.transactionId,...d});return}const v=c.filter(m=>m.paddleDefaultPriceId).map(m=>({priceId:m.paddleDefaultPriceId,quantity:1}));if(v.length===0)throw new Error("No items in your cart have valid pricing.");if(v.length!==c.length)throw new Error("Some items in your cart are not available for purchase right now. Please remove them and try again.");g.Checkout.open({items:v,...d})}catch(d){i.value=!1,o.value=d instanceof Error?d.message:"Checkout failed."}}function R(){if(typeof sessionStorage>"u")return!1;try{if(sessionStorage.getItem(z)==="1")return sessionStorage.removeItem(z),!0}catch{}return!1}async function A(a){{const g=a.items?.length?a.items.map(c=>({name:c.product?.name??"",priceId:c.price_id})):y.cart.map(c=>({name:c.name,priceId:c.paddleDefaultPriceId??""})),_=(a.items??[]).some(c=>c.billing_cycle!=null);sessionStorage.setItem("pse_checkout_complete",JSON.stringify({transactionId:a.transaction_id??"",customerEmail:a.customer?.email??"",isSubscriptionOrder:_,items:g}))}y.clearCart(),i.value=!1,await x.push("/cart/confirmation")}return{openCheckout:U,consumeAutoOpenFlag:R,isProcessing:i,checkoutError:o}}const Pe={class:"pb-28 lg:pb-0"},Se={class:"container py-10 lg:py-12"},Ie={key:0,class:"py-16 text-center"},Ee={key:1,class:"flex flex-col gap-10 lg:flex-row lg:gap-8"},Le={class:"flex-1"},Oe={class:"mb-6 flex items-baseline gap-2"},Ue={class:"body-1 text-text-grey-20"},Re={class:"flex flex-col gap-4"},Ae={class:"min-w-0"},Ne={class:"body-1-s line-clamp-2 text-text-dark-blue-10"},Te={class:"mt-1 flex items-baseline gap-2"},Be={key:0,class:"body-2 text-text-grey-20 line-through"},De={class:"body-1-s text-action-primary-blue-10"},ze=["aria-label","onClick"],Ve={class:"w-full lg:w-96"},$e={class:"rounded-xl border border-gray-200 p-6"},He={class:"flex items-center justify-between"},je={class:"heading-6 text-text-dark-blue-10"},Ke={key:0,class:"label-1 mt-2 text-text-grey-20"},Me={class:"mt-4 flex cursor-pointer items-start gap-2 text-left"},Ye={class:"body-2 text-text-grey-10"},Fe={key:1,class:"body-2 mt-3 text-red-600"},We={key:0,class:"bg-section-secondary-strength-2 py-12 lg:py-16"},qe={class:"container"},Ge={class:"mb-8 flex items-center justify-between gap-4"},Je={class:"hidden sm:block"},Xe={class:"grid grid-cols-3 gap-4 lg:grid-cols-4 xl:grid-cols-5"},Ze={class:"grid grid-cols-2 gap-4 sm:hidden"},Qe={key:0,class:"fixed inset-x-0 bottom-0 z-50 border-t border-gray-200 bg-white p-4 lg:hidden"},Rt=re({__name:"index",async setup(y){let f,x;
1ae({title:"Cart",robots:"noindex, nofollow"});const i=W(),{cart:o,cartTotalDisplay:L,hasUpgradeInCart:O}=oe(i),{data:U}=([f,x]=K(()=>ke()),f=await f,x(),f),R=p=>ve(U.value,p);ne(async()=>{const p=o.value.filter(k=>!k.isBundle&&!k.isLibraryUpgrade).map(k=>k.id);if(!p.length)return;const e=await $fetch("/api/library/explore-list",{method:"POST",body:{libraries:p}}).catch(()=>[]);i.syncLibraryPrices(e)});const{data:A}=([f,x]=K(()=>xe()),f=await f,x(),f),a=_e(()=>{const p=new Set(o.value.map(e=>e.id));return(A.value??[]).filter(e=>e.id&&!p.has(e.id))}),g={spaceBetween:16,slidesPerView:2.2,breakpoints:{640:{slidesPerView:3},1024:{slidesPerView:4},1280:{slidesPerView:5}}},{openCheckout:_,consumeAutoOpenFlag:c,isProcessing:d,checkoutError:v}=we(),m=V(!1);function w(p){return p.regularPrice!=null&&p.salePrice!=null&&p.regularPrice>p.salePrice}const{isAuthenticated:P}=F();let N=!1;function q(){if(!(N||!P.value||o.value.length===0)){if(!c()){N=!0;return}N=!0,m.value=!0,_()}}return ie([P,()=>o.value.length],()=>q(),{immediate:!0}),(p,e)=>{const k=X,$=le,S=ce,G=ge,H=pe,T=he,J=be,j=fe;return n(),u("div",Pe,[t("div",Se,[l(k,{items:[{title:"Cart"}],class:"mb-8 lg:mb-10"}),r(o).length===0?(n(),u("div",Ie,[l($,{name:"ui:cart",class:"mx-auto mb-4 size-16 text-gray-300"}),e[3]||(e[3]=t("p",{class:"heading-4 mb-2 text-text-dark-blue-10"},"Your cart is empty",-1)),e[4]||(e[4]=t("p",{class:"body-1 mb-6 text-text-grey-20"}," Browse our library collection and find your next sound. ",-1)),l(S,{label:"Browse Libraries",to:"/libraries","show-icon":""})])):(n(),u("div",Ee,[t("div",Le,[t("div",Oe,[e[5]||(e[5]=t("h1",{class:"heading-4 text-text-dark-blue-10"},"Shopping Cart",-1)),t("span",Ue,"("+h(r(o).length)+" "+h(r(o).length===1?"item":"items")+")",1)]),t("ul",Re,[(n(!0),u(I,null,E(r(o),s=>(n(),u("li",{key:s.id,class:"flex items-start justify-between gap-4 rounded-lg border border-gray-200 p-3 shadow-sm lg:p-6"},[l(H,{to:R(s.id),class:"flex flex-1 items-center gap-3 overflow-hidden lg:gap-4"},{default:b(()=>[l(G,{src:s.artworkWebpUrl||s.artworkUrl||"",alt:s.name,width:"134",height:"134",class:"size-20 shrink-0 rounded object-cover lg:size-32"},null,8,["src","alt"]),t("div",Ae,[t("p",Ne,h(s.name),1),t("div",Te,[w(s)?(n(),u("span",Be,h(r(Y)(s.regularPrice,{isCents:!0})),1)):C("",!0),t("span",De,h(s.salePrice!=null?r(Y)(s.salePrice,{isCents:!0}):""),1)])])]),_:2},1032,["to"]),t("button",{type:"button","aria-label":`Remove ${s.name} from cart`,class:"flex size-10 shrink-0 items-center justify-center rounded-full bg-section-secondary-strength-2 text-text-dark-blue-10 transition-colors hover:bg-gray-200",onClick:et=>r(i).removeFromCart(s.id)},[l($,{name:"lucide:trash-2",class:"size-5"})],8,ze)]))),128))])]),t("div",Ve,[e[9]||(e[9]=t("h2",{class:"heading-4 mb-6 text-text-dark-blue-10"},"Summary",-1)),t("div",$e,[t("div",He,[e[6]||(e[6]=t("span",{class:"body-1 text-text-grey-10"},"Subtotal:",-1)),t("span",je,h(r(L)),1)]),r(O)?C("",!0):(n(),u("p",Ke," Your upgrade discount will be applied at checkout. ")),t("label",Me,[ue(t("input",{"onUpdate:modelValue":e[0]||(e[0]=s=>me(m)?m.value=s:null),type:"checkbox",class:"mt-0.5 size-4 shrink-0 cursor-pointer accent-action-primary-blue-10",required:""},null,512),[[de,r(m)]]),t("span",Ye,[e[8]||(e[8]=M(" I agree with the ",-1)),l(H,{to:"/individual-end-user-license-agreement",target:"_blank",rel:"noopener noreferrer",class:"text-action-primary-blue-10 hover:underline"},{default:b(()=>[...e[7]||(e[7]=[M(" Individual End User License Agreement. ",-1)])]),_:1})])]),r(v)?(n(),u("p",Fe,h(r(v)),1)):C("",!0),l(S,{label:"Checkout",class:"mt-4 hidden w-full lg:block",disabled:r(d)||!r(m),onClick:e[1]||(e[1]=s=>r(_)())},null,8,["disabled"])])])]))]),r(a).length?(n(),u("section",We,[t("div",qe,[t("div",Ge,[e[10]||(e[10]=t("h2",{class:"heading-4 text-text-dark-blue-10"},"We also recommend",-1)),l(S,{label:"All Libraries",to:"/libraries",variant:"ghost",size:"xs","show-icon":""})]),t("div",Je,[l(j,null,{fallback:b(()=>[t("div",Xe,[(n(!0),u(I,null,E(r(a).slice(0,6),s=>(n(),B(T,{key:s.id??"",library:s,variant:"product"},null,8,["library"]))),128))])]),default:b(()=>[l(J,{options:g,"gradient-from":"#f5f5f5"},{default:b(()=>[(n(!0),u(I,null,E(r(a),s=>(n(),B(r(ye),{key:s.id??""},{default:b(()=>[l(T,{library:s,variant:"product"},null,8,["library"])]),_:2},1024))),128))]),_:1})]),_:1})]),t("div",Ze,[(n(!0),u(I,null,E(r(a).slice(0,6),s=>(n(),B(T,{key:s.id??"",library:s,variant:"product"},null,8,["library"]))),128))])])])):C("",!0),l(j,null,{default:b(()=>[r(o).length?(n(),u("div",Qe,[l(S,{label:"Checkout",class:"w-full",disabled:r(d)||!r(m),onClick:e[2]||(e[2]=s=>r(_)())},null,8,["disabled"])])):C("",!0)]),_:1})])}}});
1export{Rt as default}; 2//# sourceMappingURL=CFffESwb.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.