{"version":3,"file":"Filters.DFapYrw5.mjs","names":["React.useState","React.useMemo","React.useRef"],"sources":["https:/framerusercontent.com/modules/VbWziSGQRickAxLT0pXW/UsRpAREecxcTDOlY4Tv8/Filters.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{forwardRef}from\"react\";// Override that adds navigation and filters the collection using CSS\nexport const withInventoryFilter=Component=>{return /*#__PURE__*/forwardRef((props,ref)=>{const{soldField=\"Sold\",reservedValues=\"Reserved,Sold\",showCounts=false}=props;const[filter,setFilter]=React.useState(\"all\");const[allItems,setAllItems]=React.useState([]);const[isLoading,setIsLoading]=React.useState(true);const reservedSet=React.useMemo(()=>new Set(reservedValues.split(\",\").map(s=>s.trim().toLowerCase()).filter(Boolean)),[reservedValues]);// Use a ref to access the rendered component and count items\nconst componentRef=React.useRef(null);React.useEffect(()=>{// Simple, lightweight approach - just wait a bit then count once\nconst timer=setTimeout(()=>{if(componentRef.current){// Find collection items\nlet items=componentRef.current.querySelectorAll('a[href*=\"catalog\"]');if(items.length===0){const gridContainer=componentRef.current.querySelector(\".framer-sVa1h.framer-380oeo\");if(gridContainer){items=gridContainer.querySelectorAll(\"a, div[data-framer-name]\");}}// Filter to actual items\nconst itemsArray=Array.from(items).filter(item=>{const element=item;return element.tagName===\"A\"||element.tagName===\"DIV\"&&element.querySelector('a[href*=\"catalog\"]');});setAllItems(itemsArray);setIsLoading(false);}},500)// Single check after 500ms\n;return()=>clearTimeout(timer);},[]);const isReserved=item=>{// Look for reserved/sold indicators in the item's text content or attributes\nconst text=item.textContent?.toLowerCase()||\"\";const href=item.getAttribute(\"href\")||\"\";// Check if the item contains reserved/sold text\nreturn reservedSet.has(\"reserved\")&&text.includes(\"reserved\")||reservedSet.has(\"sold\")&&text.includes(\"sold\")||href.includes(\"reserved\")||href.includes(\"sold\");};const total=allItems.length;const reservedCount=allItems.reduce((count,item)=>count+(isReserved(item)?1:0),0);const availableCount=total-reservedCount;// Apply CSS filtering based on current filter\nReact.useEffect(()=>{if(!componentRef.current)return;// Use the same improved selectors for filtering\nlet items=componentRef.current.querySelectorAll('a[href*=\"catalog\"]');if(items.length===0){const gridContainer=componentRef.current.querySelector(\".framer-sVa1h.framer-380oeo\");if(gridContainer){items=gridContainer.querySelectorAll(\"a, div[data-framer-name]\");}}// Filter to only actual collection items\nconst filteredItems=Array.from(items).filter(item=>{const element=item;return element.tagName===\"A\"||element.tagName===\"DIV\"&&element.querySelector('a[href*=\"catalog\"]');});filteredItems.forEach(item=>{const element=item;const isItemReserved=isReserved(item);if(filter===\"all\"){element.style.display=\"\";}else if(filter===\"reserved\"){element.style.display=isItemReserved?\"\":\"none\";}else if(filter===\"available\"){element.style.display=!isItemReserved?\"\":\"none\";}});},[filter,allItems,reservedSet]);// Navigation component with counts\nconst Navigation=()=>/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap:12,padding:\"16px 0\",marginBottom:\"20px\",borderBottom:\"1px solid rgba(255,255,255,0.1)\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",gap:12},children:[\"all\",\"available\",\"reserved\"].map(f=>{let count=0;if(f===\"all\")count=total;else if(f===\"reserved\")count=reservedCount;else if(f===\"available\")count=availableCount;return /*#__PURE__*/_jsxs(\"button\",{onClick:()=>setFilter(f),disabled:isLoading,style:{padding:\"8px 16px\",borderRadius:20,border:\"1px solid rgba(255,255,255,0.3)\",background:filter===f?\"rgba(0,0,0,0.8)\":\"rgba(0,0,0,0.1)\",color:filter===f?\"white\":\"rgba(0,0,0,0.8)\",cursor:isLoading?\"default\":\"pointer\",fontSize:12,fontFamily:\"Inter, -apple-system, BlinkMacSystemFont, sans-serif\",fontWeight:500,display:\"flex\",alignItems:\"center\",gap:6,transition:\"all 0.2s ease\",opacity:isLoading?.6:1},children:[f[0].toUpperCase()+f.slice(1),showCounts&&/*#__PURE__*/_jsx(\"span\",{style:{opacity:.7},children:isLoading?\"(...)\":`(${count})`})]},f);})}),isLoading&&/*#__PURE__*/_jsx(\"div\",{style:{fontSize:11,color:\"rgba(0,0,0,0.7)\",fontFamily:\"Inter, sans-serif\",marginTop:4},children:\"Loading collection...\"})]});return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\"},children:[/*#__PURE__*/_jsx(Navigation,{}),/*#__PURE__*/_jsx(\"div\",{ref:componentRef,children:/*#__PURE__*/_jsx(Component,{ref:ref,...props,style:{...props?.style}})})]});});};function Stat({label,value}){return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",gap:6,alignItems:\"center\"},children:[/*#__PURE__*/_jsxs(\"span\",{style:{opacity:.7,color:\"rgba(255,255,255,0.7)\"},children:[label,\":\"]}),/*#__PURE__*/_jsx(\"strong\",{style:{color:\"white\",fontSize:16},children:value})]});}// Property controls for the override\naddPropertyControls(withInventoryFilter,{soldField:{type:ControlType.String,title:\"Sold field\",defaultValue:\"Sold\"},reservedValues:{type:ControlType.String,title:\"Reserved values\",defaultValue:\"Reserved,Sold\"},showCounts:{type:ControlType.Boolean,title:\"Show counters\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"withInventoryFilter\":{\"type\":\"reactHoc\",\"name\":\"withInventoryFilter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Filters.map"],"mappings":"2TAAyD,IAA4B,IAAoD,CAC5H,EAAoB,GAAgC,GAAY,EAAM,IAAM,CAAC,GAAK,CAAC,YAAU,OAAO,iBAAe,gBAAgB,aAAW,IAAO,EAAW,CAAC,EAAO,GAAWA,EAAe,MAAM,CAAM,CAAC,EAAS,GAAaA,EAAe,EAAE,CAAC,CAAM,CAAC,EAAU,GAAcA,EAAe,GAAK,CAAO,EAAYC,MAAkB,IAAI,IAAI,EAAe,MAAM,IAAI,CAAC,IAAI,GAAG,EAAE,MAAM,CAAC,aAAa,CAAC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