1import{r as n,j as N}from"./index-DB1uCt0m.js";import{u as re}from"./use-hydrated-BrdeQr_C.js";import{u as te}from"./environment-RFbaRb7h.js";var ne=({as:o="div",...s},i)=>N.jsx(o,{...s,ref:i}),oe=n.forwardRef(ne),ie="https://challenges.cloudflare.com/turnstile/v0/api.js",P="cf-turnstile-script",ue="cf-turnstile",$="onloadTurnstileCallback",W=o=>!!document.getElementById(o),ce=({render:o="explicit",onLoadCallbackName:s=$,scriptOptions:{nonce:i="",defer:e=!0,async:a=!0,id:x="",appendTo:p,onError:d,crossOrigin:v=""}={}})=>{let h=x||P;if(W(h))return;let c=document.createElement("script");c.id=h,c.src=`${ie}?onload=${s}&render=${o}`,!document.querySelector(`script[src="${c.src}"]`)&&(c.defer=!!e,c.async=!!a,i&&(c.nonce=i),v&&(c.crossOrigin=v),d&&(c.onerror=d,delete window[s]),(p==="body"?document.body:document.getElementsByTagName("head")[0]).appendChild(c))},T={normal:{width:300,height:65},compact:{width:150,height:140},invisible:{width:0,height:0,overflow:"hidden"},flexible:{minWidth:300,width:"100%",height:65},interactionOnly:{width:"fit-content",height:"auto",display:"flex"}};function se(o){if(o!=="invisible"&&o!=="interactionOnly")return o}function ae(o=P){let[s,i]=n.useState(!1);return n.useEffect(()=>{let e=()=>{W(o)&&i(!0)},a=new MutationObserver(e);return a.observe(document,{childList:!0,subtree:!0}),e(),()=>{a.disconnect()}},[o]),s}var O="unloaded",q,le=new Promise((o,s)=>{q={resolve:o,reject:s},O==="ready"&&o(void 0)}),H=(o=$)=>(O==="unloaded"&&(O="loading",window[o]=()=>{q.resolve(),O="ready",delete window[o]}),le),Y=n.forwardRef((o,s)=>{let{scriptOptions:i,options:e={},siteKey:a,onWidgetLoad:x,onSuccess:p,onExpire:d,onError:v,onBeforeInteractive:h,onAfterInteractive:c,onUnsupported:j,onTimeout:C,onLoadScript:A,id:G,style:J,as:X="div",injectScript:K=!0,rerenderOnCallbackChange:u=!1,...M}=o,l=e.size,_=n.useCallback(()=>typeof l>"u"?{}:e.execution==="execute"?T.invisible:e.appearance==="interaction-only"?T.interactionOnly:T[l],[e.execution,l,e.appearance]),[Q,I]=n.useState(_()),f=n.useRef(null),[b,L]=n.useState(!1),t=n.useRef(void 0),k=n.useRef(!1),D=G||ue,m=n.useRef({onSuccess:p,onError:v,onExpire:d,onBeforeInteractive:h,onAfterInteractive:c,onUnsupported:j,onTimeout:C});n.useEffect(()=>{u||(m.current={onSuccess:p,onError:v,onExpire:d,onBeforeInteractive:h,onAfterInteractive:c,onUnsupported:j,onTimeout:C})});let B=i?.id||P,F=ae(B),R=i?.onLoadCallbackName||$,Z=e.appearance||"always",S=n.useMemo(()=>({sitekey:a,action:e.action,cData:e.cData,theme:e.theme||"auto",language:e.language||"auto",tabindex:e.tabIndex,"response-field":e.responseField,"response-field-name":e.responseFieldName,size:se(l),retry:e.retry||"auto","retry-interval":e.retryInterval||8e3,"refresh-expired":e.refreshExpired||"auto","refresh-timeout":e.refreshTimeout||"auto",execution:e.execution||"render",appearance:e.appearance||"always","feedback-enabled":e.feedbackEnabled??!0,callback:r=>{k.current=!0,u?p?.(r):m.current.onSuccess?.(r)},"error-callback":u?v:(...r)=>m.current.onError?.(...r),"expired-callback":u?d:(...r)=>m.current.onExpire?.(...r),"before-interactive-callback":u?h:(...r)=>m.current.onBeforeInteractive?.(...r),"after-interactive-callback":u?c:(...r)=>m.current.onAfterInteractive?.(...r),"unsupported-callback":u?j:(...r)=>m.current.onUnsupported?.(...r),"timeout-callback":u?C:(...r)=>m.current.onTimeout?.(...r)}),[e.action,e.appearance,e.cData,e.execution,e.language,e.refreshExpired,e.responseField,e.responseFieldName,e.retry,e.retryInterval,e.tabIndex,e.theme,e.feedbackEnabled,e.refreshTimeout,a,l,u,u?p:null,u?v:null,u?d:null,u?h:null,u?c:null,u?j:null,u?C:null]),y=n.useCallback(()=>typeof window<"u"&&!!window.turnstile,[]);return n.useEffect(function(){K&&!b&&(H(R),ce({onLoadCallbackName:R,scriptOptions:{...i,id:B}}))},[K,b,i,B,R]),n.useEffect(function(){O!=="ready"&&H(R).then(()=>L(!0)).catch(console.error)},[R]),n.useEffect(function(){if(!f.current||!b)return;let r=!1;return(async()=>{if(r||!f.current)return;let w=window.turnstile.render(f.current,S);t.current=w,t.current&&x?.(t.current)})(),()=>{r=!0,t.current&&(window.turnstile.remove(t.current),k.current=!1)}},[D,b,S]),n.useImperativeHandle(s,()=>{let{turnstile:r}=window;return{getResponse(){if(!r?.getResponse||!t.current||!y()){console.warn("Turnstile has not been loaded");return}return r.getResponse(t.current)},async getResponsePromise(w=3e4,V=100){return new Promise((ee,U)=>{let E,z=async()=>
1{if(k.current&&window.turnstile&&t.current)try{let g=window.turnstile.getResponse(t.current);return E&&clearTimeout(E),g?ee(g):U(new Error("No response received"))}catch(g){return E&&clearTimeout(E),console.warn("Failed to get response",g),U(new Error("Failed to get response"))}E||(E=setTimeout(()=>{E&&clearTimeout(E),U(new Error("Timeout"))},w)),await new Promise(g=>setTimeout(g,V)),await z()};z()})},reset(){if(!r?.reset||!t.current||!y()){console.warn("Turnstile has not been loaded");return}e.execution==="execute"&&I(T.invisible);try{k.current=!1,r.reset(t.current)}catch(w){console.warn(`Failed to reset Turnstile widget ${t}`,w)}},remove(){if(!r?.remove||!t.current||!y()){console.warn("Turnstile has not been loaded");return}I(T.invisible),k.current=!1,r.remove(t.current),t.current=null},render(){if(!r?.render||!f.current||!y()||t.current){console.warn("Turnstile has not been loaded or container not found");return}let w=r.render(f.current,S);return t.current=w,t.current&&x?.(t.current),e.execution!=="execute"&&I(l?T[l]:{}),w},execute(){if(e.execution!=="execute"){console.warn('Execution mode is not set to "execute"');return}if(!r?.execute||!f.current||!t.current||!y()){console.warn("Turnstile has not been loaded or container not found");return}r.execute(f.current,S),I(l?T[l]:{})},isExpired(){return!r?.isExpired||!t.current||!y()?(console.warn("Turnstile has not been loaded"),!1):r.isExpired(t.current)}}},[t,e.execution,l,S,f,y,b,x]),n.useEffect(()=>{if(b||!F)return;if(window.turnstile){L(!0);return}let r=setInterval(()=>{window.turnstile&&(L(!0),clearInterval(r))},50);return()=>{clearInterval(r)}},[b,F]),n.useEffect(()=>{I(_())},[e.execution,l,Z]),n.useEffect(()=>{!F||typeof A!="function"||A()},[F]),N.jsx(oe,{ref:f,as:X,id:D,style:{...Q,...J},...M})});Y.displayName="Turnstile";const de="cf-turnstile-response";function we({nonce:o,id:s,onVerify:i,resetSignal:e}){const a=n.useRef(void 0),x=re(),{TURNSTILE_SITE_KEY:p}=te();return n.useEffect(()=>{e!==void 0&&(i?.(null),a.current?.reset())},[e]),N.jsx(N.Fragment,{children:x&&N.jsx(Y,{id:s,onError:()=>i?.(null),onExpire:()=>{i?.(null),a.current?.reset()},onSuccess:d=>i?.(d),options:{responseFieldName:de},ref:a,scriptOptions:{nonce:o},siteKey:p})})}export{we as T};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.