import{r as u,R as H,a as N,j as S,F as Oe}from"./index.1ec44e23.js";import{c as z}from"./2e4f433f.js";import"./ebc50768.js";import"./ef11f8a9.js";import"./2d3554bc.js";import{d as Re}from"./616890f5.js";import"./3c10424c.js";import"./a8ae7088.js";import"./c268d3e4.js";import{s as ne,a as A,o as x,C as M,S as ee,y as $,u as E,L as Le,F as Ie,N as Ce,k as V,n as Te,p as Z,h as Pe,c as we,q as ke,$ as F,I as _,i as Ae,e as Ee,m as X,j as g,r as De,v as Ne}from"./7aafe6fa.js";import"./6cbd8241.js";import"./8bce3399.js";import"./b9494af1.js";import"./d6282b27.js";function ie(e,r){let[t,n]=u.exports.useState(e),i=ne(e);return A(()=>n(i.current),[i,n,...r]),t}function te(e){var r;if(e.type)return e.type;let t=(r=e.as)!=null?r:"button";if(typeof t=="string"&&t.toLowerCase()==="button")return"button"}function Me(e,r){let[t,n]=u.exports.useState(()=>te(e));return A(()=>{n(te(e))},[e.type,e.as]),A(()=>{t||!r.current||r.current instanceof HTMLButtonElement&&!r.current.hasAttribute("type")&&n("button")},[t,r]),t}function $e(e){throw new Error("Unexpected object: "+e)}var R=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(R||{});function Fe(e,r){let t=r.resolveItems();if(t.length<=0)return null;let n=r.resolveActiveIndex(),i=n!=null?n:-1,a=(()=>{switch(e.focus){case 0:return t.findIndex(o=>!r.resolveDisabled(o));case 1:{let o=t.slice().reverse().findIndex((l,d,f)=>i!==-1&&f.length-d-1>=i?!1:!r.resolveDisabled(l));return o===-1?o:t.length-1-o}case 2:return t.findIndex((o,l)=>l<=i?!1:!r.resolveDisabled(o));case 3:{let o=t.slice().reverse().findIndex(l=>!r.resolveDisabled(l));return o===-1?o:t.length-1-o}case 4:return t.findIndex(o=>r.resolveId(o)===e.id);case 5:return null;default:$e(e)}})();return a===-1?n:a}function ae(e={},r=null,t=[]){for(let[n,i]of Object.entries(e))se(t,le(r,n),i);return t}function le(e,r){return e?e+"["+r+"]":r}function se(e,r,t){if(Array.isArray(t))for(let[n,i]of t.entries())se(e,le(r,n.toString()),i);else t instanceof Date?e.push([r,t.toISOString()]):typeof t=="boolean"?e.push([r,t?"1":"0"]):typeof t=="string"?e.push([r,t]):typeof t=="number"?e.push([r,`${t}`]):t==null?e.push([r,""]):ae(t,r,e)}function Qe(e,r,t){let[n,i]=u.exports.useState(t),a=e!==void 0,o=u.exports.useRef(a),l=u.exports.useRef(!1),d=u.exports.useRef(!1);return a&&!o.current&&!l.current?(l.current=!0,o.current=a,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!a&&o.current&&!d.current&&(d.current=!0,o.current=a,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[a?e:n,x(f=>(a||i(f),r==null?void 0:r(f)))]}function re(e){return[e.screenX,e.screenY]}function Ue(){let e=u.exports.useRef([-1,-1]);return{wasMoved(r){let t=re(r);return e.current[0]===t[0]&&e.current[1]===t[1]?!1:(e.current=t,!0)},update(r){e.current=re(r)}}}var je=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(je||{}),Be=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Be||{}),He=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(He||{}),ze=(e=>(e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.GoToOption=2]="GoToOption",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterOption=5]="RegisterOption",e[e.UnregisterOption=6]="UnregisterOption",e[e.RegisterLabel=7]="RegisterLabel",e))(ze||{});function K(e,r=t=>t){let t=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,n=Ne(r(e.options.slice()),a=>a.dataRef.current.domRef.current),i=t?n.indexOf(t):null;return i===-1&&(i=null),{options:n,activeOptionIndex:i}}let Ge={[1](e){return e.dataRef.current.disabled||e.listboxState===1?e:{...e,activeOptionIndex:null,listboxState:1}},[0](e){if(e.dataRef.current.disabled||e.listboxState===0)return e;let r=e.activeOptionIndex,{isSelected:t}=e.dataRef.current,n=e.options.findIndex(i=>t(i.dataRef.current.value));return n!==-1&&(r=n),{...e,listboxState:0,activeOptionIndex:r}},[2](e,r){var t;if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=K(e),i=Fe(r,{resolveItems:()=>n.options,resolveActiveIndex:()=>n.activeOptionIndex,resolveId:a=>a.id,resolveDisabled:a=>a.dataRef.current.disabled});return{...e,...n,searchQuery:"",activeOptionIndex:i,activationTrigger:(t=r.trigger)!=null?t:1}},[3]:(e,r)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let t=e.searchQuery!==""?0:1,n=e.searchQuery+r.value.toLowerCase(),i=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+t).concat(e.options.slice(0,e.activeOptionIndex+t)):e.options).find(o=>{var l;return!o.dataRef.current.disabled&&((l=o.dataRef.current.textValue)==null?void 0:l.startsWith(n))}),a=i?e.options.indexOf(i):-1;return a===-1||a===e.activeOptionIndex?{...e,searchQuery:n}:{...e,searchQuery:n,activeOptionIndex:a,activationTrigger:1}},[4](e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},[5]:(e,r)=>{let t={id:r.id,dataRef:r.dataRef},n=K(e,i=>[...i,t]);return e.activeOptionIndex===null&&e.dataRef.current.isSelected(r.dataRef.current.value)&&(n.activeOptionIndex=n.options.indexOf(t)),{...e,...n}},[6]:(e,r)=>{let t=K(e,n=>{let i=n.findIndex(a=>a.id===r.id);return i!==-1&&n.splice(i,1),n});return{...e,...t,activationTrigger:1}},[7]:(e,r)=>({...e,labelId:r.id})},Y=u.exports.createContext(null);Y.displayName="ListboxActionsContext";function Q(e){let r=u.exports.useContext(Y);if(r===null){let t=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Q),t}return r}let J=u.exports.createContext(null);J.displayName="ListboxDataContext";function U(e){let r=u.exports.useContext(J);if(r===null){let t=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,U),t}return r}function Ve(e,r){return E(r.type,Ge,e,r)}let _e=u.exports.Fragment,qe=M(function(e,r){let{value:t,defaultValue:n,name:i,onChange:a,by:o=(c,v)=>c===v,disabled:l=!1,horizontal:d=!1,multiple:f=!1,...L}=e;const I=d?"horizontal":"vertical";let w=$(r),[y=f?[]:void 0,T]=Qe(t,a,n),[P,p]=u.exports.useReducer(Ve,{dataRef:u.exports.createRef(),listboxState:1,options:[],searchQuery:"",labelId:null,activeOptionIndex:null,activationTrigger:1}),s=u.exports.useRef({static:!1,hold:!1}),b=u.exports.useRef(null),k=u.exports.useRef(null),q=u.exports.useRef(null),h=x(typeof o=="string"?(c,v)=>{let O=o;return(c==null?void 0:c[O])===(v==null?void 0:v[O])}:o),C=u.exports.useCallback(c=>E(m.mode,{[1]:()=>y.some(v=>h(v,c)),[0]:()=>h(y,c)}),[y]),m=u.exports.useMemo(()=>({...P,value:y,disabled:l,mode:f?1:0,orientation:I,compare:h,isSelected:C,optionsPropsRef:s,labelRef:b,buttonRef:k,optionsRef:q}),[y,l,f,P]);A(()=>{P.dataRef.current=m},[m]),Le([m.buttonRef,m.optionsRef],(c,v)=>{var O;p({type:1}),Ie(v,Ce.Loose)||(c.preventDefault(),(O=m.buttonRef.current)==null||O.focus())},m.listboxState===0);let ue=u.exports.useMemo(()=>({open:m.listboxState===0,disabled:l,value:y}),[m,l,y]),ce=x(c=>{let v=m.options.find(O=>O.id===c);!v||D(v.dataRef.current.value)}),de=x(()=>{if(m.activeOptionIndex!==null){let{dataRef:c,id:v}=m.options[m.activeOptionIndex];D(c.current.value),p({type:2,focus:R.Specific,id:v})}}),pe=x(()=>p({type:0})),fe=x(()=>p({type:1})),ve=x((c,v,O)=>c===R.Specific?p({type:2,focus:R.Specific,id:v,trigger:O}):p({type:2,focus:c,trigger:O})),xe=x((c,v)=>(p({type:5,id:c,dataRef:v}),()=>p({type:6,id:c}))),be=x(c=>(p({type:7,id:c}),()=>p({type:7,id:null}))),D=x(c=>E(m.mode,{[0](){return T==null?void 0:T(c)},[1](){let v=m.value.slice(),O=v.findIndex(B=>h(B,c));return O===-1?v.push(c):v.splice(O,1),T==null?void 0:T(v)}})),me=x(c=>p({type:3,value:c})),he=x(()=>p({type:4})),ge=u.exports.useMemo(()=>({onChange:D,registerOption:xe,registerLabel:be,goToOption:ve,closeListbox:fe,openListbox:pe,selectActiveOption:de,selectOption:ce,search:me,clearSearch:he}),[]),Se={ref:w},j=u.exports.useRef(null),ye=V();return u.exports.useEffect(()=>{!j.current||n!==void 0&&ye.addEventListener(j.current,"reset",()=>{D(n)})},[j,D]),H.createElement(Y.Provider,{value:ge},H.createElement(J.Provider,{value:m},H.createElement(Te,{value:E(m.listboxState,{[0]:Z.Open,[1]:Z.Closed})},i!=null&&y!=null&&ae({[i]:y}).map(([c,v],O)=>H.createElement(Pe,{features:we.Hidden,ref:O===0?B=>{var W;j.current=(W=B==null?void 0:B.closest("form"))!=null?W:null}:void 0,...ke({key:c,as:"input",type:"hidden",hidden:!0,readOnly:!0,name:c,value:v})})),F({ourProps:Se,theirProps:L,slot:ue,defaultTag:_e,name:"Listbox"}))))}),Ke="button",Ze=M(function(e,r){var t;let n=_(),{id:i=`headlessui-listbox-button-${n}`,...a}=e,o=U("Listbox.Button"),l=Q("Listbox.Button"),d=$(o.buttonRef,r),f=V(),L=x(p=>{switch(p.key){case g.Space:case g.Enter:case g.ArrowDown:p.preventDefault(),l.openListbox(),f.nextFrame(()=>{o.value||l.goToOption(R.First)});break;case g.ArrowUp:p.preventDefault(),l.openListbox(),f.nextFrame(()=>{o.value||l.goToOption(R.Last)});break}}),I=x(p=>{switch(p.key){case g.Space:p.preventDefault();break}}),w=x(p=>{if(De(p.currentTarget))return p.preventDefault();o.listboxState===0?(l.closeListbox(),f.nextFrame(()=>{var s;return(s=o.buttonRef.current)==null?void 0:s.focus({preventScroll:!0})})):(p.preventDefault(),l.openListbox())}),y=ie(()=>{if(o.labelId)return[o.labelId,i].join(" ")},[o.labelId,i]),T=u.exports.useMemo(()=>({open:o.listboxState===0,disabled:o.disabled,value:o.value}),[o]),P={ref:d,id:i,type:Me(e,o.buttonRef),"aria-haspopup":!0,"aria-controls":(t=o.optionsRef.current)==null?void 0:t.id,"aria-expanded":o.disabled?void 0:o.listboxState===0,"aria-labelledby":y,disabled:o.disabled,onKeyDown:L,onKeyUp:I,onClick:w};return F({ourProps:P,theirProps:a,slot:T,defaultTag:Ke,name:"Listbox.Button"})}),Xe="label",Ye=M(function(e,r){let t=_(),{id:n=`headlessui-listbox-label-${t}`,...i}=e,a=U("Listbox.Label"),o=Q("Listbox.Label"),l=$(a.labelRef,r);A(()=>o.registerLabel(n),[n]);let d=x(()=>{var L;return(L=a.buttonRef.current)==null?void 0:L.focus({preventScroll:!0})}),f=u.exports.useMemo(()=>({open:a.listboxState===0,disabled:a.disabled}),[a]);return F({ourProps:{ref:l,id:n,onClick:d},theirProps:i,slot:f,defaultTag:Xe,name:"Listbox.Label"})}),Je="ul",We=ee.RenderStrategy|ee.Static,et=M(function(e,r){var t;let n=_(),{id:i=`headlessui-listbox-options-${n}`,...a}=e,o=U("Listbox.Options"),l=Q("Listbox.Options"),d=$(o.optionsRef,r),f=V(),L=V(),I=Ae(),w=(()=>I!==null?I===Z.Open:o.listboxState===0)();u.exports.useEffect(()=>{var s;let b=o.optionsRef.current;!b||o.listboxState===0&&b!==((s=Ee(b))==null?void 0:s.activeElement)&&b.focus({preventScroll:!0})},[o.listboxState,o.optionsRef]);let y=x(s=>{switch(L.dispose(),s.key){case g.Space:if(o.searchQuery!=="")return s.preventDefault(),s.stopPropagation(),l.search(s.key);case g.Enter:if(s.preventDefault(),s.stopPropagation(),o.activeOptionIndex!==null){let{dataRef:b}=o.options[o.activeOptionIndex];l.onChange(b.current.value)}o.mode===0&&(l.closeListbox(),X().nextFrame(()=>{var b;return(b=o.buttonRef.current)==null?void 0:b.focus({preventScroll:!0})}));break;case E(o.orientation,{vertical:g.ArrowDown,horizontal:g.ArrowRight}):return s.preventDefault(),s.stopPropagation(),l.goToOption(R.Next);case E(o.orientation,{vertical:g.ArrowUp,horizontal:g.ArrowLeft}):return s.preventDefault(),s.stopPropagation(),l.goToOption(R.Previous);case g.Home:case g.PageUp:return s.preventDefault(),s.stopPropagation(),l.goToOption(R.First);case g.End:case g.PageDown:return s.preventDefault(),s.stopPropagation(),l.goToOption(R.Last);case g.Escape:return s.preventDefault(),s.stopPropagation(),l.closeListbox(),f.nextFrame(()=>{var b;return(b=o.buttonRef.current)==null?void 0:b.focus({preventScroll:!0})});case g.Tab:s.preventDefault(),s.stopPropagation();break;default:s.key.length===1&&(l.search(s.key),L.setTimeout(()=>l.clearSearch(),350));break}}),T=ie(()=>{var s,b,k;return(k=(s=o.labelRef.current)==null?void 0:s.id)!=null?k:(b=o.buttonRef.current)==null?void 0:b.id},[o.labelRef.current,o.buttonRef.current]),P=u.exports.useMemo(()=>({open:o.listboxState===0}),[o]),p={"aria-activedescendant":o.activeOptionIndex===null||(t=o.options[o.activeOptionIndex])==null?void 0:t.id,"aria-multiselectable":o.mode===1?!0:void 0,"aria-labelledby":T,"aria-orientation":o.orientation,id:i,onKeyDown:y,role:"listbox",tabIndex:0,ref:d};return F({ourProps:p,theirProps:a,slot:P,defaultTag:Je,features:We,visible:w,name:"Listbox.Options"})}),tt="li",rt=M(function(e,r){let t=_(),{id:n=`headlessui-listbox-option-${t}`,disabled:i=!1,value:a,...o}=e,l=U("Listbox.Option"),d=Q("Listbox.Option"),f=l.activeOptionIndex!==null?l.options[l.activeOptionIndex].id===n:!1,L=l.isSelected(a),I=u.exports.useRef(null),w=ne({disabled:i,value:a,domRef:I,get textValue(){var h,C;return(C=(h=I.current)==null?void 0:h.textContent)==null?void 0:C.toLowerCase()}}),y=$(r,I);A(()=>{if(l.listboxState!==0||!f||l.activationTrigger===0)return;let h=X();return h.requestAnimationFrame(()=>{var C,m;(m=(C=I.current)==null?void 0:C.scrollIntoView)==null||m.call(C,{block:"nearest"})}),h.dispose},[I,f,l.listboxState,l.activationTrigger,l.activeOptionIndex]),A(()=>d.registerOption(n,w),[w,n]);let T=x(h=>{if(i)return h.preventDefault();d.onChange(a),l.mode===0&&(d.closeListbox(),X().nextFrame(()=>{var C;return(C=l.buttonRef.current)==null?void 0:C.focus({preventScroll:!0})}))}),P=x(()=>{if(i)return d.goToOption(R.Nothing);d.goToOption(R.Specific,n)}),p=Ue(),s=x(h=>p.update(h)),b=x(h=>{!p.wasMoved(h)||i||f||d.goToOption(R.Specific,n,0)}),k=x(h=>{!p.wasMoved(h)||i||!f||d.goToOption(R.Nothing)}),q=u.exports.useMemo(()=>({active:f,selected:L,disabled:i}),[f,L,i]);return F({ourProps:{id:n,ref:y,role:"option",tabIndex:i===!0?void 0:-1,"aria-disabled":i===!0?!0:void 0,"aria-selected":L,disabled:void 0,onClick:T,onFocus:P,onPointerEnter:s,onMouseEnter:s,onPointerMove:b,onMouseMove:b,onPointerLeave:k,onMouseLeave:k},theirProps:o,slot:q,defaultTag:tt,name:"Listbox.Option"})}),G=Object.assign(qe,{Button:Ze,Label:Ye,Options:et,Option:rt});function ot(){return N("svg",{width:"54",height:"54",viewBox:"0 0 54 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"animate-spin",children:[S("path",{d:"M43.6663 27.0002C43.6663 36.2049 36.2044 43.6668 26.9997 43.6668C17.7949 43.6668 10.333 36.2049 10.333 27.0002C10.333 17.7954 17.7949 10.3335 26.9997 10.3335C36.2044 10.3335 43.6663 17.7954 43.6663 27.0002ZM13.6663 27.0002C13.6663 34.364 19.6359 40.3335 26.9997 40.3335C34.3635 40.3335 40.333 34.364 40.333 27.0002C40.333 19.6364 34.3635 13.6668 26.9997 13.6668C19.6359 13.6668 13.6663 19.6364 13.6663 27.0002Z",fill:"#E6E7EB"}),S("path",{d:"M26.9997 10.3332C29.1884 10.3332 31.3556 10.7643 33.3777 11.6018C35.3998 12.4394 37.2371 13.6671 38.7848 15.2147C40.3324 16.7624 41.5601 18.5997 42.3977 20.6218C43.2352 22.6439 43.6663 24.8111 43.6663 26.9998L40.333 26.9998C40.333 25.2489 39.9881 23.5151 39.3181 21.8974C38.648 20.2797 37.6659 18.8099 36.4278 17.5717C35.1896 16.3336 33.7198 15.3515 32.1021 14.6814C30.4844 14.0114 28.7506 13.6665 26.9997 13.6665L26.9997 10.3332Z",fill:"black"})]})}const oe=[{name:"Artist's name",collectionSortOrder:"MANUAL",productSort:{key:void 0,reverse:!1}},{name:"Price",symbol:"\u2197",collectionSortOrder:"PRICE_ASC",productSort:{key:"PRICE",reverse:!1}},{name:"Price",symbol:"\u2198",collectionSortOrder:"PRICE_DESC",productSort:{key:"PRICE",reverse:!0}},{name:"Title",symbol:"\u2197",collectionSortOrder:"ALPHA_ASC",productSort:{key:"TITLE",reverse:!1}},{name:"Title",symbol:"\u2198",collectionSortOrder:"ALPHA_DESC",productSort:{key:"TITLE",reverse:!0}}];function gt({initialSortOrder:e}){const r=u.exports.useMemo(()=>e==="MANUAL"?oe:oe.filter(d=>d.collectionSortOrder!=="MANUAL"),[e]),[t,n]=u.exports.useState(!1),{setServerProps:i}=Re(),[a,o]=u.exports.useState(r.find(d=>d.collectionSortOrder===e));return S(G,{onChange:d=>{o(d),i("productSort",d.productSort)},value:a,children:({open:d})=>(setTimeout(()=>n(d)),N("div",{className:"relative",children:[N(G.Button,{className:"text-left outline-0",children:[S("span",{className:z("block text-gray",t&&"text-black"),children:"Sort by"}),N("span",{className:"block text-main",children:[a==null?void 0:a.name," ",(a==null?void 0:a.symbol)&&S("span",{children:a.symbol})]})]}),S(G.Options,{className:z("absolute top-full left-0 w-full",'after:content-[""] after:absolute after:w-screen after:h-full after:bg-white',"after:top-0 after:right-0 after:-z-10 after:outline-0"),children:S("div",{className:"overflow-y-auto mt-20 mb-10",children:t&&S(u.exports.Suspense,{fallback:S("div",{className:"overflow-hidden",children:S(ot,{})}),children:S(nt,{selectedSortOption:a,getClassName:f=>z(["cursor-pointer whitespace-nowrap text-gray",f?"text-main":null]),options:r})})})})]}))})}function nt({selectedSortOption:e,getClassName:r,options:t}){const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return S(Oe,{children:t.filter(i=>i!==e).map(i=>{const a=i===e;return S(G.Option,{value:i,onClick:n,children:({active:o})=>S("div",{className:r(o),children:N("span",{className:z("group",a&&"text-main"),children:[S("span",{className:"inline-block w-[39px] group-hover:text-main",children:i.name}),i.symbol&&S("span",{className:"group-hover:text-main",children:i.symbol})]})})},i.collectionSortOrder)})})}export{oe as SORT_OPTIONS,nt as SortOptions,gt as default}; //# sourceMappingURL=b6c5c1a8.js.map