{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/OOFOW5xBl7UsXk1dpKpb/v927zVAaw2LsCUIGB54f/FC_CatalogSortDropdown.js"],
  "sourcesContent": ["/*\n * Framer Commerce\n * Confidential and Proprietary - All Rights Reserved\n * Unauthorized use, reproduction, distribution, or disclosure of this\n * source code or any related information is strictly prohibited.\n *\n * This software is the exclusive property of Framer Commerce (\"Company\").\n * It is considered highly confidential and proprietary information.\n *\n * Any use, copying, modification, distribution, or sharing of this software,\n * in whole or in part, without the express written permission of the Company\n * is strictly prohibited and may result in legal action.\n *\n * DISCLAIMER: This software does not provide any express or\n * implied warranties, including, but not limited to, the implied warranties\n * of merchantability and fitness for a particular purpose. In no event shall\n * Framer Commerce be liable for any direct, indirect, incidental, special,\n * exemplary, or consequential damages (including, but not limited to, procurement\n * of substitute goods or services; loss of use, data, or profits; or business\n * interruption) however caused and on any theory of liability, whether in\n * contract, strict liability, or tort (including negligence or otherwise)\n * arising in any way out of the use of this software, even if advised of\n * the possibility of such damage.\n *\n * Any unauthorized possession, use, copying, distribution, or dissemination\n * of this software will be considered a breach of confidentiality and may\n * result in legal action.\n *\n * For inquiries, contact:\n * Framer Commerce\n * Email: hello@framercommerce.com\n *\n * \u00A9 2025 Butter Supply Inc. All Rights Reserved.\n */import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n */export default function FC_CatalogSortDropdown(props){const{DropdownVisual,relevanceText=\"Relevance\",titleAscText=\"A-Z\",titleDescText=\"Z-A\",priceAscText=\"Price (lowest first)\",priceDescText=\"Price (highest first)\",newestText=\"Newest\",bestSellingText=\"Best Selling\",defaultSort=\"relevance\"}=props;const dropdownRef=React.useRef(null);const[currentSort,setCurrentSort]=React.useState(defaultSort);const handleClick=()=>{if(dropdownRef.current){dropdownRef.current.focus();const event=new MouseEvent(\"mousedown\",{bubbles:true,cancelable:true,view:window});dropdownRef.current.dispatchEvent(event);}};// Map internal sort values to display text\nconst sortOptions=React.useMemo(()=>{return[{value:\"relevance\",text:relevanceText},{value:\"title_asc\",text:titleAscText},{value:\"title_desc\",text:titleDescText},{value:\"price_asc\",text:priceAscText},{value:\"price_desc\",text:priceDescText},{value:\"newest\",text:newestText},{value:\"best_selling\",text:bestSellingText}].filter(option=>option.text)// Filter out options with empty text\n;},[relevanceText,titleAscText,titleDescText,priceAscText,priceDescText,newestText,bestSellingText]);// Get the current sort text\nconst getCurrentSortText=React.useCallback(()=>{const option=sortOptions.find(opt=>opt.value===currentSort);return option?.text||relevanceText;},[currentSort,sortOptions,relevanceText]);// Helper function to update text content with {{param}}\nconst updateButtonContent=element=>{if(!element||typeof element!==\"object\")return element;// Handle arrays\nif(Array.isArray(element)){return element.map(child=>updateButtonContent(child));}if(!/*#__PURE__*/React.isValidElement(element))return element;const{children,...otherProps}=element.props;// Special handling for Framer Text components\nif(element.type?.displayName?.includes(\"Text\")){const text=element.props.text||\"\";const newText=text.replace(/{{param}}/g,getCurrentSortText());return /*#__PURE__*/React.cloneElement(element,{...otherProps,text:newText});}// Handle children recursively\nlet newChildren=children;if(children){if(typeof children===\"string\"){newChildren=children.replace(/{{param}}/g,getCurrentSortText());}else if(/*#__PURE__*/React.isValidElement(children)||Array.isArray(children)){newChildren=updateButtonContent(children);}}return /*#__PURE__*/React.cloneElement(element,{...otherProps,children:newChildren});};// Handle sort change\nconst handleSortChange=React.useCallback(e=>{const value=e.target.value;setCurrentSort(value);// Save to session storage\nif(typeof window!==\"undefined\"){sessionStorage.setItem(\"sortBy\",value);}// Map URL sort parameter to internal sort configuration\nlet sortConfig;switch(value){case\"relevance\":sortConfig={type:\"relevancy\",sortBy:\"relevancy\",sortDirection:null};break;case\"title_asc\":sortConfig={type:\"name\",sortBy:\"name\",sortDirection:\"aToZ\"};break;case\"title_desc\":sortConfig={type:\"name\",sortBy:\"name\",sortDirection:\"zToA\"};break;case\"price_asc\":sortConfig={type:\"price\",sortBy:\"price\",sortDirection:\"lowToHigh\"};break;case\"price_desc\":sortConfig={type:\"price\",sortBy:\"price\",sortDirection:\"highToLow\"};break;case\"newest\":sortConfig={type:\"created\",sortBy:\"created\",sortDirection:\"newest\"};break;case\"best_selling\":sortConfig={type:\"best-selling\",sortBy:\"best-selling\",sortDirection:null};break;}// Update URL with sort parameter\nif(typeof window!==\"undefined\"){const url=new URL(window.location.href);url.searchParams.set(\"sort\",value);window.history.pushState({sortConfig},\"\",url.toString());}// Dispatch sort change event\ndocument.dispatchEvent(new CustomEvent(\"product-sort-change\",{detail:sortConfig}));},[]);// Update sort value from URL on mount and URL changes\nReact.useEffect(()=>{if(typeof window===\"undefined\")return;const updateSortFromUrl=()=>{const urlParams=new URLSearchParams(window.location.search);const sortParam=urlParams.get(\"sort\");// First check URL\nif(sortParam&&sortOptions.some(option=>option.value===sortParam)){setCurrentSort(sortParam);sessionStorage.setItem(\"sortBy\",sortParam);}else{const storedSort=sessionStorage.getItem(\"sortBy\");if(storedSort&&sortOptions.some(option=>option.value===storedSort)){setCurrentSort(storedSort);// Update URL to match session storage\nconst url=new URL(window.location.href);url.searchParams.set(\"sort\",storedSort);window.history.pushState({sort:storedSort},\"\",url.toString());}}};updateSortFromUrl();window.addEventListener(\"popstate\",updateSortFromUrl);return()=>{window.removeEventListener(\"popstate\",updateSortFromUrl);};},[sortOptions]);return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\",cursor:\"pointer\"},onClick:handleClick,children:[/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",pointerEvents:\"none\"},children:updateButtonContent(DropdownVisual)}),/*#__PURE__*/_jsx(\"select\",{ref:dropdownRef,value:currentSort,onChange:handleSortChange,style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",opacity:0,cursor:\"pointer\"},children:sortOptions.map(option=>/*#__PURE__*/_jsx(\"option\",{value:option.value,children:option.text},option.value))})]});}addPropertyControls(FC_CatalogSortDropdown,{DropdownVisual:{type:ControlType.ComponentInstance,title:\"Component\",description:\"Connect to native Framer component, on-canvas but off-page. Use {{param}} in text to show the current sort option\"},defaultSort:{type:ControlType.Enum,title:\"Default Sort\",options:[\"relevance\",\"title_asc\",\"title_desc\",\"price_asc\",\"price_desc\",\"newest\",\"best_selling\"],optionTitles:[\"Relevance\",\"Title A-Z\",\"Title Z-A\",\"Price Low-High\",\"Price High-Low\",\"Newest\",\"Best Selling\"],defaultValue:\"relevance\"},relevanceText:{type:ControlType.String,title:\"Relevance\",defaultValue:\"Relevance\"},titleAscText:{type:ControlType.String,title:\"Title (A-Z)\",defaultValue:\"A-Z\"},titleDescText:{type:ControlType.String,title:\"Title (Z-A)\",defaultValue:\"Z-A\"},priceAscText:{type:ControlType.String,title:\"Price (Low)\",defaultValue:\"Price (lowest first)\"},priceDescText:{type:ControlType.String,title:\"Price (High)\",defaultValue:\"Price (highest first)\"},newestText:{type:ControlType.String,title:\"Newest\",defaultValue:\"Newest\"},bestSellingText:{type:ControlType.String,title:\"Best Selling\",defaultValue:\"Best Selling\",description:\"Empty fields won't be displayed\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FC_CatalogSortDropdown\",\"slots\":[\"DropdownVisual\"],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FC_CatalogSortDropdown.map"],
  "mappings": "qLAmCkB,SAARA,EAAwCC,EAAM,CAAC,GAAK,CAAC,eAAAC,EAAe,cAAAC,EAAc,YAAY,aAAAC,EAAa,MAAM,cAAAC,EAAc,MAAM,aAAAC,EAAa,uBAAuB,cAAAC,EAAc,wBAAwB,WAAAC,EAAW,SAAS,gBAAAC,EAAgB,eAAe,YAAAC,EAAY,WAAW,EAAET,EAAYU,EAAkBC,EAAO,IAAI,EAAO,CAACC,EAAYC,CAAc,EAAQC,EAASL,CAAW,EAA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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAACsB,EAAoB3C,EAAuB,CAAC,eAAe,CAAC,KAAK4C,EAAY,kBAAkB,MAAM,YAAY,YAAY,mHAAmH,EAAE,YAAY,CAAC,KAAKA,EAAY,KAAK,MAAM,eAAe,QAAQ,CAAC,YAAY,YAAY,aAAa,YAAY,aAAa,SAAS,cAAc,EAAE,aAAa,CAAC,YAAY,YAAY,YAAY,iBAAiB,iBAAiB,SAAS,cAAc,EAAE,aAAa,WAAW,EAAE,cAAc,CAAC,KAAKA,EAAY,OAAO,MAAM,YAAY,aAAa,WAAW,EAAE,aAAa,CAAC,KAAKA,EAAY,OAAO,MAAM,cAAc,aAAa,KAAK,EAAE,cAAc,CAAC,KAAKA,EAAY,OAAO,MAAM,cAAc,aAAa,KAAK,EAAE,aAAa,CAAC,KAAKA,EAAY,OAAO,MAAM,cAAc,aAAa,sBAAsB,EAAE,cAAc,CAAC,KAAKA,EAAY,OAAO,MAAM,eAAe,aAAa,uBAAuB,EAAE,WAAW,CAAC,KAAKA,EAAY,OAAO,MAAM,SAAS,aAAa,QAAQ,EAAE,gBAAgB,CAAC,KAAKA,EAAY,OAAO,MAAM,eAAe,aAAa,eAAe,YAAY,iCAAiC,CAAC,CAAC",
  "names": ["FC_CatalogSortDropdown", "props", "DropdownVisual", "relevanceText", "titleAscText", "titleDescText", "priceAscText", "priceDescText", "newestText", "bestSellingText", "defaultSort", "dropdownRef", "pe", "currentSort", "setCurrentSort", "ye", "handleClick", "event", "window", "sortOptions", "se", "option", "getCurrentSortText", "te", "opt", "updateButtonContent", "element", "child", "J", "children", "otherProps", "newText", "q", "newChildren", "handleSortChange", "value", "sortConfig", "url", "ue", "updateSortFromUrl", "sortParam", "storedSort", "u", "addPropertyControls", "ControlType"]
}
