{"version":3,"file":"CarryOverButtonTextAsUTM.b2EM3fFf.mjs","names":["__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/sLufP6l3FlDOOaVTnwQD/O017qGhHFRPo1L35cDYd/CarryOverButtonTextAsUTM.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";function getUtmContent(element){return(element.innerText||element.textContent||\"\").toLowerCase().trim().replace(/\\s+/g,\"-\").replace(/[^a-z0-9-]/g,\"\");}function shouldCarryParam(key){return key.startsWith(\"utm_\")||key===\"fbclid\"||key===\"gclid\"||key===\"msclkid\";}export function buildTrackedUrl(link,fallbackUtmSource,utmContent){const url=new URL(link,window.location.origin);const currentParams=new URLSearchParams(window.location.search);const internal=url.hostname===window.location.hostname||[\"gametheory.in\",\"www.gametheory.in\"].includes(url.hostname);const currentSource=(currentParams.get(\"utm_source\")||\"\").toLowerCase();const selfTagged=[\"gametheory.in\",\"www.gametheory.in\"].includes(currentSource);// Internal navigation must not start a new acquisition campaign.\nif(internal){for(const key of Array.from(url.searchParams.keys())){if(shouldCarryParam(key))url.searchParams.delete(key);}}for(const[key,value]of currentParams.entries()){if(!shouldCarryParam(key))continue;if(selfTagged&&key.startsWith(\"utm_\"))continue;if(!url.searchParams.has(key))url.searchParams.set(key,value);}if(internal){if(utmContent)url.searchParams.set(\"internal_cta\",utmContent);url.searchParams.set(\"internal_referrer\",window.location.pathname);}else{if(!url.searchParams.has(\"utm_source\")&&fallbackUtmSource){url.searchParams.set(\"utm_source\",fallbackUtmSource);}if(!url.searchParams.has(\"utm_content\")&&utmContent){url.searchParams.set(\"utm_content\",utmContent);}}return url.toString();}// Code Component version\nexport function CarryOverButtonTextasUTM(props){const{children,utmSource=\"\",link,openInNewTab=false}=props;const handleClick=e=>{e.preventDefault();const utmContent=getUtmContent(e.currentTarget);const newUrl=buildTrackedUrl(link,utmSource,utmContent);if(openInNewTab){window.open(newUrl,\"_blank\");}else{window.location.href=newUrl;}};return /*#__PURE__*/_jsx(\"div\",{onClick:handleClick,style:{cursor:\"pointer\",width:\"100%\",height:\"100%\"},children:children});}addPropertyControls(CarryOverButtonTextasUTM,{link:{type:ControlType.String,title:\"Link URL\",placeholder:\"https://gametheory.in/page\"},utmSource:{type:ControlType.String,title:\"UTM Source\",defaultValue:\"\",placeholder:\"e.g. email, whatsapp\"},openInNewTab:{type:ControlType.Boolean,title:\"Open in New Tab\",defaultValue:false}});// Preserve acquisition on internal links; identify website referrals to external destinations.\nexport function WebsiteUTM(){return{onClick:e=>{e.preventDefault();const linkElement=e.target.closest(\"a\");const link=linkElement?.getAttribute(\"href\");if(!link){console.error(\"No link found on element\");return;}const utmContent=getUtmContent(e.currentTarget);const newUrl=buildTrackedUrl(link,\"gametheory.in\",utmContent);const target=linkElement?.getAttribute(\"target\");if(target===\"_blank\"){window.open(newUrl,\"_blank\");}else{window.location.href=newUrl;}}};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withWebsiteUTM(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...WebsiteUTM(props)});};}withWebsiteUTM.displayName=\"WebsiteUTM\";\nexport const __FramerMetadata__ = {\"exports\":{\"CarryOverButtonTextasUTM\":{\"type\":\"reactComponent\",\"name\":\"CarryOverButtonTextasUTM\",\"slots\":[\"children\"],\"annotations\":{\"framerContractVersion\":\"1\"}},\"WebsiteUTM\":{\"type\":\"override\",\"name\":\"WebsiteUTM\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withWebsiteUTM\":{\"type\":\"reactHoc\",\"name\":\"withWebsiteUTM\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"buildTrackedUrl\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CarryOverButtonTextAsUTM.map"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