{"version":3,"file":"URLparameterAppender.eMoQPbda.mjs","names":[],"sources":["https:/framerusercontent.com/modules/VFguCZmubOf7i40mZ7m8/tmj0bme5csx1l2vYKtOd/URLparameterAppender.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect}from\"react\";export default function URLParameterAppender({enabled=true,localStorageKeys=\"email,firstName,lastName,phone\",dataLayerEventName=\"Form Submit\",delay=100}){useEffect(()=>{if(!enabled)return;const updateURL=()=>{try{// Helper function to clean quotes from values\nconst cleanValue=value=>{// Remove leading and trailing quotes (single or double)\nreturn value.replace(/^[\"']|[\"']$/g,\"\");};// Parse localStorage keys\nconst keys=localStorageKeys.split(\",\").map(key=>key.trim()).filter(Boolean);// Collect data from localStorage\nconst urlParams=new URLSearchParams(window.location.search);const newParams={};// Get localStorage values\nkeys.forEach(key=>{const value=localStorage.getItem(key);if(value&&!urlParams.has(key)){newParams[key]=cleanValue(value);}});// Get dataLayer values\nif(window.dataLayer&&Array.isArray(window.dataLayer)){// Find the most recent Form Submit event\nconst formSubmitEvents=window.dataLayer.filter(event=>event.event===dataLayerEventName);if(formSubmitEvents.length>0){const latestEvent=formSubmitEvents[formSubmitEvents.length-1];// Extract relevant fields\nkeys.forEach(key=>{if(latestEvent[key]&&!urlParams.has(key)&&!newParams[key]){newParams[key]=cleanValue(String(latestEvent[key]));}});}}// Only update URL if we have new parameters\nif(Object.keys(newParams).length>0){// Add new parameters to existing ones\nObject.entries(newParams).forEach(([key,value])=>{urlParams.set(key,value);});// Update URL without page reload\nconst newURL=`${window.location.pathname}?${urlParams.toString()}`;window.history.pushState({},\"\",newURL);}}catch(error){console.error(\"URLParameterAppender error:\",error);}};// Execute after delay\nconst timer=setTimeout(updateURL,delay);return()=>clearTimeout(timer);},[enabled,localStorageKeys,dataLayerEventName,delay]);// Return minimal div to ensure Framer recognizes the component\nreturn /*#__PURE__*/_jsx(\"div\",{style:{width:1,height:1,opacity:0,pointerEvents:\"none\"}});}URLParameterAppender.displayName=\"URL Parameter Appender\";addPropertyControls(URLParameterAppender,{enabled:{type:ControlType.Boolean,title:\"Enabled\",defaultValue:true},localStorageKeys:{type:ControlType.String,title:\"LocalStorage Keys\",defaultValue:\"email,firstName,lastName,phone\",description:\"Comma-separated list of localStorage keys to read\"},dataLayerEventName:{type:ControlType.String,title:\"DataLayer Event\",defaultValue:\"Form Submit\",description:\"Event name to search for in dataLayer\"},delay:{type:ControlType.Number,title:\"Delay (ms)\",defaultValue:100,min:0,max:5e3,step:100,description:\"Delay before appending parameters\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"URLParameterAppender\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./URLparameterAppender.map"],"mappings":"0SAA4H,SAAwB,EAAqB,CAAC,UAAQ,GAAK,mBAAiB,iCAAiC,qBAAmB,cAAc,QAAM,KAAK,CAarR,OAbsR,MAAc,CAAC,GAAG,CAAC,EAAQ,OAYjT,IAAM,EAAM,eAZgU,CAAC,GAAG,CAChV,IAAM,EAAW,GACV,EAAM,QAAQ,eAAe,GAAG,CACjC,EAAK,EAAiB,MAAM,IAAI,CAAC,IAAI,GAAK,EAAI,MAAM,CAAC,CAAC,OAAO,QAAQ,CACrE,EAAU,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAO,EAAU,EAAE,CAE9E,GADA,EAAK,QAAQ,GAAK,CAAC,IAAM,EAAM,aAAa,QAAQ,EAAI,CAAI,GAAO,CAAC,EAAU,IAAI,EAAI,GAAE,EAAU,GAAK,EAAW,EAAM,GAAI,CACzH,EAAO,WAAW,MAAM,QAAQ,EAAO,UAAU,CAAC,CACrD,IAAM,EAAiB,EAAO,UAAU,OAAO,GAAO,EAAM,QAAQ,EAAmB,CAAC,GAAG,EAAiB,OAAO,EAAE,CAAC,IAAM,EAAY,EAAiB,EAAiB,OA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