From dc10c7262e102eda85e018ea63796d7b1c9c351e Mon Sep 17 00:00:00 2001 From: Daniel Regeci <536331+ovx@users.noreply.github.com> Date: Thu, 14 Nov 2024 10:14:07 +0700 Subject: [PATCH] 1.0.7 --- dist/altcha.js | 2 +- dist/altcha.umd.cjs | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/altcha.js b/dist/altcha.js index c630860..5e14265 100644 --- a/dist/altcha.js +++ b/dist/altcha.js @@ -1063,7 +1063,7 @@ function An(n, e, t) { ln(() => { Et(), y && (y.removeEventListener("submit", je), y.removeEventListener("reset", Pe), y.removeEventListener("focusin", Te), y = null), J && (clearTimeout(J), J = null), document.removeEventListener("click", Ye), document.removeEventListener("scroll", We), window.removeEventListener("resize", Me); }), on(() => { - k("mounted", "1.0.6"), k("workers", le), zt(), k("plugins", te.length ? te.map((r) => r.constructor.pluginName).join(", ") : "none"), b && k("using test mode"), S && ke(S), f !== void 0 && k("auto", f), z !== void 0 && Ue(z), y = E.closest("form"), y && (y.addEventListener("submit", je, { capture: !0 }), y.addEventListener("reset", Pe), f === "onfocus" && y.addEventListener("focusin", Te)), f === "onload" && (x ? ge() : ne()), i && (Z || G) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."), requestAnimationFrame(() => { + k("mounted", "1.0.7"), k("workers", le), zt(), k("plugins", te.length ? te.map((r) => r.constructor.pluginName).join(", ") : "none"), b && k("using test mode"), S && ke(S), f !== void 0 && k("auto", f), z !== void 0 && Ue(z), y = E.closest("form"), y && (y.addEventListener("submit", je, { capture: !0 }), y.addEventListener("reset", Pe), f === "onfocus" && y.addEventListener("focusin", Te)), f === "onload" && (x ? ge() : ne()), i && (Z || G) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."), requestAnimationFrame(() => { de("load"); }); }); diff --git a/dist/altcha.umd.cjs b/dist/altcha.umd.cjs index 36ba9ad..9d82655 100644 --- a/dist/altcha.umd.cjs +++ b/dist/altcha.umd.cjs @@ -1,2 +1,2 @@ -(function(F,W){typeof exports=="object"&&typeof module<"u"?W(exports):typeof define=="function"&&define.amd?define(["exports"],W):(F=typeof globalThis<"u"?globalThis:F||self,W(F.altcha={}))})(this,function(F){"use strict";var Xn=Object.defineProperty;var Zn=(F,W,ce)=>W in F?Xn(F,W,{enumerable:!0,configurable:!0,writable:!0,value:ce}):F[W]=ce;var J=(F,W,ce)=>Zn(F,typeof W!="symbol"?W+"":W,ce);const W="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGQ9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIHAoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBiKGUsdCxyKXtpZih0eXBlb2YgY3J5cHRvPiJ1Inx8ISgic3VidGxlImluIGNyeXB0byl8fCEoImRpZ2VzdCJpbiBjcnlwdG8uc3VidGxlKSl0aHJvdyBuZXcgRXJyb3IoIldlYiBDcnlwdG8gaXMgbm90IGF2YWlsYWJsZS4gU2VjdXJlIGNvbnRleHQgaXMgcmVxdWlyZWQgKGh0dHBzOi8vZGV2ZWxvcGVyLm1vemlsbGEub3JnL2VuLVVTL2RvY3MvV2ViL1NlY3VyaXR5L1NlY3VyZV9Db250ZXh0cykuIik7cmV0dXJuIHAoYXdhaXQgY3J5cHRvLnN1YnRsZS5kaWdlc3Qoci50b1VwcGVyQ2FzZSgpLGQuZW5jb2RlKGUrdCkpKX1mdW5jdGlvbiB3KGUsdCxyPSJTSEEtMjU2IixuPTFlNixzPTApe2NvbnN0IG89bmV3IEFib3J0Q29udHJvbGxlcixhPURhdGUubm93KCk7cmV0dXJue3Byb21pc2U6KGFzeW5jKCk9Pntmb3IobGV0IGM9cztjPD1uO2MrPTEpe2lmKG8uc2lnbmFsLmFib3J0ZWQpcmV0dXJuIG51bGw7aWYoYXdhaXQgYih0LGMscik9PT1lKXJldHVybntudW1iZXI6Yyx0b29rOkRhdGUubm93KCktYX19cmV0dXJuIG51bGx9KSgpLGNvbnRyb2xsZXI6b319ZnVuY3Rpb24gaChlKXtjb25zdCB0PWF0b2IoZSkscj1uZXcgVWludDhBcnJheSh0Lmxlbmd0aCk7Zm9yKGxldCBuPTA7bjx0Lmxlbmd0aDtuKyspcltuXT10LmNoYXJDb2RlQXQobik7cmV0dXJuIHJ9ZnVuY3Rpb24gZyhlLHQ9MTIpe2NvbnN0IHI9bmV3IFVpbnQ4QXJyYXkodCk7Zm9yKGxldCBuPTA7bjx0O24rKylyW25dPWUlMjU2LGU9TWF0aC5mbG9vcihlLzI1Nik7cmV0dXJuIHJ9YXN5bmMgZnVuY3Rpb24gbShlLHQ9IiIscj0xZTYsbj0wKXtjb25zdCBzPSJBRVMtR0NNIixvPW5ldyBBYm9ydENvbnRyb2xsZXIsYT1EYXRlLm5vdygpLGw9YXN5bmMoKT0+e2ZvcihsZXQgdT1uO3U8PXI7dSs9MSl7aWYoby5zaWduYWwuYWJvcnRlZHx8IWN8fCF5KXJldHVybiBudWxsO3RyeXtjb25zdCBmPWF3YWl0IGNyeXB0by5zdWJ0bGUuZGVjcnlwdCh7bmFtZTpzLGl2OmcodSl9LGMseSk7aWYoZilyZXR1cm57Y2xlYXJUZXh0Om5ldyBUZXh0RGVjb2RlcigpLmRlY29kZShmKSx0b29rOkRhdGUubm93KCktYX19Y2F0Y2h7fX1yZXR1cm4gbnVsbH07bGV0IGM9bnVsbCx5PW51bGw7dHJ5e3k9aChlKTtjb25zdCB1PWF3YWl0IGNyeXB0by5zdWJ0bGUuZGlnZXN0KCJTSEEtMjU2IixkLmVuY29kZSh0KSk7Yz1hd2FpdCBjcnlwdG8uc3VidGxlLmltcG9ydEtleSgicmF3Iix1LHMsITEsWyJkZWNyeXB0Il0pfWNhdGNoe3JldHVybntwcm9taXNlOlByb21pc2UucmVqZWN0KCksY29udHJvbGxlcjpvfX1yZXR1cm57cHJvbWlzZTpsKCksY29udHJvbGxlcjpvfX1sZXQgaTtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOnIsc3RhcnQ6bixtYXg6c309ZS5kYXRhO2xldCBvPW51bGw7aWYodD09PSJhYm9ydCIpaT09bnVsbHx8aS5hYm9ydCgpLGk9dm9pZCAwO2Vsc2UgaWYodD09PSJ3b3JrIil7aWYoIm9iZnVzY2F0ZWQiaW4gcil7Y29uc3R7a2V5OmEsb2JmdXNjYXRlZDpsfT1yfHx7fTtvPWF3YWl0IG0obCxhLHMsbil9ZWxzZXtjb25zdHthbGdvcml0aG06YSxjaGFsbGVuZ2U6bCxzYWx0OmN9PXJ8fHt9O289dyhsLGMsYSxzLG4pfWk9by5jb250cm9sbGVyLG8ucHJvbWlzZS50aGVuKGE9PntzZWxmLnBvc3RNZXNzYWdlKGEmJnsuLi5hLHdvcmtlcjohMH0pfSl9fX0pKCk7Cg==",ce=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),Ze=typeof self<"u"&&self.Blob&&new Blob([ce(W)],{type:"text/javascript;charset=utf-8"});function Rt(n){let e;try{if(e=Ze&&(self.URL||self.webkitURL).createObjectURL(Ze),!e)throw"";const t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+W,{name:n==null?void 0:n.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}function Ee(){}function Lt(n,e){for(const t in e)n[t]=e[t];return n}function Te(n){return n()}function Ye(){return Object.create(null)}function ge(n){n.forEach(Te)}function je(n){return typeof n=="function"}function zt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Vt(n){return Object.keys(n).length===0}function St(n,e,t,i){if(n){const o=We(n,e,t,i);return n[0](o)}}function We(n,e,t,i){return n[1]&&i?Lt(t.ctx.slice(),n[1](i(e))):t.ctx}function Gt(n,e,t,i){if(n[2]&&i){const o=n[2](i(t));if(e.dirty===void 0)return o;if(typeof o=="object"){const l=[],s=Math.max(e.dirty.length,o.length);for(let d=0;d32){const e=[],t=n.ctx.length/32;for(let i=0;in.removeEventListener(e,t,i)}function a(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function jt(n){return Array.from(n.childNodes)}function Pe(n,e,t){n.classList.toggle(e,!!t)}function Wt(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function Pt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let me;function be(n){me=n}function Se(){if(!me)throw new Error("Function called outside component initialization");return me}function Ft(n){Se().$$.on_mount.push(n)}function Mt(n){Se().$$.on_destroy.push(n)}function Ut(){const n=Se();return(e,t,{cancelable:i=!1}={})=>{const o=n.$$.callbacks[e];if(o){const l=Wt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(n,l)}),!l.defaultPrevented}return!0}}const ae=[],Ce=[];let fe=[];const Fe=[],Me=Promise.resolve();let Ge=!1;function Ue(){Ge||(Ge=!0,Me.then(w))}function Ht(){return Ue(),Me}function Ne(n){fe.push(n)}const Ae=new Set;let ue=0;function w(){if(ue!==0)return;const n=me;do{try{for(;uen.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),fe=e}const Ie=new Set;let Jt;function He(n,e){n&&n.i&&(Ie.delete(n),n.i(e))}function Ot(n,e,t,i){if(n&&n.o){if(Ie.has(n))return;Ie.add(n),Jt.c.push(()=>{Ie.delete(n)}),n.o(e)}}function Kt(n,e,t){const{fragment:i,after_update:o}=n.$$;i&&i.m(e,t),Ne(()=>{const l=n.$$.on_mount.map(Te).filter(je);n.$$.on_destroy?n.$$.on_destroy.push(...l):ge(l),n.$$.on_mount=[]}),o.forEach(Ne)}function $t(n,e){const t=n.$$;t.fragment!==null&&(Dt(t.after_update),ge(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Qt(n,e){n.$$.dirty[0]===-1&&(ae.push(n),Ue(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const H=U.length?U[0]:M;return f.ctx&&o(f.ctx[v],f.ctx[v]=H)&&(!f.skip_bound&&f.bound[v]&&f.bound[v](H),R&&Qt(n,v)),M}):[],f.update(),R=!0,ge(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const v=jt(e.target);f.fragment&&f.fragment.l(v),v.forEach(T)}else f.fragment&&f.fragment.c();e.intro&&He(n.$$.fragment),Kt(n,e.target,e.anchor),w()}be(h)}let Be;typeof HTMLElement=="function"&&(Be=class extends HTMLElement{constructor(e,t,i){super();J(this,"$$ctor");J(this,"$$s");J(this,"$$c");J(this,"$$cn",!1);J(this,"$$d",{});J(this,"$$r",!1);J(this,"$$p_d",{});J(this,"$$l",{});J(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}if(this.$$l[e]){const o=this.$$l[e].indexOf(t);o>=0&&this.$$l[e].splice(o,1)}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=S("slot"),l!=="default"&&a(s,"name",l)},m:function(f,R){j(f,s,R)},d:function(f){f&&T(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=Pt(this);for(const l of this.$$s)l in i&&(t[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=Re(s,l.value,this.$$p_d,"toProp"))}for(const l in this.$$p_d)!(l in this.$$d)&&this[l]!==void 0&&(this.$$d[l]=this[l],delete this[l]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const l in this.$$p_d)if(this.$$d[l]=this.$$c.$$.ctx[this.$$c.$$.props[l]],this.$$p_d[l].reflect){const s=Re(l,this.$$d[l],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const s of this.$$l[l]){const d=this.$$c.$on(l,s);this.$$l_u.set(s,d)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Re(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Re(n,e,t,i){var l;const o=(l=t[n])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function en(n,e,t,i,o,l){let s=class extends Be{constructor(){super(n,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(d=>(e[d].attribute||d).toLowerCase())}};return Object.keys(e).forEach(d=>{Object.defineProperty(s.prototype,d,{get(){return this.$$c&&d in this.$$c?this.$$c[d]:this.$$d[d]},set(h){var f;h=Re(d,h,e),this.$$d[d]=h,(f=this.$$c)==null||f.$set({[d]:h})}})}),i.forEach(d=>{Object.defineProperty(s.prototype,d,{get(){var h;return(h=this.$$c)==null?void 0:h[d]}})}),n.element=s,s}class tn{constructor(){J(this,"$$");J(this,"$$set")}$destroy(){$t(this,1),this.$destroy=Ee}$on(e,t){if(!je(t))return Ee;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!Vt(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const nn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(nn);const De=new TextEncoder;function rn(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function on(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await Je(i,n,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Je(n,e,t){if(typeof crypto>"u"||!("subtle"in crypto)||!("digest"in crypto.subtle))throw new Error("Web Crypto is not available. Secure context is required (https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts).");return rn(await crypto.subtle.digest(t.toUpperCase(),De.encode(n+e)))}function ln(n,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let h=o;h<=i;h+=1){if(l.signal.aborted)return null;if(await Je(e,h,t)===n)return{number:h,took:Date.now()-s}}return null})(),controller:l}}function sn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function cn(n){const e=atob(n),t=new Uint8Array(e.length);for(let i=0;i{for(let R=i;R<=t;R+=1){if(l.signal.aborted||!h||!f)return null;try{const v=await crypto.subtle.decrypt({name:o,iv:an(R)},h,f);if(v)return{clearText:new TextDecoder().decode(v),took:Date.now()-s}}catch{}}return null};let h=null,f=null;try{f=cn(n);const R=await crypto.subtle.digest("SHA-256",De.encode(e));h=await crypto.subtle.importKey("raw",R,o,!1,["decrypt"])}catch{return{promise:Promise.reject(),controller:l}}return{promise:d(),controller:l}}var g=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(g||{});function un(n){Xt(n,"svelte-ddsc3z",'.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}')}function Oe(n){let e,t,i;return{c(){e=$("svg"),t=$("path"),i=$("path"),a(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),a(t,"fill","currentColor"),a(t,"opacity",".25"),a(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),a(i,"fill","currentColor"),a(i,"class","altcha-spinner svelte-ddsc3z"),a(e,"width","24"),a(e,"height","24"),a(e,"viewBox","0 0 24 24"),a(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){j(o,e,l),I(e,t),I(e,i)},d(o){o&&T(e)}}}function dn(n){let e,t=n[11].label+"",i;return{c(){e=S("label"),a(e,"for",i=n[4]+"_checkbox"),a(e,"class","svelte-ddsc3z")},m(o,l){j(o,e,l),e.innerHTML=t},p(o,l){l[0]&2048&&t!==(t=o[11].label+"")&&(e.innerHTML=t),l[0]&16&&i!==(i=o[4]+"_checkbox")&&a(e,"for",i)},d(o){o&&T(e)}}}function hn(n){let e,t=n[11].verifying+"";return{c(){e=S("span")},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].verifying+"")&&(e.innerHTML=t)},d(i){i&&T(e)}}}function gn(n){let e,t=n[11].verified+"",i,o;return{c(){e=S("span"),i=Q(),o=S("input"),a(o,"type","hidden"),a(o,"name",n[4]),o.value=n[6]},m(l,s){j(l,e,s),e.innerHTML=t,j(l,i,s),j(l,o,s)},p(l,s){s[0]&2048&&t!==(t=l[11].verified+"")&&(e.innerHTML=t),s[0]&16&&a(o,"name",l[4]),s[0]&64&&(o.value=l[6])},d(l){l&&(T(e),T(i),T(o))}}}function Ke(n){let e,t,i,o,l,s,d;return{c(){e=S("div"),t=S("a"),i=$("svg"),o=$("path"),l=$("path"),s=$("path"),a(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),a(o,"fill","currentColor"),a(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),a(l,"fill","currentColor"),a(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),a(s,"fill","currentColor"),a(i,"width","22"),a(i,"height","22"),a(i,"viewBox","0 0 20 20"),a(i,"fill","none"),a(i,"xmlns","http://www.w3.org/2000/svg"),a(t,"href",tt),a(t,"target","_blank"),a(t,"class","altcha-logo svelte-ddsc3z"),a(t,"aria-label",d=n[11].ariaLinkLabel)},m(h,f){j(h,e,f),I(e,t),I(t,i),I(i,o),I(i,l),I(i,s)},p(h,f){f[0]&2048&&d!==(d=h[11].ariaLinkLabel)&&a(t,"aria-label",d)},d(h){h&&T(e)}}}function $e(n){let e,t,i,o;function l(h,f){return h[7]===g.EXPIRED?bn:mn}let s=l(n),d=s(n);return{c(){e=S("div"),t=$("svg"),i=$("path"),o=Q(),d.c(),a(i,"stroke-linecap","round"),a(i,"stroke-linejoin","round"),a(i,"d","M6 18L18 6M6 6l12 12"),a(t,"width","14"),a(t,"height","14"),a(t,"xmlns","http://www.w3.org/2000/svg"),a(t,"fill","none"),a(t,"viewBox","0 0 24 24"),a(t,"stroke-width","1.5"),a(t,"stroke","currentColor"),a(e,"class","altcha-error svelte-ddsc3z")},m(h,f){j(h,e,f),I(e,t),I(t,i),I(e,o),d.m(e,null)},p(h,f){s===(s=l(h))&&d?d.p(h,f):(d.d(1),d=s(h),d&&(d.c(),d.m(e,null)))},d(h){h&&T(e),d.d()}}}function mn(n){let e,t=n[11].error+"";return{c(){e=S("div"),a(e,"title",n[5])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&T(e)}}}function bn(n){let e,t=n[11].expired+"";return{c(){e=S("div"),a(e,"title",n[5])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&T(e)}}}function Qe(n){let e,t,i=n[11].footer+"";return{c(){e=S("div"),t=S("div"),a(t,"class","svelte-ddsc3z"),a(e,"class","altcha-footer svelte-ddsc3z")},m(o,l){j(o,e,l),I(e,t),t.innerHTML=i},p(o,l){l[0]&2048&&i!==(i=o[11].footer+"")&&(t.innerHTML=i)},d(o){o&&T(e)}}}function qe(n){let e;return{c(){e=S("div"),a(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){j(t,e,i),n[48](e)},p:Ee,d(t){t&&T(e),n[48](null)}}}function yn(n){let e,t,i,o,l,s,d,h,f,R,v,M,U,H,G,z,q;const ee=n[46].default,Z=St(ee,n,n[45],null);let N=n[7]===g.VERIFYING&&Oe();function te(u,b){return u[7]===g.VERIFIED?gn:u[7]===g.VERIFYING?hn:dn}let O=te(n),Y=O(n),x=(n[3]!==!0||n[12])&&Ke(n),A=(n[5]||n[7]===g.EXPIRED)&&$e(n),V=n[11].footer&&(n[2]!==!0||n[12])&&Qe(n),_=n[1]&&qe(n);return{c(){Z&&Z.c(),e=Q(),t=S("div"),i=S("div"),N&&N.c(),o=Q(),l=S("div"),s=S("input"),f=Q(),R=S("div"),Y.c(),v=Q(),x&&x.c(),M=Q(),A&&A.c(),U=Q(),V&&V.c(),H=Q(),_&&_.c(),a(s,"type","checkbox"),a(s,"id",d=n[4]+"_checkbox"),s.required=h=n[0]!=="onsubmit"&&(!n[1]||n[0]!=="off"),a(s,"class","svelte-ddsc3z"),a(l,"class","altcha-checkbox svelte-ddsc3z"),Pe(l,"altcha-hidden",n[7]===g.VERIFYING),a(R,"class","altcha-label svelte-ddsc3z"),a(i,"class","altcha-main svelte-ddsc3z"),a(t,"class","altcha svelte-ddsc3z"),a(t,"data-state",n[7]),a(t,"data-floating",n[1])},m(u,b){Z&&Z.m(u,b),j(u,e,b),j(u,t,b),I(t,i),N&&N.m(i,null),I(i,o),I(i,l),I(l,s),s.checked=n[8],I(i,f),I(i,R),Y.m(R,null),I(i,v),x&&x.m(i,null),I(t,M),A&&A.m(t,null),I(t,U),V&&V.m(t,null),I(t,H),_&&_.m(t,null),n[49](t),G=!0,z||(q=[Ve(s,"change",n[47]),Ve(s,"change",n[13]),Ve(s,"invalid",n[14])],z=!0)},p(u,b){Z&&Z.p&&(!G||b[1]&16384)&&Nt(Z,ee,u,u[45],G?Gt(ee,u[45],b,null):At(u[45]),null),u[7]===g.VERIFYING?N||(N=Oe(),N.c(),N.m(i,o)):N&&(N.d(1),N=null),(!G||b[0]&16&&d!==(d=u[4]+"_checkbox"))&&a(s,"id",d),(!G||b[0]&3&&h!==(h=u[0]!=="onsubmit"&&(!u[1]||u[0]!=="off")))&&(s.required=h),b[0]&256&&(s.checked=u[8]),(!G||b[0]&128)&&Pe(l,"altcha-hidden",u[7]===g.VERIFYING),O===(O=te(u))&&Y?Y.p(u,b):(Y.d(1),Y=O(u),Y&&(Y.c(),Y.m(R,null))),u[3]!==!0||u[12]?x?x.p(u,b):(x=Ke(u),x.c(),x.m(i,null)):x&&(x.d(1),x=null),u[5]||u[7]===g.EXPIRED?A?A.p(u,b):(A=$e(u),A.c(),A.m(t,U)):A&&(A.d(1),A=null),u[11].footer&&(u[2]!==!0||u[12])?V?V.p(u,b):(V=Qe(u),V.c(),V.m(t,H)):V&&(V.d(1),V=null),u[1]?_?_.p(u,b):(_=qe(u),_.c(),_.m(t,null)):_&&(_.d(1),_=null),(!G||b[0]&128)&&a(t,"data-state",u[7]),(!G||b[0]&2)&&a(t,"data-floating",u[1])},i(u){G||(He(Z,u),G=!0)},o(u){Ot(Z,u),G=!1},d(u){u&&(T(e),T(t)),Z&&Z.d(u),N&&N.d(),Y.d(),x&&x.d(),A&&A.d(),V&&V.d(),_&&_.d(),n[49](null),z=!1,ge(q)}}}const et="Visit Altcha.org",tt="https://altcha.org/";function nt(n){return JSON.parse(n)}function vn(n,e,t){var Et,Ct;let i,o,l,s,{$$slots:d={},$$scope:h}=e,{auto:f=void 0}=e,{blockspam:R=void 0}=e,{challengeurl:v=void 0}=e,{challengejson:M=void 0}=e,{debug:U=!1}=e,{delay:H=0}=e,{expire:G=void 0}=e,{floating:z=void 0}=e,{floatinganchor:q=void 0}=e,{floatingoffset:ee=void 0}=e,{hidefooter:Z=!1}=e,{hidelogo:N=!1}=e,{name:te="altcha"}=e,{maxnumber:O=1e6}=e,{mockerror:Y=!1}=e,{obfuscated:x=void 0}=e,{plugins:A=void 0}=e,{refetchonexpire:V=!0}=e,{spamfilter:_=!1}=e,{strings:u=void 0}=e,{test:b=!1}=e,{verifyurl:ne=void 0}=e,{workers:de=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:ye=void 0}=e;const ve=Ut(),it=["SHA-256","SHA-384","SHA-512"],ot=(Ct=(Et=document.documentElement.lang)==null?void 0:Et.split("-"))==null?void 0:Ct[0];let oe=!1,E,le=null,he=null,y=null,pe=null,K=null,se=null,re=[],C=g.UNVERIFIED;Mt(()=>{pn(),y&&(y.removeEventListener("submit",ut),y.removeEventListener("reset",dt),y.removeEventListener("focusin",ft),y=null),K&&(clearTimeout(K),K=null),document.removeEventListener("click",ct),document.removeEventListener("scroll",at),window.removeEventListener("resize",gt)}),Ft(()=>{k("mounted","1.0.6"),k("workers",de),En(),k("plugins",re.length?re.map(r=>r.constructor.pluginName).join(", "):"none"),b&&k("using test mode"),G&&ze(G),f!==void 0&&k("auto",f),z!==void 0&&mt(z),y=E.closest("form"),y&&(y.addEventListener("submit",ut,{capture:!0}),y.addEventListener("reset",dt),f==="onfocus"&&y.addEventListener("focusin",ft)),f==="onload"&&(x?we():ie()),i&&(Z||N)&&k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."),requestAnimationFrame(()=>{ve("load")})});function lt(r,c){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:c.number,salt:r.salt,signature:r.signature,test:b?!0:void 0,took:c.took}))}function pn(){for(const r of re)r.destroy()}function st(){v&&V&&C===g.VERIFIED?ie():_e(g.EXPIRED,s.expired)}async function wn(){var r;if(Y)throw k("mocking error"),new Error("Mocked error.");if(o)return k("using provided json data"),o;if(b)return k("generating test challenge",{test:b}),on(typeof b!="boolean"?+b:void 0);{if(!v&&y){const p=y.getAttribute("action");p!=null&&p.includes("/form/")&&t(15,v=p+"/altcha")}if(!v)throw new Error("Attribute challengeurl not set.");k("fetching challenge from",v);const c=await fetch(v,{headers:_?{"x-altcha-spam-filter":"1"}:{}});if(c.status!==200)throw new Error(`Server responded with ${c.status}.`);const m=c.headers.get("Expires"),L=c.headers.get("X-Altcha-Config"),B=await c.json(),P=new URLSearchParams((r=B.salt.split("?"))==null?void 0:r[1]),X=P.get("expires")||P.get("expire");if(X){const p=new Date(+X*1e3),D=isNaN(p.getTime())?0:p.getTime()-Date.now();D>0&&ze(D)}if(L)try{const p=JSON.parse(L);p&&typeof p=="object"&&(p.verifyurl&&(p.verifyurl=new URL(p.verifyurl,new URL(v)).toString()),vt(p))}catch(p){k("unable to configure from X-Altcha-Config",p)}if(!G&&(m!=null&&m.length)){const p=Date.parse(m);if(p){const D=p-Date.now();D>0&&ze(D)}}return B}}function _n(r){var m;const c=y==null?void 0:y.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((m=c==null?void 0:c.value)==null?void 0:m.slice(c.value.indexOf("@")))||void 0}function kn(){return _==="ipAddress"?{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:!1,expectedCountries:void 0,expectedLanguages:void 0,fields:!1,ipAddress:void 0,text:void 0,timeZone:void 0}:typeof _=="object"?_:{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,text:void 0,timeZone:void 0}}function xn(r){return[...(y==null?void 0:y.querySelectorAll(r!=null&&r.length?r.map(m=>`input[name="${m}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((m,L)=>{const B=L.name,P=L.value;return B&&P&&(m[B]=/\n/.test(P)?P.replace(new RegExp("(?W in F?Xn(F,W,{enumerable:!0,configurable:!0,writable:!0,value:ce}):F[W]=ce;var J=(F,W,ce)=>Zn(F,typeof W!="symbol"?W+"":W,ce);const W="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGQ9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIHAoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBiKGUsdCxyKXtpZih0eXBlb2YgY3J5cHRvPiJ1Inx8ISgic3VidGxlImluIGNyeXB0byl8fCEoImRpZ2VzdCJpbiBjcnlwdG8uc3VidGxlKSl0aHJvdyBuZXcgRXJyb3IoIldlYiBDcnlwdG8gaXMgbm90IGF2YWlsYWJsZS4gU2VjdXJlIGNvbnRleHQgaXMgcmVxdWlyZWQgKGh0dHBzOi8vZGV2ZWxvcGVyLm1vemlsbGEub3JnL2VuLVVTL2RvY3MvV2ViL1NlY3VyaXR5L1NlY3VyZV9Db250ZXh0cykuIik7cmV0dXJuIHAoYXdhaXQgY3J5cHRvLnN1YnRsZS5kaWdlc3Qoci50b1VwcGVyQ2FzZSgpLGQuZW5jb2RlKGUrdCkpKX1mdW5jdGlvbiB3KGUsdCxyPSJTSEEtMjU2IixuPTFlNixzPTApe2NvbnN0IG89bmV3IEFib3J0Q29udHJvbGxlcixhPURhdGUubm93KCk7cmV0dXJue3Byb21pc2U6KGFzeW5jKCk9Pntmb3IobGV0IGM9cztjPD1uO2MrPTEpe2lmKG8uc2lnbmFsLmFib3J0ZWQpcmV0dXJuIG51bGw7aWYoYXdhaXQgYih0LGMscik9PT1lKXJldHVybntudW1iZXI6Yyx0b29rOkRhdGUubm93KCktYX19cmV0dXJuIG51bGx9KSgpLGNvbnRyb2xsZXI6b319ZnVuY3Rpb24gaChlKXtjb25zdCB0PWF0b2IoZSkscj1uZXcgVWludDhBcnJheSh0Lmxlbmd0aCk7Zm9yKGxldCBuPTA7bjx0Lmxlbmd0aDtuKyspcltuXT10LmNoYXJDb2RlQXQobik7cmV0dXJuIHJ9ZnVuY3Rpb24gZyhlLHQ9MTIpe2NvbnN0IHI9bmV3IFVpbnQ4QXJyYXkodCk7Zm9yKGxldCBuPTA7bjx0O24rKylyW25dPWUlMjU2LGU9TWF0aC5mbG9vcihlLzI1Nik7cmV0dXJuIHJ9YXN5bmMgZnVuY3Rpb24gbShlLHQ9IiIscj0xZTYsbj0wKXtjb25zdCBzPSJBRVMtR0NNIixvPW5ldyBBYm9ydENvbnRyb2xsZXIsYT1EYXRlLm5vdygpLGw9YXN5bmMoKT0+e2ZvcihsZXQgdT1uO3U8PXI7dSs9MSl7aWYoby5zaWduYWwuYWJvcnRlZHx8IWN8fCF5KXJldHVybiBudWxsO3RyeXtjb25zdCBmPWF3YWl0IGNyeXB0by5zdWJ0bGUuZGVjcnlwdCh7bmFtZTpzLGl2OmcodSl9LGMseSk7aWYoZilyZXR1cm57Y2xlYXJUZXh0Om5ldyBUZXh0RGVjb2RlcigpLmRlY29kZShmKSx0b29rOkRhdGUubm93KCktYX19Y2F0Y2h7fX1yZXR1cm4gbnVsbH07bGV0IGM9bnVsbCx5PW51bGw7dHJ5e3k9aChlKTtjb25zdCB1PWF3YWl0IGNyeXB0by5zdWJ0bGUuZGlnZXN0KCJTSEEtMjU2IixkLmVuY29kZSh0KSk7Yz1hd2FpdCBjcnlwdG8uc3VidGxlLmltcG9ydEtleSgicmF3Iix1LHMsITEsWyJkZWNyeXB0Il0pfWNhdGNoe3JldHVybntwcm9taXNlOlByb21pc2UucmVqZWN0KCksY29udHJvbGxlcjpvfX1yZXR1cm57cHJvbWlzZTpsKCksY29udHJvbGxlcjpvfX1sZXQgaTtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOnIsc3RhcnQ6bixtYXg6c309ZS5kYXRhO2xldCBvPW51bGw7aWYodD09PSJhYm9ydCIpaT09bnVsbHx8aS5hYm9ydCgpLGk9dm9pZCAwO2Vsc2UgaWYodD09PSJ3b3JrIil7aWYoIm9iZnVzY2F0ZWQiaW4gcil7Y29uc3R7a2V5OmEsb2JmdXNjYXRlZDpsfT1yfHx7fTtvPWF3YWl0IG0obCxhLHMsbil9ZWxzZXtjb25zdHthbGdvcml0aG06YSxjaGFsbGVuZ2U6bCxzYWx0OmN9PXJ8fHt9O289dyhsLGMsYSxzLG4pfWk9by5jb250cm9sbGVyLG8ucHJvbWlzZS50aGVuKGE9PntzZWxmLnBvc3RNZXNzYWdlKGEmJnsuLi5hLHdvcmtlcjohMH0pfSl9fX0pKCk7Cg==",ce=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),Ze=typeof self<"u"&&self.Blob&&new Blob([ce(W)],{type:"text/javascript;charset=utf-8"});function Rt(n){let e;try{if(e=Ze&&(self.URL||self.webkitURL).createObjectURL(Ze),!e)throw"";const t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+W,{name:n==null?void 0:n.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}function Ee(){}function Lt(n,e){for(const t in e)n[t]=e[t];return n}function Te(n){return n()}function Ye(){return Object.create(null)}function ge(n){n.forEach(Te)}function je(n){return typeof n=="function"}function zt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Vt(n){return Object.keys(n).length===0}function St(n,e,t,i){if(n){const o=We(n,e,t,i);return n[0](o)}}function We(n,e,t,i){return n[1]&&i?Lt(t.ctx.slice(),n[1](i(e))):t.ctx}function Gt(n,e,t,i){if(n[2]&&i){const o=n[2](i(t));if(e.dirty===void 0)return o;if(typeof o=="object"){const l=[],s=Math.max(e.dirty.length,o.length);for(let d=0;d32){const e=[],t=n.ctx.length/32;for(let i=0;in.removeEventListener(e,t,i)}function a(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function jt(n){return Array.from(n.childNodes)}function Pe(n,e,t){n.classList.toggle(e,!!t)}function Wt(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function Pt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let me;function be(n){me=n}function Se(){if(!me)throw new Error("Function called outside component initialization");return me}function Ft(n){Se().$$.on_mount.push(n)}function Mt(n){Se().$$.on_destroy.push(n)}function Ut(){const n=Se();return(e,t,{cancelable:i=!1}={})=>{const o=n.$$.callbacks[e];if(o){const l=Wt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(n,l)}),!l.defaultPrevented}return!0}}const ae=[],Ce=[];let fe=[];const Fe=[],Me=Promise.resolve();let Ge=!1;function Ue(){Ge||(Ge=!0,Me.then(w))}function Ht(){return Ue(),Me}function Ne(n){fe.push(n)}const Ae=new Set;let ue=0;function w(){if(ue!==0)return;const n=me;do{try{for(;uen.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),fe=e}const Ie=new Set;let Jt;function He(n,e){n&&n.i&&(Ie.delete(n),n.i(e))}function Ot(n,e,t,i){if(n&&n.o){if(Ie.has(n))return;Ie.add(n),Jt.c.push(()=>{Ie.delete(n)}),n.o(e)}}function Kt(n,e,t){const{fragment:i,after_update:o}=n.$$;i&&i.m(e,t),Ne(()=>{const l=n.$$.on_mount.map(Te).filter(je);n.$$.on_destroy?n.$$.on_destroy.push(...l):ge(l),n.$$.on_mount=[]}),o.forEach(Ne)}function $t(n,e){const t=n.$$;t.fragment!==null&&(Dt(t.after_update),ge(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Qt(n,e){n.$$.dirty[0]===-1&&(ae.push(n),Ue(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const H=U.length?U[0]:M;return f.ctx&&o(f.ctx[v],f.ctx[v]=H)&&(!f.skip_bound&&f.bound[v]&&f.bound[v](H),R&&Qt(n,v)),M}):[],f.update(),R=!0,ge(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const v=jt(e.target);f.fragment&&f.fragment.l(v),v.forEach(T)}else f.fragment&&f.fragment.c();e.intro&&He(n.$$.fragment),Kt(n,e.target,e.anchor),w()}be(h)}let Be;typeof HTMLElement=="function"&&(Be=class extends HTMLElement{constructor(e,t,i){super();J(this,"$$ctor");J(this,"$$s");J(this,"$$c");J(this,"$$cn",!1);J(this,"$$d",{});J(this,"$$r",!1);J(this,"$$p_d",{});J(this,"$$l",{});J(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}if(this.$$l[e]){const o=this.$$l[e].indexOf(t);o>=0&&this.$$l[e].splice(o,1)}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=S("slot"),l!=="default"&&a(s,"name",l)},m:function(f,R){j(f,s,R)},d:function(f){f&&T(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=Pt(this);for(const l of this.$$s)l in i&&(t[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=Re(s,l.value,this.$$p_d,"toProp"))}for(const l in this.$$p_d)!(l in this.$$d)&&this[l]!==void 0&&(this.$$d[l]=this[l],delete this[l]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const l in this.$$p_d)if(this.$$d[l]=this.$$c.$$.ctx[this.$$c.$$.props[l]],this.$$p_d[l].reflect){const s=Re(l,this.$$d[l],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const s of this.$$l[l]){const d=this.$$c.$on(l,s);this.$$l_u.set(s,d)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Re(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Re(n,e,t,i){var l;const o=(l=t[n])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function en(n,e,t,i,o,l){let s=class extends Be{constructor(){super(n,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(d=>(e[d].attribute||d).toLowerCase())}};return Object.keys(e).forEach(d=>{Object.defineProperty(s.prototype,d,{get(){return this.$$c&&d in this.$$c?this.$$c[d]:this.$$d[d]},set(h){var f;h=Re(d,h,e),this.$$d[d]=h,(f=this.$$c)==null||f.$set({[d]:h})}})}),i.forEach(d=>{Object.defineProperty(s.prototype,d,{get(){var h;return(h=this.$$c)==null?void 0:h[d]}})}),n.element=s,s}class tn{constructor(){J(this,"$$");J(this,"$$set")}$destroy(){$t(this,1),this.$destroy=Ee}$on(e,t){if(!je(t))return Ee;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!Vt(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const nn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(nn);const De=new TextEncoder;function rn(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function on(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await Je(i,n,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Je(n,e,t){if(typeof crypto>"u"||!("subtle"in crypto)||!("digest"in crypto.subtle))throw new Error("Web Crypto is not available. Secure context is required (https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts).");return rn(await crypto.subtle.digest(t.toUpperCase(),De.encode(n+e)))}function ln(n,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let h=o;h<=i;h+=1){if(l.signal.aborted)return null;if(await Je(e,h,t)===n)return{number:h,took:Date.now()-s}}return null})(),controller:l}}function sn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function cn(n){const e=atob(n),t=new Uint8Array(e.length);for(let i=0;i{for(let R=i;R<=t;R+=1){if(l.signal.aborted||!h||!f)return null;try{const v=await crypto.subtle.decrypt({name:o,iv:an(R)},h,f);if(v)return{clearText:new TextDecoder().decode(v),took:Date.now()-s}}catch{}}return null};let h=null,f=null;try{f=cn(n);const R=await crypto.subtle.digest("SHA-256",De.encode(e));h=await crypto.subtle.importKey("raw",R,o,!1,["decrypt"])}catch{return{promise:Promise.reject(),controller:l}}return{promise:d(),controller:l}}var g=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(g||{});function un(n){Xt(n,"svelte-ddsc3z",'.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}')}function Oe(n){let e,t,i;return{c(){e=$("svg"),t=$("path"),i=$("path"),a(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),a(t,"fill","currentColor"),a(t,"opacity",".25"),a(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),a(i,"fill","currentColor"),a(i,"class","altcha-spinner svelte-ddsc3z"),a(e,"width","24"),a(e,"height","24"),a(e,"viewBox","0 0 24 24"),a(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){j(o,e,l),I(e,t),I(e,i)},d(o){o&&T(e)}}}function dn(n){let e,t=n[11].label+"",i;return{c(){e=S("label"),a(e,"for",i=n[4]+"_checkbox"),a(e,"class","svelte-ddsc3z")},m(o,l){j(o,e,l),e.innerHTML=t},p(o,l){l[0]&2048&&t!==(t=o[11].label+"")&&(e.innerHTML=t),l[0]&16&&i!==(i=o[4]+"_checkbox")&&a(e,"for",i)},d(o){o&&T(e)}}}function hn(n){let e,t=n[11].verifying+"";return{c(){e=S("span")},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].verifying+"")&&(e.innerHTML=t)},d(i){i&&T(e)}}}function gn(n){let e,t=n[11].verified+"",i,o;return{c(){e=S("span"),i=Q(),o=S("input"),a(o,"type","hidden"),a(o,"name",n[4]),o.value=n[6]},m(l,s){j(l,e,s),e.innerHTML=t,j(l,i,s),j(l,o,s)},p(l,s){s[0]&2048&&t!==(t=l[11].verified+"")&&(e.innerHTML=t),s[0]&16&&a(o,"name",l[4]),s[0]&64&&(o.value=l[6])},d(l){l&&(T(e),T(i),T(o))}}}function Ke(n){let e,t,i,o,l,s,d;return{c(){e=S("div"),t=S("a"),i=$("svg"),o=$("path"),l=$("path"),s=$("path"),a(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),a(o,"fill","currentColor"),a(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),a(l,"fill","currentColor"),a(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),a(s,"fill","currentColor"),a(i,"width","22"),a(i,"height","22"),a(i,"viewBox","0 0 20 20"),a(i,"fill","none"),a(i,"xmlns","http://www.w3.org/2000/svg"),a(t,"href",tt),a(t,"target","_blank"),a(t,"class","altcha-logo svelte-ddsc3z"),a(t,"aria-label",d=n[11].ariaLinkLabel)},m(h,f){j(h,e,f),I(e,t),I(t,i),I(i,o),I(i,l),I(i,s)},p(h,f){f[0]&2048&&d!==(d=h[11].ariaLinkLabel)&&a(t,"aria-label",d)},d(h){h&&T(e)}}}function $e(n){let e,t,i,o;function l(h,f){return h[7]===g.EXPIRED?bn:mn}let s=l(n),d=s(n);return{c(){e=S("div"),t=$("svg"),i=$("path"),o=Q(),d.c(),a(i,"stroke-linecap","round"),a(i,"stroke-linejoin","round"),a(i,"d","M6 18L18 6M6 6l12 12"),a(t,"width","14"),a(t,"height","14"),a(t,"xmlns","http://www.w3.org/2000/svg"),a(t,"fill","none"),a(t,"viewBox","0 0 24 24"),a(t,"stroke-width","1.5"),a(t,"stroke","currentColor"),a(e,"class","altcha-error svelte-ddsc3z")},m(h,f){j(h,e,f),I(e,t),I(t,i),I(e,o),d.m(e,null)},p(h,f){s===(s=l(h))&&d?d.p(h,f):(d.d(1),d=s(h),d&&(d.c(),d.m(e,null)))},d(h){h&&T(e),d.d()}}}function mn(n){let e,t=n[11].error+"";return{c(){e=S("div"),a(e,"title",n[5])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&T(e)}}}function bn(n){let e,t=n[11].expired+"";return{c(){e=S("div"),a(e,"title",n[5])},m(i,o){j(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&T(e)}}}function Qe(n){let e,t,i=n[11].footer+"";return{c(){e=S("div"),t=S("div"),a(t,"class","svelte-ddsc3z"),a(e,"class","altcha-footer svelte-ddsc3z")},m(o,l){j(o,e,l),I(e,t),t.innerHTML=i},p(o,l){l[0]&2048&&i!==(i=o[11].footer+"")&&(t.innerHTML=i)},d(o){o&&T(e)}}}function qe(n){let e;return{c(){e=S("div"),a(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){j(t,e,i),n[48](e)},p:Ee,d(t){t&&T(e),n[48](null)}}}function yn(n){let e,t,i,o,l,s,d,h,f,R,v,M,U,H,G,z,q;const ee=n[46].default,Z=St(ee,n,n[45],null);let N=n[7]===g.VERIFYING&&Oe();function te(u,b){return u[7]===g.VERIFIED?gn:u[7]===g.VERIFYING?hn:dn}let O=te(n),Y=O(n),x=(n[3]!==!0||n[12])&&Ke(n),A=(n[5]||n[7]===g.EXPIRED)&&$e(n),V=n[11].footer&&(n[2]!==!0||n[12])&&Qe(n),_=n[1]&&qe(n);return{c(){Z&&Z.c(),e=Q(),t=S("div"),i=S("div"),N&&N.c(),o=Q(),l=S("div"),s=S("input"),f=Q(),R=S("div"),Y.c(),v=Q(),x&&x.c(),M=Q(),A&&A.c(),U=Q(),V&&V.c(),H=Q(),_&&_.c(),a(s,"type","checkbox"),a(s,"id",d=n[4]+"_checkbox"),s.required=h=n[0]!=="onsubmit"&&(!n[1]||n[0]!=="off"),a(s,"class","svelte-ddsc3z"),a(l,"class","altcha-checkbox svelte-ddsc3z"),Pe(l,"altcha-hidden",n[7]===g.VERIFYING),a(R,"class","altcha-label svelte-ddsc3z"),a(i,"class","altcha-main svelte-ddsc3z"),a(t,"class","altcha svelte-ddsc3z"),a(t,"data-state",n[7]),a(t,"data-floating",n[1])},m(u,b){Z&&Z.m(u,b),j(u,e,b),j(u,t,b),I(t,i),N&&N.m(i,null),I(i,o),I(i,l),I(l,s),s.checked=n[8],I(i,f),I(i,R),Y.m(R,null),I(i,v),x&&x.m(i,null),I(t,M),A&&A.m(t,null),I(t,U),V&&V.m(t,null),I(t,H),_&&_.m(t,null),n[49](t),G=!0,z||(q=[Ve(s,"change",n[47]),Ve(s,"change",n[13]),Ve(s,"invalid",n[14])],z=!0)},p(u,b){Z&&Z.p&&(!G||b[1]&16384)&&Nt(Z,ee,u,u[45],G?Gt(ee,u[45],b,null):At(u[45]),null),u[7]===g.VERIFYING?N||(N=Oe(),N.c(),N.m(i,o)):N&&(N.d(1),N=null),(!G||b[0]&16&&d!==(d=u[4]+"_checkbox"))&&a(s,"id",d),(!G||b[0]&3&&h!==(h=u[0]!=="onsubmit"&&(!u[1]||u[0]!=="off")))&&(s.required=h),b[0]&256&&(s.checked=u[8]),(!G||b[0]&128)&&Pe(l,"altcha-hidden",u[7]===g.VERIFYING),O===(O=te(u))&&Y?Y.p(u,b):(Y.d(1),Y=O(u),Y&&(Y.c(),Y.m(R,null))),u[3]!==!0||u[12]?x?x.p(u,b):(x=Ke(u),x.c(),x.m(i,null)):x&&(x.d(1),x=null),u[5]||u[7]===g.EXPIRED?A?A.p(u,b):(A=$e(u),A.c(),A.m(t,U)):A&&(A.d(1),A=null),u[11].footer&&(u[2]!==!0||u[12])?V?V.p(u,b):(V=Qe(u),V.c(),V.m(t,H)):V&&(V.d(1),V=null),u[1]?_?_.p(u,b):(_=qe(u),_.c(),_.m(t,null)):_&&(_.d(1),_=null),(!G||b[0]&128)&&a(t,"data-state",u[7]),(!G||b[0]&2)&&a(t,"data-floating",u[1])},i(u){G||(He(Z,u),G=!0)},o(u){Ot(Z,u),G=!1},d(u){u&&(T(e),T(t)),Z&&Z.d(u),N&&N.d(),Y.d(),x&&x.d(),A&&A.d(),V&&V.d(),_&&_.d(),n[49](null),z=!1,ge(q)}}}const et="Visit Altcha.org",tt="https://altcha.org/";function nt(n){return JSON.parse(n)}function vn(n,e,t){var Et,Ct;let i,o,l,s,{$$slots:d={},$$scope:h}=e,{auto:f=void 0}=e,{blockspam:R=void 0}=e,{challengeurl:v=void 0}=e,{challengejson:M=void 0}=e,{debug:U=!1}=e,{delay:H=0}=e,{expire:G=void 0}=e,{floating:z=void 0}=e,{floatinganchor:q=void 0}=e,{floatingoffset:ee=void 0}=e,{hidefooter:Z=!1}=e,{hidelogo:N=!1}=e,{name:te="altcha"}=e,{maxnumber:O=1e6}=e,{mockerror:Y=!1}=e,{obfuscated:x=void 0}=e,{plugins:A=void 0}=e,{refetchonexpire:V=!0}=e,{spamfilter:_=!1}=e,{strings:u=void 0}=e,{test:b=!1}=e,{verifyurl:ne=void 0}=e,{workers:de=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:ye=void 0}=e;const ve=Ut(),it=["SHA-256","SHA-384","SHA-512"],ot=(Ct=(Et=document.documentElement.lang)==null?void 0:Et.split("-"))==null?void 0:Ct[0];let oe=!1,E,le=null,he=null,y=null,pe=null,K=null,se=null,re=[],C=g.UNVERIFIED;Mt(()=>{pn(),y&&(y.removeEventListener("submit",ut),y.removeEventListener("reset",dt),y.removeEventListener("focusin",ft),y=null),K&&(clearTimeout(K),K=null),document.removeEventListener("click",ct),document.removeEventListener("scroll",at),window.removeEventListener("resize",gt)}),Ft(()=>{k("mounted","1.0.7"),k("workers",de),En(),k("plugins",re.length?re.map(r=>r.constructor.pluginName).join(", "):"none"),b&&k("using test mode"),G&&ze(G),f!==void 0&&k("auto",f),z!==void 0&&mt(z),y=E.closest("form"),y&&(y.addEventListener("submit",ut,{capture:!0}),y.addEventListener("reset",dt),f==="onfocus"&&y.addEventListener("focusin",ft)),f==="onload"&&(x?we():ie()),i&&(Z||N)&&k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."),requestAnimationFrame(()=>{ve("load")})});function lt(r,c){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:c.number,salt:r.salt,signature:r.signature,test:b?!0:void 0,took:c.took}))}function pn(){for(const r of re)r.destroy()}function st(){v&&V&&C===g.VERIFIED?ie():_e(g.EXPIRED,s.expired)}async function wn(){var r;if(Y)throw k("mocking error"),new Error("Mocked error.");if(o)return k("using provided json data"),o;if(b)return k("generating test challenge",{test:b}),on(typeof b!="boolean"?+b:void 0);{if(!v&&y){const p=y.getAttribute("action");p!=null&&p.includes("/form/")&&t(15,v=p+"/altcha")}if(!v)throw new Error("Attribute challengeurl not set.");k("fetching challenge from",v);const c=await fetch(v,{headers:_?{"x-altcha-spam-filter":"1"}:{}});if(c.status!==200)throw new Error(`Server responded with ${c.status}.`);const m=c.headers.get("Expires"),L=c.headers.get("X-Altcha-Config"),B=await c.json(),P=new URLSearchParams((r=B.salt.split("?"))==null?void 0:r[1]),X=P.get("expires")||P.get("expire");if(X){const p=new Date(+X*1e3),D=isNaN(p.getTime())?0:p.getTime()-Date.now();D>0&&ze(D)}if(L)try{const p=JSON.parse(L);p&&typeof p=="object"&&(p.verifyurl&&(p.verifyurl=new URL(p.verifyurl,new URL(v)).toString()),vt(p))}catch(p){k("unable to configure from X-Altcha-Config",p)}if(!G&&(m!=null&&m.length)){const p=Date.parse(m);if(p){const D=p-Date.now();D>0&&ze(D)}}return B}}function _n(r){var m;const c=y==null?void 0:y.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((m=c==null?void 0:c.value)==null?void 0:m.slice(c.value.indexOf("@")))||void 0}function kn(){return _==="ipAddress"?{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:!1,expectedCountries:void 0,expectedLanguages:void 0,fields:!1,ipAddress:void 0,text:void 0,timeZone:void 0}:typeof _=="object"?_:{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,text:void 0,timeZone:void 0}}function xn(r){return[...(y==null?void 0:y.querySelectorAll(r!=null&&r.length?r.map(m=>`input[name="${m}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((m,L)=>{const B=L.name,P=L.value;return B&&P&&(m[B]=/\n/.test(P)?P.replace(new RegExp("(?c instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",`[name=${te}]`,...r)}function Cn(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(C)?_&&(y==null?void 0:y.reportValidity())===!1?t(8,oe=!1):x?we():ie():t(8,oe=!0)}function ct(r){const c=r.target;z&&c&&!E.contains(c)&&(C===g.VERIFIED||f==="off"&&C===g.UNVERIFIED)&&t(9,E.style.display="none",E)}function at(){z&&C!==g.UNVERIFIED&&Le()}function In(r){for(const c of re)typeof c.onErrorChange=="function"&&c.onErrorChange(pe)}function ft(r){C===g.UNVERIFIED&&ie()}function ut(r){y&&f==="onsubmit"?C===g.UNVERIFIED?(r.preventDefault(),r.stopPropagation(),ie().then(()=>{y==null||y.requestSubmit()})):C!==g.VERIFIED&&(r.preventDefault(),r.stopPropagation(),C===g.VERIFYING&&ht()):y&&z&&f==="off"&&C===g.UNVERIFIED&&(r.preventDefault(),r.stopPropagation(),t(9,E.style.display="block",E),Le())}function dt(){_e()}function ht(){C===g.VERIFYING&&s.waitAlert&&alert(s.waitAlert)}function Rn(r){for(const c of re)typeof c.onStateChange=="function"&&c.onStateChange(C);z&&C!==g.UNVERIFIED&&requestAnimationFrame(()=>{Le()}),t(8,oe=C===g.VERIFIED)}function gt(){z&&Le()}function Le(r=20){if(E)if(he||(he=(q?document.querySelector(q):y==null?void 0:y.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])'))||y),he){const c=parseInt(ee,10)||12,m=he.getBoundingClientRect(),L=E.getBoundingClientRect(),B=document.documentElement.clientHeight,P=document.documentElement.clientWidth,X=z==="auto"?m.bottom+L.height+c+r>B:z==="top",p=Math.max(r,Math.min(P-r-L.width,m.left+m.width/2-L.width/2));if(X?t(9,E.style.top=`${m.top-(L.height+c)}px`,E):t(9,E.style.top=`${m.bottom+c}px`,E),t(9,E.style.left=`${p}px`,E),E.setAttribute("data-floating",X?"top":"bottom"),le){const D=le.getBoundingClientRect();t(10,le.style.left=m.left-p+m.width/2-D.width/2+"px",le)}}else k("unable to find floating anchor element")}async function Ln(r){if(!ne)throw new Error("Attribute verifyurl not set.");k("requesting server verification from",ne);const c={payload:r};if(_){const{blockedCountries:B,classifier:P,disableRules:X,email:p,expectedLanguages:D,expectedCountries:Xe,fields:ke,ipAddress:xe,text:An,timeZone:It}=kn();c.blockedCountries=B,c.classifier=P,c.disableRules=X,c.email=p===!1?void 0:_n(p),c.expectedCountries=Xe,c.expectedLanguages=D||(ot?[ot]:void 0),c.fields=ke===!1?void 0:xn(ke),c.ipAddress=xe===!1?void 0:xe||"auto",c.text=An,c.timeZone=It===!1?void 0:It||sn()}const m=await fetch(ne,{body:JSON.stringify(c),headers:{"content-type":"application/json"},method:"POST"});if(m.status!==200)throw new Error(`Server responded with ${m.status}.`);const L=await m.json();if(L!=null&&L.payload&&t(6,se=L.payload),ve("serververification",L),R&&L.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function ze(r){k("expire",r),K&&(clearTimeout(K),K=null),r<1?st():K=setTimeout(st,r)}function mt(r){k("floating",r),z!==r&&(t(9,E.style.left="",E),t(9,E.style.top="",E)),t(1,z=r===!0||r===""?"auto":r===!1||r==="false"?void 0:z),z?(f||t(0,f="onsubmit"),document.addEventListener("scroll",at),document.addEventListener("click",ct),window.addEventListener("resize",gt)):f==="onsubmit"&&t(0,f=void 0)}function bt(r){if(!r.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(r.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!it.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${it.join(", ")}`);if(!r.challenge||r.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!r.salt||r.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function yt(r){let c=null;if("Worker"in window){try{c=await zn(r,r.maxnumber)}catch(m){k(m)}if((c==null?void 0:c.number)!==void 0||"obfuscated"in r)return{data:r,solution:c}}if("obfuscated"in r){const m=await fn(r.obfuscated,r.key,r.maxnumber);return{data:r,solution:await m.promise}}return{data:r,solution:await ln(r.challenge,r.salt,r.algorithm,r.maxnumber||O).promise}}async function zn(r,c=typeof b=="number"?b:O,m=Math.ceil(de)){const L=[];m=Math.min(16,Math.max(1,m));for(let X=0;X{const D=p*B;return new Promise(Xe=>{X.addEventListener("message",ke=>{if(ke.data)for(const xe of L)xe!==X&&xe.postMessage({type:"abort"});Xe(ke.data)}),X.postMessage({payload:r,max:D+B,start:D,type:"work"})})}));for(const X of L)X.terminate();return P.find(X=>!!X)||null}async function we(){if(!x){t(7,C=g.ERROR);return}const r=re.find(c=>c.constructor.pluginName==="obfuscation");if(!r||!("clarify"in r)){t(7,C=g.ERROR),k("Plugin `obfuscation` not found. Import `altcha/plugins/obfuscation` to load it.");return}if("clarify"in r&&typeof r.clarify=="function")return r.clarify()}function vt(r){r.obfuscated!==void 0&&t(24,x=r.obfuscated),r.auto!==void 0&&(t(0,f=r.auto),f==="onload"&&(x?we():ie())),r.blockspam!==void 0&&t(16,R=!!r.blockspam),r.floatinganchor!==void 0&&t(20,q=r.floatinganchor),r.delay!==void 0&&t(18,H=r.delay),r.floatingoffset!==void 0&&t(21,ee=r.floatingoffset),r.floating!==void 0&&mt(r.floating),r.expire!==void 0&&(ze(r.expire),t(19,G=r.expire)),r.challenge&&(bt(r.challenge),o=r.challenge),r.challengeurl!==void 0&&t(15,v=r.challengeurl),r.debug!==void 0&&t(17,U=!!r.debug),r.hidefooter!==void 0&&t(2,Z=!!r.hidefooter),r.hidelogo!==void 0&&t(3,N=!!r.hidelogo),r.maxnumber!==void 0&&t(22,O=+r.maxnumber),r.mockerror!==void 0&&t(23,Y=!!r.mockerror),r.name!==void 0&&t(4,te=r.name),r.refetchonexpire!==void 0&&t(25,V=!!r.refetchonexpire),r.spamfilter!==void 0&&t(26,_=typeof r.spamfilter=="object"?r.spamfilter:!!r.spamfilter),r.strings&&t(44,l=r.strings),r.test!==void 0&&t(27,b=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(28,ne=r.verifyurl),r.workers!==void 0&&t(29,de=+r.workers),r.workerurl!==void 0&&t(30,ye=r.workerurl)}function pt(){return{auto:f,blockspam:R,challengeurl:v,debug:U,delay:H,expire:G,floating:z,floatinganchor:q,floatingoffset:ee,hidefooter:Z,hidelogo:N,name:te,maxnumber:O,mockerror:Y,obfuscated:x,refetchonexpire:V,spamfilter:_,strings:s,test:b,verifyurl:ne,workers:de,workerurl:ye}}function wt(){return he}function Vn(r){return re.find(c=>c.constructor.pluginName===r)}function _t(){return C}function _e(r=g.UNVERIFIED,c=null){K&&(clearTimeout(K),K=null),t(8,oe=!1),t(5,pe=c),t(6,se=null),t(7,C=r)}function kt(r){he=r}function xt(r,c=null){t(7,C=r),t(5,pe=c)}async function ie(){return _e(g.VERIFYING),await new Promise(r=>setTimeout(r,H||0)),wn().then(r=>(bt(r),k("challenge",r),yt(r))).then(({data:r,solution:c})=>{if(k("solution",c),"challenge"in r&&c&&!("clearText"in c))if((c==null?void 0:c.number)!==void 0){if(ne)return Ln(lt(r,c));t(6,se=lt(r,c)),k("payload",se)}else throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{t(7,C=g.VERIFIED),k("verified"),Ht().then(()=>{ve("verified",{payload:se})})}).catch(r=>{k(r),t(7,C=g.ERROR),t(5,pe=r.message)})}function Sn(){oe=this.checked,t(8,oe)}function Gn(r){Ce[r?"unshift":"push"](()=>{le=r,t(10,le)})}function Nn(r){Ce[r?"unshift":"push"](()=>{E=r,t(9,E)})}return n.$$set=r=>{"auto"in r&&t(0,f=r.auto),"blockspam"in r&&t(16,R=r.blockspam),"challengeurl"in r&&t(15,v=r.challengeurl),"challengejson"in r&&t(31,M=r.challengejson),"debug"in r&&t(17,U=r.debug),"delay"in r&&t(18,H=r.delay),"expire"in r&&t(19,G=r.expire),"floating"in r&&t(1,z=r.floating),"floatinganchor"in r&&t(20,q=r.floatinganchor),"floatingoffset"in r&&t(21,ee=r.floatingoffset),"hidefooter"in r&&t(2,Z=r.hidefooter),"hidelogo"in r&&t(3,N=r.hidelogo),"name"in r&&t(4,te=r.name),"maxnumber"in r&&t(22,O=r.maxnumber),"mockerror"in r&&t(23,Y=r.mockerror),"obfuscated"in r&&t(24,x=r.obfuscated),"plugins"in r&&t(32,A=r.plugins),"refetchonexpire"in r&&t(25,V=r.refetchonexpire),"spamfilter"in r&&t(26,_=r.spamfilter),"strings"in r&&t(33,u=r.strings),"test"in r&&t(27,b=r.test),"verifyurl"in r&&t(28,ne=r.verifyurl),"workers"in r&&t(29,de=r.workers),"workerurl"in r&&t(30,ye=r.workerurl),"$$scope"in r&&t(45,h=r.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&32768|n.$$.dirty[1]&1&&t(12,i=M&&new URL(M,location.origin).host.endsWith(".altcha.org")&&!!(v!=null&&v.includes("apiKey=ckey_"))),n.$$.dirty[1]&1&&(o=M?nt(M):void 0),n.$$.dirty[1]&4&&t(44,l=u?nt(u):{}),n.$$.dirty[1]&8192&&t(11,s={ariaLinkLabel:et,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),n.$$.dirty[0]&192&&ve("statechange",{payload:se,state:C}),n.$$.dirty[0]&32&&In(),n.$$.dirty[0]&128&&Rn()},[f,z,Z,N,te,pe,se,C,oe,E,le,s,i,Cn,ht,v,R,U,H,G,q,ee,O,Y,x,V,_,b,ne,de,ye,M,A,u,we,vt,pt,wt,Vn,_t,_e,kt,xt,ie,l,h,d,Sn,Gn,Nn]}class rt extends tn{constructor(e){super(),qt(this,e,vn,yn,zt,{auto:0,blockspam:16,challengeurl:15,challengejson:31,debug:17,delay:18,expire:19,floating:1,floatinganchor:20,floatingoffset:21,hidefooter:2,hidelogo:3,name:4,maxnumber:22,mockerror:23,obfuscated:24,plugins:32,refetchonexpire:25,spamfilter:26,strings:33,test:27,verifyurl:28,workers:29,workerurl:30,clarify:34,configure:35,getConfiguration:36,getFloatingAnchor:37,getPlugin:38,getState:39,reset:40,setFloatingAnchor:41,setState:42,verify:43},un,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[16]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[15]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[31]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[17]}set debug(e){this.$$set({debug:e}),w()}get delay(){return this.$$.ctx[18]}set delay(e){this.$$set({delay:e}),w()}get expire(){return this.$$.ctx[19]}set expire(e){this.$$set({expire:e}),w()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),w()}get floatinganchor(){return this.$$.ctx[20]}set floatinganchor(e){this.$$set({floatinganchor:e}),w()}get floatingoffset(){return this.$$.ctx[21]}set floatingoffset(e){this.$$set({floatingoffset:e}),w()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),w()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),w()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),w()}get maxnumber(){return this.$$.ctx[22]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[23]}set mockerror(e){this.$$set({mockerror:e}),w()}get obfuscated(){return this.$$.ctx[24]}set obfuscated(e){this.$$set({obfuscated:e}),w()}get plugins(){return this.$$.ctx[32]}set plugins(e){this.$$set({plugins:e}),w()}get refetchonexpire(){return this.$$.ctx[25]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[26]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[33]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[27]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[28]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[29]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[30]}set workerurl(e){this.$$set({workerurl:e}),w()}get clarify(){return this.$$.ctx[34]}get configure(){return this.$$.ctx[35]}get getConfiguration(){return this.$$.ctx[36]}get getFloatingAnchor(){return this.$$.ctx[37]}get getPlugin(){return this.$$.ctx[38]}get getState(){return this.$$.ctx[39]}get reset(){return this.$$.ctx[40]}get setFloatingAnchor(){return this.$$.ctx[41]}get setState(){return this.$$.ctx[42]}get verify(){return this.$$.ctx[43]}}customElements.define("altcha-widget",en(rt,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},obfuscated:{},plugins:{},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},["default"],["clarify","configure","getConfiguration","getFloatingAnchor","getPlugin","getState","reset","setFloatingAnchor","setState","verify"],!1)),globalThis.altchaCreateWorker=n=>n?new Worker(new URL(n)):new Rt,globalThis.altchaPlugins=globalThis.altchaPlugins||[],F.Altcha=rt,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})}); diff --git a/package.json b/package.json index 39c3f1d..3bf841c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "altcha", "description": "GDPR compliant, self-hosted CAPTCHA alternative.", - "version": "1.0.6", + "version": "1.0.7", "license": "MIT", "author": { "name": "Daniel Regeci",