import{j as t}from"./jsx-runtime.D_zvdyIk.js";import{r as s,b as O}from"./index.2yJIXLcc.js";import{u as Q}from"./index.CfnX_YjH.js";import{s as _,l as X}from"./cartStore.DQm8CpS2.js";import{a as Y}from"./index.BlACm4Ui.js";import{a as J}from"./index.DRwKiUZ5.js";import{G as D}from"./iconBase.Blz05Vck.js";import{c as z}from"./utils.Dmkrq8gB.js";import{s as Z}from"./js.cookie.C0BS3qSL.js";import ee from"./ProductFilters.Bs-V0onL.js";import"./textConverter.D1LjrjZ_.js";import"./ShowTags.0G00e1B2.js";import"./config.MP0qMYzO.js";/**
  * react-collapsed v4.2.0
  *
  * Copyright (c) 2019-2024, Rogin Farrer
  *
  * This source code is licensed under the MIT license found in the
  * LICENSE.md file in the root directory of this source tree.
  *
  * @license MIT
  */var te=class extends Error{constructor(e){super(`react-collapsed: ${e}`)}},N=(...e)=>(e[0],`${e[1]}`,void 0);function H(e){const n=s.useRef(e);return s.useEffect(()=>{n.current=e}),s.useCallback((...r)=>n.current?.(...r),[])}function ne(e,n,r){const[o,i]=s.useState(n),a=s.useRef(typeof e<"u"),c=a.current?e:o,d=H(r),l=s.useCallback(h=>{const b=typeof h=="function"?h(c):h;a.current||i(b),d?.(b)},[d,c]);return s.useEffect(()=>{N(!(a.current&&e==null),"`isExpanded` state is changing from controlled to uncontrolled. useCollapse should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled collapse for the lifetime of the component. Check the `isExpanded` prop."),N(!(!a.current&&e!=null),"`isExpanded` state is changing from uncontrolled to controlled. useCollapse should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled collapse for the lifetime of the component. Check the `isExpanded` prop.")},[e]),[c,l]}var re="(prefers-reduced-motion: reduce)";function se(){const[e,n]=s.useState(!1);return s.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia(re);n(r.matches);const o=i=>{n(i.matches)};if(r.addEventListener)return r.addEventListener("change",o),()=>{r.removeEventListener("change",o)};if(r.addListener)return r.addListener(o),()=>{r.removeListener(o)}},[]),e}var oe=O.useId||(()=>{});function ae(){return oe()??""}var ie=typeof window<"u"?s.useLayoutEffect:s.useEffect,T=!1,le=0,M=()=>++le;function ce(e){const n=e||(T?M():null),[r,o]=s.useState(n);return ie(()=>{r===null&&o(M())},[]),s.useEffect(()=>{T===!1&&(T=!0)},[]),r!=null?String(r):void 0}function de(e){const n=ae(),r=ce(e);return typeof e=="string"?e:typeof n=="string"?n:r}function ue(e,n){const r=performance.now(),o={};function i(){o.id=requestAnimationFrame(a=>{a-r>n?e():i()})}return i(),o}function U(e){e.id&&cancelAnimationFrame(e.id)}function q(e){return e?.current?e.current.scrollHeight:(N(!0,"Was not able to find a ref to the collapse element via `getCollapseProps`. Ensure that the element exposes its `ref` prop. If it exposes the ref prop under a different name (like `innerRef`), use the `refKey` property to change it. Example:\n\nconst collapseProps = getCollapseProps({refKey: 'innerRef'})"),0)}function fe(e){if(!e||typeof e=="string")return 0;const n=e/36;return Math.round((4+15*n**.25+n/5)*10)}function pe(e,n){if(e!=null)if(typeof e=="function")e(n);else try{e.current=n}catch{throw new te(`Cannot assign value "${n}" to ref "${e}"`)}}function B(...e){return e.every(n=>n==null)?null:n=>{e.forEach(r=>{pe(r,n)})}}function me(e){let n=r=>{};n=r=>{if(!r?.current)return;const{paddingTop:o,paddingBottom:i}=window.getComputedStyle(r.current);N(!(o&&o!=="0px"||i&&i!=="0px"),`Padding applied to the collapse element will cause the animation to break and not perform as expected. To fix, apply equivalent padding to the direct descendent of the collapse element. Example:

Before:   <div {...getCollapseProps({style: {padding: 10}})}>{children}</div>

After:   <div {...getCollapseProps()}>
             <div style={{padding: 10}}>
                 {children}
             </div>
          </div>`)},s.useEffect(()=>{n(e)},[e])}var he=typeof window>"u"?s.useEffect:s.useLayoutEffect;function ge({duration:e,easing:n="cubic-bezier(0.4, 0, 0.2, 1)",onTransitionStateChange:r=()=>{},isExpanded:o,defaultExpanded:i=!1,hasDisabledAnimation:a,id:c,...d}={}){const l=H(r),h=de(c?`${c}`:void 0),[f,b]=ne(o,i),k=s.useRef(f),[C,w]=s.useState(!1),L=se(),y=a??L,E=s.useRef(),j=s.useRef(),g=s.useRef(null),[F,K]=s.useState(null);me(g);const S=`${d.collapsedHeight||0}px`;function P(x){if(!g.current)return;const p=g.current;for(const m in x){const v=x[m];v?p.style[m]=v:p.style.removeProperty(m)}}return he(()=>{if(!g.current||f===k.current)return;k.current=f;function p(u){return y?0:e??fe(u)}const m=u=>`height ${p(u)}ms ${n}`,v=u=>{function R(){f?(P({height:"",overflow:"",transition:"",display:""}),l("expandEnd")):(P({transition:""}),l("collapseEnd")),w(!1)}j.current&&U(j.current),j.current=ue(R,u)};return w(!0),f?E.current=requestAnimationFrame(()=>{l("expandStart"),P({display:"block",overflow:"hidden",height:S}),E.current=requestAnimationFrame(()=>{l("expanding");const u=q(g);v(p(u)),g.current&&(g.current.style.transition=m(u),g.current.style.height=`${u}px`)})}):E.current=requestAnimationFrame(()=>{l("collapseStart");const u=q(g);v(p(u)),P({transition:m(u),height:`${u}px`}),E.current=requestAnimationFrame(()=>{l("collapsing"),P({height:S,overflow:"hidden"})})}),()=>{E.current&&cancelAnimationFrame(E.current),j.current&&U(j.current)}},[f,S,y,e,n,l]),{isExpanded:f,setExpanded:b,getToggleProps(x){const{disabled:p,onClick:m,refKey:v,...u}={refKey:"ref",onClick(){},disabled:!1,...x},R=F?F.tagName==="BUTTON":void 0,V=x?.[v||"ref"],I={id:`react-collapsed-toggle-${h}`,"aria-controls":`react-collapsed-panel-${h}`,"aria-expanded":f,onClick(W){p||(m?.(W),b(G=>!G))},[v||"ref"]:B(V,K)},$={type:"button",disabled:p?!0:void 0},A={"aria-disabled":p?!0:void 0,role:"button",tabIndex:p?-1:0};return R===!1?{...I,...A,...u}:R===!0?{...I,...$,...u}:{...I,...$,...A,...u}},getCollapseProps(x){const{style:p,refKey:m}={refKey:"ref",style:{},...x},v=x?.[m||"ref"];return{id:`react-collapsed-panel-${h}`,"aria-hidden":!f,"aria-labelledby":`react-collapsed-toggle-${h}`,role:"region",...x,[m||"ref"]:B(g,v),style:{boxSizing:"border-box",...!C&&!f?{display:S==="0px"?"none":"block",height:S,overflow:"hidden"}:{},...p}}}}}function xe(e){return D({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M13.758 19.414l-4.758 1.586v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v1.5"},child:[]},{tag:"path",attr:{d:"M22 22l-5 -5"},child:[]},{tag:"path",attr:{d:"M17 22l5 -5"},child:[]}]})(e)}function ve(e){return D({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z"},child:[]}]})(e)}function we({item:e}){const[n,r]=s.useState(""),[o,i]=s.useState(new URLSearchParams);s.useEffect(()=>{r(window.location.pathname),i(new URLSearchParams(window.location.search))},[]);const a=n===e.path,c=new URLSearchParams(o.toString()),d=a?"p":"a";return c.delete("q"),t.jsx("li",{className:"mt-2 flex text-black dark:text-white",children:t.jsx(d,{href:z(e.path,c),className:`w-full text-sm ${a?"bg-green-400":"hover:underline"}`,children:e.title})},e.title)}function be({item:e}){const[n,r]=s.useState(""),[o,i]=s.useState(new URLSearchParams);s.useEffect(()=>{r(window.location.pathname),i(new URLSearchParams(window.location.search))},[]);const a=new URLSearchParams(o.toString());e.slug?a.set("sort",e.slug):a.delete("sort");const c=z(n,a),d=o.get("sort")===e.slug,l=d?"p":"a";return t.jsx("li",{className:"flex text-sm text-dark hover:bg-light hover:text-white",children:t.jsx(l,{href:c,className:`w-full pl-4 py-2 ${d?"bg-dark text-white":""}`,children:e.title})},e.title)}function ye({item:e}){return"path"in e?t.jsx(we,{item:e}):t.jsx(be,{item:e})}const Ee=({list:e})=>{const[n,r]=s.useState(""),[o,i]=s.useState(!1),a=s.useRef(null);return s.useEffect(()=>{const c=d=>{a.current&&!a.current.contains(d.target)&&i(!1)};return window.addEventListener("click",c),()=>window.removeEventListener("click",c)},[]),s.useEffect(()=>{const c=window.location.pathname,d=new URLSearchParams(window.location.search);e.forEach(l=>{("path"in l&&c===l.path||"slug"in l&&d.get("sort")===l.slug)&&r(l.title)})},[e]),t.jsxs("div",{className:"relative inline-block text-left text-light",ref:a,children:[t.jsxs("button",{type:"button",className:"inline-flex w-full justify-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-semibold shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-light/10",onClick:()=>{i(!o)},id:"menu-button","aria-haspopup":"true",children:[t.jsx("div",{children:n}),t.jsx("svg",{className:`-mr-1 h-5 w-5 text-gray-400 transform ${o?"rotate-180":""} transition-transform`,fill:"currentColor",viewBox:"0 0 20 20","aria-hidden":"true",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),o&&t.jsx("div",{className:"absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none overflow-hidden",onClick:()=>{i(!1)},children:t.jsx("div",{role:"menu","aria-orientation":"vertical","aria-labelledby":"menu-button",children:e.map((c,d)=>t.jsx(ye,{item:c},d))})})]})},Me=({categories:e,vendors:n,tags:r,maxPriceData:o,vendorsWithCounts:i,categoriesWithCounts:a})=>{const{getCollapseProps:c,getToggleProps:d,isExpanded:l,setExpanded:h}=ge(),[f,b]=s.useState(!1),k=Q(X),C=w=>{_(w==="list"?"list":"card")};return s.useEffect(()=>{const w=document.getElementById("searchInput");(f||new URLSearchParams(window.location.search).get("q"))&&w?.focus()},[f]),s.useEffect(()=>{const w=L=>{const y=L.target;!y.closest(".collapse-container-class")&&!y.closest(".filter-button-container")&&l&&h(!1),!y.closest("#searchInput")&&f&&b(!1)};return document.addEventListener("click",w),()=>document.removeEventListener("click",w)},[l,f]),t.jsx("section",{className:"pt-4",children:t.jsx("div",{className:"container",children:t.jsxs("div",{className:"row",children:[t.jsx("div",{className:"col-3 max-lg:hidden"}),t.jsx("div",{className:"col-12 lg:col-9",children:t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsxs("div",{className:"flex gap-x-4 items-center font-medium text-xs md:text-base",children:[t.jsx("p",{className:"max-md:hidden text-dark dark:text-darkmode-dark",children:"Views"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>C("card"),className:`btn border dark:border-darkmode-border ${k==="list"?"btn-outline-primary":"btn-primary"} p-2 hover:scale-105 duration-300`,children:t.jsx(Y,{})}),t.jsx("button",{onClick:()=>C("list"),className:`btn border dark:border-darkmode-border ${k==="list"?"btn-primary":"btn-outline-primary"} p-2 hover:scale-105 duration-300`,children:t.jsx(J,{})})]})]}),t.jsxs("div",{className:"flex gap-x-8",children:[t.jsx("div",{className:"filter-button-container block lg:hidden mt-1",children:t.jsx("button",{...d(),children:l?t.jsxs("span",{className:"font-medium text-base flex gap-x-1 items-center justify-center",children:[t.jsx(xe,{})," Filter"]}):t.jsxs("span",{className:"font-medium text-base flex gap-x-1 items-center justify-center",children:[t.jsx(ve,{})," Filter"]})})}),t.jsxs("div",{className:"flex gap-x-4 items-center font-medium text-sm md:text-base relative z-20",children:[t.jsx("p",{className:"max-md:hidden text-dark dark:text-darkmode-dark",children:"Sort By"}),t.jsx(Ee,{list:Z})]})]})]})}),t.jsx("div",{className:"col-12 lg:col-3",children:t.jsx("div",{className:"lg:block relative",children:t.jsx("div",{className:"block lg:hidden w-full",children:t.jsx("section",{className:"collapse-container-class z-20 bg-body dark:bg-darkmode-body w-full px-4 rounded-md",...c(),children:t.jsx("div",{className:"pb-8",children:t.jsx(ee,{categories:e,vendors:n,tags:r,maxPriceData:o,vendorsWithCounts:i,categoriesWithCounts:a})})})})})})]})})})};export{Me as default};
