{"version":3,"file":"BlogHelpers.XgqO6S4_.mjs","names":["useState","blogContent","__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/rW8YoV64sTcSTVvIJWd5/izCgZNvFsM2Izr8F3sVe/BlogHelpers.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{Data}from\"framer\";import{useState}from\"react\";// ADD CLASS NAME TO OBJECT\nexport function withClass(Component){return props=>{props.className+=\" blog-tag\"// Remember to add a space\n;return /*#__PURE__*/_jsx(Component,{...props});};}// CHANGE COMPONENT VARIANT BASED ON URL PARAMETER\n// Create a Data object to store the current variant\nconst store=Data({currentVariant:\"default\"});// Function to update the variant based on URL\nfunction updateVariantFromURL(){const urlParams=new URLSearchParams(window.location.search);const urlVariant=urlParams.get(\"variant\");if(urlVariant){store.currentVariant=urlVariant;}}// Call this function when the component mounts\nif(typeof window!==\"undefined\"){updateVariantFromURL();// Optional: Listen for URL changes\nwindow.addEventListener(\"popstate\",updateVariantFromURL);}export function VariantOverride(){return{variant:store.currentVariant};}// APPEND URL PARAMETER TO LINK BASED ON TAG SLUG PROP\nexport function AppendUrlParameter(props){return{onTap(event){// Prevent the default link navigation\nevent.preventDefault();// Define the target link (e.g., from a component or hardcoded)\nconst targetLink=\"https://www.carbon-direct.com/insights\";// Define the parameter key\nconst paramKey=\"variant\";// Get the slug value from props\nconst paramValue=props.slug||\"view-all\"// Fallback to a default value\n;const anchor=\"#feed\";// Create a new URL object\nconst newUrl=new URL(targetLink);// Append or update the parameter\nnewUrl.searchParams.set(paramKey,paramValue);newUrl.hash=anchor;// Navigate to the new URL\nwindow.location.href=newUrl.toString();}};}export function ScrollToAnchor(){return{onLoad:()=>{setTimeout(()=>{if(window.location.hash){const target=document.querySelector(window.location.hash);if(target){target.scrollIntoView({behavior:\"smooth\",block:\"start\"});}}},100)// Small delay to ensure elements are rendered\n;}};}// REMOVE PARAMETER TO CURRENT URL ON CLICK\nexport function RemoveParameter(){return{onTap:()=>{const url=new URL(window.location.href);url.searchParams.delete(\"variant\");window.history.replaceState({},\"\",url.toString());}};}// HIDE SIDE NAV IF THERE AREN'T ANY H2S OR H3S IN THE BLOG CONTENT\nexport function HideIfNoHeadings(){const[isVisible,setIsVisible]=useState(true);useEffect(()=>{const checkHeadings=()=>{const blogContent=document.querySelector(\"#blog-content\");if(blogContent){const hasHeadings=blogContent.querySelectorAll(\"h2, h3\").length>0;setIsVisible(hasHeadings);}else{setIsVisible(false);}};// Run on mount\ncheckHeadings();// Set up observer\nconst observer=new MutationObserver(()=>{checkHeadings();});const blogContent=document.querySelector(\"#blog-content\");if(blogContent){observer.observe(blogContent,{childList:true,subtree:true});}return()=>observer.disconnect();},[]);return{style:{display:isVisible?\"block\":\"none\"}};}// FIX FILTERING ON MOBILE\nexport function FixDropdown(){return{onPointerDown:event=>{event.preventDefault()// Prevents focus conflicts\n;event.stopPropagation()// Prevents event bubbling issues\n;const dropdownMenu=document.querySelector(\".framer-a4IS0\");if(dropdownMenu){dropdownMenu.classList.toggle(\"open\");}},onFocus:event=>{event.preventDefault()// Prevents focus-based triggering\n;}};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withVariantOverride(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...VariantOverride(props)});};}withVariantOverride.displayName=\"VariantOverride\";export function withAppendUrlParameter(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...AppendUrlParameter(props)});};}withAppendUrlParameter.displayName=\"AppendUrlParameter\";export function withScrollToAnchor(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...ScrollToAnchor(props)});};}withScrollToAnchor.displayName=\"ScrollToAnchor\";export function withRemoveParameter(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...RemoveParameter(props)});};}withRemoveParameter.displayName=\"RemoveParameter\";export function withHideIfNoHeadings(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...HideIfNoHeadings(props)});};}withHideIfNoHeadings.displayName=\"HideIfNoHeadings\";export function withFixDropdown(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...FixDropdown(props)});};}withFixDropdown.displayName=\"FixDropdown\";\nexport const __FramerMetadata__ = {\"exports\":{\"FixDropdown\":{\"type\":\"override\",\"name\":\"FixDropdown\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withHideIfNoHeadings\":{\"type\":\"reactHoc\",\"name\":\"withHideIfNoHeadings\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFixDropdown\":{\"type\":\"reactHoc\",\"name\":\"withFixDropdown\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAppendUrlParameter\":{\"type\":\"reactHoc\",\"name\":\"withAppendUrlParameter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withScrollToAnchor\":{\"type\":\"reactHoc\",\"name\":\"withScrollToAnchor\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"AppendUrlParameter\":{\"type\":\"override\",\"name\":\"AppendUrlParameter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ScrollToAnchor\":{\"type\":\"override\",\"name\":\"ScrollToAnchor\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"HideIfNoHeadings\":{\"type\":\"override\",\"name\":\"HideIfNoHeadings\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withVariantOverride\":{\"type\":\"reactHoc\",\"name\":\"withVariantOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRemoveParameter\":{\"type\":\"reactHoc\",\"name\":\"withRemoveParameter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"RemoveParameter\":{\"type\":\"override\",\"name\":\"RemoveParameter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withClass\":{\"type\":\"reactHoc\",\"name\":\"withClass\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"VariantOverride\":{\"type\":\"override\",\"name\":\"VariantOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BlogHelpers.map"],"mappings":"mTACA,SAAgB,EAAU,EAAU,CAAC,MAAO,KAAQ,EAAM,WAAW,YAChD,EAAK,EAAU,CAAC,GAAG,EAAM,EAAK,CAGnD,SAAS,GAAsB,CAAC,IAAM,EAAU,IAAI,gBAAgB,EAAO,SAAS,QAAc,EAAW,EAAU,IAAI,WAAc,IAAY,EAAM,eAAe,EAAa,CAE7H,SAAgB,GAAiB,CAAC,MAAM,CAAC,QAAQ,EAAM,eAAe,AAAE,CAClI,SAAgB,EAAmB,EAAM,CAAC,MAAM,CAAC,MAAM,EAAM,CAC7D,EAAM,iBACN,IAEM,EAAW,EAAM,MAAM,WAEvB,EAAO,IAAI,IAAI,0CACrB,EAAO,aAAa,IAAI,UAAS,GAAY,EAAO,KAAK,QACzD,EAAO,SAAS,KAAK,EAAO,UAAY,EAAC,AAAE,UAAgB,GAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG,EAAO,SAAS,KAAK,CAAC,IAAM,EAAO,SAAS,cAAc,EAAO,SAAS,MAAS,GAAQ,EAAO,eAAe,CAAC,SAAS,SAAS,MAAM,QAAQ,CAAI,CAAC,EAAC,IACxQ,EAAC,AAAE,CACL,SAAgB,GAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,IAAM,EAAI,IAAI,IAAI,EAAO,SAAS,MAAM,EAAI,aAAa,OAAO,WAAW,EAAO,QAAQ,aAAa,EAAE,CAAC,GAAG,EAAI,WAAa,EAAC,AAAE,CACrL,SAAgB,GAAkB,CAAC,GAAK,CAAC,EAAU,EAAa,CAACA,EAAS,IAE+J,OAFzJ,MA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