{"version":3,"file":"WithSourceURL.CYZrIZBU.mjs","names":[],"sources":["https:/framerusercontent.com/modules/7ZfpyYgXqFDbjWnIio6O/SvzDhj41fRjcj9tY0ihW/WithSourceURL.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useLayoutEffect}from\"react\";export function withSourceURL(Component){return props=>{useLayoutEffect(()=>{const hideAndPopulate=()=>{// Always handle source_url fields\nconst sourceInputs=document.querySelectorAll('input[name=\"source_url\"], input[placeholder=\"source_url\"]');sourceInputs.forEach((input,index)=>{if(input){input.style.cssText=`\n                            display: none !important;\n                            visibility: hidden !important;\n                            position: absolute !important;\n                            left: -9999px !important;\n                            opacity: 0 !important;\n                            width: 0 !important;\n                            height: 0 !important;\n                        `;input.value=getSmartPageName(window.location.href);const label=input.closest(\"label\");if(label){label.style.cssText=`\n                                display: none !important;\n                                visibility: hidden !important;\n                                position: absolute !important;\n                                left: -9999px !important;\n                            `;}console.log(`Source URL field ${index+1} hidden and populated:`,getSmartPageName(window.location.href));}});// Always handle utm_campaign fields (hide them always)\nconst utmInputs=document.querySelectorAll('input[name=\"utm_campaign\"], input[placeholder=\"utm_campaign\"]');utmInputs.forEach((input,index)=>{if(input){input.style.cssText=`\n                            display: none !important;\n                            visibility: hidden !important;\n                            position: absolute !important;\n                            left: -9999px !important;\n                            opacity: 0 !important;\n                            width: 0 !important;\n                            height: 0 !important;\n                        `;// Only populate if UTM parameters exist\nif(hasUTMParameters(window.location.href)){input.value=getUTMData(window.location.href);console.log(`UTM Campaign field ${index+1} hidden and populated:`,getUTMData(window.location.href));}else{input.value=\"\"// Empty value for direct traffic\n;console.log(`UTM Campaign field ${index+1} hidden (no UTM data)`);}const label=input.closest(\"label\");if(label){label.style.cssText=`\n                                display: none !important;\n                                visibility: hidden !important;\n                                position: absolute !important;\n                                left: -9999px !important;\n                            `;}}});};hideAndPopulate();},[]);useEffect(()=>{const sourceInputs=document.querySelectorAll('input[name=\"source_url\"], input[placeholder=\"source_url\"]');sourceInputs.forEach(input=>{if(input&&input.style.display!==\"none\"){input.style.display=\"none\";input.value=getSmartPageName(window.location.href);}});const utmInputs=document.querySelectorAll('input[name=\"utm_campaign\"], input[placeholder=\"utm_campaign\"]');utmInputs.forEach(input=>{if(input&&input.style.display!==\"none\"){input.style.display=\"none\";if(hasUTMParameters(window.location.href)){input.value=getUTMData(window.location.href);}else{input.value=\"\";}}});},[]);return /*#__PURE__*/_jsx(Component,{...props});};}// Keep all your existing helper functions the same\nfunction hasUTMParameters(url){try{const urlObj=new URL(url);const params=new URLSearchParams(urlObj.search);const utmParams=[\"utm_source\",\"utm_medium\",\"utm_campaign\",\"utm_content\",\"utm_term\"];return utmParams.some(param=>params.has(param));}catch(error){return false;}}function getSmartPageName(url){try{const urlObj=new URL(url);let pathname=urlObj.pathname.replace(/^\\/+|\\/+$/g,\"\");if(!pathname||pathname===\"\")return\"Homepage\";if(!pathname.includes(\"/\")){return formatPageName(pathname);}const pathParts=pathname.split(\"/\");const lastPart=pathParts[pathParts.length-1];const parentPart=pathParts[pathParts.length-2];return`${formatPageName(parentPart)} - ${formatPageName(lastPart)}`;}catch(error){console.error(\"Error parsing URL:\",error);return\"Unknown Page\";}}function getUTMData(url){try{const urlObj=new URL(url);const params=new URLSearchParams(urlObj.search);const source=params.get(\"utm_source\")||\"\";const medium=params.get(\"utm_medium\")||\"\";const campaign=params.get(\"utm_campaign\")||\"\";const content=params.get(\"utm_content\")||\"\";const term=params.get(\"utm_term\")||\"\";let parts=[];if(source)parts.push(source);if(medium)parts.push(medium);if(campaign)parts.push(campaign);if(content)parts.push(content);if(term)parts.push(term);return parts.join(\"/\")||\"UTM_Present\";}catch(error){console.error(\"Error parsing UTM data:\",error);return\"UTM_Error\";}}function formatPageName(segment){if(!segment)return\"\";return segment.replace(/[-_]/g,\" \").replace(/\\b\\w/g,letter=>letter.toUpperCase()).replace(/\\bPr\\b/g,\"Puerto Rico\").replace(/\\bKy\\b/g,\"Cayman\").replace(/\\bUsa\\b/g,\"USA\").replace(/\\bUk\\b/g,\"UK\");}\nexport const __FramerMetadata__ = {\"exports\":{\"withSourceURL\":{\"type\":\"reactHoc\",\"name\":\"withSourceURL\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WithSourceURL.map"],"mappings":"2MAAwF,SAAgB,EAAc,EAAU,CAAC,MAAO,CAAA,IAAQ,EAAgB,IAAI,CAAC,IAAM,EAAgB,IAAI,CAC/L,IAAM,EAAa,SAAS,iBAAiB,4DAA4D,CAAC,EAAa,QAAQ,CAAC,EAAM,IAAQ,CAAC,GAAG,EAAM,CAQ9H,AAR+H,EAAM,MAAM,QAAA;;;;;;;;0BAQ3I,EAAM,MAAM,EAAiB,EAAO,SAAS,KAAK,CAAC,IAAM,EAAM,EAAM,QAAQ,QAAQ,CAKhF,AALoF,IAAO,EAAM,MAAM,QAAA;;;;;+BAKvG,QAAQ,KAAK,mBAAmB,EAAM,EAAE,wBAAwB,EAAiB,EAAO,SAAS,KAAK,CAAC,AAAE,CAAC,EAAC,CAC1I,IAAM,EAAU,SAAS,iBAAiB,gEAAgE,CAAC,EAAU,QAAQ,CAAC,EAAM,IAAQ,CAAC,GAAG,EAAM,CAStJ,AATuJ,EAAM,MAAM,QAAA;;;;;;;;0BAShK,EAAiB,EAAO,SAAS,KAAK,EAAE,EAAM,MAAM,EAAW,EAAO,SAAS,KAAK,CAAC,QAAQ,KAAK,qBAAqB,EAAM,EAAE,wBAAwB,EAAW,EAAO,SAAS,KAAK,CAAC,GAAO,EAAM,MAAM,GAC7M,QAAQ,KAAK,qBAAqB,EAAM,EAAE,uBAAuB,MAAQ,EAAM,EAAM,QAAQ,QAAQ,CAAC,AAAG,IAAO,EAAM,MAAM,QAAA;;;;;8BAK7F,CAAC,EAAC,AAAE,EAAC,GAAiB,AAAE,EAAC,CAAE,EAAC,CAAC,EAAU,IAAI,CAAC,IAAM,EAAa,SAAS,iBAAiB,4DAA4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