{"version":3,"file":"TurnstileGate.CGe6pPre.mjs","names":["React.useRef","React.useState"],"sources":["https:/framerusercontent.com/modules/RWBaq9wYKDltK97moxGP/LbbA4Xay8CC4IW4raYY0/GateEmail.js","https:/framerusercontent.com/modules/ZTOLwGXNax1xmsz9zUhZ/wASeN6K2W3dG2bES6POF/TurnstileGate.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef}from\"react\";const DEFAULT_BLOCKED=[\"gmail.com\",\"googlemail.com\",\"yahoo.com\",\"outlook.com\",\"hotmail.com\",\"icloud.com\",\"aol.com\",\"proton.me\",\"protonmail.com\"];function getDomain(email){const at=email.lastIndexOf(\"@\");if(at===-1)return\"\";return email.slice(at+1).trim().toLowerCase();}function findInput(el){if(!el)return null;// If the layer *is* the input\nif(el.tagName===\"INPUT\")return el;// Otherwise search inside\nreturn el.querySelector(\"input\");}export function withGateEmail(Component,options={}){const blocked=new Set((options.blockedDomains??DEFAULT_BLOCKED).map(d=>d.toLowerCase()));const message=options.message??\"Please use your work email address.\";const reportOnBlur=options.reportOnBlur??true;return /*#__PURE__*/forwardRef(function GateEmail(props,ref){const handleInput=e=>{// Best-case: handler is attached to the actual input\nconst target=e?.currentTarget||e?.target;const value=String(target?.value??\"\").trim();const domain=getDomain(value);// If we can access the real input, enforce custom validity\nif(target&&typeof target.setCustomValidity===\"function\"){if(value&&domain&&blocked.has(domain)){target.setCustomValidity(message);}else{target.setCustomValidity(\"\");}}// Preserve any existing behavior Framer already had\nprops?.onInput?.(e);props?.onChange?.(e);};const handleBlur=e=>{props?.onBlur?.(e);if(!reportOnBlur)return;const target=e?.currentTarget||e?.target;if(target&&typeof target.reportValidity===\"function\"){target.reportValidity();return;}// Fallback: find nested input and report validity\nconst host=(e?.currentTarget)??null;const input=findInput(host);input?.reportValidity?.();};return /*#__PURE__*/_jsx(Component,{...props,ref:ref,// Use both — different Framer input layers sometimes fire one or the other\nonInput:handleInput,onChange:handleInput,onBlur:handleBlur});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withGateEmail\":{\"type\":\"reactHoc\",\"name\":\"withGateEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GateEmail.map","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";function loadTurnstileScript(){const id=\"cf-turnstile-script\";if(document.getElementById(id))return;const s=document.createElement(\"script\");s.id=id;s.src=\"https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit\";s.async=true;s.defer=true;document.head.appendChild(s);}export default function TurnstileGate(props){const{siteKey,theme,size,tokenFieldName,width}=props;const containerRef=React.useRef(null);const[token,setToken]=React.useState(\"\");React.useEffect(()=>{loadTurnstileScript();// Callback gets called when user passes Turnstile\nwindow.__onTurnstileSolved=t=>{setToken(t);window.__TURNSTILE_TOKEN__=t;};const tryRender=()=>{if(!window.turnstile||!containerRef.current)return false;// Avoid double-render\nif(containerRef.current.getAttribute(\"data-rendered\")===\"1\")return true;window.turnstile.render(containerRef.current,{sitekey:siteKey,theme,size,callback:window.__onTurnstileSolved,\"error-callback\":()=>{setToken(\"\");window.__TURNSTILE_TOKEN__=\"\";},\"expired-callback\":()=>{setToken(\"\");window.__TURNSTILE_TOKEN__=\"\";}});containerRef.current.setAttribute(\"data-rendered\",\"1\");return true;};// Poll a few times until script is ready\nlet tries=0;const iv=setInterval(()=>{tries+=1;const ok=tryRender();if(ok||tries>40)clearInterval(iv);},100);return()=>clearInterval(iv);},[siteKey,theme,size]);return /*#__PURE__*/_jsxs(\"div\",{style:{width},children:[/*#__PURE__*/_jsx(\"div\",{ref:containerRef}),/*#__PURE__*/_jsx(\"input\",{type:\"hidden\",name:tokenFieldName,value:token,readOnly:true})]});}TurnstileGate.defaultProps={siteKey:\"\",theme:\"auto\",size:\"normal\",tokenFieldName:\"cf-turnstile-response\",width:320};addPropertyControls(TurnstileGate,{siteKey:{type:ControlType.String,title:\"Site Key\"},theme:{type:ControlType.Enum,title:\"Theme\",options:[\"auto\",\"light\",\"dark\"],optionTitles:[\"Auto\",\"Light\",\"Dark\"]},size:{type:ControlType.Enum,title:\"Size\",options:[\"normal\",\"compact\"],optionTitles:[\"Normal\",\"Compact\"]},tokenFieldName:{type:ControlType.String,title:\"Token field\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TurnstileGate\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TurnstileGate.map"],"mappings":"qNAA0N,SAAS,EAAU,EAAM,CAAC,IAAM,EAAG,EAAM,YAAY,IAAI,CAAqB,OAAjB,IAAK,GAAS,GAAU,EAAM,MAAM,EAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAE,SAAS,EAAU,EAAG,CAE7W,OAFkX,EAC/W,EAAG,UAAU,QAAe,EACxB,EAAG,cAAc,QAAQ,CAF4V,KAE1V,SAAgB,EAAc,EAAU,EAAQ,EAAE,CAAC,CAAC,IAAM,EAAQ,IAAI,KAAK,EAAQ,gBAAgB,GAAiB,IAAI,GAAG,EAAE,aAAa,CAAC,CAAC,CAAO,EAAQ,EAAQ,SAAS,sCAA4C,EAAa,EAAQ,cAAc,GAAK,OAAoB,EAAW,SAAmB,EAAM,EAAI,CAAC,IAAM,EAAY,GAAG,CACpX,IAAM,EAAO,GAAG,eAAe,GAAG,OAAa,EAAM,OAAO,GAAQ,OAAO,GAAG,CAAC,MAAM,CAAO,EAAO,EAAU,EAAM,CAChH,GAAQ,OAAO,EAAO,mBAAoB,aAAe,GAAO,GAAQ,EAAQ,IAAI,EAAO,CAAE,EAAO,kBAAkB,EAAQ,CAAO,EAAO,kBAAkB,GAAG,EACpK,GAAO,UAAU,EAAE,CAAC,GAAO,WAAW,EAAE,EAAS,EAAW,GAAG,CAAoB,GAAnB,GAAO,SAAS,EAA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