PageSourceSearch

https://www.childfund.org/scripts/Dj03AZZ5-turnstile.js

js childfund.org collected 2026-10-02 06:07:13 UTC 4,807 bytes, 2 lines download raw bytes

1import{l as r}from"./-mcz9By9-verndale-core.js";class o extends r.Component{widgetId=null;sitekey=null;isInitializing=!1;initializationAttempts=0;MAX_RETRIES=50;RETRY_DELAY=100;MAX_INIT_ATTEMPTS=3;SITEKEY_WAIT_TIMEOUT=5e3;constructor(t){super(t),this.sitekey=t.dataset.sitekey||null}async setupDefaults(){this.dom={container:this.el},await this.waitForSitekey(),await this.initializeTurnstile()}addListeners(){}async waitForSitekey(){if(this.sitekey)return;const t=this.el.dataset.sitekey;if(t){this.sitekey=t;return}return new Promise(i=>{const e=Date.now(),n=setInterval(()=>{const s=this.el.dataset.sitekey;s?(this.sitekey=s,clearInterval(n),i()):Date.now()-e>=this.SITEKEY_WAIT_TIMEOUT&&(clearInterval(n),i())},100)})}async waitForTurnstile(){return new Promise((t,i)=>{if(window.turnstile){t(window.turnstile);return}if(!document.querySelector('script[src*="challenges.cloudflare.com/turnstile"]')){i(new Error("Turnstile script tag not found. Make sure the script is included in the page."));return}let n=0;const s=setInterval(()=>{n++,window.turnstile?(clearInterval(s),t(window.turnstile)):n>=this.MAX_RETRIES&&(clearInterval(s),i(new Error("Turnstile script timeout - failed to load after maximum retries. This may be due to network issues or ad blockers.")))},this.RETRY_DELAY)})}async initializeTurnstile(){if(this.isInitializing||this.widgetId!==null){console.warn("Turnstile already initialized or initializing");return}if(!this.sitekey){const i=new Error("Turnstile sitekey is required. Set data-sitekey attribute on the container element.");this.handleInitializationError(i);return}const t=this.dom?.container;if(!t){const i=new Error("Turnstile container element not found");this.handleInitializationError(i);return}if(!t.isConnected){const i=new Error("Turnstile container is not in the DOM. Ensure the element is rendered before initialization.");this.handleInitializationError(i);return}this.isInitializing=!0,this.initializationAttempts++;try{const i=await this.waitForTurnstile();if(this.widgetId!==null){console.warn("Turnstile widget already exists, skipping initialization"),this.isInitializing=!1;return}this.widgetId=i.render(t,{sitekey:this.sitekey,callback:this.handleTokenCallback.bind(this),"error-callback":this.handleErrorCallback.bind(this),"expired-callback":this.handleExpiredCallback.bind(this),"timeout-callback":this.handleTimeoutCallback.bind(this),theme:"auto",size:"normal",retry:"auto","retry-interval":8e3,"refresh-expired":"auto"}),console.log("Turnstile widget initialized successfully",{widgetId:this.widgetId,sitekey:this.sitekey}),this.isInitializing=!1}catch(i){this.isInitializing=!1,this.initializationAttempts<this.MAX_INIT_ATTEMPTS&&i instanceof Error&&i.message.includes("timeout")?(console.warn(`Turnstile initialization failed, retrying (${this.initializationAttempts}/${this.MAX_INIT_ATTEMPTS})...`,i),await new Promise(e=>setTimeout(e,1e3)),await this.initializeTurnstile()):this.handleInitializationError(i)}}handleTokenCallback(t){const i=this.dom?.container;i&&(i.dataset.turnstileToken=t);const e=new CustomEvent("turnstile:success",{detail:{token:t,widgetId:this.widgetId}});console.log("Turnstile success",e,t,this.widgetId),window.dispatchEvent(e)}handleErrorCallback(){const t=new CustomEvent("turnstile:error",{detail:{widgetId:this.widgetId}});window.dispatchEvent(t)}handleExpiredCallback(){const t=new CustomEvent("turnstile:expired",{detail:{widgetId:this.widgetId}});console.log("Turnstile expired",t),window.dispatchEvent(t)}handleTimeoutCallback(){const t=new CustomEvent("turnstile:timeout",{detail:{widgetId:this.widgetId}});console.log("Turnstile timeout",t),window.dispatchEvent(t)}handleInitializationError(t){const i=t instanceof Error?t.message:"Unknown error";console.error("Turnstile initialization error:",i,t);const e=this.dom?.container;e&&(e.dataset.turnstileError="true",e.setAttribute("aria-label",`Turnstile error: ${i}`));const n=new CustomEvent("turnstile:init-error",{detail:{error:i,attempts:this.initializationAttempts}});window.dispatchEvent(n)}getToken(){if(!(!window.turnstile||!this.widgetId))return window.turnstile.getResponse(this.widgetId)}reset(){if(window.turnstile&&this.widgetId)try{window.turnstile.reset(this.widgetId)}catch(t){console.error("Error resetting Turnstile widget:",t)}}async reinitialize(){this.destroy(),this.widgetId=null,this.isInitializing=!1,this.initializationAttempts=0,this.sitekey=this.el.dataset.sitekey||null,await this.waitForSitekey(),await this.initializeTur
1nstile()}destroy(){if(window.turnstile&&this.widgetId){try{window.turnstile.remove(this.widgetId)}catch(i){console.error("Error removing Turnstile widget:",i)}this.widgetId=null}const t=this.dom?.container;t&&delete t.dataset.turnstileError}}export{o as default};
2//# sourceMappingURL=Dj03AZZ5-turnstile.js.map

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.