{"version":3,"file":"Featherly_Form.CI3dgWCb.mjs","names":[],"sources":["https:/framerusercontent.com/modules/AEs6o6tWYh2g8WSoxbwa/GyEmzPlMEHGW5btPWTMu/Featherly_Form.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function FeatheryForm({url,practiceFieldName=\"practice\"}){useEffect(()=>{console.log(\"=== FEATHERY FORM COMPONENT MOUNTED ===\");console.log(\"Initial url prop:\",url);console.log(\"Practice field name:\",practiceFieldName);if(typeof window===\"undefined\"||typeof document===\"undefined\"){console.log(\"Window or document is undefined, exiting\");return;}console.log(\"Window and document are available\");// Extract practice parameter from URL prop and add it to current page URL\nconst formIdToUse=\"LR4dz0\"// Always use this form ID\n;console.log(\"Using form ID:\",formIdToUse);let shouldUpdateUrl=false;const currentParams=new URLSearchParams(window.location.search);if(url){console.log(\"URL prop provided:\",url);try{const urlObj=new URL(url,window.location.origin);console.log(\"Parsed URL object:\",urlObj.href);console.log(\"URL search params:\",urlObj.search);const practiceParam=urlObj.searchParams.get(\"practice\");console.log(\"Extracted practice parameter:\",practiceParam);if(practiceParam&&!currentParams.has(practiceFieldName)){// Only add practice param if it does not already exist\ncurrentParams.set(practiceFieldName,practiceParam);shouldUpdateUrl=true;console.log(\"Practice parameter will be added to URL\");}else if(practiceParam){console.log(\"Practice parameter already exists in URL, skipping\");}else{console.log(\"No practice parameter found in URL\");}}catch(err){console.error(\"Failed parsing URL:\",err);}}else{console.log(\"No URL prop provided\");}// Handle referrer params\nconst referrer=document.referrer;console.log(\"Document referrer:\",referrer);if(referrer.includes(\"cornerhealth.com\")){console.log(\"Referrer is from cornerhealth.com, merging params\");try{const refUrl=new URL(referrer);console.log(\"Parsed referrer URL:\",refUrl.href);// merge prior params into current ones\nrefUrl.searchParams.forEach((value,key)=>{console.log(`Checking param: ${key}=${value}`);if(!currentParams.has(key)){currentParams.set(key,value);shouldUpdateUrl=true;console.log(`Added param: ${key}=${value}`);}else{console.log(`Param ${key} already exists, skipping`);}});console.log(\"Merged params:\",currentParams.toString());}catch(err){console.error(\"Failed parsing referrer:\",err);}}else{console.log(\"Referrer is not from cornerhealth.com, skipping param merge\");}// Only update URL if we actually added new parameters\nif(shouldUpdateUrl){const newUrl=`${window.location.pathname}?${currentParams.toString()}`;console.log(\"Updating URL to:\",newUrl);window.history.replaceState({},\"\",newUrl);console.log(\"URL updated with new parameters\");}else{console.log(\"No URL update needed\");}// Load Feathery SDK with the correct formId\nconsole.log(\"Creating Feathery script element\");const script=document.createElement(\"script\");script.src=\"https://cdn.jsdelivr.net/npm/@feathery/react@latest/umd/index.js\";script.async=true;script.onload=()=>{console.log(\"Feathery script loaded successfully\");console.log(\"window.Feathery available:\",!!window.Feathery);if(window.Feathery){console.log(\"Initializing Feathery with API key\");window.Feathery.init(\"aba10c1b-28de-464a-9a01-b7beccff4085\");console.log(\"Feathery initialized\");console.log(\"Rendering form with ID:\",formIdToUse);console.log(\"Feathery will read practice param from URL:\",window.location.search);// Do not pass hidden fields, let Feathery read from URL\nwindow.Feathery.renderAt(\"container\",{formId:formIdToUse},false);console.log(\"Feathery renderAt called successfully\");console.log(\"Container element:\",document.getElementById(\"container\"));}else{console.error(\"window.Feathery is not available after script load\");}};script.onerror=err=>{console.error(\"Failed to load Feathery script:\",err);};console.log(\"Appending Feathery script to document body\");document.body.appendChild(script);console.log(\"Script appended\");return()=>{console.log(\"=== CLEANUP: Component unmounting ===\");// Cleanup script on unmount\nif(script.parentNode){console.log(\"Removing Feathery script from DOM\");document.body.removeChild(script);}else{console.log(\"Script already removed or not in DOM\");}};},[url,practiceFieldName]);return /*#__PURE__*/_jsx(\"div\",{id:\"container\",style:{width:\"100vw\",height:\"2400px\"}});}addPropertyControls(FeatheryForm,{url:{type:ControlType.Link,title:\"URL\",description:\"URL with ?practice= parameter to determine which form to load\"},practiceFieldName:{type:ControlType.String,title:\"Practice Field Name\",description:\"The field name to use for the practice parameter (e.g., 'practice' or 'appt_type_id')\",defaultValue:\"practice\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FeatheryForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Featherly_Form.map"],"mappings":"wLAA4H,SAAwB,EAAa,CAAC,MAAI,oBAAkB,YAAY,CASH,OATI,MAAc,CAAmJ,GAAlJ,QAAQ,IAAI,0CAA0C,CAAC,QAAQ,IAAI,oBAAoB,EAAI,CAAC,QAAQ,IAAI,uBAAuB,EAAkB,CAAW,IAAS,QAAa,OAAO,SAAW,IAAY,CAAC,QAAQ,IAAI,2CAA2C,CAAC,OAAQ,QAAQ,IAAI,oCAAoC,CACrhB,IAAM,EAAY,SACjB,QAAQ,IAAI,iBAAiB,EAAY,CAAC,IAAI,EAAgB,GAAY,EAAc,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAC,GAAG,EAAI,CAAC,QAAQ,IAAI,qBAAqB,EAAI,CAAC,GAAG,CAAC,IAAM,EAAO,IAAI,IAAI,EAAI,EAAO,SAAS,OAAO,CAAC,QAAQ,IAAI,qBAAqB,EAAO,KAAK,CAAC,QAAQ,IAAI,qBAAqB,EAAO,OAAO,CAAC,IAAM,EAAc,EAAO,aAAa,IAAI,WAAW,CAAC,QAAQ,IAAI,gCAAgC,EAAc,CAAI,GAAe,CAAC,EAAc,IAAI,EAAkB,EAChf,EAAc,IAAI,EAAkB,EAAc,CAAC,EAAgB,GAAK,QAAQ,IAAI,0CAA0C,EAAU,EAAe,QAAQ,IAAI,qDAAqD,CAAO,QAAQ,IAAI,qCAAqC,OAAS,EAAI,CAAC,QAAQ,MAAM,sBAAsB,EAAI,OAAQ,QAAQ,IAAI,uBAAuB,CACjX,IAAM,EAAS,SAAS,SAAoD,GAA3C,QAAQ,IAAI,qBAAqB,EAAS,CAAI,EAAS,SAAS,mBAAmB,CAAC,CAAC,QAAQ,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