{"version":3,"file":"RecapchaInput.Di6sg81Z.mjs","names":["useState","useRef"],"sources":["https:/framer.com/m/FramerFormsShared-XPyb.js@hMz2wp3CWZkNwPJFGPgQ","https:/framerusercontent.com/modules/J0pYruOPdrrqmASXNd0m/gHDAvAB0LfLb5GUD1EKK/RecapchaInput.js"],"sourcesContent":["/*\n * FramerFormsShared\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/DwWOdDzQZGCuvkNlbUjZ/hMz2wp3CWZkNwPJFGPgQ/FramerFormsShared.js\"\n","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useRef,useState}from\"react\";import{HiddenInput}from\"https://framer.com/m/FramerFormsShared-XPyb.js@hMz2wp3CWZkNwPJFGPgQ\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function RecaptchaInput(props){const[verified,setVerified]=useState(false);if(!props.siteKey){return /*#__PURE__*/_jsx(\"div\",{style:{...props.style},children:/*#__PURE__*/_jsx(InvalideSetupMessage,{})});}return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style},children:[/*#__PURE__*/_jsx(RepatchaContainer,{siteKey:props.siteKey,onVerifiedChange:setVerified}),/*#__PURE__*/_jsx(HiddenInput,{name:\"recaptcha\",required:true,value:verified?\"Yes\":\"\"})]});}RecaptchaInput.displayName=\"reCAPTCHA Input\";addPropertyControls(RecaptchaInput,{siteKey:{type:ControlType.String,title:\"Site Key\",defaultValue:\"\",placeholder:\"Paste your site key here\"}});const RepatchaContainer=props=>{const captchaContainerRef=useRef(null);useEffect(()=>{if(!document.getElementById(\"recaptcha-script\")){const script=document.createElement(\"script\");script.id=\"recaptcha-script\";script.src=\"https://www.google.com/recaptcha/api.js?render=explicit\";script.async=true;script.defer=true;document.body.appendChild(script);}},[]);useEffect(()=>{if(!props.siteKey)return;const container=captchaContainerRef.current;if(!container)return;const stripTokenName=()=>{const textarea=container.querySelector('textarea[name=\"g-recaptcha-response\"]');if(textarea){textarea.removeAttribute(\"name\");return true;}return false;};const observer=new MutationObserver(()=>{stripTokenName();});observer.observe(container,{childList:true,subtree:true});const interval=setInterval(()=>{const reCaptchaInitialized=!!window.grecaptcha&&window.grecaptcha.render;if(!reCaptchaInitialized)return;window.grecaptcha.render(container,{sitekey:props.siteKey,callback:()=>{props.onVerifiedChange(true);stripTokenName();},\"expired-callback\":()=>props.onVerifiedChange(false)});clearInterval(interval);},500);return()=>{clearInterval(interval);observer.disconnect();};},[props.siteKey]);return /*#__PURE__*/_jsx(\"div\",{ref:captchaContainerRef});};const InvalideSetupMessage=()=>{return /*#__PURE__*/_jsx(\"div\",{style:{padding:\"12px\",background:\"#f5f5f5\",color:\"#888\",borderRadius:\"6px\",fontSize:\"14px\",textAlign:\"center\"},children:\"Enter your reCAPTCHA site key in the properties panel\"});};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RecaptchaInput\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RecapchaInput.map"],"mappings":"iRCGG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,EAAS,GAAaA,EAAS,GAAM,CAAkI,OAA7H,EAAM,QAA2I,EAAM,MAAM,CAAC,MAAM,CAAC,GAAG,EAAM,MAAM,CAAC,SAAS,CAAc,EAAK,EAAkB,CAAC,QAAQ,EAAM,QAAQ,iBAAiB,EAAY,CAAC,CAAc,EAAK,EAAY,CAAC,KAAK,YAAY,SAAS,GAAK,MAAM,EAAS,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAhV,EAAK,MAAM,CAAC,MAAM,CAAC,GAAG,EAAM,MAAM,CAAC,SAAsB,EAAK,EAAqB,EAAE,CAAC,CAAC,CAAC,0BAHnK,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