{"version":3,"file":"google-captcha.js","sources":["../../../src/assets/scripts/google-captcha.entry.ts"],"sourcesContent":["import { postAsync } from '@_api/_base';\n\nconst oncaptchaLoadCallback = function () {\n const grecaptcha = (window as any).grecaptcha;\n const registerButton = document.querySelector('.saig-o-signup-form__section-register button') as HTMLButtonElement;\n const disableCapcha = registerButton.dataset.disableCapcha;\n\n if (disableCapcha) {\n return;\n }\n\n grecaptcha.render('dvCaptcha', {\n sitekey: '6LeTP5UnAAAAAAeAOvHA8kKd51Dvqhfa__dZLiAq',\n //sitekey: '6LeIB8onAAAAAAuLwgUp2WL0dkUWBzVcefR756nE', // Dev key\n 'expired-callback': captchaExpiryCallback,\n callback: captchaCallback,\n });\n};\nconst captchaExpiryCallback = function () {\n const txtCaptcha = document.querySelector('[id*=txtCaptcha]')!;\n txtCaptcha.textContent = 'Captcha verification expired';\n window.signupFormStatus = { ...window.signupFormStatus, capchaVerify: false };\n window.dispatchEvent(new CustomEvent('verifyRegister'));\n};\nconst captchaCallback = function (response: any) {\n const divCaptcha = document.getElementById('dvCaptcha');\n const url = divCaptcha?.dataset.url;\n\n postAsync(url ?? '/en-au/api/UserAccount/VerifyCaptcha', undefined, `\"${response}\"`).then((res) => {\n const txtCaptcha = document.querySelector('[id*=txtCaptcha]')!;\n const captchaResponse = JSON.parse(res);\n if (captchaResponse.success) {\n txtCaptcha.textContent = captchaResponse.success;\n window.signupFormStatus = { ...window.signupFormStatus, capchaVerify: true };\n window.dispatchEvent(new CustomEvent('verifyRegister'));\n } else {\n txtCaptcha.textContent = 'Captcha verification failed';\n }\n });\n};\n\nconst setupCaptcha = () => {\n const script = document.createElement('script');\n\n script.src = 'https://www.google.com/recaptcha/api.js?onload=oncaptchaLoadCallback&render=explicit';\n script.async = true;\n script.type = 'text/javascript';\n\n document.body.appendChild(script);\n};\n(window as any).captchaCallback = captchaCallback;\n(window as any).oncaptchaLoadCallback = oncaptchaLoadCallback;\n\nsetupCaptcha();\nexport {};\n"],"names":["oncaptchaLoadCallback","grecaptcha","captchaExpiryCallback","captchaCallback","txtCaptcha","response","divCaptcha","url","postAsync","res","captchaResponse","setupCaptcha","script"],"mappings":"0CAEA,MAAMA,EAAwB,UAAY,CACxC,MAAMC,EAAc,OAAe,WACZ,SAAS,cAAc,8CAA8C,EACvD,QAAQ,eAM7CA,EAAW,OAAO,YAAa,CAC7B,QAAS,2CAET,mBAAoBC,EACpB,SAAUC,CAAA,CACX,CACH,EACMD,EAAwB,UAAY,CAClC,MAAAE,EAAa,SAAS,cAAc,kBAAkB,EAC5DA,EAAW,YAAc,+BACzB,OAAO,iBAAmB,CAAE,GAAG,OAAO,iBAAkB,aAAc,IACtE,OAAO,cAAc,IAAI,YAAY,gBAAgB,CAAC,CACxD,EACMD,EAAkB,SAAUE,EAAe,CACzC,MAAAC,EAAa,SAAS,eAAe,WAAW,EAChDC,EAAMD,GAAA,YAAAA,EAAY,QAAQ,IAEtBE,EAAAD,GAAO,uCAAwC,OAAW,IAAIF,IAAW,EAAE,KAAMI,GAAQ,CAC3F,MAAAL,EAAa,SAAS,cAAc,kBAAkB,EACtDM,EAAkB,KAAK,MAAMD,CAAG,EAClCC,EAAgB,SAClBN,EAAW,YAAcM,EAAgB,QACzC,OAAO,iBAAmB,CAAE,GAAG,OAAO,iBAAkB,aAAc,IACtE,OAAO,cAAc,IAAI,YAAY,gBAAgB,CAAC,GAEtDN,EAAW,YAAc,6BAC3B,CACD,CACH,EAEMO,EAAe,IAAM,CACnB,MAAAC,EAAS,SAAS,cAAc,QAAQ,EAE9CA,EAAO,IAAM,uFACbA,EAAO,MAAQ,GACfA,EAAO,KAAO,kBAEL,SAAA,KAAK,YAAYA,CAAM,CAClC,EACC,OAAe,gBAAkBT,EACjC,OAAe,sBAAwBH,EAExCW,EAAa"}