altcha 0.7.0 → 0.9.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.
@@ -1,70 +1,109 @@
1
- var Pt = Object.defineProperty;
2
- var it = (n) => {
3
- throw TypeError(n);
4
- };
5
- var Ut = (n, e, t) => e in n ? Pt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
- var S = (n, e, t) => Ut(n, typeof e != "symbol" ? e + "" : e, t), rt = (n, e, t) => e.has(n) || it("Cannot " + t);
7
- var U = (n, e, t) => (rt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), re = (n, e, t) => e.has(n) ? it("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), ot = (n, e, t, r) => (rt(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t);
8
- function ce() {
1
+ var jt = Object.defineProperty;
2
+ var Ht = (n, e, t) => e in n ? jt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var Z = (n, e, t) => Ht(n, typeof e != "symbol" ? e + "" : e, t);
4
+ function xe() {
9
5
  }
10
- function wt(n) {
6
+ function Ot(n, e) {
7
+ for (const t in e) n[t] = e[t];
8
+ return (
9
+ /** @type {T & S} */
10
+ n
11
+ );
12
+ }
13
+ function ht(n) {
11
14
  return n();
12
15
  }
13
- function st() {
16
+ function nt() {
14
17
  return /* @__PURE__ */ Object.create(null);
15
18
  }
16
- function ve(n) {
17
- n.forEach(wt);
19
+ function pe(n) {
20
+ n.forEach(ht);
18
21
  }
19
- function _t(n) {
22
+ function dt(n) {
20
23
  return typeof n == "function";
21
24
  }
22
- function Ot(n, e) {
25
+ function Ut(n, e) {
23
26
  return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function";
24
27
  }
25
- function Ht(n) {
28
+ function $t(n) {
26
29
  return Object.keys(n).length === 0;
27
30
  }
28
- function p(n, e) {
31
+ function Bt(n, e, t, i) {
32
+ if (n) {
33
+ const o = gt(n, e, t, i);
34
+ return n[0](o);
35
+ }
36
+ }
37
+ function gt(n, e, t, i) {
38
+ return n[1] && i ? Ot(t.ctx.slice(), n[1](i(e))) : t.ctx;
39
+ }
40
+ function qt(n, e, t, i) {
41
+ if (n[2] && i) {
42
+ const o = n[2](i(t));
43
+ if (e.dirty === void 0)
44
+ return o;
45
+ if (typeof o == "object") {
46
+ const l = [], s = Math.max(e.dirty.length, o.length);
47
+ for (let h = 0; h < s; h += 1)
48
+ l[h] = e.dirty[h] | o[h];
49
+ return l;
50
+ }
51
+ return e.dirty | o;
52
+ }
53
+ return e.dirty;
54
+ }
55
+ function Zt(n, e, t, i, o, l) {
56
+ if (o) {
57
+ const s = gt(e, t, i, l);
58
+ n.p(s, o);
59
+ }
60
+ }
61
+ function Gt(n) {
62
+ if (n.ctx.length > 32) {
63
+ const e = [], t = n.ctx.length / 32;
64
+ for (let i = 0; i < t; i++)
65
+ e[i] = -1;
66
+ return e;
67
+ }
68
+ return -1;
69
+ }
70
+ function L(n, e) {
29
71
  n.appendChild(e);
30
72
  }
31
- function M(n, e, t) {
73
+ function H(n, e, t) {
32
74
  n.insertBefore(e, t || null);
33
75
  }
34
- function D(n) {
76
+ function j(n) {
35
77
  n.parentNode && n.parentNode.removeChild(n);
36
78
  }
37
79
  function F(n) {
38
80
  return document.createElement(n);
39
81
  }
40
- function z(n) {
82
+ function K(n) {
41
83
  return document.createElementNS("http://www.w3.org/2000/svg", n);
42
84
  }
43
- function yt(n) {
85
+ function Yt(n) {
44
86
  return document.createTextNode(n);
45
87
  }
46
- function W() {
47
- return yt(" ");
48
- }
49
- function $t() {
50
- return yt("");
88
+ function z() {
89
+ return Yt(" ");
51
90
  }
52
- function Me(n, e, t, r) {
53
- return n.addEventListener(e, t, r), () => n.removeEventListener(e, t, r);
91
+ function Le(n, e, t, i) {
92
+ return n.addEventListener(e, t, i), () => n.removeEventListener(e, t, i);
54
93
  }
55
- function a(n, e, t) {
94
+ function c(n, e, t) {
56
95
  t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t);
57
96
  }
58
- function qt(n) {
97
+ function Wt(n) {
59
98
  return Array.from(n.childNodes);
60
99
  }
61
- function lt(n, e, t) {
100
+ function rt(n, e, t) {
62
101
  n.classList.toggle(e, !!t);
63
102
  }
64
- function Zt(n, e, { bubbles: t = !1, cancelable: r = !1 } = {}) {
65
- return new CustomEvent(n, { detail: e, bubbles: t, cancelable: r });
103
+ function Xt(n, e, { bubbles: t = !1, cancelable: i = !1 } = {}) {
104
+ return new CustomEvent(n, { detail: e, bubbles: t, cancelable: i });
66
105
  }
67
- function Yt(n) {
106
+ function Jt(n) {
68
107
  const e = {};
69
108
  return n.childNodes.forEach(
70
109
  /** @param {Element} node */
@@ -73,215 +112,224 @@ function Yt(n) {
73
112
  }
74
113
  ), e;
75
114
  }
76
- let me;
77
- function ge(n) {
78
- me = n;
115
+ let we;
116
+ function _e(n) {
117
+ we = n;
79
118
  }
80
- function Be() {
81
- if (!me) throw new Error("Function called outside component initialization");
82
- return me;
119
+ function Te() {
120
+ if (!we) throw new Error("Function called outside component initialization");
121
+ return we;
83
122
  }
84
- function Gt(n) {
85
- Be().$$.on_mount.push(n);
123
+ function zt(n) {
124
+ Te().$$.on_mount.push(n);
86
125
  }
87
- function Jt(n) {
88
- Be().$$.on_destroy.push(n);
126
+ function Kt(n) {
127
+ Te().$$.on_destroy.push(n);
89
128
  }
90
- function Xt() {
91
- const n = Be();
92
- return (e, t, { cancelable: r = !1 } = {}) => {
129
+ function Qt() {
130
+ const n = Te();
131
+ return (e, t, { cancelable: i = !1 } = {}) => {
93
132
  const o = n.$$.callbacks[e];
94
133
  if (o) {
95
- const s = Zt(
134
+ const l = Xt(
96
135
  /** @type {string} */
97
136
  e,
98
137
  t,
99
- { cancelable: r }
138
+ { cancelable: i }
100
139
  );
101
- return o.slice().forEach((u) => {
102
- u.call(n, s);
103
- }), !s.defaultPrevented;
140
+ return o.slice().forEach((s) => {
141
+ s.call(n, l);
142
+ }), !l.defaultPrevented;
104
143
  }
105
144
  return !0;
106
145
  };
107
146
  }
108
- const se = [], Fe = [];
109
- let le = [];
110
- const at = [], vt = /* @__PURE__ */ Promise.resolve();
111
- let je = !1;
112
- function Et() {
113
- je || (je = !0, vt.then(v));
147
+ const ce = [], Ae = [];
148
+ let ue = [];
149
+ const it = [], mt = /* @__PURE__ */ Promise.resolve();
150
+ let Se = !1;
151
+ function bt() {
152
+ Se || (Se = !0, mt.then(p));
114
153
  }
115
- function Wt() {
116
- return Et(), vt;
154
+ function en() {
155
+ return bt(), mt;
117
156
  }
118
- function Ve(n) {
119
- le.push(n);
157
+ function De(n) {
158
+ ue.push(n);
120
159
  }
121
- const Ne = /* @__PURE__ */ new Set();
122
- let oe = 0;
123
- function v() {
124
- if (oe !== 0)
160
+ const Re = /* @__PURE__ */ new Set();
161
+ let fe = 0;
162
+ function p() {
163
+ if (fe !== 0)
125
164
  return;
126
- const n = me;
165
+ const n = we;
127
166
  do {
128
167
  try {
129
- for (; oe < se.length; ) {
130
- const e = se[oe];
131
- oe++, ge(e), zt(e.$$);
168
+ for (; fe < ce.length; ) {
169
+ const e = ce[fe];
170
+ fe++, _e(e), tn(e.$$);
132
171
  }
133
172
  } catch (e) {
134
- throw se.length = 0, oe = 0, e;
173
+ throw ce.length = 0, fe = 0, e;
135
174
  }
136
- for (ge(null), se.length = 0, oe = 0; Fe.length; ) Fe.pop()();
137
- for (let e = 0; e < le.length; e += 1) {
138
- const t = le[e];
139
- Ne.has(t) || (Ne.add(t), t());
175
+ for (_e(null), ce.length = 0, fe = 0; Ae.length; ) Ae.pop()();
176
+ for (let e = 0; e < ue.length; e += 1) {
177
+ const t = ue[e];
178
+ Re.has(t) || (Re.add(t), t());
140
179
  }
141
- le.length = 0;
142
- } while (se.length);
143
- for (; at.length; )
144
- at.pop()();
145
- je = !1, Ne.clear(), ge(n);
180
+ ue.length = 0;
181
+ } while (ce.length);
182
+ for (; it.length; )
183
+ it.pop()();
184
+ Se = !1, Re.clear(), _e(n);
146
185
  }
147
- function zt(n) {
186
+ function tn(n) {
148
187
  if (n.fragment !== null) {
149
- n.update(), ve(n.before_update);
188
+ n.update(), pe(n.before_update);
150
189
  const e = n.dirty;
151
- n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(Ve);
190
+ n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(De);
152
191
  }
153
192
  }
154
- function Kt(n) {
193
+ function nn(n) {
155
194
  const e = [], t = [];
156
- le.forEach((r) => n.indexOf(r) === -1 ? e.push(r) : t.push(r)), t.forEach((r) => r()), le = e;
195
+ ue.forEach((i) => n.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), ue = e;
157
196
  }
158
- const Qt = /* @__PURE__ */ new Set();
159
- function en(n, e) {
160
- n && n.i && (Qt.delete(n), n.i(e));
197
+ const ve = /* @__PURE__ */ new Set();
198
+ let rn;
199
+ function yt(n, e) {
200
+ n && n.i && (ve.delete(n), n.i(e));
161
201
  }
162
- function tn(n, e, t) {
163
- const { fragment: r, after_update: o } = n.$$;
164
- r && r.m(e, t), Ve(() => {
165
- const s = n.$$.on_mount.map(wt).filter(_t);
166
- n.$$.on_destroy ? n.$$.on_destroy.push(...s) : ve(s), n.$$.on_mount = [];
167
- }), o.forEach(Ve);
202
+ function on(n, e, t, i) {
203
+ if (n && n.o) {
204
+ if (ve.has(n)) return;
205
+ ve.add(n), rn.c.push(() => {
206
+ ve.delete(n);
207
+ }), n.o(e);
208
+ }
209
+ }
210
+ function ln(n, e, t) {
211
+ const { fragment: i, after_update: o } = n.$$;
212
+ i && i.m(e, t), De(() => {
213
+ const l = n.$$.on_mount.map(ht).filter(dt);
214
+ n.$$.on_destroy ? n.$$.on_destroy.push(...l) : pe(l), n.$$.on_mount = [];
215
+ }), o.forEach(De);
168
216
  }
169
- function nn(n, e) {
217
+ function sn(n, e) {
170
218
  const t = n.$$;
171
- t.fragment !== null && (Kt(t.after_update), ve(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
219
+ t.fragment !== null && (nn(t.after_update), pe(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
172
220
  }
173
- function rn(n, e) {
174
- n.$$.dirty[0] === -1 && (se.push(n), Et(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31;
221
+ function fn(n, e) {
222
+ n.$$.dirty[0] === -1 && (ce.push(n), bt(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31;
175
223
  }
176
- function on(n, e, t, r, o, s, u = null, f = [-1]) {
177
- const l = me;
178
- ge(n);
179
- const c = n.$$ = {
224
+ function cn(n, e, t, i, o, l, s = null, h = [-1]) {
225
+ const d = we;
226
+ _e(n);
227
+ const u = n.$$ = {
180
228
  fragment: null,
181
229
  ctx: [],
182
230
  // state
183
- props: s,
184
- update: ce,
231
+ props: l,
232
+ update: xe,
185
233
  not_equal: o,
186
- bound: st(),
234
+ bound: nt(),
187
235
  // lifecycle
188
236
  on_mount: [],
189
237
  on_destroy: [],
190
238
  on_disconnect: [],
191
239
  before_update: [],
192
240
  after_update: [],
193
- context: new Map(e.context || (l ? l.$$.context : [])),
241
+ context: new Map(e.context || (d ? d.$$.context : [])),
194
242
  // everything else
195
- callbacks: st(),
196
- dirty: f,
243
+ callbacks: nt(),
244
+ dirty: h,
197
245
  skip_bound: !1,
198
- root: e.target || l.$$.root
246
+ root: e.target || d.$$.root
199
247
  };
200
- u && u(c.root);
201
- let O = !1;
202
- if (c.ctx = t ? t(n, e.props || {}, (m, H, ...$) => {
203
- const q = $.length ? $[0] : H;
204
- return c.ctx && o(c.ctx[m], c.ctx[m] = q) && (!c.skip_bound && c.bound[m] && c.bound[m](q), O && rn(n, m)), H;
205
- }) : [], c.update(), O = !0, ve(c.before_update), c.fragment = r ? r(c.ctx) : !1, e.target) {
248
+ s && s(u.root);
249
+ let A = !1;
250
+ if (u.ctx = t ? t(n, e.props || {}, (b, Y, ...U) => {
251
+ const $ = U.length ? U[0] : Y;
252
+ return u.ctx && o(u.ctx[b], u.ctx[b] = $) && (!u.skip_bound && u.bound[b] && u.bound[b]($), A && fn(n, b)), Y;
253
+ }) : [], u.update(), A = !0, pe(u.before_update), u.fragment = i ? i(u.ctx) : !1, e.target) {
206
254
  if (e.hydrate) {
207
- const m = qt(e.target);
208
- c.fragment && c.fragment.l(m), m.forEach(D);
255
+ const b = Wt(e.target);
256
+ u.fragment && u.fragment.l(b), b.forEach(j);
209
257
  } else
210
- c.fragment && c.fragment.c();
211
- e.intro && en(n.$$.fragment), tn(n, e.target, e.anchor), v();
258
+ u.fragment && u.fragment.c();
259
+ e.intro && yt(n.$$.fragment), ln(n, e.target, e.anchor), p();
212
260
  }
213
- ge(l);
261
+ _e(d);
214
262
  }
215
- let kt;
216
- typeof HTMLElement == "function" && (kt = class extends HTMLElement {
217
- constructor(e, t, r) {
263
+ let _t;
264
+ typeof HTMLElement == "function" && (_t = class extends HTMLElement {
265
+ constructor(e, t, i) {
218
266
  super();
219
267
  /** The Svelte component constructor */
220
- S(this, "$$ctor");
268
+ Z(this, "$$ctor");
221
269
  /** Slots */
222
- S(this, "$$s");
270
+ Z(this, "$$s");
223
271
  /** The Svelte component instance */
224
- S(this, "$$c");
272
+ Z(this, "$$c");
225
273
  /** Whether or not the custom element is connected */
226
- S(this, "$$cn", !1);
274
+ Z(this, "$$cn", !1);
227
275
  /** Component props data */
228
- S(this, "$$d", {});
276
+ Z(this, "$$d", {});
229
277
  /** `true` if currently in the process of reflecting component props back to attributes */
230
- S(this, "$$r", !1);
278
+ Z(this, "$$r", !1);
231
279
  /** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
232
- S(this, "$$p_d", {});
280
+ Z(this, "$$p_d", {});
233
281
  /** @type {Record<string, Function[]>} Event listeners */
234
- S(this, "$$l", {});
282
+ Z(this, "$$l", {});
235
283
  /** @type {Map<Function, Function>} Event listener unsubscribe functions */
236
- S(this, "$$l_u", /* @__PURE__ */ new Map());
237
- this.$$ctor = e, this.$$s = t, r && this.attachShadow({ mode: "open" });
284
+ Z(this, "$$l_u", /* @__PURE__ */ new Map());
285
+ this.$$ctor = e, this.$$s = t, i && this.attachShadow({ mode: "open" });
238
286
  }
239
- addEventListener(e, t, r) {
287
+ addEventListener(e, t, i) {
240
288
  if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(t), this.$$c) {
241
289
  const o = this.$$c.$on(e, t);
242
290
  this.$$l_u.set(t, o);
243
291
  }
244
- super.addEventListener(e, t, r);
292
+ super.addEventListener(e, t, i);
245
293
  }
246
- removeEventListener(e, t, r) {
247
- if (super.removeEventListener(e, t, r), this.$$c) {
294
+ removeEventListener(e, t, i) {
295
+ if (super.removeEventListener(e, t, i), this.$$c) {
248
296
  const o = this.$$l_u.get(t);
249
297
  o && (o(), this.$$l_u.delete(t));
250
298
  }
251
299
  }
252
300
  async connectedCallback() {
253
301
  if (this.$$cn = !0, !this.$$c) {
254
- let e = function(s) {
302
+ let e = function(l) {
255
303
  return () => {
256
- let u;
304
+ let s;
257
305
  return {
258
306
  c: function() {
259
- u = F("slot"), s !== "default" && a(u, "name", s);
307
+ s = F("slot"), l !== "default" && c(s, "name", l);
260
308
  },
261
309
  /**
262
310
  * @param {HTMLElement} target
263
311
  * @param {HTMLElement} [anchor]
264
312
  */
265
- m: function(c, O) {
266
- M(c, u, O);
313
+ m: function(u, A) {
314
+ H(u, s, A);
267
315
  },
268
- d: function(c) {
269
- c && D(u);
316
+ d: function(u) {
317
+ u && j(s);
270
318
  }
271
319
  };
272
320
  };
273
321
  };
274
322
  if (await Promise.resolve(), !this.$$cn || this.$$c)
275
323
  return;
276
- const t = {}, r = Yt(this);
277
- for (const s of this.$$s)
278
- s in r && (t[s] = [e(s)]);
279
- for (const s of this.attributes) {
280
- const u = this.$$g_p(s.name);
281
- u in this.$$d || (this.$$d[u] = Te(u, s.value, this.$$p_d, "toProp"));
324
+ const t = {}, i = Jt(this);
325
+ for (const l of this.$$s)
326
+ l in i && (t[l] = [e(l)]);
327
+ for (const l of this.attributes) {
328
+ const s = this.$$g_p(l.name);
329
+ s in this.$$d || (this.$$d[s] = Ce(s, l.value, this.$$p_d, "toProp"));
282
330
  }
283
- for (const s in this.$$p_d)
284
- !(s in this.$$d) && this[s] !== void 0 && (this.$$d[s] = this[s], delete this[s]);
331
+ for (const l in this.$$p_d)
332
+ !(l in this.$$d) && this[l] !== void 0 && (this.$$d[l] = this[l], delete this[l]);
285
333
  this.$$c = new this.$$ctor({
286
334
  target: this.shadowRoot || this,
287
335
  props: {
@@ -294,32 +342,32 @@ typeof HTMLElement == "function" && (kt = class extends HTMLElement {
294
342
  });
295
343
  const o = () => {
296
344
  this.$$r = !0;
297
- for (const s in this.$$p_d)
298
- if (this.$$d[s] = this.$$c.$$.ctx[this.$$c.$$.props[s]], this.$$p_d[s].reflect) {
299
- const u = Te(
300
- s,
301
- this.$$d[s],
345
+ for (const l in this.$$p_d)
346
+ if (this.$$d[l] = this.$$c.$$.ctx[this.$$c.$$.props[l]], this.$$p_d[l].reflect) {
347
+ const s = Ce(
348
+ l,
349
+ this.$$d[l],
302
350
  this.$$p_d,
303
351
  "toAttribute"
304
352
  );
305
- u == null ? this.removeAttribute(this.$$p_d[s].attribute || s) : this.setAttribute(this.$$p_d[s].attribute || s, u);
353
+ s == null ? this.removeAttribute(this.$$p_d[l].attribute || l) : this.setAttribute(this.$$p_d[l].attribute || l, s);
306
354
  }
307
355
  this.$$r = !1;
308
356
  };
309
357
  this.$$c.$$.after_update.push(o), o();
310
- for (const s in this.$$l)
311
- for (const u of this.$$l[s]) {
312
- const f = this.$$c.$on(s, u);
313
- this.$$l_u.set(u, f);
358
+ for (const l in this.$$l)
359
+ for (const s of this.$$l[l]) {
360
+ const h = this.$$c.$on(l, s);
361
+ this.$$l_u.set(s, h);
314
362
  }
315
363
  this.$$l = {};
316
364
  }
317
365
  }
318
366
  // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
319
367
  // and setting attributes through setAttribute etc, this is helpful
320
- attributeChangedCallback(e, t, r) {
368
+ attributeChangedCallback(e, t, i) {
321
369
  var o;
322
- this.$$r || (e = this.$$g_p(e), this.$$d[e] = Te(e, r, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] }));
370
+ this.$$r || (e = this.$$g_p(e), this.$$d[e] = Ce(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] }));
323
371
  }
324
372
  disconnectedCallback() {
325
373
  this.$$cn = !1, Promise.resolve().then(() => {
@@ -332,12 +380,12 @@ typeof HTMLElement == "function" && (kt = class extends HTMLElement {
332
380
  ) || e;
333
381
  }
334
382
  });
335
- function Te(n, e, t, r) {
336
- var s;
337
- const o = (s = t[n]) == null ? void 0 : s.type;
338
- if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !r || !t[n])
383
+ function Ce(n, e, t, i) {
384
+ var l;
385
+ const o = (l = t[n]) == null ? void 0 : l.type;
386
+ if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[n])
339
387
  return e;
340
- if (r === "toAttribute")
388
+ if (i === "toAttribute")
341
389
  switch (o) {
342
390
  case "Object":
343
391
  case "Array":
@@ -362,38 +410,38 @@ function Te(n, e, t, r) {
362
410
  return e;
363
411
  }
364
412
  }
365
- function sn(n, e, t, r, o, s) {
366
- let u = class extends kt {
413
+ function un(n, e, t, i, o, l) {
414
+ let s = class extends _t {
367
415
  constructor() {
368
416
  super(n, t, o), this.$$p_d = e;
369
417
  }
370
418
  static get observedAttributes() {
371
419
  return Object.keys(e).map(
372
- (f) => (e[f].attribute || f).toLowerCase()
420
+ (h) => (e[h].attribute || h).toLowerCase()
373
421
  );
374
422
  }
375
423
  };
376
- return Object.keys(e).forEach((f) => {
377
- Object.defineProperty(u.prototype, f, {
424
+ return Object.keys(e).forEach((h) => {
425
+ Object.defineProperty(s.prototype, h, {
378
426
  get() {
379
- return this.$$c && f in this.$$c ? this.$$c[f] : this.$$d[f];
427
+ return this.$$c && h in this.$$c ? this.$$c[h] : this.$$d[h];
380
428
  },
381
- set(l) {
382
- var c;
383
- l = Te(f, l, e), this.$$d[f] = l, (c = this.$$c) == null || c.$set({ [f]: l });
429
+ set(d) {
430
+ var u;
431
+ d = Ce(h, d, e), this.$$d[h] = d, (u = this.$$c) == null || u.$set({ [h]: d });
384
432
  }
385
433
  });
386
- }), r.forEach((f) => {
387
- Object.defineProperty(u.prototype, f, {
434
+ }), i.forEach((h) => {
435
+ Object.defineProperty(s.prototype, h, {
388
436
  get() {
389
- var l;
390
- return (l = this.$$c) == null ? void 0 : l[f];
437
+ var d;
438
+ return (d = this.$$c) == null ? void 0 : d[h];
391
439
  }
392
440
  });
393
441
  }), n.element = /** @type {any} */
394
- u, u;
442
+ s, s;
395
443
  }
396
- class ln {
444
+ class an {
397
445
  constructor() {
398
446
  /**
399
447
  * ### PRIVATE API
@@ -402,7 +450,7 @@ class ln {
402
450
  *
403
451
  * @type {any}
404
452
  */
405
- S(this, "$$");
453
+ Z(this, "$$");
406
454
  /**
407
455
  * ### PRIVATE API
408
456
  *
@@ -410,11 +458,11 @@ class ln {
410
458
  *
411
459
  * @type {any}
412
460
  */
413
- S(this, "$$set");
461
+ Z(this, "$$set");
414
462
  }
415
463
  /** @returns {void} */
416
464
  $destroy() {
417
- nn(this, 1), this.$destroy = ce;
465
+ sn(this, 1), this.$destroy = xe;
418
466
  }
419
467
  /**
420
468
  * @template {Extract<keyof Events, string>} K
@@ -423,12 +471,12 @@ class ln {
423
471
  * @returns {() => void}
424
472
  */
425
473
  $on(e, t) {
426
- if (!_t(t))
427
- return ce;
428
- const r = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
429
- return r.push(t), () => {
430
- const o = r.indexOf(t);
431
- o !== -1 && r.splice(o, 1);
474
+ if (!dt(t))
475
+ return xe;
476
+ const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
477
+ return i.push(t), () => {
478
+ const o = i.indexOf(t);
479
+ o !== -1 && i.splice(o, 1);
432
480
  };
433
481
  }
434
482
  /**
@@ -436,229 +484,189 @@ class ln {
436
484
  * @returns {void}
437
485
  */
438
486
  $set(e) {
439
- this.$$set && !Ht(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
487
+ this.$$set && !$t(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
440
488
  }
441
489
  }
442
- const an = "4";
443
- typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(an);
444
- const fn = new TextEncoder();
445
- function cn(n) {
490
+ const hn = "4";
491
+ typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(hn);
492
+ const wt = new TextEncoder();
493
+ function dn(n) {
446
494
  return [...new Uint8Array(n)].map((e) => e.toString(16).padStart(2, "0")).join("");
447
495
  }
448
- async function un(n, e = "SHA-256", t = 1e5) {
449
- const r = Date.now().toString(16);
496
+ async function gn(n, e = "SHA-256", t = 1e5) {
497
+ const i = Date.now().toString(16);
450
498
  n || (n = Math.round(Math.random() * t));
451
- const o = await pt(r, n, e);
499
+ const o = await pt(i, n, e);
452
500
  return {
453
501
  algorithm: e,
454
502
  challenge: o,
455
- salt: r,
503
+ salt: i,
456
504
  signature: ""
457
505
  };
458
506
  }
459
507
  async function pt(n, e, t) {
460
- return cn(
508
+ return dn(
461
509
  await crypto.subtle.digest(
462
510
  t.toUpperCase(),
463
- fn.encode(n + e)
511
+ wt.encode(n + e)
464
512
  )
465
513
  );
466
514
  }
467
- function hn(n, e, t = "SHA-256", r = 1e6, o = 0) {
468
- const s = new AbortController(), u = Date.now();
515
+ function mn(n, e, t = "SHA-256", i = 1e6, o = 0) {
516
+ const l = new AbortController(), s = Date.now();
469
517
  return {
470
518
  promise: (async () => {
471
- for (let l = o; l <= r; l += 1) {
472
- if (s.signal.aborted)
519
+ for (let d = o; d <= i; d += 1) {
520
+ if (l.signal.aborted)
473
521
  return null;
474
- if (await pt(e, l, t) === n)
522
+ if (await pt(e, d, t) === n)
475
523
  return {
476
- number: l,
477
- took: Date.now() - u
524
+ number: d,
525
+ took: Date.now() - s
478
526
  };
479
527
  }
480
528
  return null;
481
529
  })(),
482
- controller: s
530
+ controller: l
483
531
  };
484
532
  }
485
- function Ct() {
533
+ function bn() {
486
534
  try {
487
535
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
488
536
  } catch {
489
537
  }
490
538
  }
491
- var ae, fe, be, we, _e, ye;
492
- class dn {
493
- constructor(e) {
494
- S(this, "beaconUrl", null);
495
- S(this, "error", null);
496
- S(this, "loadTime", Date.now());
497
- S(this, "submitTime", null);
498
- S(this, "startTime", null);
499
- S(this, "viewTimeThresholdMs", 1500);
500
- re(this, ae, {});
501
- re(this, fe, null);
502
- re(this, be, this.onFormChange.bind(this));
503
- re(this, we, this.onFormFocus.bind(this));
504
- re(this, _e, this.onFormSubmit.bind(this));
505
- re(this, ye, this.onUnload.bind(this));
506
- this.elForm = e, window.addEventListener("unload", U(this, ye)), this.elForm.addEventListener("change", U(this, be)), this.elForm.addEventListener("focusin", U(this, we)), this.elForm.addEventListener("submit", U(this, _e));
507
- }
508
- data() {
509
- const e = Object.entries(U(this, ae));
510
- return {
511
- correction: e.length && e.filter(([t, r]) => r > 1).length / e.length || 0,
512
- dropoff: !this.submitTime && !this.error && U(this, fe) ? U(this, fe) : null,
513
- error: this.error,
514
- mobile: this.isMobile(),
515
- start: this.startTime,
516
- submit: this.submitTime,
517
- tz: Ct()
518
- };
519
- }
520
- dataAsBase64() {
521
- try {
522
- return btoa(
523
- JSON.stringify(this.data())
524
- );
525
- } catch (e) {
526
- console.error("failed to encode ALTCHA session data to base64", e);
527
- }
528
- return "";
529
- }
530
- destroy() {
531
- window.removeEventListener("unload", U(this, ye)), this.elForm.removeEventListener("change", U(this, be)), this.elForm.removeEventListener("focusin", U(this, we)), this.elForm.removeEventListener("submit", U(this, _e));
532
- }
533
- end() {
534
- this.submitTime || (this.submitTime = Date.now());
535
- }
536
- getFieldName(e, t = 40) {
537
- const r = e.getAttribute("data-group-label"), o = e.getAttribute("name") || e.getAttribute("aria-label");
538
- return ((r ? r + ": " : "") + o).slice(0, t);
539
- }
540
- isMobile() {
541
- const e = "userAgentData" in navigator && navigator.userAgentData ? navigator.userAgentData : {};
542
- return "mobile" in e ? e.mobile === !0 : /Mobi/i.test(window.navigator.userAgent);
543
- }
544
- isInput(e) {
545
- return ["INPUT", "SELECT", "TEXTAREA"].includes(e.tagName);
546
- }
547
- onFormFieldChange(e) {
548
- const t = this.getFieldName(e);
549
- t && this.trackFieldChange(t);
550
- }
551
- onFormChange(e) {
552
- const t = e.target;
553
- t && this.isInput(t) && this.onFormFieldChange(t);
554
- }
555
- onFormFocus(e) {
556
- const t = e.target;
557
- if (this.startTime || this.start(), t && this.isInput(t)) {
558
- const r = this.getFieldName(t);
559
- r && ot(this, fe, r);
560
- }
561
- }
562
- onFormSubmit() {
563
- this.end();
564
- }
565
- onUnload() {
566
- this.loadTime <= Date.now() - this.viewTimeThresholdMs && !this.submitTime && this.sendBeacon();
567
- }
568
- async sendBeacon() {
569
- if (this.beaconUrl && "sendBeacon" in navigator)
539
+ function yn(n) {
540
+ const e = atob(n), t = new Uint8Array(e.length);
541
+ for (let i = 0; i < e.length; i++)
542
+ t[i] = e.charCodeAt(i);
543
+ return t;
544
+ }
545
+ function _n(n, e = 12) {
546
+ const t = new Uint8Array(e);
547
+ for (let i = 0; i < e; i++)
548
+ t[i] = n % 256, n = Math.floor(n / 256);
549
+ return t;
550
+ }
551
+ async function wn(n, e = "", t = 1e6, i = 0) {
552
+ const o = "AES-GCM", l = new AbortController(), s = Date.now(), h = async () => {
553
+ for (let A = i; A <= t; A += 1) {
554
+ if (l.signal.aborted || !d || !u)
555
+ return null;
570
556
  try {
571
- navigator.sendBeacon(
572
- new URL(this.beaconUrl, location.origin),
573
- JSON.stringify(this.data())
557
+ const b = await crypto.subtle.decrypt(
558
+ {
559
+ name: o,
560
+ iv: _n(A)
561
+ },
562
+ d,
563
+ u
574
564
  );
565
+ if (b)
566
+ return {
567
+ clearText: new TextDecoder().decode(b),
568
+ took: Date.now() - s
569
+ };
575
570
  } catch {
576
571
  }
572
+ }
573
+ return null;
574
+ };
575
+ let d = null, u = null;
576
+ try {
577
+ u = yn(n);
578
+ const A = await crypto.subtle.digest(
579
+ "SHA-256",
580
+ wt.encode(e)
581
+ );
582
+ d = await crypto.subtle.importKey(
583
+ "raw",
584
+ A,
585
+ o,
586
+ !1,
587
+ ["decrypt"]
588
+ );
589
+ } catch {
590
+ return {
591
+ promise: Promise.reject(),
592
+ controller: l
593
+ };
577
594
  }
578
- start() {
579
- this.startTime = Date.now();
580
- }
581
- trackError(e) {
582
- this.error = e === null ? null : String(e);
583
- }
584
- trackFieldChange(e) {
585
- U(this, ae)[e] = (U(this, ae)[e] || 0) + 1;
586
- }
595
+ return {
596
+ promise: h(),
597
+ controller: l
598
+ };
587
599
  }
588
- ae = new WeakMap(), fe = new WeakMap(), be = new WeakMap(), we = new WeakMap(), _e = new WeakMap(), ye = new WeakMap();
589
- var _ = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(_ || {});
590
- function ft(n) {
591
- let e, t, r;
600
+ var m = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(m || {});
601
+ function ot(n) {
602
+ let e, t, i;
592
603
  return {
593
604
  c() {
594
- e = z("svg"), t = z("path"), r = z("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(r, "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(r, "fill", "currentColor"), a(r, "class", "altcha-spinner"), a(e, "width", "24"), a(e, "height", "24"), a(e, "viewBox", "0 0 24 24"), a(e, "xmlns", "http://www.w3.org/2000/svg");
605
+ e = K("svg"), t = K("path"), i = K("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"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg");
595
606
  },
596
- m(o, s) {
597
- M(o, e, s), p(e, t), p(e, r);
607
+ m(o, l) {
608
+ H(o, e, l), L(e, t), L(e, i);
598
609
  },
599
610
  d(o) {
600
- o && D(e);
611
+ o && j(e);
601
612
  }
602
613
  };
603
614
  }
604
- function gn(n) {
615
+ function pn(n) {
605
616
  let e, t = (
606
617
  /*_strings*/
607
- n[13].label + ""
608
- ), r;
618
+ n[11].label + ""
619
+ ), i;
609
620
  return {
610
621
  c() {
611
- e = F("label"), a(e, "for", r = /*name*/
622
+ e = F("label"), c(e, "for", i = /*name*/
612
623
  n[4] + "_checkbox");
613
624
  },
614
- m(o, s) {
615
- M(o, e, s), e.innerHTML = t;
625
+ m(o, l) {
626
+ H(o, e, l), e.innerHTML = t;
616
627
  },
617
- p(o, s) {
618
- s[0] & /*_strings*/
619
- 8192 && t !== (t = /*_strings*/
620
- o[13].label + "") && (e.innerHTML = t), s[0] & /*name*/
621
- 16 && r !== (r = /*name*/
622
- o[4] + "_checkbox") && a(e, "for", r);
628
+ p(o, l) {
629
+ l[0] & /*_strings*/
630
+ 2048 && t !== (t = /*_strings*/
631
+ o[11].label + "") && (e.innerHTML = t), l[0] & /*name*/
632
+ 16 && i !== (i = /*name*/
633
+ o[4] + "_checkbox") && c(e, "for", i);
623
634
  },
624
635
  d(o) {
625
- o && D(e);
636
+ o && j(e);
626
637
  }
627
638
  };
628
639
  }
629
- function mn(n) {
640
+ function En(n) {
630
641
  let e, t = (
631
642
  /*_strings*/
632
- n[13].verifying + ""
643
+ n[11].verifying + ""
633
644
  );
634
645
  return {
635
646
  c() {
636
647
  e = F("span");
637
648
  },
638
- m(r, o) {
639
- M(r, e, o), e.innerHTML = t;
649
+ m(i, o) {
650
+ H(i, e, o), e.innerHTML = t;
640
651
  },
641
- p(r, o) {
652
+ p(i, o) {
642
653
  o[0] & /*_strings*/
643
- 8192 && t !== (t = /*_strings*/
644
- r[13].verifying + "") && (e.innerHTML = t);
654
+ 2048 && t !== (t = /*_strings*/
655
+ i[11].verifying + "") && (e.innerHTML = t);
645
656
  },
646
- d(r) {
647
- r && D(e);
657
+ d(i) {
658
+ i && j(e);
648
659
  }
649
660
  };
650
661
  }
651
- function bn(n) {
662
+ function kn(n) {
652
663
  let e, t = (
653
664
  /*_strings*/
654
- n[13].verified + ""
655
- ), r, o, s, u, f = (
656
- /*session*/
657
- n[11] && ct(n)
658
- );
665
+ n[11].verified + ""
666
+ ), i, o;
659
667
  return {
660
668
  c() {
661
- e = F("span"), r = W(), o = F("input"), s = W(), f && f.c(), u = $t(), a(o, "type", "hidden"), a(
669
+ e = F("span"), i = z(), o = F("input"), c(o, "type", "hidden"), c(
662
670
  o,
663
671
  "name",
664
672
  /*name*/
@@ -666,534 +674,412 @@ function bn(n) {
666
674
  ), o.value = /*payload*/
667
675
  n[6];
668
676
  },
669
- m(l, c) {
670
- M(l, e, c), e.innerHTML = t, M(l, r, c), M(l, o, c), M(l, s, c), f && f.m(l, c), M(l, u, c);
677
+ m(l, s) {
678
+ H(l, e, s), e.innerHTML = t, H(l, i, s), H(l, o, s);
671
679
  },
672
- p(l, c) {
673
- c[0] & /*_strings*/
674
- 8192 && t !== (t = /*_strings*/
675
- l[13].verified + "") && (e.innerHTML = t), c[0] & /*name*/
676
- 16 && a(
680
+ p(l, s) {
681
+ s[0] & /*_strings*/
682
+ 2048 && t !== (t = /*_strings*/
683
+ l[11].verified + "") && (e.innerHTML = t), s[0] & /*name*/
684
+ 16 && c(
677
685
  o,
678
686
  "name",
679
687
  /*name*/
680
688
  l[4]
681
- ), c[0] & /*payload*/
689
+ ), s[0] & /*payload*/
682
690
  64 && (o.value = /*payload*/
683
- l[6]), /*session*/
684
- l[11] ? f ? f.p(l, c) : (f = ct(l), f.c(), f.m(u.parentNode, u)) : f && (f.d(1), f = null);
691
+ l[6]);
685
692
  },
686
693
  d(l) {
687
- l && (D(e), D(r), D(o), D(s), D(u)), f && f.d(l);
694
+ l && (j(e), j(i), j(o));
688
695
  }
689
696
  };
690
697
  }
691
- function ct(n) {
692
- let e;
693
- return {
694
- c() {
695
- e = F("input"), a(e, "type", "hidden"), a(e, "name", "__session"), e.value = /*sessionPayload*/
696
- n[12];
697
- },
698
- m(t, r) {
699
- M(t, e, r);
700
- },
701
- p(t, r) {
702
- r[0] & /*sessionPayload*/
703
- 4096 && (e.value = /*sessionPayload*/
704
- t[12]);
705
- },
706
- d(t) {
707
- t && D(e);
708
- }
709
- };
710
- }
711
- function ut(n) {
712
- let e, t, r, o, s, u, f;
698
+ function lt(n) {
699
+ let e, t, i, o, l, s, h;
713
700
  return {
714
701
  c() {
715
- e = F("div"), t = F("a"), r = z("svg"), o = z("path"), s = z("path"), u = z("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(s, "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(s, "fill", "currentColor"), a(u, "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(u, "fill", "currentColor"), a(r, "width", "22"), a(r, "height", "22"), a(r, "viewBox", "0 0 20 20"), a(r, "fill", "none"), a(r, "xmlns", "http://www.w3.org/2000/svg"), a(t, "href", At), a(t, "target", "_blank"), a(t, "class", "altcha-logo"), a(t, "aria-label", f = /*_strings*/
716
- n[13].ariaLinkLabel);
702
+ e = F("div"), t = F("a"), i = K("svg"), o = K("path"), l = K("path"), s = K("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", Et), c(t, "target", "_blank"), c(t, "class", "altcha-logo"), c(t, "aria-label", h = /*_strings*/
703
+ n[11].ariaLinkLabel);
717
704
  },
718
- m(l, c) {
719
- M(l, e, c), p(e, t), p(t, r), p(r, o), p(r, s), p(r, u);
705
+ m(d, u) {
706
+ H(d, e, u), L(e, t), L(t, i), L(i, o), L(i, l), L(i, s);
720
707
  },
721
- p(l, c) {
722
- c[0] & /*_strings*/
723
- 8192 && f !== (f = /*_strings*/
724
- l[13].ariaLinkLabel) && a(t, "aria-label", f);
708
+ p(d, u) {
709
+ u[0] & /*_strings*/
710
+ 2048 && h !== (h = /*_strings*/
711
+ d[11].ariaLinkLabel) && c(t, "aria-label", h);
725
712
  },
726
- d(l) {
727
- l && D(e);
713
+ d(d) {
714
+ d && j(e);
728
715
  }
729
716
  };
730
717
  }
731
- function ht(n) {
732
- let e, t, r, o;
733
- function s(l, c) {
718
+ function st(n) {
719
+ let e, t, i, o;
720
+ function l(d, u) {
734
721
  return (
735
722
  /*state*/
736
- l[7] === _.EXPIRED ? _n : wn
723
+ d[7] === m.EXPIRED ? Cn : vn
737
724
  );
738
725
  }
739
- let u = s(n), f = u(n);
726
+ let s = l(n), h = s(n);
740
727
  return {
741
728
  c() {
742
- e = F("div"), t = z("svg"), r = z("path"), o = W(), f.c(), a(r, "stroke-linecap", "round"), a(r, "stroke-linejoin", "round"), a(r, "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");
729
+ e = F("div"), t = K("svg"), i = K("path"), o = z(), h.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");
743
730
  },
744
- m(l, c) {
745
- M(l, e, c), p(e, t), p(t, r), p(e, o), f.m(e, null);
731
+ m(d, u) {
732
+ H(d, e, u), L(e, t), L(t, i), L(e, o), h.m(e, null);
746
733
  },
747
- p(l, c) {
748
- u === (u = s(l)) && f ? f.p(l, c) : (f.d(1), f = u(l), f && (f.c(), f.m(e, null)));
734
+ p(d, u) {
735
+ s === (s = l(d)) && h ? h.p(d, u) : (h.d(1), h = s(d), h && (h.c(), h.m(e, null)));
749
736
  },
750
- d(l) {
751
- l && D(e), f.d();
737
+ d(d) {
738
+ d && j(e), h.d();
752
739
  }
753
740
  };
754
741
  }
755
- function wn(n) {
742
+ function vn(n) {
756
743
  let e, t = (
757
744
  /*_strings*/
758
- n[13].error + ""
745
+ n[11].error + ""
759
746
  );
760
747
  return {
761
748
  c() {
762
- e = F("div"), a(
749
+ e = F("div"), c(
763
750
  e,
764
751
  "title",
765
752
  /*error*/
766
753
  n[5]
767
754
  );
768
755
  },
769
- m(r, o) {
770
- M(r, e, o), e.innerHTML = t;
756
+ m(i, o) {
757
+ H(i, e, o), e.innerHTML = t;
771
758
  },
772
- p(r, o) {
759
+ p(i, o) {
773
760
  o[0] & /*_strings*/
774
- 8192 && t !== (t = /*_strings*/
775
- r[13].error + "") && (e.innerHTML = t), o[0] & /*error*/
776
- 32 && a(
761
+ 2048 && t !== (t = /*_strings*/
762
+ i[11].error + "") && (e.innerHTML = t), o[0] & /*error*/
763
+ 32 && c(
777
764
  e,
778
765
  "title",
779
766
  /*error*/
780
- r[5]
767
+ i[5]
781
768
  );
782
769
  },
783
- d(r) {
784
- r && D(e);
770
+ d(i) {
771
+ i && j(e);
785
772
  }
786
773
  };
787
774
  }
788
- function _n(n) {
775
+ function Cn(n) {
789
776
  let e, t = (
790
777
  /*_strings*/
791
- n[13].expired + ""
778
+ n[11].expired + ""
792
779
  );
793
780
  return {
794
781
  c() {
795
- e = F("div"), a(
782
+ e = F("div"), c(
796
783
  e,
797
784
  "title",
798
785
  /*error*/
799
786
  n[5]
800
787
  );
801
788
  },
802
- m(r, o) {
803
- M(r, e, o), e.innerHTML = t;
789
+ m(i, o) {
790
+ H(i, e, o), e.innerHTML = t;
804
791
  },
805
- p(r, o) {
792
+ p(i, o) {
806
793
  o[0] & /*_strings*/
807
- 8192 && t !== (t = /*_strings*/
808
- r[13].expired + "") && (e.innerHTML = t), o[0] & /*error*/
809
- 32 && a(
794
+ 2048 && t !== (t = /*_strings*/
795
+ i[11].expired + "") && (e.innerHTML = t), o[0] & /*error*/
796
+ 32 && c(
810
797
  e,
811
798
  "title",
812
799
  /*error*/
813
- r[5]
800
+ i[5]
814
801
  );
815
802
  },
816
- d(r) {
817
- r && D(e);
803
+ d(i) {
804
+ i && j(e);
818
805
  }
819
806
  };
820
807
  }
821
- function dt(n) {
822
- let e, t, r = (
808
+ function ft(n) {
809
+ let e, t, i = (
823
810
  /*_strings*/
824
- n[13].footer + ""
811
+ n[11].footer + ""
825
812
  );
826
813
  return {
827
814
  c() {
828
- e = F("div"), t = F("div"), a(e, "class", "altcha-footer");
815
+ e = F("div"), t = F("div"), c(e, "class", "altcha-footer");
829
816
  },
830
- m(o, s) {
831
- M(o, e, s), p(e, t), t.innerHTML = r;
817
+ m(o, l) {
818
+ H(o, e, l), L(e, t), t.innerHTML = i;
832
819
  },
833
- p(o, s) {
834
- s[0] & /*_strings*/
835
- 8192 && r !== (r = /*_strings*/
836
- o[13].footer + "") && (t.innerHTML = r);
820
+ p(o, l) {
821
+ l[0] & /*_strings*/
822
+ 2048 && i !== (i = /*_strings*/
823
+ o[11].footer + "") && (t.innerHTML = i);
837
824
  },
838
825
  d(o) {
839
- o && D(e);
826
+ o && j(e);
840
827
  }
841
828
  };
842
829
  }
843
- function gt(n) {
830
+ function ct(n) {
844
831
  let e;
845
832
  return {
846
833
  c() {
847
- e = F("div"), a(e, "class", "altcha-anchor-arrow");
834
+ e = F("div"), c(e, "class", "altcha-anchor-arrow");
848
835
  },
849
- m(t, r) {
850
- M(t, e, r), n[41](e);
836
+ m(t, i) {
837
+ H(t, e, i), n[48](e);
851
838
  },
852
- p: ce,
839
+ p: xe,
853
840
  d(t) {
854
- t && D(e), n[41](null);
841
+ t && j(e), n[48](null);
855
842
  }
856
843
  };
857
844
  }
858
- function yn(n) {
859
- let e, t, r, o, s, u, f, l, c, O, m, H, $, q, J, b = (
845
+ function xn(n) {
846
+ let e, t, i, o, l, s, h, d, u, A, b, Y, U, $, D, R, X;
847
+ const J = (
848
+ /*#slots*/
849
+ n[46].default
850
+ ), N = Bt(
851
+ J,
852
+ n,
853
+ /*$$scope*/
854
+ n[45],
855
+ null
856
+ );
857
+ let T = (
860
858
  /*state*/
861
- n[7] === _.VERIFYING && ft()
859
+ n[7] === m.VERIFYING && ot()
862
860
  );
863
- function K(d, E) {
861
+ function Q(a, y) {
864
862
  return (
865
863
  /*state*/
866
- d[7] === _.VERIFIED ? bn : (
864
+ a[7] === m.VERIFIED ? kn : (
867
865
  /*state*/
868
- d[7] === _.VERIFYING ? mn : gn
866
+ a[7] === m.VERIFYING ? En : pn
869
867
  )
870
868
  );
871
869
  }
872
- let X = K(n), j = X(n), I = (
870
+ let G = Q(n), V = G(n), v = (
873
871
  /*hidelogo*/
874
872
  (n[3] !== !0 || /*isFreeSaaS*/
875
- n[14]) && ut(n)
876
- ), R = (
873
+ n[12]) && lt(n)
874
+ ), P = (
877
875
  /*error*/
878
876
  (n[5] || /*state*/
879
- n[7] === _.EXPIRED) && ht(n)
880
- ), C = (
877
+ n[7] === m.EXPIRED) && st(n)
878
+ ), S = (
881
879
  /*_strings*/
882
- n[13].footer && /*hidefooter*/
880
+ n[11].footer && /*hidefooter*/
883
881
  (n[2] !== !0 || /*isFreeSaaS*/
884
- n[14]) && dt(n)
885
- ), x = (
882
+ n[12]) && ft(n)
883
+ ), E = (
886
884
  /*floating*/
887
- n[1] && gt(n)
885
+ n[1] && ct(n)
888
886
  );
889
887
  return {
890
888
  c() {
891
- e = F("div"), t = F("div"), b && b.c(), r = W(), o = F("div"), s = F("input"), l = W(), c = F("div"), j.c(), O = W(), I && I.c(), m = W(), R && R.c(), H = W(), C && C.c(), $ = W(), x && x.c(), a(s, "type", "checkbox"), a(s, "id", u = /*name*/
892
- n[4] + "_checkbox"), s.required = f = /*auto*/
893
- n[0] !== "onsubmit", a(o, "class", "altcha-checkbox"), lt(
894
- o,
889
+ N && N.c(), e = z(), t = F("div"), i = F("div"), T && T.c(), o = z(), l = F("div"), s = F("input"), u = z(), A = F("div"), V.c(), b = z(), v && v.c(), Y = z(), P && P.c(), U = z(), S && S.c(), $ = z(), E && E.c(), c(s, "type", "checkbox"), c(s, "id", h = /*name*/
890
+ n[4] + "_checkbox"), s.required = d = /*auto*/
891
+ n[0] !== "onsubmit" && (!/*floating*/
892
+ n[1] || /*auto*/
893
+ n[0] !== "off"), c(l, "class", "altcha-checkbox"), rt(
894
+ l,
895
895
  "altcha-hidden",
896
896
  /*state*/
897
- n[7] === _.VERIFYING
898
- ), a(c, "class", "altcha-label"), a(t, "class", "altcha-main"), a(e, "class", "altcha"), a(
899
- e,
897
+ n[7] === m.VERIFYING
898
+ ), c(A, "class", "altcha-label"), c(i, "class", "altcha-main"), c(t, "class", "altcha"), c(
899
+ t,
900
900
  "data-state",
901
901
  /*state*/
902
902
  n[7]
903
- ), a(
904
- e,
903
+ ), c(
904
+ t,
905
905
  "data-floating",
906
906
  /*floating*/
907
907
  n[1]
908
908
  );
909
909
  },
910
- m(d, E) {
911
- M(d, e, E), p(e, t), b && b.m(t, null), p(t, r), p(t, o), p(o, s), s.checked = /*checked*/
912
- n[8], p(t, l), p(t, c), j.m(c, null), p(t, O), I && I.m(t, null), p(e, m), R && R.m(e, null), p(e, H), C && C.m(e, null), p(e, $), x && x.m(e, null), n[42](e), q || (J = [
913
- Me(
910
+ m(a, y) {
911
+ N && N.m(a, y), H(a, e, y), H(a, t, y), L(t, i), T && T.m(i, null), L(i, o), L(i, l), L(l, s), s.checked = /*checked*/
912
+ n[8], L(i, u), L(i, A), V.m(A, null), L(i, b), v && v.m(i, null), L(t, Y), P && P.m(t, null), L(t, U), S && S.m(t, null), L(t, $), E && E.m(t, null), n[49](t), D = !0, R || (X = [
913
+ Le(
914
914
  s,
915
915
  "change",
916
916
  /*input_change_handler*/
917
- n[40]
917
+ n[47]
918
918
  ),
919
- Me(
919
+ Le(
920
920
  s,
921
921
  "change",
922
922
  /*onCheckedChange*/
923
- n[15]
923
+ n[13]
924
924
  ),
925
- Me(
925
+ Le(
926
926
  s,
927
927
  "invalid",
928
928
  /*onInvalid*/
929
- n[16]
929
+ n[14]
930
930
  )
931
- ], q = !0);
931
+ ], R = !0);
932
932
  },
933
- p(d, E) {
934
- /*state*/
935
- d[7] === _.VERIFYING ? b || (b = ft(), b.c(), b.m(t, r)) : b && (b.d(1), b = null), E[0] & /*name*/
936
- 16 && u !== (u = /*name*/
937
- d[4] + "_checkbox") && a(s, "id", u), E[0] & /*auto*/
938
- 1 && f !== (f = /*auto*/
939
- d[0] !== "onsubmit") && (s.required = f), E[0] & /*checked*/
933
+ p(a, y) {
934
+ N && N.p && (!D || y[1] & /*$$scope*/
935
+ 16384) && Zt(
936
+ N,
937
+ J,
938
+ a,
939
+ /*$$scope*/
940
+ a[45],
941
+ D ? qt(
942
+ J,
943
+ /*$$scope*/
944
+ a[45],
945
+ y,
946
+ null
947
+ ) : Gt(
948
+ /*$$scope*/
949
+ a[45]
950
+ ),
951
+ null
952
+ ), /*state*/
953
+ a[7] === m.VERIFYING ? T || (T = ot(), T.c(), T.m(i, o)) : T && (T.d(1), T = null), (!D || y[0] & /*name*/
954
+ 16 && h !== (h = /*name*/
955
+ a[4] + "_checkbox")) && c(s, "id", h), (!D || y[0] & /*auto, floating*/
956
+ 3 && d !== (d = /*auto*/
957
+ a[0] !== "onsubmit" && (!/*floating*/
958
+ a[1] || /*auto*/
959
+ a[0] !== "off"))) && (s.required = d), y[0] & /*checked*/
940
960
  256 && (s.checked = /*checked*/
941
- d[8]), E[0] & /*state*/
942
- 128 && lt(
943
- o,
961
+ a[8]), (!D || y[0] & /*state*/
962
+ 128) && rt(
963
+ l,
944
964
  "altcha-hidden",
945
965
  /*state*/
946
- d[7] === _.VERIFYING
947
- ), X === (X = K(d)) && j ? j.p(d, E) : (j.d(1), j = X(d), j && (j.c(), j.m(c, null))), /*hidelogo*/
948
- d[3] !== !0 || /*isFreeSaaS*/
949
- d[14] ? I ? I.p(d, E) : (I = ut(d), I.c(), I.m(t, null)) : I && (I.d(1), I = null), /*error*/
950
- d[5] || /*state*/
951
- d[7] === _.EXPIRED ? R ? R.p(d, E) : (R = ht(d), R.c(), R.m(e, H)) : R && (R.d(1), R = null), /*_strings*/
952
- d[13].footer && /*hidefooter*/
953
- (d[2] !== !0 || /*isFreeSaaS*/
954
- d[14]) ? C ? C.p(d, E) : (C = dt(d), C.c(), C.m(e, $)) : C && (C.d(1), C = null), /*floating*/
955
- d[1] ? x ? x.p(d, E) : (x = gt(d), x.c(), x.m(e, null)) : x && (x.d(1), x = null), E[0] & /*state*/
956
- 128 && a(
957
- e,
966
+ a[7] === m.VERIFYING
967
+ ), G === (G = Q(a)) && V ? V.p(a, y) : (V.d(1), V = G(a), V && (V.c(), V.m(A, null))), /*hidelogo*/
968
+ a[3] !== !0 || /*isFreeSaaS*/
969
+ a[12] ? v ? v.p(a, y) : (v = lt(a), v.c(), v.m(i, null)) : v && (v.d(1), v = null), /*error*/
970
+ a[5] || /*state*/
971
+ a[7] === m.EXPIRED ? P ? P.p(a, y) : (P = st(a), P.c(), P.m(t, U)) : P && (P.d(1), P = null), /*_strings*/
972
+ a[11].footer && /*hidefooter*/
973
+ (a[2] !== !0 || /*isFreeSaaS*/
974
+ a[12]) ? S ? S.p(a, y) : (S = ft(a), S.c(), S.m(t, $)) : S && (S.d(1), S = null), /*floating*/
975
+ a[1] ? E ? E.p(a, y) : (E = ct(a), E.c(), E.m(t, null)) : E && (E.d(1), E = null), (!D || y[0] & /*state*/
976
+ 128) && c(
977
+ t,
958
978
  "data-state",
959
979
  /*state*/
960
- d[7]
961
- ), E[0] & /*floating*/
962
- 2 && a(
963
- e,
980
+ a[7]
981
+ ), (!D || y[0] & /*floating*/
982
+ 2) && c(
983
+ t,
964
984
  "data-floating",
965
985
  /*floating*/
966
- d[1]
986
+ a[1]
967
987
  );
968
988
  },
969
- i: ce,
970
- o: ce,
971
- d(d) {
972
- d && D(e), b && b.d(), j.d(), I && I.d(), R && R.d(), C && C.d(), x && x.d(), n[42](null), q = !1, ve(J);
989
+ i(a) {
990
+ D || (yt(N, a), D = !0);
991
+ },
992
+ o(a) {
993
+ on(N, a), D = !1;
994
+ },
995
+ d(a) {
996
+ a && (j(e), j(t)), N && N.d(a), T && T.d(), V.d(), v && v.d(), P && P.d(), S && S.d(), E && E.d(), n[49](null), R = !1, pe(X);
973
997
  }
974
998
  };
975
999
  }
976
- const mt = "Visit Altcha.org", At = "https://altcha.org/";
977
- function bt(n) {
1000
+ const ut = "Visit Altcha.org", Et = "https://altcha.org/";
1001
+ function at(n) {
978
1002
  return JSON.parse(n);
979
1003
  }
980
- function vn(n, e, t) {
981
- var tt, nt;
982
- let r, o, s, u, { analytics: f = !1 } = e, { auto: l = void 0 } = e, { beaconurl: c = void 0 } = e, { blockspam: O = void 0 } = e, { challengeurl: m = void 0 } = e, { challengejson: H = void 0 } = e, { debug: $ = !1 } = e, { delay: q = 0 } = e, { expire: J = void 0 } = e, { floating: b = void 0 } = e, { floatinganchor: K = void 0 } = e, { floatingoffset: X = void 0 } = e, { hidefooter: j = !1 } = e, { hidelogo: I = !1 } = e, { name: R = "altcha" } = e, { maxnumber: C = 1e6 } = e, { mockerror: x = !1 } = e, { refetchonexpire: d = !0 } = e, { spamfilter: E = !1 } = e, { strings: Ee = void 0 } = e, { test: Z = !1 } = e, { verifyurl: ee = void 0 } = e, { workers: ue = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: ke = void 0 } = e;
983
- const Re = Xt(), Pe = ["SHA-256", "SHA-384", "SHA-512"], Ue = (nt = (tt = document.documentElement.lang) == null ? void 0 : tt.split("-")) == null ? void 0 : nt[0];
984
- let Q = !1, A, te = null, pe = null, g = null, Ce = null, Y = null, ne = null, V = null, Oe = null, B = _.UNVERIFIED;
985
- Jt(() => {
986
- g && (g.removeEventListener("submit", $e), g.removeEventListener("reset", qe), g.removeEventListener("focusin", He), g = null), V && V.destroy(), Y && (clearTimeout(Y), Y = null), document.removeEventListener("click", Xe), document.removeEventListener("scroll", We), window.removeEventListener("resize", Ke);
987
- }), Gt(() => {
988
- k("mounted", "0.7.0"), k("workers", ue), Z && k("using test mode"), J && Ae(J), l !== void 0 && k("auto", l), b !== void 0 && Qe(b), g = A.closest("form"), g && (g.addEventListener("submit", $e, { capture: !0 }), g.addEventListener("reset", qe), l === "onfocus" && g.addEventListener("focusin", He)), f && Ge(), l === "onload" && ie(), r && (j || I) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.");
1004
+ function An(n, e, t) {
1005
+ var Qe, et;
1006
+ let i, o, l, s, { $$slots: h = {}, $$scope: d } = e, { auto: u = void 0 } = e, { blockspam: A = void 0 } = e, { challengeurl: b = void 0 } = e, { challengejson: Y = void 0 } = e, { debug: U = !1 } = e, { delay: $ = 0 } = e, { expire: D = void 0 } = e, { floating: R = void 0 } = e, { floatinganchor: X = void 0 } = e, { floatingoffset: J = void 0 } = e, { hidefooter: N = !1 } = e, { hidelogo: T = !1 } = e, { name: Q = "altcha" } = e, { maxnumber: G = 1e6 } = e, { mockerror: V = !1 } = e, { obfuscated: v = void 0 } = e, { plugins: P = void 0 } = e, { refetchonexpire: S = !0 } = e, { spamfilter: E = !1 } = e, { strings: a = void 0 } = e, { test: y = !1 } = e, { verifyurl: ee = void 0 } = e, { workers: le = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: ae = void 0 } = e;
1007
+ const he = Qt(), Pe = ["SHA-256", "SHA-384", "SHA-512"], Me = (et = (Qe = document.documentElement.lang) == null ? void 0 : Qe.split("-")) == null ? void 0 : et[0];
1008
+ let re = !1, C, ie = null, se = null, _ = null, de = null, W = null, oe = null, te = [], x = m.UNVERIFIED;
1009
+ Kt(() => {
1010
+ kt(), _ && (_.removeEventListener("submit", Oe), _.removeEventListener("reset", Ue), _.removeEventListener("focusin", He), _ = null), W && (clearTimeout(W), W = null), document.removeEventListener("click", Ve), document.removeEventListener("scroll", je), window.removeEventListener("resize", Be);
1011
+ }), zt(() => {
1012
+ k("mounted", "0.9.0"), k("workers", le), It(), k("plugins", te.length ? te.map((r) => r.constructor.pluginName).join(", ") : "none"), y && k("using test mode"), D && ke(D), u !== void 0 && k("auto", u), R !== void 0 && qe(R), _ = C.closest("form"), _ && (_.addEventListener("submit", Oe, { capture: !0 }), _.addEventListener("reset", Ue), u === "onfocus" && _.addEventListener("focusin", He)), u === "onload" && (v ? ge() : ne()), i && (N || T) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."), requestAnimationFrame(() => {
1013
+ he("load");
1014
+ });
989
1015
  });
990
- function k(...i) {
991
- ($ || i.some((h) => h instanceof Error)) && console[i[0] instanceof Error ? "error" : "log"]("ALTCHA", ...i);
992
- }
993
- function He(i) {
994
- B === _.UNVERIFIED && ie();
995
- }
996
- function $e(i) {
997
- g && V && B === _.VERIFIED && (V.end(), t(12, Oe = V.dataAsBase64())), g && l === "onsubmit" && (B === _.UNVERIFIED ? (i.preventDefault(), i.stopPropagation(), ie().then(() => {
998
- g == null || g.requestSubmit();
999
- })) : B !== _.VERIFIED && (i.preventDefault(), i.stopPropagation(), B === _.VERIFYING && ze()));
1000
- }
1001
- function qe() {
1002
- Le();
1003
- }
1004
- function Ze(i, h) {
1016
+ function Fe(r, f) {
1005
1017
  return btoa(JSON.stringify({
1006
- algorithm: i.algorithm,
1007
- challenge: i.challenge,
1008
- number: h.number,
1009
- salt: i.salt,
1010
- signature: i.signature,
1011
- test: Z ? !0 : void 0,
1012
- took: h.took
1018
+ algorithm: r.algorithm,
1019
+ challenge: r.challenge,
1020
+ number: f.number,
1021
+ salt: r.salt,
1022
+ signature: r.signature,
1023
+ test: y ? !0 : void 0,
1024
+ took: f.took
1013
1025
  }));
1014
1026
  }
1015
- function Ye(i) {
1016
- if (!i.algorithm)
1017
- throw new Error("Invalid challenge. Property algorithm is missing.");
1018
- if (i.signature === void 0)
1019
- throw new Error("Invalid challenge. Property signature is missing.");
1020
- if (!Pe.includes(i.algorithm.toUpperCase()))
1021
- throw new Error(`Unknown algorithm value. Allowed values: ${Pe.join(", ")}`);
1022
- if (!i.challenge || i.challenge.length < 40)
1023
- throw new Error("Challenge is too short. Min. 40 chars.");
1024
- if (!i.salt || i.salt.length < 10)
1025
- throw new Error("Salt is too short. Min. 10 chars.");
1027
+ function kt() {
1028
+ for (const r of te)
1029
+ r.destroy();
1026
1030
  }
1027
- async function Lt() {
1028
- var i;
1029
- if (x)
1031
+ function Ne() {
1032
+ b && S && x === m.VERIFIED ? ne() : me(m.EXPIRED, s.expired);
1033
+ }
1034
+ async function vt() {
1035
+ var r;
1036
+ if (V)
1030
1037
  throw k("mocking error"), new Error("Mocked error.");
1031
1038
  if (o)
1032
1039
  return k("using provided json data"), o;
1033
- if (Z)
1034
- return k("generating test challenge", { test: Z }), un(typeof Z != "boolean" ? +Z : void 0);
1040
+ if (y)
1041
+ return k("generating test challenge", { test: y }), gn(typeof y != "boolean" ? +y : void 0);
1035
1042
  {
1036
- if (!m && g) {
1037
- const y = g.getAttribute("action");
1038
- y != null && y.includes("/form/") && t(17, m = y + "/altcha");
1043
+ if (!b && _) {
1044
+ const w = _.getAttribute("action");
1045
+ w != null && w.includes("/form/") && t(15, b = w + "/altcha");
1039
1046
  }
1040
- if (!m)
1047
+ if (!b)
1041
1048
  throw new Error("Attribute challengeurl not set.");
1042
- k("fetching challenge from", m);
1043
- const h = await fetch(m, {
1049
+ k("fetching challenge from", b);
1050
+ const f = await fetch(b, {
1044
1051
  headers: E ? { "x-altcha-spam-filter": "1" } : {}
1045
1052
  });
1046
- if (h.status !== 200)
1047
- throw new Error(`Server responded with ${h.status}.`);
1048
- const w = h.headers.get("Expires"), T = h.headers.get("X-Altcha-Config"), P = await h.json(), N = new URLSearchParams((i = P.salt.split("?")) == null ? void 0 : i[1]), G = N.get("expires") || N.get("expire");
1049
- if (G) {
1050
- const y = new Date(+G * 1e3), L = isNaN(y.getTime()) ? 0 : y.getTime() - Date.now();
1051
- L > 0 && Ae(L);
1053
+ if (f.status !== 200)
1054
+ throw new Error(`Server responded with ${f.status}.`);
1055
+ const g = f.headers.get("Expires"), I = f.headers.get("X-Altcha-Config"), B = await f.json(), O = new URLSearchParams((r = B.salt.split("?")) == null ? void 0 : r[1]), M = O.get("expires") || O.get("expire");
1056
+ if (M) {
1057
+ const w = new Date(+M * 1e3), q = isNaN(w.getTime()) ? 0 : w.getTime() - Date.now();
1058
+ q > 0 && ke(q);
1052
1059
  }
1053
- if (T)
1060
+ if (I)
1054
1061
  try {
1055
- const y = JSON.parse(T);
1056
- y && typeof y == "object" && (y.verifyurl && (y.verifyurl = new URL(y.verifyurl, new URL(m)).toString()), et(y));
1057
- } catch (y) {
1058
- k("unable to configure from X-Altcha-Config", y);
1062
+ const w = JSON.parse(I);
1063
+ w && typeof w == "object" && (w.verifyurl && (w.verifyurl = new URL(w.verifyurl, new URL(b)).toString()), Ye(w));
1064
+ } catch (w) {
1065
+ k("unable to configure from X-Altcha-Config", w);
1059
1066
  }
1060
- if (!J && (w != null && w.length)) {
1061
- const y = Date.parse(w);
1062
- if (y) {
1063
- const L = y - Date.now();
1064
- L > 0 && Ae(L);
1067
+ if (!D && (g != null && g.length)) {
1068
+ const w = Date.parse(g);
1069
+ if (w) {
1070
+ const q = w - Date.now();
1071
+ q > 0 && ke(q);
1065
1072
  }
1066
1073
  }
1067
- return P;
1074
+ return B;
1068
1075
  }
1069
1076
  }
1070
- function Ge() {
1071
- if (!V)
1072
- if (g) {
1073
- if (k("analytics enabled"), t(11, V = new dn(g)), c === void 0) {
1074
- const i = g.getAttribute("action");
1075
- i && t(19, c = i + "/beacon");
1076
- }
1077
- t(11, V.beaconUrl = c || null, V);
1078
- } else
1079
- k("analytics cannot be enabled - form element not found");
1080
- }
1081
- function Je() {
1082
- m && d && B === _.VERIFIED ? ie() : Le(_.EXPIRED, u.expired);
1083
- }
1084
- async function It(i) {
1085
- let h = null;
1086
- if ("Worker" in window) {
1087
- try {
1088
- h = await xt(i.challenge, i.salt, i.algorithm, i.maxnumber);
1089
- } catch (w) {
1090
- k(w);
1091
- }
1092
- if ((h == null ? void 0 : h.number) !== void 0)
1093
- return { data: i, solution: h };
1094
- }
1095
- return {
1096
- data: i,
1097
- solution: await hn(i.challenge, i.salt, i.algorithm, i.maxnumber || C).promise
1098
- };
1099
- }
1100
- async function xt(i, h, w, T = typeof Z == "number" ? Z : C, P = Math.ceil(ue)) {
1101
- const N = [];
1102
- P = Math.min(16, Math.max(1, P));
1103
- for (let L = 0; L < P; L++)
1104
- N.push(createAltchaWorker(ke));
1105
- const G = Math.ceil(T / P), y = await Promise.all(N.map((L, De) => {
1106
- const he = De * G;
1107
- return new Promise((Ie) => {
1108
- L.addEventListener("message", (xe) => {
1109
- if (xe.data)
1110
- for (const de of N)
1111
- de !== L && de.postMessage({ type: "abort" });
1112
- Ie(xe.data);
1113
- }), L.postMessage({
1114
- payload: {
1115
- alg: w,
1116
- challenge: i,
1117
- max: he + G,
1118
- salt: h,
1119
- start: he
1120
- },
1121
- type: "work"
1122
- });
1123
- });
1124
- }));
1125
- for (const L of N)
1126
- L.terminate();
1127
- return y.find((L) => !!L) || null;
1128
- }
1129
- function Tt() {
1130
- [_.UNVERIFIED, _.ERROR, _.EXPIRED].includes(B) ? E && (g == null ? void 0 : g.reportValidity()) === !1 ? t(8, Q = !1) : ie() : t(8, Q = !0);
1131
- }
1132
- function Xe(i) {
1133
- const h = i.target;
1134
- b && h && !A.contains(h) && B === _.VERIFIED && t(9, A.style.display = "none", A);
1135
- }
1136
- function We() {
1137
- b && Se();
1138
- }
1139
- function ze() {
1140
- B === _.VERIFYING && u.waitAlert && alert(u.waitAlert);
1141
- }
1142
- function Ft(i) {
1143
- V && V.trackError(Ce);
1144
- }
1145
- function Rt(i) {
1146
- b && B !== _.UNVERIFIED && requestAnimationFrame(() => {
1147
- Se();
1148
- });
1077
+ function Ct(r) {
1078
+ var g;
1079
+ const f = _ == null ? void 0 : _.querySelector(typeof r == "string" ? `input[name="${r}"]` : 'input[type="email"]:not([data-no-spamfilter])');
1080
+ return ((g = f == null ? void 0 : f.value) == null ? void 0 : g.slice(f.value.indexOf("@"))) || void 0;
1149
1081
  }
1150
- function Ke() {
1151
- b && Se();
1152
- }
1153
- function Ae(i) {
1154
- k("expire", i), Y && (clearTimeout(Y), Y = null), i < 1 ? Je() : Y = setTimeout(Je, i);
1155
- }
1156
- function Qe(i) {
1157
- k("floating", i), b !== i && (t(9, A.style.left = "", A), t(9, A.style.top = "", A)), t(1, b = i === !0 || i === "" ? "auto" : i === !1 || i === "false" ? void 0 : b), b ? (l || t(0, l = "onsubmit"), document.addEventListener("scroll", We), document.addEventListener("click", Xe), window.addEventListener("resize", Ke)) : l === "onsubmit" && t(0, l = void 0);
1158
- }
1159
- function St(i) {
1160
- var w;
1161
- const h = g == null ? void 0 : g.querySelector(typeof i == "string" ? `input[name="${i}"]` : 'input[type="email"]:not([data-no-spamfilter])');
1162
- return ((w = h == null ? void 0 : h.value) == null ? void 0 : w.slice(h.value.indexOf("@"))) || void 0;
1163
- }
1164
- function Dt(i) {
1165
- return [
1166
- ...(g == null ? void 0 : g.querySelectorAll(i != null && i.length ? i.map((w) => `input[name="${w}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || []
1167
- ].reduce(
1168
- (w, T) => {
1169
- const P = T.name, N = T.value;
1170
- return P && N && (w[P] = /\n/.test(N) ? N.replace(new RegExp("(?<!\\r)\\n", "g"), `\r
1171
- `) : N), w;
1172
- },
1173
- {}
1174
- );
1175
- }
1176
- async function Mt(i) {
1177
- if (!ee)
1178
- throw new Error("Attribute verifyurl not set.");
1179
- k("requesting server verification from", ee);
1180
- const h = { payload: i };
1181
- if (E) {
1182
- const { blockedCountries: P, classifier: N, disableRules: G, email: y, expectedLanguages: L, expectedCountries: De, fields: he, ipAddress: Ie, text: xe, timeZone: de } = Nt();
1183
- h.blockedCountries = P, h.classifier = N, h.disableRules = G, h.email = y === !1 ? void 0 : St(y), h.expectedCountries = De, h.expectedLanguages = L || (Ue ? [Ue] : void 0), h.fields = he === !1 ? void 0 : Dt(he), h.ipAddress = Ie === !1 ? void 0 : Ie || "auto", h.text = xe, h.timeZone = de === !1 ? void 0 : de || Ct();
1184
- }
1185
- const w = await fetch(ee, {
1186
- body: JSON.stringify(h),
1187
- headers: { "content-type": "application/json" },
1188
- method: "POST"
1189
- });
1190
- if (w.status !== 200)
1191
- throw new Error(`Server responded with ${w.status}.`);
1192
- const T = await w.json();
1193
- if (T != null && T.payload && t(6, ne = T.payload), Re("serververification", T), O && T.classification === "BAD")
1194
- throw new Error("SpamFilter returned negative classification.");
1195
- }
1196
- function Nt() {
1082
+ function xt() {
1197
1083
  return E === "ipAddress" ? {
1198
1084
  blockedCountries: void 0,
1199
1085
  classifier: void 0,
@@ -1218,316 +1104,578 @@ function vn(n, e, t) {
1218
1104
  timeZone: void 0
1219
1105
  };
1220
1106
  }
1221
- function Se(i = 20) {
1222
- if (A)
1223
- if (pe || (pe = (K ? document.querySelector(K) : g == null ? void 0 : g.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || g), pe) {
1224
- const h = parseInt(X, 10) || 12, w = pe.getBoundingClientRect(), T = A.getBoundingClientRect(), P = document.documentElement.clientHeight, N = document.documentElement.clientWidth, G = b === "auto" ? w.bottom + T.height + h + i > P : b === "top", y = Math.max(i, Math.min(N - i - T.width, w.left + w.width / 2 - T.width / 2));
1225
- if (G ? t(9, A.style.top = `${w.top - (T.height + h)}px`, A) : t(9, A.style.top = `${w.bottom + h}px`, A), t(9, A.style.left = `${y}px`, A), A.setAttribute("data-floating", G ? "top" : "bottom"), te) {
1226
- const L = te.getBoundingClientRect();
1227
- t(10, te.style.left = w.left - y + w.width / 2 - L.width / 2 + "px", te);
1107
+ function At(r) {
1108
+ return [
1109
+ ...(_ == null ? void 0 : _.querySelectorAll(r != null && r.length ? r.map((g) => `input[name="${g}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || []
1110
+ ].reduce(
1111
+ (g, I) => {
1112
+ const B = I.name, O = I.value;
1113
+ return B && O && (g[B] = /\n/.test(O) ? O.replace(new RegExp("(?<!\\r)\\n", "g"), `\r
1114
+ `) : O), g;
1115
+ },
1116
+ {}
1117
+ );
1118
+ }
1119
+ function It() {
1120
+ const r = P !== void 0 ? P.split(",") : void 0;
1121
+ for (const f of globalThis.altchaPlugins)
1122
+ (!r || r.includes(f.pluginName)) && te.push(new f({
1123
+ el: C,
1124
+ clarify: ge,
1125
+ dispatch: he,
1126
+ getConfiguration: We,
1127
+ getFloatingAnchor: Xe,
1128
+ getState: Je,
1129
+ log: k,
1130
+ reset: me,
1131
+ solve: Ge,
1132
+ setState: Ke,
1133
+ setFloatingAnchor: ze,
1134
+ verify: ne
1135
+ }));
1136
+ }
1137
+ function k(...r) {
1138
+ (U || r.some((f) => f instanceof Error)) && console[r[0] instanceof Error ? "error" : "log"]("ALTCHA", `[name=${Q}]`, ...r);
1139
+ }
1140
+ function Lt() {
1141
+ [m.UNVERIFIED, m.ERROR, m.EXPIRED].includes(x) ? E && (_ == null ? void 0 : _.reportValidity()) === !1 ? t(8, re = !1) : v ? ge() : ne() : t(8, re = !0);
1142
+ }
1143
+ function Ve(r) {
1144
+ const f = r.target;
1145
+ R && f && !C.contains(f) && (x === m.VERIFIED || u === "off" && x === m.UNVERIFIED) && t(9, C.style.display = "none", C);
1146
+ }
1147
+ function je() {
1148
+ R && x !== m.UNVERIFIED && Ee();
1149
+ }
1150
+ function Rt(r) {
1151
+ for (const f of te)
1152
+ typeof f.onErrorChange == "function" && f.onErrorChange(de);
1153
+ }
1154
+ function He(r) {
1155
+ x === m.UNVERIFIED && ne();
1156
+ }
1157
+ function Oe(r) {
1158
+ _ && u === "onsubmit" ? x === m.UNVERIFIED ? (r.preventDefault(), r.stopPropagation(), ne().then(() => {
1159
+ _ == null || _.requestSubmit();
1160
+ })) : x !== m.VERIFIED && (r.preventDefault(), r.stopPropagation(), x === m.VERIFYING && $e()) : _ && R && u === "off" && x === m.UNVERIFIED && (r.preventDefault(), r.stopPropagation(), t(9, C.style.display = "block", C), Ee());
1161
+ }
1162
+ function Ue() {
1163
+ me();
1164
+ }
1165
+ function $e() {
1166
+ x === m.VERIFYING && s.waitAlert && alert(s.waitAlert);
1167
+ }
1168
+ function St(r) {
1169
+ for (const f of te)
1170
+ typeof f.onStateChange == "function" && f.onStateChange(x);
1171
+ R && x !== m.UNVERIFIED && requestAnimationFrame(() => {
1172
+ Ee();
1173
+ }), t(8, re = x === m.VERIFIED);
1174
+ }
1175
+ function Be() {
1176
+ R && Ee();
1177
+ }
1178
+ function Ee(r = 20) {
1179
+ if (C)
1180
+ if (se || (se = (X ? document.querySelector(X) : _ == null ? void 0 : _.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || _), se) {
1181
+ const f = parseInt(J, 10) || 12, g = se.getBoundingClientRect(), I = C.getBoundingClientRect(), B = document.documentElement.clientHeight, O = document.documentElement.clientWidth, M = R === "auto" ? g.bottom + I.height + f + r > B : R === "top", w = Math.max(r, Math.min(O - r - I.width, g.left + g.width / 2 - I.width / 2));
1182
+ if (M ? t(9, C.style.top = `${g.top - (I.height + f)}px`, C) : t(9, C.style.top = `${g.bottom + f}px`, C), t(9, C.style.left = `${w}px`, C), C.setAttribute("data-floating", M ? "top" : "bottom"), ie) {
1183
+ const q = ie.getBoundingClientRect();
1184
+ t(10, ie.style.left = g.left - w + g.width / 2 - q.width / 2 + "px", ie);
1228
1185
  }
1229
1186
  } else
1230
1187
  k("unable to find floating anchor element");
1231
1188
  }
1232
- function et(i) {
1233
- i.analytics && (t(18, f = i.analytics), Ge()), i.auto !== void 0 && (t(0, l = i.auto), l === "onload" && ie()), i.beaconurl && (t(19, c = i.beaconurl), V && t(11, V.beaconUrl = c, V)), i.floatinganchor !== void 0 && t(23, K = i.floatinganchor), i.delay !== void 0 && t(21, q = i.delay), i.floatingoffset !== void 0 && t(24, X = i.floatingoffset), i.floating !== void 0 && Qe(i.floating), i.expire !== void 0 && (Ae(i.expire), t(22, J = i.expire)), i.challenge && (Ye(i.challenge), o = i.challenge), i.challengeurl !== void 0 && t(17, m = i.challengeurl), i.debug !== void 0 && t(20, $ = !!i.debug), i.hidefooter !== void 0 && t(2, j = !!i.hidefooter), i.hidelogo !== void 0 && t(3, I = !!i.hidelogo), i.maxnumber !== void 0 && t(25, C = +i.maxnumber), i.mockerror !== void 0 && t(26, x = !!i.mockerror), i.name !== void 0 && t(4, R = i.name), i.refetchonexpire !== void 0 && t(27, d = !!i.refetchonexpire), i.spamfilter !== void 0 && t(28, E = typeof i.spamfilter == "object" ? i.spamfilter : !!i.spamfilter), i.strings && t(39, s = i.strings), i.test !== void 0 && t(29, Z = typeof i.test == "number" ? i.test : !!i.test), i.verifyurl !== void 0 && t(30, ee = i.verifyurl), i.workers !== void 0 && t(31, ue = +i.workers), i.workerurl !== void 0 && t(32, ke = i.workerurl);
1189
+ async function Dt(r) {
1190
+ if (!ee)
1191
+ throw new Error("Attribute verifyurl not set.");
1192
+ k("requesting server verification from", ee);
1193
+ const f = { payload: r };
1194
+ if (E) {
1195
+ const { blockedCountries: B, classifier: O, disableRules: M, email: w, expectedLanguages: q, expectedCountries: Ie, fields: be, ipAddress: ye, text: Vt, timeZone: tt } = xt();
1196
+ f.blockedCountries = B, f.classifier = O, f.disableRules = M, f.email = w === !1 ? void 0 : Ct(w), f.expectedCountries = Ie, f.expectedLanguages = q || (Me ? [Me] : void 0), f.fields = be === !1 ? void 0 : At(be), f.ipAddress = ye === !1 ? void 0 : ye || "auto", f.text = Vt, f.timeZone = tt === !1 ? void 0 : tt || bn();
1197
+ }
1198
+ const g = await fetch(ee, {
1199
+ body: JSON.stringify(f),
1200
+ headers: { "content-type": "application/json" },
1201
+ method: "POST"
1202
+ });
1203
+ if (g.status !== 200)
1204
+ throw new Error(`Server responded with ${g.status}.`);
1205
+ const I = await g.json();
1206
+ if (I != null && I.payload && t(6, oe = I.payload), he("serververification", I), A && I.classification === "BAD")
1207
+ throw new Error("SpamFilter returned negative classification.");
1208
+ }
1209
+ function ke(r) {
1210
+ k("expire", r), W && (clearTimeout(W), W = null), r < 1 ? Ne() : W = setTimeout(Ne, r);
1234
1211
  }
1235
- function Le(i = _.UNVERIFIED, h = null) {
1236
- Y && (clearTimeout(Y), Y = null), t(8, Q = !1), t(5, Ce = h), t(6, ne = null), t(7, B = i);
1212
+ function qe(r) {
1213
+ k("floating", r), R !== r && (t(9, C.style.left = "", C), t(9, C.style.top = "", C)), t(1, R = r === !0 || r === "" ? "auto" : r === !1 || r === "false" ? void 0 : R), R ? (u || t(0, u = "onsubmit"), document.addEventListener("scroll", je), document.addEventListener("click", Ve), window.addEventListener("resize", Be)) : u === "onsubmit" && t(0, u = void 0);
1237
1214
  }
1238
- async function ie() {
1239
- return Le(_.VERIFYING), await new Promise((i) => setTimeout(i, q || 0)), Lt().then((i) => (Ye(i), k("challenge", i), It(i))).then(({ data: i, solution: h }) => {
1240
- if (k("solution", h), (h == null ? void 0 : h.number) !== void 0) {
1241
- if (ee)
1242
- return Mt(Ze(i, h));
1243
- t(6, ne = Ze(i, h)), k("payload", ne);
1244
- } else
1245
- throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned.");
1215
+ function Ze(r) {
1216
+ if (!r.algorithm)
1217
+ throw new Error("Invalid challenge. Property algorithm is missing.");
1218
+ if (r.signature === void 0)
1219
+ throw new Error("Invalid challenge. Property signature is missing.");
1220
+ if (!Pe.includes(r.algorithm.toUpperCase()))
1221
+ throw new Error(`Unknown algorithm value. Allowed values: ${Pe.join(", ")}`);
1222
+ if (!r.challenge || r.challenge.length < 40)
1223
+ throw new Error("Challenge is too short. Min. 40 chars.");
1224
+ if (!r.salt || r.salt.length < 10)
1225
+ throw new Error("Salt is too short. Min. 10 chars.");
1226
+ }
1227
+ async function Ge(r) {
1228
+ let f = null;
1229
+ if ("Worker" in window) {
1230
+ try {
1231
+ f = await Tt(r, r.maxnumber);
1232
+ } catch (g) {
1233
+ k(g);
1234
+ }
1235
+ if ((f == null ? void 0 : f.number) !== void 0 || "obfuscated" in r)
1236
+ return { data: r, solution: f };
1237
+ }
1238
+ if ("obfuscated" in r) {
1239
+ const g = await wn(r.obfuscated, r.key, r.maxnumber);
1240
+ return { data: r, solution: await g.promise };
1241
+ }
1242
+ return {
1243
+ data: r,
1244
+ solution: await mn(r.challenge, r.salt, r.algorithm, r.maxnumber || G).promise
1245
+ };
1246
+ }
1247
+ async function Tt(r, f = typeof y == "number" ? y : G, g = Math.ceil(le)) {
1248
+ const I = [];
1249
+ g = Math.min(16, Math.max(1, g));
1250
+ for (let M = 0; M < g; M++)
1251
+ I.push(altchaCreateWorker(ae));
1252
+ const B = Math.ceil(f / g), O = await Promise.all(I.map((M, w) => {
1253
+ const q = w * B;
1254
+ return new Promise((Ie) => {
1255
+ M.addEventListener("message", (be) => {
1256
+ if (be.data)
1257
+ for (const ye of I)
1258
+ ye !== M && ye.postMessage({ type: "abort" });
1259
+ Ie(be.data);
1260
+ }), M.postMessage({
1261
+ payload: r,
1262
+ max: q + B,
1263
+ start: q,
1264
+ type: "work"
1265
+ });
1266
+ });
1267
+ }));
1268
+ for (const M of I)
1269
+ M.terminate();
1270
+ return O.find((M) => !!M) || null;
1271
+ }
1272
+ async function ge() {
1273
+ if (!v) {
1274
+ t(7, x = m.ERROR);
1275
+ return;
1276
+ }
1277
+ const r = te.find((f) => f.constructor.pluginName === "obfuscation");
1278
+ if (!r || !("clarify" in r)) {
1279
+ t(7, x = m.ERROR), k("Plugin `obfuscation` not found. Import `altcha/plugins/obfuscation` to load it.");
1280
+ return;
1281
+ }
1282
+ if ("clarify" in r && typeof r.clarify == "function")
1283
+ return r.clarify();
1284
+ }
1285
+ function Ye(r) {
1286
+ r.obfuscated !== void 0 && t(24, v = r.obfuscated), r.auto !== void 0 && (t(0, u = r.auto), u === "onload" && (v ? ge() : ne())), r.blockspam !== void 0 && t(16, A = !!r.blockspam), r.floatinganchor !== void 0 && t(20, X = r.floatinganchor), r.delay !== void 0 && t(18, $ = r.delay), r.floatingoffset !== void 0 && t(21, J = r.floatingoffset), r.floating !== void 0 && qe(r.floating), r.expire !== void 0 && (ke(r.expire), t(19, D = r.expire)), r.challenge && (Ze(r.challenge), o = r.challenge), r.challengeurl !== void 0 && t(15, b = r.challengeurl), r.debug !== void 0 && t(17, U = !!r.debug), r.hidefooter !== void 0 && t(2, N = !!r.hidefooter), r.hidelogo !== void 0 && t(3, T = !!r.hidelogo), r.maxnumber !== void 0 && t(22, G = +r.maxnumber), r.mockerror !== void 0 && t(23, V = !!r.mockerror), r.name !== void 0 && t(4, Q = r.name), r.refetchonexpire !== void 0 && t(25, S = !!r.refetchonexpire), r.spamfilter !== void 0 && t(26, E = typeof r.spamfilter == "object" ? r.spamfilter : !!r.spamfilter), r.strings && t(44, l = r.strings), r.test !== void 0 && t(27, y = typeof r.test == "number" ? r.test : !!r.test), r.verifyurl !== void 0 && t(28, ee = r.verifyurl), r.workers !== void 0 && t(29, le = +r.workers), r.workerurl !== void 0 && t(30, ae = r.workerurl);
1287
+ }
1288
+ function We() {
1289
+ return {
1290
+ auto: u,
1291
+ blockspam: A,
1292
+ challengeurl: b,
1293
+ debug: U,
1294
+ delay: $,
1295
+ expire: D,
1296
+ floating: R,
1297
+ floatinganchor: X,
1298
+ floatingoffset: J,
1299
+ hidefooter: N,
1300
+ hidelogo: T,
1301
+ name: Q,
1302
+ maxnumber: G,
1303
+ mockerror: V,
1304
+ obfuscated: v,
1305
+ refetchonexpire: S,
1306
+ spamfilter: E,
1307
+ strings: s,
1308
+ test: y,
1309
+ verifyurl: ee,
1310
+ workers: le,
1311
+ workerurl: ae
1312
+ };
1313
+ }
1314
+ function Xe() {
1315
+ return se;
1316
+ }
1317
+ function Pt(r) {
1318
+ return te.find((f) => f.constructor.pluginName === r);
1319
+ }
1320
+ function Je() {
1321
+ return x;
1322
+ }
1323
+ function me(r = m.UNVERIFIED, f = null) {
1324
+ W && (clearTimeout(W), W = null), t(8, re = !1), t(5, de = f), t(6, oe = null), t(7, x = r);
1325
+ }
1326
+ function ze(r) {
1327
+ se = r;
1328
+ }
1329
+ function Ke(r, f = null) {
1330
+ t(7, x = r), t(5, de = f);
1331
+ }
1332
+ async function ne() {
1333
+ return me(m.VERIFYING), await new Promise((r) => setTimeout(r, $ || 0)), vt().then((r) => (Ze(r), k("challenge", r), Ge(r))).then(({ data: r, solution: f }) => {
1334
+ if (k("solution", f), "challenge" in r && f && !("clearText" in f))
1335
+ if ((f == null ? void 0 : f.number) !== void 0) {
1336
+ if (ee)
1337
+ return Dt(Fe(r, f));
1338
+ t(6, oe = Fe(r, f)), k("payload", oe);
1339
+ } else
1340
+ throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned.");
1246
1341
  }).then(() => {
1247
- Wt().then(() => {
1248
- t(7, B = _.VERIFIED), t(8, Q = !0), k("verified"), Re("verified", { payload: ne });
1342
+ en().then(() => {
1343
+ t(7, x = m.VERIFIED), k("verified"), he("verified", { payload: oe });
1249
1344
  });
1250
- }).catch((i) => {
1251
- k(i), t(7, B = _.ERROR), t(8, Q = !1), t(5, Ce = i.message);
1345
+ }).catch((r) => {
1346
+ k(r), t(7, x = m.ERROR), t(5, de = r.message);
1252
1347
  });
1253
1348
  }
1254
- function jt() {
1255
- Q = this.checked, t(8, Q);
1349
+ function Mt() {
1350
+ re = this.checked, t(8, re);
1256
1351
  }
1257
- function Vt(i) {
1258
- Fe[i ? "unshift" : "push"](() => {
1259
- te = i, t(10, te);
1352
+ function Ft(r) {
1353
+ Ae[r ? "unshift" : "push"](() => {
1354
+ ie = r, t(10, ie);
1260
1355
  });
1261
1356
  }
1262
- function Bt(i) {
1263
- Fe[i ? "unshift" : "push"](() => {
1264
- A = i, t(9, A);
1357
+ function Nt(r) {
1358
+ Ae[r ? "unshift" : "push"](() => {
1359
+ C = r, t(9, C);
1265
1360
  });
1266
1361
  }
1267
- return n.$$set = (i) => {
1268
- "analytics" in i && t(18, f = i.analytics), "auto" in i && t(0, l = i.auto), "beaconurl" in i && t(19, c = i.beaconurl), "blockspam" in i && t(33, O = i.blockspam), "challengeurl" in i && t(17, m = i.challengeurl), "challengejson" in i && t(34, H = i.challengejson), "debug" in i && t(20, $ = i.debug), "delay" in i && t(21, q = i.delay), "expire" in i && t(22, J = i.expire), "floating" in i && t(1, b = i.floating), "floatinganchor" in i && t(23, K = i.floatinganchor), "floatingoffset" in i && t(24, X = i.floatingoffset), "hidefooter" in i && t(2, j = i.hidefooter), "hidelogo" in i && t(3, I = i.hidelogo), "name" in i && t(4, R = i.name), "maxnumber" in i && t(25, C = i.maxnumber), "mockerror" in i && t(26, x = i.mockerror), "refetchonexpire" in i && t(27, d = i.refetchonexpire), "spamfilter" in i && t(28, E = i.spamfilter), "strings" in i && t(35, Ee = i.strings), "test" in i && t(29, Z = i.test), "verifyurl" in i && t(30, ee = i.verifyurl), "workers" in i && t(31, ue = i.workers), "workerurl" in i && t(32, ke = i.workerurl);
1362
+ return n.$$set = (r) => {
1363
+ "auto" in r && t(0, u = r.auto), "blockspam" in r && t(16, A = r.blockspam), "challengeurl" in r && t(15, b = r.challengeurl), "challengejson" in r && t(31, Y = r.challengejson), "debug" in r && t(17, U = r.debug), "delay" in r && t(18, $ = r.delay), "expire" in r && t(19, D = r.expire), "floating" in r && t(1, R = r.floating), "floatinganchor" in r && t(20, X = r.floatinganchor), "floatingoffset" in r && t(21, J = r.floatingoffset), "hidefooter" in r && t(2, N = r.hidefooter), "hidelogo" in r && t(3, T = r.hidelogo), "name" in r && t(4, Q = r.name), "maxnumber" in r && t(22, G = r.maxnumber), "mockerror" in r && t(23, V = r.mockerror), "obfuscated" in r && t(24, v = r.obfuscated), "plugins" in r && t(32, P = r.plugins), "refetchonexpire" in r && t(25, S = r.refetchonexpire), "spamfilter" in r && t(26, E = r.spamfilter), "strings" in r && t(33, a = r.strings), "test" in r && t(27, y = r.test), "verifyurl" in r && t(28, ee = r.verifyurl), "workers" in r && t(29, le = r.workers), "workerurl" in r && t(30, ae = r.workerurl), "$$scope" in r && t(45, d = r.$$scope);
1269
1364
  }, n.$$.update = () => {
1270
1365
  n.$$.dirty[0] & /*challengeurl*/
1271
- 131072 && t(14, r = !!(m != null && m.includes(".altcha.org")) && !!(m != null && m.includes("apiKey=ckey_"))), n.$$.dirty[1] & /*challengejson*/
1272
- 8 && (o = H ? bt(H) : void 0), n.$$.dirty[1] & /*strings*/
1273
- 16 && t(39, s = Ee ? bt(Ee) : {}), n.$$.dirty[1] & /*parsedStrings*/
1274
- 256 && t(13, u = {
1275
- ariaLinkLabel: mt,
1366
+ 32768 && t(12, i = !!(b != null && b.includes(".altcha.org")) && !!(b != null && b.includes("apiKey=ckey_"))), n.$$.dirty[1] & /*challengejson*/
1367
+ 1 && (o = Y ? at(Y) : void 0), n.$$.dirty[1] & /*strings*/
1368
+ 4 && t(44, l = a ? at(a) : {}), n.$$.dirty[1] & /*parsedStrings*/
1369
+ 8192 && t(11, s = {
1370
+ ariaLinkLabel: ut,
1276
1371
  error: "Verification failed. Try again later.",
1277
1372
  expired: "Verification expired. Try again.",
1278
- footer: `Protected by <a href="${At}" target="_blank" aria-label="${s.ariaLinkLabel || mt}">ALTCHA</a>`,
1373
+ footer: `Protected by <a href="${Et}" target="_blank" aria-label="${l.ariaLinkLabel || ut}">ALTCHA</a>`,
1279
1374
  label: "I'm not a robot",
1280
1375
  verified: "Verified",
1281
1376
  verifying: "Verifying...",
1282
1377
  waitAlert: "Verifying... please wait.",
1283
- ...s
1378
+ ...l
1284
1379
  }), n.$$.dirty[0] & /*payload, state*/
1285
- 192 && Re("statechange", { payload: ne, state: B }), n.$$.dirty[0] & /*error*/
1286
- 32 && Ft(), n.$$.dirty[0] & /*state*/
1287
- 128 && Rt();
1380
+ 192 && he("statechange", { payload: oe, state: x }), n.$$.dirty[0] & /*error*/
1381
+ 32 && Rt(), n.$$.dirty[0] & /*state*/
1382
+ 128 && St();
1288
1383
  }, [
1289
- l,
1290
- b,
1291
- j,
1292
- I,
1384
+ u,
1293
1385
  R,
1294
- Ce,
1295
- ne,
1296
- B,
1386
+ N,
1387
+ T,
1297
1388
  Q,
1389
+ de,
1390
+ oe,
1391
+ x,
1392
+ re,
1393
+ C,
1394
+ ie,
1395
+ s,
1396
+ i,
1397
+ Lt,
1398
+ $e,
1399
+ b,
1298
1400
  A,
1299
- te,
1300
- V,
1301
- Oe,
1302
- u,
1303
- r,
1304
- Tt,
1305
- ze,
1306
- m,
1307
- f,
1308
- c,
1401
+ U,
1309
1402
  $,
1310
- q,
1311
- J,
1312
- K,
1403
+ D,
1313
1404
  X,
1314
- C,
1315
- x,
1316
- d,
1405
+ J,
1406
+ G,
1407
+ V,
1408
+ v,
1409
+ S,
1317
1410
  E,
1318
- Z,
1411
+ y,
1319
1412
  ee,
1320
- ue,
1321
- ke,
1322
- O,
1323
- H,
1324
- Ee,
1325
- et,
1326
- Le,
1327
- ie,
1328
- s,
1329
- jt,
1330
- Vt,
1331
- Bt
1413
+ le,
1414
+ ae,
1415
+ Y,
1416
+ P,
1417
+ a,
1418
+ ge,
1419
+ Ye,
1420
+ We,
1421
+ Xe,
1422
+ Pt,
1423
+ Je,
1424
+ me,
1425
+ ze,
1426
+ Ke,
1427
+ ne,
1428
+ l,
1429
+ d,
1430
+ h,
1431
+ Mt,
1432
+ Ft,
1433
+ Nt
1332
1434
  ];
1333
1435
  }
1334
- class En extends ln {
1436
+ class In extends an {
1335
1437
  constructor(e) {
1336
- super(), on(
1438
+ super(), cn(
1337
1439
  this,
1338
1440
  e,
1339
- vn,
1340
- yn,
1341
- Ot,
1441
+ An,
1442
+ xn,
1443
+ Ut,
1342
1444
  {
1343
- analytics: 18,
1344
1445
  auto: 0,
1345
- beaconurl: 19,
1346
- blockspam: 33,
1347
- challengeurl: 17,
1348
- challengejson: 34,
1349
- debug: 20,
1350
- delay: 21,
1351
- expire: 22,
1446
+ blockspam: 16,
1447
+ challengeurl: 15,
1448
+ challengejson: 31,
1449
+ debug: 17,
1450
+ delay: 18,
1451
+ expire: 19,
1352
1452
  floating: 1,
1353
- floatinganchor: 23,
1354
- floatingoffset: 24,
1453
+ floatinganchor: 20,
1454
+ floatingoffset: 21,
1355
1455
  hidefooter: 2,
1356
1456
  hidelogo: 3,
1357
1457
  name: 4,
1358
- maxnumber: 25,
1359
- mockerror: 26,
1360
- refetchonexpire: 27,
1361
- spamfilter: 28,
1362
- strings: 35,
1363
- test: 29,
1364
- verifyurl: 30,
1365
- workers: 31,
1366
- workerurl: 32,
1367
- configure: 36,
1368
- reset: 37,
1369
- verify: 38
1458
+ maxnumber: 22,
1459
+ mockerror: 23,
1460
+ obfuscated: 24,
1461
+ plugins: 32,
1462
+ refetchonexpire: 25,
1463
+ spamfilter: 26,
1464
+ strings: 33,
1465
+ test: 27,
1466
+ verifyurl: 28,
1467
+ workers: 29,
1468
+ workerurl: 30,
1469
+ clarify: 34,
1470
+ configure: 35,
1471
+ getConfiguration: 36,
1472
+ getFloatingAnchor: 37,
1473
+ getPlugin: 38,
1474
+ getState: 39,
1475
+ reset: 40,
1476
+ setFloatingAnchor: 41,
1477
+ setState: 42,
1478
+ verify: 43
1370
1479
  },
1371
1480
  null,
1372
1481
  [-1, -1, -1]
1373
1482
  );
1374
1483
  }
1375
- get analytics() {
1376
- return this.$$.ctx[18];
1377
- }
1378
- set analytics(e) {
1379
- this.$$set({ analytics: e }), v();
1380
- }
1381
1484
  get auto() {
1382
1485
  return this.$$.ctx[0];
1383
1486
  }
1384
1487
  set auto(e) {
1385
- this.$$set({ auto: e }), v();
1386
- }
1387
- get beaconurl() {
1388
- return this.$$.ctx[19];
1389
- }
1390
- set beaconurl(e) {
1391
- this.$$set({ beaconurl: e }), v();
1488
+ this.$$set({ auto: e }), p();
1392
1489
  }
1393
1490
  get blockspam() {
1394
- return this.$$.ctx[33];
1491
+ return this.$$.ctx[16];
1395
1492
  }
1396
1493
  set blockspam(e) {
1397
- this.$$set({ blockspam: e }), v();
1494
+ this.$$set({ blockspam: e }), p();
1398
1495
  }
1399
1496
  get challengeurl() {
1400
- return this.$$.ctx[17];
1497
+ return this.$$.ctx[15];
1401
1498
  }
1402
1499
  set challengeurl(e) {
1403
- this.$$set({ challengeurl: e }), v();
1500
+ this.$$set({ challengeurl: e }), p();
1404
1501
  }
1405
1502
  get challengejson() {
1406
- return this.$$.ctx[34];
1503
+ return this.$$.ctx[31];
1407
1504
  }
1408
1505
  set challengejson(e) {
1409
- this.$$set({ challengejson: e }), v();
1506
+ this.$$set({ challengejson: e }), p();
1410
1507
  }
1411
1508
  get debug() {
1412
- return this.$$.ctx[20];
1509
+ return this.$$.ctx[17];
1413
1510
  }
1414
1511
  set debug(e) {
1415
- this.$$set({ debug: e }), v();
1512
+ this.$$set({ debug: e }), p();
1416
1513
  }
1417
1514
  get delay() {
1418
- return this.$$.ctx[21];
1515
+ return this.$$.ctx[18];
1419
1516
  }
1420
1517
  set delay(e) {
1421
- this.$$set({ delay: e }), v();
1518
+ this.$$set({ delay: e }), p();
1422
1519
  }
1423
1520
  get expire() {
1424
- return this.$$.ctx[22];
1521
+ return this.$$.ctx[19];
1425
1522
  }
1426
1523
  set expire(e) {
1427
- this.$$set({ expire: e }), v();
1524
+ this.$$set({ expire: e }), p();
1428
1525
  }
1429
1526
  get floating() {
1430
1527
  return this.$$.ctx[1];
1431
1528
  }
1432
1529
  set floating(e) {
1433
- this.$$set({ floating: e }), v();
1530
+ this.$$set({ floating: e }), p();
1434
1531
  }
1435
1532
  get floatinganchor() {
1436
- return this.$$.ctx[23];
1533
+ return this.$$.ctx[20];
1437
1534
  }
1438
1535
  set floatinganchor(e) {
1439
- this.$$set({ floatinganchor: e }), v();
1536
+ this.$$set({ floatinganchor: e }), p();
1440
1537
  }
1441
1538
  get floatingoffset() {
1442
- return this.$$.ctx[24];
1539
+ return this.$$.ctx[21];
1443
1540
  }
1444
1541
  set floatingoffset(e) {
1445
- this.$$set({ floatingoffset: e }), v();
1542
+ this.$$set({ floatingoffset: e }), p();
1446
1543
  }
1447
1544
  get hidefooter() {
1448
1545
  return this.$$.ctx[2];
1449
1546
  }
1450
1547
  set hidefooter(e) {
1451
- this.$$set({ hidefooter: e }), v();
1548
+ this.$$set({ hidefooter: e }), p();
1452
1549
  }
1453
1550
  get hidelogo() {
1454
1551
  return this.$$.ctx[3];
1455
1552
  }
1456
1553
  set hidelogo(e) {
1457
- this.$$set({ hidelogo: e }), v();
1554
+ this.$$set({ hidelogo: e }), p();
1458
1555
  }
1459
1556
  get name() {
1460
1557
  return this.$$.ctx[4];
1461
1558
  }
1462
1559
  set name(e) {
1463
- this.$$set({ name: e }), v();
1560
+ this.$$set({ name: e }), p();
1464
1561
  }
1465
1562
  get maxnumber() {
1466
- return this.$$.ctx[25];
1563
+ return this.$$.ctx[22];
1467
1564
  }
1468
1565
  set maxnumber(e) {
1469
- this.$$set({ maxnumber: e }), v();
1566
+ this.$$set({ maxnumber: e }), p();
1470
1567
  }
1471
1568
  get mockerror() {
1472
- return this.$$.ctx[26];
1569
+ return this.$$.ctx[23];
1473
1570
  }
1474
1571
  set mockerror(e) {
1475
- this.$$set({ mockerror: e }), v();
1572
+ this.$$set({ mockerror: e }), p();
1573
+ }
1574
+ get obfuscated() {
1575
+ return this.$$.ctx[24];
1576
+ }
1577
+ set obfuscated(e) {
1578
+ this.$$set({ obfuscated: e }), p();
1579
+ }
1580
+ get plugins() {
1581
+ return this.$$.ctx[32];
1582
+ }
1583
+ set plugins(e) {
1584
+ this.$$set({ plugins: e }), p();
1476
1585
  }
1477
1586
  get refetchonexpire() {
1478
- return this.$$.ctx[27];
1587
+ return this.$$.ctx[25];
1479
1588
  }
1480
1589
  set refetchonexpire(e) {
1481
- this.$$set({ refetchonexpire: e }), v();
1590
+ this.$$set({ refetchonexpire: e }), p();
1482
1591
  }
1483
1592
  get spamfilter() {
1484
- return this.$$.ctx[28];
1593
+ return this.$$.ctx[26];
1485
1594
  }
1486
1595
  set spamfilter(e) {
1487
- this.$$set({ spamfilter: e }), v();
1596
+ this.$$set({ spamfilter: e }), p();
1488
1597
  }
1489
1598
  get strings() {
1490
- return this.$$.ctx[35];
1599
+ return this.$$.ctx[33];
1491
1600
  }
1492
1601
  set strings(e) {
1493
- this.$$set({ strings: e }), v();
1602
+ this.$$set({ strings: e }), p();
1494
1603
  }
1495
1604
  get test() {
1496
- return this.$$.ctx[29];
1605
+ return this.$$.ctx[27];
1497
1606
  }
1498
1607
  set test(e) {
1499
- this.$$set({ test: e }), v();
1608
+ this.$$set({ test: e }), p();
1500
1609
  }
1501
1610
  get verifyurl() {
1502
- return this.$$.ctx[30];
1611
+ return this.$$.ctx[28];
1503
1612
  }
1504
1613
  set verifyurl(e) {
1505
- this.$$set({ verifyurl: e }), v();
1614
+ this.$$set({ verifyurl: e }), p();
1506
1615
  }
1507
1616
  get workers() {
1508
- return this.$$.ctx[31];
1617
+ return this.$$.ctx[29];
1509
1618
  }
1510
1619
  set workers(e) {
1511
- this.$$set({ workers: e }), v();
1620
+ this.$$set({ workers: e }), p();
1512
1621
  }
1513
1622
  get workerurl() {
1514
- return this.$$.ctx[32];
1623
+ return this.$$.ctx[30];
1515
1624
  }
1516
1625
  set workerurl(e) {
1517
- this.$$set({ workerurl: e }), v();
1626
+ this.$$set({ workerurl: e }), p();
1627
+ }
1628
+ get clarify() {
1629
+ return this.$$.ctx[34];
1518
1630
  }
1519
1631
  get configure() {
1632
+ return this.$$.ctx[35];
1633
+ }
1634
+ get getConfiguration() {
1520
1635
  return this.$$.ctx[36];
1521
1636
  }
1522
- get reset() {
1637
+ get getFloatingAnchor() {
1523
1638
  return this.$$.ctx[37];
1524
1639
  }
1525
- get verify() {
1640
+ get getPlugin() {
1526
1641
  return this.$$.ctx[38];
1527
1642
  }
1643
+ get getState() {
1644
+ return this.$$.ctx[39];
1645
+ }
1646
+ get reset() {
1647
+ return this.$$.ctx[40];
1648
+ }
1649
+ get setFloatingAnchor() {
1650
+ return this.$$.ctx[41];
1651
+ }
1652
+ get setState() {
1653
+ return this.$$.ctx[42];
1654
+ }
1655
+ get verify() {
1656
+ return this.$$.ctx[43];
1657
+ }
1528
1658
  }
1529
- customElements.define("altcha-widget", sn(En, { analytics: { type: "Boolean" }, auto: {}, beaconurl: {}, 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));
1530
- globalThis.createAltchaWorker = (n) => new Worker(new URL(n || "./worker.js", import.meta.url));
1659
+ customElements.define("altcha-widget", un(
1660
+ In,
1661
+ { 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: {} },
1662
+ ["default"],
1663
+ [
1664
+ "clarify",
1665
+ "configure",
1666
+ "getConfiguration",
1667
+ "getFloatingAnchor",
1668
+ "getPlugin",
1669
+ "getState",
1670
+ "reset",
1671
+ "setFloatingAnchor",
1672
+ "setState",
1673
+ "verify"
1674
+ ],
1675
+ !1
1676
+ ));
1677
+ globalThis.altchaCreateWorker = (n) => new Worker(new URL(n || "./worker.js", import.meta.url));
1678
+ globalThis.altchaPlugins = globalThis.altchaPlugins || [];
1531
1679
  export {
1532
- En as Altcha
1680
+ In as Altcha
1533
1681
  };