altcha 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/altcha.js CHANGED
@@ -72,7 +72,7 @@ function Rt(r, e) {
72
72
  function $(r, e, t) {
73
73
  r.insertBefore(e, t || null);
74
74
  }
75
- function T(r) {
75
+ function Z(r) {
76
76
  r.parentNode && r.parentNode.removeChild(r);
77
77
  }
78
78
  function A(r) {
@@ -243,7 +243,7 @@ function Wt(r, e, t, i, o, l, s = null, u = [-1]) {
243
243
  }) : [], d.update(), U = !0, ae(d.before_update), d.fragment = i ? i(d.ctx) : !1, e.target) {
244
244
  if (e.hydrate) {
245
245
  const S = It(e.target);
246
- d.fragment && d.fragment.l(S), S.forEach(T);
246
+ d.fragment && d.fragment.l(S), S.forEach(Z);
247
247
  } else
248
248
  d.fragment && d.fragment.c();
249
249
  e.intro && Dt(r.$$.fragment), Ut(r, e.target, e.anchor), v();
@@ -304,7 +304,7 @@ typeof HTMLElement == "function" && (ot = class extends HTMLElement {
304
304
  $(d, s, U);
305
305
  },
306
306
  d: function(d) {
307
- d && T(s);
307
+ d && Z(s);
308
308
  }
309
309
  };
310
310
  };
@@ -534,7 +534,7 @@ function Oe(r) {
534
534
  $(o, e, l), _(e, t), _(e, i);
535
535
  },
536
536
  d(o) {
537
- o && T(e);
537
+ o && Z(e);
538
538
  }
539
539
  };
540
540
  }
@@ -559,7 +559,7 @@ function qt(r) {
559
559
  o[4] + "_checkbox") && c(e, "for", i);
560
560
  },
561
561
  d(o) {
562
- o && T(e);
562
+ o && Z(e);
563
563
  }
564
564
  };
565
565
  }
@@ -581,7 +581,7 @@ function Qt(r) {
581
581
  i[11].verifying + "") && (e.innerHTML = t);
582
582
  },
583
583
  d(i) {
584
- i && T(e);
584
+ i && Z(e);
585
585
  }
586
586
  };
587
587
  }
@@ -617,7 +617,7 @@ function er(r) {
617
617
  l[5]);
618
618
  },
619
619
  d(l) {
620
- l && (T(e), T(i), T(o));
620
+ l && (Z(e), Z(i), Z(o));
621
621
  }
622
622
  };
623
623
  }
@@ -637,7 +637,7 @@ function Ye(r) {
637
637
  f[11].ariaLinkLabel) && c(t, "aria-label", u);
638
638
  },
639
639
  d(f) {
640
- f && T(e);
640
+ f && Z(e);
641
641
  }
642
642
  };
643
643
  }
@@ -661,7 +661,7 @@ function Pe(r) {
661
661
  s === (s = l(f)) && u ? u.p(f, d) : (u.d(1), u = s(f), u && (u.c(), u.m(e, null)));
662
662
  },
663
663
  d(f) {
664
- f && T(e), u.d();
664
+ f && Z(e), u.d();
665
665
  }
666
666
  };
667
667
  }
@@ -694,7 +694,7 @@ function tr(r) {
694
694
  );
695
695
  },
696
696
  d(i) {
697
- i && T(e);
697
+ i && Z(e);
698
698
  }
699
699
  };
700
700
  }
@@ -727,7 +727,7 @@ function rr(r) {
727
727
  );
728
728
  },
729
729
  d(i) {
730
- i && T(e);
730
+ i && Z(e);
731
731
  }
732
732
  };
733
733
  }
@@ -749,7 +749,7 @@ function Ke(r) {
749
749
  o[11].footer + "") && (t.innerHTML = i);
750
750
  },
751
751
  d(o) {
752
- o && T(e);
752
+ o && Z(e);
753
753
  }
754
754
  };
755
755
  }
@@ -764,7 +764,7 @@ function Je(r) {
764
764
  },
765
765
  p: ne,
766
766
  d(t) {
767
- t && T(e), r[36](null);
767
+ t && Z(e), r[36](null);
768
768
  }
769
769
  };
770
770
  }
@@ -878,7 +878,7 @@ function nr(r) {
878
878
  i: ne,
879
879
  o: ne,
880
880
  d(h) {
881
- h && T(e), N && N.d(), j.d(), L && L.d(), R && R.d(), w && w.d(), z && z.d(), r[37](null), F = !1, ae(P);
881
+ h && Z(e), N && N.d(), j.d(), L && L.d(), R && R.d(), w && w.d(), z && z.d(), r[37](null), F = !1, ae(P);
882
882
  }
883
883
  };
884
884
  }
@@ -896,22 +896,22 @@ function or(r, e, t) {
896
896
  var Fe, Ge;
897
897
  let i, o, l, { auto: s = void 0 } = e, { blockspam: u = void 0 } = e, { challengeurl: f = void 0 } = e, { challengejson: d = void 0 } = e, { debug: U = !1 } = e, { delay: S = 0 } = e, { expire: D = void 0 } = e, { floating: k = void 0 } = e, { floatinganchor: F = void 0 } = e, { floatingoffset: P = void 0 } = e, { hidefooter: N = !1 } = e, { hidelogo: Q = !1 } = e, { name: H = "altcha" } = e, { maxnumber: j = 1e6 } = e, { mockerror: L = !1 } = e, { refetchonexpire: R = !0 } = e, { spamfilter: w = !1 } = e, { strings: z = void 0 } = e, { test: h = !1 } = e, { verifyurl: y = void 0 } = e, { workers: ie = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: ve = void 0 } = e;
898
898
  const we = Tt(), Re = ["SHA-256", "SHA-384", "SHA-512"], ze = (Ge = (Fe = document.documentElement.lang) == null ? void 0 : Fe.split("-")) == null ? void 0 : Ge[0];
899
- let O = !1, x, K = null, fe = null, m = null, ye = null, J = null, Z = b.UNVERIFIED, W = null;
899
+ let O = !1, x, K = null, fe = null, m = null, ye = null, J = null, M = b.UNVERIFIED, W = null;
900
900
  jt(() => {
901
901
  m && (m.removeEventListener("submit", Ae), m.removeEventListener("reset", Ne), m.removeEventListener("focusin", Ie), m = null), W && (clearTimeout(W), W = null), document.removeEventListener("click", Ze), document.removeEventListener("scroll", Me), window.removeEventListener("resize", $e);
902
902
  }), St(() => {
903
- E("mounted", "0.6.2"), E("workers", ie), h && E("using test mode"), D && ue(D), s !== void 0 && E("auto", s), k !== void 0 && De(k), m = x.closest("form"), m && (m.addEventListener("submit", Ae, { capture: !0 }), m.addEventListener("reset", Ne), s === "onfocus" && m.addEventListener("focusin", Ie)), s === "onload" && q();
903
+ E("mounted", "0.6.3"), E("workers", ie), h && E("using test mode"), D && ue(D), s !== void 0 && E("auto", s), k !== void 0 && De(k), m = x.closest("form"), m && (m.addEventListener("submit", Ae, { capture: !0 }), m.addEventListener("reset", Ne), s === "onfocus" && m.addEventListener("focusin", Ie)), s === "onload" && q();
904
904
  });
905
905
  function E(...n) {
906
906
  (U || n.some((a) => a instanceof Error)) && console[n[0] instanceof Error ? "error" : "log"]("ALTCHA", ...n);
907
907
  }
908
908
  function Ie(n) {
909
- Z === b.UNVERIFIED && q();
909
+ M === b.UNVERIFIED && q();
910
910
  }
911
911
  function Ae(n) {
912
- m && s === "onsubmit" && (Z === b.UNVERIFIED ? (n.preventDefault(), n.stopPropagation(), q().then(() => {
912
+ m && s === "onsubmit" && (M === b.UNVERIFIED ? (n.preventDefault(), n.stopPropagation(), q().then(() => {
913
913
  m == null || m.requestSubmit();
914
- })) : Z !== b.VERIFIED && (n.preventDefault(), n.stopPropagation(), Z === b.VERIFYING && Ve()));
914
+ })) : M !== b.VERIFIED && (n.preventDefault(), n.stopPropagation(), M === b.VERIFYING && Ve()));
915
915
  }
916
916
  function Ne() {
917
917
  de();
@@ -958,7 +958,7 @@ function or(r, e, t) {
958
958
  });
959
959
  if (a.status !== 200)
960
960
  throw new Error(`Server responded with ${a.status}.`);
961
- const g = a.headers.get("Expires"), I = a.headers.get("X-Altcha-Config"), M = await a.json(), V = new URLSearchParams((n = M.salt.split("?")) == null ? void 0 : n[1]), X = V.get("expires") || V.get("expire");
961
+ const g = a.headers.get("Expires"), I = a.headers.get("X-Altcha-Config"), V = await a.json(), T = new URLSearchParams((n = V.salt.split("?")) == null ? void 0 : n[1]), X = T.get("expires") || T.get("expire");
962
962
  if (X) {
963
963
  const p = new Date(+X * 1e3), C = isNaN(p.getTime()) ? 0 : p.getTime() - Date.now();
964
964
  C > 0 && ue(C);
@@ -977,11 +977,11 @@ function or(r, e, t) {
977
977
  C > 0 && ue(C);
978
978
  }
979
979
  }
980
- return M;
980
+ return V;
981
981
  }
982
982
  }
983
983
  function Te() {
984
- f && R && Z === b.VERIFIED ? q() : de(b.EXPIRED, l.expired);
984
+ f && R && M === b.VERIFIED ? q() : de(b.EXPIRED, l.expired);
985
985
  }
986
986
  async function at(n) {
987
987
  let a = null;
@@ -999,20 +999,20 @@ function or(r, e, t) {
999
999
  solution: await Kt(n.challenge, n.salt, n.algorithm, n.maxnumber || j).promise
1000
1000
  };
1001
1001
  }
