{"version":3,"file":"FeeQuoteBridgeOverride.CAt33ObP.mjs","names":[],"sources":["https:/framerusercontent.com/modules/KO5a4tUxwSmTjLnqDwOu/SpTfDxGqoBe3iClWF0C6/FeeQuoteBridgeOverride.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect}from\"react\";/**\n * User request:\n * Create a NEW Framer code override export named `withFeeQuoteBridge` in a new code file.\n * Apply it only to the existing native Framer form with id `fee-enquiry-form`.\n * Preserve native form structure/props/submission handling and only add browser-side message handling.\n * Accept window messages only from origin `https://mw-fee-calculator.bosbai.chatgpt.site` and payload type `mw-fees-quote`\n * with string `quoteReference` and string `quoteDetails`.\n * Upsert hidden inputs inside the form named:\n * `Quote reference`, `Indicative monthly fee`, `Indicative annual fee`, `Quote details`.\n * Set values from payload and update `completed-quote-summary` text according to `monthlyFee`.\n * Scroll the form into view with smooth behavior and start alignment.\n */export function withFeeQuoteBridge(Component){return /*#__PURE__*/forwardRef(function FeeQuoteBridgeOverride(props,ref){useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const trustedOrigin=\"https://mw-fee-calculator.bosbai.chatgpt.site\";const upsertHiddenInput=(form,name,value)=>{const existing=form.querySelector(`input[name=\"${name}\"]`);const input=existing instanceof HTMLInputElement?existing:(()=>{const nextInput=document.createElement(\"input\");nextInput.type=\"hidden\";nextInput.name=name;form.appendChild(nextInput);return nextInput;})();input.value=value;};const onMessage=event=>{if(event.origin!==trustedOrigin)return;const data=event.data;if(!data||typeof data!==\"object\")return;const payload=data;if(payload.type!==\"mw-fees-quote\")return;if(typeof payload.quoteReference!==\"string\")return;if(typeof payload.quoteDetails!==\"string\")return;const formElement=document.getElementById(\"fee-enquiry-form\");if(!(formElement instanceof HTMLFormElement))return;const monthlyFee=payload.monthlyFee;const annualFee=payload.annualFee;upsertHiddenInput(formElement,\"Quote reference\",payload.quoteReference);upsertHiddenInput(formElement,\"Indicative monthly fee\",String(monthlyFee||\"\"));upsertHiddenInput(formElement,\"Indicative annual fee\",String(annualFee||\"\"));upsertHiddenInput(formElement,\"Quote details\",payload.quoteDetails);const summaryElement=document.getElementById(\"completed-quote-summary\");if(summaryElement){summaryElement.textContent=monthlyFee===\"Tailored review\"?\"Your completed requirements are ready for Mark to review.\":`Your indicative fee of ${monthlyFee} a month plus VAT is ready to send to Mark.`;}formElement.scrollIntoView({behavior:\"smooth\",block:\"start\"});};window.addEventListener(\"message\",onMessage);return()=>{window.removeEventListener(\"message\",onMessage);};},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props,style:{...props.style}});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withFeeQuoteBridge\":{\"type\":\"reactHoc\",\"name\":\"withFeeQuoteBridge\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FeeQuoteBridgeOverride.map"],"mappings":"uIAWG,SAAgB,EAAmB,EAAU,CAAC,OAAoB,EAAW,SAAgC,EAAM,EAAI,CAAmrD,OAAlrD,MAAc,CAAC,GAAU,IAAS,QAAa,OAAO,SAAW,IAAY,OAAO,IAA0E,GAAmB,EAAK,EAAK,IAAQ,CAAC,IAAM,EAAS,EAAK,cAAc,eAAe,EAAK,GAAG,EAAQ,EAAM,aAAoB,iBAAiB,OAAc,CAAC,IAAM,EAAU,SAAS,cAAc,OAAO,EAA0E,MAAxE,GAAU,KAAK,SAAS,EAAU,KAAK,EAAK,EAAK,YAAY,CAAS,EAAS,CAAU,EAAA,CAAG,EAAE,EAAM,MAAM,CAAM,EAAQ,EAAU,GAAO,CAAC,GAAG,EAAM,SAAS,gDAAc,OAAO,IAAM,EAAK,EAAM,KAAK,GAAG,CAAC,GAAM,OAAO,GAAO,SAAS,OAAO,IAAM,EAAQ,EAAiG,GAAzF,EAAQ,OAAO,iBAA0B,OAAO,EAAQ,gBAAiB,UAAmB,OAAO,EAAQ,cAAe,SAAS,OAAO,IAAM,EAAY,SAAS,eAAe,kB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