{"version":3,"file":"copy_Marketo_Form_Embed_1.CTLIWXAc.mjs","names":["useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/szxOwHI6DHkuQkymCHtB/XdBKZLioOR0Pn0kFUE6f/copy_Marketo_Form_Embed_1.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect}from\"react\";import{SettingsMessage}from\"https://framer.com/m/Utils-QTIc.js@PVRWqcAS5FromVQ03eYl\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicHeight 300\n */export default function MarketoForm(props){// 1. Destructure onClose from props so we can use it when the form submits\nconst{embed,style,onClose}=props;const[isEmbedValid,setIsEmbedValid]=useState(false);const[formId,setFormId]=useState(null);const[script,setScript]=useState(null);const[isLoading,setIsLoading]=useState(true);if(!embed||embed.length===0){return /*#__PURE__*/_jsx(SettingsMessage,{title:\"Marketo Embed Component\",description:\"Enter the Marketo Embed Code here\",containerStyle:style});}useEffect(()=>{setIsLoading(true);const embedRegex=/MktoForms2\\.loadForm\\(\"(.+?)\", \"(.+?)\", (\\d+)(?:, .+?)?\\);/;const embedMatch=embed.match(embedRegex);const[,link,value,id]=embedMatch||[];setFormId(`mktoForm_${id}`);const embedFirstLine=`<script src=\"${link}/js/forms2/js/forms2.min.js\"></script>`;const isValidEmbed=embed.startsWith(embedFirstLine)&&value&&id&&link;setIsEmbedValid(isValidEmbed);if(isValidEmbed){const newScript=document.createElement(\"script\");newScript.src=`${link}/js/forms2/js/forms2.min.js`;newScript.async=true;const handleError=(error,message)=>{setIsEmbedValid(false);setIsLoading(false);console.error(message,error);};const handleScriptLoad=()=>{try{if(window.MktoForms2){window.MktoForms2.loadForm(link,value,id,function(form){form.onSuccess(function(values,followUpUrl){if(window.dreamdata&&window.dreamdata.initialized){const email=values.Email||values.email;window.dreamdata.identify(null,{email:email});window.dreamdata.track(\"Marketo Form Submitted\");}// 2. Trigger the Framer close action if it exists\nif(typeof onClose===\"function\"){onClose();}// Return false if you want to prevent Marketo's default\n// redirect (since the overlay is closing anyway)\nreturn true;});});}}catch(error){handleError(error,\"Error loading form:\");}};newScript.onload=handleScriptLoad;document.body.appendChild(newScript);setScript(newScript);try{document.body.appendChild(newScript);setScript(newScript);}catch(error){handleError(error,\"Error appending script:\");}}setIsLoading(false);return()=>{if(script){try{document.body.removeChild(script);}catch(error){setIsEmbedValid(false);console.error(\"Error removing script:\",error);}}};},[embed,onClose])// 3. Added onClose to the dependency array\n;return /*#__PURE__*/_jsx(_Fragment,{children:isLoading?/*#__PURE__*/_jsx(_Fragment,{}):isEmbedValid?/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:customCSS}),/*#__PURE__*/_jsx(\"form\",{id:formId})]}):/*#__PURE__*/_jsx(SettingsMessage,{title:\"Your embed code is incorrect!\",description:\"Update the Marketo embed form in the component property.\",containerStyle:style,icon:\"🚨\"})});}const customCSS=`\n    .mktoLabel {\n        width: auto !important;\n        float: none !important;\n        display: block !important;\n    }\n`;MarketoForm.displayName=\"Marketo Form\";addPropertyControls(MarketoForm,{embed:{title:\"Embed Code\",type:ControlType.String,displayTextArea:true,description:\"[Where to find my Marketo embed form](https://experienceleague.adobe.com/en/docs/marketo/using/product-docs/demand-generation/forms/form-actions/embed-a-form-on-your-website).\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MarketoForm\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"600\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"300\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMapping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