1002
- async function ft(n, a, g, I = typeof h == "number" ? h : j, M = Math.ceil(ie)) {
1003
- const V = [];
1004
- if (M < 1)
1002
+ async function ft(n, a, g, I = typeof h == "number" ? h : j, V = Math.ceil(ie)) {
1003
+ const T = [];
1004
+ if (V < 1)
1005
1005
  throw new Error("Wrong number of workers configured.");
1006
- if (M > 16)
1006
+ if (V > 16)
1007
1007
  throw new Error("Too many workers. Max. 16 allowed workers.");
1008
- for (let C = 0; C < M; C++)
1009
- V.push(createAltchaWorker(ve));
1010
- const X = Math.ceil(I / M), p = await Promise.all(V.map((C, _e) => {
1008
+ for (let C = 0; C < V; C++)
1009
+ T.push(createAltchaWorker(ve));
1010
+ const X = Math.ceil(I / V), p = await Promise.all(T.map((C, _e) => {
1011
1011
  const oe = _e * X;
1012
1012
  return new Promise((he) => {
1013
1013
  C.addEventListener("message", (ge) => {
1014
1014
  if (ge.data)
1015
- for (const le of V)
1015
+ for (const le of T)
1016
1016
  le !== C && le.postMessage({ type: "abort" });
1017
1017
  he(ge.data);
1018
1018
  }), C.postMessage({
@@ -1027,25 +1027,25 @@ function or(r, e, t) {
1027
1027
  });
1028
1028
  });
1029
1029
  }));
1030
- for (const C of V)
1030
+ for (const C of T)
1031
1031
  C.terminate();
1032
1032
  return p.find((C) => !!C) || null;
1033
1033
  }
1034
1034
  function ut() {
1035
- [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(Z) ? w && (m == null ? void 0 : m.reportValidity()) === !1 ? t(7, O = !1) : q() : t(7, O = !0);
1035
+ [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(M) ? w && (m == null ? void 0 : m.reportValidity()) === !1 ? t(7, O = !1) : q() : t(7, O = !0);
1036
1036
  }
1037
1037
  function Ze(n) {
1038
1038
  const a = n.target;
1039
- k && a && !x.contains(a) && Z === b.VERIFIED && t(8, x.style.display = "none", x);
1039
+ k && a && !x.contains(a) && M === b.VERIFIED && t(8, x.style.display = "none", x);
1040
1040
  }
1041
1041
  function Me() {
1042
1042
  k && pe();
1043
1043
  }
1044
1044
  function Ve() {
1045
- Z === b.VERIFYING && l.waitAlert && alert(l.waitAlert);
1045
+ M === b.VERIFYING && l.waitAlert && alert(l.waitAlert);
1046
1046
  }
1047
1047
  function dt(n) {
1048
- k && Z !== b.UNVERIFIED && requestAnimationFrame(() => {
1048
+ k && M !== b.UNVERIFIED && requestAnimationFrame(() => {
1049
1049
  pe();
1050
1050
  });
1051
1051
  }
@@ -1068,8 +1068,9 @@ function or(r, e, t) {
1068
1068
  ...(m == null ? void 0 : m.querySelectorAll(n != null && n.length ? n.map((g) => `input[name="${g}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || []
1069
1069
  ].reduce(
1070
1070
  (g, I) => {
1071
- const M = I.name, V = I.value.trim();
1072
- return M && V && (g[M] = V), g;
1071
+ const V = I.name, T = I.value;
1072
+ return V && T && (g[V] = /\n/.test(T) ? T.replace(new RegExp("(?<!\\r)\\n", "g"), `\r
1073
+ `) : T), g;
1073
1074
  },
1074
1075
  {}
1075
1076
  );
@@ -1080,7 +1081,7 @@ function or(r, e, t) {
1080
1081
  E("requesting server verification from", y);
1081
1082
  const a = { payload: n };
1082
1083
  if (w) {
1083
- const { blockedCountries: M, classifier: V, disableRules: X, email: p, expectedLanguages: C, expectedCountries: _e, fields: oe, ipAddress: he, text: ge, timeZone: le } = typeof w == "object" ? w : {
1084
+ const { blockedCountries: V, classifier: T, disableRules: X, email: p, expectedLanguages: C, expectedCountries: _e, fields: oe, ipAddress: he, text: ge, timeZone: le } = typeof w == "object" ? w : {
1084
1085
  blockedCountries: void 0,
1085
1086
  classifier: void 0,
1086
1087
  disableRules: void 0,
@@ -1092,7 +1093,7 @@ function or(r, e, t) {
1092
1093
  text: void 0,
1093
1094
  timeZone: void 0
1094
1095
  };
1095
- a.blockedCountries = M, a.classifier = V, a.disableRules = X, a.email = p === !1 ? void 0 : ht(p), a.expectedCountries = _e, a.expectedLanguages = C || (ze ? [ze] : void 0), a.fields = oe === !1 ? void 0 : gt(oe), a.ipAddress = he === !1 ? void 0 : he || "auto", a.text = ge, a.timeZone = le === !1 ? void 0 : le || ir();
1096
+ a.blockedCountries = V, a.classifier = T, a.disableRules = X, a.email = p === !1 ? void 0 : ht(p), a.expectedCountries = _e, a.expectedLanguages = C || (ze ? [ze] : void 0), a.fields = oe === !1 ? void 0 : gt(oe), a.ipAddress = he === !1 ? void 0 : he || "auto", a.text = ge, a.timeZone = le === !1 ? void 0 : le || ir();
1096
1097
  }
1097
1098
  const g = await fetch(y, {
1098
1099
  body: JSON.stringify(a),
@@ -1108,7 +1109,7 @@ function or(r, e, t) {
1108
1109
  function pe(n = 20) {
1109
1110
  if (x)
1110
1111
  if (fe || (fe = (F ? document.querySelector(F) : m == null ? void 0 : m.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || m), fe) {
1111
- const a = parseInt(P, 10) || 12, g = fe.getBoundingClientRect(), I = x.getBoundingClientRect(), M = document.documentElement.clientHeight, V = document.documentElement.clientWidth, X = k === "auto" ? g.bottom + I.height + a + n > M : k === "top", p = Math.max(n, Math.min(V - n - I.width, g.left + g.width / 2 - I.width / 2));
1112
+ const a = parseInt(P, 10) || 12, g = fe.getBoundingClientRect(), I = x.getBoundingClientRect(), V = document.documentElement.clientHeight, T = document.documentElement.clientWidth, X = k === "auto" ? g.bottom + I.height + a + n > V : k === "top", p = Math.max(n, Math.min(T - n - I.width, g.left + g.width / 2 - I.width / 2));
1112
1113
  if (X ? t(8, x.style.top = `${g.top - (I.height + a)}px`, x) : t(8, x.style.top = `${g.bottom + a}px`, x), t(8, x.style.left = `${p}px`, x), x.setAttribute("data-floating", X ? "top" : "bottom"), K) {
1113
1114
  const C = K.getBoundingClientRect();
1114
1115
  t(9, K.style.left = g.left - p + g.width / 2 - C.width / 2 + "px", K);
@@ -1120,7 +1121,7 @@ function or(r, e, t) {
1120
1121
  n.auto !== void 0 && (t(0, s = n.auto), s === "onload" && q()), n.floatinganchor !== void 0 && t(18, F = n.floatinganchor), n.delay !== void 0 && t(16, S = n.delay), n.floatingoffset !== void 0 && t(19, P = n.floatingoffset), n.floating !== void 0 && De(n.floating), n.expire !== void 0 && (ue(n.expire), t(17, D = n.expire)), n.challenge && (je(n.challenge), i = n.challenge), n.challengeurl !== void 0 && t(14, f = n.challengeurl), n.debug !== void 0 && t(15, U = !!n.debug), n.hidefooter !== void 0 && t(2, N = !!n.hidefooter), n.hidelogo !== void 0 && t(3, Q = !!n.hidelogo), n.maxnumber !== void 0 && t(20, j = +n.maxnumber), n.mockerror !== void 0 && t(21, L = !!n.mockerror), n.name !== void 0 && t(4, H = n.name), n.refetchonexpire !== void 0 && t(22, R = !!n.refetchonexpire), n.spamfilter !== void 0 && t(23, w = typeof n.spamfilter == "object" ? n.spamfilter : !!n.spamfilter), n.strings && t(34, o = n.strings), n.test !== void 0 && t(24, h = typeof n.test == "number" ? n.test : !!n.test), n.verifyurl !== void 0 && t(25, y = n.verifyurl), n.workers !== void 0 && t(26, ie = +n.workers);
1121
1122
  }
1122
1123
  function de(n = b.UNVERIFIED, a = null) {
1123
- W && (clearTimeout(W), W = null), t(7, O = !1), t(10, ye = a), t(5, J = null), t(6, Z = n);
1124
+ W && (clearTimeout(W), W = null), t(7, O = !1), t(10, ye = a), t(5, J = null), t(6, M = n);
1124
1125
  }
1125
1126
  async function q() {
1126
1127
  return de(b.VERIFYING), await new Promise((n) => setTimeout(n, S || 0)), ct().then((n) => (je(n), E("challenge", n), at(n))).then(({ data: n, solution: a }) => {
@@ -1132,10 +1133,10 @@ function or(r, e, t) {
1132
1133
  throw E("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned.");
1133
1134
  }).then(() => {
1134
1135
  Zt().then(() => {
1135
- t(6, Z = b.VERIFIED), t(7, O = !0), E("verified"), we("verified", { payload: J });
1136
+ t(6, M = b.VERIFIED), t(7, O = !0), E("verified"), we("verified", { payload: J });
1136
1137
  });
1137
1138
  }).catch((n) => {
1138
- E(n), t(6, Z = b.ERROR), t(7, O = !1), t(10, ye = n.message);
1139
+ E(n), t(6, M = b.ERROR), t(7, O = !1), t(10, ye = n.message);
1139
1140
  });
1140
1141
  }
1141
1142
  function bt() {
@@ -1168,7 +1169,7 @@ function or(r, e, t) {
1168
1169
  waitAlert: "Verifying... please wait.",
1169
1170
  ...o
1170
1171
  }), r.$$.dirty[0] & /*payload, state*/
1171
- 96 && we("statechange", { payload: J, state: Z }), r.$$.dirty[0] & /*state*/
1172
+ 96 && we("statechange", { payload: J, state: M }), r.$$.dirty[0] & /*state*/
1172
1173
  64 && dt();
1173
1174
  }, [
1174
1175
  s,
@@ -1177,7 +1178,7 @@ function or(r, e, t) {
1177
1178
  Q,
1178
1179
  H,
1179
1180
  J,
1180
- Z,
1181
+ M,
1181
1182
  O,
1182
1183
  x,
1183
1184
  K,
@@ -1 +1,2 @@
1
- (function(F,Z){typeof exports=="object"&&typeof module<"u"?Z(exports):typeof define=="function"&&define.amd?define(["exports"],Z):(F=typeof globalThis<"u"?globalThis:F||self,Z(F.altcha={}))})(this,function(F){"use strict";var lr=Object.defineProperty;var sr=(F,Z,te)=>Z in F?lr(F,Z,{enumerable:!0,configurable:!0,writable:!0,value:te}):F[Z]=te;var X=(F,Z,te)=>sr(F,typeof Z!="symbol"?Z+"":Z,te);const Z="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",te=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),Ae=typeof window<"u"&&window.Blob&&new Blob([te(Z)],{type:"text/javascript;charset=utf-8"});function ut(r){let e;try{if(e=Ae&&(window.URL||window.webkitURL).createObjectURL(Ae),!e)throw"";const t=new Worker(e,{name:r==null?void 0:r.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Z,{name:r==null?void 0:r.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}function re(){}function Ne(r){return r()}function Se(){return Object.create(null)}function se(r){r.forEach(Ne)}function Te(r){return typeof r=="function"}function dt(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function ht(r){return Object.keys(r).length===0}function y(r,e){r.appendChild(e)}function gt(r,e,t){const i=mt(r);if(!i.getElementById(e)){const o=L("style");o.id=e,o.textContent=t,bt(i,o)}}function mt(r){if(!r)return document;const e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function bt(r,e){return y(r.head||r,e),e.sheet}function M(r,e,t){r.insertBefore(e,t||null)}function j(r){r.parentNode&&r.parentNode.removeChild(r)}function L(r){return document.createElement(r)}function O(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function vt(r){return document.createTextNode(r)}function P(){return vt(" ")}function pe(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function c(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function wt(r){return Array.from(r.childNodes)}function je(r,e,t){r.classList.toggle(e,!!t)}function yt(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function pt(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ce;function ae(r){ce=r}function _e(){if(!ce)throw new Error("Function called outside component initialization");return ce}function _t(r){_e().$$.on_mount.push(r)}function kt(r){_e().$$.on_destroy.push(r)}function xt(){const r=_e();return(e,t,{cancelable:i=!1}={})=>{const o=r.$$.callbacks[e];if(o){const l=yt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(r,l)}),!l.defaultPrevented}return!0}}const ne=[],he=[];let ie=[];const Ze=[],Me=Promise.resolve();let ke=!1;function Ve(){ke||(ke=!0,Me.then(v))}function Et(){return Ve(),Me}function xe(r){ie.push(r)}const Ee=new Set;let oe=0;function v(){if(oe!==0)return;const r=ce;do{try{for(;oe<ne.length;){const e=ne[oe];oe++,ae(e),Ct(e.$$)}}catch(e){throw ne.length=0,oe=0,e}for(ae(null),ne.length=0,oe=0;he.length;)he.pop()();for(let e=0;e<ie.length;e+=1){const t=ie[e];Ee.has(t)||(Ee.add(t),t())}ie.length=0}while(ne.length);for(;Ze.length;)Ze.pop()();ke=!1,Ee.clear(),ae(r)}function Ct(r){if(r.fragment!==null){r.update(),se(r.before_update);const e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(xe)}}function Lt(r){const e=[],t=[];ie.forEach(i=>r.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),ie=e}const Rt=new Set;function zt(r,e){r&&r.i&&(Rt.delete(r),r.i(e))}function It(r,e,t){const{fragment:i,after_update:o}=r.$$;i&&i.m(e,t),xe(()=>{const l=r.$$.on_mount.map(Ne).filter(Te);r.$$.on_destroy?r.$$.on_destroy.push(...l):se(l),r.$$.on_mount=[]}),o.forEach(xe)}function At(r,e){const t=r.$$;t.fragment!==null&&(Lt(t.after_update),se(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Nt(r,e){r.$$.dirty[0]===-1&&(ne.push(r),Ve(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function St(r,e,t,i,o,l,s=null,u=[-1]){const f=ce;ae(r);const d=r.$$={fragment:null,ctx:[],props:l,update:re,not_equal:o,bound:Se(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(f?f.$$.context:[])),callbacks:Se(),dirty:u,skip_bound:!1,root:e.target||f.$$.root};s&&s(d.root);let G=!1;if(d.ctx=t?t(r,e.props||{},(S,U,...k)=>{const W=k.length?k[0]:U;return d.ctx&&o(d.ctx[S],d.ctx[S]=W)&&(!d.skip_bound&&d.bound[S]&&d.bound[S](W),G&&Nt(r,S)),U}):[],d.update(),G=!0,se(d.before_update),d.fragment=i?i(d.ctx):!1,e.target){if(e.hydrate){const S=wt(e.target);d.fragment&&d.fragment.l(S),S.forEach(j)}else d.fragment&&d.fragment.c();e.intro&&zt(r.$$.fragment),It(r,e.target,e.anchor),v()}ae(f)}let $e;typeof HTMLElement=="function"&&($e=class extends HTMLElement{constructor(e,t,i){super();X(this,"$$ctor");X(this,"$$s");X(this,"$$c");X(this,"$$cn",!1);X(this,"$$d",{});X(this,"$$r",!1);X(this,"$$p_d",{});X(this,"$$l",{});X(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=L("slot"),l!=="default"&&c(s,"name",l)},m:function(d,G){M(d,s,G)},d:function(d){d&&j(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=pt(this);for(const l of this.$$s)l in i&&(t[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=ge(s,l.value,this.$$p_d,"toProp"))}for(const l in this.$$p_d)!(l in this.$$d)&&this[l]!==void 0&&(this.$$d[l]=this[l],delete this[l]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const l in this.$$p_d)if(this.$$d[l]=this.$$c.$$.ctx[this.$$c.$$.props[l]],this.$$p_d[l].reflect){const s=ge(l,this.$$d[l],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const s of this.$$l[l]){const u=this.$$c.$on(l,s);this.$$l_u.set(s,u)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=ge(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function ge(r,e,t,i){var l;const o=(l=t[r])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Tt(r,e,t,i,o,l){let s=class extends $e{constructor(){super(r,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(u=>(e[u].attribute||u).toLowerCase())}};return Object.keys(e).forEach(u=>{Object.defineProperty(s.prototype,u,{get(){return this.$$c&&u in this.$$c?this.$$c[u]:this.$$d[u]},set(f){var d;f=ge(u,f,e),this.$$d[u]=f,(d=this.$$c)==null||d.$set({[u]:f})}})}),i.forEach(u=>{Object.defineProperty(s.prototype,u,{get(){var f;return(f=this.$$c)==null?void 0:f[u]}})}),l&&(s=l(s)),r.element=s,s}class jt{constructor(){X(this,"$$");X(this,"$$set")}$destroy(){At(this,1),this.$destroy=re}$on(e,t){if(!Te(t))return re;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!ht(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Zt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Zt);const Mt=new TextEncoder;function Vt(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function $t(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const o=await De(i,r,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function De(r,e,t){return Vt(await crypto.subtle.digest(t.toUpperCase(),Mt.encode(r+e)))}function Dt(r,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let f=o;f<=i;f+=1){if(l.signal.aborted)return null;if(await De(e,f,t)===r)return{number:f,took:Date.now()-s}}return null})(),controller:l}}var m=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(m||{});function Ut(r){gt(r,"svelte-ddsc3z",'.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}')}function Ue(r){let e,t,i;return{c(){e=O("svg"),t=O("path"),i=O("path"),c(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(t,"fill","currentColor"),c(t,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-ddsc3z"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){M(o,e,l),y(e,t),y(e,i)},d(o){o&&j(e)}}}function Ft(r){let e,t=r[11].label+"",i;return{c(){e=L("label"),c(e,"for",i=r[4]+"_checkbox"),c(e,"class","svelte-ddsc3z")},m(o,l){M(o,e,l),e.innerHTML=t},p(o,l){l[0]&2048&&t!==(t=o[11].label+"")&&(e.innerHTML=t),l[0]&16&&i!==(i=o[4]+"_checkbox")&&c(e,"for",i)},d(o){o&&j(e)}}}function Gt(r){let e,t=r[11].verifying+"";return{c(){e=L("span")},m(i,o){M(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].verifying+"")&&(e.innerHTML=t)},d(i){i&&j(e)}}}function Wt(r){let e,t=r[11].verified+"",i,o;return{c(){e=L("span"),i=P(),o=L("input"),c(o,"type","hidden"),c(o,"name",r[4]),o.value=r[5]},m(l,s){M(l,e,s),e.innerHTML=t,M(l,i,s),M(l,o,s)},p(l,s){s[0]&2048&&t!==(t=l[11].verified+"")&&(e.innerHTML=t),s[0]&16&&c(o,"name",l[4]),s[0]&32&&(o.value=l[5])},d(l){l&&(j(e),j(i),j(o))}}}function Fe(r){let e,t,i,o,l,s,u;return{c(){e=L("div"),t=L("a"),i=O("svg"),o=O("path"),l=O("path"),s=O("path"),c(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(o,"fill","currentColor"),c(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(l,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(t,"href",He),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-ddsc3z"),c(t,"aria-label",u=r[11].ariaLinkLabel)},m(f,d){M(f,e,d),y(e,t),y(t,i),y(i,o),y(i,l),y(i,s)},p(f,d){d[0]&2048&&u!==(u=f[11].ariaLinkLabel)&&c(t,"aria-label",u)},d(f){f&&j(e)}}}function Ge(r){let e,t,i,o;function l(f,d){return f[6]===m.EXPIRED?Bt:Xt}let s=l(r),u=s(r);return{c(){e=L("div"),t=O("svg"),i=O("path"),o=P(),u.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(t,"width","14"),c(t,"height","14"),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"fill","none"),c(t,"viewBox","0 0 24 24"),c(t,"stroke-width","1.5"),c(t,"stroke","currentColor"),c(e,"class","altcha-error svelte-ddsc3z")},m(f,d){M(f,e,d),y(e,t),y(t,i),y(e,o),u.m(e,null)},p(f,d){s===(s=l(f))&&u?u.p(f,d):(u.d(1),u=s(f),u&&(u.c(),u.m(e,null)))},d(f){f&&j(e),u.d()}}}function Xt(r){let e,t=r[11].error+"";return{c(){e=L("div"),c(e,"title",r[10])},m(i,o){M(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),o[0]&1024&&c(e,"title",i[10])},d(i){i&&j(e)}}}function Bt(r){let e,t=r[11].expired+"";return{c(){e=L("div"),c(e,"title",r[10])},m(i,o){M(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),o[0]&1024&&c(e,"title",i[10])},d(i){i&&j(e)}}}function We(r){let e,t,i=r[11].footer+"";return{c(){e=L("div"),t=L("div"),c(t,"class","svelte-ddsc3z"),c(e,"class","altcha-footer svelte-ddsc3z")},m(o,l){M(o,e,l),y(e,t),t.innerHTML=i},p(o,l){l[0]&2048&&i!==(i=o[11].footer+"")&&(t.innerHTML=i)},d(o){o&&j(e)}}}function Xe(r){let e;return{c(){e=L("div"),c(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){M(t,e,i),r[36](e)},p:re,d(t){t&&j(e),r[36](null)}}}function Ht(r){let e,t,i,o,l,s,u,f,d,G,S,U,k,W,J,N=r[6]===m.VERIFYING&&Ue();function le(h,p){return h[6]===m.VERIFIED?Wt:h[6]===m.VERIFYING?Gt:Ft}let Y=le(r),T=Y(r),R=r[3]!==!0&&Fe(r),z=(r[10]||r[6]===m.EXPIRED)&&Ge(r),w=r[11].footer&&r[2]!==!0&&We(r),I=r[1]&&Xe(r);return{c(){e=L("div"),t=L("div"),N&&N.c(),i=P(),o=L("div"),l=L("input"),f=P(),d=L("div"),T.c(),G=P(),R&&R.c(),S=P(),z&&z.c(),U=P(),w&&w.c(),k=P(),I&&I.c(),c(l,"type","checkbox"),c(l,"id",s=r[4]+"_checkbox"),l.required=u=r[0]!=="onsubmit",c(l,"class","svelte-ddsc3z"),c(o,"class","altcha-checkbox svelte-ddsc3z"),je(o,"altcha-hidden",r[6]===m.VERIFYING),c(d,"class","altcha-label svelte-ddsc3z"),c(t,"class","altcha-main svelte-ddsc3z"),c(e,"class","altcha svelte-ddsc3z"),c(e,"data-state",r[6]),c(e,"data-floating",r[1])},m(h,p){M(h,e,p),y(e,t),N&&N.m(t,null),y(t,i),y(t,o),y(o,l),l.checked=r[7],y(t,f),y(t,d),T.m(d,null),y(t,G),R&&R.m(t,null),y(e,S),z&&z.m(e,null),y(e,U),w&&w.m(e,null),y(e,k),I&&I.m(e,null),r[37](e),W||(J=[pe(l,"change",r[35]),pe(l,"change",r[12]),pe(l,"invalid",r[13])],W=!0)},p(h,p){h[6]===m.VERIFYING?N||(N=Ue(),N.c(),N.m(t,i)):N&&(N.d(1),N=null),p[0]&16&&s!==(s=h[4]+"_checkbox")&&c(l,"id",s),p[0]&1&&u!==(u=h[0]!=="onsubmit")&&(l.required=u),p[0]&128&&(l.checked=h[7]),p[0]&64&&je(o,"altcha-hidden",h[6]===m.VERIFYING),Y===(Y=le(h))&&T?T.p(h,p):(T.d(1),T=Y(h),T&&(T.c(),T.m(d,null))),h[3]!==!0?R?R.p(h,p):(R=Fe(h),R.c(),R.m(t,null)):R&&(R.d(1),R=null),h[10]||h[6]===m.EXPIRED?z?z.p(h,p):(z=Ge(h),z.c(),z.m(e,U)):z&&(z.d(1),z=null),h[11].footer&&h[2]!==!0?w?w.p(h,p):(w=We(h),w.c(),w.m(e,k)):w&&(w.d(1),w=null),h[1]?I?I.p(h,p):(I=Xe(h),I.c(),I.m(e,null)):I&&(I.d(1),I=null),p[0]&64&&c(e,"data-state",h[6]),p[0]&2&&c(e,"data-floating",h[1])},i:re,o:re,d(h){h&&j(e),N&&N.d(),T.d(),R&&R.d(),z&&z.d(),w&&w.d(),I&&I.d(),r[37](null),W=!1,se(J)}}}const Be="Visit Altcha.org",He="https://altcha.org/";function Oe(r){return JSON.parse(r)}function Ot(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Pt(r,e,t){var at,ft;let i,o,l,{auto:s=void 0}=e,{blockspam:u=void 0}=e,{challengeurl:f=void 0}=e,{challengejson:d=void 0}=e,{debug:G=!1}=e,{delay:S=0}=e,{expire:U=void 0}=e,{floating:k=void 0}=e,{floatinganchor:W=void 0}=e,{floatingoffset:J=void 0}=e,{hidefooter:N=!1}=e,{hidelogo:le=!1}=e,{name:Y="altcha"}=e,{maxnumber:T=1e6}=e,{mockerror:R=!1}=e,{refetchonexpire:z=!0}=e,{spamfilter:w=!1}=e,{strings:I=void 0}=e,{test:h=!1}=e,{verifyurl:p=void 0}=e,{workers:fe=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:Ce=void 0}=e;const Le=xt(),Ye=["SHA-256","SHA-384","SHA-512"],Ke=(ft=(at=document.documentElement.lang)==null?void 0:at.split("-"))==null?void 0:ft[0];let K=!1,x,q=null,me=null,b=null,Re=null,Q=null,V=m.UNVERIFIED,B=null;kt(()=>{b&&(b.removeEventListener("submit",qe),b.removeEventListener("reset",Qe),b.removeEventListener("focusin",Je),b=null),B&&(clearTimeout(B),B=null),document.removeEventListener("click",nt),document.removeEventListener("scroll",it),window.removeEventListener("resize",lt)}),_t(()=>{E("mounted","0.6.2"),E("workers",fe),h&&E("using test mode"),U&&be(U),s!==void 0&&E("auto",s),k!==void 0&&st(k),b=x.closest("form"),b&&(b.addEventListener("submit",qe,{capture:!0}),b.addEventListener("reset",Qe),s==="onfocus"&&b.addEventListener("focusin",Je)),s==="onload"&&ee()});function E(...n){(G||n.some(a=>a instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Je(n){V===m.UNVERIFIED&&ee()}function qe(n){b&&s==="onsubmit"&&(V===m.UNVERIFIED?(n.preventDefault(),n.stopPropagation(),ee().then(()=>{b==null||b.requestSubmit()})):V!==m.VERIFIED&&(n.preventDefault(),n.stopPropagation(),V===m.VERIFYING&&ot()))}function Qe(){ve()}function et(n,a){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:a.number,salt:n.salt,signature:n.signature,test:h?!0:void 0,took:a.took}))}function tt(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Ye.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ye.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function Yt(){var n;if(R)throw E("mocking error"),new Error("Mocked error.");if(i)return E("using provided json data"),i;if(h)return E("generating test challenge",{test:h}),$t(typeof h!="boolean"?+h:void 0);{if(!f)throw new Error("Attribute challengeurl not set.");E("fetching challenge from",f);const a=await fetch(f,{headers:{"x-altcha-spam-filter":w?"1":"0"}});if(a.status!==200)throw new Error(`Server responded with ${a.status}.`);const g=a.headers.get("Expires"),A=a.headers.get("X-Altcha-Config"),$=await a.json(),D=new URLSearchParams((n=$.salt.split("?"))==null?void 0:n[1]),H=D.get("expires")||D.get("expire");if(H){const _=new Date(+H*1e3),C=isNaN(_.getTime())?0:_.getTime()-Date.now();C>0&&be(C)}if(A)try{const _=JSON.parse(A);_&&typeof _=="object"&&(_.verifyurl&&(_.verifyurl=new URL(_.verifyurl,new URL(f)).toString()),ct(_))}catch(_){E("unable to configure from X-Altcha-Config",_)}if(!U&&(g!=null&&g.length)){const _=Date.parse(g);if(_){const C=_-Date.now();C>0&&be(C)}}return $}}function rt(){f&&z&&V===m.VERIFIED?ee():ve(m.EXPIRED,l.expired)}async function Kt(n){let a=null;if("Worker"in window){try{a=await Jt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(g){E(g)}if((a==null?void 0:a.number)!==void 0)return{data:n,solution:a}}return{data:n,solution:await Dt(n.challenge,n.salt,n.algorithm,n.maxnumber||T).promise}}async function Jt(n,a,g,A=typeof h=="number"?h:T,$=Math.ceil(fe)){const D=[];if($<1)throw new Error("Wrong number of workers configured.");if($>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let C=0;C<$;C++)D.push(createAltchaWorker(Ce));const H=Math.ceil(A/$),_=await Promise.all(D.map((C,Ie)=>{const ue=Ie*H;return new Promise(we=>{C.addEventListener("message",ye=>{if(ye.data)for(const de of D)de!==C&&de.postMessage({type:"abort"});we(ye.data)}),C.postMessage({payload:{alg:g,challenge:n,max:ue+H,salt:a,start:ue},type:"work"})})}));for(const C of D)C.terminate();return _.find(C=>!!C)||null}function qt(){[m.UNVERIFIED,m.ERROR,m.EXPIRED].includes(V)?w&&(b==null?void 0:b.reportValidity())===!1?t(7,K=!1):ee():t(7,K=!0)}function nt(n){const a=n.target;k&&a&&!x.contains(a)&&V===m.VERIFIED&&t(8,x.style.display="none",x)}function it(){k&&ze()}function ot(){V===m.VERIFYING&&l.waitAlert&&alert(l.waitAlert)}function Qt(n){k&&V!==m.UNVERIFIED&&requestAnimationFrame(()=>{ze()})}function lt(){k&&ze()}function be(n){E("expire",n),B&&(clearTimeout(B),B=null),n<1?rt():B=setTimeout(rt,n)}function st(n){E("floating",n),k!==n&&(t(8,x.style.left="",x),t(8,x.style.top="",x)),t(1,k=n===!0||n===""?"auto":n===!1||n==="false"?void 0:k),k?(s||t(0,s="onsubmit"),document.addEventListener("scroll",it),document.addEventListener("click",nt),window.addEventListener("resize",lt)):s==="onsubmit"&&t(0,s=void 0)}function er(n){var g;const a=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((g=a==null?void 0:a.value)==null?void 0:g.slice(a.value.indexOf("@")))||void 0}function tr(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(g=>`input[name="${g}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((g,A)=>{const $=A.name,D=A.value.trim();return $&&D&&(g[$]=D),g},{})}async function rr(n){if(!p)throw new Error("Attribute verifyurl not set.");E("requesting server verification from",p);const a={payload:n};if(w){const{blockedCountries:$,classifier:D,disableRules:H,email:_,expectedLanguages:C,expectedCountries:Ie,fields:ue,ipAddress:we,text:ye,timeZone:de}=typeof w=="object"?w:{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,text:void 0,timeZone:void 0};a.blockedCountries=$,a.classifier=D,a.disableRules=H,a.email=_===!1?void 0:er(_),a.expectedCountries=Ie,a.expectedLanguages=C||(Ke?[Ke]:void 0),a.fields=ue===!1?void 0:tr(ue),a.ipAddress=we===!1?void 0:we||"auto",a.text=ye,a.timeZone=de===!1?void 0:de||Ot()}const g=await fetch(p,{body:JSON.stringify(a),headers:{"content-type":"application/json"},method:"POST"});if(g.status!==200)throw new Error(`Server responded with ${g.status}.`);const A=await g.json();if(A!=null&&A.payload&&t(5,Q=A.payload),Le("serververification",A),u&&A.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function ze(n=20){if(x)if(me||(me=(W?document.querySelector(W):b==null?void 0:b.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])'))||b),me){const a=parseInt(J,10)||12,g=me.getBoundingClientRect(),A=x.getBoundingClientRect(),$=document.documentElement.clientHeight,D=document.documentElement.clientWidth,H=k==="auto"?g.bottom+A.height+a+n>$:k==="top",_=Math.max(n,Math.min(D-n-A.width,g.left+g.width/2-A.width/2));if(H?t(8,x.style.top=`${g.top-(A.height+a)}px`,x):t(8,x.style.top=`${g.bottom+a}px`,x),t(8,x.style.left=`${_}px`,x),x.setAttribute("data-floating",H?"top":"bottom"),q){const C=q.getBoundingClientRect();t(9,q.style.left=g.left-_+g.width/2-C.width/2+"px",q)}}else E("unable to find floating anchor element")}function ct(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&ee()),n.floatinganchor!==void 0&&t(18,W=n.floatinganchor),n.delay!==void 0&&t(16,S=n.delay),n.floatingoffset!==void 0&&t(19,J=n.floatingoffset),n.floating!==void 0&&st(n.floating),n.expire!==void 0&&(be(n.expire),t(17,U=n.expire)),n.challenge&&(tt(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(14,f=n.challengeurl),n.debug!==void 0&&t(15,G=!!n.debug),n.hidefooter!==void 0&&t(2,N=!!n.hidefooter),n.hidelogo!==void 0&&t(3,le=!!n.hidelogo),n.maxnumber!==void 0&&t(20,T=+n.maxnumber),n.mockerror!==void 0&&t(21,R=!!n.mockerror),n.name!==void 0&&t(4,Y=n.name),n.refetchonexpire!==void 0&&t(22,z=!!n.refetchonexpire),n.spamfilter!==void 0&&t(23,w=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(34,o=n.strings),n.test!==void 0&&t(24,h=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(25,p=n.verifyurl),n.workers!==void 0&&t(26,fe=+n.workers)}function ve(n=m.UNVERIFIED,a=null){B&&(clearTimeout(B),B=null),t(7,K=!1),t(10,Re=a),t(5,Q=null),t(6,V=n)}async function ee(){return ve(m.VERIFYING),await new Promise(n=>setTimeout(n,S||0)),Yt().then(n=>(tt(n),E("challenge",n),Kt(n))).then(({data:n,solution:a})=>{if(E("solution",a),(a==null?void 0:a.number)!==void 0){if(p)return rr(et(n,a));t(5,Q=et(n,a)),E("payload",Q)}else throw E("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{Et().then(()=>{t(6,V=m.VERIFIED),t(7,K=!0),E("verified"),Le("verified",{payload:Q})})}).catch(n=>{E(n),t(6,V=m.ERROR),t(7,K=!1),t(10,Re=n.message)})}function nr(){K=this.checked,t(7,K)}function ir(n){he[n?"unshift":"push"](()=>{q=n,t(9,q)})}function or(n){he[n?"unshift":"push"](()=>{x=n,t(8,x)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(27,u=n.blockspam),"challengeurl"in n&&t(14,f=n.challengeurl),"challengejson"in n&&t(28,d=n.challengejson),"debug"in n&&t(15,G=n.debug),"delay"in n&&t(16,S=n.delay),"expire"in n&&t(17,U=n.expire),"floating"in n&&t(1,k=n.floating),"floatinganchor"in n&&t(18,W=n.floatinganchor),"floatingoffset"in n&&t(19,J=n.floatingoffset),"hidefooter"in n&&t(2,N=n.hidefooter),"hidelogo"in n&&t(3,le=n.hidelogo),"name"in n&&t(4,Y=n.name),"maxnumber"in n&&t(20,T=n.maxnumber),"mockerror"in n&&t(21,R=n.mockerror),"refetchonexpire"in n&&t(22,z=n.refetchonexpire),"spamfilter"in n&&t(23,w=n.spamfilter),"strings"in n&&t(29,I=n.strings),"test"in n&&t(24,h=n.test),"verifyurl"in n&&t(25,p=n.verifyurl),"workers"in n&&t(26,fe=n.workers),"workerurl"in n&&t(30,Ce=n.workerurl)},r.$$.update=()=>{r.$$.dirty[0]&268435456&&(i=d?Oe(d):void 0),r.$$.dirty[0]&536870912&&t(34,o=I?Oe(I):{}),r.$$.dirty[1]&8&&t(11,l={ariaLinkLabel:Be,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by <a href="${He}" target="_blank" aria-label="${o.ariaLinkLabel||Be}">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),r.$$.dirty[0]&96&&Le("statechange",{payload:Q,state:V}),r.$$.dirty[0]&64&&Qt()},[s,k,N,le,Y,Q,V,K,x,q,Re,l,qt,ot,f,G,S,U,W,J,T,R,z,w,h,p,fe,u,d,I,Ce,ct,ve,ee,o,nr,ir,or]}class Pe extends jt{constructor(e){super(),St(this,e,Pt,Ht,dt,{auto:0,blockspam:27,challengeurl:14,challengejson:28,debug:15,delay:16,expire:17,floating:1,floatinganchor:18,floatingoffset:19,hidefooter:2,hidelogo:3,name:4,maxnumber:20,mockerror:21,refetchonexpire:22,spamfilter:23,strings:29,test:24,verifyurl:25,workers:26,workerurl:30,configure:31,reset:32,verify:33},Ut,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),v()}get blockspam(){return this.$$.ctx[27]}set blockspam(e){this.$$set({blockspam:e}),v()}get challengeurl(){return this.$$.ctx[14]}set challengeurl(e){this.$$set({challengeurl:e}),v()}get challengejson(){return this.$$.ctx[28]}set challengejson(e){this.$$set({challengejson:e}),v()}get debug(){return this.$$.ctx[15]}set debug(e){this.$$set({debug:e}),v()}get delay(){return this.$$.ctx[16]}set delay(e){this.$$set({delay:e}),v()}get expire(){return this.$$.ctx[17]}set expire(e){this.$$set({expire:e}),v()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),v()}get floatinganchor(){return this.$$.ctx[18]}set floatinganchor(e){this.$$set({floatinganchor:e}),v()}get floatingoffset(){return this.$$.ctx[19]}set floatingoffset(e){this.$$set({floatingoffset:e}),v()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),v()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),v()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),v()}get maxnumber(){return this.$$.ctx[20]}set maxnumber(e){this.$$set({maxnumber:e}),v()}get mockerror(){return this.$$.ctx[21]}set mockerror(e){this.$$set({mockerror:e}),v()}get refetchonexpire(){return this.$$.ctx[22]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),v()}get spamfilter(){return this.$$.ctx[23]}set spamfilter(e){this.$$set({spamfilter:e}),v()}get strings(){return this.$$.ctx[29]}set strings(e){this.$$set({strings:e}),v()}get test(){return this.$$.ctx[24]}set test(e){this.$$set({test:e}),v()}get verifyurl(){return this.$$.ctx[25]}set verifyurl(e){this.$$set({verifyurl:e}),v()}get workers(){return this.$$.ctx[26]}set workers(e){this.$$set({workers:e}),v()}get workerurl(){return this.$$.ctx[30]}set workerurl(e){this.$$set({workerurl:e}),v()}get configure(){return this.$$.ctx[31]}get reset(){return this.$$.ctx[32]}get verify(){return this.$$.ctx[33]}}customElements.define("altcha-widget",Tt(Pe,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=r=>r?new Worker(new URL(r)):new ut,F.Altcha=Pe,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
1
+ (function(F,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(F=typeof globalThis<"u"?globalThis:F||self,M(F.altcha={}))})(this,function(F){"use strict";var lr=Object.defineProperty;var sr=(F,M,te)=>M in F?lr(F,M,{enumerable:!0,configurable:!0,writable:!0,value:te}):F[M]=te;var X=(F,M,te)=>sr(F,typeof M!="symbol"?M+"":M,te);const M="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGQoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBwKGUsdCxvKXtyZXR1cm4gZChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChvLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGcoZSx0LG89IlNIQS0yNTYiLGw9MWU2LGM9MCl7Y29uc3QgYT1uZXcgQWJvcnRDb250cm9sbGVyLGk9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgbj1jO248PWw7bis9MSl7aWYoYS5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCBwKHQsbixvKT09PWUpcmV0dXJue251bWJlcjpuLHRvb2s6RGF0ZS5ub3coKS1pfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjphfX1sZXQgcjtvbm1lc3NhZ2U9YXN5bmMgZT0+e2NvbnN0e3R5cGU6dCxwYXlsb2FkOm99PWUuZGF0YTtpZih0PT09ImFib3J0IilyPT1udWxsfHxyLmFib3J0KCkscj12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtjb25zdHthbGc6bCxjaGFsbGVuZ2U6YyxtYXg6YSxzYWx0Omksc3RhcnQ6dX09b3x8e30sbj1nKGMsaSxsLGEsdSk7cj1uLmNvbnRyb2xsZXIsbi5wcm9taXNlLnRoZW4ocz0+e3NlbGYucG9zdE1lc3NhZ2UocyYmey4uLnMsd29ya2VyOiEwfSl9KX19fSkoKTsK",te=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),Ae=typeof window<"u"&&window.Blob&&new Blob([te(M)],{type:"text/javascript;charset=utf-8"});function ut(r){let e;try{if(e=Ae&&(window.URL||window.webkitURL).createObjectURL(Ae),!e)throw"";const t=new Worker(e,{name:r==null?void 0:r.name});return t.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+M,{name:r==null?void 0:r.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}function re(){}function Ne(r){return r()}function Se(){return Object.create(null)}function se(r){r.forEach(Ne)}function Te(r){return typeof r=="function"}function dt(r,e){return r!=r?e==e:r!==e||r&&typeof r=="object"||typeof r=="function"}function ht(r){return Object.keys(r).length===0}function y(r,e){r.appendChild(e)}function gt(r,e,t){const i=mt(r);if(!i.getElementById(e)){const o=L("style");o.id=e,o.textContent=t,bt(i,o)}}function mt(r){if(!r)return document;const e=r.getRootNode?r.getRootNode():r.ownerDocument;return e&&e.host?e:r.ownerDocument}function bt(r,e){return y(r.head||r,e),e.sheet}function V(r,e,t){r.insertBefore(e,t||null)}function Z(r){r.parentNode&&r.parentNode.removeChild(r)}function L(r){return document.createElement(r)}function O(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function vt(r){return document.createTextNode(r)}function P(){return vt(" ")}function pe(r,e,t,i){return r.addEventListener(e,t,i),()=>r.removeEventListener(e,t,i)}function c(r,e,t){t==null?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t)}function wt(r){return Array.from(r.childNodes)}function je(r,e,t){r.classList.toggle(e,!!t)}function yt(r,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:e,bubbles:t,cancelable:i})}function pt(r){const e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let ce;function ae(r){ce=r}function _e(){if(!ce)throw new Error("Function called outside component initialization");return ce}function _t(r){_e().$$.on_mount.push(r)}function kt(r){_e().$$.on_destroy.push(r)}function xt(){const r=_e();return(e,t,{cancelable:i=!1}={})=>{const o=r.$$.callbacks[e];if(o){const l=yt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(r,l)}),!l.defaultPrevented}return!0}}const ne=[],he=[];let ie=[];const Ze=[],Me=Promise.resolve();let ke=!1;function Ve(){ke||(ke=!0,Me.then(v))}function Et(){return Ve(),Me}function xe(r){ie.push(r)}const Ee=new Set;let oe=0;function v(){if(oe!==0)return;const r=ce;do{try{for(;oe<ne.length;){const e=ne[oe];oe++,ae(e),Ct(e.$$)}}catch(e){throw ne.length=0,oe=0,e}for(ae(null),ne.length=0,oe=0;he.length;)he.pop()();for(let e=0;e<ie.length;e+=1){const t=ie[e];Ee.has(t)||(Ee.add(t),t())}ie.length=0}while(ne.length);for(;Ze.length;)Ze.pop()();ke=!1,Ee.clear(),ae(r)}function Ct(r){if(r.fragment!==null){r.update(),se(r.before_update);const e=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,e),r.after_update.forEach(xe)}}function Lt(r){const e=[],t=[];ie.forEach(i=>r.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),ie=e}const Rt=new Set;function zt(r,e){r&&r.i&&(Rt.delete(r),r.i(e))}function It(r,e,t){const{fragment:i,after_update:o}=r.$$;i&&i.m(e,t),xe(()=>{const l=r.$$.on_mount.map(Ne).filter(Te);r.$$.on_destroy?r.$$.on_destroy.push(...l):se(l),r.$$.on_mount=[]}),o.forEach(xe)}function At(r,e){const t=r.$$;t.fragment!==null&&(Lt(t.after_update),se(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Nt(r,e){r.$$.dirty[0]===-1&&(ne.push(r),Ve(),r.$$.dirty.fill(0)),r.$$.dirty[e/31|0]|=1<<e%31}function St(r,e,t,i,o,l,s=null,u=[-1]){const f=ce;ae(r);const d=r.$$={fragment:null,ctx:[],props:l,update:re,not_equal:o,bound:Se(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(f?f.$$.context:[])),callbacks:Se(),dirty:u,skip_bound:!1,root:e.target||f.$$.root};s&&s(d.root);let G=!1;if(d.ctx=t?t(r,e.props||{},(S,U,...k)=>{const W=k.length?k[0]:U;return d.ctx&&o(d.ctx[S],d.ctx[S]=W)&&(!d.skip_bound&&d.bound[S]&&d.bound[S](W),G&&Nt(r,S)),U}):[],d.update(),G=!0,se(d.before_update),d.fragment=i?i(d.ctx):!1,e.target){if(e.hydrate){const S=wt(e.target);d.fragment&&d.fragment.l(S),S.forEach(Z)}else d.fragment&&d.fragment.c();e.intro&&zt(r.$$.fragment),It(r,e.target,e.anchor),v()}ae(f)}let $e;typeof HTMLElement=="function"&&($e=class extends HTMLElement{constructor(e,t,i){super();X(this,"$$ctor");X(this,"$$s");X(this,"$$c");X(this,"$$cn",!1);X(this,"$$d",{});X(this,"$$r",!1);X(this,"$$p_d",{});X(this,"$$l",{});X(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(l){return()=>{let s;return{c:function(){s=L("slot"),l!=="default"&&c(s,"name",l)},m:function(d,G){V(d,s,G)},d:function(d){d&&Z(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=pt(this);for(const l of this.$$s)l in i&&(t[l]=[e(l)]);for(const l of this.attributes){const s=this.$$g_p(l.name);s in this.$$d||(this.$$d[s]=ge(s,l.value,this.$$p_d,"toProp"))}for(const l in this.$$p_d)!(l in this.$$d)&&this[l]!==void 0&&(this.$$d[l]=this[l],delete this[l]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const l in this.$$p_d)if(this.$$d[l]=this.$$c.$$.ctx[this.$$c.$$.props[l]],this.$$p_d[l].reflect){const s=ge(l,this.$$d[l],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const s of this.$$l[l]){const u=this.$$c.$on(l,s);this.$$l_u.set(s,u)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=ge(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function ge(r,e,t,i){var l;const o=(l=t[r])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[r])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Tt(r,e,t,i,o,l){let s=class extends $e{constructor(){super(r,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(u=>(e[u].attribute||u).toLowerCase())}};return Object.keys(e).forEach(u=>{Object.defineProperty(s.prototype,u,{get(){return this.$$c&&u in this.$$c?this.$$c[u]:this.$$d[u]},set(f){var d;f=ge(u,f,e),this.$$d[u]=f,(d=this.$$c)==null||d.$set({[u]:f})}})}),i.forEach(u=>{Object.defineProperty(s.prototype,u,{get(){var f;return(f=this.$$c)==null?void 0:f[u]}})}),l&&(s=l(s)),r.element=s,s}class jt{constructor(){X(this,"$$");X(this,"$$set")}$destroy(){At(this,1),this.$destroy=re}$on(e,t){if(!Te(t))return re;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!ht(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Zt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Zt);const Mt=new TextEncoder;function Vt(r){return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function $t(r,e="SHA-256",t=1e5){const i=Date.now().toString(16);r||(r=Math.round(Math.random()*t));const o=await De(i,r,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function De(r,e,t){return Vt(await crypto.subtle.digest(t.toUpperCase(),Mt.encode(r+e)))}function Dt(r,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let f=o;f<=i;f+=1){if(l.signal.aborted)return null;if(await De(e,f,t)===r)return{number:f,took:Date.now()-s}}return null})(),controller:l}}var m=(r=>(r.ERROR="error",r.VERIFIED="verified",r.VERIFYING="verifying",r.UNVERIFIED="unverified",r.EXPIRED="expired",r))(m||{});function Ut(r){gt(r,"svelte-ddsc3z",'.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}')}function Ue(r){let e,t,i;return{c(){e=O("svg"),t=O("path"),i=O("path"),c(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(t,"fill","currentColor"),c(t,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-ddsc3z"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){V(o,e,l),y(e,t),y(e,i)},d(o){o&&Z(e)}}}function Ft(r){let e,t=r[11].label+"",i;return{c(){e=L("label"),c(e,"for",i=r[4]+"_checkbox"),c(e,"class","svelte-ddsc3z")},m(o,l){V(o,e,l),e.innerHTML=t},p(o,l){l[0]&2048&&t!==(t=o[11].label+"")&&(e.innerHTML=t),l[0]&16&&i!==(i=o[4]+"_checkbox")&&c(e,"for",i)},d(o){o&&Z(e)}}}function Gt(r){let e,t=r[11].verifying+"";return{c(){e=L("span")},m(i,o){V(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].verifying+"")&&(e.innerHTML=t)},d(i){i&&Z(e)}}}function Wt(r){let e,t=r[11].verified+"",i,o;return{c(){e=L("span"),i=P(),o=L("input"),c(o,"type","hidden"),c(o,"name",r[4]),o.value=r[5]},m(l,s){V(l,e,s),e.innerHTML=t,V(l,i,s),V(l,o,s)},p(l,s){s[0]&2048&&t!==(t=l[11].verified+"")&&(e.innerHTML=t),s[0]&16&&c(o,"name",l[4]),s[0]&32&&(o.value=l[5])},d(l){l&&(Z(e),Z(i),Z(o))}}}function Fe(r){let e,t,i,o,l,s,u;return{c(){e=L("div"),t=L("a"),i=O("svg"),o=O("path"),l=O("path"),s=O("path"),c(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(o,"fill","currentColor"),c(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(l,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(t,"href",He),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-ddsc3z"),c(t,"aria-label",u=r[11].ariaLinkLabel)},m(f,d){V(f,e,d),y(e,t),y(t,i),y(i,o),y(i,l),y(i,s)},p(f,d){d[0]&2048&&u!==(u=f[11].ariaLinkLabel)&&c(t,"aria-label",u)},d(f){f&&Z(e)}}}function Ge(r){let e,t,i,o;function l(f,d){return f[6]===m.EXPIRED?Bt:Xt}let s=l(r),u=s(r);return{c(){e=L("div"),t=O("svg"),i=O("path"),o=P(),u.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(t,"width","14"),c(t,"height","14"),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"fill","none"),c(t,"viewBox","0 0 24 24"),c(t,"stroke-width","1.5"),c(t,"stroke","currentColor"),c(e,"class","altcha-error svelte-ddsc3z")},m(f,d){V(f,e,d),y(e,t),y(t,i),y(e,o),u.m(e,null)},p(f,d){s===(s=l(f))&&u?u.p(f,d):(u.d(1),u=s(f),u&&(u.c(),u.m(e,null)))},d(f){f&&Z(e),u.d()}}}function Xt(r){let e,t=r[11].error+"";return{c(){e=L("div"),c(e,"title",r[10])},m(i,o){V(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),o[0]&1024&&c(e,"title",i[10])},d(i){i&&Z(e)}}}function Bt(r){let e,t=r[11].expired+"";return{c(){e=L("div"),c(e,"title",r[10])},m(i,o){V(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),o[0]&1024&&c(e,"title",i[10])},d(i){i&&Z(e)}}}function We(r){let e,t,i=r[11].footer+"";return{c(){e=L("div"),t=L("div"),c(t,"class","svelte-ddsc3z"),c(e,"class","altcha-footer svelte-ddsc3z")},m(o,l){V(o,e,l),y(e,t),t.innerHTML=i},p(o,l){l[0]&2048&&i!==(i=o[11].footer+"")&&(t.innerHTML=i)},d(o){o&&Z(e)}}}function Xe(r){let e;return{c(){e=L("div"),c(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){V(t,e,i),r[36](e)},p:re,d(t){t&&Z(e),r[36](null)}}}function Ht(r){let e,t,i,o,l,s,u,f,d,G,S,U,k,W,J,N=r[6]===m.VERIFYING&&Ue();function le(h,p){return h[6]===m.VERIFIED?Wt:h[6]===m.VERIFYING?Gt:Ft}let Y=le(r),T=Y(r),R=r[3]!==!0&&Fe(r),z=(r[10]||r[6]===m.EXPIRED)&&Ge(r),w=r[11].footer&&r[2]!==!0&&We(r),I=r[1]&&Xe(r);return{c(){e=L("div"),t=L("div"),N&&N.c(),i=P(),o=L("div"),l=L("input"),f=P(),d=L("div"),T.c(),G=P(),R&&R.c(),S=P(),z&&z.c(),U=P(),w&&w.c(),k=P(),I&&I.c(),c(l,"type","checkbox"),c(l,"id",s=r[4]+"_checkbox"),l.required=u=r[0]!=="onsubmit",c(l,"class","svelte-ddsc3z"),c(o,"class","altcha-checkbox svelte-ddsc3z"),je(o,"altcha-hidden",r[6]===m.VERIFYING),c(d,"class","altcha-label svelte-ddsc3z"),c(t,"class","altcha-main svelte-ddsc3z"),c(e,"class","altcha svelte-ddsc3z"),c(e,"data-state",r[6]),c(e,"data-floating",r[1])},m(h,p){V(h,e,p),y(e,t),N&&N.m(t,null),y(t,i),y(t,o),y(o,l),l.checked=r[7],y(t,f),y(t,d),T.m(d,null),y(t,G),R&&R.m(t,null),y(e,S),z&&z.m(e,null),y(e,U),w&&w.m(e,null),y(e,k),I&&I.m(e,null),r[37](e),W||(J=[pe(l,"change",r[35]),pe(l,"change",r[12]),pe(l,"invalid",r[13])],W=!0)},p(h,p){h[6]===m.VERIFYING?N||(N=Ue(),N.c(),N.m(t,i)):N&&(N.d(1),N=null),p[0]&16&&s!==(s=h[4]+"_checkbox")&&c(l,"id",s),p[0]&1&&u!==(u=h[0]!=="onsubmit")&&(l.required=u),p[0]&128&&(l.checked=h[7]),p[0]&64&&je(o,"altcha-hidden",h[6]===m.VERIFYING),Y===(Y=le(h))&&T?T.p(h,p):(T.d(1),T=Y(h),T&&(T.c(),T.m(d,null))),h[3]!==!0?R?R.p(h,p):(R=Fe(h),R.c(),R.m(t,null)):R&&(R.d(1),R=null),h[10]||h[6]===m.EXPIRED?z?z.p(h,p):(z=Ge(h),z.c(),z.m(e,U)):z&&(z.d(1),z=null),h[11].footer&&h[2]!==!0?w?w.p(h,p):(w=We(h),w.c(),w.m(e,k)):w&&(w.d(1),w=null),h[1]?I?I.p(h,p):(I=Xe(h),I.c(),I.m(e,null)):I&&(I.d(1),I=null),p[0]&64&&c(e,"data-state",h[6]),p[0]&2&&c(e,"data-floating",h[1])},i:re,o:re,d(h){h&&Z(e),N&&N.d(),T.d(),R&&R.d(),z&&z.d(),w&&w.d(),I&&I.d(),r[37](null),W=!1,se(J)}}}const Be="Visit Altcha.org",He="https://altcha.org/";function Oe(r){return JSON.parse(r)}function Ot(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Pt(r,e,t){var at,ft;let i,o,l,{auto:s=void 0}=e,{blockspam:u=void 0}=e,{challengeurl:f=void 0}=e,{challengejson:d=void 0}=e,{debug:G=!1}=e,{delay:S=0}=e,{expire:U=void 0}=e,{floating:k=void 0}=e,{floatinganchor:W=void 0}=e,{floatingoffset:J=void 0}=e,{hidefooter:N=!1}=e,{hidelogo:le=!1}=e,{name:Y="altcha"}=e,{maxnumber:T=1e6}=e,{mockerror:R=!1}=e,{refetchonexpire:z=!0}=e,{spamfilter:w=!1}=e,{strings:I=void 0}=e,{test:h=!1}=e,{verifyurl:p=void 0}=e,{workers:fe=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:Ce=void 0}=e;const Le=xt(),Ye=["SHA-256","SHA-384","SHA-512"],Ke=(ft=(at=document.documentElement.lang)==null?void 0:at.split("-"))==null?void 0:ft[0];let K=!1,x,q=null,me=null,b=null,Re=null,Q=null,$=m.UNVERIFIED,B=null;kt(()=>{b&&(b.removeEventListener("submit",qe),b.removeEventListener("reset",Qe),b.removeEventListener("focusin",Je),b=null),B&&(clearTimeout(B),B=null),document.removeEventListener("click",nt),document.removeEventListener("scroll",it),window.removeEventListener("resize",lt)}),_t(()=>{E("mounted","0.6.3"),E("workers",fe),h&&E("using test mode"),U&&be(U),s!==void 0&&E("auto",s),k!==void 0&&st(k),b=x.closest("form"),b&&(b.addEventListener("submit",qe,{capture:!0}),b.addEventListener("reset",Qe),s==="onfocus"&&b.addEventListener("focusin",Je)),s==="onload"&&ee()});function E(...n){(G||n.some(a=>a instanceof Error))&&console[n[0]instanceof Error?"error":"log"]("ALTCHA",...n)}function Je(n){$===m.UNVERIFIED&&ee()}function qe(n){b&&s==="onsubmit"&&($===m.UNVERIFIED?(n.preventDefault(),n.stopPropagation(),ee().then(()=>{b==null||b.requestSubmit()})):$!==m.VERIFIED&&(n.preventDefault(),n.stopPropagation(),$===m.VERIFYING&&ot()))}function Qe(){ve()}function et(n,a){return btoa(JSON.stringify({algorithm:n.algorithm,challenge:n.challenge,number:a.number,salt:n.salt,signature:n.signature,test:h?!0:void 0,took:a.took}))}function tt(n){if(!n.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(n.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Ye.includes(n.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ye.join(", ")}`);if(!n.challenge||n.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!n.salt||n.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function Yt(){var n;if(R)throw E("mocking error"),new Error("Mocked error.");if(i)return E("using provided json data"),i;if(h)return E("generating test challenge",{test:h}),$t(typeof h!="boolean"?+h:void 0);{if(!f)throw new Error("Attribute challengeurl not set.");E("fetching challenge from",f);const a=await fetch(f,{headers:{"x-altcha-spam-filter":w?"1":"0"}});if(a.status!==200)throw new Error(`Server responded with ${a.status}.`);const g=a.headers.get("Expires"),A=a.headers.get("X-Altcha-Config"),D=await a.json(),j=new URLSearchParams((n=D.salt.split("?"))==null?void 0:n[1]),H=j.get("expires")||j.get("expire");if(H){const _=new Date(+H*1e3),C=isNaN(_.getTime())?0:_.getTime()-Date.now();C>0&&be(C)}if(A)try{const _=JSON.parse(A);_&&typeof _=="object"&&(_.verifyurl&&(_.verifyurl=new URL(_.verifyurl,new URL(f)).toString()),ct(_))}catch(_){E("unable to configure from X-Altcha-Config",_)}if(!U&&(g!=null&&g.length)){const _=Date.parse(g);if(_){const C=_-Date.now();C>0&&be(C)}}return D}}function rt(){f&&z&&$===m.VERIFIED?ee():ve(m.EXPIRED,l.expired)}async function Kt(n){let a=null;if("Worker"in window){try{a=await Jt(n.challenge,n.salt,n.algorithm,n.maxnumber)}catch(g){E(g)}if((a==null?void 0:a.number)!==void 0)return{data:n,solution:a}}return{data:n,solution:await Dt(n.challenge,n.salt,n.algorithm,n.maxnumber||T).promise}}async function Jt(n,a,g,A=typeof h=="number"?h:T,D=Math.ceil(fe)){const j=[];if(D<1)throw new Error("Wrong number of workers configured.");if(D>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let C=0;C<D;C++)j.push(createAltchaWorker(Ce));const H=Math.ceil(A/D),_=await Promise.all(j.map((C,Ie)=>{const ue=Ie*H;return new Promise(we=>{C.addEventListener("message",ye=>{if(ye.data)for(const de of j)de!==C&&de.postMessage({type:"abort"});we(ye.data)}),C.postMessage({payload:{alg:g,challenge:n,max:ue+H,salt:a,start:ue},type:"work"})})}));for(const C of j)C.terminate();return _.find(C=>!!C)||null}function qt(){[m.UNVERIFIED,m.ERROR,m.EXPIRED].includes($)?w&&(b==null?void 0:b.reportValidity())===!1?t(7,K=!1):ee():t(7,K=!0)}function nt(n){const a=n.target;k&&a&&!x.contains(a)&&$===m.VERIFIED&&t(8,x.style.display="none",x)}function it(){k&&ze()}function ot(){$===m.VERIFYING&&l.waitAlert&&alert(l.waitAlert)}function Qt(n){k&&$!==m.UNVERIFIED&&requestAnimationFrame(()=>{ze()})}function lt(){k&&ze()}function be(n){E("expire",n),B&&(clearTimeout(B),B=null),n<1?rt():B=setTimeout(rt,n)}function st(n){E("floating",n),k!==n&&(t(8,x.style.left="",x),t(8,x.style.top="",x)),t(1,k=n===!0||n===""?"auto":n===!1||n==="false"?void 0:k),k?(s||t(0,s="onsubmit"),document.addEventListener("scroll",it),document.addEventListener("click",nt),window.addEventListener("resize",lt)):s==="onsubmit"&&t(0,s=void 0)}function er(n){var g;const a=b==null?void 0:b.querySelector(typeof n=="string"?`input[name="${n}"]`:'input[type="email"]:not([data-no-spamfilter])');return((g=a==null?void 0:a.value)==null?void 0:g.slice(a.value.indexOf("@")))||void 0}function tr(n){return[...(b==null?void 0:b.querySelectorAll(n!=null&&n.length?n.map(g=>`input[name="${g}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((g,A)=>{const D=A.name,j=A.value;return D&&j&&(g[D]=/\n/.test(j)?j.replace(new RegExp("(?<!\\r)\\n","g"),`\r
2
+ `):j),g},{})}async function rr(n){if(!p)throw new Error("Attribute verifyurl not set.");E("requesting server verification from",p);const a={payload:n};if(w){const{blockedCountries:D,classifier:j,disableRules:H,email:_,expectedLanguages:C,expectedCountries:Ie,fields:ue,ipAddress:we,text:ye,timeZone:de}=typeof w=="object"?w:{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,text:void 0,timeZone:void 0};a.blockedCountries=D,a.classifier=j,a.disableRules=H,a.email=_===!1?void 0:er(_),a.expectedCountries=Ie,a.expectedLanguages=C||(Ke?[Ke]:void 0),a.fields=ue===!1?void 0:tr(ue),a.ipAddress=we===!1?void 0:we||"auto",a.text=ye,a.timeZone=de===!1?void 0:de||Ot()}const g=await fetch(p,{body:JSON.stringify(a),headers:{"content-type":"application/json"},method:"POST"});if(g.status!==200)throw new Error(`Server responded with ${g.status}.`);const A=await g.json();if(A!=null&&A.payload&&t(5,Q=A.payload),Le("serververification",A),u&&A.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function ze(n=20){if(x)if(me||(me=(W?document.querySelector(W):b==null?void 0:b.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])'))||b),me){const a=parseInt(J,10)||12,g=me.getBoundingClientRect(),A=x.getBoundingClientRect(),D=document.documentElement.clientHeight,j=document.documentElement.clientWidth,H=k==="auto"?g.bottom+A.height+a+n>D:k==="top",_=Math.max(n,Math.min(j-n-A.width,g.left+g.width/2-A.width/2));if(H?t(8,x.style.top=`${g.top-(A.height+a)}px`,x):t(8,x.style.top=`${g.bottom+a}px`,x),t(8,x.style.left=`${_}px`,x),x.setAttribute("data-floating",H?"top":"bottom"),q){const C=q.getBoundingClientRect();t(9,q.style.left=g.left-_+g.width/2-C.width/2+"px",q)}}else E("unable to find floating anchor element")}function ct(n){n.auto!==void 0&&(t(0,s=n.auto),s==="onload"&&ee()),n.floatinganchor!==void 0&&t(18,W=n.floatinganchor),n.delay!==void 0&&t(16,S=n.delay),n.floatingoffset!==void 0&&t(19,J=n.floatingoffset),n.floating!==void 0&&st(n.floating),n.expire!==void 0&&(be(n.expire),t(17,U=n.expire)),n.challenge&&(tt(n.challenge),i=n.challenge),n.challengeurl!==void 0&&t(14,f=n.challengeurl),n.debug!==void 0&&t(15,G=!!n.debug),n.hidefooter!==void 0&&t(2,N=!!n.hidefooter),n.hidelogo!==void 0&&t(3,le=!!n.hidelogo),n.maxnumber!==void 0&&t(20,T=+n.maxnumber),n.mockerror!==void 0&&t(21,R=!!n.mockerror),n.name!==void 0&&t(4,Y=n.name),n.refetchonexpire!==void 0&&t(22,z=!!n.refetchonexpire),n.spamfilter!==void 0&&t(23,w=typeof n.spamfilter=="object"?n.spamfilter:!!n.spamfilter),n.strings&&t(34,o=n.strings),n.test!==void 0&&t(24,h=typeof n.test=="number"?n.test:!!n.test),n.verifyurl!==void 0&&t(25,p=n.verifyurl),n.workers!==void 0&&t(26,fe=+n.workers)}function ve(n=m.UNVERIFIED,a=null){B&&(clearTimeout(B),B=null),t(7,K=!1),t(10,Re=a),t(5,Q=null),t(6,$=n)}async function ee(){return ve(m.VERIFYING),await new Promise(n=>setTimeout(n,S||0)),Yt().then(n=>(tt(n),E("challenge",n),Kt(n))).then(({data:n,solution:a})=>{if(E("solution",a),(a==null?void 0:a.number)!==void 0){if(p)return rr(et(n,a));t(5,Q=et(n,a)),E("payload",Q)}else throw E("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{Et().then(()=>{t(6,$=m.VERIFIED),t(7,K=!0),E("verified"),Le("verified",{payload:Q})})}).catch(n=>{E(n),t(6,$=m.ERROR),t(7,K=!1),t(10,Re=n.message)})}function nr(){K=this.checked,t(7,K)}function ir(n){he[n?"unshift":"push"](()=>{q=n,t(9,q)})}function or(n){he[n?"unshift":"push"](()=>{x=n,t(8,x)})}return r.$$set=n=>{"auto"in n&&t(0,s=n.auto),"blockspam"in n&&t(27,u=n.blockspam),"challengeurl"in n&&t(14,f=n.challengeurl),"challengejson"in n&&t(28,d=n.challengejson),"debug"in n&&t(15,G=n.debug),"delay"in n&&t(16,S=n.delay),"expire"in n&&t(17,U=n.expire),"floating"in n&&t(1,k=n.floating),"floatinganchor"in n&&t(18,W=n.floatinganchor),"floatingoffset"in n&&t(19,J=n.floatingoffset),"hidefooter"in n&&t(2,N=n.hidefooter),"hidelogo"in n&&t(3,le=n.hidelogo),"name"in n&&t(4,Y=n.name),"maxnumber"in n&&t(20,T=n.maxnumber),"mockerror"in n&&t(21,R=n.mockerror),"refetchonexpire"in n&&t(22,z=n.refetchonexpire),"spamfilter"in n&&t(23,w=n.spamfilter),"strings"in n&&t(29,I=n.strings),"test"in n&&t(24,h=n.test),"verifyurl"in n&&t(25,p=n.verifyurl),"workers"in n&&t(26,fe=n.workers),"workerurl"in n&&t(30,Ce=n.workerurl)},r.$$.update=()=>{r.$$.dirty[0]&268435456&&(i=d?Oe(d):void 0),r.$$.dirty[0]&536870912&&t(34,o=I?Oe(I):{}),r.$$.dirty[1]&8&&t(11,l={ariaLinkLabel:Be,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by <a href="${He}" target="_blank" aria-label="${o.ariaLinkLabel||Be}">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),r.$$.dirty[0]&96&&Le("statechange",{payload:Q,state:$}),r.$$.dirty[0]&64&&Qt()},[s,k,N,le,Y,Q,$,K,x,q,Re,l,qt,ot,f,G,S,U,W,J,T,R,z,w,h,p,fe,u,d,I,Ce,ct,ve,ee,o,nr,ir,or]}class Pe extends jt{constructor(e){super(),St(this,e,Pt,Ht,dt,{auto:0,blockspam:27,challengeurl:14,challengejson:28,debug:15,delay:16,expire:17,floating:1,floatinganchor:18,floatingoffset:19,hidefooter:2,hidelogo:3,name:4,maxnumber:20,mockerror:21,refetchonexpire:22,spamfilter:23,strings:29,test:24,verifyurl:25,workers:26,workerurl:30,configure:31,reset:32,verify:33},Ut,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),v()}get blockspam(){return this.$$.ctx[27]}set blockspam(e){this.$$set({blockspam:e}),v()}get challengeurl(){return this.$$.ctx[14]}set challengeurl(e){this.$$set({challengeurl:e}),v()}get challengejson(){return this.$$.ctx[28]}set challengejson(e){this.$$set({challengejson:e}),v()}get debug(){return this.$$.ctx[15]}set debug(e){this.$$set({debug:e}),v()}get delay(){return this.$$.ctx[16]}set delay(e){this.$$set({delay:e}),v()}get expire(){return this.$$.ctx[17]}set expire(e){this.$$set({expire:e}),v()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),v()}get floatinganchor(){return this.$$.ctx[18]}set floatinganchor(e){this.$$set({floatinganchor:e}),v()}get floatingoffset(){return this.$$.ctx[19]}set floatingoffset(e){this.$$set({floatingoffset:e}),v()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),v()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),v()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),v()}get maxnumber(){return this.$$.ctx[20]}set maxnumber(e){this.$$set({maxnumber:e}),v()}get mockerror(){return this.$$.ctx[21]}set mockerror(e){this.$$set({mockerror:e}),v()}get refetchonexpire(){return this.$$.ctx[22]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),v()}get spamfilter(){return this.$$.ctx[23]}set spamfilter(e){this.$$set({spamfilter:e}),v()}get strings(){return this.$$.ctx[29]}set strings(e){this.$$set({strings:e}),v()}get test(){return this.$$.ctx[24]}set test(e){this.$$set({test:e}),v()}get verifyurl(){return this.$$.ctx[25]}set verifyurl(e){this.$$set({verifyurl:e}),v()}get workers(){return this.$$.ctx[26]}set workers(e){this.$$set({workers:e}),v()}get workerurl(){return this.$$.ctx[30]}set workerurl(e){this.$$set({workerurl:e}),v()}get configure(){return this.$$.ctx[31]}get reset(){return this.$$.ctx[32]}get verify(){return this.$$.ctx[33]}}customElements.define("altcha-widget",Tt(Pe,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=r=>r?new Worker(new URL(r)):new ut,F.Altcha=Pe,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
@@ -27,7 +27,7 @@ function E(n, e) {
27
27
  function P(n, e, t) {
28
28
  n.insertBefore(e, t || null);
29
29
  }
30
- function D(n) {
30
+ function N(n) {
31
31
  n.parentNode && n.parentNode.removeChild(n);
32
32
  }
33
33
  function $(n) {
@@ -198,7 +198,7 @@ function jt(n, e, t, i, l, o, s = null, a = [-1]) {
198
198
  }) : [], h.update(), H = !0, ce(h.before_update), h.fragment = i ? i(h.ctx) : !1, e.target) {
199
199
  if (e.hydrate) {
200
200
  const T = Et(e.target);
201
- h.fragment && h.fragment.l(T), T.forEach(D);
201
+ h.fragment && h.fragment.l(T), T.forEach(N);
202
202
  } else
203
203
  h.fragment && h.fragment.c();
204
204
  e.intro && Tt(n.$$.fragment), St(n, e.target, e.anchor), w();
@@ -259,7 +259,7 @@ typeof HTMLElement == "function" && (rt = class extends HTMLElement {
259
259
  P(h, s, H);
260
260
  },
261
261
  d: function(h) {
262
- h && D(s);
262
+ h && N(s);
263
263
  }
264
264
  };
265
265
  };
@@ -486,7 +486,7 @@ function Ye(n) {
486
486
  P(l, e, o), E(e, t), E(e, i);
487
487
  },
488
488
  d(l) {
489
- l && D(e);
489
+ l && N(e);
490
490
  }
491
491
  };
492
492
  }
@@ -511,7 +511,7 @@ function qt(n) {
511
511
  l[4] + "_checkbox") && f(e, "for", i);
512
512
  },
513
513
  d(l) {
514
- l && D(e);
514
+ l && N(e);
515
515
  }
516
516
  };
517
517
  }
@@ -533,7 +533,7 @@ function Zt(n) {
533
533
  i[11].verifying + "") && (e.innerHTML = t);
534
534
  },
535
535
  d(i) {
536
- i && D(e);
536
+ i && N(e);
537
537
  }
538
538
  };
539
539
  }
@@ -569,7 +569,7 @@ function Yt(n) {
569
569
  o[5]);
570
570
  },
571
571
  d(o) {
572
- o && (D(e), D(i), D(l));
572
+ o && (N(e), N(i), N(l));
573
573
  }
574
574
  };
575
575
  }
@@ -589,7 +589,7 @@ function Ge(n) {
589
589
  u[11].ariaLinkLabel) && f(t, "aria-label", a);
590
590
  },
591
591
  d(u) {
592
- u && D(e);
592
+ u && N(e);
593
593
  }
594
594
  };
595
595
  }
@@ -613,7 +613,7 @@ function We(n) {
613
613
  s === (s = o(u)) && a ? a.p(u, h) : (a.d(1), a = s(u), a && (a.c(), a.m(e, null)));
614
614
  },
615
615
  d(u) {
616
- u && D(e), a.d();
616
+ u && N(e), a.d();
617
617
  }
618
618
  };
619
619
  }
@@ -646,7 +646,7 @@ function Gt(n) {
646
646
  );
647
647
  },
648
648
  d(i) {
649
- i && D(e);
649
+ i && N(e);
650
650
  }
651
651
  };
652
652
  }
@@ -679,7 +679,7 @@ function Wt(n) {
679
679
  );
680
680
  },
681
681
  d(i) {
682
- i && D(e);
682
+ i && N(e);
683
683
  }
684
684
  };
685
685
  }
@@ -701,7 +701,7 @@ function Xe(n) {
701
701
  l[11].footer + "") && (t.innerHTML = i);
702
702
  },
703
703
  d(l) {
704
- l && D(e);
704
+ l && N(e);
705
705
  }
706
706
  };
707
707
  }
@@ -716,7 +716,7 @@ function Je(n) {
716
716
  },
717
717
  p: re,
718
718
  d(t) {
719
- t && D(e), n[36](null);
719
+ t && N(e), n[36](null);
720
720
  }
721
721
  };
722
722
  }
@@ -830,7 +830,7 @@ function Xt(n) {
830
830
  i: re,
831
831
  o: re,
832
832
  d(d) {
833
- d && D(e), M && M.d(), S.d(), L && L.d(), I && I.d(), _ && _.d(), A && A.d(), n[37](null), O = !1, ce(X);
833
+ d && N(e), M && M.d(), S.d(), L && L.d(), I && I.d(), _ && _.d(), A && A.d(), n[37](null), O = !1, ce(X);
834
834
  }
835
835
  };
836
836
  }
@@ -848,22 +848,22 @@ function zt(n, e, t) {
848
848
  var Oe, Be;
849
849
  let i, l, o, { auto: s = void 0 } = e, { blockspam: a = void 0 } = e, { challengeurl: u = void 0 } = e, { challengejson: h = void 0 } = e, { debug: H = !1 } = e, { delay: T = 0 } = e, { expire: F = void 0 } = e, { floating: v = void 0 } = e, { floatinganchor: O = void 0 } = e, { floatingoffset: X = void 0 } = e, { hidefooter: M = !1 } = e, { hidelogo: Q = !1 } = e, { name: Y = "altcha" } = e, { maxnumber: S = 1e6 } = e, { mockerror: L = !1 } = e, { refetchonexpire: I = !0 } = e, { spamfilter: _ = !1 } = e, { strings: A = void 0 } = e, { test: d = !1 } = e, { verifyurl: y = void 0 } = e, { workers: ie = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: we = void 0 } = e;
850
850
  const _e = It(), Ie = ["SHA-256", "SHA-384", "SHA-512"], Ae = (Be = (Oe = document.documentElement.lang) == null ? void 0 : Oe.split("-")) == null ? void 0 : Be[0];
851
- let G = !1, p, J = null, ue = null, m = null, ye = null, z = null, N = b.UNVERIFIED, U = null;
851
+ let G = !1, p, J = null, ue = null, m = null, ye = null, z = null, j = b.UNVERIFIED, U = null;
852
852
  Lt(() => {
853
853
  m && (m.removeEventListener("submit", $e), m.removeEventListener("reset", Me), m.removeEventListener("focusin", Re), m = null), U && (clearTimeout(U), U = null), document.removeEventListener("click", Ne), document.removeEventListener("scroll", je), window.removeEventListener("resize", Pe);
854
854
  }), Ct(() => {
855
- x("mounted", "0.6.2"), x("workers", ie), d && x("using test mode"), F && ae(F), s !== void 0 && x("auto", s), v !== void 0 && Fe(v), m = p.closest("form"), m && (m.addEventListener("submit", $e, { capture: !0 }), m.addEventListener("reset", Me), s === "onfocus" && m.addEventListener("focusin", Re)), s === "onload" && K();
855
+ x("mounted", "0.6.3"), x("workers", ie), d && x("using test mode"), F && ae(F), s !== void 0 && x("auto", s), v !== void 0 && Fe(v), m = p.closest("form"), m && (m.addEventListener("submit", $e, { capture: !0 }), m.addEventListener("reset", Me), s === "onfocus" && m.addEventListener("focusin", Re)), s === "onload" && K();
856
856
  });
857
857
  function x(...r) {
858
858
  (H || r.some((c) => c instanceof Error)) && console[r[0] instanceof Error ? "error" : "log"]("ALTCHA", ...r);
859
859
  }
860
860
  function Re(r) {
861
- N === b.UNVERIFIED && K();
861
+ j === b.UNVERIFIED && K();
862
862
  }
863
863
  function $e(r) {
864
- m && s === "onsubmit" && (N === b.UNVERIFIED ? (r.preventDefault(), r.stopPropagation(), K().then(() => {
864
+ m && s === "onsubmit" && (j === b.UNVERIFIED ? (r.preventDefault(), r.stopPropagation(), K().then(() => {
865
865
  m == null || m.requestSubmit();
866
- })) : N !== b.VERIFIED && (r.preventDefault(), r.stopPropagation(), N === b.VERIFYING && Ve()));
866
+ })) : j !== b.VERIFIED && (r.preventDefault(), r.stopPropagation(), j === b.VERIFYING && Ve()));
867
867
  }
868
868
  function Me() {
869
869
  he();
@@ -910,7 +910,7 @@ function zt(n, e, t) {
910
910
  });
911
911
  if (c.status !== 200)
912
912
  throw new Error(`Server responded with ${c.status}.`);
913
- const g = c.headers.get("Expires"), R = c.headers.get("X-Altcha-Config"), j = await c.json(), V = new URLSearchParams((r = j.salt.split("?")) == null ? void 0 : r[1]), q = V.get("expires") || V.get("expire");
913
+ const g = c.headers.get("Expires"), R = c.headers.get("X-Altcha-Config"), V = await c.json(), D = new URLSearchParams((r = V.salt.split("?")) == null ? void 0 : r[1]), q = D.get("expires") || D.get("expire");
914
914
  if (q) {
915
915
  const k = new Date(+q * 1e3), C = isNaN(k.getTime()) ? 0 : k.getTime() - Date.now();
916
916
  C > 0 && ae(C);
@@ -929,11 +929,11 @@ function zt(n, e, t) {
929
929
  C > 0 && ae(C);
930
930
  }
931
931
  }
932
- return j;
932
+ return V;
933
933
  }
934
934
  }
935
935
  function De() {
936
- u && I && N === b.VERIFIED ? K() : he(b.EXPIRED, o.expired);
936
+ u && I && j === b.VERIFIED ? K() : he(b.EXPIRED, o.expired);
937
937
  }
938
938
  async function st(r) {
939
939
  let c = null;
@@ -951,20 +951,20 @@ function zt(n, e, t) {
951
951
  solution: await Ut(r.challenge, r.salt, r.algorithm, r.maxnumber || S).promise
952
952
  };
953
953
  }
954
- async function ft(r, c, g, R = typeof d == "number" ? d : S, j = Math.ceil(ie)) {
955
- const V = [];
956
- if (j < 1)
954
+ async function ft(r, c, g, R = typeof d == "number" ? d : S, V = Math.ceil(ie)) {
955
+ const D = [];
956
+ if (V < 1)
957
957
  throw new Error("Wrong number of workers configured.");
958
- if (j > 16)
958
+ if (V > 16)
959
959
  throw new Error("Too many workers. Max. 16 allowed workers.");
960
- for (let C = 0; C < j; C++)
961
- V.push(createAltchaWorker(we));
962
- const q = Math.ceil(R / j), k = await Promise.all(V.map((C, ve) => {
960
+ for (let C = 0; C < V; C++)
961
+ D.push(createAltchaWorker(we));
962
+ const q = Math.ceil(R / V), k = await Promise.all(D.map((C, ve) => {
963
963
  const oe = ve * q;
964
964
  return new Promise((de) => {
965
965
  C.addEventListener("message", (ge) => {
966
966
  if (ge.data)
967
- for (const le of V)
967
+ for (const le of D)
968
968
  le !== C && le.postMessage({ type: "abort" });
969
969
  de(ge.data);
970
970
  }), C.postMessage({
@@ -979,25 +979,25 @@ function zt(n, e, t) {
979
979
  });
980
980
  });
981
981
  }));
982
- for (const C of V)
982
+ for (const C of D)
983
983
  C.terminate();
984
984
  return k.find((C) => !!C) || null;
985
985
  }
986
986
  function ct() {
987
- [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(N) ? _ && (m == null ? void 0 : m.reportValidity()) === !1 ? t(7, G = !1) : K() : t(7, G = !0);
987
+ [b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(j) ? _ && (m == null ? void 0 : m.reportValidity()) === !1 ? t(7, G = !1) : K() : t(7, G = !0);
988
988
  }
989
989
  function Ne(r) {
990
990
  const c = r.target;
991
- v && c && !p.contains(c) && N === b.VERIFIED && t(8, p.style.display = "none", p);
991
+ v && c && !p.contains(c) && j === b.VERIFIED && t(8, p.style.display = "none", p);
992
992
  }
993
993
  function je() {
994
994
  v && ke();
995
995
  }
996
996
  function Ve() {
997
- N === b.VERIFYING && o.waitAlert && alert(o.waitAlert);
997
+ j === b.VERIFYING && o.waitAlert && alert(o.waitAlert);
998
998
  }
999
999
  function ut(r) {
1000
- v && N !== b.UNVERIFIED && requestAnimationFrame(() => {
1000
+ v && j !== b.UNVERIFIED && requestAnimationFrame(() => {
1001
1001
  ke();
1002
1002
  });
1003
1003
  }
@@ -1020,8 +1020,9 @@ function zt(n, e, t) {
1020
1020
  ...(m == null ? void 0 : m.querySelectorAll(r != null && r.length ? r.map((g) => `input[name="${g}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || []
1021
1021
  ].reduce(
1022
1022
  (g, R) => {
1023
- const j = R.name, V = R.value.trim();
1024
- return j && V && (g[j] = V), g;
1023
+ const V = R.name, D = R.value;
1024
+ return V && D && (g[V] = /\n/.test(D) ? D.replace(new RegExp("(?<!\\r)\\n", "g"), `\r
1025
+ `) : D), g;
1025
1026
  },
1026
1027
  {}
1027
1028
  );
@@ -1032,7 +1033,7 @@ function zt(n, e, t) {
1032
1033
  x("requesting server verification from", y);
1033
1034
  const c = { payload: r };
1034
1035
  if (_) {
1035
- const { blockedCountries: j, classifier: V, disableRules: q, email: k, expectedLanguages: C, expectedCountries: ve, fields: oe, ipAddress: de, text: ge, timeZone: le } = typeof _ == "object" ? _ : {
1036
+ const { blockedCountries: V, classifier: D, disableRules: q, email: k, expectedLanguages: C, expectedCountries: ve, fields: oe, ipAddress: de, text: ge, timeZone: le } = typeof _ == "object" ? _ : {
1036
1037
  blockedCountries: void 0,
1037
1038
  classifier: void 0,
1038
1039
  disableRules: void 0,
@@ -1044,7 +1045,7 @@ function zt(n, e, t) {
1044
1045
  text: void 0,
1045
1046
  timeZone: void 0
1046
1047
  };
1047
- c.blockedCountries = j, c.classifier = V, c.disableRules = q, c.email = k === !1 ? void 0 : at(k), c.expectedCountries = ve, c.expectedLanguages = C || (Ae ? [Ae] : void 0), c.fields = oe === !1 ? void 0 : ht(oe), c.ipAddress = de === !1 ? void 0 : de || "auto", c.text = ge, c.timeZone = le === !1 ? void 0 : le || Jt();
1048
+ c.blockedCountries = V, c.classifier = D, c.disableRules = q, c.email = k === !1 ? void 0 : at(k), c.expectedCountries = ve, c.expectedLanguages = C || (Ae ? [Ae] : void 0), c.fields = oe === !1 ? void 0 : ht(oe), c.ipAddress = de === !1 ? void 0 : de || "auto", c.text = ge, c.timeZone = le === !1 ? void 0 : le || Jt();
1048
1049
  }
1049
1050
  const g = await fetch(y, {
1050
1051
  body: JSON.stringify(c),
@@ -1060,7 +1061,7 @@ function zt(n, e, t) {
1060
1061
  function ke(r = 20) {
1061
1062
  if (p)
1062
1063
  if (ue || (ue = (O ? document.querySelector(O) : m == null ? void 0 : m.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || m), ue) {
1063
- const c = parseInt(X, 10) || 12, g = ue.getBoundingClientRect(), R = p.getBoundingClientRect(), j = document.documentElement.clientHeight, V = document.documentElement.clientWidth, q = v === "auto" ? g.bottom + R.height + c + r > j : v === "top", k = Math.max(r, Math.min(V - r - R.width, g.left + g.width / 2 - R.width / 2));
1064
+ const c = parseInt(X, 10) || 12, g = ue.getBoundingClientRect(), R = p.getBoundingClientRect(), V = document.documentElement.clientHeight, D = document.documentElement.clientWidth, q = v === "auto" ? g.bottom + R.height + c + r > V : v === "top", k = Math.max(r, Math.min(D - r - R.width, g.left + g.width / 2 - R.width / 2));
1064
1065
  if (q ? t(8, p.style.top = `${g.top - (R.height + c)}px`, p) : t(8, p.style.top = `${g.bottom + c}px`, p), t(8, p.style.left = `${k}px`, p), p.setAttribute("data-floating", q ? "top" : "bottom"), J) {
1065
1066
  const C = J.getBoundingClientRect();
1066
1067
  t(9, J.style.left = g.left - k + g.width / 2 - C.width / 2 + "px", J);
@@ -1072,7 +1073,7 @@ function zt(n, e, t) {
1072
1073
  r.auto !== void 0 && (t(0, s = r.auto), s === "onload" && K()), r.floatinganchor !== void 0 && t(18, O = r.floatinganchor), r.delay !== void 0 && t(16, T = r.delay), r.floatingoffset !== void 0 && t(19, X = r.floatingoffset), r.floating !== void 0 && Fe(r.floating), r.expire !== void 0 && (ae(r.expire), t(17, F = r.expire)), r.challenge && (Se(r.challenge), i = r.challenge), r.challengeurl !== void 0 && t(14, u = r.challengeurl), r.debug !== void 0 && t(15, H = !!r.debug), r.hidefooter !== void 0 && t(2, M = !!r.hidefooter), r.hidelogo !== void 0 && t(3, Q = !!r.hidelogo), r.maxnumber !== void 0 && t(20, S = +r.maxnumber), r.mockerror !== void 0 && t(21, L = !!r.mockerror), r.name !== void 0 && t(4, Y = r.name), r.refetchonexpire !== void 0 && t(22, I = !!r.refetchonexpire), r.spamfilter !== void 0 && t(23, _ = typeof r.spamfilter == "object" ? r.spamfilter : !!r.spamfilter), r.strings && t(34, l = r.strings), r.test !== void 0 && t(24, d = typeof r.test == "number" ? r.test : !!r.test), r.verifyurl !== void 0 && t(25, y = r.verifyurl), r.workers !== void 0 && t(26, ie = +r.workers);
1073
1074
  }
1074
1075
  function he(r = b.UNVERIFIED, c = null) {
1075
- U && (clearTimeout(U), U = null), t(7, G = !1), t(10, ye = c), t(5, z = null), t(6, N = r);
1076
+ U && (clearTimeout(U), U = null), t(7, G = !1), t(10, ye = c), t(5, z = null), t(6, j = r);
1076
1077
  }
1077
1078
  async function K() {
1078
1079
  return he(b.VERIFYING), await new Promise((r) => setTimeout(r, T || 0)), lt().then((r) => (Se(r), x("challenge", r), st(r))).then(({ data: r, solution: c }) => {
@@ -1084,10 +1085,10 @@ function zt(n, e, t) {
1084
1085
  throw x("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned.");
1085
1086
  }).then(() => {
1086
1087
  At().then(() => {
1087
- t(6, N = b.VERIFIED), t(7, G = !0), x("verified"), _e("verified", { payload: z });
1088
+ t(6, j = b.VERIFIED), t(7, G = !0), x("verified"), _e("verified", { payload: z });
1088
1089
  });
1089
1090
  }).catch((r) => {
1090
- x(r), t(6, N = b.ERROR), t(7, G = !1), t(10, ye = r.message);
1091
+ x(r), t(6, j = b.ERROR), t(7, G = !1), t(10, ye = r.message);
1091
1092
  });
1092
1093
  }
1093
1094
  function gt() {
@@ -1120,7 +1121,7 @@ function zt(n, e, t) {
1120
1121
  waitAlert: "Verifying... please wait.",
1121
1122
  ...l
1122
1123
  }), n.$$.dirty[0] & /*payload, state*/
1123
- 96 && _e("statechange", { payload: z, state: N }), n.$$.dirty[0] & /*state*/
1124
+ 96 && _e("statechange", { payload: z, state: j }), n.$$.dirty[0] & /*state*/
1124
1125
  64 && ut();
1125
1126
  }, [
1126
1127
  s,
@@ -1129,7 +1130,7 @@ function zt(n, e, t) {
1129
1130
  Q,
1130
1131
  Y,
1131
1132
  z,
1132
- N,
1133
+ j,
1133
1134
  G,
1134
1135
  p,
1135
1136
  J,
@@ -1 +1,2 @@
1
- (function(O,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(O=typeof globalThis<"u"?globalThis:O||self,D(O.altcha={}))})(this,function(O){"use strict";var Qt=Object.defineProperty;var en=(O,D,Z)=>D in O?Qt(O,D,{enumerable:!0,configurable:!0,writable:!0,value:Z}):O[D]=Z;var q=(O,D,Z)=>en(O,typeof D!="symbol"?D+"":D,Z);var D=typeof document<"u"?document.currentScript:null;function Z(){}function Re(n){return n()}function $e(){return Object.create(null)}function le(n){n.forEach(Re)}function Te(n){return typeof n=="function"}function ct(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function ut(n){return Object.keys(n).length===0}function v(n,e){n.appendChild(e)}function N(n,e,t){n.insertBefore(e,t||null)}function j(n){n.parentNode&&n.parentNode.removeChild(n)}function $(n){return document.createElement(n)}function W(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function at(n){return document.createTextNode(n)}function X(){return at(" ")}function ye(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function f(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function ht(n){return Array.from(n.childNodes)}function Se(n,e,t){n.classList.toggle(e,!!t)}function dt(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function gt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let se;function fe(n){se=n}function ke(){if(!se)throw new Error("Function called outside component initialization");return se}function mt(n){ke().$$.on_mount.push(n)}function bt(n){ke().$$.on_destroy.push(n)}function wt(){const n=ke();return(e,t,{cancelable:i=!1}={})=>{const l=n.$$.callbacks[e];if(l){const o=dt(e,t,{cancelable:i});return l.slice().forEach(s=>{s.call(n,o)}),!o.defaultPrevented}return!0}}const ne=[],he=[];let re=[];const Me=[],je=Promise.resolve();let ve=!1;function De(){ve||(ve=!0,je.then(w))}function _t(){return De(),je}function Ee(n){re.push(n)}const pe=new Set;let ie=0;function w(){if(ie!==0)return;const n=se;do{try{for(;ie<ne.length;){const e=ne[ie];ie++,fe(e),yt(e.$$)}}catch(e){throw ne.length=0,ie=0,e}for(fe(null),ne.length=0,ie=0;he.length;)he.pop()();for(let e=0;e<re.length;e+=1){const t=re[e];pe.has(t)||(pe.add(t),t())}re.length=0}while(ne.length);for(;Me.length;)Me.pop()();ve=!1,pe.clear(),fe(n)}function yt(n){if(n.fragment!==null){n.update(),le(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Ee)}}function kt(n){const e=[],t=[];re.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),re=e}const vt=new Set;function Et(n,e){n&&n.i&&(vt.delete(n),n.i(e))}function pt(n,e,t){const{fragment:i,after_update:l}=n.$$;i&&i.m(e,t),Ee(()=>{const o=n.$$.on_mount.map(Re).filter(Te);n.$$.on_destroy?n.$$.on_destroy.push(...o):le(o),n.$$.on_mount=[]}),l.forEach(Ee)}function xt(n,e){const t=n.$$;t.fragment!==null&&(kt(t.after_update),le(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Ct(n,e){n.$$.dirty[0]===-1&&(ne.push(n),De(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Lt(n,e,t,i,l,o,s=null,a=[-1]){const u=se;fe(n);const h=n.$$={fragment:null,ctx:[],props:o,update:Z,not_equal:l,bound:$e(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(u?u.$$.context:[])),callbacks:$e(),dirty:a,skip_bound:!1,root:e.target||u.$$.root};s&&s(h.root);let B=!1;if(h.ctx=t?t(n,e.props||{},(S,H,...E)=>{const U=E.length?E[0]:H;return h.ctx&&l(h.ctx[S],h.ctx[S]=U)&&(!h.skip_bound&&h.bound[S]&&h.bound[S](U),B&&Ct(n,S)),H}):[],h.update(),B=!0,le(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const S=ht(e.target);h.fragment&&h.fragment.l(S),S.forEach(j)}else h.fragment&&h.fragment.c();e.intro&&Et(n.$$.fragment),pt(n,e.target,e.anchor),w()}fe(u)}let Ne;typeof HTMLElement=="function"&&(Ne=class extends HTMLElement{constructor(e,t,i){super();q(this,"$$ctor");q(this,"$$s");q(this,"$$c");q(this,"$$cn",!1);q(this,"$$d",{});q(this,"$$r",!1);q(this,"$$p_d",{});q(this,"$$l",{});q(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const l=this.$$c.$on(e,t);this.$$l_u.set(t,l)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const l=this.$$l_u.get(t);l&&(l(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(o){return()=>{let s;return{c:function(){s=$("slot"),o!=="default"&&f(s,"name",o)},m:function(h,B){N(h,s,B)},d:function(h){h&&j(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=gt(this);for(const o of this.$$s)o in i&&(t[o]=[e(o)]);for(const o of this.attributes){const s=this.$$g_p(o.name);s in this.$$d||(this.$$d[s]=de(s,o.value,this.$$p_d,"toProp"))}for(const o in this.$$p_d)!(o in this.$$d)&&this[o]!==void 0&&(this.$$d[o]=this[o],delete this[o]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const l=()=>{this.$$r=!0;for(const o in this.$$p_d)if(this.$$d[o]=this.$$c.$$.ctx[this.$$c.$$.props[o]],this.$$p_d[o].reflect){const s=de(o,this.$$d[o],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[o].attribute||o):this.setAttribute(this.$$p_d[o].attribute||o,s)}this.$$r=!1};this.$$c.$$.after_update.push(l),l();for(const o in this.$$l)for(const s of this.$$l[o]){const a=this.$$c.$on(o,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,t,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=de(e,i,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function de(n,e,t,i){var o;const l=(o=t[n])==null?void 0:o.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(l){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(l){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function It(n,e,t,i,l,o){let s=class extends Ne{constructor(){super(n,t,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(u){var h;u=de(a,u,e),this.$$d[a]=u,(h=this.$$c)==null||h.$set({[a]:u})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var u;return(u=this.$$c)==null?void 0:u[a]}})}),o&&(s=o(s)),n.element=s,s}class At{constructor(){q(this,"$$");q(this,"$$set")}$destroy(){xt(this,1),this.$destroy=Z}$on(e,t){if(!Te(t))return Z;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const l=i.indexOf(t);l!==-1&&i.splice(l,1)}}$set(e){this.$$set&&!ut(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Rt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Rt);const $t=new TextEncoder;function Tt(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function St(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const l=await Ve(i,n,e);return{algorithm:e,challenge:l,salt:i,signature:""}}async function Ve(n,e,t){return Tt(await crypto.subtle.digest(t.toUpperCase(),$t.encode(n+e)))}function Mt(n,e,t="SHA-256",i=1e6,l=0){const o=new AbortController,s=Date.now();return{promise:(async()=>{for(let u=l;u<=i;u+=1){if(o.signal.aborted)return null;if(await Ve(e,u,t)===n)return{number:u,took:Date.now()-s}}return null})(),controller:o}}var m=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(m||{});function Pe(n){let e,t,i;return{c(){e=W("svg"),t=W("path"),i=W("path"),f(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"),f(t,"fill","currentColor"),f(t,"opacity",".25"),f(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"),f(i,"fill","currentColor"),f(i,"class","altcha-spinner"),f(e,"width","24"),f(e,"height","24"),f(e,"viewBox","0 0 24 24"),f(e,"xmlns","http://www.w3.org/2000/svg")},m(l,o){N(l,e,o),v(e,t),v(e,i)},d(l){l&&j(e)}}}function jt(n){let e,t=n[11].label+"",i;return{c(){e=$("label"),f(e,"for",i=n[4]+"_checkbox")},m(l,o){N(l,e,o),e.innerHTML=t},p(l,o){o[0]&2048&&t!==(t=l[11].label+"")&&(e.innerHTML=t),o[0]&16&&i!==(i=l[4]+"_checkbox")&&f(e,"for",i)},d(l){l&&j(e)}}}function Dt(n){let e,t=n[11].verifying+"";return{c(){e=$("span")},m(i,l){N(i,e,l),e.innerHTML=t},p(i,l){l[0]&2048&&t!==(t=i[11].verifying+"")&&(e.innerHTML=t)},d(i){i&&j(e)}}}function Nt(n){let e,t=n[11].verified+"",i,l;return{c(){e=$("span"),i=X(),l=$("input"),f(l,"type","hidden"),f(l,"name",n[4]),l.value=n[5]},m(o,s){N(o,e,s),e.innerHTML=t,N(o,i,s),N(o,l,s)},p(o,s){s[0]&2048&&t!==(t=o[11].verified+"")&&(e.innerHTML=t),s[0]&16&&f(l,"name",o[4]),s[0]&32&&(l.value=o[5])},d(o){o&&(j(e),j(i),j(l))}}}function Fe(n){let e,t,i,l,o,s,a;return{c(){e=$("div"),t=$("a"),i=W("svg"),l=W("path"),o=W("path"),s=W("path"),f(l,"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"),f(l,"fill","currentColor"),f(o,"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"),f(o,"fill","currentColor"),f(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"),f(s,"fill","currentColor"),f(i,"width","22"),f(i,"height","22"),f(i,"viewBox","0 0 20 20"),f(i,"fill","none"),f(i,"xmlns","http://www.w3.org/2000/svg"),f(t,"href",qe),f(t,"target","_blank"),f(t,"class","altcha-logo"),f(t,"aria-label",a=n[11].ariaLinkLabel)},m(u,h){N(u,e,h),v(e,t),v(t,i),v(i,l),v(i,o),v(i,s)},p(u,h){h[0]&2048&&a!==(a=u[11].ariaLinkLabel)&&f(t,"aria-label",a)},d(u){u&&j(e)}}}function He(n){let e,t,i,l;function o(u,h){return u[6]===m.EXPIRED?Pt:Vt}let s=o(n),a=s(n);return{c(){e=$("div"),t=W("svg"),i=W("path"),l=X(),a.c(),f(i,"stroke-linecap","round"),f(i,"stroke-linejoin","round"),f(i,"d","M6 18L18 6M6 6l12 12"),f(t,"width","14"),f(t,"height","14"),f(t,"xmlns","http://www.w3.org/2000/svg"),f(t,"fill","none"),f(t,"viewBox","0 0 24 24"),f(t,"stroke-width","1.5"),f(t,"stroke","currentColor"),f(e,"class","altcha-error")},m(u,h){N(u,e,h),v(e,t),v(t,i),v(e,l),a.m(e,null)},p(u,h){s===(s=o(u))&&a?a.p(u,h):(a.d(1),a=s(u),a&&(a.c(),a.m(e,null)))},d(u){u&&j(e),a.d()}}}function Vt(n){let e,t=n[11].error+"";return{c(){e=$("div"),f(e,"title",n[10])},m(i,l){N(i,e,l),e.innerHTML=t},p(i,l){l[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),l[0]&1024&&f(e,"title",i[10])},d(i){i&&j(e)}}}function Pt(n){let e,t=n[11].expired+"";return{c(){e=$("div"),f(e,"title",n[10])},m(i,l){N(i,e,l),e.innerHTML=t},p(i,l){l[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),l[0]&1024&&f(e,"title",i[10])},d(i){i&&j(e)}}}function Oe(n){let e,t,i=n[11].footer+"";return{c(){e=$("div"),t=$("div"),f(e,"class","altcha-footer")},m(l,o){N(l,e,o),v(e,t),t.innerHTML=i},p(l,o){o[0]&2048&&i!==(i=l[11].footer+"")&&(t.innerHTML=i)},d(l){l&&j(e)}}}function Be(n){let e;return{c(){e=$("div"),f(e,"class","altcha-anchor-arrow")},m(t,i){N(t,e,i),n[36](e)},p:Z,d(t){t&&j(e),n[36](null)}}}function Ft(n){let e,t,i,l,o,s,a,u,h,B,S,H,E,U,K,T=n[6]===m.VERIFYING&&Pe();function oe(d,y){return d[6]===m.VERIFIED?Nt:d[6]===m.VERIFYING?Dt:jt}let J=oe(n),M=J(n),L=n[3]!==!0&&Fe(n),I=(n[10]||n[6]===m.EXPIRED)&&He(n),_=n[11].footer&&n[2]!==!0&&Oe(n),A=n[1]&&Be(n);return{c(){e=$("div"),t=$("div"),T&&T.c(),i=X(),l=$("div"),o=$("input"),u=X(),h=$("div"),M.c(),B=X(),L&&L.c(),S=X(),I&&I.c(),H=X(),_&&_.c(),E=X(),A&&A.c(),f(o,"type","checkbox"),f(o,"id",s=n[4]+"_checkbox"),o.required=a=n[0]!=="onsubmit",f(l,"class","altcha-checkbox"),Se(l,"altcha-hidden",n[6]===m.VERIFYING),f(h,"class","altcha-label"),f(t,"class","altcha-main"),f(e,"class","altcha"),f(e,"data-state",n[6]),f(e,"data-floating",n[1])},m(d,y){N(d,e,y),v(e,t),T&&T.m(t,null),v(t,i),v(t,l),v(l,o),o.checked=n[7],v(t,u),v(t,h),M.m(h,null),v(t,B),L&&L.m(t,null),v(e,S),I&&I.m(e,null),v(e,H),_&&_.m(e,null),v(e,E),A&&A.m(e,null),n[37](e),U||(K=[ye(o,"change",n[35]),ye(o,"change",n[12]),ye(o,"invalid",n[13])],U=!0)},p(d,y){d[6]===m.VERIFYING?T||(T=Pe(),T.c(),T.m(t,i)):T&&(T.d(1),T=null),y[0]&16&&s!==(s=d[4]+"_checkbox")&&f(o,"id",s),y[0]&1&&a!==(a=d[0]!=="onsubmit")&&(o.required=a),y[0]&128&&(o.checked=d[7]),y[0]&64&&Se(l,"altcha-hidden",d[6]===m.VERIFYING),J===(J=oe(d))&&M?M.p(d,y):(M.d(1),M=J(d),M&&(M.c(),M.m(h,null))),d[3]!==!0?L?L.p(d,y):(L=Fe(d),L.c(),L.m(t,null)):L&&(L.d(1),L=null),d[10]||d[6]===m.EXPIRED?I?I.p(d,y):(I=He(d),I.c(),I.m(e,H)):I&&(I.d(1),I=null),d[11].footer&&d[2]!==!0?_?_.p(d,y):(_=Oe(d),_.c(),_.m(e,E)):_&&(_.d(1),_=null),d[1]?A?A.p(d,y):(A=Be(d),A.c(),A.m(e,null)):A&&(A.d(1),A=null),y[0]&64&&f(e,"data-state",d[6]),y[0]&2&&f(e,"data-floating",d[1])},i:Z,o:Z,d(d){d&&j(e),T&&T.d(),M.d(),L&&L.d(),I&&I.d(),_&&_.d(),A&&A.d(),n[37](null),U=!1,le(K)}}}const Ue="Visit Altcha.org",qe="https://altcha.org/";function Ze(n){return JSON.parse(n)}function Ht(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ot(n,e,t){var st,ft;let i,l,o,{auto:s=void 0}=e,{blockspam:a=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:h=void 0}=e,{debug:B=!1}=e,{delay:S=0}=e,{expire:H=void 0}=e,{floating:E=void 0}=e,{floatinganchor:U=void 0}=e,{floatingoffset:K=void 0}=e,{hidefooter:T=!1}=e,{hidelogo:oe=!1}=e,{name:J="altcha"}=e,{maxnumber:M=1e6}=e,{mockerror:L=!1}=e,{refetchonexpire:I=!0}=e,{spamfilter:_=!1}=e,{strings:A=void 0}=e,{test:d=!1}=e,{verifyurl:y=void 0}=e,{workers:ce=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:xe=void 0}=e;const Ce=wt(),Ge=["SHA-256","SHA-384","SHA-512"],We=(ft=(st=document.documentElement.lang)==null?void 0:st.split("-"))==null?void 0:ft[0];let z=!1,p,Q=null,ge=null,b=null,Le=null,ee=null,V=m.UNVERIFIED,Y=null;bt(()=>{b&&(b.removeEventListener("submit",Je),b.removeEventListener("reset",ze),b.removeEventListener("focusin",Xe),b=null),Y&&(clearTimeout(Y),Y=null),document.removeEventListener("click",tt),document.removeEventListener("scroll",nt),window.removeEventListener("resize",it)}),mt(()=>{x("mounted","0.6.2"),x("workers",ce),d&&x("using test mode"),H&&me(H),s!==void 0&&x("auto",s),E!==void 0&&ot(E),b=p.closest("form"),b&&(b.addEventListener("submit",Je,{capture:!0}),b.addEventListener("reset",ze),s==="onfocus"&&b.addEventListener("focusin",Xe)),s==="onload"&&te()});function x(...r){(B||r.some(c=>c instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",...r)}function Xe(r){V===m.UNVERIFIED&&te()}function Je(r){b&&s==="onsubmit"&&(V===m.UNVERIFIED?(r.preventDefault(),r.stopPropagation(),te().then(()=>{b==null||b.requestSubmit()})):V!==m.VERIFIED&&(r.preventDefault(),r.stopPropagation(),V===m.VERIFYING&&rt()))}function ze(){be()}function Ke(r,c){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:c.number,salt:r.salt,signature:r.signature,test:d?!0:void 0,took:c.took}))}function Qe(r){if(!r.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(r.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Ge.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ge.join(", ")}`);if(!r.challenge||r.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!r.salt||r.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function Bt(){var r;if(L)throw x("mocking error"),new Error("Mocked error.");if(i)return x("using provided json data"),i;if(d)return x("generating test challenge",{test:d}),St(typeof d!="boolean"?+d:void 0);{if(!u)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",u);const c=await fetch(u,{headers:{"x-altcha-spam-filter":_?"1":"0"}});if(c.status!==200)throw new Error(`Server responded with ${c.status}.`);const g=c.headers.get("Expires"),R=c.headers.get("X-Altcha-Config"),P=await c.json(),F=new URLSearchParams((r=P.salt.split("?"))==null?void 0:r[1]),G=F.get("expires")||F.get("expire");if(G){const k=new Date(+G*1e3),C=isNaN(k.getTime())?0:k.getTime()-Date.now();C>0&&me(C)}if(R)try{const k=JSON.parse(R);k&&typeof k=="object"&&(k.verifyurl&&(k.verifyurl=new URL(k.verifyurl,new URL(u)).toString()),lt(k))}catch(k){x("unable to configure from X-Altcha-Config",k)}if(!H&&(g!=null&&g.length)){const k=Date.parse(g);if(k){const C=k-Date.now();C>0&&me(C)}}return P}}function et(){u&&I&&V===m.VERIFIED?te():be(m.EXPIRED,o.expired)}async function Ut(r){let c=null;if("Worker"in window){try{c=await qt(r.challenge,r.salt,r.algorithm,r.maxnumber)}catch(g){x(g)}if((c==null?void 0:c.number)!==void 0)return{data:r,solution:c}}return{data:r,solution:await Mt(r.challenge,r.salt,r.algorithm,r.maxnumber||M).promise}}async function qt(r,c,g,R=typeof d=="number"?d:M,P=Math.ceil(ce)){const F=[];if(P<1)throw new Error("Wrong number of workers configured.");if(P>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let C=0;C<P;C++)F.push(createAltchaWorker(xe));const G=Math.ceil(R/P),k=await Promise.all(F.map((C,Ae)=>{const ue=Ae*G;return new Promise(we=>{C.addEventListener("message",_e=>{if(_e.data)for(const ae of F)ae!==C&&ae.postMessage({type:"abort"});we(_e.data)}),C.postMessage({payload:{alg:g,challenge:r,max:ue+G,salt:c,start:ue},type:"work"})})}));for(const C of F)C.terminate();return k.find(C=>!!C)||null}function Zt(){[m.UNVERIFIED,m.ERROR,m.EXPIRED].includes(V)?_&&(b==null?void 0:b.reportValidity())===!1?t(7,z=!1):te():t(7,z=!0)}function tt(r){const c=r.target;E&&c&&!p.contains(c)&&V===m.VERIFIED&&t(8,p.style.display="none",p)}function nt(){E&&Ie()}function rt(){V===m.VERIFYING&&o.waitAlert&&alert(o.waitAlert)}function Yt(r){E&&V!==m.UNVERIFIED&&requestAnimationFrame(()=>{Ie()})}function it(){E&&Ie()}function me(r){x("expire",r),Y&&(clearTimeout(Y),Y=null),r<1?et():Y=setTimeout(et,r)}function ot(r){x("floating",r),E!==r&&(t(8,p.style.left="",p),t(8,p.style.top="",p)),t(1,E=r===!0||r===""?"auto":r===!1||r==="false"?void 0:E),E?(s||t(0,s="onsubmit"),document.addEventListener("scroll",nt),document.addEventListener("click",tt),window.addEventListener("resize",it)):s==="onsubmit"&&t(0,s=void 0)}function Gt(r){var g;const c=b==null?void 0:b.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((g=c==null?void 0:c.value)==null?void 0:g.slice(c.value.indexOf("@")))||void 0}function Wt(r){return[...(b==null?void 0:b.querySelectorAll(r!=null&&r.length?r.map(g=>`input[name="${g}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((g,R)=>{const P=R.name,F=R.value.trim();return P&&F&&(g[P]=F),g},{})}async function Xt(r){if(!y)throw new Error("Attribute verifyurl not set.");x("requesting server verification from",y);const c={payload:r};if(_){const{blockedCountries:P,classifier:F,disableRules:G,email:k,expectedLanguages:C,expectedCountries:Ae,fields:ue,ipAddress:we,text:_e,timeZone:ae}=typeof _=="object"?_:{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,text:void 0,timeZone:void 0};c.blockedCountries=P,c.classifier=F,c.disableRules=G,c.email=k===!1?void 0:Gt(k),c.expectedCountries=Ae,c.expectedLanguages=C||(We?[We]:void 0),c.fields=ue===!1?void 0:Wt(ue),c.ipAddress=we===!1?void 0:we||"auto",c.text=_e,c.timeZone=ae===!1?void 0:ae||Ht()}const g=await fetch(y,{body:JSON.stringify(c),headers:{"content-type":"application/json"},method:"POST"});if(g.status!==200)throw new Error(`Server responded with ${g.status}.`);const R=await g.json();if(R!=null&&R.payload&&t(5,ee=R.payload),Ce("serververification",R),a&&R.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Ie(r=20){if(p)if(ge||(ge=(U?document.querySelector(U):b==null?void 0:b.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])'))||b),ge){const c=parseInt(K,10)||12,g=ge.getBoundingClientRect(),R=p.getBoundingClientRect(),P=document.documentElement.clientHeight,F=document.documentElement.clientWidth,G=E==="auto"?g.bottom+R.height+c+r>P:E==="top",k=Math.max(r,Math.min(F-r-R.width,g.left+g.width/2-R.width/2));if(G?t(8,p.style.top=`${g.top-(R.height+c)}px`,p):t(8,p.style.top=`${g.bottom+c}px`,p),t(8,p.style.left=`${k}px`,p),p.setAttribute("data-floating",G?"top":"bottom"),Q){const C=Q.getBoundingClientRect();t(9,Q.style.left=g.left-k+g.width/2-C.width/2+"px",Q)}}else x("unable to find floating anchor element")}function lt(r){r.auto!==void 0&&(t(0,s=r.auto),s==="onload"&&te()),r.floatinganchor!==void 0&&t(18,U=r.floatinganchor),r.delay!==void 0&&t(16,S=r.delay),r.floatingoffset!==void 0&&t(19,K=r.floatingoffset),r.floating!==void 0&&ot(r.floating),r.expire!==void 0&&(me(r.expire),t(17,H=r.expire)),r.challenge&&(Qe(r.challenge),i=r.challenge),r.challengeurl!==void 0&&t(14,u=r.challengeurl),r.debug!==void 0&&t(15,B=!!r.debug),r.hidefooter!==void 0&&t(2,T=!!r.hidefooter),r.hidelogo!==void 0&&t(3,oe=!!r.hidelogo),r.maxnumber!==void 0&&t(20,M=+r.maxnumber),r.mockerror!==void 0&&t(21,L=!!r.mockerror),r.name!==void 0&&t(4,J=r.name),r.refetchonexpire!==void 0&&t(22,I=!!r.refetchonexpire),r.spamfilter!==void 0&&t(23,_=typeof r.spamfilter=="object"?r.spamfilter:!!r.spamfilter),r.strings&&t(34,l=r.strings),r.test!==void 0&&t(24,d=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(25,y=r.verifyurl),r.workers!==void 0&&t(26,ce=+r.workers)}function be(r=m.UNVERIFIED,c=null){Y&&(clearTimeout(Y),Y=null),t(7,z=!1),t(10,Le=c),t(5,ee=null),t(6,V=r)}async function te(){return be(m.VERIFYING),await new Promise(r=>setTimeout(r,S||0)),Bt().then(r=>(Qe(r),x("challenge",r),Ut(r))).then(({data:r,solution:c})=>{if(x("solution",c),(c==null?void 0:c.number)!==void 0){if(y)return Xt(Ke(r,c));t(5,ee=Ke(r,c)),x("payload",ee)}else throw x("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{_t().then(()=>{t(6,V=m.VERIFIED),t(7,z=!0),x("verified"),Ce("verified",{payload:ee})})}).catch(r=>{x(r),t(6,V=m.ERROR),t(7,z=!1),t(10,Le=r.message)})}function Jt(){z=this.checked,t(7,z)}function zt(r){he[r?"unshift":"push"](()=>{Q=r,t(9,Q)})}function Kt(r){he[r?"unshift":"push"](()=>{p=r,t(8,p)})}return n.$$set=r=>{"auto"in r&&t(0,s=r.auto),"blockspam"in r&&t(27,a=r.blockspam),"challengeurl"in r&&t(14,u=r.challengeurl),"challengejson"in r&&t(28,h=r.challengejson),"debug"in r&&t(15,B=r.debug),"delay"in r&&t(16,S=r.delay),"expire"in r&&t(17,H=r.expire),"floating"in r&&t(1,E=r.floating),"floatinganchor"in r&&t(18,U=r.floatinganchor),"floatingoffset"in r&&t(19,K=r.floatingoffset),"hidefooter"in r&&t(2,T=r.hidefooter),"hidelogo"in r&&t(3,oe=r.hidelogo),"name"in r&&t(4,J=r.name),"maxnumber"in r&&t(20,M=r.maxnumber),"mockerror"in r&&t(21,L=r.mockerror),"refetchonexpire"in r&&t(22,I=r.refetchonexpire),"spamfilter"in r&&t(23,_=r.spamfilter),"strings"in r&&t(29,A=r.strings),"test"in r&&t(24,d=r.test),"verifyurl"in r&&t(25,y=r.verifyurl),"workers"in r&&t(26,ce=r.workers),"workerurl"in r&&t(30,xe=r.workerurl)},n.$$.update=()=>{n.$$.dirty[0]&268435456&&(i=h?Ze(h):void 0),n.$$.dirty[0]&536870912&&t(34,l=A?Ze(A):{}),n.$$.dirty[1]&8&&t(11,o={ariaLinkLabel:Ue,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by <a href="${qe}" target="_blank" aria-label="${l.ariaLinkLabel||Ue}">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),n.$$.dirty[0]&96&&Ce("statechange",{payload:ee,state:V}),n.$$.dirty[0]&64&&Yt()},[s,E,T,oe,J,ee,V,z,p,Q,Le,o,Zt,rt,u,B,S,H,U,K,M,L,I,_,d,y,ce,a,h,A,xe,lt,be,te,l,Jt,zt,Kt]}class Ye extends At{constructor(e){super(),Lt(this,e,Ot,Ft,ct,{auto:0,blockspam:27,challengeurl:14,challengejson:28,debug:15,delay:16,expire:17,floating:1,floatinganchor:18,floatingoffset:19,hidefooter:2,hidelogo:3,name:4,maxnumber:20,mockerror:21,refetchonexpire:22,spamfilter:23,strings:29,test:24,verifyurl:25,workers:26,workerurl:30,configure:31,reset:32,verify:33},null,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[27]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[14]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[28]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[15]}set debug(e){this.$$set({debug:e}),w()}get delay(){return this.$$.ctx[16]}set delay(e){this.$$set({delay:e}),w()}get expire(){return this.$$.ctx[17]}set expire(e){this.$$set({expire:e}),w()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),w()}get floatinganchor(){return this.$$.ctx[18]}set floatinganchor(e){this.$$set({floatinganchor:e}),w()}get floatingoffset(){return this.$$.ctx[19]}set floatingoffset(e){this.$$set({floatingoffset:e}),w()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),w()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),w()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),w()}get maxnumber(){return this.$$.ctx[20]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[21]}set mockerror(e){this.$$set({mockerror:e}),w()}get refetchonexpire(){return this.$$.ctx[22]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[23]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[29]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[24]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[25]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[26]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[30]}set workerurl(e){this.$$set({workerurl:e}),w()}get configure(){return this.$$.ctx[31]}get reset(){return this.$$.ctx[32]}get verify(){return this.$$.ctx[33]}}customElements.define("altcha-widget",It(Ye,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=n=>new Worker(new URL(n||"./worker.js",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:D&&D.src||new URL("altcha.umd.cjs",document.baseURI).href)),O.Altcha=Ye,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
1
+ (function(O,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(O=typeof globalThis<"u"?globalThis:O||self,N(O.altcha={}))})(this,function(O){"use strict";var Qt=Object.defineProperty;var en=(O,N,Z)=>N in O?Qt(O,N,{enumerable:!0,configurable:!0,writable:!0,value:Z}):O[N]=Z;var q=(O,N,Z)=>en(O,typeof N!="symbol"?N+"":N,Z);var N=typeof document<"u"?document.currentScript:null;function Z(){}function Re(n){return n()}function $e(){return Object.create(null)}function le(n){n.forEach(Re)}function Te(n){return typeof n=="function"}function ct(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function ut(n){return Object.keys(n).length===0}function v(n,e){n.appendChild(e)}function V(n,e,t){n.insertBefore(e,t||null)}function D(n){n.parentNode&&n.parentNode.removeChild(n)}function $(n){return document.createElement(n)}function W(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function at(n){return document.createTextNode(n)}function X(){return at(" ")}function ye(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function f(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function ht(n){return Array.from(n.childNodes)}function Se(n,e,t){n.classList.toggle(e,!!t)}function dt(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function gt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let se;function fe(n){se=n}function ke(){if(!se)throw new Error("Function called outside component initialization");return se}function mt(n){ke().$$.on_mount.push(n)}function bt(n){ke().$$.on_destroy.push(n)}function wt(){const n=ke();return(e,t,{cancelable:i=!1}={})=>{const l=n.$$.callbacks[e];if(l){const o=dt(e,t,{cancelable:i});return l.slice().forEach(s=>{s.call(n,o)}),!o.defaultPrevented}return!0}}const ne=[],he=[];let re=[];const Me=[],je=Promise.resolve();let ve=!1;function De(){ve||(ve=!0,je.then(w))}function _t(){return De(),je}function Ee(n){re.push(n)}const pe=new Set;let ie=0;function w(){if(ie!==0)return;const n=se;do{try{for(;ie<ne.length;){const e=ne[ie];ie++,fe(e),yt(e.$$)}}catch(e){throw ne.length=0,ie=0,e}for(fe(null),ne.length=0,ie=0;he.length;)he.pop()();for(let e=0;e<re.length;e+=1){const t=re[e];pe.has(t)||(pe.add(t),t())}re.length=0}while(ne.length);for(;Me.length;)Me.pop()();ve=!1,pe.clear(),fe(n)}function yt(n){if(n.fragment!==null){n.update(),le(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Ee)}}function kt(n){const e=[],t=[];re.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),re=e}const vt=new Set;function Et(n,e){n&&n.i&&(vt.delete(n),n.i(e))}function pt(n,e,t){const{fragment:i,after_update:l}=n.$$;i&&i.m(e,t),Ee(()=>{const o=n.$$.on_mount.map(Re).filter(Te);n.$$.on_destroy?n.$$.on_destroy.push(...o):le(o),n.$$.on_mount=[]}),l.forEach(Ee)}function xt(n,e){const t=n.$$;t.fragment!==null&&(kt(t.after_update),le(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Ct(n,e){n.$$.dirty[0]===-1&&(ne.push(n),De(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Lt(n,e,t,i,l,o,s=null,a=[-1]){const u=se;fe(n);const h=n.$$={fragment:null,ctx:[],props:o,update:Z,not_equal:l,bound:$e(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(u?u.$$.context:[])),callbacks:$e(),dirty:a,skip_bound:!1,root:e.target||u.$$.root};s&&s(h.root);let B=!1;if(h.ctx=t?t(n,e.props||{},(S,H,...E)=>{const U=E.length?E[0]:H;return h.ctx&&l(h.ctx[S],h.ctx[S]=U)&&(!h.skip_bound&&h.bound[S]&&h.bound[S](U),B&&Ct(n,S)),H}):[],h.update(),B=!0,le(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const S=ht(e.target);h.fragment&&h.fragment.l(S),S.forEach(D)}else h.fragment&&h.fragment.c();e.intro&&Et(n.$$.fragment),pt(n,e.target,e.anchor),w()}fe(u)}let Ne;typeof HTMLElement=="function"&&(Ne=class extends HTMLElement{constructor(e,t,i){super();q(this,"$$ctor");q(this,"$$s");q(this,"$$c");q(this,"$$cn",!1);q(this,"$$d",{});q(this,"$$r",!1);q(this,"$$p_d",{});q(this,"$$l",{});q(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const l=this.$$c.$on(e,t);this.$$l_u.set(t,l)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const l=this.$$l_u.get(t);l&&(l(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(o){return()=>{let s;return{c:function(){s=$("slot"),o!=="default"&&f(s,"name",o)},m:function(h,B){V(h,s,B)},d:function(h){h&&D(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=gt(this);for(const o of this.$$s)o in i&&(t[o]=[e(o)]);for(const o of this.attributes){const s=this.$$g_p(o.name);s in this.$$d||(this.$$d[s]=de(s,o.value,this.$$p_d,"toProp"))}for(const o in this.$$p_d)!(o in this.$$d)&&this[o]!==void 0&&(this.$$d[o]=this[o],delete this[o]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const l=()=>{this.$$r=!0;for(const o in this.$$p_d)if(this.$$d[o]=this.$$c.$$.ctx[this.$$c.$$.props[o]],this.$$p_d[o].reflect){const s=de(o,this.$$d[o],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[o].attribute||o):this.setAttribute(this.$$p_d[o].attribute||o,s)}this.$$r=!1};this.$$c.$$.after_update.push(l),l();for(const o in this.$$l)for(const s of this.$$l[o]){const a=this.$$c.$on(o,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,t,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=de(e,i,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function de(n,e,t,i){var o;const l=(o=t[n])==null?void 0:o.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(l){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(l){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function It(n,e,t,i,l,o){let s=class extends Ne{constructor(){super(n,t,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(u){var h;u=de(a,u,e),this.$$d[a]=u,(h=this.$$c)==null||h.$set({[a]:u})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var u;return(u=this.$$c)==null?void 0:u[a]}})}),o&&(s=o(s)),n.element=s,s}class At{constructor(){q(this,"$$");q(this,"$$set")}$destroy(){xt(this,1),this.$destroy=Z}$on(e,t){if(!Te(t))return Z;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const l=i.indexOf(t);l!==-1&&i.splice(l,1)}}$set(e){this.$$set&&!ut(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Rt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Rt);const $t=new TextEncoder;function Tt(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function St(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const l=await Ve(i,n,e);return{algorithm:e,challenge:l,salt:i,signature:""}}async function Ve(n,e,t){return Tt(await crypto.subtle.digest(t.toUpperCase(),$t.encode(n+e)))}function Mt(n,e,t="SHA-256",i=1e6,l=0){const o=new AbortController,s=Date.now();return{promise:(async()=>{for(let u=l;u<=i;u+=1){if(o.signal.aborted)return null;if(await Ve(e,u,t)===n)return{number:u,took:Date.now()-s}}return null})(),controller:o}}var m=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(m||{});function Pe(n){let e,t,i;return{c(){e=W("svg"),t=W("path"),i=W("path"),f(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"),f(t,"fill","currentColor"),f(t,"opacity",".25"),f(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"),f(i,"fill","currentColor"),f(i,"class","altcha-spinner"),f(e,"width","24"),f(e,"height","24"),f(e,"viewBox","0 0 24 24"),f(e,"xmlns","http://www.w3.org/2000/svg")},m(l,o){V(l,e,o),v(e,t),v(e,i)},d(l){l&&D(e)}}}function jt(n){let e,t=n[11].label+"",i;return{c(){e=$("label"),f(e,"for",i=n[4]+"_checkbox")},m(l,o){V(l,e,o),e.innerHTML=t},p(l,o){o[0]&2048&&t!==(t=l[11].label+"")&&(e.innerHTML=t),o[0]&16&&i!==(i=l[4]+"_checkbox")&&f(e,"for",i)},d(l){l&&D(e)}}}function Dt(n){let e,t=n[11].verifying+"";return{c(){e=$("span")},m(i,l){V(i,e,l),e.innerHTML=t},p(i,l){l[0]&2048&&t!==(t=i[11].verifying+"")&&(e.innerHTML=t)},d(i){i&&D(e)}}}function Nt(n){let e,t=n[11].verified+"",i,l;return{c(){e=$("span"),i=X(),l=$("input"),f(l,"type","hidden"),f(l,"name",n[4]),l.value=n[5]},m(o,s){V(o,e,s),e.innerHTML=t,V(o,i,s),V(o,l,s)},p(o,s){s[0]&2048&&t!==(t=o[11].verified+"")&&(e.innerHTML=t),s[0]&16&&f(l,"name",o[4]),s[0]&32&&(l.value=o[5])},d(o){o&&(D(e),D(i),D(l))}}}function Fe(n){let e,t,i,l,o,s,a;return{c(){e=$("div"),t=$("a"),i=W("svg"),l=W("path"),o=W("path"),s=W("path"),f(l,"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"),f(l,"fill","currentColor"),f(o,"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"),f(o,"fill","currentColor"),f(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"),f(s,"fill","currentColor"),f(i,"width","22"),f(i,"height","22"),f(i,"viewBox","0 0 20 20"),f(i,"fill","none"),f(i,"xmlns","http://www.w3.org/2000/svg"),f(t,"href",qe),f(t,"target","_blank"),f(t,"class","altcha-logo"),f(t,"aria-label",a=n[11].ariaLinkLabel)},m(u,h){V(u,e,h),v(e,t),v(t,i),v(i,l),v(i,o),v(i,s)},p(u,h){h[0]&2048&&a!==(a=u[11].ariaLinkLabel)&&f(t,"aria-label",a)},d(u){u&&D(e)}}}function He(n){let e,t,i,l;function o(u,h){return u[6]===m.EXPIRED?Pt:Vt}let s=o(n),a=s(n);return{c(){e=$("div"),t=W("svg"),i=W("path"),l=X(),a.c(),f(i,"stroke-linecap","round"),f(i,"stroke-linejoin","round"),f(i,"d","M6 18L18 6M6 6l12 12"),f(t,"width","14"),f(t,"height","14"),f(t,"xmlns","http://www.w3.org/2000/svg"),f(t,"fill","none"),f(t,"viewBox","0 0 24 24"),f(t,"stroke-width","1.5"),f(t,"stroke","currentColor"),f(e,"class","altcha-error")},m(u,h){V(u,e,h),v(e,t),v(t,i),v(e,l),a.m(e,null)},p(u,h){s===(s=o(u))&&a?a.p(u,h):(a.d(1),a=s(u),a&&(a.c(),a.m(e,null)))},d(u){u&&D(e),a.d()}}}function Vt(n){let e,t=n[11].error+"";return{c(){e=$("div"),f(e,"title",n[10])},m(i,l){V(i,e,l),e.innerHTML=t},p(i,l){l[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),l[0]&1024&&f(e,"title",i[10])},d(i){i&&D(e)}}}function Pt(n){let e,t=n[11].expired+"";return{c(){e=$("div"),f(e,"title",n[10])},m(i,l){V(i,e,l),e.innerHTML=t},p(i,l){l[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),l[0]&1024&&f(e,"title",i[10])},d(i){i&&D(e)}}}function Oe(n){let e,t,i=n[11].footer+"";return{c(){e=$("div"),t=$("div"),f(e,"class","altcha-footer")},m(l,o){V(l,e,o),v(e,t),t.innerHTML=i},p(l,o){o[0]&2048&&i!==(i=l[11].footer+"")&&(t.innerHTML=i)},d(l){l&&D(e)}}}function Be(n){let e;return{c(){e=$("div"),f(e,"class","altcha-anchor-arrow")},m(t,i){V(t,e,i),n[36](e)},p:Z,d(t){t&&D(e),n[36](null)}}}function Ft(n){let e,t,i,l,o,s,a,u,h,B,S,H,E,U,K,T=n[6]===m.VERIFYING&&Pe();function oe(d,y){return d[6]===m.VERIFIED?Nt:d[6]===m.VERIFYING?Dt:jt}let J=oe(n),M=J(n),L=n[3]!==!0&&Fe(n),I=(n[10]||n[6]===m.EXPIRED)&&He(n),_=n[11].footer&&n[2]!==!0&&Oe(n),A=n[1]&&Be(n);return{c(){e=$("div"),t=$("div"),T&&T.c(),i=X(),l=$("div"),o=$("input"),u=X(),h=$("div"),M.c(),B=X(),L&&L.c(),S=X(),I&&I.c(),H=X(),_&&_.c(),E=X(),A&&A.c(),f(o,"type","checkbox"),f(o,"id",s=n[4]+"_checkbox"),o.required=a=n[0]!=="onsubmit",f(l,"class","altcha-checkbox"),Se(l,"altcha-hidden",n[6]===m.VERIFYING),f(h,"class","altcha-label"),f(t,"class","altcha-main"),f(e,"class","altcha"),f(e,"data-state",n[6]),f(e,"data-floating",n[1])},m(d,y){V(d,e,y),v(e,t),T&&T.m(t,null),v(t,i),v(t,l),v(l,o),o.checked=n[7],v(t,u),v(t,h),M.m(h,null),v(t,B),L&&L.m(t,null),v(e,S),I&&I.m(e,null),v(e,H),_&&_.m(e,null),v(e,E),A&&A.m(e,null),n[37](e),U||(K=[ye(o,"change",n[35]),ye(o,"change",n[12]),ye(o,"invalid",n[13])],U=!0)},p(d,y){d[6]===m.VERIFYING?T||(T=Pe(),T.c(),T.m(t,i)):T&&(T.d(1),T=null),y[0]&16&&s!==(s=d[4]+"_checkbox")&&f(o,"id",s),y[0]&1&&a!==(a=d[0]!=="onsubmit")&&(o.required=a),y[0]&128&&(o.checked=d[7]),y[0]&64&&Se(l,"altcha-hidden",d[6]===m.VERIFYING),J===(J=oe(d))&&M?M.p(d,y):(M.d(1),M=J(d),M&&(M.c(),M.m(h,null))),d[3]!==!0?L?L.p(d,y):(L=Fe(d),L.c(),L.m(t,null)):L&&(L.d(1),L=null),d[10]||d[6]===m.EXPIRED?I?I.p(d,y):(I=He(d),I.c(),I.m(e,H)):I&&(I.d(1),I=null),d[11].footer&&d[2]!==!0?_?_.p(d,y):(_=Oe(d),_.c(),_.m(e,E)):_&&(_.d(1),_=null),d[1]?A?A.p(d,y):(A=Be(d),A.c(),A.m(e,null)):A&&(A.d(1),A=null),y[0]&64&&f(e,"data-state",d[6]),y[0]&2&&f(e,"data-floating",d[1])},i:Z,o:Z,d(d){d&&D(e),T&&T.d(),M.d(),L&&L.d(),I&&I.d(),_&&_.d(),A&&A.d(),n[37](null),U=!1,le(K)}}}const Ue="Visit Altcha.org",qe="https://altcha.org/";function Ze(n){return JSON.parse(n)}function Ht(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ot(n,e,t){var st,ft;let i,l,o,{auto:s=void 0}=e,{blockspam:a=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:h=void 0}=e,{debug:B=!1}=e,{delay:S=0}=e,{expire:H=void 0}=e,{floating:E=void 0}=e,{floatinganchor:U=void 0}=e,{floatingoffset:K=void 0}=e,{hidefooter:T=!1}=e,{hidelogo:oe=!1}=e,{name:J="altcha"}=e,{maxnumber:M=1e6}=e,{mockerror:L=!1}=e,{refetchonexpire:I=!0}=e,{spamfilter:_=!1}=e,{strings:A=void 0}=e,{test:d=!1}=e,{verifyurl:y=void 0}=e,{workers:ce=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:xe=void 0}=e;const Ce=wt(),Ge=["SHA-256","SHA-384","SHA-512"],We=(ft=(st=document.documentElement.lang)==null?void 0:st.split("-"))==null?void 0:ft[0];let z=!1,p,Q=null,ge=null,b=null,Le=null,ee=null,P=m.UNVERIFIED,Y=null;bt(()=>{b&&(b.removeEventListener("submit",Je),b.removeEventListener("reset",ze),b.removeEventListener("focusin",Xe),b=null),Y&&(clearTimeout(Y),Y=null),document.removeEventListener("click",tt),document.removeEventListener("scroll",nt),window.removeEventListener("resize",it)}),mt(()=>{x("mounted","0.6.3"),x("workers",ce),d&&x("using test mode"),H&&me(H),s!==void 0&&x("auto",s),E!==void 0&&ot(E),b=p.closest("form"),b&&(b.addEventListener("submit",Je,{capture:!0}),b.addEventListener("reset",ze),s==="onfocus"&&b.addEventListener("focusin",Xe)),s==="onload"&&te()});function x(...r){(B||r.some(c=>c instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",...r)}function Xe(r){P===m.UNVERIFIED&&te()}function Je(r){b&&s==="onsubmit"&&(P===m.UNVERIFIED?(r.preventDefault(),r.stopPropagation(),te().then(()=>{b==null||b.requestSubmit()})):P!==m.VERIFIED&&(r.preventDefault(),r.stopPropagation(),P===m.VERIFYING&&rt()))}function ze(){be()}function Ke(r,c){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:c.number,salt:r.salt,signature:r.signature,test:d?!0:void 0,took:c.took}))}function Qe(r){if(!r.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(r.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!Ge.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${Ge.join(", ")}`);if(!r.challenge||r.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!r.salt||r.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function Bt(){var r;if(L)throw x("mocking error"),new Error("Mocked error.");if(i)return x("using provided json data"),i;if(d)return x("generating test challenge",{test:d}),St(typeof d!="boolean"?+d:void 0);{if(!u)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",u);const c=await fetch(u,{headers:{"x-altcha-spam-filter":_?"1":"0"}});if(c.status!==200)throw new Error(`Server responded with ${c.status}.`);const g=c.headers.get("Expires"),R=c.headers.get("X-Altcha-Config"),F=await c.json(),j=new URLSearchParams((r=F.salt.split("?"))==null?void 0:r[1]),G=j.get("expires")||j.get("expire");if(G){const k=new Date(+G*1e3),C=isNaN(k.getTime())?0:k.getTime()-Date.now();C>0&&me(C)}if(R)try{const k=JSON.parse(R);k&&typeof k=="object"&&(k.verifyurl&&(k.verifyurl=new URL(k.verifyurl,new URL(u)).toString()),lt(k))}catch(k){x("unable to configure from X-Altcha-Config",k)}if(!H&&(g!=null&&g.length)){const k=Date.parse(g);if(k){const C=k-Date.now();C>0&&me(C)}}return F}}function et(){u&&I&&P===m.VERIFIED?te():be(m.EXPIRED,o.expired)}async function Ut(r){let c=null;if("Worker"in window){try{c=await qt(r.challenge,r.salt,r.algorithm,r.maxnumber)}catch(g){x(g)}if((c==null?void 0:c.number)!==void 0)return{data:r,solution:c}}return{data:r,solution:await Mt(r.challenge,r.salt,r.algorithm,r.maxnumber||M).promise}}async function qt(r,c,g,R=typeof d=="number"?d:M,F=Math.ceil(ce)){const j=[];if(F<1)throw new Error("Wrong number of workers configured.");if(F>16)throw new Error("Too many workers. Max. 16 allowed workers.");for(let C=0;C<F;C++)j.push(createAltchaWorker(xe));const G=Math.ceil(R/F),k=await Promise.all(j.map((C,Ae)=>{const ue=Ae*G;return new Promise(we=>{C.addEventListener("message",_e=>{if(_e.data)for(const ae of j)ae!==C&&ae.postMessage({type:"abort"});we(_e.data)}),C.postMessage({payload:{alg:g,challenge:r,max:ue+G,salt:c,start:ue},type:"work"})})}));for(const C of j)C.terminate();return k.find(C=>!!C)||null}function Zt(){[m.UNVERIFIED,m.ERROR,m.EXPIRED].includes(P)?_&&(b==null?void 0:b.reportValidity())===!1?t(7,z=!1):te():t(7,z=!0)}function tt(r){const c=r.target;E&&c&&!p.contains(c)&&P===m.VERIFIED&&t(8,p.style.display="none",p)}function nt(){E&&Ie()}function rt(){P===m.VERIFYING&&o.waitAlert&&alert(o.waitAlert)}function Yt(r){E&&P!==m.UNVERIFIED&&requestAnimationFrame(()=>{Ie()})}function it(){E&&Ie()}function me(r){x("expire",r),Y&&(clearTimeout(Y),Y=null),r<1?et():Y=setTimeout(et,r)}function ot(r){x("floating",r),E!==r&&(t(8,p.style.left="",p),t(8,p.style.top="",p)),t(1,E=r===!0||r===""?"auto":r===!1||r==="false"?void 0:E),E?(s||t(0,s="onsubmit"),document.addEventListener("scroll",nt),document.addEventListener("click",tt),window.addEventListener("resize",it)):s==="onsubmit"&&t(0,s=void 0)}function Gt(r){var g;const c=b==null?void 0:b.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((g=c==null?void 0:c.value)==null?void 0:g.slice(c.value.indexOf("@")))||void 0}function Wt(r){return[...(b==null?void 0:b.querySelectorAll(r!=null&&r.length?r.map(g=>`input[name="${g}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((g,R)=>{const F=R.name,j=R.value;return F&&j&&(g[F]=/\n/.test(j)?j.replace(new RegExp("(?<!\\r)\\n","g"),`\r
2
+ `):j),g},{})}async function Xt(r){if(!y)throw new Error("Attribute verifyurl not set.");x("requesting server verification from",y);const c={payload:r};if(_){const{blockedCountries:F,classifier:j,disableRules:G,email:k,expectedLanguages:C,expectedCountries:Ae,fields:ue,ipAddress:we,text:_e,timeZone:ae}=typeof _=="object"?_:{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,text:void 0,timeZone:void 0};c.blockedCountries=F,c.classifier=j,c.disableRules=G,c.email=k===!1?void 0:Gt(k),c.expectedCountries=Ae,c.expectedLanguages=C||(We?[We]:void 0),c.fields=ue===!1?void 0:Wt(ue),c.ipAddress=we===!1?void 0:we||"auto",c.text=_e,c.timeZone=ae===!1?void 0:ae||Ht()}const g=await fetch(y,{body:JSON.stringify(c),headers:{"content-type":"application/json"},method:"POST"});if(g.status!==200)throw new Error(`Server responded with ${g.status}.`);const R=await g.json();if(R!=null&&R.payload&&t(5,ee=R.payload),Ce("serververification",R),a&&R.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Ie(r=20){if(p)if(ge||(ge=(U?document.querySelector(U):b==null?void 0:b.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])'))||b),ge){const c=parseInt(K,10)||12,g=ge.getBoundingClientRect(),R=p.getBoundingClientRect(),F=document.documentElement.clientHeight,j=document.documentElement.clientWidth,G=E==="auto"?g.bottom+R.height+c+r>F:E==="top",k=Math.max(r,Math.min(j-r-R.width,g.left+g.width/2-R.width/2));if(G?t(8,p.style.top=`${g.top-(R.height+c)}px`,p):t(8,p.style.top=`${g.bottom+c}px`,p),t(8,p.style.left=`${k}px`,p),p.setAttribute("data-floating",G?"top":"bottom"),Q){const C=Q.getBoundingClientRect();t(9,Q.style.left=g.left-k+g.width/2-C.width/2+"px",Q)}}else x("unable to find floating anchor element")}function lt(r){r.auto!==void 0&&(t(0,s=r.auto),s==="onload"&&te()),r.floatinganchor!==void 0&&t(18,U=r.floatinganchor),r.delay!==void 0&&t(16,S=r.delay),r.floatingoffset!==void 0&&t(19,K=r.floatingoffset),r.floating!==void 0&&ot(r.floating),r.expire!==void 0&&(me(r.expire),t(17,H=r.expire)),r.challenge&&(Qe(r.challenge),i=r.challenge),r.challengeurl!==void 0&&t(14,u=r.challengeurl),r.debug!==void 0&&t(15,B=!!r.debug),r.hidefooter!==void 0&&t(2,T=!!r.hidefooter),r.hidelogo!==void 0&&t(3,oe=!!r.hidelogo),r.maxnumber!==void 0&&t(20,M=+r.maxnumber),r.mockerror!==void 0&&t(21,L=!!r.mockerror),r.name!==void 0&&t(4,J=r.name),r.refetchonexpire!==void 0&&t(22,I=!!r.refetchonexpire),r.spamfilter!==void 0&&t(23,_=typeof r.spamfilter=="object"?r.spamfilter:!!r.spamfilter),r.strings&&t(34,l=r.strings),r.test!==void 0&&t(24,d=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(25,y=r.verifyurl),r.workers!==void 0&&t(26,ce=+r.workers)}function be(r=m.UNVERIFIED,c=null){Y&&(clearTimeout(Y),Y=null),t(7,z=!1),t(10,Le=c),t(5,ee=null),t(6,P=r)}async function te(){return be(m.VERIFYING),await new Promise(r=>setTimeout(r,S||0)),Bt().then(r=>(Qe(r),x("challenge",r),Ut(r))).then(({data:r,solution:c})=>{if(x("solution",c),(c==null?void 0:c.number)!==void 0){if(y)return Xt(Ke(r,c));t(5,ee=Ke(r,c)),x("payload",ee)}else throw x("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{_t().then(()=>{t(6,P=m.VERIFIED),t(7,z=!0),x("verified"),Ce("verified",{payload:ee})})}).catch(r=>{x(r),t(6,P=m.ERROR),t(7,z=!1),t(10,Le=r.message)})}function Jt(){z=this.checked,t(7,z)}function zt(r){he[r?"unshift":"push"](()=>{Q=r,t(9,Q)})}function Kt(r){he[r?"unshift":"push"](()=>{p=r,t(8,p)})}return n.$$set=r=>{"auto"in r&&t(0,s=r.auto),"blockspam"in r&&t(27,a=r.blockspam),"challengeurl"in r&&t(14,u=r.challengeurl),"challengejson"in r&&t(28,h=r.challengejson),"debug"in r&&t(15,B=r.debug),"delay"in r&&t(16,S=r.delay),"expire"in r&&t(17,H=r.expire),"floating"in r&&t(1,E=r.floating),"floatinganchor"in r&&t(18,U=r.floatinganchor),"floatingoffset"in r&&t(19,K=r.floatingoffset),"hidefooter"in r&&t(2,T=r.hidefooter),"hidelogo"in r&&t(3,oe=r.hidelogo),"name"in r&&t(4,J=r.name),"maxnumber"in r&&t(20,M=r.maxnumber),"mockerror"in r&&t(21,L=r.mockerror),"refetchonexpire"in r&&t(22,I=r.refetchonexpire),"spamfilter"in r&&t(23,_=r.spamfilter),"strings"in r&&t(29,A=r.strings),"test"in r&&t(24,d=r.test),"verifyurl"in r&&t(25,y=r.verifyurl),"workers"in r&&t(26,ce=r.workers),"workerurl"in r&&t(30,xe=r.workerurl)},n.$$.update=()=>{n.$$.dirty[0]&268435456&&(i=h?Ze(h):void 0),n.$$.dirty[0]&536870912&&t(34,l=A?Ze(A):{}),n.$$.dirty[1]&8&&t(11,o={ariaLinkLabel:Ue,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by <a href="${qe}" target="_blank" aria-label="${l.ariaLinkLabel||Ue}">ALTCHA</a>`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),n.$$.dirty[0]&96&&Ce("statechange",{payload:ee,state:P}),n.$$.dirty[0]&64&&Yt()},[s,E,T,oe,J,ee,P,z,p,Q,Le,o,Zt,rt,u,B,S,H,U,K,M,L,I,_,d,y,ce,a,h,A,xe,lt,be,te,l,Jt,zt,Kt]}class Ye extends At{constructor(e){super(),Lt(this,e,Ot,Ft,ct,{auto:0,blockspam:27,challengeurl:14,challengejson:28,debug:15,delay:16,expire:17,floating:1,floatinganchor:18,floatingoffset:19,hidefooter:2,hidelogo:3,name:4,maxnumber:20,mockerror:21,refetchonexpire:22,spamfilter:23,strings:29,test:24,verifyurl:25,workers:26,workerurl:30,configure:31,reset:32,verify:33},null,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[27]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[14]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[28]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[15]}set debug(e){this.$$set({debug:e}),w()}get delay(){return this.$$.ctx[16]}set delay(e){this.$$set({delay:e}),w()}get expire(){return this.$$.ctx[17]}set expire(e){this.$$set({expire:e}),w()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),w()}get floatinganchor(){return this.$$.ctx[18]}set floatinganchor(e){this.$$set({floatinganchor:e}),w()}get floatingoffset(){return this.$$.ctx[19]}set floatingoffset(e){this.$$set({floatingoffset:e}),w()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),w()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),w()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),w()}get maxnumber(){return this.$$.ctx[20]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[21]}set mockerror(e){this.$$set({mockerror:e}),w()}get refetchonexpire(){return this.$$.ctx[22]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[23]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[29]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[24]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[25]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[26]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[30]}set workerurl(e){this.$$set({workerurl:e}),w()}get configure(){return this.$$.ctx[31]}get reset(){return this.$$.ctx[32]}get verify(){return this.$$.ctx[33]}}customElements.define("altcha-widget",It(Ye,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},[],["configure","reset","verify"],!1)),globalThis.createAltchaWorker=n=>new Worker(new URL(n||"./worker.js",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:N&&N.src||new URL("altcha.umd.cjs",document.baseURI).href)),O.Altcha=Ye,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "altcha",
3
3
  "description": "GDPR compliant, self-hosted CAPTCHA alternative.",
4
- "version": "0.6.2",
4
+ "version": "0.6.3",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Daniel Regeci",