{"version":3,"file":"RecaptchaButton.CDKtNlu2.mjs","names":["useState","useRef","_Fragment"],"sources":["https:/framerusercontent.com/modules/L0Mxw44VymKGmgkARXr5/bipD4MMxVOnDC02jMhPt/RecaptchaButton.js"],"sourcesContent":["// Google reCAPTCHA v2 component with explicit rendering for form integration\n// IMPORTANT: This component generates a token that MUST be verified on your backend server\n// to complete the reCAPTCHA protection. Without server-side verification, you will receive\n// \"unprotected events\" warnings from Google.\n//\n// Backend verification example:\n// 1. Send the token to your server endpoint\n// 2. Verify with Google: POST https://www.google.com/recaptcha/api/siteverify\n// 3. Include secret key, response token, and user IP\n// 4. Check the verification response before processing the form\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Google reCAPTCHA v2 Widget Component\n * \n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Recaptcha(props){const{siteKey=\"\",theme=\"light\",size=\"normal\",onVerify,onExpired,onError,showInstructions=true}=props;const[scriptLoaded,setScriptLoaded]=useState(false);const[widgetId,setWidgetId]=useState(null);const[error,setError]=useState(null);const[token,setToken]=useState(null);const recaptchaRef=useRef(null);useEffect(()=>{if(typeof window===\"undefined\")return;if(!siteKey){startTransition(()=>setError(\"Site key is required\"));return;}// Check if script is already loaded\nif(window.grecaptcha){startTransition(()=>setScriptLoaded(true));return;}// Define the callback function\nwindow.onRecaptchaLoad=()=>{startTransition(()=>{setScriptLoaded(true);setError(null);});};// Load the script with explicit rendering\nconst script=document.createElement(\"script\");script.src=\"https://www.google.com/recaptcha/api.js?onload=onRecaptchaLoad&render=explicit\";script.async=true;script.defer=true;script.onerror=()=>{startTransition(()=>setError(\"Failed to load reCAPTCHA\"));};document.head.appendChild(script);return()=>{try{if(document.head.contains(script)){document.head.removeChild(script);}delete window.onRecaptchaLoad;}catch(e){// Script already removed\n}};},[siteKey]);useEffect(()=>{if(!scriptLoaded||!window.grecaptcha||!recaptchaRef.current||!siteKey){return;}// Reset any existing widget\nif(widgetId!==null){try{window.grecaptcha.reset(widgetId);}catch(e){// Widget doesn't exist\n}}// Render the reCAPTCHA widget\ntry{window.grecaptcha.ready(()=>{if(recaptchaRef.current){const id=window.grecaptcha.render(recaptchaRef.current,{sitekey:siteKey,theme:theme,size:size,callback:responseToken=>{startTransition(()=>{setError(null);setToken(responseToken);});if(onVerify)onVerify(responseToken);},\"expired-callback\":()=>{startTransition(()=>setToken(null));if(onExpired)onExpired();},\"error-callback\":()=>{console.warn(\"reCAPTCHA error occurred - this may be due to network issues or invalid site key\");startTransition(()=>setToken(null));if(onError)onError();}});startTransition(()=>setWidgetId(id));}});}catch(err){startTransition(()=>setError(\"Failed to render reCAPTCHA\"));}},[scriptLoaded,siteKey,theme,size,onVerify,onExpired,onError]);const reset=()=>{if(widgetId!==null&&window.grecaptcha){try{window.grecaptcha.reset(widgetId);startTransition(()=>setToken(null));}catch(e){// Widget doesn't exist\n}}};const getResponse=()=>{if(widgetId!==null&&window.grecaptcha){try{return window.grecaptcha.getResponse(widgetId);}catch(e){return\"\";}}return\"\";};if(error){return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,position:\"relative\",padding:\"16px\",backgroundColor:\"#fee\",color:\"#c33\",border:\"1px solid #fcc\",borderRadius:\"4px\",fontSize:\"14px\",textAlign:\"center\"},children:[\"Error: \",error]});}if(!scriptLoaded){return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,position:\"relative\",padding:\"16px\",backgroundColor:\"#f5f5f5\",color:\"#666\",border:\"1px solid #ddd\",borderRadius:\"4px\",fontSize:\"14px\",textAlign:\"center\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",gap:\"8px\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{width:\"16px\",height:\"16px\",border:\"2px solid #ddd\",borderTop:\"2px solid #666\",borderRadius:\"50%\",animation:\"spin 1s linear infinite\"}}),\"Loading reCAPTCHA...\",/*#__PURE__*/_jsx(\"style\",{children:`\n            @keyframes spin {\n              0% { transform: rotate(0deg); }\n              100% { transform: rotate(360deg); }\n            }\n          `})]});}return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,position:\"relative\",display:\"inline-block\"},children:[/*#__PURE__*/_jsx(\"div\",{ref:recaptchaRef,style:{minHeight:size===\"compact\"?\"144px\":\"78px\",minWidth:size===\"compact\"?\"164px\":\"304px\"}}),showInstructions&&/*#__PURE__*/_jsxs(\"div\",{style:{marginTop:\"12px\",padding:\"12px\",backgroundColor:\"#f8f9fa\",border:\"1px solid #e9ecef\",borderRadius:\"4px\",fontSize:\"12px\",color:\"#495057\",lineHeight:\"1.4\"},children:[/*#__PURE__*/_jsx(\"strong\",{children:\"⚠️ Backend Verification Required\"}),/*#__PURE__*/_jsx(\"br\",{}),token?/*#__PURE__*/_jsxs(_Fragment,{children:[\"Token generated! Send this token to your server for verification:\",/*#__PURE__*/_jsx(\"br\",{}),/*#__PURE__*/_jsxs(\"code\",{style:{backgroundColor:\"#e9ecef\",padding:\"2px 4px\",borderRadius:\"2px\",fontSize:\"11px\",wordBreak:\"break-all\"},children:[token.substring(0,50),\"...\"]})]}):\"Complete the reCAPTCHA above to generate a verification token.\",/*#__PURE__*/_jsx(\"br\",{}),/*#__PURE__*/_jsx(\"small\",{children:'Without server-side verification, Google will send \"unprotected events\" warnings.'})]})]});}addPropertyControls(Recaptcha,{siteKey:{type:ControlType.String,title:\"Site Key\",placeholder:\"Your reCAPTCHA v2 site key\",defaultValue:\"\"},theme:{type:ControlType.Enum,title:\"Theme\",options:[\"light\",\"dark\"],optionTitles:[\"Light\",\"Dark\"],defaultValue:\"light\",displaySegmentedControl:true},size:{type:ControlType.Enum,title:\"Size\",options:[\"normal\",\"compact\"],optionTitles:[\"Normal\",\"Compact\"],defaultValue:\"normal\",displaySegmentedControl:true},showInstructions:{type:ControlType.Boolean,title:\"Show Instructions\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},onVerify:{type:ControlType.EventHandler,title:\"On Verify\"},onExpired:{type:ControlType.EventHandler,title:\"On Expired\"},onError:{type:ControlType.EventHandler,title:\"On Error\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Recaptcha\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RecaptchaButton.map"],"mappings":"sNAeG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,UAAQ,GAAG,QAAM,QAAQ,OAAK,SAAS,WAAS,YAAU,UAAQ,mBAAiB,IAAM,EAAW,CAAC,EAAa,GAAiBA,EAAS,GAAM,CAAM,CAAC,EAAS,GAAaA,EAAS,KAAK,CAAM,CAAC,EAAM,GAAUA,EAAS,KAAK,CAAM,CAAC,EAAM,GAAUA,EAAS,KAAK,CAAO,EAAaC,EAAO,KAAK,CAavU,OAbwU,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,GAAG,CAAC,EAAQ,CAAC,MAAoB,EAAS,uBAAuB,CAAC,CAAC,OACld,GAAG,EAAO,WAAW,CAAC,MAAoB,EAAgB,GAAK,CAAC,CAAC,OACjE,EAAO,oBAAoB,CAAC,MAAoB,CAAC,EAAgB,GAAK,CAAC,EAAS,KAAK,EAAG,EACxF,IAAM,EAAO,SAAS,cAAc,SAAS,CAAmP,MAAlP,GAAO,IAAI,iFAAiF,EAAO,MAAM,GAAK,EAAO,MAAM,GAAK,EAAO,YAAY,CAAC,MAAoB,EAAS,2BAA2B,CAAC,EAAG,SAAS,KAAK,YAAY,EAAO,KAAW,CAAC,GAAG,CAAI,SAAS,KAAK,SAAS,EAAO,EAAE,SAAS,KAAK,YAAY,EAAO,CAAE,OAAO,EAAO,qBAAyB,KACvZ,CAAC,EAAQ,CAAC,CAAC,MAAc,CAAI,MAAC,GAAc,CA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