{"version":3,"file":"FC_CatalogResultCounter.C6howTPZ.mjs","names":["useState","transform"],"sources":["https:/framerusercontent.com/modules/Uua6HH41VQEb0xszmKqn/FNuqrhvI3eUEvq6YuFtE/FC_CatalogResultCounter.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 * © 2025 Butter Supply Inc. All Rights Reserved.\n */import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useState}from\"react\";/**\n * @framerIntrinsicWidth 100%\n * @framerIntrinsicHeight auto\n * @framerSupportedLayoutWidth fixed | fill\n * @framerSupportedLayoutHeight fixed | auto\n */// Helper function for consistent logging\nconst logDebug=(component,action,data)=>{console.log(`🔍 [${component}] ${action}:`,data);};/**\n * @framerDisableUnlink\n */export default function FC_CatalogResultCounter(props){const{content,font,color,transform}=props;// State for search term and result count\nconst[searchTerm,setSearchTerm]=useState(\"\");const[resultCount,setResultCount]=useState(0);// Detect if we're in canvas\nconst isCanvas=()=>{if(typeof window===\"undefined\")return false;try{return window.document?.location?.href.includes(\"framer\")||window.document?.location?.pathname.includes(\"preview\")||!window.document?.location?.host||window.parent!==window;}catch(e){return true;}};// Apply text transform\nconst getTransformedText=(text,transform)=>{switch(transform){case\"Uppercase\":return text.toUpperCase();case\"Lowercase\":return text.toLowerCase();case\"Capitalize\":return text.split(\" \").map(word=>word.charAt(0).toUpperCase()+word.slice(1).toLowerCase()).join(\" \");default:return text;}};// Replace placeholders with actual values\nconst getFormattedText=text=>{const term=isCanvas()&&!searchTerm?\"term\":searchTerm;return text.replace(/\\{\\{term\\}\\}/g,term).replace(/\\{\\{\\#\\}\\}/g,resultCount.toString());};// Get the appropriate text content based on state\nconst getDisplayText=()=>{return content;};// Listen for search events\nuseEffect(()=>{const handleSearchChange=e=>{logDebug(\"SearchResults\",\"Received search event\",e.detail);// Handle different event types\nconst term=e.detail.term||e.detail.search;setSearchTerm(term);if(e.detail.term===\"\"&&e.detail.count){setResultCount(e.detail.count);}};const handleResultsChange=e=>{logDebug(\"SearchResults\",\"Received results count\",e.detail);setResultCount(e.detail.count||0);if(e.detail.search===\"\"){setResultCount(e.detail.count);}};// Check URL for initial search term\nconst updateSearchFromURL=()=>{if(typeof window!==\"undefined\"){const urlParams=new URLSearchParams(window.location.search);const searchParam=urlParams.get(\"search\");if(searchParam){setSearchTerm(searchParam);}}};// Initial URL check\nupdateSearchFromURL();// Listen for URL changes\nwindow.addEventListener(\"popstate\",updateSearchFromURL);// Listen for all search-related events\ndocument.addEventListener(\"product-search-change\",handleSearchChange);document.addEventListener(\"product-search-results\",handleSearchChange);document.addEventListener(\"filter-navigation\",handleSearchChange);document.addEventListener(\"product-search-results\",handleResultsChange);return()=>{window.removeEventListener(\"popstate\",updateSearchFromURL);document.removeEventListener(\"product-search-change\",handleSearchChange);document.removeEventListener(\"filter-navigation\",handleSearchChange);document.removeEventListener(\"product-search-results\",handleResultsChange);};},[]);// Container style\nconst containerStyle={width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\"};// Text style\nconst textStyle={...font,color:color,textTransform:transform.toLowerCase()};return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,children:/*#__PURE__*/_jsx(\"span\",{style:textStyle,children:getTransformedText(getFormattedText(getDisplayText()),transform)})});}FC_CatalogResultCounter.defaultProps={content:\"{{#}} items\",font:{family:\"Inter\",fontSize:16,weight:400},color:\"#000000\",transform:\"None\"};addPropertyControls(FC_CatalogResultCounter,{content:{type:ControlType.String,title:\"Text\",defaultValue:\"{{#}} items\",description:\"Use {{#}} for item count. \\n \\n If on a dedicated Search page, use {{term}} for the search value.\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},transform:{type:ControlType.Enum,title:\"Transform\",options:[\"None\",\"Uppercase\",\"Lowercase\",\"Capitalize\"],defaultValue:\"None\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FC_CatalogResultCounter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FC_CatalogResultCounter.map"],"mappings":"0LAyCG,SAAwB,EAAwB,EAAM,CAAC,GAAK,CAAC,UAAQ,OAAK,QAAM,aAAW,EACzF,CAAC,EAAW,GAAeA,EAAS,GAAG,CAAM,CAAC,EAAY,GAAgBA,EAAS,EAAE,CACpF,MAAa,CAAC,GAAU,IAAS,OAAY,MAAO,GAAM,GAAG,CAAC,OAAO,EAAO,UAAU,UAAU,KAAK,SAAS,SAAS,EAAE,EAAO,UAAU,UAAU,SAAS,SAAS,UAAU,EAAE,CAAC,EAAO,UAAU,UAAU,MAAM,EAAO,SAAS,OAAgB,CAAC,MAAO,KAC5P,GAAoB,EAAK,IAAY,CAAC,OAAOC,EAAP,CAAkB,IAAI,YAAY,OAAO,EAAK,aAAa,CAAC,IAAI,YAAY,OAAO,EAA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