altcha 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/altcha.js +705 -606
- package/dist/altcha.umd.cjs +1 -1
- package/dist_external/altcha.css +41 -1
- package/dist_external/altcha.js +739 -640
- package/dist_external/altcha.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/altcha.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(T,z){typeof exports=="object"&&typeof module<"u"?z(exports):typeof define=="function"&&define.amd?define(["exports"],z):(T=typeof globalThis<"u"?globalThis:T||self,z(T.altcha={}))})(this,function(T){"use strict";var Wt=Object.defineProperty;var Pt=(T,z,Q)=>z in T?Wt(T,z,{enumerable:!0,configurable:!0,writable:!0,value:Q}):T[z]=Q;var V=(T,z,Q)=>Pt(T,typeof z!="symbol"?z+"":z,Q);const z="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",Q=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),we=typeof window<"u"&&window.Blob&&new Blob([Q(z)],{type:"text/javascript;charset=utf-8"});function Je(t){let e;try{if(e=we&&(window.URL||window.webkitURL).createObjectURL(we),!e)throw"";const r=new Worker(e,{name:t==null?void 0:t.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),r}catch{return new Worker("data:text/javascript;base64,"+z,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}function re(){}function _e(t){return t()}function pe(){return Object.create(null)}function ne(t){t.forEach(_e)}function ke(t){return typeof t=="function"}function Qe(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function qe(t){return Object.keys(t).length===0}function v(t,e){t.appendChild(e)}function et(t,e,r){const i=tt(t);if(!i.getElementById(e)){const o=C("style");o.id=e,o.textContent=r,rt(i,o)}}function tt(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function rt(t,e){return v(t.head||t,e),e.sheet}function j(t,e,r){t.insertBefore(e,r||null)}function N(t){t.parentNode&&t.parentNode.removeChild(t)}function C(t){return document.createElement(t)}function X(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function nt(t){return document.createTextNode(t)}function P(){return nt(" ")}function ue(t,e,r,i){return t.addEventListener(e,r,i),()=>t.removeEventListener(e,r,i)}function c(t,e,r){r==null?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}function it(t){return Array.from(t.childNodes)}function xe(t,e,r){t.classList.toggle(e,!!r)}function ot(t,e,{bubbles:r=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:r,cancelable:i})}function lt(t){const e={};return t.childNodes.forEach(r=>{e[r.slot||"default"]=!0}),e}let ie;function oe(t){ie=t}function he(){if(!ie)throw new Error("Function called outside component initialization");return ie}function st(t){he().$$.on_mount.push(t)}function ct(t){he().$$.on_destroy.push(t)}function at(){const t=he();return(e,r,{cancelable:i=!1}={})=>{const o=t.$$.callbacks[e];if(o){const l=ot(e,r,{cancelable:i});return o.slice().forEach(s=>{s.call(t,l)}),!l.defaultPrevented}return!0}}const q=[],de=[];let ee=[];const Ee=[],$e=Promise.resolve();let me=!1;function Ce(){me||(me=!0,$e.then(w))}function ft(){return Ce(),$e}function ge(t){ee.push(t)}const be=new Set;let te=0;function w(){if(te!==0)return;const t=ie;do{try{for(;te<q.length;){const e=q[te];te++,oe(e),ut(e.$$)}}catch(e){throw q.length=0,te=0,e}for(oe(null),q.length=0,te=0;de.length;)de.pop()();for(let e=0;e<ee.length;e+=1){const r=ee[e];be.has(r)||(be.add(r),r())}ee.length=0}while(q.length);for(;Ee.length;)Ee.pop()();me=!1,be.clear(),oe(t)}function ut(t){if(t.fragment!==null){t.update(),ne(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(ge)}}function ht(t){const e=[],r=[];ee.forEach(i=>t.indexOf(i)===-1?e.push(i):r.push(i)),r.forEach(i=>i()),ee=e}const dt=new Set;function mt(t,e){t&&t.i&&(dt.delete(t),t.i(e))}function gt(t,e,r){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,r),ge(()=>{const l=t.$$.on_mount.map(_e).filter(ke);t.$$.on_destroy?t.$$.on_destroy.push(...l):ne(l),t.$$.on_mount=[]}),o.forEach(ge)}function bt(t,e){const r=t.$$;r.fragment!==null&&(ht(r.after_update),ne(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function yt(t,e){t.$$.dirty[0]===-1&&(q.push(t),Ce(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function vt(t,e,r,i,o,l,s=null,f=[-1]){const a=ie;oe(t);const u=t.$$={fragment:null,ctx:[],props:l,update:re,not_equal:o,bound:pe(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:pe(),dirty:f,skip_bound:!1,root:e.target||a.$$.root};s&&s(u.root);let Z=!1;if(u.ctx=r?r(t,e.props||{},(L,U,...G)=>{const F=G.length?G[0]:U;return u.ctx&&o(u.ctx[L],u.ctx[L]=F)&&(!u.skip_bound&&u.bound[L]&&u.bound[L](F),Z&&yt(t,L)),U}):[],u.update(),Z=!0,ne(u.before_update),u.fragment=i?i(u.ctx):!1,e.target){if(e.hydrate){const L=it(e.target);u.fragment&&u.fragment.l(L),L.forEach(N)}else u.fragment&&u.fragment.c();e.intro&&mt(t.$$.fragment),gt(t,e.target,e.anchor),w()}oe(a)}let Le;typeof HTMLElement=="function"&&(Le=class extends HTMLElement{constructor(e,r,i){super();V(this,"$$ctor");V(this,"$$s");V(this,"$$c");V(this,"$$cn",!1);V(this,"$$d",{});V(this,"$$r",!1);V(this,"$$p_d",{});V(this,"$$l",{});V(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=r,i&&this.attachShadow({mode:"open"})}addEventListener(e,r,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(r),this.$$c){const o=this.$$c.$on(e,r);this.$$l_u.set(r,o)}super.addEventListener(e,r,i)}removeEventListener(e,r,i){if(super.removeEventListener(e,r,i),this.$$c){const o=this.$$l_u.get(r);o&&(o(),this.$$l_u.delete(r))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=C("slot"),l!=="default"&&c(s,"name",l)},m:function(u,Z){j(u,s,Z)},d:function(u){u&&N(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const r={},i=lt(this);for(const l of this.$$s)l in i&&(r[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=le(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:r,$$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=le(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 f=this.$$c.$on(l,s);this.$$l_u.set(s,f)}this.$$l={}}}attributeChangedCallback(e,r,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=le(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.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(r=>this.$$p_d[r].attribute===e||!this.$$p_d[r].attribute&&r.toLowerCase()===e)||e}});function le(t,e,r,i){var l;const o=(l=r[t])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!r[t])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 wt(t,e,r,i,o,l){let s=class extends Le{constructor(){super(t,r,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(f=>(e[f].attribute||f).toLowerCase())}};return Object.keys(e).forEach(f=>{Object.defineProperty(s.prototype,f,{get(){return this.$$c&&f in this.$$c?this.$$c[f]:this.$$d[f]},set(a){var u;a=le(f,a,e),this.$$d[f]=a,(u=this.$$c)==null||u.$set({[f]:a})}})}),i.forEach(f=>{Object.defineProperty(s.prototype,f,{get(){var a;return(a=this.$$c)==null?void 0:a[f]}})}),l&&(s=l(s)),t.element=s,s}class _t{constructor(){V(this,"$$");V(this,"$$set")}$destroy(){bt(this,1),this.$destroy=re}$on(e,r){if(!ke(r))return re;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(r),()=>{const o=i.indexOf(r);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!qe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const pt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(pt);const kt=new TextEncoder;function xt(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Et(t,e="SHA-256",r=1e5){const i=Date.now().toString(16);t||(t=Math.round(Math.random()*r));const o=await Re(i,t,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Re(t,e,r){return xt(await crypto.subtle.digest(r.toUpperCase(),kt.encode(t+e)))}function $t(t,e,r="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let a=o;a<=i;a+=1){if(l.signal.aborted)return null;if(await Re(e,a,r)===t)return{number:a,took:Date.now()-s}}return null})(),controller:l}}var g=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t.EXPIRED="expired",t))(g||{});function Ct(t){et(t,"svelte-15co9zy",".altcha.svelte-15co9zy.svelte-15co9zy{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);overflow:hidden;position:relative;text-align:left}.altcha.svelte-15co9zy.svelte-15co9zy:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-15co9zy.svelte-15co9zy{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-15co9zy.svelte-15co9zy{flex-grow:1}.altcha-label.svelte-15co9zy label.svelte-15co9zy{cursor:pointer}.altcha-logo.svelte-15co9zy.svelte-15co9zy{color:currentColor;opacity:0.3}.altcha-logo.svelte-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-error.svelte-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy{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-15co9zy.svelte-15co9zy:hover{opacity:1}.altcha-footer.svelte-15co9zy>.svelte-15co9zy:first-child{flex-grow:1}.altcha-footer.svelte-15co9zy a{color:currentColor}.altcha-checkbox.svelte-15co9zy.svelte-15co9zy{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-15co9zy input.svelte-15co9zy{width:18px;height:18px;margin:0}.altcha-hidden.svelte-15co9zy.svelte-15co9zy{display:none}.altcha-spinner.svelte-15co9zy.svelte-15co9zy{animation:svelte-15co9zy-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-15co9zy-altcha-spinner{100%{transform:rotate(360deg)}}")}function Ie(t){let e,r,i;return{c(){e=X("svg"),r=X("path"),i=X("path"),c(r,"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"),c(r,"fill","currentColor"),c(r,"opacity",".25"),c(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"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-15co9zy"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){j(o,e,l),v(e,r),v(e,i)},d(o){o&&N(e)}}}function Lt(t){let e,r=t[9].label+"",i;return{c(){e=C("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-15co9zy")},m(o,l){j(o,e,l),e.innerHTML=r},p(o,l){l[0]&512&&r!==(r=o[9].label+"")&&(e.innerHTML=r),l[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&N(e)}}}function Rt(t){let e,r=t[9].verifying+"";return{c(){e=C("span")},m(i,o){j(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].verifying+"")&&(e.innerHTML=r)},d(i){i&&N(e)}}}function It(t){let e,r=t[9].verified+"",i,o;return{c(){e=C("span"),i=P(),o=C("input"),c(o,"type","hidden"),c(o,"name",t[3]),o.value=t[4]},m(l,s){j(l,e,s),e.innerHTML=r,j(l,i,s),j(l,o,s)},p(l,s){s[0]&512&&r!==(r=l[9].verified+"")&&(e.innerHTML=r),s[0]&8&&c(o,"name",l[3]),s[0]&16&&(o.value=l[4])},d(l){l&&(N(e),N(i),N(o))}}}function ze(t){let e,r,i,o,l,s,f;return{c(){e=C("div"),r=C("a"),i=X("svg"),o=X("path"),l=X("path"),s=X("path"),c(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"),c(o,"fill","currentColor"),c(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"),c(l,"fill","currentColor"),c(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"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(r,"href",Ae),c(r,"target","_blank"),c(r,"class","altcha-logo svelte-15co9zy"),c(r,"aria-label",f=t[9].ariaLinkLabel)},m(a,u){j(a,e,u),v(e,r),v(r,i),v(i,o),v(i,l),v(i,s)},p(a,u){u[0]&512&&f!==(f=a[9].ariaLinkLabel)&&c(r,"aria-label",f)},d(a){a&&N(e)}}}function Ne(t){let e,r,i,o;function l(a,u){return a[5]===g.EXPIRED?Nt:zt}let s=l(t),f=s(t);return{c(){e=C("div"),r=X("svg"),i=X("path"),o=P(),f.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(r,"width","14"),c(r,"height","14"),c(r,"xmlns","http://www.w3.org/2000/svg"),c(r,"fill","none"),c(r,"viewBox","0 0 24 24"),c(r,"stroke-width","1.5"),c(r,"stroke","currentColor"),c(e,"class","altcha-error svelte-15co9zy")},m(a,u){j(a,e,u),v(e,r),v(r,i),v(e,o),f.m(e,null)},p(a,u){s===(s=l(a))&&f?f.p(a,u):(f.d(1),f=s(a),f&&(f.c(),f.m(e,null)))},d(a){a&&N(e),f.d()}}}function zt(t){let e,r=t[9].error+"";return{c(){e=C("div"),c(e,"title",t[8])},m(i,o){j(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].error+"")&&(e.innerHTML=r),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function Nt(t){let e,r=t[9].expired+"";return{c(){e=C("div"),c(e,"title",t[8])},m(i,o){j(i,e,o),e.innerHTML=r},p(i,o){o[0]&512&&r!==(r=i[9].expired+"")&&(e.innerHTML=r),o[0]&256&&c(e,"title",i[8])},d(i){i&&N(e)}}}function Se(t){let e,r,i=t[9].footer+"";return{c(){e=C("div"),r=C("div"),c(r,"class","svelte-15co9zy"),c(e,"class","altcha-footer svelte-15co9zy")},m(o,l){j(o,e,l),v(e,r),r.innerHTML=i},p(o,l){l[0]&512&&i!==(i=o[9].footer+"")&&(r.innerHTML=i)},d(o){o&&N(e)}}}function St(t){let e,r,i,o,l,s,f,a,u,Z,L,U,G,F,p=t[5]===g.VERIFYING&&Ie();function Y(d,I){return d[5]===g.VERIFIED?It:d[5]===g.VERIFYING?Rt:Lt}let H=Y(t),k=H(t),x=t[2]!==!0&&ze(t),m=(t[8]||t[5]===g.EXPIRED)&&Ne(t),y=t[9].footer&&t[1]!==!0&&Se(t);return{c(){e=C("div"),r=C("div"),p&&p.c(),i=P(),o=C("div"),l=C("input"),a=P(),u=C("div"),k.c(),Z=P(),x&&x.c(),L=P(),m&&m.c(),U=P(),y&&y.c(),c(l,"type","checkbox"),c(l,"id",s=t[3]+"_checkbox"),l.required=f=t[0]!=="onsubmit",c(l,"class","svelte-15co9zy"),c(o,"class","altcha-checkbox svelte-15co9zy"),xe(o,"altcha-hidden",t[5]===g.VERIFYING),c(u,"class","altcha-label svelte-15co9zy"),c(r,"class","altcha-main svelte-15co9zy"),c(e,"class","altcha svelte-15co9zy"),c(e,"data-state",t[5])},m(d,I){j(d,e,I),v(e,r),p&&p.m(r,null),v(r,i),v(r,o),v(o,l),l.checked=t[6],v(r,a),v(r,u),k.m(u,null),v(r,Z),x&&x.m(r,null),v(e,L),m&&m.m(e,null),v(e,U),y&&y.m(e,null),t[31](e),G||(F=[ue(l,"change",t[30]),ue(l,"change",t[10]),ue(l,"invalid",t[11])],G=!0)},p(d,I){d[5]===g.VERIFYING?p||(p=Ie(),p.c(),p.m(r,i)):p&&(p.d(1),p=null),I[0]&8&&s!==(s=d[3]+"_checkbox")&&c(l,"id",s),I[0]&1&&f!==(f=d[0]!=="onsubmit")&&(l.required=f),I[0]&64&&(l.checked=d[6]),I[0]&32&&xe(o,"altcha-hidden",d[5]===g.VERIFYING),H===(H=Y(d))&&k?k.p(d,I):(k.d(1),k=H(d),k&&(k.c(),k.m(u,null))),d[2]!==!0?x?x.p(d,I):(x=ze(d),x.c(),x.m(r,null)):x&&(x.d(1),x=null),d[8]||d[5]===g.EXPIRED?m?m.p(d,I):(m=Ne(d),m.c(),m.m(e,U)):m&&(m.d(1),m=null),d[9].footer&&d[1]!==!0?y?y.p(d,I):(y=Se(d),y.c(),y.m(e,null)):y&&(y.d(1),y=null),I[0]&32&&c(e,"data-state",d[5])},i:re,o:re,d(d){d&&N(e),p&&p.d(),k.d(),x&&x.d(),m&&m.d(),y&&y.d(),t[31](null),G=!1,ne(F)}}}const je="Visit Altcha.org",Ae="https://altcha.org/";function Te(t){return JSON.parse(t)}function jt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function At(t,e,r){var We,Pe;let i,o,l,{auto:s=void 0}=e,{blockspam:f=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:u=void 0}=e,{debug:Z=!1}=e,{expire:L=void 0}=e,{hidefooter:U=!1}=e,{hidelogo:G=!1}=e,{name:F="altcha"}=e,{maxnumber:p=1e6}=e,{mockerror:Y=!1}=e,{refetchonexpire:H=!0}=e,{spamfilter:k=!1}=e,{strings:x=void 0}=e,{test:m=!1}=e,{verifyurl:y=void 0}=e,{workers:d=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:I=void 0}=e;const ye=at(),Me=["SHA-256","SHA-384","SHA-512"],Ve=(Pe=(We=document.documentElement.lang)==null?void 0:We.split("-"))==null?void 0:Pe[0];let W=!1,se,b=null,ve=null,B=null,D=g.UNVERIFIED,O=null;ct(()=>{b&&(b.removeEventListener("submit",Ge),b.removeEventListener("reset",De),b.removeEventListener("focusin",Ue),b=null),O&&(clearTimeout(O),O=null)}),st(()=>{R("mounted","0.5.1"),R("workers",d),m&&R("using test mode"),L&&ce(L),s!==void 0&&R("auto",s),b=se.closest("form"),b&&(b.addEventListener("submit",Ge),b.addEventListener("reset",De),s==="onfocus"&&b.addEventListener("focusin",Ue)),s==="onload"&&K()});function R(...n){(Z||n.some(h=>h instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Ue(n){D===g.UNVERIFIED&&K()}function Ge(n){b&&s==="onsubmit"&&D===g.UNVERIFIED&&(n.preventDefault(),n.stopPropagation(),K().then(()=>{b==null||b.requestSubmit()}))}function De(){ae()}function Oe(n,h){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:h.number,salt:n.salt,signature:n.signature,test:m?!0:void 0,took:h.took}))}function Xe(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Me.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Me.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function Tt(){var n;if(Y)throw R("mocking error"),new Error("Mocked error.");if(i)return R("using provided json data"),i;if(m)return R("generating test challenge",{test:m}),Et(typeof m!="boolean"?+m:void 0);{if(!a)throw new Error("Attribute challengeurl not set.");R("fetching challenge from",a);const h=await fetch(a,{headers:{"x-altcha-spam-filter":k?"1":"0"}});if(h.status!==200)throw new Error(`Server responded with ${h.status}.`);const _=h.headers.get("Expires"),S=h.headers.get("X-Altcha-Config"),A=await h.json(),M=new URLSearchParams((n=A.salt.split("?"))==null?void 0:n[1]),J=M.get("expires")||M.get("expire");if(J){const E=new Date(+J*1e3),$=isNaN(E.getTime())?0:E.getTime()-Date.now();$>0&&ce($)}if(S)try{const E=JSON.parse(S);E&&typeof E=="object"&&(E.verifyurl&&(E.verifyurl=new URL(E.verifyurl,new URL(a)).toString()),He(E))}catch(E){R("unable to configure from X-Altcha-Config",E)}if(!L&&(_!=null&&_.length)){const E=Date.parse(_);if(E){const $=E-Date.now();$>0&&ce($)}}return A}}function Fe(){a&&H&&D===g.VERIFIED?K():ae(g.EXPIRED,l.expired)}async function Zt(n){let h=null;if("Worker"in window){try{h=await Mt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(_){R(_)}if((h==null?void 0:h.number)!==void 0)return{data:n,solution:h}}return{data:n,solution:await $t(n.challenge,n.salt,n.algorithm,n.maxnumber||p).promise}}async function Mt(n,h,_,S=typeof m=="number"?m:p,A=Math.ceil(d)){const M=[];if(A<1)throw new Error("Wrong number of workers configured.");if(A>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let $=0;$<A;$++)M.push(createAltchaWorker(I));const J=Math.ceil(S/A),E=await Promise.all(M.map(($,fe)=>{const Ye=fe*J;return new Promise(Ht=>{$.addEventListener("message",Be=>{if(Be.data)for(const Ke of M)Ke!==$&&Ke.postMessage({type:"abort"});Ht(Be.data)}),$.postMessage({payload:{alg:_,challenge:n,max:Ye+J,salt:h,start:Ye},type:"work"})})}));for(const $ of M)$.terminate();return E.find($=>!!$)||null}function Vt(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(D)?k&&(b==null?void 0:b.reportValidity())===!1?r(6,W=!1):K():r(6,W=!0)}function Ut(){D===g.VERIFYING&&alert(l.waitAlert)}function ce(n){R("expire",n),O&&(clearTimeout(O),O=null),n<1?Fe():O=setTimeout(Fe,n)}function Gt(n){var _;const h=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((_=h==null?void 0:h.value)==null?void 0:_.slice(h.value.indexOf("@")))||void 0}function Dt(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(_=>`input[name="${_}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((_,S)=>{const A=S.name,M=S.value.trim();return A&&M&&(_[A]=M),_},{})}async function Ot(n){if(!y)throw new Error("Attribute verifyurl not set.");R("requesting server verification from",y);const h={payload:n};if(k){const{email:A,expectedLanguages:M,expectedCountries:J,fields:E,ipAddress:$,timeZone:fe}=typeof k=="object"?k:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};h.ipAddress=$===!1?void 0:$||"auto",h.email=A===!1?void 0:Gt(A),h.fields=E===!1?void 0:Dt(E),h.timeZone=fe===!1?void 0:fe||jt(),h.expectedCountries=J,h.expectedLanguages=M||(Ve?[Ve]:void 0)}const _=await fetch(y,{body:JSON.stringify(h),headers:{"content-type":"application/json"},method:"POST"});if(_.status!==200)throw new Error(`Server responded with ${_.status}.`);const S=await _.json();if(S!=null&&S.payload&&r(4,B=S.payload),ye("serververification",S),f&&S.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function He(n){n.auto!==void 0&&(r(0,s=n.auto),s==="onload"&&K()),n.expire!==void 0&&(ce(n.expire),r(14,L=n.expire)),n.challenge&&(Xe(n.challenge),i=n.challenge),n.challengeurl!==void 0&&r(12,a=n.challengeurl),n.debug!==void 0&&r(13,Z=!!n.debug),n.hidefooter!==void 0&&r(1,U=!!n.hidefooter),n.hidelogo!==void 0&&r(2,G=!!n.hidelogo),n.maxnumber!==void 0&&r(15,p=+n.maxnumber),n.mockerror!==void 0&&r(16,Y=!!n.mockerror),n.name!==void 0&&r(3,F=n.name),n.refetchonexpire!==void 0&&r(17,H=!!n.refetchonexpire),n.spamfilter!==void 0&&r(18,k=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&r(29,o=n.strings),n.test!==void 0&&r(19,m=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&r(20,y=n.verifyurl),n.workers!==void 0&&r(21,d=+n.workers)}function ae(n=g.UNVERIFIED,h=null){O&&(clearTimeout(O),O=null),r(6,W=!1),r(8,ve=h),r(4,B=null),r(5,D=n)}async function K(){return ae(g.VERIFYING),Tt().then(n=>(Xe(n),R("challenge",n),Zt(n))).then(({data:n,solution:h})=>{if(R("solution",h),(h==null?void 0:h.number)!==void 0){if(y)return Ot(Oe(n,h));r(4,B=Oe(n,h)),R("payload",B)}else throw R("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{ft().then(()=>{r(5,D=g.VERIFIED),r(6,W=!0),R("verified"),ye("verified",{payload:B})})}).catch(n=>{R(n),r(5,D=g.ERROR),r(6,W=!1),r(8,ve=n.message)})}function Xt(){W=this.checked,r(6,W)}function Ft(n){de[n?"unshift":"push"](()=>{se=n,r(7,se)})}return t.$$set=n=>{"auto"in n&&r(0,s=n.auto),"blockspam"in n&&r(22,f=n.blockspam),"challengeurl"in n&&r(12,a=n.challengeurl),"challengejson"in n&&r(23,u=n.challengejson),"debug"in n&&r(13,Z=n.debug),"expire"in n&&r(14,L=n.expire),"hidefooter"in n&&r(1,U=n.hidefooter),"hidelogo"in n&&r(2,G=n.hidelogo),"name"in n&&r(3,F=n.name),"maxnumber"in n&&r(15,p=n.maxnumber),"mockerror"in n&&r(16,Y=n.mockerror),"refetchonexpire"in n&&r(17,H=n.refetchonexpire),"spamfilter"in n&&r(18,k=n.spamfilter),"strings"in n&&r(24,x=n.strings),"test"in n&&r(19,m=n.test),"verifyurl"in n&&r(20,y=n.verifyurl),"workers"in n&&r(21,d=n.workers),"workerurl"in n&&r(25,I=n.workerurl)},t.$$.update=()=>{t.$$.dirty[0]&8388608&&(i=u?Te(u):void 0),t.$$.dirty[0]&16777216&&r(29,o=x?Te(x):{}),t.$$.dirty[0]&536870912&&r(9,l={ariaLinkLabel:je,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by <a href="${Ae}" target="_blank" aria-label="${o.ariaLinkLabel||je}">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),t.$$.dirty[0]&48&&ye("statechange",{payload:B,state:D})},[s,U,G,F,B,D,W,se,ve,l,Vt,Ut,a,Z,L,p,Y,H,k,m,y,d,f,u,x,I,He,ae,K,o,Xt,Ft]}class Ze extends _t{constructor(e){super(),vt(this,e,At,St,Qe,{auto:0,blockspam:22,challengeurl:12,challengejson:23,debug:13,expire:14,hidefooter:1,hidelogo:2,name:3,maxnumber:15,mockerror:16,refetchonexpire:17,spamfilter:18,strings:24,test:19,verifyurl:20,workers:21,workerurl:25,configure:26,reset:27,verify:28},Ct,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[22]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[12]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[23]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[13]}set debug(e){this.$$set({debug:e}),w()}get expire(){return this.$$.ctx[14]}set expire(e){this.$$set({expire:e}),w()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),w()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),w()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),w()}get maxnumber(){return this.$$.ctx[15]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[16]}set mockerror(e){this.$$set({mockerror:e}),w()}get refetchonexpire(){return this.$$.ctx[17]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[18]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[24]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[19]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[20]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[21]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[25]}set workerurl(e){this.$$set({workerurl:e}),w()}get configure(){return this.$$.ctx[26]}get reset(){return this.$$.ctx[27]}get verify(){return this.$$.ctx[28]}}customElements.define("altcha-widget",wt(Ze,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},expire:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=t=>t?new Worker(new URL(t)):new Je,T.Altcha=Ze,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(F,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(F=typeof globalThis<"u"?globalThis:F||self,M(F.altcha={}))})(this,function(F){"use strict";var lr=Object.defineProperty;var sr=(F,M,te)=>M in F?lr(F,M,{enumerable:!0,configurable:!0,writable:!0,value:te}):F[M]=te;var X=(F,M,te)=>sr(F,typeof M!="symbol"?M+"":M,te);const M="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",te=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),Le=typeof window<"u"&&window.Blob&&new Blob([te(M)],{type:"text/javascript;charset=utf-8"});function ft(r){let e;try{if(e=Le&&(window.URL||window.webkitURL).createObjectURL(Le),!e)throw"";const t=new Worker(e,{name:r==null?void 0:r.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+M,{name:r==null?void 0:r.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}function re(){}function Re(r){return r()}function ze(){return Object.create(null)}function se(r){r.forEach(Re)}function Ie(r){return typeof r=="function"}function ut(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function dt(r){return Object.keys(r).length===0}function y(r,e){r.appendChild(e)}function ht(r,e,t){const i=gt(r);if(!i.getElementById(e)){const o=L("style");o.id=e,o.textContent=t,mt(i,o)}}function gt(r){if(!r)return document;const e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function mt(r,e){return y(r.head||r,e),e.sheet}function V(r,e,t){r.insertBefore(e,t||null)}function j(r){r.parentNode&&r.parentNode.removeChild(r)}function L(r){return document.createElement(r)}function O(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function bt(r){return document.createTextNode(r)}function P(){return bt(" ")}function we(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function c(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function wt(r){return Array.from(r.childNodes)}function Ae(r,e,t){r.classList.toggle(e,!!t)}function vt(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function yt(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ce;function ae(r){ce=r}function ve(){if(!ce)throw new Error("Function called outside component initialization");return ce}function pt(r){ve().$$.on_mount.push(r)}function _t(r){ve().$$.on_destroy.push(r)}function kt(){const r=ve();return(e,t,{cancelable:i=!1}={})=>{const o=r.$$.callbacks[e];if(o){const l=vt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(r,l)}),!l.defaultPrevented}return!0}}const ne=[],ue=[];let ie=[];const Ne=[],Se=Promise.resolve();let ye=!1;function Te(){ye||(ye=!0,Se.then(w))}function xt(){return Te(),Se}function pe(r){ie.push(r)}const _e=new Set;let oe=0;function w(){if(oe!==0)return;const r=ce;do{try{for(;oe<ne.length;){const e=ne[oe];oe++,ae(e),Et(e.$$)}}catch(e){throw ne.length=0,oe=0,e}for(ae(null),ne.length=0,oe=0;ue.length;)ue.pop()();for(let e=0;e<ie.length;e+=1){const t=ie[e];_e.has(t)||(_e.add(t),t())}ie.length=0}while(ne.length);for(;Ne.length;)Ne.pop()();ye=!1,_e.clear(),ae(r)}function Et(r){if(r.fragment!==null){r.update(),se(r.before_update);const e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(pe)}}function Ct(r){const e=[],t=[];ie.forEach(i=>r.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),ie=e}const Lt=new Set;function Rt(r,e){r&&r.i&&(Lt.delete(r),r.i(e))}function zt(r,e,t){const{fragment:i,after_update:o}=r.$$;i&&i.m(e,t),pe(()=>{const l=r.$$.on_mount.map(Re).filter(Ie);r.$$.on_destroy?r.$$.on_destroy.push(...l):se(l),r.$$.on_mount=[]}),o.forEach(pe)}function It(r,e){const t=r.$$;t.fragment!==null&&(Ct(t.after_update),se(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function At(r,e){r.$$.dirty[0]===-1&&(ne.push(r),Te(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function Nt(r,e,t,i,o,l,s=null,u=[-1]){const a=ce;ae(r);const d=r.$$={fragment:null,ctx:[],props:l,update:re,not_equal:o,bound:ze(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:ze(),dirty:u,skip_bound:!1,root:e.target||a.$$.root};s&&s(d.root);let G=!1;if(d.ctx=t?t(r,e.props||{},(S,U,...k)=>{const W=k.length?k[0]:U;return d.ctx&&o(d.ctx[S],d.ctx[S]=W)&&(!d.skip_bound&&d.bound[S]&&d.bound[S](W),G&&At(r,S)),U}):[],d.update(),G=!0,se(d.before_update),d.fragment=i?i(d.ctx):!1,e.target){if(e.hydrate){const S=wt(e.target);d.fragment&&d.fragment.l(S),S.forEach(j)}else d.fragment&&d.fragment.c();e.intro&&Rt(r.$$.fragment),zt(r,e.target,e.anchor),w()}ae(a)}let je;typeof HTMLElement=="function"&&(je=class extends HTMLElement{constructor(e,t,i){super();X(this,"$$ctor");X(this,"$$s");X(this,"$$c");X(this,"$$cn",!1);X(this,"$$d",{});X(this,"$$r",!1);X(this,"$$p_d",{});X(this,"$$l",{});X(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))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=L("slot"),l!=="default"&&c(s,"name",l)},m:function(d,G){V(d,s,G)},d:function(d){d&&j(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=yt(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]=de(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=de(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 u=this.$$c.$on(l,s);this.$$l_u.set(s,u)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=de(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.$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 de(r,e,t,i){var l;const o=(l=t[r])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])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 St(r,e,t,i,o,l){let s=class extends je{constructor(){super(r,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(u=>(e[u].attribute||u).toLowerCase())}};return Object.keys(e).forEach(u=>{Object.defineProperty(s.prototype,u,{get(){return this.$$c&&u in this.$$c?this.$$c[u]:this.$$d[u]},set(a){var d;a=de(u,a,e),this.$$d[u]=a,(d=this.$$c)==null||d.$set({[u]:a})}})}),i.forEach(u=>{Object.defineProperty(s.prototype,u,{get(){var a;return(a=this.$$c)==null?void 0:a[u]}})}),l&&(s=l(s)),r.element=s,s}class Tt{constructor(){X(this,"$$");X(this,"$$set")}$destroy(){It(this,1),this.$destroy=re}$on(e,t){if(!Ie(t))return re;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&&!dt(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const jt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(jt);const Zt=new TextEncoder;function Mt(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Vt(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const o=await Ze(i,r,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Ze(r,e,t){return Mt(await crypto.subtle.digest(t.toUpperCase(),Zt.encode(r+e)))}function $t(r,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let a=o;a<=i;a+=1){if(l.signal.aborted)return null;if(await Ze(e,a,t)===r)return{number:a,took:Date.now()-s}}return null})(),controller:l}}var m=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(m||{});function Dt(r){ht(r,"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 Me(r){let e,t,i;return{c(){e=O("svg"),t=O("path"),i=O("path"),c(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"),c(t,"fill","currentColor"),c(t,"opacity",".25"),c(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"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-ddsc3z"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){V(o,e,l),y(e,t),y(e,i)},d(o){o&&j(e)}}}function Ut(r){let e,t=r[11].label+"",i;return{c(){e=L("label"),c(e,"for",i=r[4]+"_checkbox"),c(e,"class","svelte-ddsc3z")},m(o,l){V(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")&&c(e,"for",i)},d(o){o&&j(e)}}}function Ft(r){let e,t=r[11].verifying+"";return{c(){e=L("span")},m(i,o){V(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].verifying+"")&&(e.innerHTML=t)},d(i){i&&j(e)}}}function Gt(r){let e,t=r[11].verified+"",i,o;return{c(){e=L("span"),i=P(),o=L("input"),c(o,"type","hidden"),c(o,"name",r[4]),o.value=r[5]},m(l,s){V(l,e,s),e.innerHTML=t,V(l,i,s),V(l,o,s)},p(l,s){s[0]&2048&&t!==(t=l[11].verified+"")&&(e.innerHTML=t),s[0]&16&&c(o,"name",l[4]),s[0]&32&&(o.value=l[5])},d(l){l&&(j(e),j(i),j(o))}}}function Ve(r){let e,t,i,o,l,s,u;return{c(){e=L("div"),t=L("a"),i=O("svg"),o=O("path"),l=O("path"),s=O("path"),c(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"),c(o,"fill","currentColor"),c(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"),c(l,"fill","currentColor"),c(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"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(t,"href",Ge),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-ddsc3z"),c(t,"aria-label",u=r[11].ariaLinkLabel)},m(a,d){V(a,e,d),y(e,t),y(t,i),y(i,o),y(i,l),y(i,s)},p(a,d){d[0]&2048&&u!==(u=a[11].ariaLinkLabel)&&c(t,"aria-label",u)},d(a){a&&j(e)}}}function $e(r){let e,t,i,o;function l(a,d){return a[6]===m.EXPIRED?Xt:Wt}let s=l(r),u=s(r);return{c(){e=L("div"),t=O("svg"),i=O("path"),o=P(),u.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(t,"width","14"),c(t,"height","14"),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"fill","none"),c(t,"viewBox","0 0 24 24"),c(t,"stroke-width","1.5"),c(t,"stroke","currentColor"),c(e,"class","altcha-error svelte-ddsc3z")},m(a,d){V(a,e,d),y(e,t),y(t,i),y(e,o),u.m(e,null)},p(a,d){s===(s=l(a))&&u?u.p(a,d):(u.d(1),u=s(a),u&&(u.c(),u.m(e,null)))},d(a){a&&j(e),u.d()}}}function Wt(r){let e,t=r[11].error+"";return{c(){e=L("div"),c(e,"title",r[10])},m(i,o){V(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),o[0]&1024&&c(e,"title",i[10])},d(i){i&&j(e)}}}function Xt(r){let e,t=r[11].expired+"";return{c(){e=L("div"),c(e,"title",r[10])},m(i,o){V(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),o[0]&1024&&c(e,"title",i[10])},d(i){i&&j(e)}}}function De(r){let e,t,i=r[11].footer+"";return{c(){e=L("div"),t=L("div"),c(t,"class","svelte-ddsc3z"),c(e,"class","altcha-footer svelte-ddsc3z")},m(o,l){V(o,e,l),y(e,t),t.innerHTML=i},p(o,l){l[0]&2048&&i!==(i=o[11].footer+"")&&(t.innerHTML=i)},d(o){o&&j(e)}}}function Ue(r){let e;return{c(){e=L("div"),c(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){V(t,e,i),r[36](e)},p:re,d(t){t&&j(e),r[36](null)}}}function Bt(r){let e,t,i,o,l,s,u,a,d,G,S,U,k,W,J,N=r[6]===m.VERIFYING&&Me();function le(h,p){return h[6]===m.VERIFIED?Gt:h[6]===m.VERIFYING?Ft:Ut}let Y=le(r),T=Y(r),R=r[3]!==!0&&Ve(r),z=(r[10]||r[6]===m.EXPIRED)&&$e(r),v=r[11].footer&&r[2]!==!0&&De(r),I=r[1]&&Ue(r);return{c(){e=L("div"),t=L("div"),N&&N.c(),i=P(),o=L("div"),l=L("input"),a=P(),d=L("div"),T.c(),G=P(),R&&R.c(),S=P(),z&&z.c(),U=P(),v&&v.c(),k=P(),I&&I.c(),c(l,"type","checkbox"),c(l,"id",s=r[4]+"_checkbox"),l.required=u=r[0]!=="onsubmit",c(l,"class","svelte-ddsc3z"),c(o,"class","altcha-checkbox svelte-ddsc3z"),Ae(o,"altcha-hidden",r[6]===m.VERIFYING),c(d,"class","altcha-label svelte-ddsc3z"),c(t,"class","altcha-main svelte-ddsc3z"),c(e,"class","altcha svelte-ddsc3z"),c(e,"data-state",r[6]),c(e,"data-floating",r[1])},m(h,p){V(h,e,p),y(e,t),N&&N.m(t,null),y(t,i),y(t,o),y(o,l),l.checked=r[7],y(t,a),y(t,d),T.m(d,null),y(t,G),R&&R.m(t,null),y(e,S),z&&z.m(e,null),y(e,U),v&&v.m(e,null),y(e,k),I&&I.m(e,null),r[37](e),W||(J=[we(l,"change",r[35]),we(l,"change",r[12]),we(l,"invalid",r[13])],W=!0)},p(h,p){h[6]===m.VERIFYING?N||(N=Me(),N.c(),N.m(t,i)):N&&(N.d(1),N=null),p[0]&16&&s!==(s=h[4]+"_checkbox")&&c(l,"id",s),p[0]&1&&u!==(u=h[0]!=="onsubmit")&&(l.required=u),p[0]&128&&(l.checked=h[7]),p[0]&64&&Ae(o,"altcha-hidden",h[6]===m.VERIFYING),Y===(Y=le(h))&&T?T.p(h,p):(T.d(1),T=Y(h),T&&(T.c(),T.m(d,null))),h[3]!==!0?R?R.p(h,p):(R=Ve(h),R.c(),R.m(t,null)):R&&(R.d(1),R=null),h[10]||h[6]===m.EXPIRED?z?z.p(h,p):(z=$e(h),z.c(),z.m(e,U)):z&&(z.d(1),z=null),h[11].footer&&h[2]!==!0?v?v.p(h,p):(v=De(h),v.c(),v.m(e,k)):v&&(v.d(1),v=null),h[1]?I?I.p(h,p):(I=Ue(h),I.c(),I.m(e,null)):I&&(I.d(1),I=null),p[0]&64&&c(e,"data-state",h[6]),p[0]&2&&c(e,"data-floating",h[1])},i:re,o:re,d(h){h&&j(e),N&&N.d(),T.d(),R&&R.d(),z&&z.d(),v&&v.d(),I&&I.d(),r[37](null),W=!1,se(J)}}}const Fe="Visit Altcha.org",Ge="https://altcha.org/";function We(r){return JSON.parse(r)}function Ht(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ot(r,e,t){var ot,lt;let i,o,l,{auto:s=void 0}=e,{blockspam:u=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:d=void 0}=e,{debug:G=!1}=e,{delay:S=0}=e,{expire:U=void 0}=e,{floating:k=void 0}=e,{floatinganchor:W=void 0}=e,{floatingoffset:J=void 0}=e,{hidefooter:N=!1}=e,{hidelogo:le=!1}=e,{name:Y="altcha"}=e,{maxnumber:T=1e6}=e,{mockerror:R=!1}=e,{refetchonexpire:z=!0}=e,{spamfilter:v=!1}=e,{strings:I=void 0}=e,{test:h=!1}=e,{verifyurl:p=void 0}=e,{workers:fe=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:ke=void 0}=e;const xe=kt(),Be=["SHA-256","SHA-384","SHA-512"],He=(lt=(ot=document.documentElement.lang)==null?void 0:ot.split("-"))==null?void 0:lt[0];let K=!1,E,q=null,he=null,b=null,Ee=null,Q=null,$=m.UNVERIFIED,B=null;_t(()=>{b&&(b.removeEventListener("submit",Pe),b.removeEventListener("reset",Ye),b.removeEventListener("focusin",Oe),b=null),B&&(clearTimeout(B),B=null),document.removeEventListener("click",Qe),document.removeEventListener("scroll",et),window.removeEventListener("resize",rt)}),pt(()=>{C("mounted","0.6.0"),C("workers",fe),h&&C("using test mode"),U&&ge(U),s!==void 0&&C("auto",s),k!==void 0&&nt(k),b=E.closest("form"),b&&(b.addEventListener("submit",Pe,{capture:!0}),b.addEventListener("reset",Ye),s==="onfocus"&&b.addEventListener("focusin",Oe)),s==="onload"&&ee()});function C(...n){(G||n.some(f=>f instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Oe(n){$===m.UNVERIFIED&&ee()}function Pe(n){b&&s==="onsubmit"&&($===m.UNVERIFIED?(n.preventDefault(),n.stopPropagation(),ee().then(()=>{b==null||b.requestSubmit()})):$!==m.VERIFIED&&(n.preventDefault(),n.stopPropagation(),$===m.VERIFYING&&tt()))}function Ye(){me()}function Ke(n,f){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:f.number,salt:n.salt,signature:n.signature,test:h?!0:void 0,took:f.took}))}function Je(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Be.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Be.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function Pt(){var n;if(R)throw C("mocking error"),new Error("Mocked error.");if(i)return C("using provided json data"),i;if(h)return C("generating test challenge",{test:h}),Vt(typeof h!="boolean"?+h:void 0);{if(!a)throw new Error("Attribute challengeurl not set.");C("fetching challenge from",a);const f=await fetch(a,{headers:{"x-altcha-spam-filter":v?"1":"0"}});if(f.status!==200)throw new Error(`Server responded with ${f.status}.`);const g=f.headers.get("Expires"),A=f.headers.get("X-Altcha-Config"),Z=await f.json(),D=new URLSearchParams((n=Z.salt.split("?"))==null?void 0:n[1]),H=D.get("expires")||D.get("expire");if(H){const _=new Date(+H*1e3),x=isNaN(_.getTime())?0:_.getTime()-Date.now();x>0&&ge(x)}if(A)try{const _=JSON.parse(A);_&&typeof _=="object"&&(_.verifyurl&&(_.verifyurl=new URL(_.verifyurl,new URL(a)).toString()),it(_))}catch(_){C("unable to configure from X-Altcha-Config",_)}if(!U&&(g!=null&&g.length)){const _=Date.parse(g);if(_){const x=_-Date.now();x>0&&ge(x)}}return Z}}function qe(){a&&z&&$===m.VERIFIED?ee():me(m.EXPIRED,l.expired)}async function Yt(n){let f=null;if("Worker"in window){try{f=await Kt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(g){C(g)}if((f==null?void 0:f.number)!==void 0)return{data:n,solution:f}}return{data:n,solution:await $t(n.challenge,n.salt,n.algorithm,n.maxnumber||T).promise}}async function Kt(n,f,g,A=typeof h=="number"?h:T,Z=Math.ceil(fe)){const D=[];if(Z<1)throw new Error("Wrong number of workers configured.");if(Z>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let x=0;x<Z;x++)D.push(createAltchaWorker(ke));const H=Math.ceil(A/Z),_=await Promise.all(D.map((x,be)=>{const st=be*H;return new Promise(or=>{x.addEventListener("message",ct=>{if(ct.data)for(const at of D)at!==x&&at.postMessage({type:"abort"});or(ct.data)}),x.postMessage({payload:{alg:g,challenge:n,max:st+H,salt:f,start:st},type:"work"})})}));for(const x of D)x.terminate();return _.find(x=>!!x)||null}function Jt(){[m.UNVERIFIED,m.ERROR,m.EXPIRED].includes($)?v&&(b==null?void 0:b.reportValidity())===!1?t(7,K=!1):ee():t(7,K=!0)}function Qe(n){const f=n.target;k&&f&&!E.contains(f)&&$===m.VERIFIED&&t(8,E.style.display="none",E)}function et(){k&&Ce()}function tt(){$===m.VERIFYING&&alert(l.waitAlert)}function qt(n){k&&$!==m.UNVERIFIED&&requestAnimationFrame(()=>{Ce()})}function rt(){k&&Ce()}function ge(n){C("expire",n),B&&(clearTimeout(B),B=null),n<1?qe():B=setTimeout(qe,n)}function nt(n){C("floating",n),k!==n&&(t(8,E.style.left="",E),t(8,E.style.top="",E)),t(1,k=n===!0||n===""?"auto":n===!1||n==="false"?void 0:k),k?(s||t(0,s="onsubmit"),document.addEventListener("scroll",et),document.addEventListener("click",Qe),window.addEventListener("resize",rt)):s==="onsubmit"&&t(0,s=void 0)}function Qt(n){var g;const f=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((g=f==null?void 0:f.value)==null?void 0:g.slice(f.value.indexOf("@")))||void 0}function er(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(g=>`input[name="${g}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((g,A)=>{const Z=A.name,D=A.value.trim();return Z&&D&&(g[Z]=D),g},{})}async function tr(n){if(!p)throw new Error("Attribute verifyurl not set.");C("requesting server verification from",p);const f={payload:n};if(v){const{email:Z,expectedLanguages:D,expectedCountries:H,fields:_,ipAddress:x,timeZone:be}=typeof v=="object"?v:{email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,timeZone:void 0};f.ipAddress=x===!1?void 0:x||"auto",f.email=Z===!1?void 0:Qt(Z),f.fields=_===!1?void 0:er(_),f.timeZone=be===!1?void 0:be||Ht(),f.expectedCountries=H,f.expectedLanguages=D||(He?[He]:void 0)}const g=await fetch(p,{body:JSON.stringify(f),headers:{"content-type":"application/json"},method:"POST"});if(g.status!==200)throw new Error(`Server responded with ${g.status}.`);const A=await g.json();if(A!=null&&A.payload&&t(5,Q=A.payload),xe("serververification",A),u&&A.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Ce(n=20){if(E)if(he||(he=(W?document.querySelector(W):b==null?void 0:b.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])'))||b),he){const f=parseInt(J,10)||12,g=he.getBoundingClientRect(),A=E.getBoundingClientRect(),Z=document.documentElement.clientHeight,D=document.documentElement.clientWidth,H=k==="auto"?g.bottom+A.height+f+n>Z:k==="top",_=Math.max(n,Math.min(D-n-A.width,g.left+g.width/2-A.width/2));if(H?t(8,E.style.top=`${g.top-(A.height+f)}px`,E):t(8,E.style.top=`${g.bottom+f}px`,E),t(8,E.style.left=`${_}px`,E),E.setAttribute("data-floating",H?"top":"bottom"),q){const x=q.getBoundingClientRect();t(9,q.style.left=g.left-_+g.width/2-x.width/2+"px",q)}}else C("unable to find floating anchor element")}function it(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&ee()),n.floatinganchor!==void 0&&t(18,W=n.floatinganchor),n.delay!==void 0&&t(16,S=n.delay),n.floatingoffset!==void 0&&t(19,J=n.floatingoffset),n.floating!==void 0&&nt(n.floating),n.expire!==void 0&&(ge(n.expire),t(17,U=n.expire)),n.challenge&&(Je(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(14,a=n.challengeurl),n.debug!==void 0&&t(15,G=!!n.debug),n.hidefooter!==void 0&&t(2,N=!!n.hidefooter),n.hidelogo!==void 0&&t(3,le=!!n.hidelogo),n.maxnumber!==void 0&&t(20,T=+n.maxnumber),n.mockerror!==void 0&&t(21,R=!!n.mockerror),n.name!==void 0&&t(4,Y=n.name),n.refetchonexpire!==void 0&&t(22,z=!!n.refetchonexpire),n.spamfilter!==void 0&&t(23,v=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(34,o=n.strings),n.test!==void 0&&t(24,h=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(25,p=n.verifyurl),n.workers!==void 0&&t(26,fe=+n.workers)}function me(n=m.UNVERIFIED,f=null){B&&(clearTimeout(B),B=null),t(7,K=!1),t(10,Ee=f),t(5,Q=null),t(6,$=n)}async function ee(){return me(m.VERIFYING),await new Promise(n=>setTimeout(n,S||0)),Pt().then(n=>(Je(n),C("challenge",n),Yt(n))).then(({data:n,solution:f})=>{if(C("solution",f),(f==null?void 0:f.number)!==void 0){if(p)return tr(Ke(n,f));t(5,Q=Ke(n,f)),C("payload",Q)}else throw C("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{xt().then(()=>{t(6,$=m.VERIFIED),t(7,K=!0),C("verified"),xe("verified",{payload:Q})})}).catch(n=>{C(n),t(6,$=m.ERROR),t(7,K=!1),t(10,Ee=n.message)})}function rr(){K=this.checked,t(7,K)}function nr(n){ue[n?"unshift":"push"](()=>{q=n,t(9,q)})}function ir(n){ue[n?"unshift":"push"](()=>{E=n,t(8,E)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(27,u=n.blockspam),"challengeurl"in n&&t(14,a=n.challengeurl),"challengejson"in n&&t(28,d=n.challengejson),"debug"in n&&t(15,G=n.debug),"delay"in n&&t(16,S=n.delay),"expire"in n&&t(17,U=n.expire),"floating"in n&&t(1,k=n.floating),"floatinganchor"in n&&t(18,W=n.floatinganchor),"floatingoffset"in n&&t(19,J=n.floatingoffset),"hidefooter"in n&&t(2,N=n.hidefooter),"hidelogo"in n&&t(3,le=n.hidelogo),"name"in n&&t(4,Y=n.name),"maxnumber"in n&&t(20,T=n.maxnumber),"mockerror"in n&&t(21,R=n.mockerror),"refetchonexpire"in n&&t(22,z=n.refetchonexpire),"spamfilter"in n&&t(23,v=n.spamfilter),"strings"in n&&t(29,I=n.strings),"test"in n&&t(24,h=n.test),"verifyurl"in n&&t(25,p=n.verifyurl),"workers"in n&&t(26,fe=n.workers),"workerurl"in n&&t(30,ke=n.workerurl)},r.$$.update=()=>{r.$$.dirty[0]&268435456&&(i=d?We(d):void 0),r.$$.dirty[0]&536870912&&t(34,o=I?We(I):{}),r.$$.dirty[1]&8&&t(11,l={ariaLinkLabel:Fe,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by <a href="${Ge}" target="_blank" aria-label="${o.ariaLinkLabel||Fe}">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),r.$$.dirty[0]&96&&xe("statechange",{payload:Q,state:$}),r.$$.dirty[0]&64&&qt()},[s,k,N,le,Y,Q,$,K,E,q,Ee,l,Jt,tt,a,G,S,U,W,J,T,R,z,v,h,p,fe,u,d,I,ke,it,me,ee,o,rr,nr,ir]}class Xe extends Tt{constructor(e){super(),Nt(this,e,Ot,Bt,ut,{auto:0,blockspam:27,challengeurl:14,challengejson:28,debug:15,delay:16,expire:17,floating:1,floatinganchor:18,floatingoffset:19,hidefooter:2,hidelogo:3,name:4,maxnumber:20,mockerror:21,refetchonexpire:22,spamfilter:23,strings:29,test:24,verifyurl:25,workers:26,workerurl:30,configure:31,reset:32,verify:33},Dt,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[27]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[14]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[28]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[15]}set debug(e){this.$$set({debug:e}),w()}get delay(){return this.$$.ctx[16]}set delay(e){this.$$set({delay:e}),w()}get expire(){return this.$$.ctx[17]}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[18]}set floatinganchor(e){this.$$set({floatinganchor:e}),w()}get floatingoffset(){return this.$$.ctx[19]}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[20]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[21]}set mockerror(e){this.$$set({mockerror:e}),w()}get refetchonexpire(){return this.$$.ctx[22]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[23]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[29]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[24]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[25]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[26]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[30]}set workerurl(e){this.$$set({workerurl:e}),w()}get configure(){return this.$$.ctx[31]}get reset(){return this.$$.ctx[32]}get verify(){return this.$$.ctx[33]}}customElements.define("altcha-widget",St(Xe,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=r=>r?new Worker(new URL(r)):new ft,F.Altcha=Xe,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
|
package/dist_external/altcha.css
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
display: flex;
|
|
8
8
|
flex-direction: column;
|
|
9
9
|
max-width: var(--altcha-max-width, 260px);
|
|
10
|
-
overflow: hidden;
|
|
11
10
|
position: relative;
|
|
12
11
|
text-align: left;
|
|
13
12
|
}
|
|
@@ -16,6 +15,47 @@
|
|
|
16
15
|
border-color: var(--altcha-color-border-focus, currentColor);
|
|
17
16
|
}
|
|
18
17
|
|
|
18
|
+
.altcha[data-floating] {
|
|
19
|
+
background: var(--altcha-color-base, white);
|
|
20
|
+
display: none;
|
|
21
|
+
filter: drop-shadow(3px 3px 6px rgba(0,0,0,0.2));
|
|
22
|
+
left: -100%;
|
|
23
|
+
position: fixed;
|
|
24
|
+
top: -100%;
|
|
25
|
+
width: var(--altcha-max-width, 260px);
|
|
26
|
+
z-index: 999999;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.altcha[data-floating="top"] .altcha-anchor-arrow {
|
|
30
|
+
border-bottom-color: transparent;
|
|
31
|
+
border-top-color: var(--altcha-color-border, #a0a0a0);
|
|
32
|
+
bottom: -12px;
|
|
33
|
+
top: auto;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.altcha[data-floating="bottom"]:focus-within::after {
|
|
37
|
+
border-bottom-color: var(--altcha-color-border-focus, currentColor);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.altcha[data-floating="top"]:focus-within::after {
|
|
41
|
+
border-top-color: var(--altcha-color-border-focus, currentColor);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.altcha[data-floating]:not([data-state="unverified"]) {
|
|
45
|
+
display: block;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.altcha-anchor-arrow {
|
|
49
|
+
border: 6px solid transparent;
|
|
50
|
+
border-bottom-color: var(--altcha-color-border, #a0a0a0);
|
|
51
|
+
content: '';
|
|
52
|
+
height: 0;
|
|
53
|
+
left: 12px;
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: -12px;
|
|
56
|
+
width: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
19
59
|
.altcha-main {
|
|
20
60
|
align-items: center;
|
|
21
61
|
display: flex;
|