"use strict";const u=require("solid-js/web"),c=require("solid-js"),m=u.template("
",2),f=globalThis??window;let o=typeof f.turnstile<"u"?"ready":"unloaded",p;{const s="cf__reactTurnstileOnLoad",n="https://challenges.cloudflare.com/turnstile/v0/api.js";let e;const l=new Promise((r,t)=>{e={resolve:r,reject:t},o==="ready"&&r(void 0)});f[s]=()=>{e.resolve(),o="ready"},p=()=>{if(o==="unloaded"){o="loading";const r=`${n}?onload=${s}&render=explicit`,t=document.createElement("script");t.src=r,t.async=!0,t.addEventListener("error",()=>{e.reject("Failed to load Turnstile.")}),document.head.appendChild(t)}return l}}function y(s){let n;const[e,l]=c.splitProps(s,["sitekey","action","cData","theme","tabIndex","responseField","responseFieldName","onVerify","onError","onLoad","onExpire"]);return c.createEffect(r=>{if(r?.(),Object.keys(e).forEach(a=>{e[a]}),!n)return;let t=!1,i="";return(async()=>{if(o!=="ready")try{await p()}catch(d){e.onError?.(d);return}if(t||!n)return;const a={sitekey:e.sitekey,action:e.action,cData:e.cData,theme:e.theme,tabindex:e.tabIndex,callback:d=>e.onVerify(d),"error-callback":()=>e.onError?.(),"expired-callback":()=>e.onExpire?.(),"response-field":e.responseField,"response-field-name":e.responseFieldName};i=window.turnstile.render(n,a),e.onLoad?.(i)})(),()=>{t=!0,i&&window.turnstile.remove(i)}}),(()=>{const r=m.cloneNode(!0),t=n;return typeof t=="function"?t(r):n=r,u.spread(r,l,!1,!1),r})()}module.exports=y;