diff --git a/README.md b/README.md index 8d0794f..87bfbe8 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Visit [ALTCHA](https://altcha.org) for more information. - [Ruby](https://github.com/altcha-org/altcha-lib-rb) - [Elixir](https://github.com/altcha-org/altcha-lib-ex) -## Plugins +## CMS - [WordPress plugin](https://github.com/altcha-org/wordpress-plugin) - [Other libraries and plugins](https://altcha.org/docs/integrations/) @@ -82,12 +82,12 @@ See [server documentation](https://altcha.org/docs/server-integration) for more ## Bundle Size -ALTCHA's default bundle is lightweight, combining all assets, including CSS and the JavaScript Web Worker, into a single file. When GZIPped, it totals only 18.35 kB, making ALTCHA’s widget 93% smaller than reCAPTCHA. +ALTCHA's default bundle is lightweight, combining all assets, including CSS and the JavaScript Web Worker, into a single file. When GZIPped, it totals only 17 kB, making ALTCHA’s widget 94% smaller than reCAPTCHA. |Distribution|Size (GZIPped)| |---|---| -|ALTCHA (v0.8.x)|18.35 kB| -|hCaptcha|48 kB| +|ALTCHA (v0.9.x)|17 kB| +|hCaptcha|48+ kB| |reCAPTCHA|270+ kB| ## Content Security Policy (CSP) @@ -98,37 +98,60 @@ The default distribution bundle of the WebComponent includes styles and the work Required options (at least one is required): -- __challengeurl__ - URL of your server to fetch the challenge from. Refer to [server integration](https://altcha.org/docs/server-integration). -- __challengejson__ - JSON-encoded challenge data. If avoiding an HTTP request to `challengeurl`, provide the data here. +- **challengeurl**: URL of your server to fetch the challenge from. Refer to [server integration](https://altcha.org/docs/server-integration). +- **challengejson**: JSON-encoded challenge data. If avoiding an HTTP request to `challengeurl`, provide the data here. Additional options: -- __analytics__ - Enable analytics with [ALTCHA Forms](https://altcha.org/forms/). See [HTML submissions documentation](https://altcha.org/docs/forms/features/html-submissions). -- __auto__ - Automatically verify without user interaction (possible values: `onfocus`, `onload`, `onsubmit`). -- __beaconurl__ - URL to which analytics data will be sent using a beacon POST if the form is abandoned. This option is only used when `analytics` is enabled. -- __blockspam__ - Only used in conjunction with the `spamfilter` option. If enabled, it will block form submission and fail verification if the Spam Filter returns a negative classification. This effectively prevents submission of the form. -- __delay__ - The artificial delay in milliseconds to apply before the verification (defaults to 0). -- __expire__ - The challenge expiration (duration in milliseconds). -- __floating__ - Enable floating UI (possible values: `auto`, `top`, `bottom`). -- __floatinganchor__ - The CSS selector of the "anchor" to which the floating UI will be attached to (defaults to the `button[type="submit"]` in the related form). -- __floatingoffset__ - The Y offset from the anchor element for the floating UI expressed in pixels (defaults to `12`). -- __hidefooter__ - Hide the footer (ALTCHA link). -- __hidelogo__ - Hide the ALTCHA logo. -- __maxnumber__ - The max. number to iterate to (defaults to 1,000,000). -- __name__ - The name of the hidden field containing the payload (defaults to "altcha"). -- __obfuscated__ - The [obfuscated data](https://altcha.org/docs/obfuscation) provided as a base64-encoded string. Use only without `challengeurl`/`challengejson`. -- __spamfilter__ - Enable [Spam Filter](#spam-filter). -- __strings__ - JSON-encoded translation strings. Refer to [customization](https://altcha.org/docs/widget-customization). -- __refetchonexpire__ - Automatically re-fetch and re-validate when the challenge expires (defaults to true). -- __verifyurl__ - URL for server-side verification requests. This option is automatically configured when the `spamfilter` option is used. Override this setting only if you are using a custom server implementation. -- __workers__ - The number of workers to utilize for PoW (defaults to `navigator.hardwareConcurrency || 8`, max. value `16`). -- __workerurl__ - The URL of the Worker script (defaults to `./worker.js`, only works with `external` build). - -Development / testing options: - -- __debug__ - Print log messages in the console. -- __mockerror__ - Causes the verification to always fail with a "mock" error. -- __test__ - Generates a "mock" challenge within the widget, bypassing the request to `challengeurl`. +- **auto**: Automatically verify without user interaction (possible values: `off`, `onfocus`, `onload`, `onsubmit`). +- **delay**: Artificial delay in milliseconds before verification (defaults to 0). +- **expire**: Challenge expiration duration in milliseconds. +- **floating**: Enable floating UI (possible values: `auto`, `top`, `bottom`). +- **floatinganchor**: CSS selector of the "anchor" to which the floating UI will be attached (defaults to the `button[type="submit"]` in the related form). +- **floatingoffset**: Y offset from the anchor element for the floating UI in pixels (defaults to `12`). +- **hidefooter**: Hide the footer (ALTCHA link). +- **hidelogo**: Hide the ALTCHA logo. +- **maxnumber**: Max number to iterate to (defaults to 1,000,000). +- **name**: Name of the hidden field containing the payload (defaults to "altcha"). +- **strings**: JSON-encoded translation strings. Refer to [customization](https://altcha.org/docs/widget-customization). +- **refetchonexpire**: Automatically re-fetch and re-validate when the challenge expires (defaults to true). +- **workers**: Number of workers to utilize for PoW (defaults to `navigator.hardwareConcurrency || 8`, max value `16`). +- **workerurl**: URL of the Worker script (defaults to `./worker.js`, only works with `external` build). + +Spam Filter-related options: + +- **blockspam**: Only used with the `spamfilter` option. If enabled, it will block form submission and fail verification if the Spam Filter returns a negative classification. This prevents form submission. +- **spamfilter**: Enable [Spam Filter](#spam-filter). +- **verifyurl**: URL for server-side verification requests. This option is automatically configured when the `spamfilter` option is used. Override this setting only if using a custom server implementation. + +Data Obfuscation options: + +- **obfuscated**: The [obfuscated data](https://altcha.org/docs/obfuscation) provided as a base64-encoded string (requires `altcha/obfuscation` plugin). Use only without `challengeurl`/`challengejson`. + +Development / Testing options: + +- **debug**: Print log messages in the console. +- **mockerror**: Causes verification to always fail with a "mock" error. +- **test**: Generates a "mock" challenge within the widget, bypassing the request to `challengeurl`. + +## Plugins + +Version 0.9.x introduced _plugins_ that can be enabled by importing individual plugin scripts: + +```js +import 'altcha/obfuscation'; +import 'altcha'; +``` + +It is recommended to import plugins _before_ the main `altcha` package to ensure proper registration before any widget instance is created. + +Available plugins built-in to the `altcha` package: + +- `altcha/analytics`: Enable analytics with [ALTCHA Forms](https://altcha.org/forms/). See [HTML submissions documentation](https://altcha.org/docs/forms/features/html-submissions). +- `altcha/obfuscation`: Enable [obfuscation](https://altcha.org/docs/obfuscation) for sensitive data such as email addresses or phone numbers. +- `altcha/upload`: Enable file upload from `type=file` fields to [ALTCHA Forms](https://altcha.org/forms/). See [HTML submissions documentation](https://altcha.org/docs/forms/features/html-submissions). + +To enable specific plugins for a particular instance of the widget, use the `plugins` attribute in the widget tag. List the names of the plugins you want to enable, separated by commas, such as `plugins="analytics,obfuscation"`. Plugins still need to be imported as described above. The `plugins` attribute only specifies which plugins should be active for that instance, even if other plugins are already imported. ## Programmatic Configuration @@ -152,9 +175,7 @@ Available configuration options: ```ts export interface Configure { - analytics?: boolean | string; - auto?: 'onfocus' | 'onload' | 'onsubmit'; - beaconurl?: string; + auto?: 'off' | 'onfocus' | 'onload' | 'onsubmit'; challenge?: { algorithm: string; challenge: string; @@ -196,9 +217,10 @@ export interface Configure { ## Events -- __serververification__ - Triggers upon a server verification (only in conjunction with `spamfilter`). -- __statechange__ - Triggers whenever an internal `state` changes. -- __verified__ - Triggers when the challenge is verified. +- **load** - Triggers when the widget loads. The exported methods become available after this event. +- **serververification** - Triggers upon a server verification (only in conjunction with `spamfilter`). +- **statechange** - Triggers whenever an internal `state` changes. +- **verified** - Triggers when the challenge is verified. ```ts enum State { @@ -249,16 +271,16 @@ interface SpamFilter { SpamFilter configuration options: -- __blockedCountries__ - An array of country codes (ISO 3166 alpha-2) that you want to block. -- __classifier__ - Enforce a specific classifier. -- __disableRules__ - An array of rules to disable. -- __email__ - The name of the input field for the user's email. Disable email checking with `false`. -- __expectedCountries__ - An array of expected countries as 2-letter codes (ISO 3166-1 alpha-2). -- __expectedLanguages__ - An array of expected languages as 2-letter codes (ISO 639 alpha-2). -- __fields__ - An array of input names to send to the spam filter. -- __ipAddress__ - The user's IP is detected automatically but can be overridden or disabled with `false`. -- __text__ - The text to classify. An array of strings can also be submitted. -- __timeZone__ - The user's timezone is detected automatically but can be overridden or disabled with `false`. +- **blockedCountries** - An array of country codes (ISO 3166 alpha-2) that you want to block. +- **classifier** - Enforce a specific classifier. +- **disableRules** - An array of rules to disable. +- **email** - The name of the input field for the user's email. Disable email checking with `false`. +- **expectedCountries** - An array of expected countries as 2-letter codes (ISO 3166-1 alpha-2). +- **expectedLanguages** - An array of expected languages as 2-letter codes (ISO 639 alpha-2). +- **fields** - An array of input names to send to the spam filter. +- **ipAddress** - The user's IP is detected automatically but can be overridden or disabled with `false`. +- **text** - The text to classify. An array of strings can also be submitted. +- **timeZone** - The user's timezone is detected automatically but can be overridden or disabled with `false`. To include the email field into `fields` (for easier server-side verification), configure the list of input names using the `spamfilter.fields: string[]` option. diff --git a/dist/altcha.d.ts b/dist/altcha.d.ts index ef75e1e..df0258a 100644 --- a/dist/altcha.d.ts +++ b/dist/altcha.d.ts @@ -3,6 +3,9 @@ export {}; declare module 'altcha'; declare global { + var altchaCreateWorker: (url?: string) => Worker; + var altchaPlugins: any[]; + type AltchaState = 'error' | 'expired' | 'verified' | 'verifying' | 'unverified'; interface AltchaStateChangeEvent extends CustomEvent<{ @@ -17,9 +20,7 @@ declare global { interface AltchaServerVerificationEvent extends CustomEvent> {} interface AltchaWidgetOptions { - analytics?: boolean | string; - auto?: 'onfocus' | 'onload' | 'onsubmit'; - beaconurl?: string; + auto?: 'off' | 'onfocus' | 'onload' | 'onsubmit'; blockspam?: boolean; challengeurl?: string; challengejson?: string; @@ -47,7 +48,13 @@ declare global { interface AltchaWidgetMethods { configure: (options: AltchaWidgetOptions) => void; clarify: () => Promise; + getConfiguration: () => AltchaWidgetOptions; + getFloatingAnchor: () => HTMLElement | null; + getPlugin: (name: string) => T; + getState: () => AltchaState; reset: (newState: AltchaState = 'unverified', err: string | null = null) => void; + setFloatingAnchor: (el: HTMLElement) => void; + setState: (newState: AltchaState, err: string | null = null) => void; verify: () => Promise; } diff --git a/dist/altcha.js b/dist/altcha.js index e0295b8..d076784 100644 --- a/dist/altcha.js +++ b/dist/altcha.js @@ -1,15 +1,11 @@ -var $t = Object.defineProperty; -var ut = (n) => { - throw TypeError(n); -}; -var en = (n, e, t) => e in n ? $t(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; -var D = (n, e, t) => en(n, typeof e != "symbol" ? e + "" : e, t), dt = (n, e, t) => e.has(n) || ut("Cannot " + t); -var W = (n, e, t) => (dt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), fe = (n, e, t) => e.has(n) ? ut("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), ht = (n, e, t, i) => (dt(n, e, "write to private field"), i ? i.call(n, t) : e.set(n, t), t); -const Rt = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIHAoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiB3KGUsdCxyKXtyZXR1cm4gcChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChyLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGIoZSx0LHI9IlNIQS0yNTYiLG49MWU2LHM9MCl7Y29uc3Qgbz1uZXcgQWJvcnRDb250cm9sbGVyLGE9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgYz1zO2M8PW47Yys9MSl7aWYoby5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCB3KHQsYyxyKT09PWUpcmV0dXJue251bWJlcjpjLHRvb2s6RGF0ZS5ub3coKS1hfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjpvfX1mdW5jdGlvbiBoKGUpe2NvbnN0IHQ9YXRvYihlKSxyPW5ldyBVaW50OEFycmF5KHQubGVuZ3RoKTtmb3IobGV0IG49MDtuPHQubGVuZ3RoO24rKylyW25dPXQuY2hhckNvZGVBdChuKTtyZXR1cm4gcn1mdW5jdGlvbiBnKGUsdD0xMil7Y29uc3Qgcj1uZXcgVWludDhBcnJheSh0KTtmb3IobGV0IG49MDtuPHQ7bisrKXJbbl09ZSUyNTYsZT1NYXRoLmZsb29yKGUvMjU2KTtyZXR1cm4gcn1hc3luYyBmdW5jdGlvbiBtKGUsdD0iIixyPTFlNixuPTApe2NvbnN0IHM9IkFFUy1HQ00iLG89bmV3IEFib3J0Q29udHJvbGxlcixhPURhdGUubm93KCksbD1hc3luYygpPT57Zm9yKGxldCB1PW47dTw9cjt1Kz0xKXtpZihvLnNpZ25hbC5hYm9ydGVkfHwhY3x8IXkpcmV0dXJuIG51bGw7dHJ5e2NvbnN0IGQ9YXdhaXQgY3J5cHRvLnN1YnRsZS5kZWNyeXB0KHtuYW1lOnMsaXY6Zyh1KX0sYyx5KTtpZihkKXJldHVybntjbGVhclRleHQ6bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKGQpLHRvb2s6RGF0ZS5ub3coKS1hfX1jYXRjaHt9fXJldHVybiBudWxsfTtsZXQgYz1udWxsLHk9bnVsbDt0cnl7eT1oKGUpO2NvbnN0IHU9YXdhaXQgY3J5cHRvLnN1YnRsZS5kaWdlc3QoIlNIQS0yNTYiLGYuZW5jb2RlKHQpKTtjPWF3YWl0IGNyeXB0by5zdWJ0bGUuaW1wb3J0S2V5KCJyYXciLHUscywhMSxbImRlY3J5cHQiXSl9Y2F0Y2h7cmV0dXJue3Byb21pc2U6UHJvbWlzZS5yZWplY3QoKSxjb250cm9sbGVyOm99fXJldHVybntwcm9taXNlOmwoKSxjb250cm9sbGVyOm99fWxldCBpO29ubWVzc2FnZT1hc3luYyBlPT57Y29uc3R7dHlwZTp0LHBheWxvYWQ6cixzdGFydDpuLG1heDpzfT1lLmRhdGE7bGV0IG89bnVsbDtpZih0PT09ImFib3J0IilpPT1udWxsfHxpLmFib3J0KCksaT12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtpZigib2JmdXNjYXRlZCJpbiByKXtjb25zdHtrZXk6YSxvYmZ1c2NhdGVkOmx9PXJ8fHt9O289YXdhaXQgbShsLGEscyxuKX1lbHNle2NvbnN0e2FsZ29yaXRobTphLGNoYWxsZW5nZTpsLHNhbHQ6Y309cnx8e307bz1iKGwsYyxhLHMsbil9aT1vLmNvbnRyb2xsZXIsby5wcm9taXNlLnRoZW4oYT0+e3NlbGYucG9zdE1lc3NhZ2UoYSYmey4uLmEsd29ya2VyOiEwfSl9KX19fSkoKTsK", tn = (n) => Uint8Array.from(atob(n), (e) => e.charCodeAt(0)), mt = typeof self < "u" && self.Blob && new Blob([tn(Rt)], { type: "text/javascript;charset=utf-8" }); -function nn(n) { +var Ft = Object.defineProperty; +var Dt = (n, e, t) => e in n ? Ft(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; +var U = (n, e, t) => Dt(n, typeof e != "symbol" ? e + "" : e, t); +const ht = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIHAoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiB3KGUsdCxyKXtyZXR1cm4gcChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChyLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGIoZSx0LHI9IlNIQS0yNTYiLG49MWU2LHM9MCl7Y29uc3Qgbz1uZXcgQWJvcnRDb250cm9sbGVyLGE9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgYz1zO2M8PW47Yys9MSl7aWYoby5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCB3KHQsYyxyKT09PWUpcmV0dXJue251bWJlcjpjLHRvb2s6RGF0ZS5ub3coKS1hfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjpvfX1mdW5jdGlvbiBoKGUpe2NvbnN0IHQ9YXRvYihlKSxyPW5ldyBVaW50OEFycmF5KHQubGVuZ3RoKTtmb3IobGV0IG49MDtuPHQubGVuZ3RoO24rKylyW25dPXQuY2hhckNvZGVBdChuKTtyZXR1cm4gcn1mdW5jdGlvbiBnKGUsdD0xMil7Y29uc3Qgcj1uZXcgVWludDhBcnJheSh0KTtmb3IobGV0IG49MDtuPHQ7bisrKXJbbl09ZSUyNTYsZT1NYXRoLmZsb29yKGUvMjU2KTtyZXR1cm4gcn1hc3luYyBmdW5jdGlvbiBtKGUsdD0iIixyPTFlNixuPTApe2NvbnN0IHM9IkFFUy1HQ00iLG89bmV3IEFib3J0Q29udHJvbGxlcixhPURhdGUubm93KCksbD1hc3luYygpPT57Zm9yKGxldCB1PW47dTw9cjt1Kz0xKXtpZihvLnNpZ25hbC5hYm9ydGVkfHwhY3x8IXkpcmV0dXJuIG51bGw7dHJ5e2NvbnN0IGQ9YXdhaXQgY3J5cHRvLnN1YnRsZS5kZWNyeXB0KHtuYW1lOnMsaXY6Zyh1KX0sYyx5KTtpZihkKXJldHVybntjbGVhclRleHQ6bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKGQpLHRvb2s6RGF0ZS5ub3coKS1hfX1jYXRjaHt9fXJldHVybiBudWxsfTtsZXQgYz1udWxsLHk9bnVsbDt0cnl7eT1oKGUpO2NvbnN0IHU9YXdhaXQgY3J5cHRvLnN1YnRsZS5kaWdlc3QoIlNIQS0yNTYiLGYuZW5jb2RlKHQpKTtjPWF3YWl0IGNyeXB0by5zdWJ0bGUuaW1wb3J0S2V5KCJyYXciLHUscywhMSxbImRlY3J5cHQiXSl9Y2F0Y2h7cmV0dXJue3Byb21pc2U6UHJvbWlzZS5yZWplY3QoKSxjb250cm9sbGVyOm99fXJldHVybntwcm9taXNlOmwoKSxjb250cm9sbGVyOm99fWxldCBpO29ubWVzc2FnZT1hc3luYyBlPT57Y29uc3R7dHlwZTp0LHBheWxvYWQ6cixzdGFydDpuLG1heDpzfT1lLmRhdGE7bGV0IG89bnVsbDtpZih0PT09ImFib3J0IilpPT1udWxsfHxpLmFib3J0KCksaT12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtpZigib2JmdXNjYXRlZCJpbiByKXtjb25zdHtrZXk6YSxvYmZ1c2NhdGVkOmx9PXJ8fHt9O289YXdhaXQgbShsLGEscyxuKX1lbHNle2NvbnN0e2FsZ29yaXRobTphLGNoYWxsZW5nZTpsLHNhbHQ6Y309cnx8e307bz1iKGwsYyxhLHMsbil9aT1vLmNvbnRyb2xsZXIsby5wcm9taXNlLnRoZW4oYT0+e3NlbGYucG9zdE1lc3NhZ2UoYSYmey4uLmEsd29ya2VyOiEwfSl9KX19fSkoKTsK", jt = (n) => Uint8Array.from(atob(n), (e) => e.charCodeAt(0)), nt = typeof self < "u" && self.Blob && new Blob([jt(ht)], { type: "text/javascript;charset=utf-8" }); +function Pt(n) { let e; try { - if (e = mt && (self.URL || self.webkitURL).createObjectURL(mt), !e) throw ""; + if (e = nt && (self.URL || self.webkitURL).createObjectURL(nt), !e) throw ""; const t = new Worker(e, { name: n == null ? void 0 : n.name }); @@ -18,7 +14,7 @@ function nn(n) { }), t; } catch { return new Worker( - "data:text/javascript;base64," + Rt, + "data:text/javascript;base64," + ht, { name: n == null ? void 0 : n.name } @@ -27,64 +23,64 @@ function nn(n) { e && (self.URL || self.webkitURL).revokeObjectURL(e); } } -function Se() { +function Re() { } -function rn(n, e) { +function Wt(n, e) { for (const t in e) n[t] = e[t]; return ( /** @type {T & S} */ n ); } -function Lt(n) { +function gt(n) { return n(); } -function gt() { +function rt() { return /* @__PURE__ */ Object.create(null); } -function Ie(n) { - n.forEach(Lt); +function we(n) { + n.forEach(gt); } -function It(n) { +function mt(n) { return typeof n == "function"; } -function on(n, e) { +function Ut(n, e) { return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function"; } -function ln(n) { +function Kt(n) { return Object.keys(n).length === 0; } -function sn(n, e, t, i) { +function Mt(n, e, t, i) { if (n) { - const o = Tt(n, e, t, i); + const o = bt(n, e, t, i); return n[0](o); } } -function Tt(n, e, t, i) { - return n[1] && i ? rn(t.ctx.slice(), n[1](i(e))) : t.ctx; +function bt(n, e, t, i) { + return n[1] && i ? Wt(t.ctx.slice(), n[1](i(e))) : t.ctx; } -function cn(n, e, t, i) { +function Bt(n, e, t, i) { if (n[2] && i) { const o = n[2](i(t)); if (e.dirty === void 0) return o; if (typeof o == "object") { const l = [], s = Math.max(e.dirty.length, o.length); - for (let c = 0; c < s; c += 1) - l[c] = e.dirty[c] | o[c]; + for (let d = 0; d < s; d += 1) + l[d] = e.dirty[d] | o[d]; return l; } return e.dirty | o; } return e.dirty; } -function an(n, e, t, i, o, l) { +function Ot(n, e, t, i, o, l) { if (o) { - const s = Tt(e, t, i, l); + const s = bt(e, t, i, l); n.p(s, o); } } -function fn(n) { +function Jt(n) { if (n.ctx.length > 32) { const e = [], t = n.ctx.length / 32; for (let i = 0; i < t; i++) @@ -96,14 +92,14 @@ function fn(n) { function L(n, e) { n.appendChild(e); } -function un(n, e, t) { - const i = dn(n); +function Qt(n, e, t) { + const i = $t(n); if (!i.getElementById(e)) { - const o = N("style"); - o.id = e, o.textContent = t, hn(i, o); + const o = Z("style"); + o.id = e, o.textContent = t, qt(i, o); } } -function dn(n) { +function $t(n) { if (!n) return document; const e = n.getRootNode ? n.getRootNode() : n.ownerDocument; return e && /** @type {ShadowRoot} */ @@ -112,50 +108,47 @@ function dn(n) { e ) : n.ownerDocument; } -function hn(n, e) { +function qt(n, e) { return L( /** @type {Document} */ n.head || n, e ), e.sheet; } -function Y(n, e, t) { +function X(n, e, t) { n.insertBefore(e, t || null); } -function S(n) { +function Y(n) { n.parentNode && n.parentNode.removeChild(n); } -function N(n) { +function Z(n) { return document.createElement(n); } -function ie(n) { +function $(n) { return document.createElementNS("http://www.w3.org/2000/svg", n); } -function Nt(n) { +function en(n) { return document.createTextNode(n); } -function q() { - return Nt(" "); +function Q() { + return en(" "); } -function mn() { - return Nt(""); -} -function De(n, e, t, i) { +function Le(n, e, t, i) { return n.addEventListener(e, t, i), () => n.removeEventListener(e, t, i); } -function f(n, e, t) { +function a(n, e, t) { t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t); } -function gn(n) { +function tn(n) { return Array.from(n.childNodes); } -function bt(n, e, t) { +function it(n, e, t) { n.classList.toggle(e, !!t); } -function bn(n, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { +function nn(n, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { return new CustomEvent(n, { detail: e, bubbles: t, cancelable: i }); } -function yn(n) { +function rn(n) { const e = {}; return n.childNodes.forEach( /** @param {Element} node */ @@ -164,26 +157,26 @@ function yn(n) { } ), e; } -let Ee; -function ke(n) { - Ee = n; +let pe; +function ve(n) { + pe = n; } -function Me() { - if (!Ee) throw new Error("Function called outside component initialization"); - return Ee; +function Ae() { + if (!pe) throw new Error("Function called outside component initialization"); + return pe; } -function vn(n) { - Me().$$.on_mount.push(n); +function on(n) { + Ae().$$.on_mount.push(n); } -function wn(n) { - Me().$$.on_destroy.push(n); +function ln(n) { + Ae().$$.on_destroy.push(n); } -function pn() { - const n = Me(); +function sn() { + const n = Ae(); return (e, t, { cancelable: i = !1 } = {}) => { const o = n.$$.callbacks[e]; if (o) { - const l = bn( + const l = nn( /** @type {string} */ e, t, @@ -196,144 +189,144 @@ function pn() { return !0; }; } -const de = [], Ze = []; -let he = []; -const yt = [], At = /* @__PURE__ */ Promise.resolve(); -let Ue = !1; -function zt() { - Ue || (Ue = !0, At.then(p)); +const ae = [], Ce = []; +let fe = []; +const ot = [], yt = /* @__PURE__ */ Promise.resolve(); +let ze = !1; +function vt() { + ze || (ze = !0, yt.then(w)); } -function _n() { - return zt(), At; +function cn() { + return vt(), yt; } -function Xe(n) { - he.push(n); +function Se(n) { + fe.push(n); } -const Ye = /* @__PURE__ */ new Set(); -let ue = 0; -function p() { - if (ue !== 0) +const Ne = /* @__PURE__ */ new Set(); +let ce = 0; +function w() { + if (ce !== 0) return; - const n = Ee; + const n = pe; do { try { - for (; ue < de.length; ) { - const e = de[ue]; - ue++, ke(e), kn(e.$$); + for (; ce < ae.length; ) { + const e = ae[ce]; + ce++, ve(e), an(e.$$); } } catch (e) { - throw de.length = 0, ue = 0, e; + throw ae.length = 0, ce = 0, e; } - for (ke(null), de.length = 0, ue = 0; Ze.length; ) Ze.pop()(); - for (let e = 0; e < he.length; e += 1) { - const t = he[e]; - Ye.has(t) || (Ye.add(t), t()); + for (ve(null), ae.length = 0, ce = 0; Ce.length; ) Ce.pop()(); + for (let e = 0; e < fe.length; e += 1) { + const t = fe[e]; + Ne.has(t) || (Ne.add(t), t()); } - he.length = 0; - } while (de.length); - for (; yt.length; ) - yt.pop()(); - Ue = !1, Ye.clear(), ke(n); + fe.length = 0; + } while (ae.length); + for (; ot.length; ) + ot.pop()(); + ze = !1, Ne.clear(), ve(n); } -function kn(n) { +function an(n) { if (n.fragment !== null) { - n.update(), Ie(n.before_update); + n.update(), we(n.before_update); const e = n.dirty; - n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(Xe); + n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(Se); } } -function En(n) { +function fn(n) { const e = [], t = []; - he.forEach((i) => n.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), he = e; + fe.forEach((i) => n.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), fe = e; } -const ze = /* @__PURE__ */ new Set(); -let xn; -function Ft(n, e) { - n && n.i && (ze.delete(n), n.i(e)); +const xe = /* @__PURE__ */ new Set(); +let un; +function pt(n, e) { + n && n.i && (xe.delete(n), n.i(e)); } -function Cn(n, e, t, i) { +function dn(n, e, t, i) { if (n && n.o) { - if (ze.has(n)) return; - ze.add(n), xn.c.push(() => { - ze.delete(n); + if (xe.has(n)) return; + xe.add(n), un.c.push(() => { + xe.delete(n); }), n.o(e); } } -function Rn(n, e, t) { +function hn(n, e, t) { const { fragment: i, after_update: o } = n.$$; - i && i.m(e, t), Xe(() => { - const l = n.$$.on_mount.map(Lt).filter(It); - n.$$.on_destroy ? n.$$.on_destroy.push(...l) : Ie(l), n.$$.on_mount = []; - }), o.forEach(Xe); + i && i.m(e, t), Se(() => { + const l = n.$$.on_mount.map(gt).filter(mt); + n.$$.on_destroy ? n.$$.on_destroy.push(...l) : we(l), n.$$.on_mount = []; + }), o.forEach(Se); } -function Ln(n, e) { +function gn(n, e) { const t = n.$$; - t.fragment !== null && (En(t.after_update), Ie(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); + t.fragment !== null && (fn(t.after_update), we(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); } -function In(n, e) { - n.$$.dirty[0] === -1 && (de.push(n), zt(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31; +function mn(n, e) { + n.$$.dirty[0] === -1 && (ae.push(n), vt(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31; } -function Tn(n, e, t, i, o, l, s = null, c = [-1]) { - const a = Ee; - ke(n); - const d = n.$$ = { +function bn(n, e, t, i, o, l, s = null, d = [-1]) { + const h = pe; + ve(n); + const f = n.$$ = { fragment: null, ctx: [], // state props: l, - update: Se, + update: Re, not_equal: o, - bound: gt(), + bound: rt(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], - context: new Map(e.context || (a ? a.$$.context : [])), + context: new Map(e.context || (h ? h.$$.context : [])), // everything else - callbacks: gt(), - dirty: c, + callbacks: rt(), + dirty: d, skip_bound: !1, - root: e.target || a.$$.root + root: e.target || h.$$.root }; - s && s(d.root); - let v = !1; - if (d.ctx = t ? t(n, e.props || {}, (R, $, ...k) => { - const K = k.length ? k[0] : $; - return d.ctx && o(d.ctx[R], d.ctx[R] = K) && (!d.skip_bound && d.bound[R] && d.bound[R](K), v && In(n, R)), $; - }) : [], d.update(), v = !0, Ie(d.before_update), d.fragment = i ? i(d.ctx) : !1, e.target) { + s && s(f.root); + let C = !1; + if (f.ctx = t ? t(n, e.props || {}, (b, M, ...D) => { + const j = D.length ? D[0] : M; + return f.ctx && o(f.ctx[b], f.ctx[b] = j) && (!f.skip_bound && f.bound[b] && f.bound[b](j), C && mn(n, b)), M; + }) : [], f.update(), C = !0, we(f.before_update), f.fragment = i ? i(f.ctx) : !1, e.target) { if (e.hydrate) { - const R = gn(e.target); - d.fragment && d.fragment.l(R), R.forEach(S); + const b = tn(e.target); + f.fragment && f.fragment.l(b), b.forEach(Y); } else - d.fragment && d.fragment.c(); - e.intro && Ft(n.$$.fragment), Rn(n, e.target, e.anchor), p(); + f.fragment && f.fragment.c(); + e.intro && pt(n.$$.fragment), hn(n, e.target, e.anchor), w(); } - ke(a); + ve(h); } -let St; -typeof HTMLElement == "function" && (St = class extends HTMLElement { +let wt; +typeof HTMLElement == "function" && (wt = class extends HTMLElement { constructor(e, t, i) { super(); /** The Svelte component constructor */ - D(this, "$$ctor"); + U(this, "$$ctor"); /** Slots */ - D(this, "$$s"); + U(this, "$$s"); /** The Svelte component instance */ - D(this, "$$c"); + U(this, "$$c"); /** Whether or not the custom element is connected */ - D(this, "$$cn", !1); + U(this, "$$cn", !1); /** Component props data */ - D(this, "$$d", {}); + U(this, "$$d", {}); /** `true` if currently in the process of reflecting component props back to attributes */ - D(this, "$$r", !1); + U(this, "$$r", !1); /** @type {Record} Props definition (name, reflected, type etc) */ - D(this, "$$p_d", {}); + U(this, "$$p_d", {}); /** @type {Record} Event listeners */ - D(this, "$$l", {}); + U(this, "$$l", {}); /** @type {Map} Event listener unsubscribe functions */ - D(this, "$$l_u", /* @__PURE__ */ new Map()); + U(this, "$$l_u", /* @__PURE__ */ new Map()); this.$$ctor = e, this.$$s = t, i && this.attachShadow({ mode: "open" }); } addEventListener(e, t, i) { @@ -356,29 +349,29 @@ typeof HTMLElement == "function" && (St = class extends HTMLElement { let s; return { c: function() { - s = N("slot"), l !== "default" && f(s, "name", l); + s = Z("slot"), l !== "default" && a(s, "name", l); }, /** * @param {HTMLElement} target * @param {HTMLElement} [anchor] */ - m: function(d, v) { - Y(d, s, v); + m: function(f, C) { + X(f, s, C); }, - d: function(d) { - d && S(s); + d: function(f) { + f && Y(s); } }; }; }; if (await Promise.resolve(), !this.$$cn || this.$$c) return; - const t = {}, i = yn(this); + const t = {}, i = rn(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] = Fe(s, l.value, this.$$p_d, "toProp")); + s in this.$$d || (this.$$d[s] = Ee(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]); @@ -396,7 +389,7 @@ typeof HTMLElement == "function" && (St = class extends HTMLElement { 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 = Fe( + const s = Ee( l, this.$$d[l], this.$$p_d, @@ -409,8 +402,8 @@ typeof HTMLElement == "function" && (St = class extends HTMLElement { this.$$c.$$.after_update.push(o), o(); for (const l in this.$$l) for (const s of this.$$l[l]) { - const c = this.$$c.$on(l, s); - this.$$l_u.set(s, c); + const d = this.$$c.$on(l, s); + this.$$l_u.set(s, d); } this.$$l = {}; } @@ -419,7 +412,7 @@ typeof HTMLElement == "function" && (St = class extends HTMLElement { // and setting attributes through setAttribute etc, this is helpful attributeChangedCallback(e, t, i) { var o; - this.$$r || (e = this.$$g_p(e), this.$$d[e] = Fe(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); + this.$$r || (e = this.$$g_p(e), this.$$d[e] = Ee(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); } disconnectedCallback() { this.$$cn = !1, Promise.resolve().then(() => { @@ -432,7 +425,7 @@ typeof HTMLElement == "function" && (St = class extends HTMLElement { ) || e; } }); -function Fe(n, e, t, i) { +function Ee(n, e, t, i) { var l; const o = (l = t[n]) == null ? void 0 : l.type; if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[n]) @@ -462,38 +455,38 @@ function Fe(n, e, t, i) { return e; } } -function Nn(n, e, t, i, o, l) { - let s = class extends St { +function yn(n, e, t, i, o, l) { + let s = class extends wt { constructor() { super(n, t, o), this.$$p_d = e; } static get observedAttributes() { return Object.keys(e).map( - (c) => (e[c].attribute || c).toLowerCase() + (d) => (e[d].attribute || d).toLowerCase() ); } }; - return Object.keys(e).forEach((c) => { - Object.defineProperty(s.prototype, c, { + return Object.keys(e).forEach((d) => { + Object.defineProperty(s.prototype, d, { get() { - return this.$$c && c in this.$$c ? this.$$c[c] : this.$$d[c]; + return this.$$c && d in this.$$c ? this.$$c[d] : this.$$d[d]; }, - set(a) { - var d; - a = Fe(c, a, e), this.$$d[c] = a, (d = this.$$c) == null || d.$set({ [c]: a }); + set(h) { + var f; + h = Ee(d, h, e), this.$$d[d] = h, (f = this.$$c) == null || f.$set({ [d]: h }); } }); - }), i.forEach((c) => { - Object.defineProperty(s.prototype, c, { + }), i.forEach((d) => { + Object.defineProperty(s.prototype, d, { get() { - var a; - return (a = this.$$c) == null ? void 0 : a[c]; + var h; + return (h = this.$$c) == null ? void 0 : h[d]; } }); }), n.element = /** @type {any} */ s, s; } -class An { +class vn { constructor() { /** * ### PRIVATE API @@ -502,7 +495,7 @@ class An { * * @type {any} */ - D(this, "$$"); + U(this, "$$"); /** * ### PRIVATE API * @@ -510,11 +503,11 @@ class An { * * @type {any} */ - D(this, "$$set"); + U(this, "$$set"); } /** @returns {void} */ $destroy() { - Ln(this, 1), this.$destroy = Se; + gn(this, 1), this.$destroy = Re; } /** * @template {Extract} K @@ -523,8 +516,8 @@ class An { * @returns {() => void} */ $on(e, t) { - if (!It(t)) - return Se; + if (!mt(t)) + return Re; const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); return i.push(t), () => { const o = i.indexOf(t); @@ -536,19 +529,19 @@ class An { * @returns {void} */ $set(e) { - this.$$set && !ln(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); + this.$$set && !Kt(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); } } -const zn = "4"; -typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(zn); -const Zt = new TextEncoder(); -function Fn(n) { +const pn = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(pn); +const _t = new TextEncoder(); +function wn(n) { return [...new Uint8Array(n)].map((e) => e.toString(16).padStart(2, "0")).join(""); } -async function Sn(n, e = "SHA-256", t = 1e5) { +async function _n(n, e = "SHA-256", t = 1e5) { const i = Date.now().toString(16); n || (n = Math.round(Math.random() * t)); - const o = await Vt(i, n, e); + const o = await kt(i, n, e); return { algorithm: e, challenge: o, @@ -556,24 +549,24 @@ async function Sn(n, e = "SHA-256", t = 1e5) { signature: "" }; } -async function Vt(n, e, t) { - return Fn( +async function kt(n, e, t) { + return wn( await crypto.subtle.digest( t.toUpperCase(), - Zt.encode(n + e) + _t.encode(n + e) ) ); } -function Zn(n, e, t = "SHA-256", i = 1e6, o = 0) { +function kn(n, e, t = "SHA-256", i = 1e6, o = 0) { const l = new AbortController(), s = Date.now(); return { promise: (async () => { - for (let a = o; a <= i; a += 1) { + for (let h = o; h <= i; h += 1) { if (l.signal.aborted) return null; - if (await Vt(e, a, t) === n) + if (await kt(e, h, t) === n) return { - number: a, + number: h, took: Date.now() - s }; } @@ -582,41 +575,41 @@ function Zn(n, e, t = "SHA-256", i = 1e6, o = 0) { controller: l }; } -function Ht() { +function xn() { try { return Intl.DateTimeFormat().resolvedOptions().timeZone; } catch { } } -function Vn(n) { +function En(n) { const e = atob(n), t = new Uint8Array(e.length); for (let i = 0; i < e.length; i++) t[i] = e.charCodeAt(i); return t; } -function Hn(n, e = 12) { +function Rn(n, e = 12) { const t = new Uint8Array(e); for (let i = 0; i < e; i++) t[i] = n % 256, n = Math.floor(n / 256); return t; } -async function Gn(n, e = "", t = 1e6, i = 0) { - const o = "AES-GCM", l = new AbortController(), s = Date.now(), c = async () => { - for (let v = i; v <= t; v += 1) { - if (l.signal.aborted || !a || !d) +async function Cn(n, e = "", t = 1e6, i = 0) { + const o = "AES-GCM", l = new AbortController(), s = Date.now(), d = async () => { + for (let C = i; C <= t; C += 1) { + if (l.signal.aborted || !h || !f) return null; try { - const R = await crypto.subtle.decrypt( + const b = await crypto.subtle.decrypt( { name: o, - iv: Hn(v) + iv: Rn(C) }, - a, - d + h, + f ); - if (R) + if (b) return { - clearText: new TextDecoder().decode(R), + clearText: new TextDecoder().decode(b), took: Date.now() - s }; } catch { @@ -624,16 +617,16 @@ async function Gn(n, e = "", t = 1e6, i = 0) { } return null; }; - let a = null, d = null; + let h = null, f = null; try { - d = Vn(n); - const v = await crypto.subtle.digest( + f = En(n); + const C = await crypto.subtle.digest( "SHA-256", - Zt.encode(e) + _t.encode(e) ); - a = await crypto.subtle.importKey( + h = await crypto.subtle.importKey( "raw", - v, + C, o, !1, ["decrypt"] @@ -645,184 +638,83 @@ async function Gn(n, e = "", t = 1e6, i = 0) { }; } return { - promise: c(), + promise: d(), controller: l }; } -var me, ge, xe, Ce, Re, Le; -class Dn { - constructor(e) { - D(this, "beaconUrl", null); - D(this, "error", null); - D(this, "loadTime", Date.now()); - D(this, "submitTime", null); - D(this, "startTime", null); - D(this, "viewTimeThresholdMs", 1500); - fe(this, me, {}); - fe(this, ge, null); - fe(this, xe, this.onFormChange.bind(this)); - fe(this, Ce, this.onFormFocus.bind(this)); - fe(this, Re, this.onFormSubmit.bind(this)); - fe(this, Le, this.onUnload.bind(this)); - this.elForm = e, window.addEventListener("unload", W(this, Le)), this.elForm.addEventListener("change", W(this, xe)), this.elForm.addEventListener("focusin", W(this, Ce)), this.elForm.addEventListener("submit", W(this, Re)); - } - data() { - const e = Object.entries(W(this, me)); - return { - correction: e.length && e.filter(([t, i]) => i > 1).length / e.length || 0, - dropoff: !this.submitTime && !this.error && W(this, ge) ? W(this, ge) : null, - error: this.error, - mobile: this.isMobile(), - start: this.startTime, - submit: this.submitTime, - tz: Ht() - }; - } - dataAsBase64() { - try { - return btoa( - JSON.stringify(this.data()) - ); - } catch (e) { - console.error("failed to encode ALTCHA session data to base64", e); - } - return ""; - } - destroy() { - window.removeEventListener("unload", W(this, Le)), this.elForm.removeEventListener("change", W(this, xe)), this.elForm.removeEventListener("focusin", W(this, Ce)), this.elForm.removeEventListener("submit", W(this, Re)); - } - end() { - this.submitTime || (this.submitTime = Date.now()); - } - getFieldName(e, t = 40) { - const i = e.getAttribute("data-group-label"), o = e.getAttribute("name") || e.getAttribute("aria-label"); - return ((i ? i + ": " : "") + o).slice(0, t); - } - isMobile() { - const e = "userAgentData" in navigator && navigator.userAgentData ? navigator.userAgentData : {}; - return "mobile" in e ? e.mobile === !0 : /Mobi/i.test(window.navigator.userAgent); - } - isInput(e) { - return ["INPUT", "SELECT", "TEXTAREA"].includes(e.tagName); - } - onFormFieldChange(e) { - const t = this.getFieldName(e); - t && this.trackFieldChange(t); - } - onFormChange(e) { - const t = e.target; - t && this.isInput(t) && this.onFormFieldChange(t); - } - onFormFocus(e) { - const t = e.target; - if (this.startTime || this.start(), t && this.isInput(t)) { - const i = this.getFieldName(t); - i && ht(this, ge, i); - } - } - onFormSubmit() { - this.end(); - } - onUnload() { - this.loadTime <= Date.now() - this.viewTimeThresholdMs && !this.submitTime && this.sendBeacon(); - } - async sendBeacon() { - if (this.beaconUrl && "sendBeacon" in navigator) - try { - navigator.sendBeacon( - new URL(this.beaconUrl, location.origin), - JSON.stringify(this.data()) - ); - } catch { - } - } - start() { - this.startTime = Date.now(); - } - trackError(e) { - this.error = e === null ? null : String(e); - } - trackFieldChange(e) { - W(this, me)[e] = (W(this, me)[e] || 0) + 1; - } -} -me = new WeakMap(), ge = new WeakMap(), xe = new WeakMap(), Ce = new WeakMap(), Re = new WeakMap(), Le = new WeakMap(); -var y = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(y || {}); -function Yn(n) { - un(n, "svelte-ddsc3z", '.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}'); +var m = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(m || {}); +function In(n) { + Qt(n, "svelte-ddsc3z", '.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}'); } -function vt(n) { +function lt(n) { let e, t, i; return { c() { - e = ie("svg"), t = ie("path"), i = ie("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 svelte-ddsc3z"), f(e, "width", "24"), f(e, "height", "24"), f(e, "viewBox", "0 0 24 24"), f(e, "xmlns", "http://www.w3.org/2000/svg"); + e = $("svg"), t = $("path"), i = $("path"), a(t, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), a(t, "fill", "currentColor"), a(t, "opacity", ".25"), a(i, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), a(i, "fill", "currentColor"), a(i, "class", "altcha-spinner svelte-ddsc3z"), a(e, "width", "24"), a(e, "height", "24"), a(e, "viewBox", "0 0 24 24"), a(e, "xmlns", "http://www.w3.org/2000/svg"); }, m(o, l) { - Y(o, e, l), L(e, t), L(e, i); + X(o, e, l), L(e, t), L(e, i); }, d(o) { - o && S(e); + o && Y(e); } }; } -function Un(n) { +function Ln(n) { let e, t = ( /*_strings*/ - n[13].label + "" + n[11].label + "" ), i; return { c() { - e = N("label"), f(e, "for", i = /*name*/ - n[4] + "_checkbox"), f(e, "class", "svelte-ddsc3z"); + e = Z("label"), a(e, "for", i = /*name*/ + n[4] + "_checkbox"), a(e, "class", "svelte-ddsc3z"); }, m(o, l) { - Y(o, e, l), e.innerHTML = t; + X(o, e, l), e.innerHTML = t; }, p(o, l) { l[0] & /*_strings*/ - 8192 && t !== (t = /*_strings*/ - o[13].label + "") && (e.innerHTML = t), l[0] & /*name*/ + 2048 && t !== (t = /*_strings*/ + o[11].label + "") && (e.innerHTML = t), l[0] & /*name*/ 16 && i !== (i = /*name*/ - o[4] + "_checkbox") && f(e, "for", i); + o[4] + "_checkbox") && a(e, "for", i); }, d(o) { - o && S(e); + o && Y(e); } }; } -function Xn(n) { +function Nn(n) { let e, t = ( /*_strings*/ - n[13].verifying + "" + n[11].verifying + "" ); return { c() { - e = N("span"); + e = Z("span"); }, m(i, o) { - Y(i, e, o), e.innerHTML = t; + X(i, e, o), e.innerHTML = t; }, p(i, o) { o[0] & /*_strings*/ - 8192 && t !== (t = /*_strings*/ - i[13].verifying + "") && (e.innerHTML = t); + 2048 && t !== (t = /*_strings*/ + i[11].verifying + "") && (e.innerHTML = t); }, d(i) { - i && S(e); + i && Y(e); } }; } -function Mn(n) { +function zn(n) { let e, t = ( /*_strings*/ - n[13].verified + "" - ), i, o, l, s, c = ( - /*session*/ - n[11] && wt(n) - ); + n[11].verified + "" + ), i, o; return { c() { - e = N("span"), i = q(), o = N("input"), l = q(), c && c.c(), s = mn(), f(o, "type", "hidden"), f( + e = Z("span"), i = Q(), o = Z("input"), a(o, "type", "hidden"), a( o, "name", /*name*/ @@ -830,100 +722,79 @@ function Mn(n) { ), o.value = /*payload*/ n[6]; }, - m(a, d) { - Y(a, e, d), e.innerHTML = t, Y(a, i, d), Y(a, o, d), Y(a, l, d), c && c.m(a, d), Y(a, s, d); + m(l, s) { + X(l, e, s), e.innerHTML = t, X(l, i, s), X(l, o, s); }, - p(a, d) { - d[0] & /*_strings*/ - 8192 && t !== (t = /*_strings*/ - a[13].verified + "") && (e.innerHTML = t), d[0] & /*name*/ - 16 && f( + p(l, s) { + s[0] & /*_strings*/ + 2048 && t !== (t = /*_strings*/ + l[11].verified + "") && (e.innerHTML = t), s[0] & /*name*/ + 16 && a( o, "name", /*name*/ - a[4] - ), d[0] & /*payload*/ + l[4] + ), s[0] & /*payload*/ 64 && (o.value = /*payload*/ - a[6]), /*session*/ - a[11] ? c ? c.p(a, d) : (c = wt(a), c.c(), c.m(s.parentNode, s)) : c && (c.d(1), c = null); - }, - d(a) { - a && (S(e), S(i), S(o), S(l), S(s)), c && c.d(a); - } - }; -} -function wt(n) { - let e; - return { - c() { - e = N("input"), f(e, "type", "hidden"), f(e, "name", "__session"), e.value = /*sessionPayload*/ - n[12]; - }, - m(t, i) { - Y(t, e, i); + l[6]); }, - p(t, i) { - i[0] & /*sessionPayload*/ - 4096 && (e.value = /*sessionPayload*/ - t[12]); - }, - d(t) { - t && S(e); + d(l) { + l && (Y(e), Y(i), Y(o)); } }; } -function pt(n) { - let e, t, i, o, l, s, c; +function st(n) { + let e, t, i, o, l, s, d; return { c() { - e = N("div"), t = N("a"), i = ie("svg"), o = ie("path"), l = ie("path"), s = ie("path"), f(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"), f(o, "fill", "currentColor"), f(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"), f(l, "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", Gt), f(t, "target", "_blank"), f(t, "class", "altcha-logo svelte-ddsc3z"), f(t, "aria-label", c = /*_strings*/ - n[13].ariaLinkLabel); + e = Z("div"), t = Z("a"), i = $("svg"), o = $("path"), l = $("path"), s = $("path"), a(o, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), a(o, "fill", "currentColor"), a(l, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), a(l, "fill", "currentColor"), a(s, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), a(s, "fill", "currentColor"), a(i, "width", "22"), a(i, "height", "22"), a(i, "viewBox", "0 0 20 20"), a(i, "fill", "none"), a(i, "xmlns", "http://www.w3.org/2000/svg"), a(t, "href", xt), a(t, "target", "_blank"), a(t, "class", "altcha-logo svelte-ddsc3z"), a(t, "aria-label", d = /*_strings*/ + n[11].ariaLinkLabel); }, - m(a, d) { - Y(a, e, d), L(e, t), L(t, i), L(i, o), L(i, l), L(i, s); + m(h, f) { + X(h, e, f), L(e, t), L(t, i), L(i, o), L(i, l), L(i, s); }, - p(a, d) { - d[0] & /*_strings*/ - 8192 && c !== (c = /*_strings*/ - a[13].ariaLinkLabel) && f(t, "aria-label", c); + p(h, f) { + f[0] & /*_strings*/ + 2048 && d !== (d = /*_strings*/ + h[11].ariaLinkLabel) && a(t, "aria-label", d); }, - d(a) { - a && S(e); + d(h) { + h && Y(e); } }; } -function _t(n) { +function ct(n) { let e, t, i, o; - function l(a, d) { + function l(h, f) { return ( /*state*/ - a[7] === y.EXPIRED ? Wn : jn + h[7] === m.EXPIRED ? An : Sn ); } - let s = l(n), c = s(n); + let s = l(n), d = s(n); return { c() { - e = N("div"), t = ie("svg"), i = ie("path"), o = q(), c.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 svelte-ddsc3z"); + e = Z("div"), t = $("svg"), i = $("path"), o = Q(), d.c(), a(i, "stroke-linecap", "round"), a(i, "stroke-linejoin", "round"), a(i, "d", "M6 18L18 6M6 6l12 12"), a(t, "width", "14"), a(t, "height", "14"), a(t, "xmlns", "http://www.w3.org/2000/svg"), a(t, "fill", "none"), a(t, "viewBox", "0 0 24 24"), a(t, "stroke-width", "1.5"), a(t, "stroke", "currentColor"), a(e, "class", "altcha-error svelte-ddsc3z"); }, - m(a, d) { - Y(a, e, d), L(e, t), L(t, i), L(e, o), c.m(e, null); + m(h, f) { + X(h, e, f), L(e, t), L(t, i), L(e, o), d.m(e, null); }, - p(a, d) { - s === (s = l(a)) && c ? c.p(a, d) : (c.d(1), c = s(a), c && (c.c(), c.m(e, null))); + p(h, f) { + s === (s = l(h)) && d ? d.p(h, f) : (d.d(1), d = s(h), d && (d.c(), d.m(e, null))); }, - d(a) { - a && S(e), c.d(); + d(h) { + h && Y(e), d.d(); } }; } -function jn(n) { +function Sn(n) { let e, t = ( /*_strings*/ - n[13].error + "" + n[11].error + "" ); return { c() { - e = N("div"), f( + e = Z("div"), a( e, "title", /*error*/ @@ -931,13 +802,13 @@ function jn(n) { ); }, m(i, o) { - Y(i, e, o), e.innerHTML = t; + X(i, e, o), e.innerHTML = t; }, p(i, o) { o[0] & /*_strings*/ - 8192 && t !== (t = /*_strings*/ - i[13].error + "") && (e.innerHTML = t), o[0] & /*error*/ - 32 && f( + 2048 && t !== (t = /*_strings*/ + i[11].error + "") && (e.innerHTML = t), o[0] & /*error*/ + 32 && a( e, "title", /*error*/ @@ -945,18 +816,18 @@ function jn(n) { ); }, d(i) { - i && S(e); + i && Y(e); } }; } -function Wn(n) { +function An(n) { let e, t = ( /*_strings*/ - n[13].expired + "" + n[11].expired + "" ); return { c() { - e = N("div"), f( + e = Z("div"), a( e, "title", /*error*/ @@ -964,13 +835,13 @@ function Wn(n) { ); }, m(i, o) { - Y(i, e, o), e.innerHTML = t; + X(i, e, o), e.innerHTML = t; }, p(i, o) { o[0] & /*_strings*/ - 8192 && t !== (t = /*_strings*/ - i[13].expired + "") && (e.innerHTML = t), o[0] & /*error*/ - 32 && f( + 2048 && t !== (t = /*_strings*/ + i[11].expired + "") && (e.innerHTML = t), o[0] & /*error*/ + 32 && a( e, "title", /*error*/ @@ -978,804 +849,881 @@ function Wn(n) { ); }, d(i) { - i && S(e); + i && Y(e); } }; } -function kt(n) { +function at(n) { let e, t, i = ( /*_strings*/ - n[13].footer + "" + n[11].footer + "" ); return { c() { - e = N("div"), t = N("div"), f(t, "class", "svelte-ddsc3z"), f(e, "class", "altcha-footer svelte-ddsc3z"); + e = Z("div"), t = Z("div"), a(t, "class", "svelte-ddsc3z"), a(e, "class", "altcha-footer svelte-ddsc3z"); }, m(o, l) { - Y(o, e, l), L(e, t), t.innerHTML = i; + X(o, e, l), L(e, t), t.innerHTML = i; }, p(o, l) { l[0] & /*_strings*/ - 8192 && i !== (i = /*_strings*/ - o[13].footer + "") && (t.innerHTML = i); + 2048 && i !== (i = /*_strings*/ + o[11].footer + "") && (t.innerHTML = i); }, d(o) { - o && S(e); + o && Y(e); } }; } -function Et(n) { +function ft(n) { let e; return { c() { - e = N("div"), f(e, "class", "altcha-anchor-arrow svelte-ddsc3z"); + e = Z("div"), a(e, "class", "altcha-anchor-arrow svelte-ddsc3z"); }, m(t, i) { - Y(t, e, i), n[46](e); + X(t, e, i), n[48](e); }, - p: Se, + p: Re, d(t) { - t && S(e), n[46](null); + t && Y(e), n[48](null); } }; } -function Bn(n) { - let e, t, i, o, l, s, c, a, d, v, R, $, k, K, X, ee, te; - const A = ( +function Tn(n) { + let e, t, i, o, l, s, d, h, f, C, b, M, D, j, S, N, O; + const J = ( /*#slots*/ - n[44].default - ), U = sn( - A, + n[46].default + ), G = Mt( + J, n, /*$$scope*/ - n[43], + n[45], null ); - let Z = ( + let A = ( /*state*/ - n[7] === y.VERIFYING && vt() + n[7] === m.VERIFYING && lt() ); - function oe(h, x) { + function q(u, y) { return ( /*state*/ - h[7] === y.VERIFIED ? Mn : ( + u[7] === m.VERIFIED ? zn : ( /*state*/ - h[7] === y.VERIFYING ? Xn : Un + u[7] === m.VERIFYING ? Nn : Ln ) ); } - let ne = oe(n), j = ne(n), I = ( + let K = q(n), H = K(n), x = ( /*hidelogo*/ (n[3] !== !0 || /*isFreeSaaS*/ - n[14]) && pt(n) - ), z = ( + n[12]) && st(n) + ), T = ( /*error*/ (n[5] || /*state*/ - n[7] === y.EXPIRED) && _t(n) - ), E = ( + n[7] === m.EXPIRED) && ct(n) + ), z = ( /*_strings*/ - n[13].footer && /*hidefooter*/ + n[11].footer && /*hidefooter*/ (n[2] !== !0 || /*isFreeSaaS*/ - n[14]) && kt(n) - ), F = ( + n[12]) && at(n) + ), _ = ( /*floating*/ - n[1] && Et(n) + n[1] && ft(n) ); return { c() { - U && U.c(), e = q(), t = N("div"), i = N("div"), Z && Z.c(), o = q(), l = N("div"), s = N("input"), d = q(), v = N("div"), j.c(), R = q(), I && I.c(), $ = q(), z && z.c(), k = q(), E && E.c(), K = q(), F && F.c(), f(s, "type", "checkbox"), f(s, "id", c = /*name*/ - n[4] + "_checkbox"), s.required = a = /*auto*/ - n[0] !== "onsubmit", f(s, "class", "svelte-ddsc3z"), f(l, "class", "altcha-checkbox svelte-ddsc3z"), bt( + G && G.c(), e = Q(), t = Z("div"), i = Z("div"), A && A.c(), o = Q(), l = Z("div"), s = Z("input"), f = Q(), C = Z("div"), H.c(), b = Q(), x && x.c(), M = Q(), T && T.c(), D = Q(), z && z.c(), j = Q(), _ && _.c(), a(s, "type", "checkbox"), a(s, "id", d = /*name*/ + n[4] + "_checkbox"), s.required = h = /*auto*/ + n[0] !== "onsubmit" && (!/*floating*/ + n[1] || /*auto*/ + n[0] !== "off"), a(s, "class", "svelte-ddsc3z"), a(l, "class", "altcha-checkbox svelte-ddsc3z"), it( l, "altcha-hidden", /*state*/ - n[7] === y.VERIFYING - ), f(v, "class", "altcha-label svelte-ddsc3z"), f(i, "class", "altcha-main svelte-ddsc3z"), f(t, "class", "altcha svelte-ddsc3z"), f( + n[7] === m.VERIFYING + ), a(C, "class", "altcha-label svelte-ddsc3z"), a(i, "class", "altcha-main svelte-ddsc3z"), a(t, "class", "altcha svelte-ddsc3z"), a( t, "data-state", /*state*/ n[7] - ), f( + ), a( t, "data-floating", /*floating*/ n[1] ); }, - m(h, x) { - U && U.m(h, x), Y(h, e, x), Y(h, t, x), L(t, i), Z && Z.m(i, null), L(i, o), L(i, l), L(l, s), s.checked = /*checked*/ - n[8], L(i, d), L(i, v), j.m(v, null), L(i, R), I && I.m(i, null), L(t, $), z && z.m(t, null), L(t, k), E && E.m(t, null), L(t, K), F && F.m(t, null), n[47](t), X = !0, ee || (te = [ - De( + m(u, y) { + G && G.m(u, y), X(u, e, y), X(u, t, y), L(t, i), A && A.m(i, null), L(i, o), L(i, l), L(l, s), s.checked = /*checked*/ + n[8], L(i, f), L(i, C), H.m(C, null), L(i, b), x && x.m(i, null), L(t, M), T && T.m(t, null), L(t, D), z && z.m(t, null), L(t, j), _ && _.m(t, null), n[49](t), S = !0, N || (O = [ + Le( s, "change", /*input_change_handler*/ - n[45] + n[47] ), - De( + Le( s, "change", /*onCheckedChange*/ - n[15] + n[13] ), - De( + Le( s, "invalid", /*onInvalid*/ - n[16] + n[14] ) - ], ee = !0); + ], N = !0); }, - p(h, x) { - U && U.p && (!X || x[1] & /*$$scope*/ - 4096) && an( - U, - A, - h, + p(u, y) { + G && G.p && (!S || y[1] & /*$$scope*/ + 16384) && Ot( + G, + J, + u, /*$$scope*/ - h[43], - X ? cn( - A, + u[45], + S ? Bt( + J, /*$$scope*/ - h[43], - x, + u[45], + y, null - ) : fn( + ) : Jt( /*$$scope*/ - h[43] + u[45] ), null ), /*state*/ - h[7] === y.VERIFYING ? Z || (Z = vt(), Z.c(), Z.m(i, o)) : Z && (Z.d(1), Z = null), (!X || x[0] & /*name*/ - 16 && c !== (c = /*name*/ - h[4] + "_checkbox")) && f(s, "id", c), (!X || x[0] & /*auto*/ - 1 && a !== (a = /*auto*/ - h[0] !== "onsubmit")) && (s.required = a), x[0] & /*checked*/ + u[7] === m.VERIFYING ? A || (A = lt(), A.c(), A.m(i, o)) : A && (A.d(1), A = null), (!S || y[0] & /*name*/ + 16 && d !== (d = /*name*/ + u[4] + "_checkbox")) && a(s, "id", d), (!S || y[0] & /*auto, floating*/ + 3 && h !== (h = /*auto*/ + u[0] !== "onsubmit" && (!/*floating*/ + u[1] || /*auto*/ + u[0] !== "off"))) && (s.required = h), y[0] & /*checked*/ 256 && (s.checked = /*checked*/ - h[8]), (!X || x[0] & /*state*/ - 128) && bt( + u[8]), (!S || y[0] & /*state*/ + 128) && it( l, "altcha-hidden", /*state*/ - h[7] === y.VERIFYING - ), ne === (ne = oe(h)) && j ? j.p(h, x) : (j.d(1), j = ne(h), j && (j.c(), j.m(v, null))), /*hidelogo*/ - h[3] !== !0 || /*isFreeSaaS*/ - h[14] ? I ? I.p(h, x) : (I = pt(h), I.c(), I.m(i, null)) : I && (I.d(1), I = null), /*error*/ - h[5] || /*state*/ - h[7] === y.EXPIRED ? z ? z.p(h, x) : (z = _t(h), z.c(), z.m(t, k)) : z && (z.d(1), z = null), /*_strings*/ - h[13].footer && /*hidefooter*/ - (h[2] !== !0 || /*isFreeSaaS*/ - h[14]) ? E ? E.p(h, x) : (E = kt(h), E.c(), E.m(t, K)) : E && (E.d(1), E = null), /*floating*/ - h[1] ? F ? F.p(h, x) : (F = Et(h), F.c(), F.m(t, null)) : F && (F.d(1), F = null), (!X || x[0] & /*state*/ - 128) && f( + u[7] === m.VERIFYING + ), K === (K = q(u)) && H ? H.p(u, y) : (H.d(1), H = K(u), H && (H.c(), H.m(C, null))), /*hidelogo*/ + u[3] !== !0 || /*isFreeSaaS*/ + u[12] ? x ? x.p(u, y) : (x = st(u), x.c(), x.m(i, null)) : x && (x.d(1), x = null), /*error*/ + u[5] || /*state*/ + u[7] === m.EXPIRED ? T ? T.p(u, y) : (T = ct(u), T.c(), T.m(t, D)) : T && (T.d(1), T = null), /*_strings*/ + u[11].footer && /*hidefooter*/ + (u[2] !== !0 || /*isFreeSaaS*/ + u[12]) ? z ? z.p(u, y) : (z = at(u), z.c(), z.m(t, j)) : z && (z.d(1), z = null), /*floating*/ + u[1] ? _ ? _.p(u, y) : (_ = ft(u), _.c(), _.m(t, null)) : _ && (_.d(1), _ = null), (!S || y[0] & /*state*/ + 128) && a( t, "data-state", /*state*/ - h[7] - ), (!X || x[0] & /*floating*/ - 2) && f( + u[7] + ), (!S || y[0] & /*floating*/ + 2) && a( t, "data-floating", /*floating*/ - h[1] + u[1] ); }, - i(h) { - X || (Ft(U, h), X = !0); + i(u) { + S || (pt(G, u), S = !0); }, - o(h) { - Cn(U, h), X = !1; + o(u) { + dn(G, u), S = !1; }, - d(h) { - h && (S(e), S(t)), U && U.d(h), Z && Z.d(), j.d(), I && I.d(), z && z.d(), E && E.d(), F && F.d(), n[47](null), ee = !1, Ie(te); + d(u) { + u && (Y(e), Y(t)), G && G.d(u), A && A.d(), H.d(), x && x.d(), T && T.d(), z && z.d(), _ && _.d(), n[49](null), N = !1, we(O); } }; } -const xt = "Visit Altcha.org", Gt = "https://altcha.org/"; -function Ct(n) { +const ut = "Visit Altcha.org", xt = "https://altcha.org/"; +function dt(n) { return JSON.parse(n); } -function Kn(n, e, t) { - var ct, at; - let i, o, l, s, { $$slots: c = {}, $$scope: a } = e, { analytics: d = !1 } = e, { auto: v = void 0 } = e, { beaconurl: R = void 0 } = e, { blockspam: $ = void 0 } = e, { challengeurl: k = void 0 } = e, { challengejson: K = void 0 } = e, { debug: X = !1 } = e, { delay: ee = 0 } = e, { expire: te = void 0 } = e, { floating: A = void 0 } = e, { floatinganchor: U = void 0 } = e, { floatingoffset: Z = void 0 } = e, { hidefooter: oe = !1 } = e, { hidelogo: ne = !1 } = e, { name: j = "altcha" } = e, { maxnumber: I = 1e6 } = e, { mockerror: z = !1 } = e, { obfuscated: E = void 0 } = e, { refetchonexpire: F = !0 } = e, { spamfilter: h = !1 } = e, { strings: x = void 0 } = e, { test: P = !1 } = e, { verifyurl: le = void 0 } = e, { workers: be = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: Te = void 0 } = e; - const Ve = pn(), je = ["SHA-256", "SHA-384", "SHA-512"], We = (at = (ct = document.documentElement.lang) == null ? void 0 : ct.split("-")) == null ? void 0 : at[0]; - let O = !1, J = null, _, se = null, Ne = null, b = null, re = null, ye = null, Q = null, ce = null, M = null, Be = null, T = y.UNVERIFIED; - wn(() => { - b && (b.removeEventListener("submit", Oe), b.removeEventListener("reset", Je), b.removeEventListener("focusin", Pe), b = null), re && _.removeEventListener("click", Ke), M && M.destroy(), Q && (clearTimeout(Q), Q = null), document.removeEventListener("click", nt), document.removeEventListener("scroll", rt), window.removeEventListener("resize", ot); - }), vn(() => { - var r, u; - C("mounted", "0.8.0"), C("workers", be), P && C("using test mode"), te && Ae(te), v !== void 0 && C("auto", v), A !== void 0 && lt(A), b = _.closest("form"), b && (b.addEventListener("submit", Oe, { capture: !0 }), b.addEventListener("reset", Je), v === "onfocus" && b.addEventListener("focusin", Pe)), re = ((r = _.parentElement) == null ? void 0 : r.querySelector("[data-clarify-button]")) || ((u = _.parentElement) == null ? void 0 : u.querySelector("button, a")), re && re.addEventListener("click", Ke), d && $e(), v === "onload" && (E ? we() : ae()), i && (oe || ne) && C("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution."); +function Zn(n, e, t) { + var qe, et; + let i, o, l, s, { $$slots: d = {}, $$scope: h } = e, { auto: f = void 0 } = e, { blockspam: C = void 0 } = e, { challengeurl: b = void 0 } = e, { challengejson: M = void 0 } = e, { debug: D = !1 } = e, { delay: j = 0 } = e, { expire: S = void 0 } = e, { floating: N = void 0 } = e, { floatinganchor: O = void 0 } = e, { floatingoffset: J = void 0 } = e, { hidefooter: G = !1 } = e, { hidelogo: A = !1 } = e, { name: q = "altcha" } = e, { maxnumber: K = 1e6 } = e, { mockerror: H = !1 } = e, { obfuscated: x = void 0 } = e, { plugins: T = void 0 } = e, { refetchonexpire: z = !0 } = e, { spamfilter: _ = !1 } = e, { strings: u = void 0 } = e, { test: y = !1 } = e, { verifyurl: ee = void 0 } = e, { workers: le = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: ue = void 0 } = e; + const de = sn(), Te = ["SHA-256", "SHA-384", "SHA-512"], Ze = (et = (qe = document.documentElement.lang) == null ? void 0 : qe.split("-")) == null ? void 0 : et[0]; + let re = !1, E, ie = null, se = null, v = null, he = null, B = null, oe = null, te = [], R = m.UNVERIFIED; + ln(() => { + Et(), v && (v.removeEventListener("submit", Fe), v.removeEventListener("reset", De), v.removeEventListener("focusin", Xe), v = null), B && (clearTimeout(B), B = null), document.removeEventListener("click", He), document.removeEventListener("scroll", Ye), window.removeEventListener("resize", Pe); + }), on(() => { + k("mounted", "0.9.0"), k("workers", le), Nt(), k("plugins", te.length ? te.map((r) => r.constructor.pluginName).join(", ") : "none"), y && k("using test mode"), S && ke(S), f !== void 0 && k("auto", f), N !== void 0 && We(N), v = E.closest("form"), v && (v.addEventListener("submit", Fe, { capture: !0 }), v.addEventListener("reset", De), f === "onfocus" && v.addEventListener("focusin", Xe)), f === "onload" && (x ? ge() : ne()), i && (G || A) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."), requestAnimationFrame(() => { + de("load"); + }); }); - function C(...r) { - (X || r.some((u) => u instanceof Error)) && console[r[0] instanceof Error ? "error" : "log"]("ALTCHA", ...r); - } - function Ke(r) { - r.preventDefault(), T === y.UNVERIFIED && we(); - } - function Pe(r) { - T === y.UNVERIFIED && ae(); - } - function Oe(r) { - b && M && T === y.VERIFIED && (M.end(), t(12, Be = M.dataAsBase64())), b && v === "onsubmit" && (T === y.UNVERIFIED ? (r.preventDefault(), r.stopPropagation(), ae().then(() => { - b == null || b.requestSubmit(); - })) : T !== y.VERIFIED && (r.preventDefault(), r.stopPropagation(), T === y.VERIFYING && it())); - } - function Je() { - ve(); - } - function Qe(r, u) { + function Ve(r, c) { return btoa(JSON.stringify({ algorithm: r.algorithm, challenge: r.challenge, - number: u.number, + number: c.number, salt: r.salt, signature: r.signature, - test: P ? !0 : void 0, - took: u.took + test: y ? !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 (!je.includes(r.algorithm.toUpperCase())) - throw new Error(`Unknown algorithm value. Allowed values: ${je.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."); + function Et() { + for (const r of te) + r.destroy(); } - async function Dt() { + function Ge() { + b && z && R === m.VERIFIED ? ne() : me(m.EXPIRED, s.expired); + } + async function Rt() { var r; - if (z) - throw C("mocking error"), new Error("Mocked error."); + if (H) + throw k("mocking error"), new Error("Mocked error."); if (o) - return C("using provided json data"), o; - if (P) - return C("generating test challenge", { test: P }), Sn(typeof P != "boolean" ? +P : void 0); + return k("using provided json data"), o; + if (y) + return k("generating test challenge", { test: y }), _n(typeof y != "boolean" ? +y : void 0); { - if (!k && b) { - const w = b.getAttribute("action"); - w != null && w.includes("/form/") && t(17, k = w + "/altcha"); + if (!b && v) { + const p = v.getAttribute("action"); + p != null && p.includes("/form/") && t(15, b = p + "/altcha"); } - if (!k) + if (!b) throw new Error("Attribute challengeurl not set."); - C("fetching challenge from", k); - const u = await fetch(k, { - headers: h ? { "x-altcha-spam-filter": "1" } : {} + k("fetching challenge from", b); + const c = await fetch(b, { + headers: _ ? { "x-altcha-spam-filter": "1" } : {} }); - if (u.status !== 200) - throw new Error(`Server responded with ${u.status}.`); - const m = u.headers.get("Expires"), g = u.headers.get("X-Altcha-Config"), V = await u.json(), H = new URLSearchParams((r = V.salt.split("?")) == null ? void 0 : r[1]), G = H.get("expires") || H.get("expire"); - if (G) { - const w = new Date(+G * 1e3), B = isNaN(w.getTime()) ? 0 : w.getTime() - Date.now(); - B > 0 && Ae(B); + if (c.status !== 200) + throw new Error(`Server responded with ${c.status}.`); + const g = c.headers.get("Expires"), I = c.headers.get("X-Altcha-Config"), P = await c.json(), F = new URLSearchParams((r = P.salt.split("?")) == null ? void 0 : r[1]), V = F.get("expires") || F.get("expire"); + if (V) { + const p = new Date(+V * 1e3), W = isNaN(p.getTime()) ? 0 : p.getTime() - Date.now(); + W > 0 && ke(W); } - if (g) + if (I) try { - const w = JSON.parse(g); - w && typeof w == "object" && (w.verifyurl && (w.verifyurl = new URL(w.verifyurl, new URL(k)).toString()), st(w)); - } catch (w) { - C("unable to configure from X-Altcha-Config", w); + const p = JSON.parse(I); + p && typeof p == "object" && (p.verifyurl && (p.verifyurl = new URL(p.verifyurl, new URL(b)).toString()), Me(p)); + } catch (p) { + k("unable to configure from X-Altcha-Config", p); } - if (!te && (m != null && m.length)) { - const w = Date.parse(m); - if (w) { - const B = w - Date.now(); - B > 0 && Ae(B); + if (!S && (g != null && g.length)) { + const p = Date.parse(g); + if (p) { + const W = p - Date.now(); + W > 0 && ke(W); } } - return V; + return P; } } - function $e() { - if (!M) - if (b) { - if (C("analytics enabled"), t(11, M = new Dn(b)), R === void 0) { - const r = b.getAttribute("action"); - r && t(19, R = r + "/beacon"); + function Ct(r) { + var g; + const c = v == null ? void 0 : v.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 It() { + return _ === "ipAddress" ? { + blockedCountries: void 0, + classifier: void 0, + disableRules: void 0, + email: !1, + expectedCountries: void 0, + expectedLanguages: void 0, + fields: !1, + ipAddress: void 0, + text: void 0, + timeZone: void 0 + } : typeof _ == "object" ? _ : { + blockedCountries: void 0, + classifier: void 0, + disableRules: void 0, + email: void 0, + expectedCountries: void 0, + expectedLanguages: void 0, + fields: void 0, + ipAddress: void 0, + text: void 0, + timeZone: void 0 + }; + } + function Lt(r) { + return [ + ...(v == null ? void 0 : v.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, I) => { + const P = I.name, F = I.value; + return P && F && (g[P] = /\n/.test(F) ? F.replace(new RegExp("(? c instanceof Error)) && console[r[0] instanceof Error ? "error" : "log"]("ALTCHA", `[name=${q}]`, ...r); + } + function zt() { + [m.UNVERIFIED, m.ERROR, m.EXPIRED].includes(R) ? _ && (v == null ? void 0 : v.reportValidity()) === !1 ? t(8, re = !1) : x ? ge() : ne() : t(8, re = !0); + } + function He(r) { + const c = r.target; + N && c && !E.contains(c) && (R === m.VERIFIED || f === "off" && R === m.UNVERIFIED) && t(9, E.style.display = "none", E); + } + function Ye() { + N && R !== m.UNVERIFIED && _e(); + } + function St(r) { + for (const c of te) + typeof c.onErrorChange == "function" && c.onErrorChange(he); + } + function Xe(r) { + R === m.UNVERIFIED && ne(); + } + function Fe(r) { + v && f === "onsubmit" ? R === m.UNVERIFIED ? (r.preventDefault(), r.stopPropagation(), ne().then(() => { + v == null || v.requestSubmit(); + })) : R !== m.VERIFIED && (r.preventDefault(), r.stopPropagation(), R === m.VERIFYING && je()) : v && N && f === "off" && R === m.UNVERIFIED && (r.preventDefault(), r.stopPropagation(), t(9, E.style.display = "block", E), _e()); + } + function De() { + me(); + } + function je() { + R === m.VERIFYING && s.waitAlert && alert(s.waitAlert); + } + function At(r) { + for (const c of te) + typeof c.onStateChange == "function" && c.onStateChange(R); + N && R !== m.UNVERIFIED && requestAnimationFrame(() => { + _e(); + }), t(8, re = R === m.VERIFIED); + } + function Pe() { + N && _e(); + } + function _e(r = 20) { + if (E) + if (se || (se = (O ? document.querySelector(O) : v == null ? void 0 : v.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || v), se) { + const c = parseInt(J, 10) || 12, g = se.getBoundingClientRect(), I = E.getBoundingClientRect(), P = document.documentElement.clientHeight, F = document.documentElement.clientWidth, V = N === "auto" ? g.bottom + I.height + c + r > P : N === "top", p = Math.max(r, Math.min(F - r - I.width, g.left + g.width / 2 - I.width / 2)); + if (V ? t(9, E.style.top = `${g.top - (I.height + c)}px`, E) : t(9, E.style.top = `${g.bottom + c}px`, E), t(9, E.style.left = `${p}px`, E), E.setAttribute("data-floating", V ? "top" : "bottom"), ie) { + const W = ie.getBoundingClientRect(); + t(10, ie.style.left = g.left - p + g.width / 2 - W.width / 2 + "px", ie); } - t(11, M.beaconUrl = R || null, M); } else - C("analytics cannot be enabled - form element not found"); + k("unable to find floating anchor element"); + } + async function Tt(r) { + if (!ee) + throw new Error("Attribute verifyurl not set."); + k("requesting server verification from", ee); + const c = { payload: r }; + if (_) { + const { blockedCountries: P, classifier: F, disableRules: V, email: p, expectedLanguages: W, expectedCountries: Ie, fields: be, ipAddress: ye, text: Xt, timeZone: tt } = It(); + c.blockedCountries = P, c.classifier = F, c.disableRules = V, c.email = p === !1 ? void 0 : Ct(p), c.expectedCountries = Ie, c.expectedLanguages = W || (Ze ? [Ze] : void 0), c.fields = be === !1 ? void 0 : Lt(be), c.ipAddress = ye === !1 ? void 0 : ye || "auto", c.text = Xt, c.timeZone = tt === !1 ? void 0 : tt || xn(); + } + const g = await fetch(ee, { + body: JSON.stringify(c), + headers: { "content-type": "application/json" }, + method: "POST" + }); + if (g.status !== 200) + throw new Error(`Server responded with ${g.status}.`); + const I = await g.json(); + if (I != null && I.payload && t(6, oe = I.payload), de("serververification", I), C && I.classification === "BAD") + throw new Error("SpamFilter returned negative classification."); + } + function ke(r) { + k("expire", r), B && (clearTimeout(B), B = null), r < 1 ? Ge() : B = setTimeout(Ge, r); } - function et() { - k && F && T === y.VERIFIED ? ae() : ve(y.EXPIRED, s.expired); + function We(r) { + k("floating", r), N !== r && (t(9, E.style.left = "", E), t(9, E.style.top = "", E)), t(1, N = r === !0 || r === "" ? "auto" : r === !1 || r === "false" ? void 0 : N), N ? (f || t(0, f = "onsubmit"), document.addEventListener("scroll", Ye), document.addEventListener("click", He), window.addEventListener("resize", Pe)) : f === "onsubmit" && t(0, f = void 0); + } + function Ue(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 (!Te.includes(r.algorithm.toUpperCase())) + throw new Error(`Unknown algorithm value. Allowed values: ${Te.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 tt(r) { - let u = null; + async function Ke(r) { + let c = null; if ("Worker" in window) { try { - u = await Yt(r, r.maxnumber); - } catch (m) { - C(m); + c = await Zt(r, r.maxnumber); + } catch (g) { + k(g); } - if ((u == null ? void 0 : u.number) !== void 0 || "obfuscated" in r) - return { data: r, solution: u }; + if ((c == null ? void 0 : c.number) !== void 0 || "obfuscated" in r) + return { data: r, solution: c }; } if ("obfuscated" in r) { - const m = await Gn(r.obfuscated, r.key, r.maxnumber); - return { data: r, solution: await m.promise }; + const g = await Cn(r.obfuscated, r.key, r.maxnumber); + return { data: r, solution: await g.promise }; } return { data: r, - solution: await Zn(r.challenge, r.salt, r.algorithm, r.maxnumber || I).promise + solution: await kn(r.challenge, r.salt, r.algorithm, r.maxnumber || K).promise }; } - async function Yt(r, u = typeof P == "number" ? P : I, m = Math.ceil(be)) { - const g = []; - m = Math.min(16, Math.max(1, m)); - for (let G = 0; G < m; G++) - g.push(createAltchaWorker(Te)); - const V = Math.ceil(u / m), H = await Promise.all(g.map((G, w) => { - const B = w * V; - return new Promise((Ge) => { - G.addEventListener("message", (pe) => { - if (pe.data) - for (const _e of g) - _e !== G && _e.postMessage({ type: "abort" }); - Ge(pe.data); - }), G.postMessage({ + async function Zt(r, c = typeof y == "number" ? y : K, g = Math.ceil(le)) { + const I = []; + g = Math.min(16, Math.max(1, g)); + for (let V = 0; V < g; V++) + I.push(altchaCreateWorker(ue)); + const P = Math.ceil(c / g), F = await Promise.all(I.map((V, p) => { + const W = p * P; + return new Promise((Ie) => { + V.addEventListener("message", (be) => { + if (be.data) + for (const ye of I) + ye !== V && ye.postMessage({ type: "abort" }); + Ie(be.data); + }), V.postMessage({ payload: r, - max: B + V, - start: B, + max: W + P, + start: W, type: "work" }); }); })); - for (const G of g) - G.terminate(); - return H.find((G) => !!G) || null; - } - function Ut() { - [y.UNVERIFIED, y.ERROR, y.EXPIRED].includes(T) ? h && (b == null ? void 0 : b.reportValidity()) === !1 ? t(8, O = !1) : E ? we() : ae() : t(8, O = !0); - } - function nt(r) { - const u = r.target; - A && u && !_.contains(u) && T === y.VERIFIED && t(9, _.style.display = "none", _); - } - function rt() { - A && He(); - } - function it() { - T === y.VERIFYING && s.waitAlert && alert(s.waitAlert); - } - function Xt(r) { - var u; - if (J) { - const m = J.match(/^(mailto|tel|sms|https?):/); - let g; - if (m) { - const [V] = J.slice(J.indexOf(":") + 1).replace(/^\/\//, "").split("?"); - g = document.createElement("a"), g.href = J, g.innerHTML = V; - } else - g = document.createTextNode(J); - re && g && (re.after(g), (u = re.parentElement) == null || u.removeChild(re)); - } - } - function Mt(r) { - M && M.trackError(ye); - } - function jt(r) { - A && T !== y.UNVERIFIED && requestAnimationFrame(() => { - He(); - }); + for (const V of I) + V.terminate(); + return F.find((V) => !!V) || null; } - function ot() { - A && He(); - } - function Ae(r) { - C("expire", r), Q && (clearTimeout(Q), Q = null), r < 1 ? et() : Q = setTimeout(et, r); + async function ge() { + if (!x) { + t(7, R = m.ERROR); + return; + } + const r = te.find((c) => c.constructor.pluginName === "obfuscation"); + if (!r || !("clarify" in r)) { + t(7, R = m.ERROR), k("Plugin `obfuscation` not found. Import `altcha/plugins/obfuscation` to load it."); + return; + } + if ("clarify" in r && typeof r.clarify == "function") + return r.clarify(); } - function lt(r) { - C("floating", r), A !== r && (t(9, _.style.left = "", _), t(9, _.style.top = "", _)), t(1, A = r === !0 || r === "" ? "auto" : r === !1 || r === "false" ? void 0 : A), A ? (v || t(0, v = "onsubmit"), document.addEventListener("scroll", rt), document.addEventListener("click", nt), window.addEventListener("resize", ot)) : v === "onsubmit" && t(0, v = void 0); + function Me(r) { + r.obfuscated !== void 0 && t(24, x = r.obfuscated), r.auto !== void 0 && (t(0, f = r.auto), f === "onload" && (x ? ge() : ne())), r.blockspam !== void 0 && t(16, C = !!r.blockspam), r.floatinganchor !== void 0 && t(20, O = r.floatinganchor), r.delay !== void 0 && t(18, j = r.delay), r.floatingoffset !== void 0 && t(21, J = r.floatingoffset), r.floating !== void 0 && We(r.floating), r.expire !== void 0 && (ke(r.expire), t(19, S = r.expire)), r.challenge && (Ue(r.challenge), o = r.challenge), r.challengeurl !== void 0 && t(15, b = r.challengeurl), r.debug !== void 0 && t(17, D = !!r.debug), r.hidefooter !== void 0 && t(2, G = !!r.hidefooter), r.hidelogo !== void 0 && t(3, A = !!r.hidelogo), r.maxnumber !== void 0 && t(22, K = +r.maxnumber), r.mockerror !== void 0 && t(23, H = !!r.mockerror), r.name !== void 0 && t(4, q = r.name), r.refetchonexpire !== void 0 && t(25, z = !!r.refetchonexpire), r.spamfilter !== void 0 && t(26, _ = typeof r.spamfilter == "object" ? r.spamfilter : !!r.spamfilter), r.strings && t(44, l = r.strings), r.test !== void 0 && t(27, y = typeof r.test == "number" ? r.test : !!r.test), r.verifyurl !== void 0 && t(28, ee = r.verifyurl), r.workers !== void 0 && t(29, le = +r.workers), r.workerurl !== void 0 && t(30, ue = r.workerurl); } - function Wt(r) { - var m; - const u = b == null ? void 0 : b.querySelector(typeof r == "string" ? `input[name="${r}"]` : 'input[type="email"]:not([data-no-spamfilter])'); - return ((m = u == null ? void 0 : u.value) == null ? void 0 : m.slice(u.value.indexOf("@"))) || void 0; + function Be() { + return { + auto: f, + blockspam: C, + challengeurl: b, + debug: D, + delay: j, + expire: S, + floating: N, + floatinganchor: O, + floatingoffset: J, + hidefooter: G, + hidelogo: A, + name: q, + maxnumber: K, + mockerror: H, + obfuscated: x, + refetchonexpire: z, + spamfilter: _, + strings: s, + test: y, + verifyurl: ee, + workers: le, + workerurl: ue + }; } - function Bt(r) { - return [ - ...(b == null ? void 0 : b.querySelectorAll(r != null && r.length ? r.map((m) => `input[name="${m}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] - ].reduce( - (m, g) => { - const V = g.name, H = g.value; - return V && H && (m[V] = /\n/.test(H) ? H.replace(new RegExp("(? c.constructor.pluginName === r); } - function Pt() { - return h === "ipAddress" ? { - blockedCountries: void 0, - classifier: void 0, - disableRules: void 0, - email: !1, - expectedCountries: void 0, - expectedLanguages: void 0, - fields: !1, - ipAddress: void 0, - text: void 0, - timeZone: void 0 - } : typeof h == "object" ? h : { - blockedCountries: void 0, - classifier: void 0, - disableRules: void 0, - email: void 0, - expectedCountries: void 0, - expectedLanguages: void 0, - fields: void 0, - ipAddress: void 0, - text: void 0, - timeZone: void 0 - }; + function Je() { + return R; } - function He(r = 20) { - if (_) - if (Ne || (Ne = (U ? document.querySelector(U) : b == null ? void 0 : b.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || b || re), Ne) { - const u = parseInt(Z, 10) || 12, m = Ne.getBoundingClientRect(), g = _.getBoundingClientRect(), V = document.documentElement.clientHeight, H = document.documentElement.clientWidth, G = A === "auto" ? m.bottom + g.height + u + r > V : A === "top", w = Math.max(r, Math.min(H - r - g.width, m.left + m.width / 2 - g.width / 2)); - if (G ? t(9, _.style.top = `${m.top - (g.height + u)}px`, _) : t(9, _.style.top = `${m.bottom + u}px`, _), t(9, _.style.left = `${w}px`, _), _.setAttribute("data-floating", G ? "top" : "bottom"), se) { - const B = se.getBoundingClientRect(); - t(10, se.style.left = m.left - w + m.width / 2 - B.width / 2 + "px", se); - } - } else - C("unable to find floating anchor element"); + function me(r = m.UNVERIFIED, c = null) { + B && (clearTimeout(B), B = null), t(8, re = !1), t(5, he = c), t(6, oe = null), t(7, R = r); } - function st(r) { - r.analytics && (t(18, d = r.analytics), $e()), r.obfuscated !== void 0 && t(27, E = r.obfuscated), r.auto !== void 0 && (t(0, v = r.auto), v === "onload" && (E ? we() : ae())), r.beaconurl && (t(19, R = r.beaconurl), M && t(11, M.beaconUrl = R, M)), r.floatinganchor !== void 0 && t(23, U = r.floatinganchor), r.delay !== void 0 && t(21, ee = r.delay), r.floatingoffset !== void 0 && t(24, Z = r.floatingoffset), r.floating !== void 0 && lt(r.floating), r.expire !== void 0 && (Ae(r.expire), t(22, te = r.expire)), r.challenge && (qe(r.challenge), o = r.challenge), r.challengeurl !== void 0 && t(17, k = r.challengeurl), r.debug !== void 0 && t(20, X = !!r.debug), r.hidefooter !== void 0 && t(2, oe = !!r.hidefooter), r.hidelogo !== void 0 && t(3, ne = !!r.hidelogo), r.maxnumber !== void 0 && t(25, I = +r.maxnumber), r.mockerror !== void 0 && t(26, z = !!r.mockerror), r.name !== void 0 && t(4, j = r.name), r.refetchonexpire !== void 0 && t(28, F = !!r.refetchonexpire), r.spamfilter !== void 0 && t(29, h = typeof r.spamfilter == "object" ? r.spamfilter : !!r.spamfilter), r.strings && t(42, l = r.strings), r.test !== void 0 && t(30, P = typeof r.test == "number" ? r.test : !!r.test), r.verifyurl !== void 0 && t(31, le = r.verifyurl), r.workers !== void 0 && t(32, be = +r.workers), r.workerurl !== void 0 && t(33, Te = r.workerurl); + function Qe(r) { + se = r; } - function ve(r = y.UNVERIFIED, u = null) { - Q && (clearTimeout(Q), Q = null), t(8, O = !1), t(5, ye = u), t(6, ce = null), t(7, T = r); + function $e(r, c = null) { + t(7, R = r), t(5, he = c); } - async function ae() { - return ve(y.VERIFYING), await new Promise((r) => setTimeout(r, ee || 0)), Dt().then((r) => (qe(r), C("challenge", r), tt(r))).then(({ data: r, solution: u }) => { - if (C("solution", u), "challenge" in r && u && !("clearText" in u)) - if ((u == null ? void 0 : u.number) !== void 0) { - if (le) - return Kt(Qe(r, u)); - t(6, ce = Qe(r, u)), C("payload", ce); + async function ne() { + return me(m.VERIFYING), await new Promise((r) => setTimeout(r, j || 0)), Rt().then((r) => (Ue(r), k("challenge", r), Ke(r))).then(({ data: r, solution: c }) => { + if (k("solution", c), "challenge" in r && c && !("clearText" in c)) + if ((c == null ? void 0 : c.number) !== void 0) { + if (ee) + return Tt(Ve(r, c)); + t(6, oe = Ve(r, c)), k("payload", oe); } else - throw C("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); + throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); }).then(() => { - _n().then(() => { - t(7, T = y.VERIFIED), t(8, O = !0), C("verified"), Ve("verified", { payload: ce }); + cn().then(() => { + t(7, R = m.VERIFIED), k("verified"), de("verified", { payload: oe }); }); }).catch((r) => { - C(r), t(7, T = y.ERROR), t(8, O = !1), t(5, ye = r.message); + k(r), t(7, R = m.ERROR), t(5, he = r.message); }); } - async function we() { - if (!E) { - t(7, T = y.ERROR); - return; - } - ve(y.VERIFYING), await new Promise((H) => setTimeout(H, ee || 0)); - const [r, u] = E.split("?"); - let g = new URLSearchParams(u || "").get("key") || void 0; - if (g) { - const H = g.match(/^\(prompt:?(.*)\)$/); - H && (g = prompt(H[1] || "Enter Key:") || void 0); - } - const { solution: V } = await tt({ obfuscated: r, key: g, maxnumber: I }); - V && "clearText" in V ? (t(41, J = V.clearText), t(7, T = y.VERIFIED), t(8, O = !0), A && _ && t(9, _.style.display = "none", _)) : (t(7, T = y.ERROR), t(8, O = !1), t(5, ye = "Unable to decrypt data.")); - } - function Ot() { - O = this.checked, t(8, O); + function Gt() { + re = this.checked, t(8, re); } - function Jt(r) { - Ze[r ? "unshift" : "push"](() => { - se = r, t(10, se); + function Ht(r) { + Ce[r ? "unshift" : "push"](() => { + ie = r, t(10, ie); }); } - function Qt(r) { - Ze[r ? "unshift" : "push"](() => { - _ = r, t(9, _); + function Yt(r) { + Ce[r ? "unshift" : "push"](() => { + E = r, t(9, E); }); } return n.$$set = (r) => { - "analytics" in r && t(18, d = r.analytics), "auto" in r && t(0, v = r.auto), "beaconurl" in r && t(19, R = r.beaconurl), "blockspam" in r && t(34, $ = r.blockspam), "challengeurl" in r && t(17, k = r.challengeurl), "challengejson" in r && t(35, K = r.challengejson), "debug" in r && t(20, X = r.debug), "delay" in r && t(21, ee = r.delay), "expire" in r && t(22, te = r.expire), "floating" in r && t(1, A = r.floating), "floatinganchor" in r && t(23, U = r.floatinganchor), "floatingoffset" in r && t(24, Z = r.floatingoffset), "hidefooter" in r && t(2, oe = r.hidefooter), "hidelogo" in r && t(3, ne = r.hidelogo), "name" in r && t(4, j = r.name), "maxnumber" in r && t(25, I = r.maxnumber), "mockerror" in r && t(26, z = r.mockerror), "obfuscated" in r && t(27, E = r.obfuscated), "refetchonexpire" in r && t(28, F = r.refetchonexpire), "spamfilter" in r && t(29, h = r.spamfilter), "strings" in r && t(36, x = r.strings), "test" in r && t(30, P = r.test), "verifyurl" in r && t(31, le = r.verifyurl), "workers" in r && t(32, be = r.workers), "workerurl" in r && t(33, Te = r.workerurl), "$$scope" in r && t(43, a = r.$$scope); + "auto" in r && t(0, f = r.auto), "blockspam" in r && t(16, C = r.blockspam), "challengeurl" in r && t(15, b = r.challengeurl), "challengejson" in r && t(31, M = r.challengejson), "debug" in r && t(17, D = r.debug), "delay" in r && t(18, j = r.delay), "expire" in r && t(19, S = r.expire), "floating" in r && t(1, N = r.floating), "floatinganchor" in r && t(20, O = r.floatinganchor), "floatingoffset" in r && t(21, J = r.floatingoffset), "hidefooter" in r && t(2, G = r.hidefooter), "hidelogo" in r && t(3, A = r.hidelogo), "name" in r && t(4, q = r.name), "maxnumber" in r && t(22, K = r.maxnumber), "mockerror" in r && t(23, H = r.mockerror), "obfuscated" in r && t(24, x = r.obfuscated), "plugins" in r && t(32, T = r.plugins), "refetchonexpire" in r && t(25, z = r.refetchonexpire), "spamfilter" in r && t(26, _ = r.spamfilter), "strings" in r && t(33, u = r.strings), "test" in r && t(27, y = r.test), "verifyurl" in r && t(28, ee = r.verifyurl), "workers" in r && t(29, le = r.workers), "workerurl" in r && t(30, ue = r.workerurl), "$$scope" in r && t(45, h = r.$$scope); }, n.$$.update = () => { n.$$.dirty[0] & /*challengeurl*/ - 131072 && t(14, i = !!(k != null && k.includes(".altcha.org")) && !!(k != null && k.includes("apiKey=ckey_"))), n.$$.dirty[1] & /*challengejson*/ - 16 && (o = K ? Ct(K) : void 0), n.$$.dirty[1] & /*strings*/ - 32 && t(42, l = x ? Ct(x) : {}), n.$$.dirty[1] & /*parsedStrings*/ - 2048 && t(13, s = { - ariaLinkLabel: xt, + 32768 && t(12, i = !!(b != null && b.includes(".altcha.org")) && !!(b != null && b.includes("apiKey=ckey_"))), n.$$.dirty[1] & /*challengejson*/ + 1 && (o = M ? dt(M) : void 0), n.$$.dirty[1] & /*strings*/ + 4 && t(44, l = u ? dt(u) : {}), n.$$.dirty[1] & /*parsedStrings*/ + 8192 && t(11, s = { + ariaLinkLabel: ut, error: "Verification failed. Try again later.", expired: "Verification expired. Try again.", - footer: `Protected by ALTCHA`, + footer: `Protected by ALTCHA`, label: "I'm not a robot", verified: "Verified", verifying: "Verifying...", waitAlert: "Verifying... please wait.", ...l - }), n.$$.dirty[0] & /*state, payload*/ - 192 | n.$$.dirty[1] & /*clarifiedData*/ - 1024 && Ve("statechange", J ? { clarifiedData: J, state: T } : { payload: ce, state: T }), n.$$.dirty[0] & /*error*/ - 32 && Mt(), n.$$.dirty[0] & /*state*/ - 128 && jt(), n.$$.dirty[1] & /*clarifiedData*/ - 1024 && Xt(); + }), n.$$.dirty[0] & /*payload, state*/ + 192 && de("statechange", { payload: oe, state: R }), n.$$.dirty[0] & /*error*/ + 32 && St(), n.$$.dirty[0] & /*state*/ + 128 && At(); }, [ - v, + f, + N, + G, A, + q, + he, oe, - ne, + R, + re, + E, + ie, + s, + i, + zt, + je, + b, + C, + D, j, - ye, - ce, - T, + S, O, + J, + K, + H, + x, + z, _, - se, - M, - Be, - s, - i, - Ut, - it, - k, - d, - R, - X, + y, ee, - te, - U, - Z, - I, - z, - E, - F, - h, - P, le, - be, - Te, - $, - K, - x, - st, - ve, - ae, - we, - J, + ue, + M, + T, + u, + ge, + Me, + Be, + Oe, + Vt, + Je, + me, + Qe, + $e, + ne, l, - a, - c, - Ot, - Jt, - Qt + h, + d, + Gt, + Ht, + Yt ]; } -class Pn extends An { +class Vn extends vn { constructor(e) { - super(), Tn( + super(), bn( this, e, - Kn, - Bn, - on, + Zn, + Tn, + Ut, { - analytics: 18, auto: 0, - beaconurl: 19, - blockspam: 34, - challengeurl: 17, - challengejson: 35, - debug: 20, - delay: 21, - expire: 22, + blockspam: 16, + challengeurl: 15, + challengejson: 31, + debug: 17, + delay: 18, + expire: 19, floating: 1, - floatinganchor: 23, - floatingoffset: 24, + floatinganchor: 20, + floatingoffset: 21, hidefooter: 2, hidelogo: 3, name: 4, - maxnumber: 25, - mockerror: 26, - obfuscated: 27, - refetchonexpire: 28, - spamfilter: 29, - strings: 36, - test: 30, - verifyurl: 31, - workers: 32, - workerurl: 33, - configure: 37, - reset: 38, - verify: 39, - clarify: 40 + maxnumber: 22, + mockerror: 23, + obfuscated: 24, + plugins: 32, + refetchonexpire: 25, + spamfilter: 26, + strings: 33, + test: 27, + verifyurl: 28, + workers: 29, + workerurl: 30, + clarify: 34, + configure: 35, + getConfiguration: 36, + getFloatingAnchor: 37, + getPlugin: 38, + getState: 39, + reset: 40, + setFloatingAnchor: 41, + setState: 42, + verify: 43 }, - Yn, + In, [-1, -1, -1] ); } - get analytics() { - return this.$$.ctx[18]; - } - set analytics(e) { - this.$$set({ analytics: e }), p(); - } get auto() { return this.$$.ctx[0]; } set auto(e) { - this.$$set({ auto: e }), p(); - } - get beaconurl() { - return this.$$.ctx[19]; - } - set beaconurl(e) { - this.$$set({ beaconurl: e }), p(); + this.$$set({ auto: e }), w(); } get blockspam() { - return this.$$.ctx[34]; + return this.$$.ctx[16]; } set blockspam(e) { - this.$$set({ blockspam: e }), p(); + this.$$set({ blockspam: e }), w(); } get challengeurl() { - return this.$$.ctx[17]; + return this.$$.ctx[15]; } set challengeurl(e) { - this.$$set({ challengeurl: e }), p(); + this.$$set({ challengeurl: e }), w(); } get challengejson() { - return this.$$.ctx[35]; + return this.$$.ctx[31]; } set challengejson(e) { - this.$$set({ challengejson: e }), p(); + this.$$set({ challengejson: e }), w(); } get debug() { - return this.$$.ctx[20]; + return this.$$.ctx[17]; } set debug(e) { - this.$$set({ debug: e }), p(); + this.$$set({ debug: e }), w(); } get delay() { - return this.$$.ctx[21]; + return this.$$.ctx[18]; } set delay(e) { - this.$$set({ delay: e }), p(); + this.$$set({ delay: e }), w(); } get expire() { - return this.$$.ctx[22]; + return this.$$.ctx[19]; } set expire(e) { - this.$$set({ expire: e }), p(); + this.$$set({ expire: e }), w(); } get floating() { return this.$$.ctx[1]; } set floating(e) { - this.$$set({ floating: e }), p(); + this.$$set({ floating: e }), w(); } get floatinganchor() { - return this.$$.ctx[23]; + return this.$$.ctx[20]; } set floatinganchor(e) { - this.$$set({ floatinganchor: e }), p(); + this.$$set({ floatinganchor: e }), w(); } get floatingoffset() { - return this.$$.ctx[24]; + return this.$$.ctx[21]; } set floatingoffset(e) { - this.$$set({ floatingoffset: e }), p(); + this.$$set({ floatingoffset: e }), w(); } get hidefooter() { return this.$$.ctx[2]; } set hidefooter(e) { - this.$$set({ hidefooter: e }), p(); + this.$$set({ hidefooter: e }), w(); } get hidelogo() { return this.$$.ctx[3]; } set hidelogo(e) { - this.$$set({ hidelogo: e }), p(); + this.$$set({ hidelogo: e }), w(); } get name() { return this.$$.ctx[4]; } set name(e) { - this.$$set({ name: e }), p(); + this.$$set({ name: e }), w(); } get maxnumber() { - return this.$$.ctx[25]; + return this.$$.ctx[22]; } set maxnumber(e) { - this.$$set({ maxnumber: e }), p(); + this.$$set({ maxnumber: e }), w(); } get mockerror() { - return this.$$.ctx[26]; + return this.$$.ctx[23]; } set mockerror(e) { - this.$$set({ mockerror: e }), p(); + this.$$set({ mockerror: e }), w(); } get obfuscated() { - return this.$$.ctx[27]; + return this.$$.ctx[24]; } set obfuscated(e) { - this.$$set({ obfuscated: e }), p(); + this.$$set({ obfuscated: e }), w(); + } + get plugins() { + return this.$$.ctx[32]; + } + set plugins(e) { + this.$$set({ plugins: e }), w(); } get refetchonexpire() { - return this.$$.ctx[28]; + return this.$$.ctx[25]; } set refetchonexpire(e) { - this.$$set({ refetchonexpire: e }), p(); + this.$$set({ refetchonexpire: e }), w(); } get spamfilter() { - return this.$$.ctx[29]; + return this.$$.ctx[26]; } set spamfilter(e) { - this.$$set({ spamfilter: e }), p(); + this.$$set({ spamfilter: e }), w(); } get strings() { - return this.$$.ctx[36]; + return this.$$.ctx[33]; } set strings(e) { - this.$$set({ strings: e }), p(); + this.$$set({ strings: e }), w(); } get test() { - return this.$$.ctx[30]; + return this.$$.ctx[27]; } set test(e) { - this.$$set({ test: e }), p(); + this.$$set({ test: e }), w(); } get verifyurl() { - return this.$$.ctx[31]; + return this.$$.ctx[28]; } set verifyurl(e) { - this.$$set({ verifyurl: e }), p(); + this.$$set({ verifyurl: e }), w(); } get workers() { - return this.$$.ctx[32]; + return this.$$.ctx[29]; } set workers(e) { - this.$$set({ workers: e }), p(); + this.$$set({ workers: e }), w(); } get workerurl() { - return this.$$.ctx[33]; + return this.$$.ctx[30]; } set workerurl(e) { - this.$$set({ workerurl: e }), p(); + this.$$set({ workerurl: e }), w(); + } + get clarify() { + return this.$$.ctx[34]; } get configure() { + return this.$$.ctx[35]; + } + get getConfiguration() { + return this.$$.ctx[36]; + } + get getFloatingAnchor() { return this.$$.ctx[37]; } - get reset() { + get getPlugin() { return this.$$.ctx[38]; } - get verify() { + get getState() { return this.$$.ctx[39]; } - get clarify() { + get reset() { return this.$$.ctx[40]; } -} -customElements.define("altcha-widget", Nn(Pn, { analytics: { type: "Boolean" }, auto: {}, beaconurl: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, delay: {}, expire: {}, floating: {}, floatinganchor: {}, floatingoffset: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, obfuscated: {}, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, ["default"], ["configure", "reset", "verify", "clarify"], !1)); -globalThis.createAltchaWorker = (n) => n ? new Worker(new URL(n)) : new nn(); + get setFloatingAnchor() { + return this.$$.ctx[41]; + } + get setState() { + return this.$$.ctx[42]; + } + get verify() { + return this.$$.ctx[43]; + } +} +customElements.define("altcha-widget", yn( + Vn, + { auto: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, delay: {}, expire: {}, floating: {}, floatinganchor: {}, floatingoffset: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, obfuscated: {}, plugins: {}, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, + ["default"], + [ + "clarify", + "configure", + "getConfiguration", + "getFloatingAnchor", + "getPlugin", + "getState", + "reset", + "setFloatingAnchor", + "setState", + "verify" + ], + !1 +)); +globalThis.altchaCreateWorker = (n) => n ? new Worker(new URL(n)) : new Pt(); +globalThis.altchaPlugins = globalThis.altchaPlugins || []; export { - Pn as Altcha + Vn as Altcha }; diff --git a/dist/altcha.umd.cjs b/dist/altcha.umd.cjs index 1db302f..8cfad0b 100644 --- a/dist/altcha.umd.cjs +++ b/dist/altcha.umd.cjs @@ -1,2 +1,2 @@ -(function(w,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(w=typeof globalThis<"u"?globalThis:w||self,p(w.altcha={}))})(this,function(w){"use strict";var Pn=Object.defineProperty;var Dt=w=>{throw TypeError(w)};var On=(w,p,M)=>p in w?Pn(w,p,{enumerable:!0,configurable:!0,writable:!0,value:M}):w[p]=M;var X=(w,p,M)=>On(w,typeof p!="symbol"?p+"":p,M),Yt=(w,p,M)=>p.has(w)||Dt("Cannot "+M);var P=(w,p,M)=>(Yt(w,p,"read from private field"),M?M.call(w):p.get(w)),he=(w,p,M)=>p.has(w)?Dt("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(w):p.set(w,M),Ut=(w,p,M,we)=>(Yt(w,p,"write to private field"),we?we.call(w,M):p.set(w,M),M);var ye,ve,Ee,xe,Ce,Re;const p="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIHAoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiB3KGUsdCxyKXtyZXR1cm4gcChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChyLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGIoZSx0LHI9IlNIQS0yNTYiLG49MWU2LHM9MCl7Y29uc3Qgbz1uZXcgQWJvcnRDb250cm9sbGVyLGE9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgYz1zO2M8PW47Yys9MSl7aWYoby5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCB3KHQsYyxyKT09PWUpcmV0dXJue251bWJlcjpjLHRvb2s6RGF0ZS5ub3coKS1hfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjpvfX1mdW5jdGlvbiBoKGUpe2NvbnN0IHQ9YXRvYihlKSxyPW5ldyBVaW50OEFycmF5KHQubGVuZ3RoKTtmb3IobGV0IG49MDtuPHQubGVuZ3RoO24rKylyW25dPXQuY2hhckNvZGVBdChuKTtyZXR1cm4gcn1mdW5jdGlvbiBnKGUsdD0xMil7Y29uc3Qgcj1uZXcgVWludDhBcnJheSh0KTtmb3IobGV0IG49MDtuPHQ7bisrKXJbbl09ZSUyNTYsZT1NYXRoLmZsb29yKGUvMjU2KTtyZXR1cm4gcn1hc3luYyBmdW5jdGlvbiBtKGUsdD0iIixyPTFlNixuPTApe2NvbnN0IHM9IkFFUy1HQ00iLG89bmV3IEFib3J0Q29udHJvbGxlcixhPURhdGUubm93KCksbD1hc3luYygpPT57Zm9yKGxldCB1PW47dTw9cjt1Kz0xKXtpZihvLnNpZ25hbC5hYm9ydGVkfHwhY3x8IXkpcmV0dXJuIG51bGw7dHJ5e2NvbnN0IGQ9YXdhaXQgY3J5cHRvLnN1YnRsZS5kZWNyeXB0KHtuYW1lOnMsaXY6Zyh1KX0sYyx5KTtpZihkKXJldHVybntjbGVhclRleHQ6bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKGQpLHRvb2s6RGF0ZS5ub3coKS1hfX1jYXRjaHt9fXJldHVybiBudWxsfTtsZXQgYz1udWxsLHk9bnVsbDt0cnl7eT1oKGUpO2NvbnN0IHU9YXdhaXQgY3J5cHRvLnN1YnRsZS5kaWdlc3QoIlNIQS0yNTYiLGYuZW5jb2RlKHQpKTtjPWF3YWl0IGNyeXB0by5zdWJ0bGUuaW1wb3J0S2V5KCJyYXciLHUscywhMSxbImRlY3J5cHQiXSl9Y2F0Y2h7cmV0dXJue3Byb21pc2U6UHJvbWlzZS5yZWplY3QoKSxjb250cm9sbGVyOm99fXJldHVybntwcm9taXNlOmwoKSxjb250cm9sbGVyOm99fWxldCBpO29ubWVzc2FnZT1hc3luYyBlPT57Y29uc3R7dHlwZTp0LHBheWxvYWQ6cixzdGFydDpuLG1heDpzfT1lLmRhdGE7bGV0IG89bnVsbDtpZih0PT09ImFib3J0IilpPT1udWxsfHxpLmFib3J0KCksaT12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtpZigib2JmdXNjYXRlZCJpbiByKXtjb25zdHtrZXk6YSxvYmZ1c2NhdGVkOmx9PXJ8fHt9O289YXdhaXQgbShsLGEscyxuKX1lbHNle2NvbnN0e2FsZ29yaXRobTphLGNoYWxsZW5nZTpsLHNhbHQ6Y309cnx8e307bz1iKGwsYyxhLHMsbil9aT1vLmNvbnRyb2xsZXIsby5wcm9taXNlLnRoZW4oYT0+e3NlbGYucG9zdE1lc3NhZ2UoYSYmey4uLmEsd29ya2VyOiEwfSl9KX19fSkoKTsK",M=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),we=typeof self<"u"&&self.Blob&&new Blob([M(p)],{type:"text/javascript;charset=utf-8"});function Xt(n){let e;try{if(e=we&&(self.URL||self.webkitURL).createObjectURL(we),!e)throw"";const t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+p,{name:n==null?void 0:n.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}function Se(){}function Mt(n,e){for(const t in e)n[t]=e[t];return n}function Pe(n){return n()}function Oe(){return Object.create(null)}function pe(n){n.forEach(Pe)}function Je(n){return typeof n=="function"}function jt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Wt(n){return Object.keys(n).length===0}function Bt(n,e,t,i){if(n){const o=Qe(n,e,t,i);return n[0](o)}}function Qe(n,e,t,i){return n[1]&&i?Mt(t.ctx.slice(),n[1](i(e))):t.ctx}function Kt(n,e,t,i){if(n[2]&&i){const o=n[2](i(t));if(e.dirty===void 0)return o;if(typeof o=="object"){const l=[],s=Math.max(e.dirty.length,o.length);for(let a=0;a32){const e=[],t=n.ctx.length/32;for(let i=0;in.removeEventListener(e,t,i)}function c(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function en(n){return Array.from(n.childNodes)}function $e(n,e,t){n.classList.toggle(e,!!t)}function tn(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function nn(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let _e;function ke(n){_e=n}function Ue(){if(!_e)throw new Error("Function called outside component initialization");return _e}function rn(n){Ue().$$.on_mount.push(n)}function on(n){Ue().$$.on_destroy.push(n)}function ln(){const n=Ue();return(e,t,{cancelable:i=!1}={})=>{const o=n.$$.callbacks[e];if(o){const l=tn(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(n,l)}),!l.defaultPrevented}return!0}}const me=[],Fe=[];let be=[];const et=[],tt=Promise.resolve();let Xe=!1;function nt(){Xe||(Xe=!0,tt.then(_))}function sn(){return nt(),tt}function Me(n){be.push(n)}const je=new Set;let ge=0;function _(){if(ge!==0)return;const n=_e;do{try{for(;gen.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),be=e}const Ze=new Set;let fn;function rt(n,e){n&&n.i&&(Ze.delete(n),n.i(e))}function un(n,e,t,i){if(n&&n.o){if(Ze.has(n))return;Ze.add(n),fn.c.push(()=>{Ze.delete(n)}),n.o(e)}}function dn(n,e,t){const{fragment:i,after_update:o}=n.$$;i&&i.m(e,t),Me(()=>{const l=n.$$.on_mount.map(Pe).filter(Je);n.$$.on_destroy?n.$$.on_destroy.push(...l):pe(l),n.$$.on_mount=[]}),o.forEach(Me)}function hn(n,e){const t=n.$$;t.fragment!==null&&(an(t.after_update),pe(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function mn(n,e){n.$$.dirty[0]===-1&&(me.push(n),nt(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const J=x.length?x[0]:re;return d.ctx&&o(d.ctx[T],d.ctx[T]=J)&&(!d.skip_bound&&d.bound[T]&&d.bound[T](J),v&&mn(n,T)),re}):[],d.update(),v=!0,pe(d.before_update),d.fragment=i?i(d.ctx):!1,e.target){if(e.hydrate){const T=en(e.target);d.fragment&&d.fragment.l(T),T.forEach(S)}else d.fragment&&d.fragment.c();e.intro&&rt(n.$$.fragment),dn(n,e.target,e.anchor),_()}ke(f)}let it;typeof HTMLElement=="function"&&(it=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=A("slot"),l!=="default"&&c(s,"name",l)},m:function(d,v){H(d,s,v)},d:function(d){d&&S(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=nn(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]=Ve(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=Ve(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 a=this.$$c.$on(l,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Ve(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Ve(n,e,t,i){var l;const o=(l=t[n])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function gn(n,e,t,i,o,l){let s=class extends it{constructor(){super(n,t,o),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(f){var d;f=Ve(a,f,e),this.$$d[a]=f,(d=this.$$c)==null||d.$set({[a]:f})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var f;return(f=this.$$c)==null?void 0:f[a]}})}),n.element=s,s}class yn{constructor(){X(this,"$$");X(this,"$$set")}$destroy(){hn(this,1),this.$destroy=Se}$on(e,t){if(!Je(t))return Se;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&&!Wt(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const vn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(vn);const ot=new TextEncoder;function wn(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function pn(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await lt(i,n,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function lt(n,e,t){return wn(await crypto.subtle.digest(t.toUpperCase(),ot.encode(n+e)))}function _n(n,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 lt(e,f,t)===n)return{number:f,took:Date.now()-s}}return null})(),controller:l}}function st(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function kn(n){const e=atob(n),t=new Uint8Array(e.length);for(let i=0;i{for(let v=i;v<=t;v+=1){if(l.signal.aborted||!f||!d)return null;try{const T=await crypto.subtle.decrypt({name:o,iv:En(v)},f,d);if(T)return{clearText:new TextDecoder().decode(T),took:Date.now()-s}}catch{}}return null};let f=null,d=null;try{d=kn(n);const v=await crypto.subtle.digest("SHA-256",ot.encode(e));f=await crypto.subtle.importKey("raw",v,o,!1,["decrypt"])}catch{return{promise:Promise.reject(),controller:l}}return{promise:a(),controller:l}}class Cn{constructor(e){X(this,"beaconUrl",null);X(this,"error",null);X(this,"loadTime",Date.now());X(this,"submitTime",null);X(this,"startTime",null);X(this,"viewTimeThresholdMs",1500);he(this,ye,{});he(this,ve,null);he(this,Ee,this.onFormChange.bind(this));he(this,xe,this.onFormFocus.bind(this));he(this,Ce,this.onFormSubmit.bind(this));he(this,Re,this.onUnload.bind(this));this.elForm=e,window.addEventListener("unload",P(this,Re)),this.elForm.addEventListener("change",P(this,Ee)),this.elForm.addEventListener("focusin",P(this,xe)),this.elForm.addEventListener("submit",P(this,Ce))}data(){const e=Object.entries(P(this,ye));return{correction:e.length&&e.filter(([t,i])=>i>1).length/e.length||0,dropoff:!this.submitTime&&!this.error&&P(this,ve)?P(this,ve):null,error:this.error,mobile:this.isMobile(),start:this.startTime,submit:this.submitTime,tz:st()}}dataAsBase64(){try{return btoa(JSON.stringify(this.data()))}catch(e){console.error("failed to encode ALTCHA session data to base64",e)}return""}destroy(){window.removeEventListener("unload",P(this,Re)),this.elForm.removeEventListener("change",P(this,Ee)),this.elForm.removeEventListener("focusin",P(this,xe)),this.elForm.removeEventListener("submit",P(this,Ce))}end(){this.submitTime||(this.submitTime=Date.now())}getFieldName(e,t=40){const i=e.getAttribute("data-group-label"),o=e.getAttribute("name")||e.getAttribute("aria-label");return((i?i+": ":"")+o).slice(0,t)}isMobile(){const e="userAgentData"in navigator&&navigator.userAgentData?navigator.userAgentData:{};return"mobile"in e?e.mobile===!0:/Mobi/i.test(window.navigator.userAgent)}isInput(e){return["INPUT","SELECT","TEXTAREA"].includes(e.tagName)}onFormFieldChange(e){const t=this.getFieldName(e);t&&this.trackFieldChange(t)}onFormChange(e){const t=e.target;t&&this.isInput(t)&&this.onFormFieldChange(t)}onFormFocus(e){const t=e.target;if(this.startTime||this.start(),t&&this.isInput(t)){const i=this.getFieldName(t);i&&Ut(this,ve,i)}}onFormSubmit(){this.end()}onUnload(){this.loadTime<=Date.now()-this.viewTimeThresholdMs&&!this.submitTime&&this.sendBeacon()}async sendBeacon(){if(this.beaconUrl&&"sendBeacon"in navigator)try{navigator.sendBeacon(new URL(this.beaconUrl,location.origin),JSON.stringify(this.data()))}catch{}}start(){this.startTime=Date.now()}trackError(e){this.error=e===null?null:String(e)}trackFieldChange(e){P(this,ye)[e]=(P(this,ye)[e]||0)+1}}ye=new WeakMap,ve=new WeakMap,Ee=new WeakMap,xe=new WeakMap,Ce=new WeakMap,Re=new WeakMap;var g=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(g||{});function Rn(n){Jt(n,"svelte-ddsc3z",'.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}')}function ct(n){let e,t,i;return{c(){e=ne("svg"),t=ne("path"),i=ne("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){H(o,e,l),I(e,t),I(e,i)},d(o){o&&S(e)}}}function Ln(n){let e,t=n[13].label+"",i;return{c(){e=A("label"),c(e,"for",i=n[4]+"_checkbox"),c(e,"class","svelte-ddsc3z")},m(o,l){H(o,e,l),e.innerHTML=t},p(o,l){l[0]&8192&&t!==(t=o[13].label+"")&&(e.innerHTML=t),l[0]&16&&i!==(i=o[4]+"_checkbox")&&c(e,"for",i)},d(o){o&&S(e)}}}function In(n){let e,t=n[13].verifying+"";return{c(){e=A("span")},m(i,o){H(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].verifying+"")&&(e.innerHTML=t)},d(i){i&&S(e)}}}function Tn(n){let e,t=n[13].verified+"",i,o,l,s,a=n[11]&&at(n);return{c(){e=A("span"),i=q(),o=A("input"),l=q(),a&&a.c(),s=$t(),c(o,"type","hidden"),c(o,"name",n[4]),o.value=n[6]},m(f,d){H(f,e,d),e.innerHTML=t,H(f,i,d),H(f,o,d),H(f,l,d),a&&a.m(f,d),H(f,s,d)},p(f,d){d[0]&8192&&t!==(t=f[13].verified+"")&&(e.innerHTML=t),d[0]&16&&c(o,"name",f[4]),d[0]&64&&(o.value=f[6]),f[11]?a?a.p(f,d):(a=at(f),a.c(),a.m(s.parentNode,s)):a&&(a.d(1),a=null)},d(f){f&&(S(e),S(i),S(o),S(l),S(s)),a&&a.d(f)}}}function at(n){let e;return{c(){e=A("input"),c(e,"type","hidden"),c(e,"name","__session"),e.value=n[12]},m(t,i){H(t,e,i)},p(t,i){i[0]&4096&&(e.value=t[12])},d(t){t&&S(e)}}}function ft(n){let e,t,i,o,l,s,a;return{c(){e=A("div"),t=A("a"),i=ne("svg"),o=ne("path"),l=ne("path"),s=ne("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",bt),c(t,"target","_blank"),c(t,"class","altcha-logo svelte-ddsc3z"),c(t,"aria-label",a=n[13].ariaLinkLabel)},m(f,d){H(f,e,d),I(e,t),I(t,i),I(i,o),I(i,l),I(i,s)},p(f,d){d[0]&8192&&a!==(a=f[13].ariaLinkLabel)&&c(t,"aria-label",a)},d(f){f&&S(e)}}}function ut(n){let e,t,i,o;function l(f,d){return f[7]===g.EXPIRED?An:Nn}let s=l(n),a=s(n);return{c(){e=A("div"),t=ne("svg"),i=ne("path"),o=q(),a.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){H(f,e,d),I(e,t),I(t,i),I(e,o),a.m(e,null)},p(f,d){s===(s=l(f))&&a?a.p(f,d):(a.d(1),a=s(f),a&&(a.c(),a.m(e,null)))},d(f){f&&S(e),a.d()}}}function Nn(n){let e,t=n[13].error+"";return{c(){e=A("div"),c(e,"title",n[5])},m(i,o){H(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].error+"")&&(e.innerHTML=t),o[0]&32&&c(e,"title",i[5])},d(i){i&&S(e)}}}function An(n){let e,t=n[13].expired+"";return{c(){e=A("div"),c(e,"title",n[5])},m(i,o){H(i,e,o),e.innerHTML=t},p(i,o){o[0]&8192&&t!==(t=i[13].expired+"")&&(e.innerHTML=t),o[0]&32&&c(e,"title",i[5])},d(i){i&&S(e)}}}function dt(n){let e,t,i=n[13].footer+"";return{c(){e=A("div"),t=A("div"),c(t,"class","svelte-ddsc3z"),c(e,"class","altcha-footer svelte-ddsc3z")},m(o,l){H(o,e,l),I(e,t),t.innerHTML=i},p(o,l){l[0]&8192&&i!==(i=o[13].footer+"")&&(t.innerHTML=i)},d(o){o&&S(e)}}}function ht(n){let e;return{c(){e=A("div"),c(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){H(t,e,i),n[46](e)},p:Se,d(t){t&&S(e),n[46](null)}}}function zn(n){let e,t,i,o,l,s,a,f,d,v,T,re,x,J,W,ie,oe;const F=n[44].default,j=Bt(F,n,n[43],null);let G=n[7]===g.VERIFYING&&ct();function ce(h,R){return h[7]===g.VERIFIED?Tn:h[7]===g.VERIFYING?In:Ln}let le=ce(n),K=le(n),N=(n[3]!==!0||n[14])&&ft(n),Z=(n[5]||n[7]===g.EXPIRED)&&ut(n),C=n[13].footer&&(n[2]!==!0||n[14])&&dt(n),V=n[1]&&ht(n);return{c(){j&&j.c(),e=q(),t=A("div"),i=A("div"),G&&G.c(),o=q(),l=A("div"),s=A("input"),d=q(),v=A("div"),K.c(),T=q(),N&&N.c(),re=q(),Z&&Z.c(),x=q(),C&&C.c(),J=q(),V&&V.c(),c(s,"type","checkbox"),c(s,"id",a=n[4]+"_checkbox"),s.required=f=n[0]!=="onsubmit",c(s,"class","svelte-ddsc3z"),c(l,"class","altcha-checkbox svelte-ddsc3z"),$e(l,"altcha-hidden",n[7]===g.VERIFYING),c(v,"class","altcha-label svelte-ddsc3z"),c(i,"class","altcha-main svelte-ddsc3z"),c(t,"class","altcha svelte-ddsc3z"),c(t,"data-state",n[7]),c(t,"data-floating",n[1])},m(h,R){j&&j.m(h,R),H(h,e,R),H(h,t,R),I(t,i),G&&G.m(i,null),I(i,o),I(i,l),I(l,s),s.checked=n[8],I(i,d),I(i,v),K.m(v,null),I(i,T),N&&N.m(i,null),I(t,re),Z&&Z.m(t,null),I(t,x),C&&C.m(t,null),I(t,J),V&&V.m(t,null),n[47](t),W=!0,ie||(oe=[Ye(s,"change",n[45]),Ye(s,"change",n[15]),Ye(s,"invalid",n[16])],ie=!0)},p(h,R){j&&j.p&&(!W||R[1]&4096)&&Pt(j,F,h,h[43],W?Kt(F,h[43],R,null):Ot(h[43]),null),h[7]===g.VERIFYING?G||(G=ct(),G.c(),G.m(i,o)):G&&(G.d(1),G=null),(!W||R[0]&16&&a!==(a=h[4]+"_checkbox"))&&c(s,"id",a),(!W||R[0]&1&&f!==(f=h[0]!=="onsubmit"))&&(s.required=f),R[0]&256&&(s.checked=h[8]),(!W||R[0]&128)&&$e(l,"altcha-hidden",h[7]===g.VERIFYING),le===(le=ce(h))&&K?K.p(h,R):(K.d(1),K=le(h),K&&(K.c(),K.m(v,null))),h[3]!==!0||h[14]?N?N.p(h,R):(N=ft(h),N.c(),N.m(i,null)):N&&(N.d(1),N=null),h[5]||h[7]===g.EXPIRED?Z?Z.p(h,R):(Z=ut(h),Z.c(),Z.m(t,x)):Z&&(Z.d(1),Z=null),h[13].footer&&(h[2]!==!0||h[14])?C?C.p(h,R):(C=dt(h),C.c(),C.m(t,J)):C&&(C.d(1),C=null),h[1]?V?V.p(h,R):(V=ht(h),V.c(),V.m(t,null)):V&&(V.d(1),V=null),(!W||R[0]&128)&&c(t,"data-state",h[7]),(!W||R[0]&2)&&c(t,"data-floating",h[1])},i(h){W||(rt(j,h),W=!0)},o(h){un(j,h),W=!1},d(h){h&&(S(e),S(t)),j&&j.d(h),G&&G.d(),K.d(),N&&N.d(),Z&&Z.d(),C&&C.d(),V&&V.d(),n[47](null),ie=!1,pe(oe)}}}const mt="Visit Altcha.org",bt="https://altcha.org/";function gt(n){return JSON.parse(n)}function Sn(n,e,t){var Vt,Ht;let i,o,l,s,{$$slots:a={},$$scope:f}=e,{analytics:d=!1}=e,{auto:v=void 0}=e,{beaconurl:T=void 0}=e,{blockspam:re=void 0}=e,{challengeurl:x=void 0}=e,{challengejson:J=void 0}=e,{debug:W=!1}=e,{delay:ie=0}=e,{expire:oe=void 0}=e,{floating:F=void 0}=e,{floatinganchor:j=void 0}=e,{floatingoffset:G=void 0}=e,{hidefooter:ce=!1}=e,{hidelogo:le=!1}=e,{name:K="altcha"}=e,{maxnumber:N=1e6}=e,{mockerror:Z=!1}=e,{obfuscated:C=void 0}=e,{refetchonexpire:V=!0}=e,{spamfilter:h=!1}=e,{strings:R=void 0}=e,{test:Q=!1}=e,{verifyurl:ae=void 0}=e,{workers:Le=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:He=void 0}=e;const We=ln(),vt=["SHA-256","SHA-384","SHA-512"],wt=(Ht=(Vt=document.documentElement.lang)==null?void 0:Vt.split("-"))==null?void 0:Ht[0];let $=!1,ee=null,E,fe=null,Ge=null,y=null,se=null,Ie=null,te=null,ue=null,B=null,pt=null,z=g.UNVERIFIED;on(()=>{y&&(y.removeEventListener("submit",Et),y.removeEventListener("reset",xt),y.removeEventListener("focusin",kt),y=null),se&&E.removeEventListener("click",_t),B&&B.destroy(),te&&(clearTimeout(te),te=null),document.removeEventListener("click",Nt),document.removeEventListener("scroll",At),window.removeEventListener("resize",St)}),rn(()=>{var r,u;L("mounted","0.8.0"),L("workers",Le),Q&&L("using test mode"),oe&&De(oe),v!==void 0&&L("auto",v),F!==void 0&&Ft(F),y=E.closest("form"),y&&(y.addEventListener("submit",Et,{capture:!0}),y.addEventListener("reset",xt),v==="onfocus"&&y.addEventListener("focusin",kt)),se=((r=E.parentElement)==null?void 0:r.querySelector("[data-clarify-button]"))||((u=E.parentElement)==null?void 0:u.querySelector("button, a")),se&&se.addEventListener("click",_t),d&&Lt(),v==="onload"&&(C?Ne():de()),i&&(ce||le)&&L("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.")});function L(...r){(W||r.some(u=>u instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",...r)}function _t(r){r.preventDefault(),z===g.UNVERIFIED&&Ne()}function kt(r){z===g.UNVERIFIED&&de()}function Et(r){y&&B&&z===g.VERIFIED&&(B.end(),t(12,pt=B.dataAsBase64())),y&&v==="onsubmit"&&(z===g.UNVERIFIED?(r.preventDefault(),r.stopPropagation(),de().then(()=>{y==null||y.requestSubmit()})):z!==g.VERIFIED&&(r.preventDefault(),r.stopPropagation(),z===g.VERIFYING&&zt()))}function xt(){Te()}function Ct(r,u){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:u.number,salt:r.salt,signature:r.signature,test:Q?!0:void 0,took:u.took}))}function Rt(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(!vt.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${vt.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 Fn(){var r;if(Z)throw L("mocking error"),new Error("Mocked error.");if(o)return L("using provided json data"),o;if(Q)return L("generating test challenge",{test:Q}),pn(typeof Q!="boolean"?+Q:void 0);{if(!x&&y){const k=y.getAttribute("action");k!=null&&k.includes("/form/")&&t(17,x=k+"/altcha")}if(!x)throw new Error("Attribute challengeurl not set.");L("fetching challenge from",x);const u=await fetch(x,{headers:h?{"x-altcha-spam-filter":"1"}:{}});if(u.status!==200)throw new Error(`Server responded with ${u.status}.`);const m=u.headers.get("Expires"),b=u.headers.get("X-Altcha-Config"),D=await u.json(),Y=new URLSearchParams((r=D.salt.split("?"))==null?void 0:r[1]),U=Y.get("expires")||Y.get("expire");if(U){const k=new Date(+U*1e3),O=isNaN(k.getTime())?0:k.getTime()-Date.now();O>0&&De(O)}if(b)try{const k=JSON.parse(b);k&&typeof k=="object"&&(k.verifyurl&&(k.verifyurl=new URL(k.verifyurl,new URL(x)).toString()),Zt(k))}catch(k){L("unable to configure from X-Altcha-Config",k)}if(!oe&&(m!=null&&m.length)){const k=Date.parse(m);if(k){const O=k-Date.now();O>0&&De(O)}}return D}}function Lt(){if(!B)if(y){if(L("analytics enabled"),t(11,B=new Cn(y)),T===void 0){const r=y.getAttribute("action");r&&t(19,T=r+"/beacon")}t(11,B.beaconUrl=T||null,B)}else L("analytics cannot be enabled - form element not found")}function It(){x&&V&&z===g.VERIFIED?de():Te(g.EXPIRED,s.expired)}async function Tt(r){let u=null;if("Worker"in window){try{u=await Zn(r,r.maxnumber)}catch(m){L(m)}if((u==null?void 0:u.number)!==void 0||"obfuscated"in r)return{data:r,solution:u}}if("obfuscated"in r){const m=await xn(r.obfuscated,r.key,r.maxnumber);return{data:r,solution:await m.promise}}return{data:r,solution:await _n(r.challenge,r.salt,r.algorithm,r.maxnumber||N).promise}}async function Zn(r,u=typeof Q=="number"?Q:N,m=Math.ceil(Le)){const b=[];m=Math.min(16,Math.max(1,m));for(let U=0;U{const O=k*D;return new Promise(Ke=>{U.addEventListener("message",Ae=>{if(Ae.data)for(const ze of b)ze!==U&&ze.postMessage({type:"abort"});Ke(Ae.data)}),U.postMessage({payload:r,max:O+D,start:O,type:"work"})})}));for(const U of b)U.terminate();return Y.find(U=>!!U)||null}function Vn(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(z)?h&&(y==null?void 0:y.reportValidity())===!1?t(8,$=!1):C?Ne():de():t(8,$=!0)}function Nt(r){const u=r.target;F&&u&&!E.contains(u)&&z===g.VERIFIED&&t(9,E.style.display="none",E)}function At(){F&&Be()}function zt(){z===g.VERIFYING&&s.waitAlert&&alert(s.waitAlert)}function Hn(r){var u;if(ee){const m=ee.match(/^(mailto|tel|sms|https?):/);let b;if(m){const[D]=ee.slice(ee.indexOf(":")+1).replace(/^\/\//,"").split("?");b=document.createElement("a"),b.href=ee,b.innerHTML=D}else b=document.createTextNode(ee);se&&b&&(se.after(b),(u=se.parentElement)==null||u.removeChild(se))}}function Gn(r){B&&B.trackError(Ie)}function Dn(r){F&&z!==g.UNVERIFIED&&requestAnimationFrame(()=>{Be()})}function St(){F&&Be()}function De(r){L("expire",r),te&&(clearTimeout(te),te=null),r<1?It():te=setTimeout(It,r)}function Ft(r){L("floating",r),F!==r&&(t(9,E.style.left="",E),t(9,E.style.top="",E)),t(1,F=r===!0||r===""?"auto":r===!1||r==="false"?void 0:F),F?(v||t(0,v="onsubmit"),document.addEventListener("scroll",At),document.addEventListener("click",Nt),window.addEventListener("resize",St)):v==="onsubmit"&&t(0,v=void 0)}function Yn(r){var m;const u=y==null?void 0:y.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((m=u==null?void 0:u.value)==null?void 0:m.slice(u.value.indexOf("@")))||void 0}function Un(r){return[...(y==null?void 0:y.querySelectorAll(r!=null&&r.length?r.map(m=>`input[name="${m}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((m,b)=>{const D=b.name,Y=b.value;return D&&Y&&(m[D]=/\n/.test(Y)?Y.replace(new RegExp("(?D:F==="top",k=Math.max(r,Math.min(Y-r-b.width,m.left+m.width/2-b.width/2));if(U?t(9,E.style.top=`${m.top-(b.height+u)}px`,E):t(9,E.style.top=`${m.bottom+u}px`,E),t(9,E.style.left=`${k}px`,E),E.setAttribute("data-floating",U?"top":"bottom"),fe){const O=fe.getBoundingClientRect();t(10,fe.style.left=m.left-k+m.width/2-O.width/2+"px",fe)}}else L("unable to find floating anchor element")}function Zt(r){r.analytics&&(t(18,d=r.analytics),Lt()),r.obfuscated!==void 0&&t(27,C=r.obfuscated),r.auto!==void 0&&(t(0,v=r.auto),v==="onload"&&(C?Ne():de())),r.beaconurl&&(t(19,T=r.beaconurl),B&&t(11,B.beaconUrl=T,B)),r.floatinganchor!==void 0&&t(23,j=r.floatinganchor),r.delay!==void 0&&t(21,ie=r.delay),r.floatingoffset!==void 0&&t(24,G=r.floatingoffset),r.floating!==void 0&&Ft(r.floating),r.expire!==void 0&&(De(r.expire),t(22,oe=r.expire)),r.challenge&&(Rt(r.challenge),o=r.challenge),r.challengeurl!==void 0&&t(17,x=r.challengeurl),r.debug!==void 0&&t(20,W=!!r.debug),r.hidefooter!==void 0&&t(2,ce=!!r.hidefooter),r.hidelogo!==void 0&&t(3,le=!!r.hidelogo),r.maxnumber!==void 0&&t(25,N=+r.maxnumber),r.mockerror!==void 0&&t(26,Z=!!r.mockerror),r.name!==void 0&&t(4,K=r.name),r.refetchonexpire!==void 0&&t(28,V=!!r.refetchonexpire),r.spamfilter!==void 0&&t(29,h=typeof r.spamfilter=="object"?r.spamfilter:!!r.spamfilter),r.strings&&t(42,l=r.strings),r.test!==void 0&&t(30,Q=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(31,ae=r.verifyurl),r.workers!==void 0&&t(32,Le=+r.workers),r.workerurl!==void 0&&t(33,He=r.workerurl)}function Te(r=g.UNVERIFIED,u=null){te&&(clearTimeout(te),te=null),t(8,$=!1),t(5,Ie=u),t(6,ue=null),t(7,z=r)}async function de(){return Te(g.VERIFYING),await new Promise(r=>setTimeout(r,ie||0)),Fn().then(r=>(Rt(r),L("challenge",r),Tt(r))).then(({data:r,solution:u})=>{if(L("solution",u),"challenge"in r&&u&&!("clearText"in u))if((u==null?void 0:u.number)!==void 0){if(ae)return Xn(Ct(r,u));t(6,ue=Ct(r,u)),L("payload",ue)}else throw L("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{sn().then(()=>{t(7,z=g.VERIFIED),t(8,$=!0),L("verified"),We("verified",{payload:ue})})}).catch(r=>{L(r),t(7,z=g.ERROR),t(8,$=!1),t(5,Ie=r.message)})}async function Ne(){if(!C){t(7,z=g.ERROR);return}Te(g.VERIFYING),await new Promise(Y=>setTimeout(Y,ie||0));const[r,u]=C.split("?");let b=new URLSearchParams(u||"").get("key")||void 0;if(b){const Y=b.match(/^\(prompt:?(.*)\)$/);Y&&(b=prompt(Y[1]||"Enter Key:")||void 0)}const{solution:D}=await Tt({obfuscated:r,key:b,maxnumber:N});D&&"clearText"in D?(t(41,ee=D.clearText),t(7,z=g.VERIFIED),t(8,$=!0),F&&E&&t(9,E.style.display="none",E)):(t(7,z=g.ERROR),t(8,$=!1),t(5,Ie="Unable to decrypt data."))}function jn(){$=this.checked,t(8,$)}function Wn(r){Fe[r?"unshift":"push"](()=>{fe=r,t(10,fe)})}function Bn(r){Fe[r?"unshift":"push"](()=>{E=r,t(9,E)})}return n.$$set=r=>{"analytics"in r&&t(18,d=r.analytics),"auto"in r&&t(0,v=r.auto),"beaconurl"in r&&t(19,T=r.beaconurl),"blockspam"in r&&t(34,re=r.blockspam),"challengeurl"in r&&t(17,x=r.challengeurl),"challengejson"in r&&t(35,J=r.challengejson),"debug"in r&&t(20,W=r.debug),"delay"in r&&t(21,ie=r.delay),"expire"in r&&t(22,oe=r.expire),"floating"in r&&t(1,F=r.floating),"floatinganchor"in r&&t(23,j=r.floatinganchor),"floatingoffset"in r&&t(24,G=r.floatingoffset),"hidefooter"in r&&t(2,ce=r.hidefooter),"hidelogo"in r&&t(3,le=r.hidelogo),"name"in r&&t(4,K=r.name),"maxnumber"in r&&t(25,N=r.maxnumber),"mockerror"in r&&t(26,Z=r.mockerror),"obfuscated"in r&&t(27,C=r.obfuscated),"refetchonexpire"in r&&t(28,V=r.refetchonexpire),"spamfilter"in r&&t(29,h=r.spamfilter),"strings"in r&&t(36,R=r.strings),"test"in r&&t(30,Q=r.test),"verifyurl"in r&&t(31,ae=r.verifyurl),"workers"in r&&t(32,Le=r.workers),"workerurl"in r&&t(33,He=r.workerurl),"$$scope"in r&&t(43,f=r.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&131072&&t(14,i=!!(x!=null&&x.includes(".altcha.org"))&&!!(x!=null&&x.includes("apiKey=ckey_"))),n.$$.dirty[1]&16&&(o=J?gt(J):void 0),n.$$.dirty[1]&32&&t(42,l=R?gt(R):{}),n.$$.dirty[1]&2048&&t(13,s={ariaLinkLabel:mt,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),n.$$.dirty[0]&192|n.$$.dirty[1]&1024&&We("statechange",ee?{clarifiedData:ee,state:z}:{payload:ue,state:z}),n.$$.dirty[0]&32&&Gn(),n.$$.dirty[0]&128&&Dn(),n.$$.dirty[1]&1024&&Hn()},[v,F,ce,le,K,Ie,ue,z,$,E,fe,B,pt,s,i,Vn,zt,x,d,T,W,ie,oe,j,G,N,Z,C,V,h,Q,ae,Le,He,re,J,R,Zt,Te,de,Ne,ee,l,f,a,jn,Wn,Bn]}class yt extends yn{constructor(e){super(),bn(this,e,Sn,zn,jt,{analytics:18,auto:0,beaconurl:19,blockspam:34,challengeurl:17,challengejson:35,debug:20,delay:21,expire:22,floating:1,floatinganchor:23,floatingoffset:24,hidefooter:2,hidelogo:3,name:4,maxnumber:25,mockerror:26,obfuscated:27,refetchonexpire:28,spamfilter:29,strings:36,test:30,verifyurl:31,workers:32,workerurl:33,configure:37,reset:38,verify:39,clarify:40},Rn,[-1,-1,-1])}get analytics(){return this.$$.ctx[18]}set analytics(e){this.$$set({analytics:e}),_()}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),_()}get beaconurl(){return this.$$.ctx[19]}set beaconurl(e){this.$$set({beaconurl:e}),_()}get blockspam(){return this.$$.ctx[34]}set blockspam(e){this.$$set({blockspam:e}),_()}get challengeurl(){return this.$$.ctx[17]}set challengeurl(e){this.$$set({challengeurl:e}),_()}get challengejson(){return this.$$.ctx[35]}set challengejson(e){this.$$set({challengejson:e}),_()}get debug(){return this.$$.ctx[20]}set debug(e){this.$$set({debug:e}),_()}get delay(){return this.$$.ctx[21]}set delay(e){this.$$set({delay:e}),_()}get expire(){return this.$$.ctx[22]}set expire(e){this.$$set({expire:e}),_()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),_()}get floatinganchor(){return this.$$.ctx[23]}set floatinganchor(e){this.$$set({floatinganchor:e}),_()}get floatingoffset(){return this.$$.ctx[24]}set floatingoffset(e){this.$$set({floatingoffset:e}),_()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),_()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),_()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),_()}get maxnumber(){return this.$$.ctx[25]}set maxnumber(e){this.$$set({maxnumber:e}),_()}get mockerror(){return this.$$.ctx[26]}set mockerror(e){this.$$set({mockerror:e}),_()}get obfuscated(){return this.$$.ctx[27]}set obfuscated(e){this.$$set({obfuscated:e}),_()}get refetchonexpire(){return this.$$.ctx[28]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),_()}get spamfilter(){return this.$$.ctx[29]}set spamfilter(e){this.$$set({spamfilter:e}),_()}get strings(){return this.$$.ctx[36]}set strings(e){this.$$set({strings:e}),_()}get test(){return this.$$.ctx[30]}set test(e){this.$$set({test:e}),_()}get verifyurl(){return this.$$.ctx[31]}set verifyurl(e){this.$$set({verifyurl:e}),_()}get workers(){return this.$$.ctx[32]}set workers(e){this.$$set({workers:e}),_()}get workerurl(){return this.$$.ctx[33]}set workerurl(e){this.$$set({workerurl:e}),_()}get configure(){return this.$$.ctx[37]}get reset(){return this.$$.ctx[38]}get verify(){return this.$$.ctx[39]}get clarify(){return this.$$.ctx[40]}}customElements.define("altcha-widget",gn(yt,{analytics:{type:"Boolean"},auto:{},beaconurl:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},obfuscated:{},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},["default"],["configure","reset","verify","clarify"],!1)),globalThis.createAltchaWorker=n=>n?new Worker(new URL(n)):new Xt,w.Altcha=yt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}); +(function(D,F){typeof exports=="object"&&typeof module<"u"?F(exports):typeof define=="function"&&define.amd?define(["exports"],F):(D=typeof globalThis<"u"?globalThis:D||self,F(D.altcha={}))})(this,function(D){"use strict";var Vn=Object.defineProperty;var Gn=(D,F,ce)=>F in D?Vn(D,F,{enumerable:!0,configurable:!0,writable:!0,value:ce}):D[F]=ce;var K=(D,F,ce)=>Gn(D,typeof F!="symbol"?F+"":F,ce);const F="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGY9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIHAoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAodD0+dC50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiB3KGUsdCxyKXtyZXR1cm4gcChhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChyLnRvVXBwZXJDYXNlKCksZi5lbmNvZGUoZSt0KSkpfWZ1bmN0aW9uIGIoZSx0LHI9IlNIQS0yNTYiLG49MWU2LHM9MCl7Y29uc3Qgbz1uZXcgQWJvcnRDb250cm9sbGVyLGE9RGF0ZS5ub3coKTtyZXR1cm57cHJvbWlzZTooYXN5bmMoKT0+e2ZvcihsZXQgYz1zO2M8PW47Yys9MSl7aWYoby5zaWduYWwuYWJvcnRlZClyZXR1cm4gbnVsbDtpZihhd2FpdCB3KHQsYyxyKT09PWUpcmV0dXJue251bWJlcjpjLHRvb2s6RGF0ZS5ub3coKS1hfX1yZXR1cm4gbnVsbH0pKCksY29udHJvbGxlcjpvfX1mdW5jdGlvbiBoKGUpe2NvbnN0IHQ9YXRvYihlKSxyPW5ldyBVaW50OEFycmF5KHQubGVuZ3RoKTtmb3IobGV0IG49MDtuPHQubGVuZ3RoO24rKylyW25dPXQuY2hhckNvZGVBdChuKTtyZXR1cm4gcn1mdW5jdGlvbiBnKGUsdD0xMil7Y29uc3Qgcj1uZXcgVWludDhBcnJheSh0KTtmb3IobGV0IG49MDtuPHQ7bisrKXJbbl09ZSUyNTYsZT1NYXRoLmZsb29yKGUvMjU2KTtyZXR1cm4gcn1hc3luYyBmdW5jdGlvbiBtKGUsdD0iIixyPTFlNixuPTApe2NvbnN0IHM9IkFFUy1HQ00iLG89bmV3IEFib3J0Q29udHJvbGxlcixhPURhdGUubm93KCksbD1hc3luYygpPT57Zm9yKGxldCB1PW47dTw9cjt1Kz0xKXtpZihvLnNpZ25hbC5hYm9ydGVkfHwhY3x8IXkpcmV0dXJuIG51bGw7dHJ5e2NvbnN0IGQ9YXdhaXQgY3J5cHRvLnN1YnRsZS5kZWNyeXB0KHtuYW1lOnMsaXY6Zyh1KX0sYyx5KTtpZihkKXJldHVybntjbGVhclRleHQ6bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKGQpLHRvb2s6RGF0ZS5ub3coKS1hfX1jYXRjaHt9fXJldHVybiBudWxsfTtsZXQgYz1udWxsLHk9bnVsbDt0cnl7eT1oKGUpO2NvbnN0IHU9YXdhaXQgY3J5cHRvLnN1YnRsZS5kaWdlc3QoIlNIQS0yNTYiLGYuZW5jb2RlKHQpKTtjPWF3YWl0IGNyeXB0by5zdWJ0bGUuaW1wb3J0S2V5KCJyYXciLHUscywhMSxbImRlY3J5cHQiXSl9Y2F0Y2h7cmV0dXJue3Byb21pc2U6UHJvbWlzZS5yZWplY3QoKSxjb250cm9sbGVyOm99fXJldHVybntwcm9taXNlOmwoKSxjb250cm9sbGVyOm99fWxldCBpO29ubWVzc2FnZT1hc3luYyBlPT57Y29uc3R7dHlwZTp0LHBheWxvYWQ6cixzdGFydDpuLG1heDpzfT1lLmRhdGE7bGV0IG89bnVsbDtpZih0PT09ImFib3J0IilpPT1udWxsfHxpLmFib3J0KCksaT12b2lkIDA7ZWxzZSBpZih0PT09IndvcmsiKXtpZigib2JmdXNjYXRlZCJpbiByKXtjb25zdHtrZXk6YSxvYmZ1c2NhdGVkOmx9PXJ8fHt9O289YXdhaXQgbShsLGEscyxuKX1lbHNle2NvbnN0e2FsZ29yaXRobTphLGNoYWxsZW5nZTpsLHNhbHQ6Y309cnx8e307bz1iKGwsYyxhLHMsbil9aT1vLmNvbnRyb2xsZXIsby5wcm9taXNlLnRoZW4oYT0+e3NlbGYucG9zdE1lc3NhZ2UoYSYmey4uLmEsd29ya2VyOiEwfSl9KX19fSkoKTsK",ce=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0)),Ge=typeof self<"u"&&self.Blob&&new Blob([ce(F)],{type:"text/javascript;charset=utf-8"});function It(n){let e;try{if(e=Ge&&(self.URL||self.webkitURL).createObjectURL(Ge),!e)throw"";const t=new Worker(e,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+F,{name:n==null?void 0:n.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}function Ee(){}function Lt(n,e){for(const t in e)n[t]=e[t];return n}function He(n){return n()}function Ye(){return Object.create(null)}function ge(n){n.forEach(He)}function Xe(n){return typeof n=="function"}function Nt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function zt(n){return Object.keys(n).length===0}function St(n,e,t,i){if(n){const o=Fe(n,e,t,i);return n[0](o)}}function Fe(n,e,t,i){return n[1]&&i?Lt(t.ctx.slice(),n[1](i(e))):t.ctx}function Tt(n,e,t,i){if(n[2]&&i){const o=n[2](i(t));if(e.dirty===void 0)return o;if(typeof o=="object"){const l=[],s=Math.max(e.dirty.length,o.length);for(let d=0;d32){const e=[],t=n.ctx.length/32;for(let i=0;in.removeEventListener(e,t,i)}function a(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Xt(n){return Array.from(n.childNodes)}function je(n,e,t){n.classList.toggle(e,!!t)}function Ft(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function jt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let me;function be(n){me=n}function Se(){if(!me)throw new Error("Function called outside component initialization");return me}function Dt(n){Se().$$.on_mount.push(n)}function Pt(n){Se().$$.on_destroy.push(n)}function Wt(){const n=Se();return(e,t,{cancelable:i=!1}={})=>{const o=n.$$.callbacks[e];if(o){const l=Ft(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(n,l)}),!l.defaultPrevented}return!0}}const ae=[],Re=[];let fe=[];const De=[],Pe=Promise.resolve();let Te=!1;function We(){Te||(Te=!0,Pe.then(w))}function Mt(){return We(),Pe}function Ae(n){fe.push(n)}const Ze=new Set;let ue=0;function w(){if(ue!==0)return;const n=me;do{try{for(;uen.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),fe=e}const Ce=new Set;let Bt;function Me(n,e){n&&n.i&&(Ce.delete(n),n.i(e))}function Ot(n,e,t,i){if(n&&n.o){if(Ce.has(n))return;Ce.add(n),Bt.c.push(()=>{Ce.delete(n)}),n.o(e)}}function Jt(n,e,t){const{fragment:i,after_update:o}=n.$$;i&&i.m(e,t),Ae(()=>{const l=n.$$.on_mount.map(He).filter(Xe);n.$$.on_destroy?n.$$.on_destroy.push(...l):ge(l),n.$$.on_mount=[]}),o.forEach(Ae)}function Qt(n,e){const t=n.$$;t.fragment!==null&&(Kt(t.after_update),ge(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function $t(n,e){n.$$.dirty[0]===-1&&(ae.push(n),We(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const W=P.length?P[0]:O;return f.ctx&&o(f.ctx[b],f.ctx[b]=W)&&(!f.skip_bound&&f.bound[b]&&f.bound[b](W),I&&$t(n,b)),O}):[],f.update(),I=!0,ge(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const b=Xt(e.target);f.fragment&&f.fragment.l(b),b.forEach(H)}else f.fragment&&f.fragment.c();e.intro&&Me(n.$$.fragment),Jt(n,e.target,e.anchor),w()}be(h)}let Ue;typeof HTMLElement=="function"&&(Ue=class extends HTMLElement{constructor(e,t,i){super();K(this,"$$ctor");K(this,"$$s");K(this,"$$c");K(this,"$$cn",!1);K(this,"$$d",{});K(this,"$$r",!1);K(this,"$$p_d",{});K(this,"$$l",{});K(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=S("slot"),l!=="default"&&a(s,"name",l)},m:function(f,I){X(f,s,I)},d:function(f){f&&H(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=jt(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]=Ie(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=Ie(l,this.$$d[l],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[l].attribute||l):this.setAttribute(this.$$p_d[l].attribute||l,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const l in this.$$l)for(const s of this.$$l[l]){const d=this.$$c.$on(l,s);this.$$l_u.set(s,d)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Ie(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Ie(n,e,t,i){var l;const o=(l=t[n])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function en(n,e,t,i,o,l){let s=class extends Ue{constructor(){super(n,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(d=>(e[d].attribute||d).toLowerCase())}};return Object.keys(e).forEach(d=>{Object.defineProperty(s.prototype,d,{get(){return this.$$c&&d in this.$$c?this.$$c[d]:this.$$d[d]},set(h){var f;h=Ie(d,h,e),this.$$d[d]=h,(f=this.$$c)==null||f.$set({[d]:h})}})}),i.forEach(d=>{Object.defineProperty(s.prototype,d,{get(){var h;return(h=this.$$c)==null?void 0:h[d]}})}),n.element=s,s}class tn{constructor(){K(this,"$$");K(this,"$$set")}$destroy(){Qt(this,1),this.$destroy=Ee}$on(e,t){if(!Xe(t))return Ee;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!zt(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const nn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(nn);const Ke=new TextEncoder;function rn(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function on(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await Be(i,n,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Be(n,e,t){return rn(await crypto.subtle.digest(t.toUpperCase(),Ke.encode(n+e)))}function ln(n,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let h=o;h<=i;h+=1){if(l.signal.aborted)return null;if(await Be(e,h,t)===n)return{number:h,took:Date.now()-s}}return null})(),controller:l}}function sn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function cn(n){const e=atob(n),t=new Uint8Array(e.length);for(let i=0;i{for(let I=i;I<=t;I+=1){if(l.signal.aborted||!h||!f)return null;try{const b=await crypto.subtle.decrypt({name:o,iv:an(I)},h,f);if(b)return{clearText:new TextDecoder().decode(b),took:Date.now()-s}}catch{}}return null};let h=null,f=null;try{f=cn(n);const I=await crypto.subtle.digest("SHA-256",Ke.encode(e));h=await crypto.subtle.importKey("raw",I,o,!1,["decrypt"])}catch{return{promise:Promise.reject(),controller:l}}return{promise:d(),controller:l}}var g=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(g||{});function un(n){Vt(n,"svelte-ddsc3z",'.altcha.svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);position:relative;text-align:left}.altcha.svelte-ddsc3z.svelte-ddsc3z:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z{background:var(--altcha-color-base, white);display:none;filter:drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.2));left:-100%;position:fixed;top:-100%;width:var(--altcha-max-width, 260px);z-index:999999}.altcha[data-floating=top].svelte-ddsc3z .altcha-anchor-arrow.svelte-ddsc3z{border-bottom-color:transparent;border-top-color:var(--altcha-color-border, #a0a0a0);bottom:-12px;top:auto}.altcha[data-floating=bottom].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-bottom-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating=top].svelte-ddsc3z.svelte-ddsc3z:focus-within::after{border-top-color:var(--altcha-color-border-focus, currentColor)}.altcha[data-floating].svelte-ddsc3z.svelte-ddsc3z:not([data-state=unverified]){display:block}.altcha-anchor-arrow.svelte-ddsc3z.svelte-ddsc3z{border:6px solid transparent;border-bottom-color:var(--altcha-color-border, #a0a0a0);content:"";height:0;left:12px;position:absolute;top:-12px;width:0}.altcha-main.svelte-ddsc3z.svelte-ddsc3z{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-ddsc3z.svelte-ddsc3z{flex-grow:1}.altcha-label.svelte-ddsc3z label.svelte-ddsc3z{cursor:pointer}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z{color:currentColor;opacity:0.3}.altcha-logo.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-error.svelte-ddsc3z.svelte-ddsc3z{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-ddsc3z.svelte-ddsc3z:hover{opacity:1}.altcha-footer.svelte-ddsc3z>.svelte-ddsc3z:first-child{flex-grow:1}.altcha-footer.svelte-ddsc3z a{color:currentColor}.altcha-checkbox.svelte-ddsc3z.svelte-ddsc3z{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-ddsc3z input.svelte-ddsc3z{width:18px;height:18px;margin:0}.altcha-hidden.svelte-ddsc3z.svelte-ddsc3z{display:none}.altcha-spinner.svelte-ddsc3z.svelte-ddsc3z{animation:svelte-ddsc3z-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-ddsc3z-altcha-spinner{100%{transform:rotate(360deg)}}')}function Oe(n){let e,t,i;return{c(){e=Q("svg"),t=Q("path"),i=Q("path"),a(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),a(t,"fill","currentColor"),a(t,"opacity",".25"),a(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),a(i,"fill","currentColor"),a(i,"class","altcha-spinner svelte-ddsc3z"),a(e,"width","24"),a(e,"height","24"),a(e,"viewBox","0 0 24 24"),a(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){X(o,e,l),C(e,t),C(e,i)},d(o){o&&H(e)}}}function dn(n){let e,t=n[11].label+"",i;return{c(){e=S("label"),a(e,"for",i=n[4]+"_checkbox"),a(e,"class","svelte-ddsc3z")},m(o,l){X(o,e,l),e.innerHTML=t},p(o,l){l[0]&2048&&t!==(t=o[11].label+"")&&(e.innerHTML=t),l[0]&16&&i!==(i=o[4]+"_checkbox")&&a(e,"for",i)},d(o){o&&H(e)}}}function hn(n){let e,t=n[11].verifying+"";return{c(){e=S("span")},m(i,o){X(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].verifying+"")&&(e.innerHTML=t)},d(i){i&&H(e)}}}function gn(n){let e,t=n[11].verified+"",i,o;return{c(){e=S("span"),i=$(),o=S("input"),a(o,"type","hidden"),a(o,"name",n[4]),o.value=n[6]},m(l,s){X(l,e,s),e.innerHTML=t,X(l,i,s),X(l,o,s)},p(l,s){s[0]&2048&&t!==(t=l[11].verified+"")&&(e.innerHTML=t),s[0]&16&&a(o,"name",l[4]),s[0]&64&&(o.value=l[6])},d(l){l&&(H(e),H(i),H(o))}}}function Je(n){let e,t,i,o,l,s,d;return{c(){e=S("div"),t=S("a"),i=Q("svg"),o=Q("path"),l=Q("path"),s=Q("path"),a(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),a(o,"fill","currentColor"),a(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),a(l,"fill","currentColor"),a(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),a(s,"fill","currentColor"),a(i,"width","22"),a(i,"height","22"),a(i,"viewBox","0 0 20 20"),a(i,"fill","none"),a(i,"xmlns","http://www.w3.org/2000/svg"),a(t,"href",tt),a(t,"target","_blank"),a(t,"class","altcha-logo svelte-ddsc3z"),a(t,"aria-label",d=n[11].ariaLinkLabel)},m(h,f){X(h,e,f),C(e,t),C(t,i),C(i,o),C(i,l),C(i,s)},p(h,f){f[0]&2048&&d!==(d=h[11].ariaLinkLabel)&&a(t,"aria-label",d)},d(h){h&&H(e)}}}function Qe(n){let e,t,i,o;function l(h,f){return h[7]===g.EXPIRED?bn:mn}let s=l(n),d=s(n);return{c(){e=S("div"),t=Q("svg"),i=Q("path"),o=$(),d.c(),a(i,"stroke-linecap","round"),a(i,"stroke-linejoin","round"),a(i,"d","M6 18L18 6M6 6l12 12"),a(t,"width","14"),a(t,"height","14"),a(t,"xmlns","http://www.w3.org/2000/svg"),a(t,"fill","none"),a(t,"viewBox","0 0 24 24"),a(t,"stroke-width","1.5"),a(t,"stroke","currentColor"),a(e,"class","altcha-error svelte-ddsc3z")},m(h,f){X(h,e,f),C(e,t),C(t,i),C(e,o),d.m(e,null)},p(h,f){s===(s=l(h))&&d?d.p(h,f):(d.d(1),d=s(h),d&&(d.c(),d.m(e,null)))},d(h){h&&H(e),d.d()}}}function mn(n){let e,t=n[11].error+"";return{c(){e=S("div"),a(e,"title",n[5])},m(i,o){X(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&H(e)}}}function bn(n){let e,t=n[11].expired+"";return{c(){e=S("div"),a(e,"title",n[5])},m(i,o){X(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",i[5])},d(i){i&&H(e)}}}function $e(n){let e,t,i=n[11].footer+"";return{c(){e=S("div"),t=S("div"),a(t,"class","svelte-ddsc3z"),a(e,"class","altcha-footer svelte-ddsc3z")},m(o,l){X(o,e,l),C(e,t),t.innerHTML=i},p(o,l){l[0]&2048&&i!==(i=o[11].footer+"")&&(t.innerHTML=i)},d(o){o&&H(e)}}}function qe(n){let e;return{c(){e=S("div"),a(e,"class","altcha-anchor-arrow svelte-ddsc3z")},m(t,i){X(t,e,i),n[48](e)},p:Ee,d(t){t&&H(e),n[48](null)}}}function yn(n){let e,t,i,o,l,s,d,h,f,I,b,O,P,W,T,N,q;const ee=n[46].default,G=St(ee,n,n[45],null);let A=n[7]===g.VERIFYING&&Oe();function te(u,y){return u[7]===g.VERIFIED?gn:u[7]===g.VERIFYING?hn:dn}let B=te(n),Y=B(n),x=(n[3]!==!0||n[12])&&Je(n),Z=(n[5]||n[7]===g.EXPIRED)&&Qe(n),z=n[11].footer&&(n[2]!==!0||n[12])&&$e(n),_=n[1]&&qe(n);return{c(){G&&G.c(),e=$(),t=S("div"),i=S("div"),A&&A.c(),o=$(),l=S("div"),s=S("input"),f=$(),I=S("div"),Y.c(),b=$(),x&&x.c(),O=$(),Z&&Z.c(),P=$(),z&&z.c(),W=$(),_&&_.c(),a(s,"type","checkbox"),a(s,"id",d=n[4]+"_checkbox"),s.required=h=n[0]!=="onsubmit"&&(!n[1]||n[0]!=="off"),a(s,"class","svelte-ddsc3z"),a(l,"class","altcha-checkbox svelte-ddsc3z"),je(l,"altcha-hidden",n[7]===g.VERIFYING),a(I,"class","altcha-label svelte-ddsc3z"),a(i,"class","altcha-main svelte-ddsc3z"),a(t,"class","altcha svelte-ddsc3z"),a(t,"data-state",n[7]),a(t,"data-floating",n[1])},m(u,y){G&&G.m(u,y),X(u,e,y),X(u,t,y),C(t,i),A&&A.m(i,null),C(i,o),C(i,l),C(l,s),s.checked=n[8],C(i,f),C(i,I),Y.m(I,null),C(i,b),x&&x.m(i,null),C(t,O),Z&&Z.m(t,null),C(t,P),z&&z.m(t,null),C(t,W),_&&_.m(t,null),n[49](t),T=!0,N||(q=[ze(s,"change",n[47]),ze(s,"change",n[13]),ze(s,"invalid",n[14])],N=!0)},p(u,y){G&&G.p&&(!T||y[1]&16384)&&At(G,ee,u,u[45],T?Tt(ee,u[45],y,null):Zt(u[45]),null),u[7]===g.VERIFYING?A||(A=Oe(),A.c(),A.m(i,o)):A&&(A.d(1),A=null),(!T||y[0]&16&&d!==(d=u[4]+"_checkbox"))&&a(s,"id",d),(!T||y[0]&3&&h!==(h=u[0]!=="onsubmit"&&(!u[1]||u[0]!=="off")))&&(s.required=h),y[0]&256&&(s.checked=u[8]),(!T||y[0]&128)&&je(l,"altcha-hidden",u[7]===g.VERIFYING),B===(B=te(u))&&Y?Y.p(u,y):(Y.d(1),Y=B(u),Y&&(Y.c(),Y.m(I,null))),u[3]!==!0||u[12]?x?x.p(u,y):(x=Je(u),x.c(),x.m(i,null)):x&&(x.d(1),x=null),u[5]||u[7]===g.EXPIRED?Z?Z.p(u,y):(Z=Qe(u),Z.c(),Z.m(t,P)):Z&&(Z.d(1),Z=null),u[11].footer&&(u[2]!==!0||u[12])?z?z.p(u,y):(z=$e(u),z.c(),z.m(t,W)):z&&(z.d(1),z=null),u[1]?_?_.p(u,y):(_=qe(u),_.c(),_.m(t,null)):_&&(_.d(1),_=null),(!T||y[0]&128)&&a(t,"data-state",u[7]),(!T||y[0]&2)&&a(t,"data-floating",u[1])},i(u){T||(Me(G,u),T=!0)},o(u){Ot(G,u),T=!1},d(u){u&&(H(e),H(t)),G&&G.d(u),A&&A.d(),Y.d(),x&&x.d(),Z&&Z.d(),z&&z.d(),_&&_.d(),n[49](null),N=!1,ge(q)}}}const et="Visit Altcha.org",tt="https://altcha.org/";function nt(n){return JSON.parse(n)}function vn(n,e,t){var Et,Rt;let i,o,l,s,{$$slots:d={},$$scope:h}=e,{auto:f=void 0}=e,{blockspam:I=void 0}=e,{challengeurl:b=void 0}=e,{challengejson:O=void 0}=e,{debug:P=!1}=e,{delay:W=0}=e,{expire:T=void 0}=e,{floating:N=void 0}=e,{floatinganchor:q=void 0}=e,{floatingoffset:ee=void 0}=e,{hidefooter:G=!1}=e,{hidelogo:A=!1}=e,{name:te="altcha"}=e,{maxnumber:B=1e6}=e,{mockerror:Y=!1}=e,{obfuscated:x=void 0}=e,{plugins:Z=void 0}=e,{refetchonexpire:z=!0}=e,{spamfilter:_=!1}=e,{strings:u=void 0}=e,{test:y=!1}=e,{verifyurl:ne=void 0}=e,{workers:de=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:ye=void 0}=e;const ve=Wt(),it=["SHA-256","SHA-384","SHA-512"],ot=(Rt=(Et=document.documentElement.lang)==null?void 0:Et.split("-"))==null?void 0:Rt[0];let oe=!1,E,le=null,he=null,v=null,pe=null,J=null,se=null,re=[],R=g.UNVERIFIED;Pt(()=>{pn(),v&&(v.removeEventListener("submit",ut),v.removeEventListener("reset",dt),v.removeEventListener("focusin",ft),v=null),J&&(clearTimeout(J),J=null),document.removeEventListener("click",ct),document.removeEventListener("scroll",at),window.removeEventListener("resize",gt)}),Dt(()=>{k("mounted","0.9.0"),k("workers",de),En(),k("plugins",re.length?re.map(r=>r.constructor.pluginName).join(", "):"none"),y&&k("using test mode"),T&&Ne(T),f!==void 0&&k("auto",f),N!==void 0&&mt(N),v=E.closest("form"),v&&(v.addEventListener("submit",ut,{capture:!0}),v.addEventListener("reset",dt),f==="onfocus"&&v.addEventListener("focusin",ft)),f==="onload"&&(x?we():ie()),i&&(G||A)&&k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."),requestAnimationFrame(()=>{ve("load")})});function lt(r,c){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:c.number,salt:r.salt,signature:r.signature,test:y?!0:void 0,took:c.took}))}function pn(){for(const r of re)r.destroy()}function st(){b&&z&&R===g.VERIFIED?ie():_e(g.EXPIRED,s.expired)}async function wn(){var r;if(Y)throw k("mocking error"),new Error("Mocked error.");if(o)return k("using provided json data"),o;if(y)return k("generating test challenge",{test:y}),on(typeof y!="boolean"?+y:void 0);{if(!b&&v){const p=v.getAttribute("action");p!=null&&p.includes("/form/")&&t(15,b=p+"/altcha")}if(!b)throw new Error("Attribute challengeurl not set.");k("fetching challenge from",b);const c=await fetch(b,{headers:_?{"x-altcha-spam-filter":"1"}:{}});if(c.status!==200)throw new Error(`Server responded with ${c.status}.`);const m=c.headers.get("Expires"),L=c.headers.get("X-Altcha-Config"),M=await c.json(),j=new URLSearchParams((r=M.salt.split("?"))==null?void 0:r[1]),V=j.get("expires")||j.get("expire");if(V){const p=new Date(+V*1e3),U=isNaN(p.getTime())?0:p.getTime()-Date.now();U>0&&Ne(U)}if(L)try{const p=JSON.parse(L);p&&typeof p=="object"&&(p.verifyurl&&(p.verifyurl=new URL(p.verifyurl,new URL(b)).toString()),vt(p))}catch(p){k("unable to configure from X-Altcha-Config",p)}if(!T&&(m!=null&&m.length)){const p=Date.parse(m);if(p){const U=p-Date.now();U>0&&Ne(U)}}return M}}function _n(r){var m;const c=v==null?void 0:v.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((m=c==null?void 0:c.value)==null?void 0:m.slice(c.value.indexOf("@")))||void 0}function kn(){return _==="ipAddress"?{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:!1,expectedCountries:void 0,expectedLanguages:void 0,fields:!1,ipAddress:void 0,text:void 0,timeZone:void 0}:typeof _=="object"?_:{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,text:void 0,timeZone:void 0}}function xn(r){return[...(v==null?void 0:v.querySelectorAll(r!=null&&r.length?r.map(m=>`input[name="${m}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((m,L)=>{const M=L.name,j=L.value;return M&&j&&(m[M]=/\n/.test(j)?j.replace(new RegExp("(?c instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",`[name=${te}]`,...r)}function Rn(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(R)?_&&(v==null?void 0:v.reportValidity())===!1?t(8,oe=!1):x?we():ie():t(8,oe=!0)}function ct(r){const c=r.target;N&&c&&!E.contains(c)&&(R===g.VERIFIED||f==="off"&&R===g.UNVERIFIED)&&t(9,E.style.display="none",E)}function at(){N&&R!==g.UNVERIFIED&&Le()}function Cn(r){for(const c of re)typeof c.onErrorChange=="function"&&c.onErrorChange(pe)}function ft(r){R===g.UNVERIFIED&&ie()}function ut(r){v&&f==="onsubmit"?R===g.UNVERIFIED?(r.preventDefault(),r.stopPropagation(),ie().then(()=>{v==null||v.requestSubmit()})):R!==g.VERIFIED&&(r.preventDefault(),r.stopPropagation(),R===g.VERIFYING&&ht()):v&&N&&f==="off"&&R===g.UNVERIFIED&&(r.preventDefault(),r.stopPropagation(),t(9,E.style.display="block",E),Le())}function dt(){_e()}function ht(){R===g.VERIFYING&&s.waitAlert&&alert(s.waitAlert)}function In(r){for(const c of re)typeof c.onStateChange=="function"&&c.onStateChange(R);N&&R!==g.UNVERIFIED&&requestAnimationFrame(()=>{Le()}),t(8,oe=R===g.VERIFIED)}function gt(){N&&Le()}function Le(r=20){if(E)if(he||(he=(q?document.querySelector(q):v==null?void 0:v.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])'))||v),he){const c=parseInt(ee,10)||12,m=he.getBoundingClientRect(),L=E.getBoundingClientRect(),M=document.documentElement.clientHeight,j=document.documentElement.clientWidth,V=N==="auto"?m.bottom+L.height+c+r>M:N==="top",p=Math.max(r,Math.min(j-r-L.width,m.left+m.width/2-L.width/2));if(V?t(9,E.style.top=`${m.top-(L.height+c)}px`,E):t(9,E.style.top=`${m.bottom+c}px`,E),t(9,E.style.left=`${p}px`,E),E.setAttribute("data-floating",V?"top":"bottom"),le){const U=le.getBoundingClientRect();t(10,le.style.left=m.left-p+m.width/2-U.width/2+"px",le)}}else k("unable to find floating anchor element")}async function Ln(r){if(!ne)throw new Error("Attribute verifyurl not set.");k("requesting server verification from",ne);const c={payload:r};if(_){const{blockedCountries:M,classifier:j,disableRules:V,email:p,expectedLanguages:U,expectedCountries:Ve,fields:ke,ipAddress:xe,text:Zn,timeZone:Ct}=kn();c.blockedCountries=M,c.classifier=j,c.disableRules=V,c.email=p===!1?void 0:_n(p),c.expectedCountries=Ve,c.expectedLanguages=U||(ot?[ot]:void 0),c.fields=ke===!1?void 0:xn(ke),c.ipAddress=xe===!1?void 0:xe||"auto",c.text=Zn,c.timeZone=Ct===!1?void 0:Ct||sn()}const m=await fetch(ne,{body:JSON.stringify(c),headers:{"content-type":"application/json"},method:"POST"});if(m.status!==200)throw new Error(`Server responded with ${m.status}.`);const L=await m.json();if(L!=null&&L.payload&&t(6,se=L.payload),ve("serververification",L),I&&L.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Ne(r){k("expire",r),J&&(clearTimeout(J),J=null),r<1?st():J=setTimeout(st,r)}function mt(r){k("floating",r),N!==r&&(t(9,E.style.left="",E),t(9,E.style.top="",E)),t(1,N=r===!0||r===""?"auto":r===!1||r==="false"?void 0:N),N?(f||t(0,f="onsubmit"),document.addEventListener("scroll",at),document.addEventListener("click",ct),window.addEventListener("resize",gt)):f==="onsubmit"&&t(0,f=void 0)}function bt(r){if(!r.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(r.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!it.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${it.join(", ")}`);if(!r.challenge||r.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!r.salt||r.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function yt(r){let c=null;if("Worker"in window){try{c=await Nn(r,r.maxnumber)}catch(m){k(m)}if((c==null?void 0:c.number)!==void 0||"obfuscated"in r)return{data:r,solution:c}}if("obfuscated"in r){const m=await fn(r.obfuscated,r.key,r.maxnumber);return{data:r,solution:await m.promise}}return{data:r,solution:await ln(r.challenge,r.salt,r.algorithm,r.maxnumber||B).promise}}async function Nn(r,c=typeof y=="number"?y:B,m=Math.ceil(de)){const L=[];m=Math.min(16,Math.max(1,m));for(let V=0;V{const U=p*M;return new Promise(Ve=>{V.addEventListener("message",ke=>{if(ke.data)for(const xe of L)xe!==V&&xe.postMessage({type:"abort"});Ve(ke.data)}),V.postMessage({payload:r,max:U+M,start:U,type:"work"})})}));for(const V of L)V.terminate();return j.find(V=>!!V)||null}async function we(){if(!x){t(7,R=g.ERROR);return}const r=re.find(c=>c.constructor.pluginName==="obfuscation");if(!r||!("clarify"in r)){t(7,R=g.ERROR),k("Plugin `obfuscation` not found. Import `altcha/plugins/obfuscation` to load it.");return}if("clarify"in r&&typeof r.clarify=="function")return r.clarify()}function vt(r){r.obfuscated!==void 0&&t(24,x=r.obfuscated),r.auto!==void 0&&(t(0,f=r.auto),f==="onload"&&(x?we():ie())),r.blockspam!==void 0&&t(16,I=!!r.blockspam),r.floatinganchor!==void 0&&t(20,q=r.floatinganchor),r.delay!==void 0&&t(18,W=r.delay),r.floatingoffset!==void 0&&t(21,ee=r.floatingoffset),r.floating!==void 0&&mt(r.floating),r.expire!==void 0&&(Ne(r.expire),t(19,T=r.expire)),r.challenge&&(bt(r.challenge),o=r.challenge),r.challengeurl!==void 0&&t(15,b=r.challengeurl),r.debug!==void 0&&t(17,P=!!r.debug),r.hidefooter!==void 0&&t(2,G=!!r.hidefooter),r.hidelogo!==void 0&&t(3,A=!!r.hidelogo),r.maxnumber!==void 0&&t(22,B=+r.maxnumber),r.mockerror!==void 0&&t(23,Y=!!r.mockerror),r.name!==void 0&&t(4,te=r.name),r.refetchonexpire!==void 0&&t(25,z=!!r.refetchonexpire),r.spamfilter!==void 0&&t(26,_=typeof r.spamfilter=="object"?r.spamfilter:!!r.spamfilter),r.strings&&t(44,l=r.strings),r.test!==void 0&&t(27,y=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(28,ne=r.verifyurl),r.workers!==void 0&&t(29,de=+r.workers),r.workerurl!==void 0&&t(30,ye=r.workerurl)}function pt(){return{auto:f,blockspam:I,challengeurl:b,debug:P,delay:W,expire:T,floating:N,floatinganchor:q,floatingoffset:ee,hidefooter:G,hidelogo:A,name:te,maxnumber:B,mockerror:Y,obfuscated:x,refetchonexpire:z,spamfilter:_,strings:s,test:y,verifyurl:ne,workers:de,workerurl:ye}}function wt(){return he}function zn(r){return re.find(c=>c.constructor.pluginName===r)}function _t(){return R}function _e(r=g.UNVERIFIED,c=null){J&&(clearTimeout(J),J=null),t(8,oe=!1),t(5,pe=c),t(6,se=null),t(7,R=r)}function kt(r){he=r}function xt(r,c=null){t(7,R=r),t(5,pe=c)}async function ie(){return _e(g.VERIFYING),await new Promise(r=>setTimeout(r,W||0)),wn().then(r=>(bt(r),k("challenge",r),yt(r))).then(({data:r,solution:c})=>{if(k("solution",c),"challenge"in r&&c&&!("clearText"in c))if((c==null?void 0:c.number)!==void 0){if(ne)return Ln(lt(r,c));t(6,se=lt(r,c)),k("payload",se)}else throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{Mt().then(()=>{t(7,R=g.VERIFIED),k("verified"),ve("verified",{payload:se})})}).catch(r=>{k(r),t(7,R=g.ERROR),t(5,pe=r.message)})}function Sn(){oe=this.checked,t(8,oe)}function Tn(r){Re[r?"unshift":"push"](()=>{le=r,t(10,le)})}function An(r){Re[r?"unshift":"push"](()=>{E=r,t(9,E)})}return n.$$set=r=>{"auto"in r&&t(0,f=r.auto),"blockspam"in r&&t(16,I=r.blockspam),"challengeurl"in r&&t(15,b=r.challengeurl),"challengejson"in r&&t(31,O=r.challengejson),"debug"in r&&t(17,P=r.debug),"delay"in r&&t(18,W=r.delay),"expire"in r&&t(19,T=r.expire),"floating"in r&&t(1,N=r.floating),"floatinganchor"in r&&t(20,q=r.floatinganchor),"floatingoffset"in r&&t(21,ee=r.floatingoffset),"hidefooter"in r&&t(2,G=r.hidefooter),"hidelogo"in r&&t(3,A=r.hidelogo),"name"in r&&t(4,te=r.name),"maxnumber"in r&&t(22,B=r.maxnumber),"mockerror"in r&&t(23,Y=r.mockerror),"obfuscated"in r&&t(24,x=r.obfuscated),"plugins"in r&&t(32,Z=r.plugins),"refetchonexpire"in r&&t(25,z=r.refetchonexpire),"spamfilter"in r&&t(26,_=r.spamfilter),"strings"in r&&t(33,u=r.strings),"test"in r&&t(27,y=r.test),"verifyurl"in r&&t(28,ne=r.verifyurl),"workers"in r&&t(29,de=r.workers),"workerurl"in r&&t(30,ye=r.workerurl),"$$scope"in r&&t(45,h=r.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&32768&&t(12,i=!!(b!=null&&b.includes(".altcha.org"))&&!!(b!=null&&b.includes("apiKey=ckey_"))),n.$$.dirty[1]&1&&(o=O?nt(O):void 0),n.$$.dirty[1]&4&&t(44,l=u?nt(u):{}),n.$$.dirty[1]&8192&&t(11,s={ariaLinkLabel:et,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),n.$$.dirty[0]&192&&ve("statechange",{payload:se,state:R}),n.$$.dirty[0]&32&&Cn(),n.$$.dirty[0]&128&&In()},[f,N,G,A,te,pe,se,R,oe,E,le,s,i,Rn,ht,b,I,P,W,T,q,ee,B,Y,x,z,_,y,ne,de,ye,O,Z,u,we,vt,pt,wt,zn,_t,_e,kt,xt,ie,l,h,d,Sn,Tn,An]}class rt extends tn{constructor(e){super(),qt(this,e,vn,yn,Nt,{auto:0,blockspam:16,challengeurl:15,challengejson:31,debug:17,delay:18,expire:19,floating:1,floatinganchor:20,floatingoffset:21,hidefooter:2,hidelogo:3,name:4,maxnumber:22,mockerror:23,obfuscated:24,plugins:32,refetchonexpire:25,spamfilter:26,strings:33,test:27,verifyurl:28,workers:29,workerurl:30,clarify:34,configure:35,getConfiguration:36,getFloatingAnchor:37,getPlugin:38,getState:39,reset:40,setFloatingAnchor:41,setState:42,verify:43},un,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),w()}get blockspam(){return this.$$.ctx[16]}set blockspam(e){this.$$set({blockspam:e}),w()}get challengeurl(){return this.$$.ctx[15]}set challengeurl(e){this.$$set({challengeurl:e}),w()}get challengejson(){return this.$$.ctx[31]}set challengejson(e){this.$$set({challengejson:e}),w()}get debug(){return this.$$.ctx[17]}set debug(e){this.$$set({debug:e}),w()}get delay(){return this.$$.ctx[18]}set delay(e){this.$$set({delay:e}),w()}get expire(){return this.$$.ctx[19]}set expire(e){this.$$set({expire:e}),w()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),w()}get floatinganchor(){return this.$$.ctx[20]}set floatinganchor(e){this.$$set({floatinganchor:e}),w()}get floatingoffset(){return this.$$.ctx[21]}set floatingoffset(e){this.$$set({floatingoffset:e}),w()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),w()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),w()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),w()}get maxnumber(){return this.$$.ctx[22]}set maxnumber(e){this.$$set({maxnumber:e}),w()}get mockerror(){return this.$$.ctx[23]}set mockerror(e){this.$$set({mockerror:e}),w()}get obfuscated(){return this.$$.ctx[24]}set obfuscated(e){this.$$set({obfuscated:e}),w()}get plugins(){return this.$$.ctx[32]}set plugins(e){this.$$set({plugins:e}),w()}get refetchonexpire(){return this.$$.ctx[25]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),w()}get spamfilter(){return this.$$.ctx[26]}set spamfilter(e){this.$$set({spamfilter:e}),w()}get strings(){return this.$$.ctx[33]}set strings(e){this.$$set({strings:e}),w()}get test(){return this.$$.ctx[27]}set test(e){this.$$set({test:e}),w()}get verifyurl(){return this.$$.ctx[28]}set verifyurl(e){this.$$set({verifyurl:e}),w()}get workers(){return this.$$.ctx[29]}set workers(e){this.$$set({workers:e}),w()}get workerurl(){return this.$$.ctx[30]}set workerurl(e){this.$$set({workerurl:e}),w()}get clarify(){return this.$$.ctx[34]}get configure(){return this.$$.ctx[35]}get getConfiguration(){return this.$$.ctx[36]}get getFloatingAnchor(){return this.$$.ctx[37]}get getPlugin(){return this.$$.ctx[38]}get getState(){return this.$$.ctx[39]}get reset(){return this.$$.ctx[40]}get setFloatingAnchor(){return this.$$.ctx[41]}get setState(){return this.$$.ctx[42]}get verify(){return this.$$.ctx[43]}}customElements.define("altcha-widget",en(rt,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},obfuscated:{},plugins:{},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},["default"],["clarify","configure","getConfiguration","getFloatingAnchor","getPlugin","getState","reset","setFloatingAnchor","setState","verify"],!1)),globalThis.altchaCreateWorker=n=>n?new Worker(new URL(n)):new It,globalThis.altchaPlugins=globalThis.altchaPlugins||[],D.Altcha=rt,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}); diff --git a/dist_external/altcha.d.ts b/dist_external/altcha.d.ts index ef75e1e..df0258a 100644 --- a/dist_external/altcha.d.ts +++ b/dist_external/altcha.d.ts @@ -3,6 +3,9 @@ export {}; declare module 'altcha'; declare global { + var altchaCreateWorker: (url?: string) => Worker; + var altchaPlugins: any[]; + type AltchaState = 'error' | 'expired' | 'verified' | 'verifying' | 'unverified'; interface AltchaStateChangeEvent extends CustomEvent<{ @@ -17,9 +20,7 @@ declare global { interface AltchaServerVerificationEvent extends CustomEvent> {} interface AltchaWidgetOptions { - analytics?: boolean | string; - auto?: 'onfocus' | 'onload' | 'onsubmit'; - beaconurl?: string; + auto?: 'off' | 'onfocus' | 'onload' | 'onsubmit'; blockspam?: boolean; challengeurl?: string; challengejson?: string; @@ -47,7 +48,13 @@ declare global { interface AltchaWidgetMethods { configure: (options: AltchaWidgetOptions) => void; clarify: () => Promise; + getConfiguration: () => AltchaWidgetOptions; + getFloatingAnchor: () => HTMLElement | null; + getPlugin: (name: string) => T; + getState: () => AltchaState; reset: (newState: AltchaState = 'unverified', err: string | null = null) => void; + setFloatingAnchor: (el: HTMLElement) => void; + setState: (newState: AltchaState, err: string | null = null) => void; verify: () => Promise; } diff --git a/dist_external/altcha.js b/dist_external/altcha.js index 68bfef2..f52365e 100644 --- a/dist_external/altcha.js +++ b/dist_external/altcha.js @@ -1,116 +1,109 @@ -var Kt = Object.defineProperty; -var ut = (n) => { - throw TypeError(n); -}; -var Qt = (n, e, t) => e in n ? Kt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; -var P = (n, e, t) => Qt(n, typeof e != "symbol" ? e + "" : e, t), ht = (n, e, t) => e.has(n) || ut("Cannot " + t); -var G = (n, e, t) => (ht(n, e, "read from private field"), t ? t.call(n) : e.get(n)), fe = (n, e, t) => e.has(n) ? ut("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), dt = (n, e, t, r) => (ht(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t); -function Me() { +var jt = Object.defineProperty; +var Ht = (n, e, t) => e in n ? jt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; +var Z = (n, e, t) => Ht(n, typeof e != "symbol" ? e + "" : e, t); +function xe() { } -function $t(n, e) { +function Ot(n, e) { for (const t in e) n[t] = e[t]; return ( /** @type {T & S} */ n ); } -function At(n) { +function ht(n) { return n(); } -function mt() { +function nt() { return /* @__PURE__ */ Object.create(null); } -function Ie(n) { - n.forEach(At); +function pe(n) { + n.forEach(ht); } -function xt(n) { +function dt(n) { return typeof n == "function"; } -function en(n, e) { +function Ut(n, e) { return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function"; } -function tn(n) { +function $t(n) { return Object.keys(n).length === 0; } -function nn(n, e, t, r) { +function Bt(n, e, t, i) { if (n) { - const o = Lt(n, e, t, r); + const o = gt(n, e, t, i); return n[0](o); } } -function Lt(n, e, t, r) { - return n[1] && r ? $t(t.ctx.slice(), n[1](r(e))) : t.ctx; +function gt(n, e, t, i) { + return n[1] && i ? Ot(t.ctx.slice(), n[1](i(e))) : t.ctx; } -function rn(n, e, t, r) { - if (n[2] && r) { - const o = n[2](r(t)); +function qt(n, e, t, i) { + if (n[2] && i) { + const o = n[2](i(t)); if (e.dirty === void 0) return o; if (typeof o == "object") { - const s = [], l = Math.max(e.dirty.length, o.length); - for (let c = 0; c < l; c += 1) - s[c] = e.dirty[c] | o[c]; - return s; + const l = [], s = Math.max(e.dirty.length, o.length); + for (let h = 0; h < s; h += 1) + l[h] = e.dirty[h] | o[h]; + return l; } return e.dirty | o; } return e.dirty; } -function on(n, e, t, r, o, s) { +function Zt(n, e, t, i, o, l) { if (o) { - const l = Lt(e, t, r, s); - n.p(l, o); + const s = gt(e, t, i, l); + n.p(s, o); } } -function sn(n) { +function Gt(n) { if (n.ctx.length > 32) { const e = [], t = n.ctx.length / 32; - for (let r = 0; r < t; r++) - e[r] = -1; + for (let i = 0; i < t; i++) + e[i] = -1; return e; } return -1; } -function I(n, e) { +function L(n, e) { n.appendChild(e); } -function B(n, e, t) { +function H(n, e, t) { n.insertBefore(e, t || null); } -function S(n) { +function j(n) { n.parentNode && n.parentNode.removeChild(n); } -function M(n) { +function F(n) { return document.createElement(n); } -function re(n) { +function K(n) { return document.createElementNS("http://www.w3.org/2000/svg", n); } -function It(n) { +function Yt(n) { return document.createTextNode(n); } -function Q() { - return It(" "); +function z() { + return Yt(" "); } -function ln() { - return It(""); +function Le(n, e, t, i) { + return n.addEventListener(e, t, i), () => n.removeEventListener(e, t, i); } -function Pe(n, e, t, r) { - return n.addEventListener(e, t, r), () => n.removeEventListener(e, t, r); -} -function u(n, e, t) { +function c(n, e, t) { t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t); } -function cn(n) { +function Wt(n) { return Array.from(n.childNodes); } -function gt(n, e, t) { +function rt(n, e, t) { n.classList.toggle(e, !!t); } -function an(n, e, { bubbles: t = !1, cancelable: r = !1 } = {}) { - return new CustomEvent(n, { detail: e, bubbles: t, cancelable: r }); +function Xt(n, e, { bubbles: t = !1, cancelable: i = !1 } = {}) { + return new CustomEvent(n, { detail: e, bubbles: t, cancelable: i }); } -function fn(n) { +function Jt(n) { const e = {}; return n.childNodes.forEach( /** @param {Element} node */ @@ -119,224 +112,224 @@ function fn(n) { } ), e; } -let pe; -function ke(n) { - pe = n; +let we; +function _e(n) { + we = n; } -function qe() { - if (!pe) throw new Error("Function called outside component initialization"); - return pe; +function Te() { + if (!we) throw new Error("Function called outside component initialization"); + return we; } -function un(n) { - qe().$$.on_mount.push(n); +function zt(n) { + Te().$$.on_mount.push(n); } -function hn(n) { - qe().$$.on_destroy.push(n); +function Kt(n) { + Te().$$.on_destroy.push(n); } -function dn() { - const n = qe(); - return (e, t, { cancelable: r = !1 } = {}) => { +function Qt() { + const n = Te(); + return (e, t, { cancelable: i = !1 } = {}) => { const o = n.$$.callbacks[e]; if (o) { - const s = an( + const l = Xt( /** @type {string} */ e, t, - { cancelable: r } + { cancelable: i } ); - return o.slice().forEach((l) => { - l.call(n, s); - }), !s.defaultPrevented; + return o.slice().forEach((s) => { + s.call(n, l); + }), !l.defaultPrevented; } return !0; }; } -const he = [], Ne = []; -let de = []; -const bt = [], Tt = /* @__PURE__ */ Promise.resolve(); -let Oe = !1; -function Rt() { - Oe || (Oe = !0, Tt.then(E)); +const ce = [], Ae = []; +let ue = []; +const it = [], mt = /* @__PURE__ */ Promise.resolve(); +let Se = !1; +function bt() { + Se || (Se = !0, mt.then(p)); } -function mn() { - return Rt(), Tt; +function en() { + return bt(), mt; } -function He(n) { - de.push(n); +function De(n) { + ue.push(n); } -const Be = /* @__PURE__ */ new Set(); -let ue = 0; -function E() { - if (ue !== 0) +const Re = /* @__PURE__ */ new Set(); +let fe = 0; +function p() { + if (fe !== 0) return; - const n = pe; + const n = we; do { try { - for (; ue < he.length; ) { - const e = he[ue]; - ue++, ke(e), gn(e.$$); + for (; fe < ce.length; ) { + const e = ce[fe]; + fe++, _e(e), tn(e.$$); } } catch (e) { - throw he.length = 0, ue = 0, e; + throw ce.length = 0, fe = 0, e; } - for (ke(null), he.length = 0, ue = 0; Ne.length; ) Ne.pop()(); - for (let e = 0; e < de.length; e += 1) { - const t = de[e]; - Be.has(t) || (Be.add(t), t()); + for (_e(null), ce.length = 0, fe = 0; Ae.length; ) Ae.pop()(); + for (let e = 0; e < ue.length; e += 1) { + const t = ue[e]; + Re.has(t) || (Re.add(t), t()); } - de.length = 0; - } while (he.length); - for (; bt.length; ) - bt.pop()(); - Oe = !1, Be.clear(), ke(n); + ue.length = 0; + } while (ce.length); + for (; it.length; ) + it.pop()(); + Se = !1, Re.clear(), _e(n); } -function gn(n) { +function tn(n) { if (n.fragment !== null) { - n.update(), Ie(n.before_update); + n.update(), pe(n.before_update); const e = n.dirty; - n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(He); + n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(De); } } -function bn(n) { +function nn(n) { const e = [], t = []; - de.forEach((r) => n.indexOf(r) === -1 ? e.push(r) : t.push(r)), t.forEach((r) => r()), de = e; + ue.forEach((i) => n.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), ue = e; } -const De = /* @__PURE__ */ new Set(); -let yn; -function Ft(n, e) { - n && n.i && (De.delete(n), n.i(e)); +const ve = /* @__PURE__ */ new Set(); +let rn; +function yt(n, e) { + n && n.i && (ve.delete(n), n.i(e)); } -function wn(n, e, t, r) { +function on(n, e, t, i) { if (n && n.o) { - if (De.has(n)) return; - De.add(n), yn.c.push(() => { - De.delete(n); + if (ve.has(n)) return; + ve.add(n), rn.c.push(() => { + ve.delete(n); }), n.o(e); } } -function _n(n, e, t) { - const { fragment: r, after_update: o } = n.$$; - r && r.m(e, t), He(() => { - const s = n.$$.on_mount.map(At).filter(xt); - n.$$.on_destroy ? n.$$.on_destroy.push(...s) : Ie(s), n.$$.on_mount = []; - }), o.forEach(He); +function ln(n, e, t) { + const { fragment: i, after_update: o } = n.$$; + i && i.m(e, t), De(() => { + const l = n.$$.on_mount.map(ht).filter(dt); + n.$$.on_destroy ? n.$$.on_destroy.push(...l) : pe(l), n.$$.on_mount = []; + }), o.forEach(De); } -function En(n, e) { +function sn(n, e) { const t = n.$$; - t.fragment !== null && (bn(t.after_update), Ie(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); + t.fragment !== null && (nn(t.after_update), pe(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []); } -function vn(n, e) { - n.$$.dirty[0] === -1 && (he.push(n), Rt(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31; +function fn(n, e) { + n.$$.dirty[0] === -1 && (ce.push(n), bt(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31; } -function kn(n, e, t, r, o, s, l = null, c = [-1]) { - const a = pe; - ke(n); - const h = n.$$ = { +function cn(n, e, t, i, o, l, s = null, h = [-1]) { + const d = we; + _e(n); + const u = n.$$ = { fragment: null, ctx: [], // state - props: s, - update: Me, + props: l, + update: xe, not_equal: o, - bound: mt(), + bound: nt(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], - context: new Map(e.context || (a ? a.$$.context : [])), + context: new Map(e.context || (d ? d.$$.context : [])), // everything else - callbacks: mt(), - dirty: c, + callbacks: nt(), + dirty: h, skip_bound: !1, - root: e.target || a.$$.root + root: e.target || d.$$.root }; - l && l(h.root); - let w = !1; - if (h.ctx = t ? t(n, e.props || {}, (x, $, ...k) => { - const J = k.length ? k[0] : $; - return h.ctx && o(h.ctx[x], h.ctx[x] = J) && (!h.skip_bound && h.bound[x] && h.bound[x](J), w && vn(n, x)), $; - }) : [], h.update(), w = !0, Ie(h.before_update), h.fragment = r ? r(h.ctx) : !1, e.target) { + s && s(u.root); + let A = !1; + if (u.ctx = t ? t(n, e.props || {}, (b, Y, ...U) => { + const $ = U.length ? U[0] : Y; + return u.ctx && o(u.ctx[b], u.ctx[b] = $) && (!u.skip_bound && u.bound[b] && u.bound[b]($), A && fn(n, b)), Y; + }) : [], u.update(), A = !0, pe(u.before_update), u.fragment = i ? i(u.ctx) : !1, e.target) { if (e.hydrate) { - const x = cn(e.target); - h.fragment && h.fragment.l(x), x.forEach(S); + const b = Wt(e.target); + u.fragment && u.fragment.l(b), b.forEach(j); } else - h.fragment && h.fragment.c(); - e.intro && Ft(n.$$.fragment), _n(n, e.target, e.anchor), E(); + u.fragment && u.fragment.c(); + e.intro && yt(n.$$.fragment), ln(n, e.target, e.anchor), p(); } - ke(a); + _e(d); } -let Dt; -typeof HTMLElement == "function" && (Dt = class extends HTMLElement { - constructor(e, t, r) { +let _t; +typeof HTMLElement == "function" && (_t = class extends HTMLElement { + constructor(e, t, i) { super(); /** The Svelte component constructor */ - P(this, "$$ctor"); + Z(this, "$$ctor"); /** Slots */ - P(this, "$$s"); + Z(this, "$$s"); /** The Svelte component instance */ - P(this, "$$c"); + Z(this, "$$c"); /** Whether or not the custom element is connected */ - P(this, "$$cn", !1); + Z(this, "$$cn", !1); /** Component props data */ - P(this, "$$d", {}); + Z(this, "$$d", {}); /** `true` if currently in the process of reflecting component props back to attributes */ - P(this, "$$r", !1); + Z(this, "$$r", !1); /** @type {Record} Props definition (name, reflected, type etc) */ - P(this, "$$p_d", {}); + Z(this, "$$p_d", {}); /** @type {Record} Event listeners */ - P(this, "$$l", {}); + Z(this, "$$l", {}); /** @type {Map} Event listener unsubscribe functions */ - P(this, "$$l_u", /* @__PURE__ */ new Map()); - this.$$ctor = e, this.$$s = t, r && this.attachShadow({ mode: "open" }); + Z(this, "$$l_u", /* @__PURE__ */ new Map()); + this.$$ctor = e, this.$$s = t, i && this.attachShadow({ mode: "open" }); } - addEventListener(e, t, r) { + 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, r); + super.addEventListener(e, t, i); } - removeEventListener(e, t, r) { - if (super.removeEventListener(e, t, r), this.$$c) { + 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(s) { + let e = function(l) { return () => { - let l; + let s; return { c: function() { - l = M("slot"), s !== "default" && u(l, "name", s); + s = F("slot"), l !== "default" && c(s, "name", l); }, /** * @param {HTMLElement} target * @param {HTMLElement} [anchor] */ - m: function(h, w) { - B(h, l, w); + m: function(u, A) { + H(u, s, A); }, - d: function(h) { - h && S(l); + d: function(u) { + u && j(s); } }; }; }; if (await Promise.resolve(), !this.$$cn || this.$$c) return; - const t = {}, r = fn(this); - for (const s of this.$$s) - s in r && (t[s] = [e(s)]); - for (const s of this.attributes) { - const l = this.$$g_p(s.name); - l in this.$$d || (this.$$d[l] = Se(l, s.value, this.$$p_d, "toProp")); + const t = {}, i = Jt(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] = Ce(s, l.value, this.$$p_d, "toProp")); } - for (const s in this.$$p_d) - !(s in this.$$d) && this[s] !== void 0 && (this.$$d[s] = this[s], delete this[s]); + 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: { @@ -349,32 +342,32 @@ typeof HTMLElement == "function" && (Dt = class extends HTMLElement { }); const o = () => { this.$$r = !0; - for (const s in this.$$p_d) - if (this.$$d[s] = this.$$c.$$.ctx[this.$$c.$$.props[s]], this.$$p_d[s].reflect) { - const l = Se( - s, - this.$$d[s], + 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 = Ce( + l, + this.$$d[l], this.$$p_d, "toAttribute" ); - l == null ? this.removeAttribute(this.$$p_d[s].attribute || s) : this.setAttribute(this.$$p_d[s].attribute || s, l); + 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 s in this.$$l) - for (const l of this.$$l[s]) { - const c = this.$$c.$on(s, l); - this.$$l_u.set(l, c); + for (const l in this.$$l) + for (const s of this.$$l[l]) { + const h = this.$$c.$on(l, s); + this.$$l_u.set(s, h); } this.$$l = {}; } } // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte // and setting attributes through setAttribute etc, this is helpful - attributeChangedCallback(e, t, r) { + attributeChangedCallback(e, t, i) { var o; - this.$$r || (e = this.$$g_p(e), this.$$d[e] = Se(e, r, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); + this.$$r || (e = this.$$g_p(e), this.$$d[e] = Ce(e, i, this.$$p_d, "toProp"), (o = this.$$c) == null || o.$set({ [e]: this.$$d[e] })); } disconnectedCallback() { this.$$cn = !1, Promise.resolve().then(() => { @@ -387,12 +380,12 @@ typeof HTMLElement == "function" && (Dt = class extends HTMLElement { ) || e; } }); -function Se(n, e, t, r) { - var s; - const o = (s = t[n]) == null ? void 0 : s.type; - if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !r || !t[n]) +function Ce(n, e, t, i) { + var l; + const o = (l = t[n]) == null ? void 0 : l.type; + if (e = o === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[n]) return e; - if (r === "toAttribute") + if (i === "toAttribute") switch (o) { case "Object": case "Array": @@ -417,38 +410,38 @@ function Se(n, e, t, r) { return e; } } -function pn(n, e, t, r, o, s) { - let l = class extends Dt { +function un(n, e, t, i, o, l) { + let s = class extends _t { constructor() { super(n, t, o), this.$$p_d = e; } static get observedAttributes() { return Object.keys(e).map( - (c) => (e[c].attribute || c).toLowerCase() + (h) => (e[h].attribute || h).toLowerCase() ); } }; - return Object.keys(e).forEach((c) => { - Object.defineProperty(l.prototype, c, { + return Object.keys(e).forEach((h) => { + Object.defineProperty(s.prototype, h, { get() { - return this.$$c && c in this.$$c ? this.$$c[c] : this.$$d[c]; + return this.$$c && h in this.$$c ? this.$$c[h] : this.$$d[h]; }, - set(a) { - var h; - a = Se(c, a, e), this.$$d[c] = a, (h = this.$$c) == null || h.$set({ [c]: a }); + set(d) { + var u; + d = Ce(h, d, e), this.$$d[h] = d, (u = this.$$c) == null || u.$set({ [h]: d }); } }); - }), r.forEach((c) => { - Object.defineProperty(l.prototype, c, { + }), i.forEach((h) => { + Object.defineProperty(s.prototype, h, { get() { - var a; - return (a = this.$$c) == null ? void 0 : a[c]; + var d; + return (d = this.$$c) == null ? void 0 : d[h]; } }); }), n.element = /** @type {any} */ - l, l; + s, s; } -class Cn { +class an { constructor() { /** * ### PRIVATE API @@ -457,7 +450,7 @@ class Cn { * * @type {any} */ - P(this, "$$"); + Z(this, "$$"); /** * ### PRIVATE API * @@ -465,11 +458,11 @@ class Cn { * * @type {any} */ - P(this, "$$set"); + Z(this, "$$set"); } /** @returns {void} */ $destroy() { - En(this, 1), this.$destroy = Me; + sn(this, 1), this.$destroy = xe; } /** * @template {Extract} K @@ -478,12 +471,12 @@ class Cn { * @returns {() => void} */ $on(e, t) { - if (!xt(t)) - return Me; - const r = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); - return r.push(t), () => { - const o = r.indexOf(t); - o !== -1 && r.splice(o, 1); + if (!dt(t)) + return xe; + const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); + return i.push(t), () => { + const o = i.indexOf(t); + o !== -1 && i.splice(o, 1); }; } /** @@ -491,104 +484,104 @@ class Cn { * @returns {void} */ $set(e) { - this.$$set && !tn(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); + this.$$set && !$t(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); } } -const An = "4"; -typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(An); -const St = new TextEncoder(); -function xn(n) { +const hn = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(hn); +const wt = new TextEncoder(); +function dn(n) { return [...new Uint8Array(n)].map((e) => e.toString(16).padStart(2, "0")).join(""); } -async function Ln(n, e = "SHA-256", t = 1e5) { - const r = Date.now().toString(16); +async function gn(n, e = "SHA-256", t = 1e5) { + const i = Date.now().toString(16); n || (n = Math.round(Math.random() * t)); - const o = await Mt(r, n, e); + const o = await pt(i, n, e); return { algorithm: e, challenge: o, - salt: r, + salt: i, signature: "" }; } -async function Mt(n, e, t) { - return xn( +async function pt(n, e, t) { + return dn( await crypto.subtle.digest( t.toUpperCase(), - St.encode(n + e) + wt.encode(n + e) ) ); } -function In(n, e, t = "SHA-256", r = 1e6, o = 0) { - const s = new AbortController(), l = Date.now(); +function mn(n, e, t = "SHA-256", i = 1e6, o = 0) { + const l = new AbortController(), s = Date.now(); return { promise: (async () => { - for (let a = o; a <= r; a += 1) { - if (s.signal.aborted) + for (let d = o; d <= i; d += 1) { + if (l.signal.aborted) return null; - if (await Mt(e, a, t) === n) + if (await pt(e, d, t) === n) return { - number: a, - took: Date.now() - l + number: d, + took: Date.now() - s }; } return null; })(), - controller: s + controller: l }; } -function Nt() { +function bn() { try { return Intl.DateTimeFormat().resolvedOptions().timeZone; } catch { } } -function Tn(n) { +function yn(n) { const e = atob(n), t = new Uint8Array(e.length); - for (let r = 0; r < e.length; r++) - t[r] = e.charCodeAt(r); + for (let i = 0; i < e.length; i++) + t[i] = e.charCodeAt(i); return t; } -function Rn(n, e = 12) { +function _n(n, e = 12) { const t = new Uint8Array(e); - for (let r = 0; r < e; r++) - t[r] = n % 256, n = Math.floor(n / 256); + for (let i = 0; i < e; i++) + t[i] = n % 256, n = Math.floor(n / 256); return t; } -async function Fn(n, e = "", t = 1e6, r = 0) { - const o = "AES-GCM", s = new AbortController(), l = Date.now(), c = async () => { - for (let w = r; w <= t; w += 1) { - if (s.signal.aborted || !a || !h) +async function wn(n, e = "", t = 1e6, i = 0) { + const o = "AES-GCM", l = new AbortController(), s = Date.now(), h = async () => { + for (let A = i; A <= t; A += 1) { + if (l.signal.aborted || !d || !u) return null; try { - const x = await crypto.subtle.decrypt( + const b = await crypto.subtle.decrypt( { name: o, - iv: Rn(w) + iv: _n(A) }, - a, - h + d, + u ); - if (x) + if (b) return { - clearText: new TextDecoder().decode(x), - took: Date.now() - l + clearText: new TextDecoder().decode(b), + took: Date.now() - s }; } catch { } } return null; }; - let a = null, h = null; + let d = null, u = null; try { - h = Tn(n); - const w = await crypto.subtle.digest( + u = yn(n); + const A = await crypto.subtle.digest( "SHA-256", - St.encode(e) + wt.encode(e) ); - a = await crypto.subtle.importKey( + d = await crypto.subtle.importKey( "raw", - w, + A, o, !1, ["decrypt"] @@ -596,185 +589,84 @@ async function Fn(n, e = "", t = 1e6, r = 0) { } catch { return { promise: Promise.reject(), - controller: s + controller: l }; } return { - promise: c(), - controller: s + promise: h(), + controller: l }; } -var me, ge, Ce, Ae, xe, Le; -class Dn { - constructor(e) { - P(this, "beaconUrl", null); - P(this, "error", null); - P(this, "loadTime", Date.now()); - P(this, "submitTime", null); - P(this, "startTime", null); - P(this, "viewTimeThresholdMs", 1500); - fe(this, me, {}); - fe(this, ge, null); - fe(this, Ce, this.onFormChange.bind(this)); - fe(this, Ae, this.onFormFocus.bind(this)); - fe(this, xe, this.onFormSubmit.bind(this)); - fe(this, Le, this.onUnload.bind(this)); - this.elForm = e, window.addEventListener("unload", G(this, Le)), this.elForm.addEventListener("change", G(this, Ce)), this.elForm.addEventListener("focusin", G(this, Ae)), this.elForm.addEventListener("submit", G(this, xe)); - } - data() { - const e = Object.entries(G(this, me)); - return { - correction: e.length && e.filter(([t, r]) => r > 1).length / e.length || 0, - dropoff: !this.submitTime && !this.error && G(this, ge) ? G(this, ge) : null, - error: this.error, - mobile: this.isMobile(), - start: this.startTime, - submit: this.submitTime, - tz: Nt() - }; - } - dataAsBase64() { - try { - return btoa( - JSON.stringify(this.data()) - ); - } catch (e) { - console.error("failed to encode ALTCHA session data to base64", e); - } - return ""; - } - destroy() { - window.removeEventListener("unload", G(this, Le)), this.elForm.removeEventListener("change", G(this, Ce)), this.elForm.removeEventListener("focusin", G(this, Ae)), this.elForm.removeEventListener("submit", G(this, xe)); - } - end() { - this.submitTime || (this.submitTime = Date.now()); - } - getFieldName(e, t = 40) { - const r = e.getAttribute("data-group-label"), o = e.getAttribute("name") || e.getAttribute("aria-label"); - return ((r ? r + ": " : "") + o).slice(0, t); - } - isMobile() { - const e = "userAgentData" in navigator && navigator.userAgentData ? navigator.userAgentData : {}; - return "mobile" in e ? e.mobile === !0 : /Mobi/i.test(window.navigator.userAgent); - } - isInput(e) { - return ["INPUT", "SELECT", "TEXTAREA"].includes(e.tagName); - } - onFormFieldChange(e) { - const t = this.getFieldName(e); - t && this.trackFieldChange(t); - } - onFormChange(e) { - const t = e.target; - t && this.isInput(t) && this.onFormFieldChange(t); - } - onFormFocus(e) { - const t = e.target; - if (this.startTime || this.start(), t && this.isInput(t)) { - const r = this.getFieldName(t); - r && dt(this, ge, r); - } - } - onFormSubmit() { - this.end(); - } - onUnload() { - this.loadTime <= Date.now() - this.viewTimeThresholdMs && !this.submitTime && this.sendBeacon(); - } - async sendBeacon() { - if (this.beaconUrl && "sendBeacon" in navigator) - try { - navigator.sendBeacon( - new URL(this.beaconUrl, location.origin), - JSON.stringify(this.data()) - ); - } catch { - } - } - start() { - this.startTime = Date.now(); - } - trackError(e) { - this.error = e === null ? null : String(e); - } - trackFieldChange(e) { - G(this, me)[e] = (G(this, me)[e] || 0) + 1; - } -} -me = new WeakMap(), ge = new WeakMap(), Ce = new WeakMap(), Ae = new WeakMap(), xe = new WeakMap(), Le = new WeakMap(); -var y = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(y || {}); -function yt(n) { - let e, t, r; +var m = /* @__PURE__ */ ((n) => (n.ERROR = "error", n.VERIFIED = "verified", n.VERIFYING = "verifying", n.UNVERIFIED = "unverified", n.EXPIRED = "expired", n))(m || {}); +function ot(n) { + let e, t, i; return { c() { - e = re("svg"), t = re("path"), r = re("path"), u(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"), u(t, "fill", "currentColor"), u(t, "opacity", ".25"), u(r, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), u(r, "fill", "currentColor"), u(r, "class", "altcha-spinner"), u(e, "width", "24"), u(e, "height", "24"), u(e, "viewBox", "0 0 24 24"), u(e, "xmlns", "http://www.w3.org/2000/svg"); + e = K("svg"), t = K("path"), i = K("path"), c(t, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), c(t, "fill", "currentColor"), c(t, "opacity", ".25"), c(i, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), c(i, "fill", "currentColor"), c(i, "class", "altcha-spinner"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg"); }, - m(o, s) { - B(o, e, s), I(e, t), I(e, r); + m(o, l) { + H(o, e, l), L(e, t), L(e, i); }, d(o) { - o && S(e); + o && j(e); } }; } -function Sn(n) { +function pn(n) { let e, t = ( /*_strings*/ - n[13].label + "" - ), r; + n[11].label + "" + ), i; return { c() { - e = M("label"), u(e, "for", r = /*name*/ + e = F("label"), c(e, "for", i = /*name*/ n[4] + "_checkbox"); }, - m(o, s) { - B(o, e, s), e.innerHTML = t; + m(o, l) { + H(o, e, l), e.innerHTML = t; }, - p(o, s) { - s[0] & /*_strings*/ - 8192 && t !== (t = /*_strings*/ - o[13].label + "") && (e.innerHTML = t), s[0] & /*name*/ - 16 && r !== (r = /*name*/ - o[4] + "_checkbox") && u(e, "for", r); + p(o, l) { + l[0] & /*_strings*/ + 2048 && t !== (t = /*_strings*/ + o[11].label + "") && (e.innerHTML = t), l[0] & /*name*/ + 16 && i !== (i = /*name*/ + o[4] + "_checkbox") && c(e, "for", i); }, d(o) { - o && S(e); + o && j(e); } }; } -function Mn(n) { +function En(n) { let e, t = ( /*_strings*/ - n[13].verifying + "" + n[11].verifying + "" ); return { c() { - e = M("span"); + e = F("span"); }, - m(r, o) { - B(r, e, o), e.innerHTML = t; + m(i, o) { + H(i, e, o), e.innerHTML = t; }, - p(r, o) { + p(i, o) { o[0] & /*_strings*/ - 8192 && t !== (t = /*_strings*/ - r[13].verifying + "") && (e.innerHTML = t); + 2048 && t !== (t = /*_strings*/ + i[11].verifying + "") && (e.innerHTML = t); }, - d(r) { - r && S(e); + d(i) { + i && j(e); } }; } -function Nn(n) { +function kn(n) { let e, t = ( /*_strings*/ - n[13].verified + "" - ), r, o, s, l, c = ( - /*session*/ - n[11] && wt(n) - ); + n[11].verified + "" + ), i, o; return { c() { - e = M("span"), r = Q(), o = M("input"), s = Q(), c && c.c(), l = ln(), u(o, "type", "hidden"), u( + e = F("span"), i = z(), o = F("input"), c(o, "type", "hidden"), c( o, "name", /*name*/ @@ -782,585 +674,413 @@ function Nn(n) { ), o.value = /*payload*/ n[6]; }, - m(a, h) { - B(a, e, h), e.innerHTML = t, B(a, r, h), B(a, o, h), B(a, s, h), c && c.m(a, h), B(a, l, h); + m(l, s) { + H(l, e, s), e.innerHTML = t, H(l, i, s), H(l, o, s); }, - p(a, h) { - h[0] & /*_strings*/ - 8192 && t !== (t = /*_strings*/ - a[13].verified + "") && (e.innerHTML = t), h[0] & /*name*/ - 16 && u( + p(l, s) { + s[0] & /*_strings*/ + 2048 && t !== (t = /*_strings*/ + l[11].verified + "") && (e.innerHTML = t), s[0] & /*name*/ + 16 && c( o, "name", /*name*/ - a[4] - ), h[0] & /*payload*/ + l[4] + ), s[0] & /*payload*/ 64 && (o.value = /*payload*/ - a[6]), /*session*/ - a[11] ? c ? c.p(a, h) : (c = wt(a), c.c(), c.m(l.parentNode, l)) : c && (c.d(1), c = null); - }, - d(a) { - a && (S(e), S(r), S(o), S(s), S(l)), c && c.d(a); - } - }; -} -function wt(n) { - let e; - return { - c() { - e = M("input"), u(e, "type", "hidden"), u(e, "name", "__session"), e.value = /*sessionPayload*/ - n[12]; - }, - m(t, r) { - B(t, e, r); + l[6]); }, - p(t, r) { - r[0] & /*sessionPayload*/ - 4096 && (e.value = /*sessionPayload*/ - t[12]); - }, - d(t) { - t && S(e); + d(l) { + l && (j(e), j(i), j(o)); } }; } -function _t(n) { - let e, t, r, o, s, l, c; +function lt(n) { + let e, t, i, o, l, s, h; return { c() { - e = M("div"), t = M("a"), r = re("svg"), o = re("path"), s = re("path"), l = re("path"), u(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"), u(o, "fill", "currentColor"), u(s, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), u(s, "fill", "currentColor"), u(l, "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"), u(l, "fill", "currentColor"), u(r, "width", "22"), u(r, "height", "22"), u(r, "viewBox", "0 0 20 20"), u(r, "fill", "none"), u(r, "xmlns", "http://www.w3.org/2000/svg"), u(t, "href", Vt), u(t, "target", "_blank"), u(t, "class", "altcha-logo"), u(t, "aria-label", c = /*_strings*/ - n[13].ariaLinkLabel); + e = F("div"), t = F("a"), i = K("svg"), o = K("path"), l = K("path"), s = K("path"), c(o, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), c(o, "fill", "currentColor"), c(l, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), c(l, "fill", "currentColor"), c(s, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), c(s, "fill", "currentColor"), c(i, "width", "22"), c(i, "height", "22"), c(i, "viewBox", "0 0 20 20"), c(i, "fill", "none"), c(i, "xmlns", "http://www.w3.org/2000/svg"), c(t, "href", Et), c(t, "target", "_blank"), c(t, "class", "altcha-logo"), c(t, "aria-label", h = /*_strings*/ + n[11].ariaLinkLabel); }, - m(a, h) { - B(a, e, h), I(e, t), I(t, r), I(r, o), I(r, s), I(r, l); + m(d, u) { + H(d, e, u), L(e, t), L(t, i), L(i, o), L(i, l), L(i, s); }, - p(a, h) { - h[0] & /*_strings*/ - 8192 && c !== (c = /*_strings*/ - a[13].ariaLinkLabel) && u(t, "aria-label", c); + p(d, u) { + u[0] & /*_strings*/ + 2048 && h !== (h = /*_strings*/ + d[11].ariaLinkLabel) && c(t, "aria-label", h); }, - d(a) { - a && S(e); + d(d) { + d && j(e); } }; } -function Et(n) { - let e, t, r, o; - function s(a, h) { +function st(n) { + let e, t, i, o; + function l(d, u) { return ( /*state*/ - a[7] === y.EXPIRED ? jn : Vn + d[7] === m.EXPIRED ? Cn : vn ); } - let l = s(n), c = l(n); + let s = l(n), h = s(n); return { c() { - e = M("div"), t = re("svg"), r = re("path"), o = Q(), c.c(), u(r, "stroke-linecap", "round"), u(r, "stroke-linejoin", "round"), u(r, "d", "M6 18L18 6M6 6l12 12"), u(t, "width", "14"), u(t, "height", "14"), u(t, "xmlns", "http://www.w3.org/2000/svg"), u(t, "fill", "none"), u(t, "viewBox", "0 0 24 24"), u(t, "stroke-width", "1.5"), u(t, "stroke", "currentColor"), u(e, "class", "altcha-error"); + e = F("div"), t = K("svg"), i = K("path"), o = z(), h.c(), c(i, "stroke-linecap", "round"), c(i, "stroke-linejoin", "round"), c(i, "d", "M6 18L18 6M6 6l12 12"), c(t, "width", "14"), c(t, "height", "14"), c(t, "xmlns", "http://www.w3.org/2000/svg"), c(t, "fill", "none"), c(t, "viewBox", "0 0 24 24"), c(t, "stroke-width", "1.5"), c(t, "stroke", "currentColor"), c(e, "class", "altcha-error"); }, - m(a, h) { - B(a, e, h), I(e, t), I(t, r), I(e, o), c.m(e, null); + m(d, u) { + H(d, e, u), L(e, t), L(t, i), L(e, o), h.m(e, null); }, - p(a, h) { - l === (l = s(a)) && c ? c.p(a, h) : (c.d(1), c = l(a), c && (c.c(), c.m(e, null))); + p(d, u) { + s === (s = l(d)) && h ? h.p(d, u) : (h.d(1), h = s(d), h && (h.c(), h.m(e, null))); }, - d(a) { - a && S(e), c.d(); + d(d) { + d && j(e), h.d(); } }; } -function Vn(n) { +function vn(n) { let e, t = ( /*_strings*/ - n[13].error + "" + n[11].error + "" ); return { c() { - e = M("div"), u( + e = F("div"), c( e, "title", /*error*/ n[5] ); }, - m(r, o) { - B(r, e, o), e.innerHTML = t; + m(i, o) { + H(i, e, o), e.innerHTML = t; }, - p(r, o) { + p(i, o) { o[0] & /*_strings*/ - 8192 && t !== (t = /*_strings*/ - r[13].error + "") && (e.innerHTML = t), o[0] & /*error*/ - 32 && u( + 2048 && t !== (t = /*_strings*/ + i[11].error + "") && (e.innerHTML = t), o[0] & /*error*/ + 32 && c( e, "title", /*error*/ - r[5] + i[5] ); }, - d(r) { - r && S(e); + d(i) { + i && j(e); } }; } -function jn(n) { +function Cn(n) { let e, t = ( /*_strings*/ - n[13].expired + "" + n[11].expired + "" ); return { c() { - e = M("div"), u( + e = F("div"), c( e, "title", /*error*/ n[5] ); }, - m(r, o) { - B(r, e, o), e.innerHTML = t; + m(i, o) { + H(i, e, o), e.innerHTML = t; }, - p(r, o) { + p(i, o) { o[0] & /*_strings*/ - 8192 && t !== (t = /*_strings*/ - r[13].expired + "") && (e.innerHTML = t), o[0] & /*error*/ - 32 && u( + 2048 && t !== (t = /*_strings*/ + i[11].expired + "") && (e.innerHTML = t), o[0] & /*error*/ + 32 && c( e, "title", /*error*/ - r[5] + i[5] ); }, - d(r) { - r && S(e); + d(i) { + i && j(e); } }; } -function vt(n) { - let e, t, r = ( +function ft(n) { + let e, t, i = ( /*_strings*/ - n[13].footer + "" + n[11].footer + "" ); return { c() { - e = M("div"), t = M("div"), u(e, "class", "altcha-footer"); + e = F("div"), t = F("div"), c(e, "class", "altcha-footer"); }, - m(o, s) { - B(o, e, s), I(e, t), t.innerHTML = r; + m(o, l) { + H(o, e, l), L(e, t), t.innerHTML = i; }, - p(o, s) { - s[0] & /*_strings*/ - 8192 && r !== (r = /*_strings*/ - o[13].footer + "") && (t.innerHTML = r); + p(o, l) { + l[0] & /*_strings*/ + 2048 && i !== (i = /*_strings*/ + o[11].footer + "") && (t.innerHTML = i); }, d(o) { - o && S(e); + o && j(e); } }; } -function kt(n) { +function ct(n) { let e; return { c() { - e = M("div"), u(e, "class", "altcha-anchor-arrow"); + e = F("div"), c(e, "class", "altcha-anchor-arrow"); }, - m(t, r) { - B(t, e, r), n[46](e); + m(t, i) { + H(t, e, i), n[48](e); }, - p: Me, + p: xe, d(t) { - t && S(e), n[46](null); + t && j(e), n[48](null); } }; } -function Un(n) { - let e, t, r, o, s, l, c, a, h, w, x, $, k, J, H, ee, te; - const R = ( +function xn(n) { + let e, t, i, o, l, s, h, d, u, A, b, Y, U, $, D, R, X; + const J = ( /*#slots*/ - n[44].default - ), O = nn( - R, + n[46].default + ), N = Bt( + J, n, /*$$scope*/ - n[43], + n[45], null ); - let N = ( + let T = ( /*state*/ - n[7] === y.VERIFYING && yt() + n[7] === m.VERIFYING && ot() ); - function oe(d, C) { + function Q(a, y) { return ( /*state*/ - d[7] === y.VERIFIED ? Nn : ( + a[7] === m.VERIFIED ? kn : ( /*state*/ - d[7] === y.VERIFYING ? Mn : Sn + a[7] === m.VERIFYING ? En : pn ) ); } - let ne = oe(n), Z = ne(n), L = ( + let G = Q(n), V = G(n), v = ( /*hidelogo*/ (n[3] !== !0 || /*isFreeSaaS*/ - n[14]) && _t(n) - ), F = ( + n[12]) && lt(n) + ), P = ( /*error*/ (n[5] || /*state*/ - n[7] === y.EXPIRED) && Et(n) - ), p = ( + n[7] === m.EXPIRED) && st(n) + ), S = ( /*_strings*/ - n[13].footer && /*hidefooter*/ + n[11].footer && /*hidefooter*/ (n[2] !== !0 || /*isFreeSaaS*/ - n[14]) && vt(n) - ), D = ( + n[12]) && ft(n) + ), E = ( /*floating*/ - n[1] && kt(n) + n[1] && ct(n) ); return { c() { - O && O.c(), e = Q(), t = M("div"), r = M("div"), N && N.c(), o = Q(), s = M("div"), l = M("input"), h = Q(), w = M("div"), Z.c(), x = Q(), L && L.c(), $ = Q(), F && F.c(), k = Q(), p && p.c(), J = Q(), D && D.c(), u(l, "type", "checkbox"), u(l, "id", c = /*name*/ - n[4] + "_checkbox"), l.required = a = /*auto*/ - n[0] !== "onsubmit", u(s, "class", "altcha-checkbox"), gt( - s, + N && N.c(), e = z(), t = F("div"), i = F("div"), T && T.c(), o = z(), l = F("div"), s = F("input"), u = z(), A = F("div"), V.c(), b = z(), v && v.c(), Y = z(), P && P.c(), U = z(), S && S.c(), $ = z(), E && E.c(), c(s, "type", "checkbox"), c(s, "id", h = /*name*/ + n[4] + "_checkbox"), s.required = d = /*auto*/ + n[0] !== "onsubmit" && (!/*floating*/ + n[1] || /*auto*/ + n[0] !== "off"), c(l, "class", "altcha-checkbox"), rt( + l, "altcha-hidden", /*state*/ - n[7] === y.VERIFYING - ), u(w, "class", "altcha-label"), u(r, "class", "altcha-main"), u(t, "class", "altcha"), u( + n[7] === m.VERIFYING + ), c(A, "class", "altcha-label"), c(i, "class", "altcha-main"), c(t, "class", "altcha"), c( t, "data-state", /*state*/ n[7] - ), u( + ), c( t, "data-floating", /*floating*/ n[1] ); }, - m(d, C) { - O && O.m(d, C), B(d, e, C), B(d, t, C), I(t, r), N && N.m(r, null), I(r, o), I(r, s), I(s, l), l.checked = /*checked*/ - n[8], I(r, h), I(r, w), Z.m(w, null), I(r, x), L && L.m(r, null), I(t, $), F && F.m(t, null), I(t, k), p && p.m(t, null), I(t, J), D && D.m(t, null), n[47](t), H = !0, ee || (te = [ - Pe( - l, + m(a, y) { + N && N.m(a, y), H(a, e, y), H(a, t, y), L(t, i), T && T.m(i, null), L(i, o), L(i, l), L(l, s), s.checked = /*checked*/ + n[8], L(i, u), L(i, A), V.m(A, null), L(i, b), v && v.m(i, null), L(t, Y), P && P.m(t, null), L(t, U), S && S.m(t, null), L(t, $), E && E.m(t, null), n[49](t), D = !0, R || (X = [ + Le( + s, "change", /*input_change_handler*/ - n[45] + n[47] ), - Pe( - l, + Le( + s, "change", /*onCheckedChange*/ - n[15] + n[13] ), - Pe( - l, + Le( + s, "invalid", /*onInvalid*/ - n[16] + n[14] ) - ], ee = !0); + ], R = !0); }, - p(d, C) { - O && O.p && (!H || C[1] & /*$$scope*/ - 4096) && on( - O, - R, - d, + p(a, y) { + N && N.p && (!D || y[1] & /*$$scope*/ + 16384) && Zt( + N, + J, + a, /*$$scope*/ - d[43], - H ? rn( - R, + a[45], + D ? qt( + J, /*$$scope*/ - d[43], - C, + a[45], + y, null - ) : sn( + ) : Gt( /*$$scope*/ - d[43] + a[45] ), null ), /*state*/ - d[7] === y.VERIFYING ? N || (N = yt(), N.c(), N.m(r, o)) : N && (N.d(1), N = null), (!H || C[0] & /*name*/ - 16 && c !== (c = /*name*/ - d[4] + "_checkbox")) && u(l, "id", c), (!H || C[0] & /*auto*/ - 1 && a !== (a = /*auto*/ - d[0] !== "onsubmit")) && (l.required = a), C[0] & /*checked*/ - 256 && (l.checked = /*checked*/ - d[8]), (!H || C[0] & /*state*/ - 128) && gt( - s, + a[7] === m.VERIFYING ? T || (T = ot(), T.c(), T.m(i, o)) : T && (T.d(1), T = null), (!D || y[0] & /*name*/ + 16 && h !== (h = /*name*/ + a[4] + "_checkbox")) && c(s, "id", h), (!D || y[0] & /*auto, floating*/ + 3 && d !== (d = /*auto*/ + a[0] !== "onsubmit" && (!/*floating*/ + a[1] || /*auto*/ + a[0] !== "off"))) && (s.required = d), y[0] & /*checked*/ + 256 && (s.checked = /*checked*/ + a[8]), (!D || y[0] & /*state*/ + 128) && rt( + l, "altcha-hidden", /*state*/ - d[7] === y.VERIFYING - ), ne === (ne = oe(d)) && Z ? Z.p(d, C) : (Z.d(1), Z = ne(d), Z && (Z.c(), Z.m(w, null))), /*hidelogo*/ - d[3] !== !0 || /*isFreeSaaS*/ - d[14] ? L ? L.p(d, C) : (L = _t(d), L.c(), L.m(r, null)) : L && (L.d(1), L = null), /*error*/ - d[5] || /*state*/ - d[7] === y.EXPIRED ? F ? F.p(d, C) : (F = Et(d), F.c(), F.m(t, k)) : F && (F.d(1), F = null), /*_strings*/ - d[13].footer && /*hidefooter*/ - (d[2] !== !0 || /*isFreeSaaS*/ - d[14]) ? p ? p.p(d, C) : (p = vt(d), p.c(), p.m(t, J)) : p && (p.d(1), p = null), /*floating*/ - d[1] ? D ? D.p(d, C) : (D = kt(d), D.c(), D.m(t, null)) : D && (D.d(1), D = null), (!H || C[0] & /*state*/ - 128) && u( + a[7] === m.VERIFYING + ), G === (G = Q(a)) && V ? V.p(a, y) : (V.d(1), V = G(a), V && (V.c(), V.m(A, null))), /*hidelogo*/ + a[3] !== !0 || /*isFreeSaaS*/ + a[12] ? v ? v.p(a, y) : (v = lt(a), v.c(), v.m(i, null)) : v && (v.d(1), v = null), /*error*/ + a[5] || /*state*/ + a[7] === m.EXPIRED ? P ? P.p(a, y) : (P = st(a), P.c(), P.m(t, U)) : P && (P.d(1), P = null), /*_strings*/ + a[11].footer && /*hidefooter*/ + (a[2] !== !0 || /*isFreeSaaS*/ + a[12]) ? S ? S.p(a, y) : (S = ft(a), S.c(), S.m(t, $)) : S && (S.d(1), S = null), /*floating*/ + a[1] ? E ? E.p(a, y) : (E = ct(a), E.c(), E.m(t, null)) : E && (E.d(1), E = null), (!D || y[0] & /*state*/ + 128) && c( t, "data-state", /*state*/ - d[7] - ), (!H || C[0] & /*floating*/ - 2) && u( + a[7] + ), (!D || y[0] & /*floating*/ + 2) && c( t, "data-floating", /*floating*/ - d[1] + a[1] ); }, - i(d) { - H || (Ft(O, d), H = !0); + i(a) { + D || (yt(N, a), D = !0); }, - o(d) { - wn(O, d), H = !1; + o(a) { + on(N, a), D = !1; }, - d(d) { - d && (S(e), S(t)), O && O.d(d), N && N.d(), Z.d(), L && L.d(), F && F.d(), p && p.d(), D && D.d(), n[47](null), ee = !1, Ie(te); + d(a) { + a && (j(e), j(t)), N && N.d(a), T && T.d(), V.d(), v && v.d(), P && P.d(), S && S.d(), E && E.d(), n[49](null), R = !1, pe(X); } }; } -const pt = "Visit Altcha.org", Vt = "https://altcha.org/"; -function Ct(n) { +const ut = "Visit Altcha.org", Et = "https://altcha.org/"; +function at(n) { return JSON.parse(n); } -function Pn(n, e, t) { - var ct, at; - let r, o, s, l, { $$slots: c = {}, $$scope: a } = e, { analytics: h = !1 } = e, { auto: w = void 0 } = e, { beaconurl: x = void 0 } = e, { blockspam: $ = void 0 } = e, { challengeurl: k = void 0 } = e, { challengejson: J = void 0 } = e, { debug: H = !1 } = e, { delay: ee = 0 } = e, { expire: te = void 0 } = e, { floating: R = void 0 } = e, { floatinganchor: O = void 0 } = e, { floatingoffset: N = void 0 } = e, { hidefooter: oe = !1 } = e, { hidelogo: ne = !1 } = e, { name: Z = "altcha" } = e, { maxnumber: L = 1e6 } = e, { mockerror: F = !1 } = e, { obfuscated: p = void 0 } = e, { refetchonexpire: D = !0 } = e, { spamfilter: d = !1 } = e, { strings: C = void 0 } = e, { test: X = !1 } = e, { verifyurl: se = void 0 } = e, { workers: be = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: Te = void 0 } = e; - const Ve = dn(), Ze = ["SHA-256", "SHA-384", "SHA-512"], Ge = (at = (ct = document.documentElement.lang) == null ? void 0 : ct.split("-")) == null ? void 0 : at[0]; - let W = !1, z = null, v, le = null, Re = null, b = null, ie = null, ye = null, K = null, ce = null, q = null, Ye = null, T = y.UNVERIFIED; - hn(() => { - b && (b.removeEventListener("submit", We), b.removeEventListener("reset", ze), b.removeEventListener("focusin", Xe), b = null), ie && v.removeEventListener("click", Je), q && q.destroy(), K && (clearTimeout(K), K = null), document.removeEventListener("click", nt), document.removeEventListener("scroll", it), window.removeEventListener("resize", ot); - }), un(() => { - var i, f; - A("mounted", "0.8.0"), A("workers", be), X && A("using test mode"), te && Fe(te), w !== void 0 && A("auto", w), R !== void 0 && st(R), b = v.closest("form"), b && (b.addEventListener("submit", We, { capture: !0 }), b.addEventListener("reset", ze), w === "onfocus" && b.addEventListener("focusin", Xe)), ie = ((i = v.parentElement) == null ? void 0 : i.querySelector("[data-clarify-button]")) || ((f = v.parentElement) == null ? void 0 : f.querySelector("button, a")), ie && ie.addEventListener("click", Je), h && $e(), w === "onload" && (p ? _e() : ae()), r && (oe || ne) && A("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution."); +function An(n, e, t) { + var Qe, et; + let i, o, l, s, { $$slots: h = {}, $$scope: d } = e, { auto: u = void 0 } = e, { blockspam: A = void 0 } = e, { challengeurl: b = void 0 } = e, { challengejson: Y = void 0 } = e, { debug: U = !1 } = e, { delay: $ = 0 } = e, { expire: D = void 0 } = e, { floating: R = void 0 } = e, { floatinganchor: X = void 0 } = e, { floatingoffset: J = void 0 } = e, { hidefooter: N = !1 } = e, { hidelogo: T = !1 } = e, { name: Q = "altcha" } = e, { maxnumber: G = 1e6 } = e, { mockerror: V = !1 } = e, { obfuscated: v = void 0 } = e, { plugins: P = void 0 } = e, { refetchonexpire: S = !0 } = e, { spamfilter: E = !1 } = e, { strings: a = void 0 } = e, { test: y = !1 } = e, { verifyurl: ee = void 0 } = e, { workers: le = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: ae = void 0 } = e; + const he = Qt(), Pe = ["SHA-256", "SHA-384", "SHA-512"], Me = (et = (Qe = document.documentElement.lang) == null ? void 0 : Qe.split("-")) == null ? void 0 : et[0]; + let re = !1, C, ie = null, se = null, _ = null, de = null, W = null, oe = null, te = [], x = m.UNVERIFIED; + Kt(() => { + kt(), _ && (_.removeEventListener("submit", Oe), _.removeEventListener("reset", Ue), _.removeEventListener("focusin", He), _ = null), W && (clearTimeout(W), W = null), document.removeEventListener("click", Ve), document.removeEventListener("scroll", je), window.removeEventListener("resize", Be); + }), zt(() => { + k("mounted", "0.9.0"), k("workers", le), It(), k("plugins", te.length ? te.map((r) => r.constructor.pluginName).join(", ") : "none"), y && k("using test mode"), D && ke(D), u !== void 0 && k("auto", u), R !== void 0 && qe(R), _ = C.closest("form"), _ && (_.addEventListener("submit", Oe, { capture: !0 }), _.addEventListener("reset", Ue), u === "onfocus" && _.addEventListener("focusin", He)), u === "onload" && (v ? ge() : ne()), i && (N || T) && k("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."), requestAnimationFrame(() => { + he("load"); + }); }); - function A(...i) { - (H || i.some((f) => f instanceof Error)) && console[i[0] instanceof Error ? "error" : "log"]("ALTCHA", ...i); - } - function Je(i) { - i.preventDefault(), T === y.UNVERIFIED && _e(); - } - function Xe(i) { - T === y.UNVERIFIED && ae(); - } - function We(i) { - b && q && T === y.VERIFIED && (q.end(), t(12, Ye = q.dataAsBase64())), b && w === "onsubmit" && (T === y.UNVERIFIED ? (i.preventDefault(), i.stopPropagation(), ae().then(() => { - b == null || b.requestSubmit(); - })) : T !== y.VERIFIED && (i.preventDefault(), i.stopPropagation(), T === y.VERIFYING && rt())); - } - function ze() { - we(); - } - function Ke(i, f) { + function Fe(r, f) { return btoa(JSON.stringify({ - algorithm: i.algorithm, - challenge: i.challenge, + algorithm: r.algorithm, + challenge: r.challenge, number: f.number, - salt: i.salt, - signature: i.signature, - test: X ? !0 : void 0, + salt: r.salt, + signature: r.signature, + test: y ? !0 : void 0, took: f.took })); } - function Qe(i) { - if (!i.algorithm) - throw new Error("Invalid challenge. Property algorithm is missing."); - if (i.signature === void 0) - throw new Error("Invalid challenge. Property signature is missing."); - if (!Ze.includes(i.algorithm.toUpperCase())) - throw new Error(`Unknown algorithm value. Allowed values: ${Ze.join(", ")}`); - if (!i.challenge || i.challenge.length < 40) - throw new Error("Challenge is too short. Min. 40 chars."); - if (!i.salt || i.salt.length < 10) - throw new Error("Salt is too short. Min. 10 chars."); + function kt() { + for (const r of te) + r.destroy(); + } + function Ne() { + b && S && x === m.VERIFIED ? ne() : me(m.EXPIRED, s.expired); } - async function jt() { - var i; - if (F) - throw A("mocking error"), new Error("Mocked error."); + async function vt() { + var r; + if (V) + throw k("mocking error"), new Error("Mocked error."); if (o) - return A("using provided json data"), o; - if (X) - return A("generating test challenge", { test: X }), Ln(typeof X != "boolean" ? +X : void 0); + return k("using provided json data"), o; + if (y) + return k("generating test challenge", { test: y }), gn(typeof y != "boolean" ? +y : void 0); { - if (!k && b) { - const _ = b.getAttribute("action"); - _ != null && _.includes("/form/") && t(17, k = _ + "/altcha"); + if (!b && _) { + const w = _.getAttribute("action"); + w != null && w.includes("/form/") && t(15, b = w + "/altcha"); } - if (!k) + if (!b) throw new Error("Attribute challengeurl not set."); - A("fetching challenge from", k); - const f = await fetch(k, { - headers: d ? { "x-altcha-spam-filter": "1" } : {} + k("fetching challenge from", b); + const f = await fetch(b, { + headers: E ? { "x-altcha-spam-filter": "1" } : {} }); if (f.status !== 200) throw new Error(`Server responded with ${f.status}.`); - const m = f.headers.get("Expires"), g = f.headers.get("X-Altcha-Config"), V = await f.json(), j = new URLSearchParams((i = V.salt.split("?")) == null ? void 0 : i[1]), U = j.get("expires") || j.get("expire"); - if (U) { - const _ = new Date(+U * 1e3), Y = isNaN(_.getTime()) ? 0 : _.getTime() - Date.now(); - Y > 0 && Fe(Y); + const g = f.headers.get("Expires"), I = f.headers.get("X-Altcha-Config"), B = await f.json(), O = new URLSearchParams((r = B.salt.split("?")) == null ? void 0 : r[1]), M = O.get("expires") || O.get("expire"); + if (M) { + const w = new Date(+M * 1e3), q = isNaN(w.getTime()) ? 0 : w.getTime() - Date.now(); + q > 0 && ke(q); } - if (g) + if (I) try { - const _ = JSON.parse(g); - _ && typeof _ == "object" && (_.verifyurl && (_.verifyurl = new URL(_.verifyurl, new URL(k)).toString()), lt(_)); - } catch (_) { - A("unable to configure from X-Altcha-Config", _); + const w = JSON.parse(I); + w && typeof w == "object" && (w.verifyurl && (w.verifyurl = new URL(w.verifyurl, new URL(b)).toString()), Ye(w)); + } catch (w) { + k("unable to configure from X-Altcha-Config", w); } - if (!te && (m != null && m.length)) { - const _ = Date.parse(m); - if (_) { - const Y = _ - Date.now(); - Y > 0 && Fe(Y); + if (!D && (g != null && g.length)) { + const w = Date.parse(g); + if (w) { + const q = w - Date.now(); + q > 0 && ke(q); } } - return V; + return B; } } - function $e() { - if (!q) - if (b) { - if (A("analytics enabled"), t(11, q = new Dn(b)), x === void 0) { - const i = b.getAttribute("action"); - i && t(19, x = i + "/beacon"); - } - t(11, q.beaconUrl = x || null, q); - } else - A("analytics cannot be enabled - form element not found"); - } - function et() { - k && D && T === y.VERIFIED ? ae() : we(y.EXPIRED, l.expired); - } - async function tt(i) { - let f = null; - if ("Worker" in window) { - try { - f = await Ut(i, i.maxnumber); - } catch (m) { - A(m); - } - if ((f == null ? void 0 : f.number) !== void 0 || "obfuscated" in i) - return { data: i, solution: f }; - } - if ("obfuscated" in i) { - const m = await Fn(i.obfuscated, i.key, i.maxnumber); - return { data: i, solution: await m.promise }; - } - return { - data: i, - solution: await In(i.challenge, i.salt, i.algorithm, i.maxnumber || L).promise - }; - } - async function Ut(i, f = typeof X == "number" ? X : L, m = Math.ceil(be)) { - const g = []; - m = Math.min(16, Math.max(1, m)); - for (let U = 0; U < m; U++) - g.push(createAltchaWorker(Te)); - const V = Math.ceil(f / m), j = await Promise.all(g.map((U, _) => { - const Y = _ * V; - return new Promise((Ue) => { - U.addEventListener("message", (Ee) => { - if (Ee.data) - for (const ve of g) - ve !== U && ve.postMessage({ type: "abort" }); - Ue(Ee.data); - }), U.postMessage({ - payload: i, - max: Y + V, - start: Y, - type: "work" - }); - }); - })); - for (const U of g) - U.terminate(); - return j.find((U) => !!U) || null; - } - function Pt() { - [y.UNVERIFIED, y.ERROR, y.EXPIRED].includes(T) ? d && (b == null ? void 0 : b.reportValidity()) === !1 ? t(8, W = !1) : p ? _e() : ae() : t(8, W = !0); - } - function nt(i) { - const f = i.target; - R && f && !v.contains(f) && T === y.VERIFIED && t(9, v.style.display = "none", v); - } - function it() { - R && je(); - } - function rt() { - T === y.VERIFYING && l.waitAlert && alert(l.waitAlert); - } - function Bt(i) { - var f; - if (z) { - const m = z.match(/^(mailto|tel|sms|https?):/); - let g; - if (m) { - const [V] = z.slice(z.indexOf(":") + 1).replace(/^\/\//, "").split("?"); - g = document.createElement("a"), g.href = z, g.innerHTML = V; - } else - g = document.createTextNode(z); - ie && g && (ie.after(g), (f = ie.parentElement) == null || f.removeChild(ie)); - } - } - function Ot(i) { - q && q.trackError(ye); - } - function Ht(i) { - R && T !== y.UNVERIFIED && requestAnimationFrame(() => { - je(); - }); - } - function ot() { - R && je(); - } - function Fe(i) { - A("expire", i), K && (clearTimeout(K), K = null), i < 1 ? et() : K = setTimeout(et, i); + function Ct(r) { + var g; + const f = _ == null ? void 0 : _.querySelector(typeof r == "string" ? `input[name="${r}"]` : 'input[type="email"]:not([data-no-spamfilter])'); + return ((g = f == null ? void 0 : f.value) == null ? void 0 : g.slice(f.value.indexOf("@"))) || void 0; } - function st(i) { - A("floating", i), R !== i && (t(9, v.style.left = "", v), t(9, v.style.top = "", v)), t(1, R = i === !0 || i === "" ? "auto" : i === !1 || i === "false" ? void 0 : R), R ? (w || t(0, w = "onsubmit"), document.addEventListener("scroll", it), document.addEventListener("click", nt), window.addEventListener("resize", ot)) : w === "onsubmit" && t(0, w = void 0); - } - function qt(i) { - var m; - const f = b == null ? void 0 : b.querySelector(typeof i == "string" ? `input[name="${i}"]` : 'input[type="email"]:not([data-no-spamfilter])'); - return ((m = f == null ? void 0 : f.value) == null ? void 0 : m.slice(f.value.indexOf("@"))) || void 0; - } - function Zt(i) { - return [ - ...(b == null ? void 0 : b.querySelectorAll(i != null && i.length ? i.map((m) => `input[name="${m}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] - ].reduce( - (m, g) => { - const V = g.name, j = g.value; - return V && j && (m[V] = /\n/.test(j) ? j.replace(new RegExp("(? V : R === "top", _ = Math.max(i, Math.min(j - i - g.width, m.left + m.width / 2 - g.width / 2)); - if (U ? t(9, v.style.top = `${m.top - (g.height + f)}px`, v) : t(9, v.style.top = `${m.bottom + f}px`, v), t(9, v.style.left = `${_}px`, v), v.setAttribute("data-floating", U ? "top" : "bottom"), le) { - const Y = le.getBoundingClientRect(); - t(10, le.style.left = m.left - _ + m.width / 2 - Y.width / 2 + "px", le); + function At(r) { + return [ + ...(_ == null ? void 0 : _.querySelectorAll(r != null && r.length ? r.map((g) => `input[name="${g}"]`).join(", ") : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || [] + ].reduce( + (g, I) => { + const B = I.name, O = I.value; + return B && O && (g[B] = /\n/.test(O) ? O.replace(new RegExp("(? f instanceof Error)) && console[r[0] instanceof Error ? "error" : "log"]("ALTCHA", `[name=${Q}]`, ...r); + } + function Lt() { + [m.UNVERIFIED, m.ERROR, m.EXPIRED].includes(x) ? E && (_ == null ? void 0 : _.reportValidity()) === !1 ? t(8, re = !1) : v ? ge() : ne() : t(8, re = !0); + } + function Ve(r) { + const f = r.target; + R && f && !C.contains(f) && (x === m.VERIFIED || u === "off" && x === m.UNVERIFIED) && t(9, C.style.display = "none", C); + } + function je() { + R && x !== m.UNVERIFIED && Ee(); + } + function Rt(r) { + for (const f of te) + typeof f.onErrorChange == "function" && f.onErrorChange(de); + } + function He(r) { + x === m.UNVERIFIED && ne(); + } + function Oe(r) { + _ && u === "onsubmit" ? x === m.UNVERIFIED ? (r.preventDefault(), r.stopPropagation(), ne().then(() => { + _ == null || _.requestSubmit(); + })) : x !== m.VERIFIED && (r.preventDefault(), r.stopPropagation(), x === m.VERIFYING && $e()) : _ && R && u === "off" && x === m.UNVERIFIED && (r.preventDefault(), r.stopPropagation(), t(9, C.style.display = "block", C), Ee()); + } + function Ue() { + me(); + } + function $e() { + x === m.VERIFYING && s.waitAlert && alert(s.waitAlert); + } + function St(r) { + for (const f of te) + typeof f.onStateChange == "function" && f.onStateChange(x); + R && x !== m.UNVERIFIED && requestAnimationFrame(() => { + Ee(); + }), t(8, re = x === m.VERIFIED); + } + function Be() { + R && Ee(); + } + function Ee(r = 20) { + if (C) + if (se || (se = (X ? document.querySelector(X) : _ == null ? void 0 : _.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])')) || _), se) { + const f = parseInt(J, 10) || 12, g = se.getBoundingClientRect(), I = C.getBoundingClientRect(), B = document.documentElement.clientHeight, O = document.documentElement.clientWidth, M = R === "auto" ? g.bottom + I.height + f + r > B : R === "top", w = Math.max(r, Math.min(O - r - I.width, g.left + g.width / 2 - I.width / 2)); + if (M ? t(9, C.style.top = `${g.top - (I.height + f)}px`, C) : t(9, C.style.top = `${g.bottom + f}px`, C), t(9, C.style.left = `${w}px`, C), C.setAttribute("data-floating", M ? "top" : "bottom"), ie) { + const q = ie.getBoundingClientRect(); + t(10, ie.style.left = g.left - w + g.width / 2 - q.width / 2 + "px", ie); } } else - A("unable to find floating anchor element"); + k("unable to find floating anchor element"); + } + async function Dt(r) { + if (!ee) + throw new Error("Attribute verifyurl not set."); + k("requesting server verification from", ee); + const f = { payload: r }; + if (E) { + const { blockedCountries: B, classifier: O, disableRules: M, email: w, expectedLanguages: q, expectedCountries: Ie, fields: be, ipAddress: ye, text: Vt, timeZone: tt } = xt(); + f.blockedCountries = B, f.classifier = O, f.disableRules = M, f.email = w === !1 ? void 0 : Ct(w), f.expectedCountries = Ie, f.expectedLanguages = q || (Me ? [Me] : void 0), f.fields = be === !1 ? void 0 : At(be), f.ipAddress = ye === !1 ? void 0 : ye || "auto", f.text = Vt, f.timeZone = tt === !1 ? void 0 : tt || bn(); + } + const g = await fetch(ee, { + body: JSON.stringify(f), + headers: { "content-type": "application/json" }, + method: "POST" + }); + if (g.status !== 200) + throw new Error(`Server responded with ${g.status}.`); + const I = await g.json(); + if (I != null && I.payload && t(6, oe = I.payload), he("serververification", I), A && I.classification === "BAD") + throw new Error("SpamFilter returned negative classification."); } - function lt(i) { - i.analytics && (t(18, h = i.analytics), $e()), i.obfuscated !== void 0 && t(27, p = i.obfuscated), i.auto !== void 0 && (t(0, w = i.auto), w === "onload" && (p ? _e() : ae())), i.beaconurl && (t(19, x = i.beaconurl), q && t(11, q.beaconUrl = x, q)), i.floatinganchor !== void 0 && t(23, O = i.floatinganchor), i.delay !== void 0 && t(21, ee = i.delay), i.floatingoffset !== void 0 && t(24, N = i.floatingoffset), i.floating !== void 0 && st(i.floating), i.expire !== void 0 && (Fe(i.expire), t(22, te = i.expire)), i.challenge && (Qe(i.challenge), o = i.challenge), i.challengeurl !== void 0 && t(17, k = i.challengeurl), i.debug !== void 0 && t(20, H = !!i.debug), i.hidefooter !== void 0 && t(2, oe = !!i.hidefooter), i.hidelogo !== void 0 && t(3, ne = !!i.hidelogo), i.maxnumber !== void 0 && t(25, L = +i.maxnumber), i.mockerror !== void 0 && t(26, F = !!i.mockerror), i.name !== void 0 && t(4, Z = i.name), i.refetchonexpire !== void 0 && t(28, D = !!i.refetchonexpire), i.spamfilter !== void 0 && t(29, d = typeof i.spamfilter == "object" ? i.spamfilter : !!i.spamfilter), i.strings && t(42, s = i.strings), i.test !== void 0 && t(30, X = typeof i.test == "number" ? i.test : !!i.test), i.verifyurl !== void 0 && t(31, se = i.verifyurl), i.workers !== void 0 && t(32, be = +i.workers), i.workerurl !== void 0 && t(33, Te = i.workerurl); + function ke(r) { + k("expire", r), W && (clearTimeout(W), W = null), r < 1 ? Ne() : W = setTimeout(Ne, r); } - function we(i = y.UNVERIFIED, f = null) { - K && (clearTimeout(K), K = null), t(8, W = !1), t(5, ye = f), t(6, ce = null), t(7, T = i); + function qe(r) { + k("floating", r), R !== r && (t(9, C.style.left = "", C), t(9, C.style.top = "", C)), t(1, R = r === !0 || r === "" ? "auto" : r === !1 || r === "false" ? void 0 : R), R ? (u || t(0, u = "onsubmit"), document.addEventListener("scroll", je), document.addEventListener("click", Ve), window.addEventListener("resize", Be)) : u === "onsubmit" && t(0, u = void 0); } - async function ae() { - return we(y.VERIFYING), await new Promise((i) => setTimeout(i, ee || 0)), jt().then((i) => (Qe(i), A("challenge", i), tt(i))).then(({ data: i, solution: f }) => { - if (A("solution", f), "challenge" in i && f && !("clearText" in f)) - if ((f == null ? void 0 : f.number) !== void 0) { - if (se) - return Gt(Ke(i, f)); - t(6, ce = Ke(i, f)), A("payload", ce); - } else - throw A("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); - }).then(() => { - mn().then(() => { - t(7, T = y.VERIFIED), t(8, W = !0), A("verified"), Ve("verified", { payload: ce }); + function Ze(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 (!Pe.includes(r.algorithm.toUpperCase())) + throw new Error(`Unknown algorithm value. Allowed values: ${Pe.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 Ge(r) { + let f = null; + if ("Worker" in window) { + try { + f = await Tt(r, r.maxnumber); + } catch (g) { + k(g); + } + if ((f == null ? void 0 : f.number) !== void 0 || "obfuscated" in r) + return { data: r, solution: f }; + } + if ("obfuscated" in r) { + const g = await wn(r.obfuscated, r.key, r.maxnumber); + return { data: r, solution: await g.promise }; + } + return { + data: r, + solution: await mn(r.challenge, r.salt, r.algorithm, r.maxnumber || G).promise + }; + } + async function Tt(r, f = typeof y == "number" ? y : G, g = Math.ceil(le)) { + const I = []; + g = Math.min(16, Math.max(1, g)); + for (let M = 0; M < g; M++) + I.push(altchaCreateWorker(ae)); + const B = Math.ceil(f / g), O = await Promise.all(I.map((M, w) => { + const q = w * B; + return new Promise((Ie) => { + M.addEventListener("message", (be) => { + if (be.data) + for (const ye of I) + ye !== M && ye.postMessage({ type: "abort" }); + Ie(be.data); + }), M.postMessage({ + payload: r, + max: q + B, + start: q, + type: "work" + }); }); - }).catch((i) => { - A(i), t(7, T = y.ERROR), t(8, W = !1), t(5, ye = i.message); - }); + })); + for (const M of I) + M.terminate(); + return O.find((M) => !!M) || null; } - async function _e() { - if (!p) { - t(7, T = y.ERROR); + async function ge() { + if (!v) { + t(7, x = m.ERROR); return; } - we(y.VERIFYING), await new Promise((j) => setTimeout(j, ee || 0)); - const [i, f] = p.split("?"); - let g = new URLSearchParams(f || "").get("key") || void 0; - if (g) { - const j = g.match(/^\(prompt:?(.*)\)$/); - j && (g = prompt(j[1] || "Enter Key:") || void 0); + const r = te.find((f) => f.constructor.pluginName === "obfuscation"); + if (!r || !("clarify" in r)) { + t(7, x = m.ERROR), k("Plugin `obfuscation` not found. Import `altcha/plugins/obfuscation` to load it."); + return; } - const { solution: V } = await tt({ obfuscated: i, key: g, maxnumber: L }); - V && "clearText" in V ? (t(41, z = V.clearText), t(7, T = y.VERIFIED), t(8, W = !0), R && v && t(9, v.style.display = "none", v)) : (t(7, T = y.ERROR), t(8, W = !1), t(5, ye = "Unable to decrypt data.")); + if ("clarify" in r && typeof r.clarify == "function") + return r.clarify(); + } + function Ye(r) { + r.obfuscated !== void 0 && t(24, v = r.obfuscated), r.auto !== void 0 && (t(0, u = r.auto), u === "onload" && (v ? ge() : ne())), r.blockspam !== void 0 && t(16, A = !!r.blockspam), r.floatinganchor !== void 0 && t(20, X = r.floatinganchor), r.delay !== void 0 && t(18, $ = r.delay), r.floatingoffset !== void 0 && t(21, J = r.floatingoffset), r.floating !== void 0 && qe(r.floating), r.expire !== void 0 && (ke(r.expire), t(19, D = r.expire)), r.challenge && (Ze(r.challenge), o = r.challenge), r.challengeurl !== void 0 && t(15, b = r.challengeurl), r.debug !== void 0 && t(17, U = !!r.debug), r.hidefooter !== void 0 && t(2, N = !!r.hidefooter), r.hidelogo !== void 0 && t(3, T = !!r.hidelogo), r.maxnumber !== void 0 && t(22, G = +r.maxnumber), r.mockerror !== void 0 && t(23, V = !!r.mockerror), r.name !== void 0 && t(4, Q = r.name), r.refetchonexpire !== void 0 && t(25, S = !!r.refetchonexpire), r.spamfilter !== void 0 && t(26, E = typeof r.spamfilter == "object" ? r.spamfilter : !!r.spamfilter), r.strings && t(44, l = r.strings), r.test !== void 0 && t(27, y = typeof r.test == "number" ? r.test : !!r.test), r.verifyurl !== void 0 && t(28, ee = r.verifyurl), r.workers !== void 0 && t(29, le = +r.workers), r.workerurl !== void 0 && t(30, ae = r.workerurl); + } + function We() { + return { + auto: u, + blockspam: A, + challengeurl: b, + debug: U, + delay: $, + expire: D, + floating: R, + floatinganchor: X, + floatingoffset: J, + hidefooter: N, + hidelogo: T, + name: Q, + maxnumber: G, + mockerror: V, + obfuscated: v, + refetchonexpire: S, + spamfilter: E, + strings: s, + test: y, + verifyurl: ee, + workers: le, + workerurl: ae + }; + } + function Xe() { + return se; + } + function Pt(r) { + return te.find((f) => f.constructor.pluginName === r); + } + function Je() { + return x; + } + function me(r = m.UNVERIFIED, f = null) { + W && (clearTimeout(W), W = null), t(8, re = !1), t(5, de = f), t(6, oe = null), t(7, x = r); + } + function ze(r) { + se = r; } - function Jt() { - W = this.checked, t(8, W); + function Ke(r, f = null) { + t(7, x = r), t(5, de = f); } - function Xt(i) { - Ne[i ? "unshift" : "push"](() => { - le = i, t(10, le); + async function ne() { + return me(m.VERIFYING), await new Promise((r) => setTimeout(r, $ || 0)), vt().then((r) => (Ze(r), k("challenge", r), Ge(r))).then(({ data: r, solution: f }) => { + if (k("solution", f), "challenge" in r && f && !("clearText" in f)) + if ((f == null ? void 0 : f.number) !== void 0) { + if (ee) + return Dt(Fe(r, f)); + t(6, oe = Fe(r, f)), k("payload", oe); + } else + throw k("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned."); + }).then(() => { + en().then(() => { + t(7, x = m.VERIFIED), k("verified"), he("verified", { payload: oe }); + }); + }).catch((r) => { + k(r), t(7, x = m.ERROR), t(5, de = r.message); }); } - function Wt(i) { - Ne[i ? "unshift" : "push"](() => { - v = i, t(9, v); + function Mt() { + re = this.checked, t(8, re); + } + function Ft(r) { + Ae[r ? "unshift" : "push"](() => { + ie = r, t(10, ie); + }); + } + function Nt(r) { + Ae[r ? "unshift" : "push"](() => { + C = r, t(9, C); }); } - return n.$$set = (i) => { - "analytics" in i && t(18, h = i.analytics), "auto" in i && t(0, w = i.auto), "beaconurl" in i && t(19, x = i.beaconurl), "blockspam" in i && t(34, $ = i.blockspam), "challengeurl" in i && t(17, k = i.challengeurl), "challengejson" in i && t(35, J = i.challengejson), "debug" in i && t(20, H = i.debug), "delay" in i && t(21, ee = i.delay), "expire" in i && t(22, te = i.expire), "floating" in i && t(1, R = i.floating), "floatinganchor" in i && t(23, O = i.floatinganchor), "floatingoffset" in i && t(24, N = i.floatingoffset), "hidefooter" in i && t(2, oe = i.hidefooter), "hidelogo" in i && t(3, ne = i.hidelogo), "name" in i && t(4, Z = i.name), "maxnumber" in i && t(25, L = i.maxnumber), "mockerror" in i && t(26, F = i.mockerror), "obfuscated" in i && t(27, p = i.obfuscated), "refetchonexpire" in i && t(28, D = i.refetchonexpire), "spamfilter" in i && t(29, d = i.spamfilter), "strings" in i && t(36, C = i.strings), "test" in i && t(30, X = i.test), "verifyurl" in i && t(31, se = i.verifyurl), "workers" in i && t(32, be = i.workers), "workerurl" in i && t(33, Te = i.workerurl), "$$scope" in i && t(43, a = i.$$scope); + return n.$$set = (r) => { + "auto" in r && t(0, u = r.auto), "blockspam" in r && t(16, A = r.blockspam), "challengeurl" in r && t(15, b = r.challengeurl), "challengejson" in r && t(31, Y = r.challengejson), "debug" in r && t(17, U = r.debug), "delay" in r && t(18, $ = r.delay), "expire" in r && t(19, D = r.expire), "floating" in r && t(1, R = r.floating), "floatinganchor" in r && t(20, X = r.floatinganchor), "floatingoffset" in r && t(21, J = r.floatingoffset), "hidefooter" in r && t(2, N = r.hidefooter), "hidelogo" in r && t(3, T = r.hidelogo), "name" in r && t(4, Q = r.name), "maxnumber" in r && t(22, G = r.maxnumber), "mockerror" in r && t(23, V = r.mockerror), "obfuscated" in r && t(24, v = r.obfuscated), "plugins" in r && t(32, P = r.plugins), "refetchonexpire" in r && t(25, S = r.refetchonexpire), "spamfilter" in r && t(26, E = r.spamfilter), "strings" in r && t(33, a = r.strings), "test" in r && t(27, y = r.test), "verifyurl" in r && t(28, ee = r.verifyurl), "workers" in r && t(29, le = r.workers), "workerurl" in r && t(30, ae = r.workerurl), "$$scope" in r && t(45, d = r.$$scope); }, n.$$.update = () => { n.$$.dirty[0] & /*challengeurl*/ - 131072 && t(14, r = !!(k != null && k.includes(".altcha.org")) && !!(k != null && k.includes("apiKey=ckey_"))), n.$$.dirty[1] & /*challengejson*/ - 16 && (o = J ? Ct(J) : void 0), n.$$.dirty[1] & /*strings*/ - 32 && t(42, s = C ? Ct(C) : {}), n.$$.dirty[1] & /*parsedStrings*/ - 2048 && t(13, l = { - ariaLinkLabel: pt, + 32768 && t(12, i = !!(b != null && b.includes(".altcha.org")) && !!(b != null && b.includes("apiKey=ckey_"))), n.$$.dirty[1] & /*challengejson*/ + 1 && (o = Y ? at(Y) : void 0), n.$$.dirty[1] & /*strings*/ + 4 && t(44, l = a ? at(a) : {}), n.$$.dirty[1] & /*parsedStrings*/ + 8192 && t(11, s = { + ariaLinkLabel: ut, error: "Verification failed. Try again later.", expired: "Verification expired. Try again.", - footer: `Protected by ALTCHA`, + footer: `Protected by ALTCHA`, label: "I'm not a robot", verified: "Verified", verifying: "Verifying...", waitAlert: "Verifying... please wait.", - ...s - }), n.$$.dirty[0] & /*state, payload*/ - 192 | n.$$.dirty[1] & /*clarifiedData*/ - 1024 && Ve("statechange", z ? { clarifiedData: z, state: T } : { payload: ce, state: T }), n.$$.dirty[0] & /*error*/ - 32 && Ot(), n.$$.dirty[0] & /*state*/ - 128 && Ht(), n.$$.dirty[1] & /*clarifiedData*/ - 1024 && Bt(); + ...l + }), n.$$.dirty[0] & /*payload, state*/ + 192 && he("statechange", { payload: oe, state: x }), n.$$.dirty[0] & /*error*/ + 32 && Rt(), n.$$.dirty[0] & /*state*/ + 128 && St(); }, [ - w, + u, R, - oe, - ne, - Z, - ye, - ce, + N, T, - W, - v, - le, - q, - Ye, - l, - r, - Pt, - rt, - k, - h, + Q, + de, + oe, x, - H, - ee, - te, - O, - N, - L, - F, - p, + re, + C, + ie, + s, + i, + Lt, + $e, + b, + A, + U, + $, D, - d, X, - se, - be, - Te, - $, J, - C, - lt, - we, + G, + V, + v, + S, + E, + y, + ee, + le, ae, - _e, - z, - s, + Y, + P, a, - c, - Jt, - Xt, - Wt + ge, + Ye, + We, + Xe, + Pt, + Je, + me, + ze, + Ke, + ne, + l, + d, + h, + Mt, + Ft, + Nt ]; } -class Bn extends Cn { +class In extends an { constructor(e) { - super(), kn( + super(), cn( this, e, - Pn, - Un, - en, + An, + xn, + Ut, { - analytics: 18, auto: 0, - beaconurl: 19, - blockspam: 34, - challengeurl: 17, - challengejson: 35, - debug: 20, - delay: 21, - expire: 22, + blockspam: 16, + challengeurl: 15, + challengejson: 31, + debug: 17, + delay: 18, + expire: 19, floating: 1, - floatinganchor: 23, - floatingoffset: 24, + floatinganchor: 20, + floatingoffset: 21, hidefooter: 2, hidelogo: 3, name: 4, - maxnumber: 25, - mockerror: 26, - obfuscated: 27, - refetchonexpire: 28, - spamfilter: 29, - strings: 36, - test: 30, - verifyurl: 31, - workers: 32, - workerurl: 33, - configure: 37, - reset: 38, - verify: 39, - clarify: 40 + maxnumber: 22, + mockerror: 23, + obfuscated: 24, + plugins: 32, + refetchonexpire: 25, + spamfilter: 26, + strings: 33, + test: 27, + verifyurl: 28, + workers: 29, + workerurl: 30, + clarify: 34, + configure: 35, + getConfiguration: 36, + getFloatingAnchor: 37, + getPlugin: 38, + getState: 39, + reset: 40, + setFloatingAnchor: 41, + setState: 42, + verify: 43 }, null, [-1, -1, -1] ); } - get analytics() { - return this.$$.ctx[18]; - } - set analytics(e) { - this.$$set({ analytics: e }), E(); - } get auto() { return this.$$.ctx[0]; } set auto(e) { - this.$$set({ auto: e }), E(); - } - get beaconurl() { - return this.$$.ctx[19]; - } - set beaconurl(e) { - this.$$set({ beaconurl: e }), E(); + this.$$set({ auto: e }), p(); } get blockspam() { - return this.$$.ctx[34]; + return this.$$.ctx[16]; } set blockspam(e) { - this.$$set({ blockspam: e }), E(); + this.$$set({ blockspam: e }), p(); } get challengeurl() { - return this.$$.ctx[17]; + return this.$$.ctx[15]; } set challengeurl(e) { - this.$$set({ challengeurl: e }), E(); + this.$$set({ challengeurl: e }), p(); } get challengejson() { - return this.$$.ctx[35]; + return this.$$.ctx[31]; } set challengejson(e) { - this.$$set({ challengejson: e }), E(); + this.$$set({ challengejson: e }), p(); } get debug() { - return this.$$.ctx[20]; + return this.$$.ctx[17]; } set debug(e) { - this.$$set({ debug: e }), E(); + this.$$set({ debug: e }), p(); } get delay() { - return this.$$.ctx[21]; + return this.$$.ctx[18]; } set delay(e) { - this.$$set({ delay: e }), E(); + this.$$set({ delay: e }), p(); } get expire() { - return this.$$.ctx[22]; + return this.$$.ctx[19]; } set expire(e) { - this.$$set({ expire: e }), E(); + this.$$set({ expire: e }), p(); } get floating() { return this.$$.ctx[1]; } set floating(e) { - this.$$set({ floating: e }), E(); + this.$$set({ floating: e }), p(); } get floatinganchor() { - return this.$$.ctx[23]; + return this.$$.ctx[20]; } set floatinganchor(e) { - this.$$set({ floatinganchor: e }), E(); + this.$$set({ floatinganchor: e }), p(); } get floatingoffset() { - return this.$$.ctx[24]; + return this.$$.ctx[21]; } set floatingoffset(e) { - this.$$set({ floatingoffset: e }), E(); + this.$$set({ floatingoffset: e }), p(); } get hidefooter() { return this.$$.ctx[2]; } set hidefooter(e) { - this.$$set({ hidefooter: e }), E(); + this.$$set({ hidefooter: e }), p(); } get hidelogo() { return this.$$.ctx[3]; } set hidelogo(e) { - this.$$set({ hidelogo: e }), E(); + this.$$set({ hidelogo: e }), p(); } get name() { return this.$$.ctx[4]; } set name(e) { - this.$$set({ name: e }), E(); + this.$$set({ name: e }), p(); } get maxnumber() { - return this.$$.ctx[25]; + return this.$$.ctx[22]; } set maxnumber(e) { - this.$$set({ maxnumber: e }), E(); + this.$$set({ maxnumber: e }), p(); } get mockerror() { - return this.$$.ctx[26]; + return this.$$.ctx[23]; } set mockerror(e) { - this.$$set({ mockerror: e }), E(); + this.$$set({ mockerror: e }), p(); } get obfuscated() { - return this.$$.ctx[27]; + return this.$$.ctx[24]; } set obfuscated(e) { - this.$$set({ obfuscated: e }), E(); + this.$$set({ obfuscated: e }), p(); + } + get plugins() { + return this.$$.ctx[32]; + } + set plugins(e) { + this.$$set({ plugins: e }), p(); } get refetchonexpire() { - return this.$$.ctx[28]; + return this.$$.ctx[25]; } set refetchonexpire(e) { - this.$$set({ refetchonexpire: e }), E(); + this.$$set({ refetchonexpire: e }), p(); } get spamfilter() { - return this.$$.ctx[29]; + return this.$$.ctx[26]; } set spamfilter(e) { - this.$$set({ spamfilter: e }), E(); + this.$$set({ spamfilter: e }), p(); } get strings() { - return this.$$.ctx[36]; + return this.$$.ctx[33]; } set strings(e) { - this.$$set({ strings: e }), E(); + this.$$set({ strings: e }), p(); } get test() { - return this.$$.ctx[30]; + return this.$$.ctx[27]; } set test(e) { - this.$$set({ test: e }), E(); + this.$$set({ test: e }), p(); } get verifyurl() { - return this.$$.ctx[31]; + return this.$$.ctx[28]; } set verifyurl(e) { - this.$$set({ verifyurl: e }), E(); + this.$$set({ verifyurl: e }), p(); } get workers() { - return this.$$.ctx[32]; + return this.$$.ctx[29]; } set workers(e) { - this.$$set({ workers: e }), E(); + this.$$set({ workers: e }), p(); } get workerurl() { - return this.$$.ctx[33]; + return this.$$.ctx[30]; } set workerurl(e) { - this.$$set({ workerurl: e }), E(); + this.$$set({ workerurl: e }), p(); + } + get clarify() { + return this.$$.ctx[34]; } get configure() { + return this.$$.ctx[35]; + } + get getConfiguration() { + return this.$$.ctx[36]; + } + get getFloatingAnchor() { return this.$$.ctx[37]; } - get reset() { + get getPlugin() { return this.$$.ctx[38]; } - get verify() { + get getState() { return this.$$.ctx[39]; } - get clarify() { + get reset() { return this.$$.ctx[40]; } -} -customElements.define("altcha-widget", pn(Bn, { analytics: { type: "Boolean" }, auto: {}, beaconurl: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, delay: {}, expire: {}, floating: {}, floatinganchor: {}, floatingoffset: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, obfuscated: {}, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, ["default"], ["configure", "reset", "verify", "clarify"], !1)); -globalThis.createAltchaWorker = (n) => new Worker(new URL(n || "./worker.js", import.meta.url)); + get setFloatingAnchor() { + return this.$$.ctx[41]; + } + get setState() { + return this.$$.ctx[42]; + } + get verify() { + return this.$$.ctx[43]; + } +} +customElements.define("altcha-widget", un( + In, + { auto: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, delay: {}, expire: {}, floating: {}, floatinganchor: {}, floatingoffset: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, obfuscated: {}, plugins: {}, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, + ["default"], + [ + "clarify", + "configure", + "getConfiguration", + "getFloatingAnchor", + "getPlugin", + "getState", + "reset", + "setFloatingAnchor", + "setState", + "verify" + ], + !1 +)); +globalThis.altchaCreateWorker = (n) => new Worker(new URL(n || "./worker.js", import.meta.url)); +globalThis.altchaPlugins = globalThis.altchaPlugins || []; export { - Bn as Altcha + In as Altcha }; diff --git a/dist_external/altcha.umd.cjs b/dist_external/altcha.umd.cjs index 88a3641..7538f90 100644 --- a/dist_external/altcha.umd.cjs +++ b/dist_external/altcha.umd.cjs @@ -1,2 +1,2 @@ -(function(w,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(w=typeof globalThis<"u"?globalThis:w||self,E(w.altcha={}))})(this,function(w){"use strict";var Bn=Object.defineProperty;var Vt=w=>{throw TypeError(w)};var Hn=(w,E,F)=>E in w?Bn(w,E,{enumerable:!0,configurable:!0,writable:!0,value:F}):w[E]=F;var q=(w,E,F)=>Hn(w,typeof E!="symbol"?E+"":E,F),Pt=(w,E,F)=>E.has(w)||Vt("Cannot "+F);var X=(w,E,F)=>(Pt(w,E,"read from private field"),F?F.call(w):E.get(w)),de=(w,E,F)=>E.has(w)?Vt("Cannot add the same private member more than once"):E instanceof WeakSet?E.add(w):E.set(w,F),Ot=(w,E,F,Se)=>(Pt(w,E,"write to private field"),Se?Se.call(w,F):E.set(w,F),F);var ye,_e,pe,ke,Ce,Ae;var E=typeof document<"u"?document.currentScript:null;function F(){}function Se(n,e){for(const t in e)n[t]=e[t];return n}function Je(n){return n()}function Xe(){return Object.create(null)}function we(n){n.forEach(Je)}function We(n){return typeof n=="function"}function Bt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Ht(n){return Object.keys(n).length===0}function qt(n,e,t,r){if(n){const o=ze(n,e,t,r);return n[0](o)}}function ze(n,e,t,r){return n[1]&&r?Se(t.ctx.slice(),n[1](r(e))):t.ctx}function Zt(n,e,t,r){if(n[2]&&r){const o=n[2](r(t));if(e.dirty===void 0)return o;if(typeof o=="object"){const s=[],l=Math.max(e.dirty.length,o.length);for(let c=0;c32){const e=[],t=n.ctx.length/32;for(let r=0;rn.removeEventListener(e,t,r)}function a(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Xt(n){return Array.from(n.childNodes)}function Qe(n,e,t){n.classList.toggle(e,!!t)}function Wt(n,e,{bubbles:t=!1,cancelable:r=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:r})}function zt(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let Ee;function ve(n){Ee=n}function Oe(){if(!Ee)throw new Error("Function called outside component initialization");return Ee}function Kt(n){Oe().$$.on_mount.push(n)}function Qt(n){Oe().$$.on_destroy.push(n)}function $t(){const n=Oe();return(e,t,{cancelable:r=!1}={})=>{const o=n.$$.callbacks[e];if(o){const s=Wt(e,t,{cancelable:r});return o.slice().forEach(l=>{l.call(n,s)}),!s.defaultPrevented}return!0}}const me=[],De=[];let ge=[];const $e=[],et=Promise.resolve();let Be=!1;function tt(){Be||(Be=!0,et.then(v))}function en(){return tt(),et}function He(n){ge.push(n)}const qe=new Set;let be=0;function v(){if(be!==0)return;const n=Ee;do{try{for(;ben.indexOf(r)===-1?e.push(r):t.push(r)),t.forEach(r=>r()),ge=e}const Me=new Set;let rn;function nt(n,e){n&&n.i&&(Me.delete(n),n.i(e))}function on(n,e,t,r){if(n&&n.o){if(Me.has(n))return;Me.add(n),rn.c.push(()=>{Me.delete(n)}),n.o(e)}}function sn(n,e,t){const{fragment:r,after_update:o}=n.$$;r&&r.m(e,t),He(()=>{const s=n.$$.on_mount.map(Je).filter(We);n.$$.on_destroy?n.$$.on_destroy.push(...s):we(s),n.$$.on_mount=[]}),o.forEach(He)}function ln(n,e){const t=n.$$;t.fragment!==null&&(nn(t.after_update),we(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function cn(n,e){n.$$.dirty[0]===-1&&(me.push(n),tt(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const z=C.length?C[0]:ie;return h.ctx&&o(h.ctx[I],h.ctx[I]=z)&&(!h.skip_bound&&h.bound[I]&&h.bound[I](z),_&&cn(n,I)),ie}):[],h.update(),_=!0,we(h.before_update),h.fragment=r?r(h.ctx):!1,e.target){if(e.hydrate){const I=Xt(e.target);h.fragment&&h.fragment.l(I),I.forEach(D)}else h.fragment&&h.fragment.c();e.intro&&nt(n.$$.fragment),sn(n,e.target,e.anchor),v()}ve(f)}let it;typeof HTMLElement=="function"&&(it=class extends HTMLElement{constructor(e,t,r){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,r&&this.attachShadow({mode:"open"})}addEventListener(e,t,r){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,r)}removeEventListener(e,t,r){if(super.removeEventListener(e,t,r),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(s){return()=>{let l;return{c:function(){l=M("slot"),s!=="default"&&a(l,"name",s)},m:function(h,_){V(h,l,_)},d:function(h){h&&D(l)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},r=zt(this);for(const s of this.$$s)s in r&&(t[s]=[e(s)]);for(const s of this.attributes){const l=this.$$g_p(s.name);l in this.$$d||(this.$$d[l]=Ne(l,s.value,this.$$p_d,"toProp"))}for(const s in this.$$p_d)!(s in this.$$d)&&this[s]!==void 0&&(this.$$d[s]=this[s],delete this[s]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const s in this.$$p_d)if(this.$$d[s]=this.$$c.$$.ctx[this.$$c.$$.props[s]],this.$$p_d[s].reflect){const l=Ne(s,this.$$d[s],this.$$p_d,"toAttribute");l==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,l)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const s in this.$$l)for(const l of this.$$l[s]){const c=this.$$c.$on(s,l);this.$$l_u.set(l,c)}this.$$l={}}}attributeChangedCallback(e,t,r){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Ne(e,r,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Ne(n,e,t,r){var s;const o=(s=t[n])==null?void 0:s.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!r||!t[n])return e;if(r==="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 an(n,e,t,r,o,s){let l=class extends it{constructor(){super(n,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(c=>(e[c].attribute||c).toLowerCase())}};return Object.keys(e).forEach(c=>{Object.defineProperty(l.prototype,c,{get(){return this.$$c&&c in this.$$c?this.$$c[c]:this.$$d[c]},set(f){var h;f=Ne(c,f,e),this.$$d[c]=f,(h=this.$$c)==null||h.$set({[c]:f})}})}),r.forEach(c=>{Object.defineProperty(l.prototype,c,{get(){var f;return(f=this.$$c)==null?void 0:f[c]}})}),n.element=l,l}class un{constructor(){q(this,"$$");q(this,"$$set")}$destroy(){ln(this,1),this.$destroy=F}$on(e,t){if(!We(t))return F;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(t),()=>{const o=r.indexOf(t);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!Ht(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const hn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(hn);const rt=new TextEncoder;function dn(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function mn(n,e="SHA-256",t=1e5){const r=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await ot(r,n,e);return{algorithm:e,challenge:o,salt:r,signature:""}}async function ot(n,e,t){return dn(await crypto.subtle.digest(t.toUpperCase(),rt.encode(n+e)))}function gn(n,e,t="SHA-256",r=1e6,o=0){const s=new AbortController,l=Date.now();return{promise:(async()=>{for(let f=o;f<=r;f+=1){if(s.signal.aborted)return null;if(await ot(e,f,t)===n)return{number:f,took:Date.now()-l}}return null})(),controller:s}}function st(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function bn(n){const e=atob(n),t=new Uint8Array(e.length);for(let r=0;r{for(let _=r;_<=t;_+=1){if(s.signal.aborted||!f||!h)return null;try{const I=await crypto.subtle.decrypt({name:o,iv:yn(_)},f,h);if(I)return{clearText:new TextDecoder().decode(I),took:Date.now()-l}}catch{}}return null};let f=null,h=null;try{h=bn(n);const _=await crypto.subtle.digest("SHA-256",rt.encode(e));f=await crypto.subtle.importKey("raw",_,o,!1,["decrypt"])}catch{return{promise:Promise.reject(),controller:s}}return{promise:c(),controller:s}}class wn{constructor(e){q(this,"beaconUrl",null);q(this,"error",null);q(this,"loadTime",Date.now());q(this,"submitTime",null);q(this,"startTime",null);q(this,"viewTimeThresholdMs",1500);de(this,ye,{});de(this,_e,null);de(this,pe,this.onFormChange.bind(this));de(this,ke,this.onFormFocus.bind(this));de(this,Ce,this.onFormSubmit.bind(this));de(this,Ae,this.onUnload.bind(this));this.elForm=e,window.addEventListener("unload",X(this,Ae)),this.elForm.addEventListener("change",X(this,pe)),this.elForm.addEventListener("focusin",X(this,ke)),this.elForm.addEventListener("submit",X(this,Ce))}data(){const e=Object.entries(X(this,ye));return{correction:e.length&&e.filter(([t,r])=>r>1).length/e.length||0,dropoff:!this.submitTime&&!this.error&&X(this,_e)?X(this,_e):null,error:this.error,mobile:this.isMobile(),start:this.startTime,submit:this.submitTime,tz:st()}}dataAsBase64(){try{return btoa(JSON.stringify(this.data()))}catch(e){console.error("failed to encode ALTCHA session data to base64",e)}return""}destroy(){window.removeEventListener("unload",X(this,Ae)),this.elForm.removeEventListener("change",X(this,pe)),this.elForm.removeEventListener("focusin",X(this,ke)),this.elForm.removeEventListener("submit",X(this,Ce))}end(){this.submitTime||(this.submitTime=Date.now())}getFieldName(e,t=40){const r=e.getAttribute("data-group-label"),o=e.getAttribute("name")||e.getAttribute("aria-label");return((r?r+": ":"")+o).slice(0,t)}isMobile(){const e="userAgentData"in navigator&&navigator.userAgentData?navigator.userAgentData:{};return"mobile"in e?e.mobile===!0:/Mobi/i.test(window.navigator.userAgent)}isInput(e){return["INPUT","SELECT","TEXTAREA"].includes(e.tagName)}onFormFieldChange(e){const t=this.getFieldName(e);t&&this.trackFieldChange(t)}onFormChange(e){const t=e.target;t&&this.isInput(t)&&this.onFormFieldChange(t)}onFormFocus(e){const t=e.target;if(this.startTime||this.start(),t&&this.isInput(t)){const r=this.getFieldName(t);r&&Ot(this,_e,r)}}onFormSubmit(){this.end()}onUnload(){this.loadTime<=Date.now()-this.viewTimeThresholdMs&&!this.submitTime&&this.sendBeacon()}async sendBeacon(){if(this.beaconUrl&&"sendBeacon"in navigator)try{navigator.sendBeacon(new URL(this.beaconUrl,location.origin),JSON.stringify(this.data()))}catch{}}start(){this.startTime=Date.now()}trackError(e){this.error=e===null?null:String(e)}trackFieldChange(e){X(this,ye)[e]=(X(this,ye)[e]||0)+1}}ye=new WeakMap,_e=new WeakMap,pe=new WeakMap,ke=new WeakMap,Ce=new WeakMap,Ae=new WeakMap;var b=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(b||{});function lt(n){let e,t,r;return{c(){e=ne("svg"),t=ne("path"),r=ne("path"),a(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),a(t,"fill","currentColor"),a(t,"opacity",".25"),a(r,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),a(r,"fill","currentColor"),a(r,"class","altcha-spinner"),a(e,"width","24"),a(e,"height","24"),a(e,"viewBox","0 0 24 24"),a(e,"xmlns","http://www.w3.org/2000/svg")},m(o,s){V(o,e,s),T(e,t),T(e,r)},d(o){o&&D(e)}}}function En(n){let e,t=n[13].label+"",r;return{c(){e=M("label"),a(e,"for",r=n[4]+"_checkbox")},m(o,s){V(o,e,s),e.innerHTML=t},p(o,s){s[0]&8192&&t!==(t=o[13].label+"")&&(e.innerHTML=t),s[0]&16&&r!==(r=o[4]+"_checkbox")&&a(e,"for",r)},d(o){o&&D(e)}}}function vn(n){let e,t=n[13].verifying+"";return{c(){e=M("span")},m(r,o){V(r,e,o),e.innerHTML=t},p(r,o){o[0]&8192&&t!==(t=r[13].verifying+"")&&(e.innerHTML=t)},d(r){r&&D(e)}}}function pn(n){let e,t=n[13].verified+"",r,o,s,l,c=n[11]&&ct(n);return{c(){e=M("span"),r=Q(),o=M("input"),s=Q(),c&&c.c(),l=Jt(),a(o,"type","hidden"),a(o,"name",n[4]),o.value=n[6]},m(f,h){V(f,e,h),e.innerHTML=t,V(f,r,h),V(f,o,h),V(f,s,h),c&&c.m(f,h),V(f,l,h)},p(f,h){h[0]&8192&&t!==(t=f[13].verified+"")&&(e.innerHTML=t),h[0]&16&&a(o,"name",f[4]),h[0]&64&&(o.value=f[6]),f[11]?c?c.p(f,h):(c=ct(f),c.c(),c.m(l.parentNode,l)):c&&(c.d(1),c=null)},d(f){f&&(D(e),D(r),D(o),D(s),D(l)),c&&c.d(f)}}}function ct(n){let e;return{c(){e=M("input"),a(e,"type","hidden"),a(e,"name","__session"),e.value=n[12]},m(t,r){V(t,e,r)},p(t,r){r[0]&4096&&(e.value=t[12])},d(t){t&&D(e)}}}function ft(n){let e,t,r,o,s,l,c;return{c(){e=M("div"),t=M("a"),r=ne("svg"),o=ne("path"),s=ne("path"),l=ne("path"),a(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),a(o,"fill","currentColor"),a(s,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),a(s,"fill","currentColor"),a(l,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),a(l,"fill","currentColor"),a(r,"width","22"),a(r,"height","22"),a(r,"viewBox","0 0 20 20"),a(r,"fill","none"),a(r,"xmlns","http://www.w3.org/2000/svg"),a(t,"href",mt),a(t,"target","_blank"),a(t,"class","altcha-logo"),a(t,"aria-label",c=n[13].ariaLinkLabel)},m(f,h){V(f,e,h),T(e,t),T(t,r),T(r,o),T(r,s),T(r,l)},p(f,h){h[0]&8192&&c!==(c=f[13].ariaLinkLabel)&&a(t,"aria-label",c)},d(f){f&&D(e)}}}function at(n){let e,t,r,o;function s(f,h){return f[7]===b.EXPIRED?Cn:kn}let l=s(n),c=l(n);return{c(){e=M("div"),t=ne("svg"),r=ne("path"),o=Q(),c.c(),a(r,"stroke-linecap","round"),a(r,"stroke-linejoin","round"),a(r,"d","M6 18L18 6M6 6l12 12"),a(t,"width","14"),a(t,"height","14"),a(t,"xmlns","http://www.w3.org/2000/svg"),a(t,"fill","none"),a(t,"viewBox","0 0 24 24"),a(t,"stroke-width","1.5"),a(t,"stroke","currentColor"),a(e,"class","altcha-error")},m(f,h){V(f,e,h),T(e,t),T(t,r),T(e,o),c.m(e,null)},p(f,h){l===(l=s(f))&&c?c.p(f,h):(c.d(1),c=l(f),c&&(c.c(),c.m(e,null)))},d(f){f&&D(e),c.d()}}}function kn(n){let e,t=n[13].error+"";return{c(){e=M("div"),a(e,"title",n[5])},m(r,o){V(r,e,o),e.innerHTML=t},p(r,o){o[0]&8192&&t!==(t=r[13].error+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",r[5])},d(r){r&&D(e)}}}function Cn(n){let e,t=n[13].expired+"";return{c(){e=M("div"),a(e,"title",n[5])},m(r,o){V(r,e,o),e.innerHTML=t},p(r,o){o[0]&8192&&t!==(t=r[13].expired+"")&&(e.innerHTML=t),o[0]&32&&a(e,"title",r[5])},d(r){r&&D(e)}}}function ut(n){let e,t,r=n[13].footer+"";return{c(){e=M("div"),t=M("div"),a(e,"class","altcha-footer")},m(o,s){V(o,e,s),T(e,t),t.innerHTML=r},p(o,s){s[0]&8192&&r!==(r=o[13].footer+"")&&(t.innerHTML=r)},d(o){o&&D(e)}}}function ht(n){let e;return{c(){e=M("div"),a(e,"class","altcha-anchor-arrow")},m(t,r){V(t,e,r),n[46](e)},p:F,d(t){t&&D(e),n[46](null)}}}function An(n){let e,t,r,o,s,l,c,f,h,_,I,ie,C,z,G,re,oe;const N=n[44].default,Z=qt(N,n,n[43],null);let P=n[7]===b.VERIFYING&<();function ce(d,L){return d[7]===b.VERIFIED?pn:d[7]===b.VERIFYING?vn:En}let se=ce(n),J=se(n),R=(n[3]!==!0||n[14])&&ft(n),j=(n[5]||n[7]===b.EXPIRED)&&at(n),A=n[13].footer&&(n[2]!==!0||n[14])&&ut(n),U=n[1]&&ht(n);return{c(){Z&&Z.c(),e=Q(),t=M("div"),r=M("div"),P&&P.c(),o=Q(),s=M("div"),l=M("input"),h=Q(),_=M("div"),J.c(),I=Q(),R&&R.c(),ie=Q(),j&&j.c(),C=Q(),A&&A.c(),z=Q(),U&&U.c(),a(l,"type","checkbox"),a(l,"id",c=n[4]+"_checkbox"),l.required=f=n[0]!=="onsubmit",a(s,"class","altcha-checkbox"),Qe(s,"altcha-hidden",n[7]===b.VERIFYING),a(_,"class","altcha-label"),a(r,"class","altcha-main"),a(t,"class","altcha"),a(t,"data-state",n[7]),a(t,"data-floating",n[1])},m(d,L){Z&&Z.m(d,L),V(d,e,L),V(d,t,L),T(t,r),P&&P.m(r,null),T(r,o),T(r,s),T(s,l),l.checked=n[8],T(r,h),T(r,_),J.m(_,null),T(r,I),R&&R.m(r,null),T(t,ie),j&&j.m(t,null),T(t,C),A&&A.m(t,null),T(t,z),U&&U.m(t,null),n[47](t),G=!0,re||(oe=[Pe(l,"change",n[45]),Pe(l,"change",n[15]),Pe(l,"invalid",n[16])],re=!0)},p(d,L){Z&&Z.p&&(!G||L[1]&4096)&&Gt(Z,N,d,d[43],G?Zt(N,d[43],L,null):Yt(d[43]),null),d[7]===b.VERIFYING?P||(P=lt(),P.c(),P.m(r,o)):P&&(P.d(1),P=null),(!G||L[0]&16&&c!==(c=d[4]+"_checkbox"))&&a(l,"id",c),(!G||L[0]&1&&f!==(f=d[0]!=="onsubmit"))&&(l.required=f),L[0]&256&&(l.checked=d[8]),(!G||L[0]&128)&&Qe(s,"altcha-hidden",d[7]===b.VERIFYING),se===(se=ce(d))&&J?J.p(d,L):(J.d(1),J=se(d),J&&(J.c(),J.m(_,null))),d[3]!==!0||d[14]?R?R.p(d,L):(R=ft(d),R.c(),R.m(r,null)):R&&(R.d(1),R=null),d[5]||d[7]===b.EXPIRED?j?j.p(d,L):(j=at(d),j.c(),j.m(t,C)):j&&(j.d(1),j=null),d[13].footer&&(d[2]!==!0||d[14])?A?A.p(d,L):(A=ut(d),A.c(),A.m(t,z)):A&&(A.d(1),A=null),d[1]?U?U.p(d,L):(U=ht(d),U.c(),U.m(t,null)):U&&(U.d(1),U=null),(!G||L[0]&128)&&a(t,"data-state",d[7]),(!G||L[0]&2)&&a(t,"data-floating",d[1])},i(d){G||(nt(Z,d),G=!0)},o(d){on(Z,d),G=!1},d(d){d&&(D(e),D(t)),Z&&Z.d(d),P&&P.d(),J.d(),R&&R.d(),j&&j.d(),A&&A.d(),U&&U.d(),n[47](null),re=!1,we(oe)}}}const dt="Visit Altcha.org",mt="https://altcha.org/";function gt(n){return JSON.parse(n)}function Ln(n,e,t){var Nt,jt;let r,o,s,l,{$$slots:c={},$$scope:f}=e,{analytics:h=!1}=e,{auto:_=void 0}=e,{beaconurl:I=void 0}=e,{blockspam:ie=void 0}=e,{challengeurl:C=void 0}=e,{challengejson:z=void 0}=e,{debug:G=!1}=e,{delay:re=0}=e,{expire:oe=void 0}=e,{floating:N=void 0}=e,{floatinganchor:Z=void 0}=e,{floatingoffset:P=void 0}=e,{hidefooter:ce=!1}=e,{hidelogo:se=!1}=e,{name:J="altcha"}=e,{maxnumber:R=1e6}=e,{mockerror:j=!1}=e,{obfuscated:A=void 0}=e,{refetchonexpire:U=!0}=e,{spamfilter:d=!1}=e,{strings:L=void 0}=e,{test:K=!1}=e,{verifyurl:fe=void 0}=e,{workers:Le=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:je=void 0}=e;const Ze=$t(),yt=["SHA-256","SHA-384","SHA-512"],_t=(jt=(Nt=document.documentElement.lang)==null?void 0:Nt.split("-"))==null?void 0:jt[0];let $=!1,ee=null,k,ae=null,Ue=null,y=null,le=null,xe=null,te=null,ue=null,Y=null,wt=null,S=b.UNVERIFIED;Qt(()=>{y&&(y.removeEventListener("submit",pt),y.removeEventListener("reset",kt),y.removeEventListener("focusin",vt),y=null),le&&k.removeEventListener("click",Et),Y&&Y.destroy(),te&&(clearTimeout(te),te=null),document.removeEventListener("click",Tt),document.removeEventListener("scroll",Rt),window.removeEventListener("resize",St)}),Kt(()=>{var i,u;x("mounted","0.8.0"),x("workers",Le),K&&x("using test mode"),oe&&Ve(oe),_!==void 0&&x("auto",_),N!==void 0&&Dt(N),y=k.closest("form"),y&&(y.addEventListener("submit",pt,{capture:!0}),y.addEventListener("reset",kt),_==="onfocus"&&y.addEventListener("focusin",vt)),le=((i=k.parentElement)==null?void 0:i.querySelector("[data-clarify-button]"))||((u=k.parentElement)==null?void 0:u.querySelector("button, a")),le&&le.addEventListener("click",Et),h&&Lt(),_==="onload"&&(A?Te():he()),r&&(ce||se)&&x("Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.")});function x(...i){(G||i.some(u=>u instanceof Error))&&console[i[0]instanceof Error?"error":"log"]("ALTCHA",...i)}function Et(i){i.preventDefault(),S===b.UNVERIFIED&&Te()}function vt(i){S===b.UNVERIFIED&&he()}function pt(i){y&&Y&&S===b.VERIFIED&&(Y.end(),t(12,wt=Y.dataAsBase64())),y&&_==="onsubmit"&&(S===b.UNVERIFIED?(i.preventDefault(),i.stopPropagation(),he().then(()=>{y==null||y.requestSubmit()})):S!==b.VERIFIED&&(i.preventDefault(),i.stopPropagation(),S===b.VERIFYING&&Ft()))}function kt(){Ie()}function Ct(i,u){return btoa(JSON.stringify({algorithm:i.algorithm,challenge:i.challenge,number:u.number,salt:i.salt,signature:i.signature,test:K?!0:void 0,took:u.took}))}function At(i){if(!i.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(i.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!yt.includes(i.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${yt.join(", ")}`);if(!i.challenge||i.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!i.salt||i.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function xn(){var i;if(j)throw x("mocking error"),new Error("Mocked error.");if(o)return x("using provided json data"),o;if(K)return x("generating test challenge",{test:K}),mn(typeof K!="boolean"?+K:void 0);{if(!C&&y){const p=y.getAttribute("action");p!=null&&p.includes("/form/")&&t(17,C=p+"/altcha")}if(!C)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",C);const u=await fetch(C,{headers:d?{"x-altcha-spam-filter":"1"}:{}});if(u.status!==200)throw new Error(`Server responded with ${u.status}.`);const m=u.headers.get("Expires"),g=u.headers.get("X-Altcha-Config"),O=await u.json(),B=new URLSearchParams((i=O.salt.split("?"))==null?void 0:i[1]),H=B.get("expires")||B.get("expire");if(H){const p=new Date(+H*1e3),W=isNaN(p.getTime())?0:p.getTime()-Date.now();W>0&&Ve(W)}if(g)try{const p=JSON.parse(g);p&&typeof p=="object"&&(p.verifyurl&&(p.verifyurl=new URL(p.verifyurl,new URL(C)).toString()),Mt(p))}catch(p){x("unable to configure from X-Altcha-Config",p)}if(!oe&&(m!=null&&m.length)){const p=Date.parse(m);if(p){const W=p-Date.now();W>0&&Ve(W)}}return O}}function Lt(){if(!Y)if(y){if(x("analytics enabled"),t(11,Y=new wn(y)),I===void 0){const i=y.getAttribute("action");i&&t(19,I=i+"/beacon")}t(11,Y.beaconUrl=I||null,Y)}else x("analytics cannot be enabled - form element not found")}function xt(){C&&U&&S===b.VERIFIED?he():Ie(b.EXPIRED,l.expired)}async function It(i){let u=null;if("Worker"in window){try{u=await In(i,i.maxnumber)}catch(m){x(m)}if((u==null?void 0:u.number)!==void 0||"obfuscated"in i)return{data:i,solution:u}}if("obfuscated"in i){const m=await _n(i.obfuscated,i.key,i.maxnumber);return{data:i,solution:await m.promise}}return{data:i,solution:await gn(i.challenge,i.salt,i.algorithm,i.maxnumber||R).promise}}async function In(i,u=typeof K=="number"?K:R,m=Math.ceil(Le)){const g=[];m=Math.min(16,Math.max(1,m));for(let H=0;H{const W=p*O;return new Promise(Ye=>{H.addEventListener("message",Re=>{if(Re.data)for(const Fe of g)Fe!==H&&Fe.postMessage({type:"abort"});Ye(Re.data)}),H.postMessage({payload:i,max:W+O,start:W,type:"work"})})}));for(const H of g)H.terminate();return B.find(H=>!!H)||null}function Tn(){[b.UNVERIFIED,b.ERROR,b.EXPIRED].includes(S)?d&&(y==null?void 0:y.reportValidity())===!1?t(8,$=!1):A?Te():he():t(8,$=!0)}function Tt(i){const u=i.target;N&&u&&!k.contains(u)&&S===b.VERIFIED&&t(9,k.style.display="none",k)}function Rt(){N&&Ge()}function Ft(){S===b.VERIFYING&&l.waitAlert&&alert(l.waitAlert)}function Rn(i){var u;if(ee){const m=ee.match(/^(mailto|tel|sms|https?):/);let g;if(m){const[O]=ee.slice(ee.indexOf(":")+1).replace(/^\/\//,"").split("?");g=document.createElement("a"),g.href=ee,g.innerHTML=O}else g=document.createTextNode(ee);le&&g&&(le.after(g),(u=le.parentElement)==null||u.removeChild(le))}}function Fn(i){Y&&Y.trackError(xe)}function Sn(i){N&&S!==b.UNVERIFIED&&requestAnimationFrame(()=>{Ge()})}function St(){N&&Ge()}function Ve(i){x("expire",i),te&&(clearTimeout(te),te=null),i<1?xt():te=setTimeout(xt,i)}function Dt(i){x("floating",i),N!==i&&(t(9,k.style.left="",k),t(9,k.style.top="",k)),t(1,N=i===!0||i===""?"auto":i===!1||i==="false"?void 0:N),N?(_||t(0,_="onsubmit"),document.addEventListener("scroll",Rt),document.addEventListener("click",Tt),window.addEventListener("resize",St)):_==="onsubmit"&&t(0,_=void 0)}function Dn(i){var m;const u=y==null?void 0:y.querySelector(typeof i=="string"?`input[name="${i}"]`:'input[type="email"]:not([data-no-spamfilter])');return((m=u==null?void 0:u.value)==null?void 0:m.slice(u.value.indexOf("@")))||void 0}function Mn(i){return[...(y==null?void 0:y.querySelectorAll(i!=null&&i.length?i.map(m=>`input[name="${m}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((m,g)=>{const O=g.name,B=g.value;return O&&B&&(m[O]=/\n/.test(B)?B.replace(new RegExp("(?O:N==="top",p=Math.max(i,Math.min(B-i-g.width,m.left+m.width/2-g.width/2));if(H?t(9,k.style.top=`${m.top-(g.height+u)}px`,k):t(9,k.style.top=`${m.bottom+u}px`,k),t(9,k.style.left=`${p}px`,k),k.setAttribute("data-floating",H?"top":"bottom"),ae){const W=ae.getBoundingClientRect();t(10,ae.style.left=m.left-p+m.width/2-W.width/2+"px",ae)}}else x("unable to find floating anchor element")}function Mt(i){i.analytics&&(t(18,h=i.analytics),Lt()),i.obfuscated!==void 0&&t(27,A=i.obfuscated),i.auto!==void 0&&(t(0,_=i.auto),_==="onload"&&(A?Te():he())),i.beaconurl&&(t(19,I=i.beaconurl),Y&&t(11,Y.beaconUrl=I,Y)),i.floatinganchor!==void 0&&t(23,Z=i.floatinganchor),i.delay!==void 0&&t(21,re=i.delay),i.floatingoffset!==void 0&&t(24,P=i.floatingoffset),i.floating!==void 0&&Dt(i.floating),i.expire!==void 0&&(Ve(i.expire),t(22,oe=i.expire)),i.challenge&&(At(i.challenge),o=i.challenge),i.challengeurl!==void 0&&t(17,C=i.challengeurl),i.debug!==void 0&&t(20,G=!!i.debug),i.hidefooter!==void 0&&t(2,ce=!!i.hidefooter),i.hidelogo!==void 0&&t(3,se=!!i.hidelogo),i.maxnumber!==void 0&&t(25,R=+i.maxnumber),i.mockerror!==void 0&&t(26,j=!!i.mockerror),i.name!==void 0&&t(4,J=i.name),i.refetchonexpire!==void 0&&t(28,U=!!i.refetchonexpire),i.spamfilter!==void 0&&t(29,d=typeof i.spamfilter=="object"?i.spamfilter:!!i.spamfilter),i.strings&&t(42,s=i.strings),i.test!==void 0&&t(30,K=typeof i.test=="number"?i.test:!!i.test),i.verifyurl!==void 0&&t(31,fe=i.verifyurl),i.workers!==void 0&&t(32,Le=+i.workers),i.workerurl!==void 0&&t(33,je=i.workerurl)}function Ie(i=b.UNVERIFIED,u=null){te&&(clearTimeout(te),te=null),t(8,$=!1),t(5,xe=u),t(6,ue=null),t(7,S=i)}async function he(){return Ie(b.VERIFYING),await new Promise(i=>setTimeout(i,re||0)),xn().then(i=>(At(i),x("challenge",i),It(i))).then(({data:i,solution:u})=>{if(x("solution",u),"challenge"in i&&u&&!("clearText"in u))if((u==null?void 0:u.number)!==void 0){if(fe)return Nn(Ct(i,u));t(6,ue=Ct(i,u)),x("payload",ue)}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(()=>{en().then(()=>{t(7,S=b.VERIFIED),t(8,$=!0),x("verified"),Ze("verified",{payload:ue})})}).catch(i=>{x(i),t(7,S=b.ERROR),t(8,$=!1),t(5,xe=i.message)})}async function Te(){if(!A){t(7,S=b.ERROR);return}Ie(b.VERIFYING),await new Promise(B=>setTimeout(B,re||0));const[i,u]=A.split("?");let g=new URLSearchParams(u||"").get("key")||void 0;if(g){const B=g.match(/^\(prompt:?(.*)\)$/);B&&(g=prompt(B[1]||"Enter Key:")||void 0)}const{solution:O}=await It({obfuscated:i,key:g,maxnumber:R});O&&"clearText"in O?(t(41,ee=O.clearText),t(7,S=b.VERIFIED),t(8,$=!0),N&&k&&t(9,k.style.display="none",k)):(t(7,S=b.ERROR),t(8,$=!1),t(5,xe="Unable to decrypt data."))}function Un(){$=this.checked,t(8,$)}function Vn(i){De[i?"unshift":"push"](()=>{ae=i,t(10,ae)})}function Pn(i){De[i?"unshift":"push"](()=>{k=i,t(9,k)})}return n.$$set=i=>{"analytics"in i&&t(18,h=i.analytics),"auto"in i&&t(0,_=i.auto),"beaconurl"in i&&t(19,I=i.beaconurl),"blockspam"in i&&t(34,ie=i.blockspam),"challengeurl"in i&&t(17,C=i.challengeurl),"challengejson"in i&&t(35,z=i.challengejson),"debug"in i&&t(20,G=i.debug),"delay"in i&&t(21,re=i.delay),"expire"in i&&t(22,oe=i.expire),"floating"in i&&t(1,N=i.floating),"floatinganchor"in i&&t(23,Z=i.floatinganchor),"floatingoffset"in i&&t(24,P=i.floatingoffset),"hidefooter"in i&&t(2,ce=i.hidefooter),"hidelogo"in i&&t(3,se=i.hidelogo),"name"in i&&t(4,J=i.name),"maxnumber"in i&&t(25,R=i.maxnumber),"mockerror"in i&&t(26,j=i.mockerror),"obfuscated"in i&&t(27,A=i.obfuscated),"refetchonexpire"in i&&t(28,U=i.refetchonexpire),"spamfilter"in i&&t(29,d=i.spamfilter),"strings"in i&&t(36,L=i.strings),"test"in i&&t(30,K=i.test),"verifyurl"in i&&t(31,fe=i.verifyurl),"workers"in i&&t(32,Le=i.workers),"workerurl"in i&&t(33,je=i.workerurl),"$$scope"in i&&t(43,f=i.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&131072&&t(14,r=!!(C!=null&&C.includes(".altcha.org"))&&!!(C!=null&&C.includes("apiKey=ckey_"))),n.$$.dirty[1]&16&&(o=z?gt(z):void 0),n.$$.dirty[1]&32&&t(42,s=L?gt(L):{}),n.$$.dirty[1]&2048&&t(13,l={ariaLinkLabel:dt,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...s}),n.$$.dirty[0]&192|n.$$.dirty[1]&1024&&Ze("statechange",ee?{clarifiedData:ee,state:S}:{payload:ue,state:S}),n.$$.dirty[0]&32&&Fn(),n.$$.dirty[0]&128&&Sn(),n.$$.dirty[1]&1024&&Rn()},[_,N,ce,se,J,xe,ue,S,$,k,ae,Y,wt,l,r,Tn,Ft,C,h,I,G,re,oe,Z,P,R,j,A,U,d,K,fe,Le,je,ie,z,L,Mt,Ie,he,Te,ee,s,f,c,Un,Vn,Pn]}class bt extends un{constructor(e){super(),fn(this,e,Ln,An,Bt,{analytics:18,auto:0,beaconurl:19,blockspam:34,challengeurl:17,challengejson:35,debug:20,delay:21,expire:22,floating:1,floatinganchor:23,floatingoffset:24,hidefooter:2,hidelogo:3,name:4,maxnumber:25,mockerror:26,obfuscated:27,refetchonexpire:28,spamfilter:29,strings:36,test:30,verifyurl:31,workers:32,workerurl:33,configure:37,reset:38,verify:39,clarify:40},null,[-1,-1,-1])}get analytics(){return this.$$.ctx[18]}set analytics(e){this.$$set({analytics:e}),v()}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),v()}get beaconurl(){return this.$$.ctx[19]}set beaconurl(e){this.$$set({beaconurl:e}),v()}get blockspam(){return this.$$.ctx[34]}set blockspam(e){this.$$set({blockspam:e}),v()}get challengeurl(){return this.$$.ctx[17]}set challengeurl(e){this.$$set({challengeurl:e}),v()}get challengejson(){return this.$$.ctx[35]}set challengejson(e){this.$$set({challengejson:e}),v()}get debug(){return this.$$.ctx[20]}set debug(e){this.$$set({debug:e}),v()}get delay(){return this.$$.ctx[21]}set delay(e){this.$$set({delay:e}),v()}get expire(){return this.$$.ctx[22]}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[23]}set floatinganchor(e){this.$$set({floatinganchor:e}),v()}get floatingoffset(){return this.$$.ctx[24]}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[25]}set maxnumber(e){this.$$set({maxnumber:e}),v()}get mockerror(){return this.$$.ctx[26]}set mockerror(e){this.$$set({mockerror:e}),v()}get obfuscated(){return this.$$.ctx[27]}set obfuscated(e){this.$$set({obfuscated:e}),v()}get refetchonexpire(){return this.$$.ctx[28]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),v()}get spamfilter(){return this.$$.ctx[29]}set spamfilter(e){this.$$set({spamfilter:e}),v()}get strings(){return this.$$.ctx[36]}set strings(e){this.$$set({strings:e}),v()}get test(){return this.$$.ctx[30]}set test(e){this.$$set({test:e}),v()}get verifyurl(){return this.$$.ctx[31]}set verifyurl(e){this.$$set({verifyurl:e}),v()}get workers(){return this.$$.ctx[32]}set workers(e){this.$$set({workers:e}),v()}get workerurl(){return this.$$.ctx[33]}set workerurl(e){this.$$set({workerurl:e}),v()}get configure(){return this.$$.ctx[37]}get reset(){return this.$$.ctx[38]}get verify(){return this.$$.ctx[39]}get clarify(){return this.$$.ctx[40]}}customElements.define("altcha-widget",an(bt,{analytics:{type:"Boolean"},auto:{},beaconurl:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},obfuscated:{},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},["default"],["configure","reset","verify","clarify"],!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:E&&E.src||new URL("altcha.umd.cjs",document.baseURI).href)),w.Altcha=bt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}); +(function($,H){typeof exports=="object"&&typeof module<"u"?H(exports):typeof define=="function"&&define.amd?define(["exports"],H):($=typeof globalThis<"u"?globalThis:$||self,H($.altcha={}))})(this,function($){"use strict";var Rn=Object.defineProperty;var Ln=($,H,z)=>H in $?Rn($,H,{enumerable:!0,configurable:!0,writable:!0,value:z}):$[H]=z;var Y=($,H,z)=>Ln($,typeof H!="symbol"?H+"":H,z);var H=typeof document<"u"?document.currentScript:null;function z(){}function xt(n,e){for(const t in e)n[t]=e[t];return n}function Fe(n){return n()}function Ne(){return Object.create(null)}function ge(n){n.forEach(Fe)}function je(n){return typeof n=="function"}function At(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function It(n){return Object.keys(n).length===0}function Rt(n,e,t,i){if(n){const o=Ve(n,e,t,i);return n[0](o)}}function Ve(n,e,t,i){return n[1]&&i?xt(t.ctx.slice(),n[1](i(e))):t.ctx}function Lt(n,e,t,i){if(n[2]&&i){const o=n[2](i(t));if(e.dirty===void 0)return o;if(typeof o=="object"){const l=[],s=Math.max(e.dirty.length,o.length);for(let h=0;h32){const e=[],t=n.ctx.length/32;for(let i=0;in.removeEventListener(e,t,i)}function c(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Pt(n){return Array.from(n.childNodes)}function Ue(n,e,t){n.classList.toggle(e,!!t)}function Mt(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}function Ft(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let me;function be(n){me=n}function Se(){if(!me)throw new Error("Function called outside component initialization");return me}function Nt(n){Se().$$.on_mount.push(n)}function jt(n){Se().$$.on_destroy.push(n)}function Vt(){const n=Se();return(e,t,{cancelable:i=!1}={})=>{const o=n.$$.callbacks[e];if(o){const l=Mt(e,t,{cancelable:i});return o.slice().forEach(s=>{s.call(n,l)}),!l.defaultPrevented}return!0}}const ce=[],Ce=[];let ue=[];const He=[],Oe=Promise.resolve();let Te=!1;function $e(){Te||(Te=!0,Oe.then(p))}function Ut(){return $e(),Oe}function De(n){ue.push(n)}const Pe=new Set;let ae=0;function p(){if(ae!==0)return;const n=me;do{try{for(;aen.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),ue=e}const xe=new Set;let $t;function Be(n,e){n&&n.i&&(xe.delete(n),n.i(e))}function Bt(n,e,t,i){if(n&&n.o){if(xe.has(n))return;xe.add(n),$t.c.push(()=>{xe.delete(n)}),n.o(e)}}function qt(n,e,t){const{fragment:i,after_update:o}=n.$$;i&&i.m(e,t),De(()=>{const l=n.$$.on_mount.map(Fe).filter(je);n.$$.on_destroy?n.$$.on_destroy.push(...l):ge(l),n.$$.on_mount=[]}),o.forEach(De)}function Zt(n,e){const t=n.$$;t.fragment!==null&&(Ot(t.after_update),ge(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Gt(n,e){n.$$.dirty[0]===-1&&(ce.push(n),$e(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const q=B.length?B[0]:X;return u.ctx&&o(u.ctx[b],u.ctx[b]=q)&&(!u.skip_bound&&u.bound[b]&&u.bound[b](q),A&&Gt(n,b)),X}):[],u.update(),A=!0,ge(u.before_update),u.fragment=i?i(u.ctx):!1,e.target){if(e.hydrate){const b=Pt(e.target);u.fragment&&u.fragment.l(b),b.forEach(j)}else u.fragment&&u.fragment.c();e.intro&&Be(n.$$.fragment),qt(n,e.target,e.anchor),p()}be(d)}let qe;typeof HTMLElement=="function"&&(qe=class extends HTMLElement{constructor(e,t,i){super();Y(this,"$$ctor");Y(this,"$$s");Y(this,"$$c");Y(this,"$$cn",!1);Y(this,"$$d",{});Y(this,"$$r",!1);Y(this,"$$p_d",{});Y(this,"$$l",{});Y(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=M("slot"),l!=="default"&&c(s,"name",l)},m:function(u,A){U(u,s,A)},d:function(u){u&&j(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=Ft(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]=Ae(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=Ae(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 h=this.$$c.$on(l,s);this.$$l_u.set(s,h)}this.$$l={}}}attributeChangedCallback(e,t,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Ae(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Ae(n,e,t,i){var l;const o=(l=t[n])==null?void 0:l.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Wt(n,e,t,i,o,l){let s=class extends qe{constructor(){super(n,t,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(h=>(e[h].attribute||h).toLowerCase())}};return Object.keys(e).forEach(h=>{Object.defineProperty(s.prototype,h,{get(){return this.$$c&&h in this.$$c?this.$$c[h]:this.$$d[h]},set(d){var u;d=Ae(h,d,e),this.$$d[h]=d,(u=this.$$c)==null||u.$set({[h]:d})}})}),i.forEach(h=>{Object.defineProperty(s.prototype,h,{get(){var d;return(d=this.$$c)==null?void 0:d[h]}})}),n.element=s,s}class Xt{constructor(){Y(this,"$$");Y(this,"$$set")}$destroy(){Zt(this,1),this.$destroy=z}$on(e,t){if(!je(t))return z;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&&!It(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Jt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Jt);const Ze=new TextEncoder;function zt(n){return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function Kt(n,e="SHA-256",t=1e5){const i=Date.now().toString(16);n||(n=Math.round(Math.random()*t));const o=await Ge(i,n,e);return{algorithm:e,challenge:o,salt:i,signature:""}}async function Ge(n,e,t){return zt(await crypto.subtle.digest(t.toUpperCase(),Ze.encode(n+e)))}function Qt(n,e,t="SHA-256",i=1e6,o=0){const l=new AbortController,s=Date.now();return{promise:(async()=>{for(let d=o;d<=i;d+=1){if(l.signal.aborted)return null;if(await Ge(e,d,t)===n)return{number:d,took:Date.now()-s}}return null})(),controller:l}}function en(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function tn(n){const e=atob(n),t=new Uint8Array(e.length);for(let i=0;i{for(let A=i;A<=t;A+=1){if(l.signal.aborted||!d||!u)return null;try{const b=await crypto.subtle.decrypt({name:o,iv:nn(A)},d,u);if(b)return{clearText:new TextDecoder().decode(b),took:Date.now()-s}}catch{}}return null};let d=null,u=null;try{u=tn(n);const A=await crypto.subtle.digest("SHA-256",Ze.encode(e));d=await crypto.subtle.importKey("raw",A,o,!1,["decrypt"])}catch{return{promise:Promise.reject(),controller:l}}return{promise:h(),controller:l}}var g=(n=>(n.ERROR="error",n.VERIFIED="verified",n.VERIFYING="verifying",n.UNVERIFIED="unverified",n.EXPIRED="expired",n))(g||{});function Ye(n){let e,t,i;return{c(){e=K("svg"),t=K("path"),i=K("path"),c(t,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(t,"fill","currentColor"),c(t,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,l){U(o,e,l),R(e,t),R(e,i)},d(o){o&&j(e)}}}function on(n){let e,t=n[11].label+"",i;return{c(){e=M("label"),c(e,"for",i=n[4]+"_checkbox")},m(o,l){U(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 ln(n){let e,t=n[11].verifying+"";return{c(){e=M("span")},m(i,o){U(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 sn(n){let e,t=n[11].verified+"",i,o;return{c(){e=M("span"),i=Q(),o=M("input"),c(o,"type","hidden"),c(o,"name",n[4]),o.value=n[6]},m(l,s){U(l,e,s),e.innerHTML=t,U(l,i,s),U(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]&64&&(o.value=l[6])},d(l){l&&(j(e),j(i),j(o))}}}function We(n){let e,t,i,o,l,s,h;return{c(){e=M("div"),t=M("a"),i=K("svg"),o=K("path"),l=K("path"),s=K("path"),c(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(o,"fill","currentColor"),c(l,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(l,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(t,"href",Qe),c(t,"target","_blank"),c(t,"class","altcha-logo"),c(t,"aria-label",h=n[11].ariaLinkLabel)},m(d,u){U(d,e,u),R(e,t),R(t,i),R(i,o),R(i,l),R(i,s)},p(d,u){u[0]&2048&&h!==(h=d[11].ariaLinkLabel)&&c(t,"aria-label",h)},d(d){d&&j(e)}}}function Xe(n){let e,t,i,o;function l(d,u){return d[7]===g.EXPIRED?cn:fn}let s=l(n),h=s(n);return{c(){e=M("div"),t=K("svg"),i=K("path"),o=Q(),h.c(),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(t,"width","14"),c(t,"height","14"),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"fill","none"),c(t,"viewBox","0 0 24 24"),c(t,"stroke-width","1.5"),c(t,"stroke","currentColor"),c(e,"class","altcha-error")},m(d,u){U(d,e,u),R(e,t),R(t,i),R(e,o),h.m(e,null)},p(d,u){s===(s=l(d))&&h?h.p(d,u):(h.d(1),h=s(d),h&&(h.c(),h.m(e,null)))},d(d){d&&j(e),h.d()}}}function fn(n){let e,t=n[11].error+"";return{c(){e=M("div"),c(e,"title",n[5])},m(i,o){U(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].error+"")&&(e.innerHTML=t),o[0]&32&&c(e,"title",i[5])},d(i){i&&j(e)}}}function cn(n){let e,t=n[11].expired+"";return{c(){e=M("div"),c(e,"title",n[5])},m(i,o){U(i,e,o),e.innerHTML=t},p(i,o){o[0]&2048&&t!==(t=i[11].expired+"")&&(e.innerHTML=t),o[0]&32&&c(e,"title",i[5])},d(i){i&&j(e)}}}function Je(n){let e,t,i=n[11].footer+"";return{c(){e=M("div"),t=M("div"),c(e,"class","altcha-footer")},m(o,l){U(o,e,l),R(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 ze(n){let e;return{c(){e=M("div"),c(e,"class","altcha-anchor-arrow")},m(t,i){U(t,e,i),n[48](e)},p:z,d(t){t&&j(e),n[48](null)}}}function un(n){let e,t,i,o,l,s,h,d,u,A,b,X,B,q,T,L,ee;const te=n[46].default,N=Rt(te,n,n[45],null);let D=n[7]===g.VERIFYING&&Ye();function ne(a,y){return a[7]===g.VERIFIED?sn:a[7]===g.VERIFYING?ln:on}let W=ne(n),V=W(n),k=(n[3]!==!0||n[12])&&We(n),P=(n[5]||n[7]===g.EXPIRED)&&Xe(n),S=n[11].footer&&(n[2]!==!0||n[12])&&Je(n),E=n[1]&&ze(n);return{c(){N&&N.c(),e=Q(),t=M("div"),i=M("div"),D&&D.c(),o=Q(),l=M("div"),s=M("input"),u=Q(),A=M("div"),V.c(),b=Q(),k&&k.c(),X=Q(),P&&P.c(),B=Q(),S&&S.c(),q=Q(),E&&E.c(),c(s,"type","checkbox"),c(s,"id",h=n[4]+"_checkbox"),s.required=d=n[0]!=="onsubmit"&&(!n[1]||n[0]!=="off"),c(l,"class","altcha-checkbox"),Ue(l,"altcha-hidden",n[7]===g.VERIFYING),c(A,"class","altcha-label"),c(i,"class","altcha-main"),c(t,"class","altcha"),c(t,"data-state",n[7]),c(t,"data-floating",n[1])},m(a,y){N&&N.m(a,y),U(a,e,y),U(a,t,y),R(t,i),D&&D.m(i,null),R(i,o),R(i,l),R(l,s),s.checked=n[8],R(i,u),R(i,A),V.m(A,null),R(i,b),k&&k.m(i,null),R(t,X),P&&P.m(t,null),R(t,B),S&&S.m(t,null),R(t,q),E&&E.m(t,null),n[49](t),T=!0,L||(ee=[Le(s,"change",n[47]),Le(s,"change",n[13]),Le(s,"invalid",n[14])],L=!0)},p(a,y){N&&N.p&&(!T||y[1]&16384)&&St(N,te,a,a[45],T?Lt(te,a[45],y,null):Tt(a[45]),null),a[7]===g.VERIFYING?D||(D=Ye(),D.c(),D.m(i,o)):D&&(D.d(1),D=null),(!T||y[0]&16&&h!==(h=a[4]+"_checkbox"))&&c(s,"id",h),(!T||y[0]&3&&d!==(d=a[0]!=="onsubmit"&&(!a[1]||a[0]!=="off")))&&(s.required=d),y[0]&256&&(s.checked=a[8]),(!T||y[0]&128)&&Ue(l,"altcha-hidden",a[7]===g.VERIFYING),W===(W=ne(a))&&V?V.p(a,y):(V.d(1),V=W(a),V&&(V.c(),V.m(A,null))),a[3]!==!0||a[12]?k?k.p(a,y):(k=We(a),k.c(),k.m(i,null)):k&&(k.d(1),k=null),a[5]||a[7]===g.EXPIRED?P?P.p(a,y):(P=Xe(a),P.c(),P.m(t,B)):P&&(P.d(1),P=null),a[11].footer&&(a[2]!==!0||a[12])?S?S.p(a,y):(S=Je(a),S.c(),S.m(t,q)):S&&(S.d(1),S=null),a[1]?E?E.p(a,y):(E=ze(a),E.c(),E.m(t,null)):E&&(E.d(1),E=null),(!T||y[0]&128)&&c(t,"data-state",a[7]),(!T||y[0]&2)&&c(t,"data-floating",a[1])},i(a){T||(Be(N,a),T=!0)},o(a){Bt(N,a),T=!1},d(a){a&&(j(e),j(t)),N&&N.d(a),D&&D.d(),V.d(),k&&k.d(),P&&P.d(),S&&S.d(),E&&E.d(),n[49](null),L=!1,ge(ee)}}}const Ke="Visit Altcha.org",Qe="https://altcha.org/";function et(n){return JSON.parse(n)}function an(n,e,t){var vt,kt;let i,o,l,s,{$$slots:h={},$$scope:d}=e,{auto:u=void 0}=e,{blockspam:A=void 0}=e,{challengeurl:b=void 0}=e,{challengejson:X=void 0}=e,{debug:B=!1}=e,{delay:q=0}=e,{expire:T=void 0}=e,{floating:L=void 0}=e,{floatinganchor:ee=void 0}=e,{floatingoffset:te=void 0}=e,{hidefooter:N=!1}=e,{hidelogo:D=!1}=e,{name:ne="altcha"}=e,{maxnumber:W=1e6}=e,{mockerror:V=!1}=e,{obfuscated:k=void 0}=e,{plugins:P=void 0}=e,{refetchonexpire:S=!0}=e,{spamfilter:E=!1}=e,{strings:a=void 0}=e,{test:y=!1}=e,{verifyurl:re=void 0}=e,{workers:he=Math.min(16,navigator.hardwareConcurrency||8)}=e,{workerurl:ye=void 0}=e;const _e=Vt(),nt=["SHA-256","SHA-384","SHA-512"],rt=(kt=(vt=document.documentElement.lang)==null?void 0:vt.split("-"))==null?void 0:kt[0];let le=!1,C,se=null,de=null,_=null,we=null,J=null,fe=null,ie=[],x=g.UNVERIFIED;jt(()=>{hn(),_&&(_.removeEventListener("submit",ct),_.removeEventListener("reset",ut),_.removeEventListener("focusin",ft),_=null),J&&(clearTimeout(J),J=null),document.removeEventListener("click",lt),document.removeEventListener("scroll",st),window.removeEventListener("resize",ht)}),Nt(()=>{v("mounted","0.9.0"),v("workers",he),yn(),v("plugins",ie.length?ie.map(r=>r.constructor.pluginName).join(", "):"none"),y&&v("using test mode"),T&&Re(T),u!==void 0&&v("auto",u),L!==void 0&&dt(L),_=C.closest("form"),_&&(_.addEventListener("submit",ct,{capture:!0}),_.addEventListener("reset",ut),u==="onfocus"&&_.addEventListener("focusin",ft)),u==="onload"&&(k?pe():oe()),i&&(N||D)&&v("Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution."),requestAnimationFrame(()=>{_e("load")})});function it(r,f){return btoa(JSON.stringify({algorithm:r.algorithm,challenge:r.challenge,number:f.number,salt:r.salt,signature:r.signature,test:y?!0:void 0,took:f.took}))}function hn(){for(const r of ie)r.destroy()}function ot(){b&&S&&x===g.VERIFIED?oe():Ee(g.EXPIRED,s.expired)}async function dn(){var r;if(V)throw v("mocking error"),new Error("Mocked error.");if(o)return v("using provided json data"),o;if(y)return v("generating test challenge",{test:y}),Kt(typeof y!="boolean"?+y:void 0);{if(!b&&_){const w=_.getAttribute("action");w!=null&&w.includes("/form/")&&t(15,b=w+"/altcha")}if(!b)throw new Error("Attribute challengeurl not set.");v("fetching challenge from",b);const f=await fetch(b,{headers:E?{"x-altcha-spam-filter":"1"}:{}});if(f.status!==200)throw new Error(`Server responded with ${f.status}.`);const m=f.headers.get("Expires"),I=f.headers.get("X-Altcha-Config"),Z=await f.json(),O=new URLSearchParams((r=Z.salt.split("?"))==null?void 0:r[1]),F=O.get("expires")||O.get("expire");if(F){const w=new Date(+F*1e3),G=isNaN(w.getTime())?0:w.getTime()-Date.now();G>0&&Re(G)}if(I)try{const w=JSON.parse(I);w&&typeof w=="object"&&(w.verifyurl&&(w.verifyurl=new URL(w.verifyurl,new URL(b)).toString()),bt(w))}catch(w){v("unable to configure from X-Altcha-Config",w)}if(!T&&(m!=null&&m.length)){const w=Date.parse(m);if(w){const G=w-Date.now();G>0&&Re(G)}}return Z}}function gn(r){var m;const f=_==null?void 0:_.querySelector(typeof r=="string"?`input[name="${r}"]`:'input[type="email"]:not([data-no-spamfilter])');return((m=f==null?void 0:f.value)==null?void 0:m.slice(f.value.indexOf("@")))||void 0}function mn(){return E==="ipAddress"?{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:!1,expectedCountries:void 0,expectedLanguages:void 0,fields:!1,ipAddress:void 0,text:void 0,timeZone:void 0}:typeof E=="object"?E:{blockedCountries:void 0,classifier:void 0,disableRules:void 0,email:void 0,expectedCountries:void 0,expectedLanguages:void 0,fields:void 0,ipAddress:void 0,text:void 0,timeZone:void 0}}function bn(r){return[...(_==null?void 0:_.querySelectorAll(r!=null&&r.length?r.map(m=>`input[name="${m}"]`).join(", "):'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])'))||[]].reduce((m,I)=>{const Z=I.name,O=I.value;return Z&&O&&(m[Z]=/\n/.test(O)?O.replace(new RegExp("(?f instanceof Error))&&console[r[0]instanceof Error?"error":"log"]("ALTCHA",`[name=${ne}]`,...r)}function _n(){[g.UNVERIFIED,g.ERROR,g.EXPIRED].includes(x)?E&&(_==null?void 0:_.reportValidity())===!1?t(8,le=!1):k?pe():oe():t(8,le=!0)}function lt(r){const f=r.target;L&&f&&!C.contains(f)&&(x===g.VERIFIED||u==="off"&&x===g.UNVERIFIED)&&t(9,C.style.display="none",C)}function st(){L&&x!==g.UNVERIFIED&&Ie()}function wn(r){for(const f of ie)typeof f.onErrorChange=="function"&&f.onErrorChange(we)}function ft(r){x===g.UNVERIFIED&&oe()}function ct(r){_&&u==="onsubmit"?x===g.UNVERIFIED?(r.preventDefault(),r.stopPropagation(),oe().then(()=>{_==null||_.requestSubmit()})):x!==g.VERIFIED&&(r.preventDefault(),r.stopPropagation(),x===g.VERIFYING&&at()):_&&L&&u==="off"&&x===g.UNVERIFIED&&(r.preventDefault(),r.stopPropagation(),t(9,C.style.display="block",C),Ie())}function ut(){Ee()}function at(){x===g.VERIFYING&&s.waitAlert&&alert(s.waitAlert)}function pn(r){for(const f of ie)typeof f.onStateChange=="function"&&f.onStateChange(x);L&&x!==g.UNVERIFIED&&requestAnimationFrame(()=>{Ie()}),t(8,le=x===g.VERIFIED)}function ht(){L&&Ie()}function Ie(r=20){if(C)if(de||(de=(ee?document.querySelector(ee):_==null?void 0:_.querySelector('input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])'))||_),de){const f=parseInt(te,10)||12,m=de.getBoundingClientRect(),I=C.getBoundingClientRect(),Z=document.documentElement.clientHeight,O=document.documentElement.clientWidth,F=L==="auto"?m.bottom+I.height+f+r>Z:L==="top",w=Math.max(r,Math.min(O-r-I.width,m.left+m.width/2-I.width/2));if(F?t(9,C.style.top=`${m.top-(I.height+f)}px`,C):t(9,C.style.top=`${m.bottom+f}px`,C),t(9,C.style.left=`${w}px`,C),C.setAttribute("data-floating",F?"top":"bottom"),se){const G=se.getBoundingClientRect();t(10,se.style.left=m.left-w+m.width/2-G.width/2+"px",se)}}else v("unable to find floating anchor element")}async function En(r){if(!re)throw new Error("Attribute verifyurl not set.");v("requesting server verification from",re);const f={payload:r};if(E){const{blockedCountries:Z,classifier:O,disableRules:F,email:w,expectedLanguages:G,expectedCountries:Me,fields:ve,ipAddress:ke,text:In,timeZone:Ct}=mn();f.blockedCountries=Z,f.classifier=O,f.disableRules=F,f.email=w===!1?void 0:gn(w),f.expectedCountries=Me,f.expectedLanguages=G||(rt?[rt]:void 0),f.fields=ve===!1?void 0:bn(ve),f.ipAddress=ke===!1?void 0:ke||"auto",f.text=In,f.timeZone=Ct===!1?void 0:Ct||en()}const m=await fetch(re,{body:JSON.stringify(f),headers:{"content-type":"application/json"},method:"POST"});if(m.status!==200)throw new Error(`Server responded with ${m.status}.`);const I=await m.json();if(I!=null&&I.payload&&t(6,fe=I.payload),_e("serververification",I),A&&I.classification==="BAD")throw new Error("SpamFilter returned negative classification.")}function Re(r){v("expire",r),J&&(clearTimeout(J),J=null),r<1?ot():J=setTimeout(ot,r)}function dt(r){v("floating",r),L!==r&&(t(9,C.style.left="",C),t(9,C.style.top="",C)),t(1,L=r===!0||r===""?"auto":r===!1||r==="false"?void 0:L),L?(u||t(0,u="onsubmit"),document.addEventListener("scroll",st),document.addEventListener("click",lt),window.addEventListener("resize",ht)):u==="onsubmit"&&t(0,u=void 0)}function gt(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(!nt.includes(r.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${nt.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 mt(r){let f=null;if("Worker"in window){try{f=await vn(r,r.maxnumber)}catch(m){v(m)}if((f==null?void 0:f.number)!==void 0||"obfuscated"in r)return{data:r,solution:f}}if("obfuscated"in r){const m=await rn(r.obfuscated,r.key,r.maxnumber);return{data:r,solution:await m.promise}}return{data:r,solution:await Qt(r.challenge,r.salt,r.algorithm,r.maxnumber||W).promise}}async function vn(r,f=typeof y=="number"?y:W,m=Math.ceil(he)){const I=[];m=Math.min(16,Math.max(1,m));for(let F=0;F{const G=w*Z;return new Promise(Me=>{F.addEventListener("message",ve=>{if(ve.data)for(const ke of I)ke!==F&&ke.postMessage({type:"abort"});Me(ve.data)}),F.postMessage({payload:r,max:G+Z,start:G,type:"work"})})}));for(const F of I)F.terminate();return O.find(F=>!!F)||null}async function pe(){if(!k){t(7,x=g.ERROR);return}const r=ie.find(f=>f.constructor.pluginName==="obfuscation");if(!r||!("clarify"in r)){t(7,x=g.ERROR),v("Plugin `obfuscation` not found. Import `altcha/plugins/obfuscation` to load it.");return}if("clarify"in r&&typeof r.clarify=="function")return r.clarify()}function bt(r){r.obfuscated!==void 0&&t(24,k=r.obfuscated),r.auto!==void 0&&(t(0,u=r.auto),u==="onload"&&(k?pe():oe())),r.blockspam!==void 0&&t(16,A=!!r.blockspam),r.floatinganchor!==void 0&&t(20,ee=r.floatinganchor),r.delay!==void 0&&t(18,q=r.delay),r.floatingoffset!==void 0&&t(21,te=r.floatingoffset),r.floating!==void 0&&dt(r.floating),r.expire!==void 0&&(Re(r.expire),t(19,T=r.expire)),r.challenge&&(gt(r.challenge),o=r.challenge),r.challengeurl!==void 0&&t(15,b=r.challengeurl),r.debug!==void 0&&t(17,B=!!r.debug),r.hidefooter!==void 0&&t(2,N=!!r.hidefooter),r.hidelogo!==void 0&&t(3,D=!!r.hidelogo),r.maxnumber!==void 0&&t(22,W=+r.maxnumber),r.mockerror!==void 0&&t(23,V=!!r.mockerror),r.name!==void 0&&t(4,ne=r.name),r.refetchonexpire!==void 0&&t(25,S=!!r.refetchonexpire),r.spamfilter!==void 0&&t(26,E=typeof r.spamfilter=="object"?r.spamfilter:!!r.spamfilter),r.strings&&t(44,l=r.strings),r.test!==void 0&&t(27,y=typeof r.test=="number"?r.test:!!r.test),r.verifyurl!==void 0&&t(28,re=r.verifyurl),r.workers!==void 0&&t(29,he=+r.workers),r.workerurl!==void 0&&t(30,ye=r.workerurl)}function yt(){return{auto:u,blockspam:A,challengeurl:b,debug:B,delay:q,expire:T,floating:L,floatinganchor:ee,floatingoffset:te,hidefooter:N,hidelogo:D,name:ne,maxnumber:W,mockerror:V,obfuscated:k,refetchonexpire:S,spamfilter:E,strings:s,test:y,verifyurl:re,workers:he,workerurl:ye}}function _t(){return de}function kn(r){return ie.find(f=>f.constructor.pluginName===r)}function wt(){return x}function Ee(r=g.UNVERIFIED,f=null){J&&(clearTimeout(J),J=null),t(8,le=!1),t(5,we=f),t(6,fe=null),t(7,x=r)}function pt(r){de=r}function Et(r,f=null){t(7,x=r),t(5,we=f)}async function oe(){return Ee(g.VERIFYING),await new Promise(r=>setTimeout(r,q||0)),dn().then(r=>(gt(r),v("challenge",r),mt(r))).then(({data:r,solution:f})=>{if(v("solution",f),"challenge"in r&&f&&!("clearText"in f))if((f==null?void 0:f.number)!==void 0){if(re)return En(it(r,f));t(6,fe=it(r,f)),v("payload",fe)}else throw v("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."),new Error("Unexpected result returned.")}).then(()=>{Ut().then(()=>{t(7,x=g.VERIFIED),v("verified"),_e("verified",{payload:fe})})}).catch(r=>{v(r),t(7,x=g.ERROR),t(5,we=r.message)})}function Cn(){le=this.checked,t(8,le)}function xn(r){Ce[r?"unshift":"push"](()=>{se=r,t(10,se)})}function An(r){Ce[r?"unshift":"push"](()=>{C=r,t(9,C)})}return n.$$set=r=>{"auto"in r&&t(0,u=r.auto),"blockspam"in r&&t(16,A=r.blockspam),"challengeurl"in r&&t(15,b=r.challengeurl),"challengejson"in r&&t(31,X=r.challengejson),"debug"in r&&t(17,B=r.debug),"delay"in r&&t(18,q=r.delay),"expire"in r&&t(19,T=r.expire),"floating"in r&&t(1,L=r.floating),"floatinganchor"in r&&t(20,ee=r.floatinganchor),"floatingoffset"in r&&t(21,te=r.floatingoffset),"hidefooter"in r&&t(2,N=r.hidefooter),"hidelogo"in r&&t(3,D=r.hidelogo),"name"in r&&t(4,ne=r.name),"maxnumber"in r&&t(22,W=r.maxnumber),"mockerror"in r&&t(23,V=r.mockerror),"obfuscated"in r&&t(24,k=r.obfuscated),"plugins"in r&&t(32,P=r.plugins),"refetchonexpire"in r&&t(25,S=r.refetchonexpire),"spamfilter"in r&&t(26,E=r.spamfilter),"strings"in r&&t(33,a=r.strings),"test"in r&&t(27,y=r.test),"verifyurl"in r&&t(28,re=r.verifyurl),"workers"in r&&t(29,he=r.workers),"workerurl"in r&&t(30,ye=r.workerurl),"$$scope"in r&&t(45,d=r.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&32768&&t(12,i=!!(b!=null&&b.includes(".altcha.org"))&&!!(b!=null&&b.includes("apiKey=ckey_"))),n.$$.dirty[1]&1&&(o=X?et(X):void 0),n.$$.dirty[1]&4&&t(44,l=a?et(a):{}),n.$$.dirty[1]&8192&&t(11,s={ariaLinkLabel:Ke,error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),n.$$.dirty[0]&192&&_e("statechange",{payload:fe,state:x}),n.$$.dirty[0]&32&&wn(),n.$$.dirty[0]&128&&pn()},[u,L,N,D,ne,we,fe,x,le,C,se,s,i,_n,at,b,A,B,q,T,ee,te,W,V,k,S,E,y,re,he,ye,X,P,a,pe,bt,yt,_t,kn,wt,Ee,pt,Et,oe,l,d,h,Cn,xn,An]}class tt extends Xt{constructor(e){super(),Yt(this,e,an,un,At,{auto:0,blockspam:16,challengeurl:15,challengejson:31,debug:17,delay:18,expire:19,floating:1,floatinganchor:20,floatingoffset:21,hidefooter:2,hidelogo:3,name:4,maxnumber:22,mockerror:23,obfuscated:24,plugins:32,refetchonexpire:25,spamfilter:26,strings:33,test:27,verifyurl:28,workers:29,workerurl:30,clarify:34,configure:35,getConfiguration:36,getFloatingAnchor:37,getPlugin:38,getState:39,reset:40,setFloatingAnchor:41,setState:42,verify:43},null,[-1,-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),p()}get blockspam(){return this.$$.ctx[16]}set blockspam(e){this.$$set({blockspam:e}),p()}get challengeurl(){return this.$$.ctx[15]}set challengeurl(e){this.$$set({challengeurl:e}),p()}get challengejson(){return this.$$.ctx[31]}set challengejson(e){this.$$set({challengejson:e}),p()}get debug(){return this.$$.ctx[17]}set debug(e){this.$$set({debug:e}),p()}get delay(){return this.$$.ctx[18]}set delay(e){this.$$set({delay:e}),p()}get expire(){return this.$$.ctx[19]}set expire(e){this.$$set({expire:e}),p()}get floating(){return this.$$.ctx[1]}set floating(e){this.$$set({floating:e}),p()}get floatinganchor(){return this.$$.ctx[20]}set floatinganchor(e){this.$$set({floatinganchor:e}),p()}get floatingoffset(){return this.$$.ctx[21]}set floatingoffset(e){this.$$set({floatingoffset:e}),p()}get hidefooter(){return this.$$.ctx[2]}set hidefooter(e){this.$$set({hidefooter:e}),p()}get hidelogo(){return this.$$.ctx[3]}set hidelogo(e){this.$$set({hidelogo:e}),p()}get name(){return this.$$.ctx[4]}set name(e){this.$$set({name:e}),p()}get maxnumber(){return this.$$.ctx[22]}set maxnumber(e){this.$$set({maxnumber:e}),p()}get mockerror(){return this.$$.ctx[23]}set mockerror(e){this.$$set({mockerror:e}),p()}get obfuscated(){return this.$$.ctx[24]}set obfuscated(e){this.$$set({obfuscated:e}),p()}get plugins(){return this.$$.ctx[32]}set plugins(e){this.$$set({plugins:e}),p()}get refetchonexpire(){return this.$$.ctx[25]}set refetchonexpire(e){this.$$set({refetchonexpire:e}),p()}get spamfilter(){return this.$$.ctx[26]}set spamfilter(e){this.$$set({spamfilter:e}),p()}get strings(){return this.$$.ctx[33]}set strings(e){this.$$set({strings:e}),p()}get test(){return this.$$.ctx[27]}set test(e){this.$$set({test:e}),p()}get verifyurl(){return this.$$.ctx[28]}set verifyurl(e){this.$$set({verifyurl:e}),p()}get workers(){return this.$$.ctx[29]}set workers(e){this.$$set({workers:e}),p()}get workerurl(){return this.$$.ctx[30]}set workerurl(e){this.$$set({workerurl:e}),p()}get clarify(){return this.$$.ctx[34]}get configure(){return this.$$.ctx[35]}get getConfiguration(){return this.$$.ctx[36]}get getFloatingAnchor(){return this.$$.ctx[37]}get getPlugin(){return this.$$.ctx[38]}get getState(){return this.$$.ctx[39]}get reset(){return this.$$.ctx[40]}get setFloatingAnchor(){return this.$$.ctx[41]}get setState(){return this.$$.ctx[42]}get verify(){return this.$$.ctx[43]}}customElements.define("altcha-widget",Wt(tt,{auto:{},blockspam:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},delay:{},expire:{},floating:{},floatinganchor:{},floatingoffset:{},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},obfuscated:{},plugins:{},refetchonexpire:{type:"Boolean"},spamfilter:{type:"Boolean"},strings:{},test:{type:"Boolean"},verifyurl:{},workers:{},workerurl:{}},["default"],["clarify","configure","getConfiguration","getFloatingAnchor","getPlugin","getState","reset","setFloatingAnchor","setState","verify"],!1)),globalThis.altchaCreateWorker=n=>new Worker(new URL(n||"./worker.js",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:H&&H.src||new URL("altcha.umd.cjs",document.baseURI).href)),globalThis.altchaPlugins=globalThis.altchaPlugins||[],$.Altcha=tt,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})}); diff --git a/dist_plugins/analytics.d.ts b/dist_plugins/analytics.d.ts new file mode 100644 index 0000000..f3f39ea --- /dev/null +++ b/dist_plugins/analytics.d.ts @@ -0,0 +1 @@ +declare module 'altcha/analytics'; \ No newline at end of file diff --git a/dist_plugins/analytics.js b/dist_plugins/analytics.js new file mode 100644 index 0000000..5e158e5 --- /dev/null +++ b/dist_plugins/analytics.js @@ -0,0 +1,290 @@ +var y = Object.defineProperty; +var p = (s) => { + throw TypeError(s); +}; +var C = (s, t, e) => t in s ? y(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e; +var l = (s, t, e) => C(s, typeof t != "symbol" ? t + "" : t, e), F = (s, t, e) => t.has(s) || p("Cannot " + e); +var i = (s, t, e) => (F(s, t, "read from private field"), e ? e.call(s) : t.get(s)), r = (s, t, e) => t.has(s) ? p("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, e), T = (s, t, e, n) => (F(s, t, "write to private field"), n ? n.call(s, e) : t.set(s, e), e), E = (s, t, e) => (F(s, t, "access private method"), e); +new TextEncoder(); +function L() { + try { + return Intl.DateTimeFormat().resolvedOptions().timeZone; + } catch { + } +} +class v { + /** + * Constructs a new instance of the Plugin. + * + * @param {PluginContext} context - The context provided to the plugin, containing necessary configurations and dependencies. + */ + constructor(t) { + this.context = t; + } + /** + * Registers a plugin class in the global `altchaPlugins` array. + * Ensures the plugin is added only once. + * + * @param {new(context: PluginContext) => Plugin} cls - The plugin class to register. + */ + static register(t) { + typeof globalThis.altchaPlugins != "object" && (globalThis.altchaPlugins = []), globalThis.altchaPlugins.includes(t) || globalThis.altchaPlugins.push(t); + } + /** + * Clean up resources when the plugin is destroyed. + * Override this method in subclasses to implement custom destruction logic. + */ + destroy() { + } + /** + * Callback triggered when an error changes. + * Override this method in subclasses to handle error state changes. + * + * @param {string | null} err - The error message or `null` if there's no error. + */ + onErrorChange(t) { + } + /** + * Callback triggered when the plugin state changes. + * Override this method in subclasses to handle state changes. + * + * @param {State} state - The new state of the plugin. + */ + onStateChange(t) { + } +} +/** + * A distinct name of the plugin. Every plugin must have it's own name. + */ +l(v, "pluginName"); +var o, a, m, f, w; +class A extends v { + /** + * Creates an instance of PluginAnalytics. + * + * @param {PluginContext} context - The context object containing plugin configurations. + */ + constructor(e) { + super(e); + r(this, f); + // HTML form element associated with the plugin + r(this, o); + // Session instance for tracking analytics data + r(this, a); + // Bound method for form submission handling + r(this, m, E(this, f, w).bind(this)); + if (T(this, o, this.context.el.closest("form")), i(this, o)) { + let n = i(this, o).getAttribute("data-beacon-url"); + const h = i(this, o).getAttribute("action"); + !n && h && (n = h + "/beacon"), i(this, o).addEventListener("submit", i(this, m)), T(this, a, new N(i(this, o), n)); + } + } + /** + * Destroys the plugin instance, removing event listeners and cleaning up the session. + */ + destroy() { + var e, n; + (e = i(this, o)) == null || e.removeEventListener("submit", i(this, m)), (n = i(this, a)) == null || n.destroy(); + } + /** + * Tracks errors by forwarding them to the session instance. + * + * @param {string | null} err - The error message, or `null` if no error exists. + */ + onErrorChange(e) { + var n; + (n = i(this, a)) == null || n.trackError(e); + } +} +o = new WeakMap(), a = new WeakMap(), m = new WeakMap(), f = new WeakSet(), /** + * Handles form submission events, appending session data to the form if applicable. + */ +w = function() { + var e; + if (i(this, a) && !i(this, a).submitTime) { + i(this, a).end(); + const n = i(this, a).dataAsBase64(); + this.context.dispatch("session", n); + const h = document.createElement("input"); + h.type = "hidden", h.name = "__session", h.value = n, (e = i(this, o)) == null || e.appendChild(h); + } +}, l(A, "pluginName", "analytics"); +var c, u, d, g, b; +class N { + /** + * Creates a new Session instance. + * + * @param {HTMLFormElement} elForm - The form element being tracked. + * @param {string | null} [beaconUrl=null] - The URL to send analytics data to. + */ + constructor(t, e = null) { + // Error message associated with the session + l(this, "error", null); + // Timestamp when the form was loaded + l(this, "loadTime", Date.now()); + // Timestamp when the form was submitted + l(this, "submitTime", null); + // Timestamp when the user started interacting with the form + l(this, "startTime", null); + // Minimum time in milliseconds required to consider the form "viewed" + l(this, "viewTimeThresholdMs", 1500); + // Tracks the number of changes made to each form field + r(this, c, {}); + // Name of the last input field focused by the user + r(this, u, null); + // Bound method for handling form change events + r(this, d, this.onFormChange.bind(this)); + // Bound method for handling form focus events + r(this, g, this.onFormFocus.bind(this)); + // Bound method for handling the unload event + r(this, b, this.onUnload.bind(this)); + this.elForm = t, this.beaconUrl = e, window.addEventListener("unload", i(this, b)), this.elForm.addEventListener("change", i(this, d)), this.elForm.addEventListener("focusin", i(this, g)); + } + /** + * Collects and returns analytics data about the form interaction. + * + * @returns {Record} - An object containing analytics data. + */ + data() { + const t = Object.entries(i(this, c)); + return { + correction: t.length && t.filter(([e, n]) => n > 1).length / t.length || 0, + dropoff: !this.submitTime && !this.error && i(this, u) ? i(this, u) : null, + error: this.error, + mobile: this.isMobile(), + start: this.startTime, + submit: this.submitTime, + tz: L() + }; + } + /** + * Encodes the session data as a base64 string. + * + * @returns {string} - The base64-encoded session data. + */ + dataAsBase64() { + try { + return btoa(JSON.stringify(this.data())); + } catch (t) { + console.error("failed to encode ALTCHA session data to base64", t); + } + return ""; + } + /** + * Destroys the session, removing event listeners. + */ + destroy() { + window.removeEventListener("unload", i(this, b)), this.elForm.removeEventListener("change", i(this, d)), this.elForm.removeEventListener("focusin", i(this, g)); + } + /** + * Marks the session as ended by recording the submission time. + */ + end() { + this.submitTime || (this.submitTime = Date.now()); + } + /** + * Retrieves the name of a form field, including a group label if available. + * + * @param {HTMLInputElement} el - The input element. + * @param {number} [maxLength=40] - The maximum length of the field name. + * @returns {string} - The field name, truncated to `maxLength` if necessary. + */ + getFieldName(t, e = 40) { + const n = t.getAttribute("data-group-label"), h = t.getAttribute("name") || t.getAttribute("aria-label"); + return ((n ? n + ": " : "") + h).slice(0, e); + } + /** + * Determines if the current device is a mobile device. + * + * @returns {boolean} - `true` if the device is mobile, otherwise `false`. + */ + isMobile() { + const t = "userAgentData" in navigator && navigator.userAgentData ? navigator.userAgentData : {}; + return "mobile" in t ? t.mobile === !0 : /Mobi/i.test(window.navigator.userAgent); + } + /** + * Checks if a given element is an input element (input, select, or textarea). + * + * @param {HTMLElement} el - The element to check. + * @returns {boolean} - `true` if the element is an input, otherwise `false`. + */ + isInput(t) { + return ["INPUT", "SELECT", "TEXTAREA"].includes(t.tagName); + } + /** + * Tracks changes to a specific form field. + * + * @param {HTMLInputElement} el - The input element that changed. + */ + onFormFieldChange(t) { + const e = this.getFieldName(t); + e && this.trackFieldChange(e); + } + /** + * Handles form change events, tracking changes to input fields. + * + * @param {Event} ev - The change event. + */ + onFormChange(t) { + const e = t.target; + e && this.isInput(e) && this.onFormFieldChange(e); + } + /** + * Handles form focus events, marking the session start time and tracking the last focused field. + * + * @param {FocusEvent} ev - The focus event. + */ + onFormFocus(t) { + const e = t.target; + if (this.startTime || this.start(), e && this.isInput(e)) { + const n = this.getFieldName(e); + n && T(this, u, n); + } + } + /** + * Handles the window unload event, sending a beacon with session data if the form was viewed but not submitted. + */ + onUnload() { + this.loadTime <= Date.now() - this.viewTimeThresholdMs && !this.submitTime && this.sendBeacon(); + } + /** + * Sends a beacon with session data to the specified beacon URL. + */ + async sendBeacon() { + if (this.beaconUrl && "sendBeacon" in navigator) + try { + navigator.sendBeacon( + new URL(this.beaconUrl, location.origin), + JSON.stringify(this.data()) + ); + } catch { + } + } + /** + * Marks the session as started by recording the start time. + */ + start() { + this.startTime = Date.now(); + } + /** + * Tracks an error associated with the session. + * + * @param {string | null} err - The error message, or `null` if no error exists. + */ + trackError(t) { + this.error = t === null ? null : String(t); + } + /** + * Tracks a change to a specific form field. + * + * @param {string} name - The name of the form field. + */ + trackFieldChange(t) { + i(this, c)[t] = (i(this, c)[t] || 0) + 1; + } +} +c = new WeakMap(), u = new WeakMap(), d = new WeakMap(), g = new WeakMap(), b = new WeakMap(); +v.register(A); +export { + A as PluginAnalytics +}; diff --git a/dist_plugins/analytics.umd.cjs b/dist_plugins/analytics.umd.cjs new file mode 100644 index 0000000..9e8919b --- /dev/null +++ b/dist_plugins/analytics.umd.cjs @@ -0,0 +1 @@ +(function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e["[name]"]={}))})(this,function(e){"use strict";var N=Object.defineProperty;var A=e=>{throw TypeError(e)};var S=(e,i,o)=>i in e?N(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o;var c=(e,i,o)=>S(e,typeof i!="symbol"?i+"":i,o),y=(e,i,o)=>i.has(e)||A("Cannot "+o);var s=(e,i,o)=>(y(e,i,"read from private field"),o?o.call(e):i.get(e)),l=(e,i,o)=>i.has(e)?A("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(e):i.set(e,o),v=(e,i,o,d)=>(y(e,i,"write to private field"),d?d.call(e,o):i.set(e,o),o),w=(e,i,o)=>(y(e,i,"access private method"),o);var a,h,b,F,C,m,g,f,T,p;new TextEncoder;function i(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}class o{constructor(t){this.context=t}static register(t){typeof globalThis.altchaPlugins!="object"&&(globalThis.altchaPlugins=[]),globalThis.altchaPlugins.includes(t)||globalThis.altchaPlugins.push(t)}destroy(){}onErrorChange(t){}onStateChange(t){}}c(o,"pluginName");class d extends o{constructor(n){super(n);l(this,F);l(this,a);l(this,h);l(this,b,w(this,F,C).bind(this));if(v(this,a,this.context.el.closest("form")),s(this,a)){let r=s(this,a).getAttribute("data-beacon-url");const u=s(this,a).getAttribute("action");!r&&u&&(r=u+"/beacon"),s(this,a).addEventListener("submit",s(this,b)),v(this,h,new L(s(this,a),r))}}destroy(){var n,r;(n=s(this,a))==null||n.removeEventListener("submit",s(this,b)),(r=s(this,h))==null||r.destroy()}onErrorChange(n){var r;(r=s(this,h))==null||r.trackError(n)}}a=new WeakMap,h=new WeakMap,b=new WeakMap,F=new WeakSet,C=function(){var n;if(s(this,h)&&!s(this,h).submitTime){s(this,h).end();const r=s(this,h).dataAsBase64();this.context.dispatch("session",r);const u=document.createElement("input");u.type="hidden",u.name="__session",u.value=r,(n=s(this,a))==null||n.appendChild(u)}},c(d,"pluginName","analytics");class L{constructor(t,n=null){c(this,"error",null);c(this,"loadTime",Date.now());c(this,"submitTime",null);c(this,"startTime",null);c(this,"viewTimeThresholdMs",1500);l(this,m,{});l(this,g,null);l(this,f,this.onFormChange.bind(this));l(this,T,this.onFormFocus.bind(this));l(this,p,this.onUnload.bind(this));this.elForm=t,this.beaconUrl=n,window.addEventListener("unload",s(this,p)),this.elForm.addEventListener("change",s(this,f)),this.elForm.addEventListener("focusin",s(this,T))}data(){const t=Object.entries(s(this,m));return{correction:t.length&&t.filter(([n,r])=>r>1).length/t.length||0,dropoff:!this.submitTime&&!this.error&&s(this,g)?s(this,g):null,error:this.error,mobile:this.isMobile(),start:this.startTime,submit:this.submitTime,tz:i()}}dataAsBase64(){try{return btoa(JSON.stringify(this.data()))}catch(t){console.error("failed to encode ALTCHA session data to base64",t)}return""}destroy(){window.removeEventListener("unload",s(this,p)),this.elForm.removeEventListener("change",s(this,f)),this.elForm.removeEventListener("focusin",s(this,T))}end(){this.submitTime||(this.submitTime=Date.now())}getFieldName(t,n=40){const r=t.getAttribute("data-group-label"),u=t.getAttribute("name")||t.getAttribute("aria-label");return((r?r+": ":"")+u).slice(0,n)}isMobile(){const t="userAgentData"in navigator&&navigator.userAgentData?navigator.userAgentData:{};return"mobile"in t?t.mobile===!0:/Mobi/i.test(window.navigator.userAgent)}isInput(t){return["INPUT","SELECT","TEXTAREA"].includes(t.tagName)}onFormFieldChange(t){const n=this.getFieldName(t);n&&this.trackFieldChange(n)}onFormChange(t){const n=t.target;n&&this.isInput(n)&&this.onFormFieldChange(n)}onFormFocus(t){const n=t.target;if(this.startTime||this.start(),n&&this.isInput(n)){const r=this.getFieldName(n);r&&v(this,g,r)}}onUnload(){this.loadTime<=Date.now()-this.viewTimeThresholdMs&&!this.submitTime&&this.sendBeacon()}async sendBeacon(){if(this.beaconUrl&&"sendBeacon"in navigator)try{navigator.sendBeacon(new URL(this.beaconUrl,location.origin),JSON.stringify(this.data()))}catch{}}start(){this.startTime=Date.now()}trackError(t){this.error=t===null?null:String(t)}trackFieldChange(t){s(this,m)[t]=(s(this,m)[t]||0)+1}}m=new WeakMap,g=new WeakMap,f=new WeakMap,T=new WeakMap,p=new WeakMap,o.register(d),e.PluginAnalytics=d,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}); diff --git a/dist_plugins/obfuscation.d.ts b/dist_plugins/obfuscation.d.ts new file mode 100644 index 0000000..d4522a9 --- /dev/null +++ b/dist_plugins/obfuscation.d.ts @@ -0,0 +1 @@ +declare module 'altcha/obfuscation'; \ No newline at end of file diff --git a/dist_plugins/obfuscation.js b/dist_plugins/obfuscation.js new file mode 100644 index 0000000..803b4d2 --- /dev/null +++ b/dist_plugins/obfuscation.js @@ -0,0 +1,130 @@ +var D = Object.defineProperty; +var B = (t) => { + throw TypeError(t); +}; +var V = (t, e, i) => e in t ? D(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i; +var f = (t, e, i) => V(t, typeof e != "symbol" ? e + "" : e, i), b = (t, e, i) => e.has(t) || B("Cannot " + i); +var p = (t, e, i) => (b(t, e, "read from private field"), i ? i.call(t) : e.get(t)), g = (t, e, i) => e.has(t) ? B("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i); +var E = (t, e, i) => (b(t, e, "access private method"), i); +class y { + /** + * Constructs a new instance of the Plugin. + * + * @param {PluginContext} context - The context provided to the plugin, containing necessary configurations and dependencies. + */ + constructor(e) { + this.context = e; + } + /** + * Registers a plugin class in the global `altchaPlugins` array. + * Ensures the plugin is added only once. + * + * @param {new(context: PluginContext) => Plugin} cls - The plugin class to register. + */ + static register(e) { + typeof globalThis.altchaPlugins != "object" && (globalThis.altchaPlugins = []), globalThis.altchaPlugins.includes(e) || globalThis.altchaPlugins.push(e); + } + /** + * Clean up resources when the plugin is destroyed. + * Override this method in subclasses to implement custom destruction logic. + */ + destroy() { + } + /** + * Callback triggered when an error changes. + * Override this method in subclasses to handle error state changes. + * + * @param {string | null} err - The error message or `null` if there's no error. + */ + onErrorChange(e) { + } + /** + * Callback triggered when the plugin state changes. + * Override this method in subclasses to handle state changes. + * + * @param {State} state - The new state of the plugin. + */ + onStateChange(e) { + } +} +/** + * A distinct name of the plugin. Every plugin must have it's own name. + */ +f(y, "pluginName"); +var l = /* @__PURE__ */ ((t) => (t.ERROR = "error", t.VERIFIED = "verified", t.VERIFYING = "verifying", t.UNVERIFIED = "unverified", t.EXPIRED = "expired", t))(l || {}), r, a, I, x; +class v extends y { + /** + * Creates an instance of PluginObfuscation. + * + * @param {PluginContext} context - The context object containing plugin configurations. + */ + constructor(i) { + var n, o; + super(i); + g(this, a); + // The button element associated with revealing the obfuscated data + f(this, "elButton"); + // Bound method for handling button click events + g(this, r, E(this, a, I).bind(this)); + const s = i.el; + this.elButton = ((n = s.parentElement) == null ? void 0 : n.querySelector("[data-clarify-button]")) || ((o = s.parentElement) == null ? void 0 : o.querySelector("button, a")), this.elButton && this.elButton.addEventListener("click", p(this, r)); + } + /** + * Destroys the plugin instance, removing event listeners. + */ + destroy() { + this.elButton && this.elButton.removeEventListener("click", p(this, r)); + } + /** + * Handles the clarification process by decrypting the obfuscated data and rendering the clear text. + */ + async clarify() { + const { el: i, getConfiguration: s, getFloatingAnchor: n, setFloatingAnchor: o, reset: d, solve: P, setState: m } = this.context, { delay: C, floating: F, maxnumber: T, obfuscated: R } = s(); + if (this.elButton && !n() && o(this.elButton), !R) { + m(l.ERROR); + return; + } + d(l.VERIFYING), await new Promise((h) => setTimeout(h, C || 0)); + const [k, N] = R.split("?"); + let c = new URLSearchParams(N || "").get("key") || void 0; + if (c) { + const h = c.match(/^\(prompt:?(.*)\)$/); + h && (c = prompt(h[1] || "Enter Key:") || void 0); + } + const { solution: u } = await P({ + obfuscated: k, + key: c, + maxnumber: T + }); + u && "clearText" in u ? (E(this, a, x).call(this, u.clearText), m(l.VERIFIED), this.context.dispatch("cleartext", u.clearText), F && i && (i.style.display = "none")) : m(l.ERROR, "Unable to decrypt data."); + } +} +r = new WeakMap(), a = new WeakSet(), /** + * Handles the button click event, triggering the clarification process. + * + * @param {Event} ev - The click event. + */ +I = function(i) { + i.preventDefault(); + const { auto: s } = this.context.getConfiguration(); + s === "off" || this.clarify(); +}, /** + * Renders the clear text data by creating an appropriate element (e.g., a link or text node). + * + * @param {string} clearText - The decrypted clear text data to render. + */ +x = function(i) { + var o; + const s = i.match(/^(mailto|tel|sms|https?):/); + let n; + if (s) { + const [d] = i.slice(i.indexOf(":") + 1).replace(/^\/\//, "").split("?"); + n = document.createElement("a"), n.href = i, n.innerHTML = d; + } else + n = document.createTextNode(i); + this.elButton && n && (this.elButton.after(n), (o = this.elButton.parentElement) == null || o.removeChild(this.elButton)); +}, f(v, "pluginName", "obfuscation"); +y.register(v); +export { + v as PluginObfuscation +}; diff --git a/dist_plugins/obfuscation.umd.cjs b/dist_plugins/obfuscation.umd.cjs new file mode 100644 index 0000000..493715a --- /dev/null +++ b/dist_plugins/obfuscation.umd.cjs @@ -0,0 +1 @@ +(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e["[name]"]={}))})(this,function(e){"use strict";var D=Object.defineProperty;var v=e=>{throw TypeError(e)};var V=(e,t,i)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var p=(e,t,i)=>V(e,typeof t!="symbol"?t+"":t,i),x=(e,t,i)=>t.has(e)||v("Cannot "+i);var E=(e,t,i)=>(x(e,t,"read from private field"),i?i.call(e):t.get(e)),b=(e,t,i)=>t.has(e)?v("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i);var R=(e,t,i)=>(x(e,t,"access private method"),i);var u,c,I,P;class t{constructor(l){this.context=l}static register(l){typeof globalThis.altchaPlugins!="object"&&(globalThis.altchaPlugins=[]),globalThis.altchaPlugins.includes(l)||globalThis.altchaPlugins.push(l)}destroy(){}onErrorChange(l){}onStateChange(l){}}p(t,"pluginName");var i=(s=>(s.ERROR="error",s.VERIFIED="verified",s.VERIFYING="verifying",s.UNVERIFIED="unverified",s.EXPIRED="expired",s))(i||{});class m extends t{constructor(n){var o,r;super(n);b(this,c);p(this,"elButton");b(this,u,R(this,c,I).bind(this));const a=n.el;this.elButton=((o=a.parentElement)==null?void 0:o.querySelector("[data-clarify-button]"))||((r=a.parentElement)==null?void 0:r.querySelector("button, a")),this.elButton&&this.elButton.addEventListener("click",E(this,u))}destroy(){this.elButton&&this.elButton.removeEventListener("click",E(this,u))}async clarify(){const{el:n,getConfiguration:a,getFloatingAnchor:o,setFloatingAnchor:r,reset:g,solve:T,setState:y}=this.context,{delay:C,floating:F,maxnumber:k,obfuscated:B}=a();if(this.elButton&&!o()&&r(this.elButton),!B){y(i.ERROR);return}g(i.VERIFYING),await new Promise(d=>setTimeout(d,C||0));const[N,O]=B.split("?");let h=new URLSearchParams(O||"").get("key")||void 0;if(h){const d=h.match(/^\(prompt:?(.*)\)$/);d&&(h=prompt(d[1]||"Enter Key:")||void 0)}const{solution:f}=await T({obfuscated:N,key:h,maxnumber:k});f&&"clearText"in f?(R(this,c,P).call(this,f.clearText),y(i.VERIFIED),this.context.dispatch("cleartext",f.clearText),F&&n&&(n.style.display="none")):y(i.ERROR,"Unable to decrypt data.")}}u=new WeakMap,c=new WeakSet,I=function(n){n.preventDefault();const{auto:a}=this.context.getConfiguration();a==="off"||this.clarify()},P=function(n){var r;const a=n.match(/^(mailto|tel|sms|https?):/);let o;if(a){const[g]=n.slice(n.indexOf(":")+1).replace(/^\/\//,"").split("?");o=document.createElement("a"),o.href=n,o.innerHTML=g}else o=document.createTextNode(n);this.elButton&&o&&(this.elButton.after(o),(r=this.elButton.parentElement)==null||r.removeChild(this.elButton))},p(m,"pluginName","obfuscation"),t.register(m),e.PluginObfuscation=m,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}); diff --git a/dist_plugins/upload.d.ts b/dist_plugins/upload.d.ts new file mode 100644 index 0000000..cea300d --- /dev/null +++ b/dist_plugins/upload.d.ts @@ -0,0 +1 @@ +declare module 'altcha/upload'; \ No newline at end of file diff --git a/dist_plugins/upload.js b/dist_plugins/upload.js new file mode 100644 index 0000000..a8061bd --- /dev/null +++ b/dist_plugins/upload.js @@ -0,0 +1,446 @@ +var V = Object.defineProperty; +var K = (t) => { + throw TypeError(t); +}; +var J = (t, n, e) => n in t ? V(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e; +var p = (t, n, e) => J(t, typeof n != "symbol" ? n + "" : n, e), v = (t, n, e) => n.has(t) || K("Cannot " + e); +var h = (t, n, e) => (v(t, n, "read from private field"), e ? e.call(t) : n.get(t)), g = (t, n, e) => n.has(t) ? K("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(t) : n.set(t, e); +var u = (t, n, e) => (v(t, n, "access private method"), e); +const b = { + generateKey: X, + exportKey: Q, + importKey: W, + decrypt: ee, + encrypt: Z +}; +async function X(t = 256) { + return crypto.subtle.generateKey({ + name: "AES-GCM", + length: t + }, !0, ["encrypt", "decrypt"]); +} +async function Q(t) { + return new Uint8Array(await crypto.subtle.exportKey("raw", t)); +} +async function W(t) { + return crypto.subtle.importKey("raw", t, { + name: "AES-GCM" + }, !0, ["encrypt", "decrypt"]); +} +async function Z(t, n, e = 16) { + const i = crypto.getRandomValues(new Uint8Array(e)); + return { + encrypted: new Uint8Array(await crypto.subtle.encrypt({ + name: "AES-GCM", + iv: i + }, t, n)), + iv: i + }; +} +async function ee(t, n, e) { + return new Uint8Array(await crypto.subtle.decrypt({ + name: "AES-GCM", + iv: e + }, t, n)); +} +function te(t, n = !1) { + return n && (t = t.replace(/_/g, "/").replace(/-/g, "+") + "=".repeat(3 - (3 + t.length) % 4)), Uint8Array.from(atob(t), (e) => e.charCodeAt(0)); +} +function S(t, n = !1) { + const e = btoa(String.fromCharCode(...t)); + return n ? e.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "") : e; +} +function x(t, n = 80) { + let e = ""; + for (; t.length > 0; ) + e += t.slice(0, n) + ` +`, t = t.slice(n); + return e; +} +function L(t) { + return te(t.split(/\r?\n/).filter((n) => !n.startsWith("-----")).join("")); +} +const d = "RSA-OAEP", w = "SHA-256", ne = 2048, re = new Uint8Array([1, 0, 1]), ie = { + generateKeyPair: se, + encrypt: oe, + decrypt: ae, + exportPrivateKey: C, + exportPrivateKeyPem: le, + exportPublicKey: U, + exportPublicKeyPem: ce, + exportPublicKeyFromPrivateKey: ue, + importPrivateKey: z, + importPrivateKeyPem: pe, + importPublicKey: I, + importPublicKeyPem: N +}; +async function se() { + return crypto.subtle.generateKey({ + name: d, + modulusLength: ne, + publicExponent: re, + hash: w + }, !0, ["encrypt", "decrypt"]); +} +async function oe(t, n) { + return new Uint8Array(await crypto.subtle.encrypt({ + name: d + }, t, n)); +} +async function ae(t, n) { + return new Uint8Array(await crypto.subtle.decrypt({ + name: d + }, t, n)); +} +async function U(t) { + return new Uint8Array(await crypto.subtle.exportKey("spki", t)); +} +async function C(t) { + return new Uint8Array(await crypto.subtle.exportKey("pkcs8", t)); +} +async function ce(t) { + return `-----BEGIN PUBLIC KEY----- +` + x(S(await U(t)), 64) + "-----END PUBLIC KEY-----"; +} +async function le(t) { + return `-----BEGIN PRIVATE KEY----- +` + x(S(await C(t)), 64) + "-----END PRIVATE KEY-----"; +} +async function I(t) { + return crypto.subtle.importKey("spki", t, { + name: d, + hash: w + }, !0, ["encrypt"]); +} +async function N(t) { + return I(L(t)); +} +async function z(t) { + return crypto.subtle.importKey("pkcs8", t, { + name: d, + hash: w + }, !0, ["decrypt"]); +} +async function pe(t) { + return z(L(t)); +} +async function ue(t) { + const n = await crypto.subtle.exportKey("jwk", t); + delete n.d, delete n.dp, delete n.dq, delete n.q, delete n.qi, n.key_ops = ["encrypt"]; + const e = await crypto.subtle.importKey("jwk", n, { + name: d, + hash: w + }, !0, ["encrypt"]); + return U(e); +} +const ye = new Uint8Array([1, 0, 1]), de = 256, he = 16; +async function fe(t, n, e = {}) { + const { aesIVLength: i = he, aesKeyLength: r = de } = e, o = await b.generateKey(r), { encrypted: c, iv: s } = await b.encrypt(o, n, i), l = await ie.encrypt(t, await b.exportKey(o)); + return new Uint8Array([ + ...ye, + ...new Uint8Array([l.length]), + ...new Uint8Array([s.length]), + ...l, + ...s, + ...c + ]); +} +class A { + /** + * Constructs a new instance of the Plugin. + * + * @param {PluginContext} context - The context provided to the plugin, containing necessary configurations and dependencies. + */ + constructor(n) { + this.context = n; + } + /** + * Registers a plugin class in the global `altchaPlugins` array. + * Ensures the plugin is added only once. + * + * @param {new(context: PluginContext) => Plugin} cls - The plugin class to register. + */ + static register(n) { + typeof globalThis.altchaPlugins != "object" && (globalThis.altchaPlugins = []), globalThis.altchaPlugins.includes(n) || globalThis.altchaPlugins.push(n); + } + /** + * Clean up resources when the plugin is destroyed. + * Override this method in subclasses to implement custom destruction logic. + */ + destroy() { + } + /** + * Callback triggered when an error changes. + * Override this method in subclasses to handle error state changes. + * + * @param {string | null} err - The error message or `null` if there's no error. + */ + onErrorChange(n) { + } + /** + * Callback triggered when the plugin state changes. + * Override this method in subclasses to handle state changes. + * + * @param {State} state - The new state of the plugin. + */ + onStateChange(n) { + } +} +/** + * A distinct name of the plugin. Every plugin must have it's own name. + */ +p(A, "pluginName"); +var f, m, a, _, j, k, E, H, R, q, P, O, B, G; +class T extends A { + /** + * Constructor initializes the plugin, setting up event listeners on the form. + * + * @param {PluginContext} context - Plugin context providing access to the element, configuration, and utility methods. + */ + constructor(e) { + super(e); + g(this, a); + p(this, "pendingFiles", []); + p(this, "uploadHandles", []); + p(this, "elForm"); + g(this, f, u(this, a, R).bind(this)); + g(this, m, u(this, a, q).bind(this)); + this.elForm = this.context.el.closest("form"), this.elForm && (this.elForm.addEventListener("change", h(this, f)), this.elForm.addEventListener("submit", h(this, m), { + capture: !0 + })); + } + /** + * Adds a file to the pending files list for upload. + * + * @param {string} fieldName - The field name associated with the file input. + * @param {File} file - The file to be uploaded. + */ + addFile(e, i) { + this.pendingFiles.find(([r, o]) => r === e && o === i) || this.pendingFiles.push([e, i]); + } + /** + * Cleans up event listeners and other resources when the plugin is destroyed. + */ + destroy() { + this.elForm && (this.elForm.removeEventListener("change", h(this, f)), this.elForm.removeEventListener("submit", h(this, m))); + } + /** + * Uploads all pending files in the list. + */ + async uploadPendingFiles() { + var i; + const e = async () => { + const r = this.pendingFiles[0]; + if (r && await u(this, a, P).call(this, u(this, a, j).call(this, r)), this.pendingFiles.length) + return e(); + }; + await e(), this.pendingFiles.length === 0 && (u(this, a, _).call(this), (i = this.elForm) == null || i.requestSubmit()); + } +} +f = new WeakMap(), m = new WeakMap(), a = new WeakSet(), /** + * Adds hidden input fields to the form containing the file IDs of uploaded files. + */ +_ = function() { + var i, r, o; + const e = this.uploadHandles.reduce((c, s) => (c[s.fieldName] || (c[s.fieldName] = []), s.fileId && c[s.fieldName].push(s.fileId), c), {}); + for (const c in e) { + const s = document.createElement("input"); + s.name = c, s.type = "hidden", s.value = e[c].join(","), (r = (i = this.elForm) == null ? void 0 : i.querySelector(`[name="${c}"]`)) == null || r.setAttribute("disabled", "disabled"), (o = this.elForm) == null || o.appendChild(s); + } +}, /** + * Creates an upload handle for the specified pending file. + * + * @param {[string, File]} pendingFile - The field name and file to be uploaded. + * @returns {UploadHandle} The created upload handle. + * @throws Will throw an error if the upload handle cannot be created. + */ +j = function(e) { + const i = this.pendingFiles.findIndex(([o, c]) => o === e[0] && c === e[1]); + if (i < 0) + throw new Error("Cannot create upload handle."); + const r = new me(e[0], e[1]); + return this.uploadHandles.push(r), this.pendingFiles.splice(i, 1), u(this, a, k).call(this, r), u(this, a, E).call(this), r; +}, /** + * Dispatches a custom event when a file upload starts. + * + * @param {UploadHandle} handle - The upload handle associated with the file upload. + */ +k = function(e) { + this.context.dispatch("upload", { handle: e }); +}, /** + * Dispatches a custom event to track the progress of ongoing file uploads. + */ +E = function() { + const e = this.pendingFiles.reduce((r, [o, c]) => r + c.size, 0) + this.uploadHandles.reduce((r, { uploadSize: o }) => r + o, 0), i = this.uploadHandles.reduce((r, { loaded: o }) => r + o, 0); + this.context.dispatch("uploadprogress", { + bytesLoaded: i, + bytesTotal: e, + pendingFiles: this.pendingFiles, + uploadHandles: this.uploadHandles + }); +}, /** + * Retrieves the upload URL from the form's attributes. + * + * @returns {string | null} The upload URL, or null if not found. + */ +H = function() { + if (this.elForm) { + const e = this.elForm.getAttribute("action"); + return this.elForm.getAttribute("data-upload-url") || e + "/file"; + } + return null; +}, /** + * Handles the form's change event, adding files to the pending files list. + * + * @param {Event} ev - The change event. + */ +R = function(e) { + const i = e.target; + if (i && i.type === "file") { + const r = i.files; + if (r != null && r.length) + for (const o of r) + this.addFile(i.name, o); + } +}, /** + * Handles the form's submit event, preventing submission until all pending files are uploaded. + * + * @param {SubmitEvent} ev - The submit event. + */ +q = function(e) { + this.pendingFiles.length && (e.preventDefault(), e.stopPropagation(), this.uploadPendingFiles()); +}, P = async function(e, i) { + const r = u(this, a, H).call(this); + if (!r) + throw new Error("Upload url not specified."); + const o = { + "content-type": "application/json" + }; + i && (o.authorization = "Altcha payload=" + i); + const c = await fetch(r, { + body: JSON.stringify({ + name: e.file.name || "file", + size: e.file.size, + type: e.file.type || "application/octet-stream" + }), + credentials: "include", + headers: o, + method: "POST" + }); + if (c.status === 401) + return u(this, a, O).call(this, c, e); + if (c.status !== 200) + throw new Error(`Unexpected server response ${c.status}.`); + const s = await c.json(); + let l = e.file; + if (s.encrypted && s.encryptionPublicKey) { + const y = await N(s.encryptionPublicKey), M = await new Response( + new ReadableStream({ + async start(F) { + const $ = e.file.stream().getReader(); + for (; ; ) { + const { done: Y, value: D } = await $.read(); + if (Y) + break; + F.enqueue(D); + } + F.close(); + } + }) + ).arrayBuffer(); + l = await fe(y, new Uint8Array(M)); + } + return e.uploadSize = l instanceof Uint8Array ? l.byteLength : e.file.size, await u(this, a, G).call(this, s.uploadUrl, e, l, { + "content-type": e.file.type || "application/octet-stream" + }), s.finalizeUrl && await u(this, a, B).call(this, s.finalizeUrl, e.uploadSize), e.fileId = s.fileId, e.resolve({ + encrypted: s.encrypted, + fileId: s.fileId + }), e.promise; +}, O = async function(e, i) { + var r; + try { + const o = e.headers.get("www-authenticate"), c = (r = o == null ? void 0 : o.match(/challenge=(.*),/)) == null ? void 0 : r[1]; + if (!c) + throw new Error("Unable to retrieve altcha challenge from www-authenticate header."); + const s = JSON.parse(c); + if (s && "challenge" in s) { + const { solution: l } = await this.context.solve(s); + if (l && "number" in l) + return u(this, a, P).call(this, i, btoa(JSON.stringify({ + ...s, + number: l.number + }))); + throw new Error("Invalid challenge solution."); + } + } catch (o) { + throw this.context.log(o), new Error("Unable to solve altcha challenge for upload."); + } +}, B = async function(e, i) { + const r = await fetch(e, { + body: JSON.stringify({ + uploadedBytes: i + }), + headers: { + "content-type": "application/json" + }, + method: "POST" + }); + if (r.status > 204) + throw new Error(`Unexpected server response ${r.status}.`); + return !0; +}, G = async function(e, i, r, o = {}) { + return new Promise((c, s) => { + const l = new XMLHttpRequest(); + i.controller.signal.addEventListener("abort", () => { + l.abort(); + }), l.upload.addEventListener("progress", (y) => { + i.setProgress(y.loaded), u(this, a, E).call(this); + }), l.addEventListener("error", (y) => { + s(new Error("Upload failed.")); + }), l.addEventListener("load", () => { + c(void 0); + }), l.open("PUT", e); + for (const y in o) + l.setRequestHeader(y, o[y]); + l.send(r); + }); +}, p(T, "pluginName", "upload"); +class me { + /** + * Creates an instance of UploadHandle. + * + * @param {string} fieldName - The name of the field associated with the file upload. + * @param {File} file - The file to be uploaded. + */ + constructor(n, e) { + p(this, "controller", new AbortController()); + p(this, "promise"); + p(this, "fileId"); + p(this, "loaded", 0); + p(this, "progress", 0); + p(this, "uploadSize", 0); + p(this, "resolve"); + p(this, "reject"); + this.fieldName = n, this.file = e, this.uploadSize = this.file.size, this.promise = new Promise((i, r) => { + this.resolve = i, this.reject = r; + }); + } + /** + * Aborts the file upload by invoking the AbortController's abort method. + */ + abort() { + this.controller.abort(); + } + /** + * Updates the progress of the file upload. + * + * @param {number} loaded - The number of bytes that have been uploaded. + */ + setProgress(n) { + this.loaded = n, this.progress = this.file.size && n ? Math.min(1, n / this.file.size) : 0; + } +} +A.register(T); +export { + T as PluginUpload +}; diff --git a/dist_plugins/upload.umd.cjs b/dist_plugins/upload.umd.cjs new file mode 100644 index 0000000..9004c92 --- /dev/null +++ b/dist_plugins/upload.umd.cjs @@ -0,0 +1,4 @@ +(function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c["[name]"]={}))})(this,function(c){"use strict";var me=Object.defineProperty;var j=c=>{throw TypeError(c)};var ge=(c,a,d)=>a in c?me(c,a,{enumerable:!0,configurable:!0,writable:!0,value:d}):c[a]=d;var y=(c,a,d)=>ge(c,typeof a!="symbol"?a+"":a,d),_=(c,a,d)=>a.has(c)||j("Cannot "+d);var b=(c,a,d)=>(_(c,a,"read from private field"),d?d.call(c):a.get(c)),P=(c,a,d)=>a.has(c)?j("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(c):a.set(c,d);var h=(c,a,d)=>(_(c,a,"access private method"),d);var g,w,l,k,H,R,K,O,q,M,v,B,G,$;const a={generateKey:d,exportKey:Y,importKey:D,decrypt:J,encrypt:V};async function d(t=256){return crypto.subtle.generateKey({name:"AES-GCM",length:t},!0,["encrypt","decrypt"])}async function Y(t){return new Uint8Array(await crypto.subtle.exportKey("raw",t))}async function D(t){return crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!0,["encrypt","decrypt"])}async function V(t,n,e=16){const i=crypto.getRandomValues(new Uint8Array(e));return{encrypted:new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:i},t,n)),iv:i}}async function J(t,n,e){return new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:e},t,n))}function X(t,n=!1){return n&&(t=t.replace(/_/g,"/").replace(/-/g,"+")+"=".repeat(3-(3+t.length)%4)),Uint8Array.from(atob(t),e=>e.charCodeAt(0))}function S(t,n=!1){const e=btoa(String.fromCharCode(...t));return n?e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):e}function x(t,n=80){let e="";for(;t.length>0;)e+=t.slice(0,n)+` +`,t=t.slice(n);return e}function L(t){return X(t.split(/\r?\n/).filter(n=>!n.startsWith("-----")).join(""))}const m="RSA-OAEP",E="SHA-256",Q=2048,W=new Uint8Array([1,0,1]),Z={generateKeyPair:ee,encrypt:te,decrypt:ne,exportPrivateKey:C,exportPrivateKeyPem:ie,exportPublicKey:U,exportPublicKeyPem:re,exportPublicKeyFromPrivateKey:oe,importPrivateKey:N,importPrivateKeyPem:se,importPublicKey:I,importPublicKeyPem:T};async function ee(){return crypto.subtle.generateKey({name:m,modulusLength:Q,publicExponent:W,hash:E},!0,["encrypt","decrypt"])}async function te(t,n){return new Uint8Array(await crypto.subtle.encrypt({name:m},t,n))}async function ne(t,n){return new Uint8Array(await crypto.subtle.decrypt({name:m},t,n))}async function U(t){return new Uint8Array(await crypto.subtle.exportKey("spki",t))}async function C(t){return new Uint8Array(await crypto.subtle.exportKey("pkcs8",t))}async function re(t){return`-----BEGIN PUBLIC KEY----- +`+x(S(await U(t)),64)+"-----END PUBLIC KEY-----"}async function ie(t){return`-----BEGIN PRIVATE KEY----- +`+x(S(await C(t)),64)+"-----END PRIVATE KEY-----"}async function I(t){return crypto.subtle.importKey("spki",t,{name:m,hash:E},!0,["encrypt"])}async function T(t){return I(L(t))}async function N(t){return crypto.subtle.importKey("pkcs8",t,{name:m,hash:E},!0,["decrypt"])}async function se(t){return N(L(t))}async function oe(t){const n=await crypto.subtle.exportKey("jwk",t);delete n.d,delete n.dp,delete n.dq,delete n.q,delete n.qi,n.key_ops=["encrypt"];const e=await crypto.subtle.importKey("jwk",n,{name:m,hash:E},!0,["encrypt"]);return U(e)}const ae=new Uint8Array([1,0,1]),ce=256,le=16;async function pe(t,n,e={}){const{aesIVLength:i=le,aesKeyLength:r=ce}=e,o=await a.generateKey(r),{encrypted:p,iv:s}=await a.encrypt(o,n,i),u=await Z.encrypt(t,await a.exportKey(o));return new Uint8Array([...ae,...new Uint8Array([u.length]),...new Uint8Array([s.length]),...u,...s,...p])}class A{constructor(n){this.context=n}static register(n){typeof globalThis.altchaPlugins!="object"&&(globalThis.altchaPlugins=[]),globalThis.altchaPlugins.includes(n)||globalThis.altchaPlugins.push(n)}destroy(){}onErrorChange(n){}onStateChange(n){}}y(A,"pluginName");class F extends A{constructor(e){super(e);P(this,l);y(this,"pendingFiles",[]);y(this,"uploadHandles",[]);y(this,"elForm");P(this,g,h(this,l,q).bind(this));P(this,w,h(this,l,M).bind(this));this.elForm=this.context.el.closest("form"),this.elForm&&(this.elForm.addEventListener("change",b(this,g)),this.elForm.addEventListener("submit",b(this,w),{capture:!0}))}addFile(e,i){this.pendingFiles.find(([r,o])=>r===e&&o===i)||this.pendingFiles.push([e,i])}destroy(){this.elForm&&(this.elForm.removeEventListener("change",b(this,g)),this.elForm.removeEventListener("submit",b(this,w)))}async uploadPendingFiles(){var i;const e=async()=>{const r=this.pendingFiles[0];if(r&&await h(this,l,v).call(this,h(this,l,H).call(this,r)),this.pendingFiles.length)return e()};await e(),this.pendingFiles.length===0&&(h(this,l,k).call(this),(i=this.elForm)==null||i.requestSubmit())}}g=new WeakMap,w=new WeakMap,l=new WeakSet,k=function(){var i,r,o;const e=this.uploadHandles.reduce((p,s)=>(p[s.fieldName]||(p[s.fieldName]=[]),s.fileId&&p[s.fieldName].push(s.fileId),p),{});for(const p in e){const s=document.createElement("input");s.name=p,s.type="hidden",s.value=e[p].join(","),(r=(i=this.elForm)==null?void 0:i.querySelector(`[name="${p}"]`))==null||r.setAttribute("disabled","disabled"),(o=this.elForm)==null||o.appendChild(s)}},H=function(e){const i=this.pendingFiles.findIndex(([o,p])=>o===e[0]&&p===e[1]);if(i<0)throw new Error("Cannot create upload handle.");const r=new ue(e[0],e[1]);return this.uploadHandles.push(r),this.pendingFiles.splice(i,1),h(this,l,R).call(this,r),h(this,l,K).call(this),r},R=function(e){this.context.dispatch("upload",{handle:e})},K=function(){const e=this.pendingFiles.reduce((r,[o,p])=>r+p.size,0)+this.uploadHandles.reduce((r,{uploadSize:o})=>r+o,0),i=this.uploadHandles.reduce((r,{loaded:o})=>r+o,0);this.context.dispatch("uploadprogress",{bytesLoaded:i,bytesTotal:e,pendingFiles:this.pendingFiles,uploadHandles:this.uploadHandles})},O=function(){if(this.elForm){const e=this.elForm.getAttribute("action");return this.elForm.getAttribute("data-upload-url")||e+"/file"}return null},q=function(e){const i=e.target;if(i&&i.type==="file"){const r=i.files;if(r!=null&&r.length)for(const o of r)this.addFile(i.name,o)}},M=function(e){this.pendingFiles.length&&(e.preventDefault(),e.stopPropagation(),this.uploadPendingFiles())},v=async function(e,i){const r=h(this,l,O).call(this);if(!r)throw new Error("Upload url not specified.");const o={"content-type":"application/json"};i&&(o.authorization="Altcha payload="+i);const p=await fetch(r,{body:JSON.stringify({name:e.file.name||"file",size:e.file.size,type:e.file.type||"application/octet-stream"}),credentials:"include",headers:o,method:"POST"});if(p.status===401)return h(this,l,B).call(this,p,e);if(p.status!==200)throw new Error(`Unexpected server response ${p.status}.`);const s=await p.json();let u=e.file;if(s.encrypted&&s.encryptionPublicKey){const f=await T(s.encryptionPublicKey),de=await new Response(new ReadableStream({async start(z){const ye=e.file.stream().getReader();for(;;){const{done:he,value:fe}=await ye.read();if(he)break;z.enqueue(fe)}z.close()}})).arrayBuffer();u=await pe(f,new Uint8Array(de))}return e.uploadSize=u instanceof Uint8Array?u.byteLength:e.file.size,await h(this,l,$).call(this,s.uploadUrl,e,u,{"content-type":e.file.type||"application/octet-stream"}),s.finalizeUrl&&await h(this,l,G).call(this,s.finalizeUrl,e.uploadSize),e.fileId=s.fileId,e.resolve({encrypted:s.encrypted,fileId:s.fileId}),e.promise},B=async function(e,i){var r;try{const o=e.headers.get("www-authenticate"),p=(r=o==null?void 0:o.match(/challenge=(.*),/))==null?void 0:r[1];if(!p)throw new Error("Unable to retrieve altcha challenge from www-authenticate header.");const s=JSON.parse(p);if(s&&"challenge"in s){const{solution:u}=await this.context.solve(s);if(u&&"number"in u)return h(this,l,v).call(this,i,btoa(JSON.stringify({...s,number:u.number})));throw new Error("Invalid challenge solution.")}}catch(o){throw this.context.log(o),new Error("Unable to solve altcha challenge for upload.")}},G=async function(e,i){const r=await fetch(e,{body:JSON.stringify({uploadedBytes:i}),headers:{"content-type":"application/json"},method:"POST"});if(r.status>204)throw new Error(`Unexpected server response ${r.status}.`);return!0},$=async function(e,i,r,o={}){return new Promise((p,s)=>{const u=new XMLHttpRequest;i.controller.signal.addEventListener("abort",()=>{u.abort()}),u.upload.addEventListener("progress",f=>{i.setProgress(f.loaded),h(this,l,K).call(this)}),u.addEventListener("error",f=>{s(new Error("Upload failed."))}),u.addEventListener("load",()=>{p(void 0)}),u.open("PUT",e);for(const f in o)u.setRequestHeader(f,o[f]);u.send(r)})},y(F,"pluginName","upload");class ue{constructor(n,e){y(this,"controller",new AbortController);y(this,"promise");y(this,"fileId");y(this,"loaded",0);y(this,"progress",0);y(this,"uploadSize",0);y(this,"resolve");y(this,"reject");this.fieldName=n,this.file=e,this.uploadSize=this.file.size,this.promise=new Promise((i,r)=>{this.resolve=i,this.reject=r})}abort(){this.controller.abort()}setProgress(n){this.loaded=n,this.progress=this.file.size&&n?Math.min(1,n/this.file.size):0}}A.register(F),c.PluginUpload=F,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}); diff --git a/package-lock.json b/package-lock.json index cebe6a9..5cb976a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,34 +1,39 @@ { "name": "altcha", - "version": "0.8.0", + "version": "0.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "altcha", - "version": "0.8.0", + "version": "0.9.0", "license": "MIT", + "dependencies": { + "@altcha/crypto": "^0.0.1" + }, "devDependencies": { - "@playwright/test": "^1.44.1", - "@sveltejs/vite-plugin-svelte": "^3.0.2", - "@tsconfig/svelte": "^5.0.0", - "@types/node": "^20.11.19", - "body-parser": "^1.20.2", - "cors": "^2.8.5", - "express": "^4.18.2", - "husky": "^9.0.11", + "@playwright/test": "^1.46.1", + "@sveltejs/vite-plugin-svelte": "^3.1.1", + "@tsconfig/svelte": "^5.0.4", + "@types/node": "^20.15.0", + "husky": "^9.1.4", "prettier": "3.2.5", - "prettier-plugin-svelte": "^3.2.3", + "prettier-plugin-svelte": "^3.2.6", "rollup-plugin-css-only": "^4.5.2", - "sass": "^1.71.1", - "svelte": "^4.2.11", - "svelte-check": "^3.4.6", - "tslib": "^2.6.0", - "typescript": "^5.0.2", - "vite": "^5.3.0", + "sass": "^1.77.8", + "svelte": "^4.2.18", + "svelte-check": "^3.8.5", + "tslib": "^2.6.3", + "typescript": "^5.5.4", + "vite": "^5.4.1", "vitest": "^0.34.6" } }, + "node_modules/@altcha/crypto": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@altcha/crypto/-/crypto-0.0.1.tgz", + "integrity": "sha512-qZMdnoD3lAyvfSUMNtC2adRi666Pxdcw9zqfMU5qBOaJWqpN9K+eqQGWqeiKDMqL0SF+EytNG4kR/Pr/99GJ6g==" + }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", @@ -42,70 +47,6 @@ "node": ">=6.0.0" } }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", - "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", - "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", - "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", - "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@esbuild/darwin-arm64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", @@ -122,294 +63,6 @@ "node": ">=12" } }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", - "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", - "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", - "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", - "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", - "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", - "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", - "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", - "cpu": [ - "loong64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", - "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", - "cpu": [ - "mips64el" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", - "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", - "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", - "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", - "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", - "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", - "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", - "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", - "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", - "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", - "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", @@ -422,297 +75,102 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", - "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", - "dev": true, - "dependencies": { - "@jridgewell/set-array": "^1.2.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/set-array": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", - "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", - "dev": true, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.25", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", - "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", - "dev": true, - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, - "node_modules/@playwright/test": { - "version": "1.45.3", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.45.3.tgz", - "integrity": "sha512-UKF4XsBfy+u3MFWEH44hva1Q8Da28G6RFtR2+5saw+jgAFQV5yYnB1fu68Mz7fO+5GJF3wgwAIs0UelU8TxFrA==", - "dev": true, - "dependencies": { - "playwright": "1.45.3" - }, - "bin": { - "playwright": "cli.js" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@rollup/pluginutils": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", - "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0", - "estree-walker": "^2.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" - }, - "peerDependenciesMeta": { - "rollup": { - "optional": true - } - } - }, - "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.19.1.tgz", - "integrity": "sha512-XzqSg714++M+FXhHfXpS1tDnNZNpgxxuGZWlRG/jSj+VEPmZ0yg6jV4E0AL3uyBKxO8mO3xtOsP5mQ+XLfrlww==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-android-arm64": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.19.1.tgz", - "integrity": "sha512-thFUbkHteM20BGShD6P08aungq4irbIZKUNbG70LN8RkO7YztcGPiKTTGZS7Kw+x5h8hOXs0i4OaHwFxlpQN6A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.19.1.tgz", - "integrity": "sha512-8o6eqeFZzVLia2hKPUZk4jdE3zW7LCcZr+MD18tXkgBBid3lssGVAYuox8x6YHoEPDdDa9ixTaStcmx88lio5Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.19.1.tgz", - "integrity": "sha512-4T42heKsnbjkn7ovYiAdDVRRWZLU9Kmhdt6HafZxFcUdpjlBlxj4wDrt1yFWLk7G4+E+8p2C9tcmSu0KA6auGA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.19.1.tgz", - "integrity": "sha512-MXg1xp+e5GhZ3Vit1gGEyoC+dyQUBy2JgVQ+3hUrD9wZMkUw/ywgkpK7oZgnB6kPpGrxJ41clkPPnsknuD6M2Q==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.19.1.tgz", - "integrity": "sha512-DZNLwIY4ftPSRVkJEaxYkq7u2zel7aah57HESuNkUnz+3bZHxwkCUkrfS2IWC1sxK6F2QNIR0Qr/YXw7nkF3Pw==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.19.1.tgz", - "integrity": "sha512-C7evongnjyxdngSDRRSQv5GvyfISizgtk9RM+z2biV5kY6S/NF/wta7K+DanmktC5DkuaJQgoKGf7KUDmA7RUw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.19.1.tgz", - "integrity": "sha512-89tFWqxfxLLHkAthAcrTs9etAoBFRduNfWdl2xUs/yLV+7XDrJ5yuXMHptNqf1Zw0UCA3cAutkAiAokYCkaPtw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.19.1.tgz", - "integrity": "sha512-PromGeV50sq+YfaisG8W3fd+Cl6mnOOiNv2qKKqKCpiiEke2KiKVyDqG/Mb9GWKbYMHj5a01fq/qlUR28PFhCQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.19.1.tgz", - "integrity": "sha512-/1BmHYh+iz0cNCP0oHCuF8CSiNj0JOGf0jRlSo3L/FAyZyG2rGBuKpkZVH9YF+x58r1jgWxvm1aRg3DHrLDt6A==", - "cpu": [ - "riscv64" - ], + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", "dev": true, - "optional": true, - "os": [ - "linux" - ] + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } }, - "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.19.1.tgz", - "integrity": "sha512-0cYP5rGkQWRZKy9/HtsWVStLXzCF3cCBTRI+qRL8Z+wkYlqN7zrSYm6FuY5Kd5ysS5aH0q5lVgb/WbG4jqXN1Q==", - "cpu": [ - "s390x" - ], + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true, - "optional": true, - "os": [ - "linux" - ] + "engines": { + "node": ">=6.0.0" + } }, - "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.19.1.tgz", - "integrity": "sha512-XUXeI9eM8rMP8aGvii/aOOiMvTs7xlCosq9xCjcqI9+5hBxtjDpD+7Abm1ZhVIFE1J2h2VIg0t2DX/gjespC2Q==", - "cpu": [ - "x64" - ], + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", "dev": true, - "optional": true, - "os": [ - "linux" - ] + "engines": { + "node": ">=6.0.0" + } }, - "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.19.1.tgz", - "integrity": "sha512-V7cBw/cKXMfEVhpSvVZhC+iGifD6U1zJ4tbibjjN+Xi3blSXaj/rJynAkCFFQfoG6VZrAiP7uGVzL440Q6Me2Q==", - "cpu": [ - "x64" - ], + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "dev": true, - "optional": true, - "os": [ - "linux" - ] + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } }, - "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.19.1.tgz", - "integrity": "sha512-88brja2vldW/76jWATlBqHEoGjJLRnP0WOEKAUbMcXaAZnemNhlAHSyj4jIwMoP2T750LE9lblvD4e2jXleZsA==", - "cpu": [ - "arm64" - ], + "node_modules/@playwright/test": { + "version": "1.46.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.46.1.tgz", + "integrity": "sha512-Fq6SwLujA/DOIvNC2EL/SojJnkKf/rAwJ//APpJJHRyMi1PdKrY3Az+4XNQ51N4RTbItbIByQ0jgd1tayq1aeA==", "dev": true, - "optional": true, - "os": [ - "win32" - ] + "dependencies": { + "playwright": "1.46.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } }, - "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.19.1.tgz", - "integrity": "sha512-LdxxcqRVSXi6k6JUrTah1rHuaupoeuiv38du8Mt4r4IPer3kwlTo+RuvfE8KzZ/tL6BhaPlzJ3835i6CxrFIRQ==", - "cpu": [ - "ia32" - ], + "node_modules/@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", "dev": true, - "optional": true, - "os": [ - "win32" - ] + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } }, - "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.19.1.tgz", - "integrity": "sha512-2bIrL28PcK3YCqD9anGxDxamxdiJAxA+l7fWIwM5o8UqNy1t3d1NdAweO2XhA0KTDJ5aH1FsuiT5+7VhtHliXg==", + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.20.0.tgz", + "integrity": "sha512-uFVfvzvsdGtlSLuL0ZlvPJvl6ZmrH4CBwLGEFPe7hUmf7htGAN+aXo43R/V6LATyxlKVC/m6UsLb7jbG+LG39Q==", "cpu": [ - "x64" + "arm64" ], "dev": true, "optional": true, "os": [ - "win32" + "darwin" ] }, "node_modules/@sinclair/typebox": { @@ -767,9 +225,9 @@ "dev": true }, "node_modules/@types/chai": { - "version": "4.3.16", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.16.tgz", - "integrity": "sha512-PatH4iOdyh3MyWtmHVFXLWCCIhUbopaltqddG9BzB+gMIzee2MJrvd+jouii9Z3wzQJruGWAm7WOMjgfG8hQlQ==", + "version": "4.3.17", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.17.tgz", + "integrity": "sha512-zmZ21EWzR71B4Sscphjief5djsLre50M6lI622OSySTmn9DB3j+C3kWroHfBQWXbOBwbgg/M8CG/hUxDLIloow==", "dev": true }, "node_modules/@types/chai-subset": { @@ -788,12 +246,12 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.14.13", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.13.tgz", - "integrity": "sha512-+bHoGiZb8UiQ0+WEtmph2IWQCjIqg8MDZMAV+ppRRhUZnquF5mQkP/9vpSwJClEiSM/C7fZZExPzfU0vJTyp8w==", + "version": "20.15.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.15.0.tgz", + "integrity": "sha512-eQf4OkH6gA9v1W0iEpht/neozCsZKMTK+C4cU6/fv7wtJCCL8LEQ4hie2Ln8ZP/0YYM2xGj7//f8xyqItkJ6QA==", "dev": true, "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.13.0" } }, "node_modules/@types/pug": { @@ -870,19 +328,6 @@ "url": "https://opencollective.com/vitest" } }, - "node_modules/accepts": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", - "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", - "dev": true, - "dependencies": { - "mime-types": "~2.1.34", - "negotiator": "0.6.3" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/acorn": { "version": "8.12.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", @@ -941,12 +386,6 @@ "dequal": "^2.0.3" } }, - "node_modules/array-flatten": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", - "dev": true - }, "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -983,45 +422,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/body-parser": { - "version": "1.20.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", - "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", - "dev": true, - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.5", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.2", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, - "node_modules/body-parser/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/body-parser/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1053,15 +453,6 @@ "node": ">=8.0.0" } }, - "node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -1071,25 +462,6 @@ "node": ">=8" } }, - "node_modules/call-bind": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", - "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", - "dev": true, - "dependencies": { - "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.4", - "set-function-length": "^1.2.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/chai": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/chai/-/chai-4.5.0.tgz", @@ -1178,55 +550,6 @@ "integrity": "sha512-uJcB/FKZtBMCJpK8MQji6bJHgu1tixKPxRLeGkNzBoOZzpnZUJm0jm2/sBDWcuBx1dYgxV4JU+g5hmNxCyAmdA==", "dev": true }, - "node_modules/content-disposition": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", - "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", - "dev": true, - "dependencies": { - "safe-buffer": "5.2.1" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/content-type": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", - "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie-signature": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", - "dev": true - }, - "node_modules/cors": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", - "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", - "dev": true, - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - } - }, "node_modules/css-tree": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", @@ -1278,32 +601,6 @@ "node": ">=0.10.0" } }, - "node_modules/define-data-property": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", - "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", - "dev": true, - "dependencies": { - "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "gopd": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -1313,16 +610,6 @@ "node": ">=6" } }, - "node_modules/destroy": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", - "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", - "dev": true, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, "node_modules/detect-indent": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", @@ -1341,42 +628,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", - "dev": true - }, - "node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/es-define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", - "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", - "dev": true, - "dependencies": { - "get-intrinsic": "^1.2.4" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "dev": true, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/es6-promise": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", @@ -1421,145 +672,22 @@ "@esbuild/win32-x64": "0.21.5" } }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "dev": true - }, "node_modules/estree-walker": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", "dev": true }, - "node_modules/etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/express": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", - "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", - "dev": true, - "dependencies": { - "accepts": "~1.3.8", - "array-flatten": "1.1.1", - "body-parser": "1.20.2", - "content-disposition": "0.5.4", - "content-type": "~1.0.4", - "cookie": "0.6.0", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "2.0.0", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "1.2.0", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.7", - "qs": "6.11.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - }, - "engines": { - "node": ">= 0.10.0" - } - }, - "node_modules/express/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/express/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", - "dev": true, - "dependencies": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "statuses": "2.0.1", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/finalhandler/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/finalhandler/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, - "node_modules/forwarded": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, "engines": { - "node": ">= 0.6" + "node": ">=8" } }, "node_modules/fs.realpath": { @@ -1582,15 +710,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/get-func-name": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", @@ -1600,25 +719,6 @@ "node": "*" } }, - "node_modules/get-intrinsic": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", - "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", - "dev": true, - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", - "has-proto": "^1.0.1", - "has-symbols": "^1.0.3", - "hasown": "^2.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -1652,88 +752,12 @@ "node": ">= 6" } }, - "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", - "dev": true, - "dependencies": { - "get-intrinsic": "^1.1.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true }, - "node_modules/has-property-descriptors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", - "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", - "dev": true, - "dependencies": { - "es-define-property": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-proto": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", - "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dev": true, - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/http-errors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", - "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", - "dev": true, - "dependencies": { - "depd": "2.0.0", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "toidentifier": "1.0.1" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/husky": { "version": "9.1.4", "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.4.tgz", @@ -1749,18 +773,6 @@ "url": "https://github.com/sponsors/typicode" } }, - "node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/immutable": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.7.tgz", @@ -1784,15 +796,6 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "node_modules/ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "dev": true, - "engines": { - "node": ">= 0.10" - } - }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -1895,63 +898,6 @@ "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", "dev": true }, - "node_modules/media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", - "dev": true - }, - "node_modules/methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true, - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dev": true, - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -2039,15 +985,6 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, - "node_modules/negotiator": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -2057,39 +994,6 @@ "node": ">=0.10.0" } }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-inspect": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", - "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", - "dev": true, - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -2114,15 +1018,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -2132,12 +1027,6 @@ "node": ">=0.10.0" } }, - "node_modules/path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==", - "dev": true - }, "node_modules/pathe": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", @@ -2203,12 +1092,12 @@ } }, "node_modules/playwright": { - "version": "1.45.3", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.45.3.tgz", - "integrity": "sha512-QhVaS+lpluxCaioejDZ95l4Y4jSFCsBvl2UZkpeXlzxmqS+aABr5c82YmfMHrL6x27nvrvykJAFpkzT2eWdJww==", + "version": "1.46.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.46.1.tgz", + "integrity": "sha512-oPcr1yqoXLCkgKtD5eNUPLiN40rYEM39odNpIb6VE6S7/15gJmA1NzVv6zJYusV0e7tzvkU/utBFNa/Kpxmwng==", "dev": true, "dependencies": { - "playwright-core": "1.45.3" + "playwright-core": "1.46.1" }, "bin": { "playwright": "cli.js" @@ -2221,9 +1110,9 @@ } }, "node_modules/playwright-core": { - "version": "1.45.3", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.45.3.tgz", - "integrity": "sha512-+ym0jNbcjikaOwwSZycFbwkWgfruWvYlJfThKYAlImbxUgdWFO2oW70ojPm4OpE4t6TAo2FY/smM+hpVTtkhDA==", + "version": "1.46.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.46.1.tgz", + "integrity": "sha512-h9LqIQaAv+CYvWzsZ+h3RsrqCStkBHlgo6/TJlFst3cOTlLghBQlJwPOZKQJTKNaD3QIB7aAVQ+gfWbN3NXB7A==", "dev": true, "bin": { "playwright-core": "cli.js" @@ -2233,9 +1122,9 @@ } }, "node_modules/postcss": { - "version": "8.4.40", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.40.tgz", - "integrity": "sha512-YF2kKIUzAofPMpfH6hOi2cGnv/HrUlfucspc7pDyvv7kGdqXrfj8SCl/t8owkEgKEuu8ZcRjSOxFxVLqwChZ2Q==", + "version": "8.4.41", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.41.tgz", + "integrity": "sha512-TesUflQ0WKZqAvg52PWL6kHgLKP6xB6heTOdoYM0Wt2UHyxNa4K25EZZMgKns3BH1RLVbZCREPpLY0rhnNoHVQ==", "dev": true, "funding": [ { @@ -2299,58 +1188,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/proxy-addr": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", - "dev": true, - "dependencies": { - "forwarded": "0.2.0", - "ipaddr.js": "1.9.1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/raw-body": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", - "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", - "dev": true, - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", @@ -2383,9 +1220,9 @@ } }, "node_modules/rollup": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.19.1.tgz", - "integrity": "sha512-K5vziVlg7hTpYfFBI+91zHBEMo6jafYXpkMlqZjg7/zhIG9iHqazBf4xz9AVdjS9BruRn280ROqLI7G3OFRIlw==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.20.0.tgz", + "integrity": "sha512-6rbWBChcnSGzIlXeIdNIZTopKYad8ZG8ajhl78lGRLsI2rX8IkaotQhVas2Ma+GPxJav19wrSzvRvuiv0YKzWw==", "dev": true, "dependencies": { "@types/estree": "1.0.5" @@ -2398,22 +1235,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.19.1", - "@rollup/rollup-android-arm64": "4.19.1", - "@rollup/rollup-darwin-arm64": "4.19.1", - "@rollup/rollup-darwin-x64": "4.19.1", - "@rollup/rollup-linux-arm-gnueabihf": "4.19.1", - "@rollup/rollup-linux-arm-musleabihf": "4.19.1", - "@rollup/rollup-linux-arm64-gnu": "4.19.1", - "@rollup/rollup-linux-arm64-musl": "4.19.1", - "@rollup/rollup-linux-powerpc64le-gnu": "4.19.1", - "@rollup/rollup-linux-riscv64-gnu": "4.19.1", - "@rollup/rollup-linux-s390x-gnu": "4.19.1", - "@rollup/rollup-linux-x64-gnu": "4.19.1", - "@rollup/rollup-linux-x64-musl": "4.19.1", - "@rollup/rollup-win32-arm64-msvc": "4.19.1", - "@rollup/rollup-win32-ia32-msvc": "4.19.1", - "@rollup/rollup-win32-x64-msvc": "4.19.1", + "@rollup/rollup-android-arm-eabi": "4.20.0", + "@rollup/rollup-android-arm64": "4.20.0", + "@rollup/rollup-darwin-arm64": "4.20.0", + "@rollup/rollup-darwin-x64": "4.20.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.20.0", + "@rollup/rollup-linux-arm-musleabihf": "4.20.0", + "@rollup/rollup-linux-arm64-gnu": "4.20.0", + "@rollup/rollup-linux-arm64-musl": "4.20.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.20.0", + "@rollup/rollup-linux-riscv64-gnu": "4.20.0", + "@rollup/rollup-linux-s390x-gnu": "4.20.0", + "@rollup/rollup-linux-x64-gnu": "4.20.0", + "@rollup/rollup-linux-x64-musl": "4.20.0", + "@rollup/rollup-win32-arm64-msvc": "4.20.0", + "@rollup/rollup-win32-ia32-msvc": "4.20.0", + "@rollup/rollup-win32-x64-msvc": "4.20.0", "fsevents": "~2.3.2" } }, @@ -2444,32 +1281,6 @@ "node": ">=6" } }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, "node_modules/sander": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/sander/-/sander-0.5.1.tgz", @@ -2499,107 +1310,6 @@ "node": ">=14.0.0" } }, - "node_modules/send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", - "dev": true, - "dependencies": { - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "mime": "1.6.0", - "ms": "2.1.3", - "on-finished": "2.4.1", - "range-parser": "~1.2.1", - "statuses": "2.0.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/send/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/send/node_modules/debug/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, - "node_modules/send/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "node_modules/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", - "dev": true, - "dependencies": { - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.18.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/set-function-length": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", - "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", - "dev": true, - "dependencies": { - "define-data-property": "^1.1.4", - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.4", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "dev": true - }, - "node_modules/side-channel": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", - "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.4", - "object-inspect": "^1.13.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/siginfo": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", @@ -2636,15 +1346,6 @@ "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", "dev": true }, - "node_modules/statuses": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/std-env": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", @@ -2701,9 +1402,9 @@ } }, "node_modules/svelte-check": { - "version": "3.8.4", - "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-3.8.4.tgz", - "integrity": "sha512-61aHMkdinWyH8BkkTX9jPLYxYzaAAz/FK/VQqdr2FiCQQ/q04WCwDlpGbHff1GdrMYTmW8chlTFvRWL9k0A8vg==", + "version": "3.8.5", + "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-3.8.5.tgz", + "integrity": "sha512-3OGGgr9+bJ/+1nbPgsvulkLC48xBsqsgtc8Wam281H4G9F5v3mYGa2bHRsPuwHC5brKl4AxJH95QF73kmfihGQ==", "dev": true, "dependencies": { "@jridgewell/trace-mapping": "^0.3.17", @@ -2804,9 +1505,9 @@ } }, "node_modules/tinybench": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.8.0.tgz", - "integrity": "sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", "dev": true }, "node_modules/tinypool": { @@ -2839,15 +1540,6 @@ "node": ">=8.0" } }, - "node_modules/toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "dev": true, - "engines": { - "node": ">=0.6" - } - }, "node_modules/tslib": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", @@ -2863,19 +1555,6 @@ "node": ">=4" } }, - "node_modules/type-is": { - "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "dev": true, - "dependencies": { - "media-typer": "0.3.0", - "mime-types": "~2.1.24" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/typescript": { "version": "5.5.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", @@ -2896,46 +1575,19 @@ "dev": true }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz", + "integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==", "dev": true }, - "node_modules/unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", - "dev": true, - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/vite": { - "version": "5.3.5", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.5.tgz", - "integrity": "sha512-MdjglKR6AQXQb9JGiS7Rc2wC6uMjcm7Go/NHNO63EwiJXfuk9PgqiP/n5IDJCziMkfw9n4Ubp7lttNwz+8ZVKA==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.1.tgz", + "integrity": "sha512-1oE6yuNXssjrZdblI9AfBbHCC41nnyoVoEZxQnID6yvQZAFBzxxkqoFLtHUMkYunL8hwOLEjgTuxpkRxvba3kA==", "dev": true, "dependencies": { "esbuild": "^0.21.3", - "postcss": "^8.4.39", + "postcss": "^8.4.41", "rollup": "^4.13.0" }, "bin": { @@ -2955,6 +1607,7 @@ "less": "*", "lightningcss": "^1.21.0", "sass": "*", + "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" @@ -2972,6 +1625,9 @@ "sass": { "optional": true }, + "sass-embedded": { + "optional": true + }, "stylus": { "optional": true }, diff --git a/package.json b/package.json index 3b7f6e0..e8113a1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "altcha", "description": "GDPR compliant, self-hosted CAPTCHA alternative.", - "version": "0.8.0", + "version": "0.9.0", "license": "MIT", "author": { "name": "Daniel Regeci", @@ -28,7 +28,8 @@ ], "files": [ "dist", - "dist_external" + "dist_external", + "dist_plugins" ], "main": "./dist/altcha.umd.cjs", "module": "./dist/altcha.js", @@ -41,20 +42,33 @@ "import": "./dist_external/altcha.css", "require": "./dist_external/altcha.css" }, - "./external/altcha.js": { + "./analytics": { + "import": "./dist_plugins/analytics.js", + "require": "./dist_plugins/analytics.umd.cjs" + }, + "./obfuscation": { + "import": "./dist_plugins/obfuscation.js", + "require": "./dist_plugins/obfuscation.umd.cjs" + }, + "./upload": { + "import": "./dist_plugins/upload.js", + "require": "./dist_plugins/upload.umd.cjs" + }, + "./altcha.ext": { "import": "./dist_external/altcha.js", "require": "./dist_external/altcha.umd.cjs" }, - "./external/worker.js": { + "./worker": { "import": "./dist_external/worker.js", "require": "./dist_external/worker.js" } }, "scripts": { "dev": "vite", - "build": "npm run build:bundle && npm run build:external", + "build": "npm run build:bundle && npm run build:external && npm run build:plugins", "build:bundle": "rimraf dist && vite build && cp src/declarations.d.ts dist/altcha.d.ts", - "build:external": "rimraf dist_external && BUILD_EXTERNAL=1 vite build && cp src/declarations.d.ts dist_external/altcha.d.ts", + "build:external": "rimraf dist_external && vite build -c vite.external.config.ts && cp src/declarations.d.ts dist_external/altcha.d.ts", + "build:plugins": "rimraf dist_plugins && find src/plugins -type f -name '*.ts' | xargs -I {} vite build -c vite.plugins.config.ts -- {}", "preview": "vite preview", "check": "svelte-check --tsconfig ./tsconfig.json", "format": "prettier --write ./src/**/*", @@ -63,23 +77,26 @@ "prepare": "husky" }, "devDependencies": { - "@playwright/test": "^1.44.1", - "@sveltejs/vite-plugin-svelte": "^3.0.2", - "@tsconfig/svelte": "^5.0.0", - "@types/node": "^20.11.19", - "body-parser": "^1.20.2", - "cors": "^2.8.5", - "express": "^4.18.2", - "husky": "^9.0.11", + "@playwright/test": "^1.46.1", + "@sveltejs/vite-plugin-svelte": "^3.1.1", + "@tsconfig/svelte": "^5.0.4", + "@types/node": "^20.15.0", + "husky": "^9.1.4", "prettier": "3.2.5", - "prettier-plugin-svelte": "^3.2.3", + "prettier-plugin-svelte": "^3.2.6", "rollup-plugin-css-only": "^4.5.2", - "sass": "^1.71.1", - "svelte": "^4.2.11", - "svelte-check": "^3.4.6", - "tslib": "^2.6.0", - "typescript": "^5.0.2", - "vite": "^5.3.0", + "sass": "^1.77.8", + "svelte": "^4.2.18", + "svelte-check": "^3.8.5", + "tslib": "^2.6.3", + "typescript": "^5.5.4", + "vite": "^5.4.1", "vitest": "^0.34.6" - } + }, + "dependencies": { + "@altcha/crypto": "^0.0.1" + }, + "optionalDependencies": { + "@rollup/rollup-linux-x64-gnu": "4.18.0" + } } diff --git a/src/Altcha.svelte b/src/Altcha.svelte index 60304ba..085ac7d 100644 --- a/src/Altcha.svelte +++ b/src/Altcha.svelte @@ -13,8 +13,8 @@ getTimeZone, clarifyData, } from './helpers'; - import { Session } from './session'; import { State } from './types'; + import type { Plugin } from './plugin'; import type { Configure, Payload, @@ -24,11 +24,10 @@ ServerVerificationPayload, Obfuscated, ClarifySolution, + PluginContext, } from './types'; - export let analytics: boolean = false; - export let auto: 'onfocus' | 'onload' | 'onsubmit' | undefined = undefined; - export let beaconurl: string | undefined = undefined; + export let auto: 'off' | 'onfocus' | 'onload' | 'onsubmit' | undefined = undefined; export let blockspam: boolean | undefined = undefined; export let challengeurl: string | undefined = undefined; export let challengejson: string | undefined = undefined; @@ -51,6 +50,7 @@ export let maxnumber: number = 1e6; export let mockerror: boolean = false; export let obfuscated: string | undefined = undefined; + export let plugins: string | undefined = undefined; export let refetchonexpire: boolean = true; export let spamfilter: boolean | 'ipAddress' | SpamFilter = false; export let strings: string | undefined = undefined; @@ -66,17 +66,14 @@ const documentLocale = document.documentElement.lang?.split('-')?.[0]; let checked: boolean = false; - let clarifiedData: string | null = null; let el: HTMLElement; let elAnchorArrow: HTMLElement | null = null; let elFloatingAnchor: HTMLElement | null = null; let elForm: HTMLFormElement | null = null; - let elClarifyButton: HTMLElement | null = null; let error: string | null = null; let expireTimeout: ReturnType | null = null; let payload: string | null = null; - let session: Session | null = null; - let sessionPayload: string | null = null; + let loadedPlugins: Plugin[] = []; let state: State = State.UNVERIFIED; $: isFreeSaaS = @@ -97,27 +94,18 @@ waitAlert: 'Verifying... please wait.', ...parsedStrings, }; - $: dispatch( - 'statechange', - clarifiedData ? { clarifiedData, state } : { payload, state } - ); + $: dispatch('statechange', { payload, state }); $: onErrorChange(error); $: onStateChange(state); - $: onClarifiedDataChange(clarifiedData); onDestroy(() => { + destroyPlugins(); if (elForm) { elForm.removeEventListener('submit', onFormSubmit); elForm.removeEventListener('reset', onFormReset); elForm.removeEventListener('focusin', onFormFocusIn); elForm = null; } - if (elClarifyButton) { - el.removeEventListener('click', onClarifyClick); - } - if (session) { - session.destroy(); - } if (expireTimeout) { clearTimeout(expireTimeout); expireTimeout = null; @@ -130,6 +118,13 @@ onMount(() => { log('mounted', ALTCHA_VERSION); log('workers', workers); + loadPlugins(); + log( + 'plugins', + loadedPlugins.length + ? loadedPlugins.map((plugin) => (plugin.constructor as any).pluginName).join(', ') + : 'none' + ); if (test) { log('using test mode'); } @@ -152,15 +147,6 @@ elForm.addEventListener('focusin', onFormFocusIn); } } - elClarifyButton = - el.parentElement?.querySelector('[data-clarify-button]') || - (el.parentElement?.querySelector('button, a') as HTMLElement | null); - if (elClarifyButton) { - elClarifyButton.addEventListener('click', onClarifyClick); - } - if (analytics) { - enableAnalytics(); - } if (auto === 'onload') { if (obfuscated) { clarify(); @@ -170,60 +156,17 @@ } if (isFreeSaaS && (hidefooter || hidelogo)) { log( - 'Attributes hidefooter and hidelogo ignored because usage with free API Keys require attribution.' + 'Attributes hidefooter and hidelogo ignored because usage with free API Keys requires attribution.' ); } + requestAnimationFrame(() => { + dispatch('load'); + }); }); - function log(...args: any[]) { - if (debug || args.some((a) => a instanceof Error)) { - console[args[0] instanceof Error ? 'error' : 'log']('ALTCHA', ...args); - } - } - - function onClarifyClick(ev: Event) { - ev.preventDefault(); - if (state === State.UNVERIFIED) { - clarify(); - } - } - - function onFormFocusIn(ev: FocusEvent) { - if (state === State.UNVERIFIED) { - verify(); - } - } - - function onFormSubmit(ev: SubmitEvent) { - if (elForm && session && state === State.VERIFIED) { - session.end(); - sessionPayload = session.dataAsBase64(); - } - if (elForm && auto === 'onsubmit') { - if (state === State.UNVERIFIED) { - ev.preventDefault(); - ev.stopPropagation(); - verify().then(() => { - elForm?.requestSubmit(); - }); - } else if (state !== State.VERIFIED) { - ev.preventDefault(); - ev.stopPropagation(); - if (state === State.VERIFYING) { - onInvalid(); - } - } - } - } - - function onFormReset() { - reset(); - } - - function parseJsonAttribute(str: string) { - return JSON.parse(str); - } - + /** + * Creates a Base64-encoded payload with solution. + */ function createAltchaPayload(data: Challenge, solution: Solution): string { return btoa( JSON.stringify({ @@ -238,26 +181,30 @@ ); } - function validateChallenge(data: Challenge) { - if (!data.algorithm) { - throw new Error(`Invalid challenge. Property algorithm is missing.`); - } - if (data.signature === undefined) { - throw new Error('Invalid challenge. Property signature is missing.'); - } - if (!allowedAlgs.includes(data.algorithm.toUpperCase())) { - throw new Error( - `Unknown algorithm value. Allowed values: ${allowedAlgs.join(', ')}` - ); + /** + * Destroys all loaded plugins. + */ + function destroyPlugins() { + for (const plugin of loadedPlugins) { + plugin.destroy(); } - if (!data.challenge || data.challenge.length < 40) { - throw new Error('Challenge is too short. Min. 40 chars.'); - } - if (!data.salt || data.salt.length < 10) { - throw new Error('Salt is too short. Min. 10 chars.'); + } + + /** + * Sets the state to EXPIRED or re-fetches the challenge if `refetchonexpire` is enabled. + */ + function expireChallenge() { + if (challengeurl && refetchonexpire && state === State.VERIFIED) { + // re-fetch challenge and verify again + verify(); + } else { + reset(State.EXPIRED, _strings.expired); } } + /** + * Fetches the challenge from the configured `challengeurl` or `challengejson`. + */ async function fetchChallenge(): Promise { if (mockerror) { log('mocking error'); @@ -332,115 +279,122 @@ } } - function enableAnalytics() { - if (session) { - // already enabled - return; - } - if (elForm) { - log('analytics enabled'); - session = new Session(elForm); - if (beaconurl === undefined) { - const action = elForm.getAttribute('action'); - if (action) { - beaconurl = action + '/beacon'; - } - } - session.beaconUrl = beaconurl || null; - } else { - log('analytics cannot be enabled - form element not found'); - } + /** + * Get the email field value fot the Spam Filter. + */ + function getEmail(name?: string) { + const elInput = elForm?.querySelector( + typeof name === 'string' + ? `input[name="${name}"]` + : 'input[type="email"]:not([data-no-spamfilter])' + ) as HTMLInputElement; + return elInput?.value?.slice(elInput.value.indexOf('@')) || void 1; } - function expireChallenge() { - if (challengeurl && refetchonexpire && state === State.VERIFIED) { - // re-fetch challenge and verify again - verify(); - } else { - reset(State.EXPIRED, _strings.expired); + /** + * Get configuration options for the Spam Filter. + */ + function getSpamFilterOptions(): SpamFilter { + if (spamfilter === 'ipAddress') { + return { + blockedCountries: undefined, + classifier: undefined, + disableRules: undefined, + email: false, + expectedCountries: undefined, + expectedLanguages: undefined, + fields: false, + ipAddress: undefined, + text: undefined, + timeZone: undefined, + }; } + return typeof spamfilter === 'object' + ? spamfilter + : { + blockedCountries: undefined, + classifier: undefined, + disableRules: undefined, + email: undefined, + expectedCountries: undefined, + expectedLanguages: undefined, + fields: undefined, + ipAddress: undefined, + text: undefined, + timeZone: undefined, + }; } - async function run(data: Challenge | Obfuscated): Promise<{ - data: Challenge | Obfuscated; - solution: Solution | ClarifySolution | null; - }> { - let solution: Solution | ClarifySolution | null = null; - if ('Worker' in window) { - try { - solution = await runWorker(data, data.maxnumber); - } catch (err) { - log(err); - } - if (solution?.number !== undefined || 'obfuscated' in data) { - return { - data, - solution, - }; + /** + * Get all text field values for the Spam Filter. + */ + function getTextFields(names?: string[]) { + const elInputs = [ + ...(elForm?.querySelectorAll( + names?.length + ? names.map((name) => `input[name="${name}"]`).join(', ') + : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])' + ) || []), + ] as HTMLInputElement[]; + return elInputs.reduce( + (acc, el) => { + const name = el.name; + const value = el.value; + if (name && value) { + acc[name] = /\n/.test(value) + ? value.replace(/(? + ); + } + + /** + * Loads the registered plugins. + */ + function loadPlugins() { + const enabledPlugins = + plugins !== undefined ? plugins.split(',') : undefined; + for (const Plugin of globalThis.altchaPlugins) { + if (!enabledPlugins || enabledPlugins.includes(Plugin.pluginName)) { + loadedPlugins.push( + new Plugin({ + el, + clarify, + dispatch, + getConfiguration, + getFloatingAnchor, + getState, + log, + reset, + solve, + setState, + setFloatingAnchor, + verify, + } satisfies PluginContext) + ); } } - if ('obfuscated' in data) { - const solution = await clarifyData( - data.obfuscated, - data.key, - data.maxnumber - ); - return { - data, - solution: await solution.promise, - }; - } - return { - data, - solution: await solveChallenge( - data.challenge, - data.salt, - data.algorithm, - data.maxnumber || maxnumber - ).promise, - }; } - async function runWorker( - challenge: Challenge | Obfuscated, - max: number = typeof test === 'number' ? test : maxnumber, - concurrency: number = Math.ceil(workers) - ): Promise { - const workers: Worker[] = []; - concurrency = Math.min(16, Math.max(1, concurrency)); - for (let i = 0; i < concurrency; i++) { - workers.push(createAltchaWorker(workerurl)); - } - const step = Math.ceil(max / concurrency); - const solutions = await Promise.all( - workers.map((worker, i) => { - const start = i * step; - return new Promise((resolve) => { - worker.addEventListener('message', (message: MessageEvent) => { - if (message.data) { - for (const w of workers) { - if (w !== worker) { - w.postMessage({ type: 'abort' }); - } - } - } - resolve(message.data); - }); - worker.postMessage({ - payload: challenge, - max: start + step, - start, - type: 'work', - }); - }) as Promise; - }) - ); - for (const worker of workers) { - worker.terminate(); + /** + * Logs debug information to the console. + */ + function log(...args: unknown[]) { + if (debug || args.some((a) => a instanceof Error)) { + console[args[0] instanceof Error ? 'error' : 'log']( + 'ALTCHA', + `[name=${name}]`, + ...args + ); } - return solutions.find((solution) => !!solution) || null; } + /** + * Called when the checkbox is checked or unchecked. + */ function onCheckedChange() { if ([State.UNVERIFIED, State.ERROR, State.EXPIRED].includes(state)) { if (spamfilter && elForm?.reportValidity() === false) { @@ -455,141 +409,185 @@ } } + /** + * Handles click events on the document. + */ function onDocumentClick(ev: MouseEvent) { const target = ev.target as HTMLElement; if ( floating && target && !el.contains(target) && - state === State.VERIFIED + (state === State.VERIFIED || (auto === 'off' && state === State.UNVERIFIED)) ) { el.style.display = 'none'; } } + /** + * Handles scroll events on the document. + */ function onDocumentScroll() { - if (floating) { + if (floating && state !== State.UNVERIFIED) { repositionFloating(); } } - function onInvalid() { - if (state === State.VERIFYING && _strings.waitAlert) { - alert(_strings.waitAlert); + /** + * Handles changes in the error state and notifies plugins. + */ + function onErrorChange(_: typeof error) { + for (const plugin of loadedPlugins) { + if (typeof plugin.onErrorChange === 'function') { + plugin.onErrorChange(error); + } } } - function onClarifiedDataChange(_: typeof clarifiedData) { - if (clarifiedData) { - const match = clarifiedData.match(/^(mailto|tel|sms|https?):/); - let el: HTMLAnchorElement | Text; - if (match) { - const [contact] = clarifiedData - .slice(clarifiedData.indexOf(':') + 1) - .replace(/^\/\//, '') - .split('?'); - el = document.createElement('a'); - el.href = clarifiedData; - el.innerHTML = contact; - } else { - el = document.createTextNode(clarifiedData); - } - if (elClarifyButton && el) { - elClarifyButton.after(el); - elClarifyButton.parentElement?.removeChild(elClarifyButton); + /** + * Handles the form focus-in event. + */ + function onFormFocusIn(ev: FocusEvent) { + if (state === State.UNVERIFIED) { + verify(); + } + } + + /** + * Handles the form submission event. + */ + function onFormSubmit(ev: SubmitEvent) { + if (elForm && auto === 'onsubmit') { + if (state === State.UNVERIFIED) { + ev.preventDefault(); + ev.stopPropagation(); + verify().then(() => { + elForm?.requestSubmit(); + }); + } else if (state !== State.VERIFIED) { + ev.preventDefault(); + ev.stopPropagation(); + if (state === State.VERIFYING) { + onInvalid(); + } } + } else if (elForm && floating && auto === 'off' && state === State.UNVERIFIED) { + ev.preventDefault(); + ev.stopPropagation(); + el.style.display = 'block'; + repositionFloating(); } } - function onErrorChange(_: typeof error) { - if (session) { - session.trackError(error); + /** + * Handles the form reset event. + */ + function onFormReset() { + reset(); + } + + /** + * Called when the form is submitted while in VERIFYING state and shows an alert message if the string `waitAlert` is configured. + */ + function onInvalid() { + if (state === State.VERIFYING && _strings.waitAlert) { + alert(_strings.waitAlert); } } + /** + * Handles changes in the state and updates the UI accordingly. + */ function onStateChange(_: typeof state) { + for (const plugin of loadedPlugins) { + if (typeof plugin.onStateChange === 'function') { + plugin.onStateChange(state); + } + } if (floating && state !== State.UNVERIFIED) { requestAnimationFrame(() => { repositionFloating(); }); } + checked = state === State.VERIFIED; } + /** + * Handles resize events on the window. + */ function onWindowResize() { if (floating) { repositionFloating(); } } - function setExpire(duration: number) { - log('expire', duration); - if (expireTimeout) { - clearTimeout(expireTimeout); - expireTimeout = null; - } - if (duration < 1) { - expireChallenge(); - } else { - expireTimeout = setTimeout(expireChallenge, duration); - } + /** + * Parses a JSON attribute string. + */ + function parseJsonAttribute(str: string) { + return JSON.parse(str); } - function setFloating(strategy: typeof floating) { - log('floating', strategy); - if (floating !== strategy) { - el.style.left = ''; - el.style.top = ''; - } - floating = - strategy === true || strategy === '' - ? 'auto' - : strategy === false || strategy === 'false' - ? undefined - : floating; - if (floating) { - if (!auto) { - auto = 'onsubmit'; + /** + * Repositions the floating UI element based on scroll position. + */ + function repositionFloating(viewportOffset: number = 20) { + if (el) { + if (!elFloatingAnchor) { + elFloatingAnchor = + (floatinganchor + ? document.querySelector(floatinganchor) + : elForm?.querySelector( + 'input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])' + )) || elForm; } - document.addEventListener('scroll', onDocumentScroll); - document.addEventListener('click', onDocumentClick); - window.addEventListener('resize', onWindowResize); - } else if (auto === 'onsubmit') { - auto = undefined; - } - } - - function getEmail(name?: string) { - const elInput = elForm?.querySelector( - typeof name === 'string' - ? `input[name="${name}"]` - : 'input[type="email"]:not([data-no-spamfilter])' - ) as HTMLInputElement; - return elInput?.value?.slice(elInput.value.indexOf('@')) || void 1; - } - - function getTextFields(names?: string[]) { - const elInputs = [ - ...(elForm?.querySelectorAll( - names?.length - ? names.map((name) => `input[name="${name}"]`).join(', ') - : 'input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])' - ) || []), - ] as HTMLInputElement[]; - return elInputs.reduce( - (acc, el) => { - const name = el.name; - const value = el.value; - if (name && value) { - acc[name] = /\n/.test(value) - ? value.replace(/(? + docHeight + : floating === 'top'; + const left = Math.max( + viewportOffset, + Math.min( + docWidth - viewportOffset - elBoundary.width, + anchorBoundry.left + anchorBoundry.width / 2 - elBoundary.width / 2 + ) + ); + if (showOnTop) { + el.style.top = `${anchorBoundry.top - (elBoundary.height + offsetY)}px`; + } else { + el.style.top = `${anchorBoundry.bottom + offsetY}px`; } - return acc; - }, - {} as Record - ); + el.style.left = `${left}px`; + el.setAttribute('data-floating', showOnTop ? 'top' : 'bottom'); + if (elAnchorArrow) { + const anchorArrowBoundry = elAnchorArrow.getBoundingClientRect(); + elAnchorArrow.style.left = + anchorBoundry.left - + left + + anchorBoundry.width / 2 - + anchorArrowBoundry.width / 2 + + 'px'; + } + } else { + log('unable to find floating anchor element'); + } + } } + /** + * Classifies the data using the Spam Filter and sets the payload. + */ async function requestServerVerification(verificationPayload: string) { if (!verifyurl) { throw new Error('Attribute verifyurl not set.'); @@ -644,98 +642,177 @@ } } - function getSpamFilterOptions(): SpamFilter { - if (spamfilter === 'ipAddress') { - return { - blockedCountries: undefined, - classifier: undefined, - disableRules: undefined, - email: false, - expectedCountries: undefined, - expectedLanguages: undefined, - fields: false, - ipAddress: undefined, - text: undefined, - timeZone: undefined, - }; + /** + * Sets the expiration timeout for the challenge. + */ + function setExpire(duration: number) { + log('expire', duration); + if (expireTimeout) { + clearTimeout(expireTimeout); + expireTimeout = null; + } + if (duration < 1) { + expireChallenge(); + } else { + expireTimeout = setTimeout(expireChallenge, duration); } - return typeof spamfilter === 'object' - ? spamfilter - : { - blockedCountries: undefined, - classifier: undefined, - disableRules: undefined, - email: undefined, - expectedCountries: undefined, - expectedLanguages: undefined, - fields: undefined, - ipAddress: undefined, - text: undefined, - timeZone: undefined, - }; } - function repositionFloating(viewportOffset: number = 20) { - if (el) { - if (!elFloatingAnchor) { - elFloatingAnchor = - (floatinganchor - ? document.querySelector(floatinganchor) - : elForm?.querySelector( - 'input[type="submit"], button[type="submit"], button:not([type="button"]):not([type="reset"])' - )) || - elForm || - elClarifyButton; + /** + * Set the floating UI mode. + */ + function setFloating(strategy: typeof floating) { + log('floating', strategy); + if (floating !== strategy) { + el.style.left = ''; + el.style.top = ''; + } + floating = + strategy === true || strategy === '' + ? 'auto' + : strategy === false || strategy === 'false' + ? undefined + : floating; + if (floating) { + if (!auto) { + auto = 'onsubmit'; } - if (elFloatingAnchor) { - // @ts-expect-error - const offsetY = parseInt(floatingoffset, 10) || 12; - const anchorBoundry = elFloatingAnchor.getBoundingClientRect(); - const elBoundary = el.getBoundingClientRect(); - const docHeight = document.documentElement.clientHeight; - const docWidth = document.documentElement.clientWidth; - const showOnTop = - floating === 'auto' - ? anchorBoundry.bottom + - elBoundary.height + - offsetY + - viewportOffset > - docHeight - : floating === 'top'; - const left = Math.max( - viewportOffset, - Math.min( - docWidth - viewportOffset - elBoundary.width, - anchorBoundry.left + anchorBoundry.width / 2 - elBoundary.width / 2 - ) - ); - if (showOnTop) { - el.style.top = `${anchorBoundry.top - (elBoundary.height + offsetY)}px`; - } else { - el.style.top = `${anchorBoundry.bottom + offsetY}px`; - } - el.style.left = `${left}px`; - el.setAttribute('data-floating', showOnTop ? 'top' : 'bottom'); - if (elAnchorArrow) { - const anchorArrowBoundry = elAnchorArrow.getBoundingClientRect(); - elAnchorArrow.style.left = - anchorBoundry.left - - left + - anchorBoundry.width / 2 - - anchorArrowBoundry.width / 2 + - 'px'; - } - } else { - log('unable to find floating anchor element'); + document.addEventListener('scroll', onDocumentScroll); + document.addEventListener('click', onDocumentClick); + window.addEventListener('resize', onWindowResize); + } else if (auto === 'onsubmit') { + auto = undefined; + } + } + + /** + * Validates a retrieved challenge and throws if invalid. + */ + function validateChallenge(data: Challenge) { + if (!data.algorithm) { + throw new Error(`Invalid challenge. Property algorithm is missing.`); + } + if (data.signature === undefined) { + throw new Error('Invalid challenge. Property signature is missing.'); + } + if (!allowedAlgs.includes(data.algorithm.toUpperCase())) { + throw new Error( + `Unknown algorithm value. Allowed values: ${allowedAlgs.join(', ')}` + ); + } + if (!data.challenge || data.challenge.length < 40) { + throw new Error('Challenge is too short. Min. 40 chars.'); + } + if (!data.salt || data.salt.length < 10) { + throw new Error('Salt is too short. Min. 10 chars.'); + } + } + + async function solve(data: Challenge | Obfuscated): Promise<{ + data: Challenge | Obfuscated; + solution: Solution | ClarifySolution | null; + }> { + let solution: Solution | ClarifySolution | null = null; + if ('Worker' in window) { + try { + solution = await solveWorkers(data, data.maxnumber); + } catch (err) { + log(err); + } + if (solution?.number !== undefined || 'obfuscated' in data) { + return { + data, + solution, + }; } } + if ('obfuscated' in data) { + const solution = await clarifyData( + data.obfuscated, + data.key, + data.maxnumber + ); + return { + data, + solution: await solution.promise, + }; + } + return { + data, + solution: await solveChallenge( + data.challenge, + data.salt, + data.algorithm, + data.maxnumber || maxnumber + ).promise, + }; } - export function configure(options: Configure) { - if (options.analytics) { - analytics = options.analytics; - enableAnalytics(); + async function solveWorkers( + challenge: Challenge | Obfuscated, + max: number = typeof test === 'number' ? test : maxnumber, + concurrency: number = Math.ceil(workers) + ): Promise { + const workers: Worker[] = []; + concurrency = Math.min(16, Math.max(1, concurrency)); + for (let i = 0; i < concurrency; i++) { + workers.push(altchaCreateWorker(workerurl)); + } + const step = Math.ceil(max / concurrency); + const solutions = await Promise.all( + workers.map((worker, i) => { + const start = i * step; + return new Promise((resolve) => { + worker.addEventListener('message', (message: MessageEvent) => { + if (message.data) { + for (const w of workers) { + if (w !== worker) { + w.postMessage({ type: 'abort' }); + } + } + } + resolve(message.data); + }); + worker.postMessage({ + payload: challenge, + max: start + step, + start, + type: 'work', + }); + }) as Promise; + }) + ); + for (const worker of workers) { + worker.terminate(); + } + return solutions.find((solution) => !!solution) || null; + } + + /** + * Clarifies the data by verifying obfuscated information. + */ + export async function clarify() { + if (!obfuscated) { + state = State.ERROR; + return; + } + const plugin = loadedPlugins.find((p) => (p.constructor as any).pluginName === 'obfuscation'); + if (!plugin || !('clarify' in plugin)) { + state = State.ERROR; + log( + 'Plugin `obfuscation` not found. Import `altcha/plugins/obfuscation` to load it.' + ); + return; } + if ('clarify' in plugin && typeof plugin.clarify === 'function') { + return plugin.clarify(); + } + } + + /** + * Programmatically configure the widget with given options. + */ + export function configure(options: Configure) { if (options.obfuscated !== undefined) { obfuscated = options.obfuscated; } @@ -749,11 +826,8 @@ } } } - if (options.beaconurl) { - beaconurl = options.beaconurl; - if (session) { - session.beaconUrl = beaconurl; - } + if (options.blockspam !== undefined) { + blockspam = !!options.blockspam; } if (options.floatinganchor !== undefined) { floatinganchor = options.floatinganchor; @@ -822,6 +896,60 @@ } } + /** + * Get the current configuration options. + */ + export function getConfiguration(): Configure { + return { + auto, + blockspam, + challengeurl, + debug, + delay, + expire, + floating: floating as Configure['floating'], + floatinganchor, + floatingoffset, + hidefooter, + hidelogo, + name, + maxnumber, + mockerror, + obfuscated, + refetchonexpire, + spamfilter, + strings: _strings, + test, + verifyurl, + workers, + workerurl, + }; + } + + /** + * Get the current "floating anchor" as an HTML element or null. + */ + export function getFloatingAnchor() { + return elFloatingAnchor; + } + + /** + * Get a loaded plugin by it's name. + */ + export function getPlugin(name: string) { + return loadedPlugins.find((plugin) => (plugin.constructor as any).pluginName === name); + } + + /** + * Get the current state. + */ + export function getState() { + return state; + } + + /** + * Clears the state and resets the form. + */ export function reset( newState: State = State.UNVERIFIED, err: string | null = null @@ -836,6 +964,24 @@ state = newState; } + /** + * Set the "floating anchor" HTML element. + */ + export function setFloatingAnchor(el: HTMLElement) { + elFloatingAnchor = el; + } + + /** + * Set the state and optional error message. + */ + export function setState(newState: State, err: string | null = null) { + state = newState; + error = err; + } + + /** + * Triggers verification. + */ export async function verify() { reset(State.VERIFYING); await new Promise((resolve) => setTimeout(resolve, delay || 0)); @@ -843,7 +989,7 @@ .then((data) => { validateChallenge(data); log('challenge', data); - return run(data); + return solve(data); }) .then(({ data, solution }) => { log('solution', solution); @@ -868,7 +1014,6 @@ .then(() => { tick().then(() => { state = State.VERIFIED; - checked = true; log('verified'); dispatch('verified', { payload }); }); @@ -876,45 +1021,9 @@ .catch((err) => { log(err); state = State.ERROR; - checked = false; error = err.message; }); } - - export async function clarify() { - if (!obfuscated) { - state = State.ERROR; - return; - } - reset(State.VERIFYING); - await new Promise((resolve) => setTimeout(resolve, delay || 0)); - const [data, params] = obfuscated.split('?'); - const parsedParams = new URLSearchParams(params || ''); - let key = parsedParams.get('key') || undefined; - if (key) { - const match = key.match(/^\(prompt:?(.*)\)$/); - if (match) { - key = prompt(match[1] || 'Enter Key:') || undefined; - } - } - const { solution } = await run({ - obfuscated: data, - key, - maxnumber, - }); - if (solution && 'clearText' in solution) { - clarifiedData = solution.clearText; - state = State.VERIFIED; - checked = true; - if (floating && el) { - el.style.display = 'none'; - } - } else { - state = State.ERROR; - checked = false; - error = 'Unable to decrypt data.'; - } - } @@ -946,7 +1055,7 @@ {@html _strings.verified} - - {#if session} - - {/if} {:else if state === State.VERIFYING} {@html _strings.verifying} {:else} diff --git a/src/App.svelte b/src/App.svelte index 8642c36..40111ad 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,9 +1,16 @@