altcha 2.2.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,290 +0,0 @@
1
- var y = Object.defineProperty;
2
- var p = (s) => {
3
- throw TypeError(s);
4
- };
5
- var C = (s, t, e) => t in s ? y(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
6
- var l = (s, t, e) => C(s, typeof t != "symbol" ? t + "" : t, e), F = (s, t, e) => t.has(s) || p("Cannot " + e);
7
- 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);
8
- new TextEncoder();
9
- function L() {
10
- try {
11
- return Intl.DateTimeFormat().resolvedOptions().timeZone;
12
- } catch {
13
- }
14
- }
15
- class v {
16
- /**
17
- * Constructs a new instance of the Plugin.
18
- *
19
- * @param {PluginContext} context - The context provided to the plugin, containing necessary configurations and dependencies.
20
- */
21
- constructor(t) {
22
- this.context = t;
23
- }
24
- /**
25
- * Registers a plugin class in the global `altchaPlugins` array.
26
- * Ensures the plugin is added only once.
27
- *
28
- * @param {new(context: PluginContext) => Plugin} cls - The plugin class to register.
29
- */
30
- static register(t) {
31
- typeof globalThis.altchaPlugins != "object" && (globalThis.altchaPlugins = []), globalThis.altchaPlugins.includes(t) || globalThis.altchaPlugins.push(t);
32
- }
33
- /**
34
- * Clean up resources when the plugin is destroyed.
35
- * Override this method in subclasses to implement custom destruction logic.
36
- */
37
- destroy() {
38
- }
39
- /**
40
- * Callback triggered when an error changes.
41
- * Override this method in subclasses to handle error state changes.
42
- *
43
- * @param {string | null} err - The error message or `null` if there's no error.
44
- */
45
- onErrorChange(t) {
46
- }
47
- /**
48
- * Callback triggered when the plugin state changes.
49
- * Override this method in subclasses to handle state changes.
50
- *
51
- * @param {State} state - The new state of the plugin.
52
- */
53
- onStateChange(t) {
54
- }
55
- }
56
- /**
57
- * A distinct name of the plugin. Every plugin must have it's own name.
58
- */
59
- l(v, "pluginName");
60
- var o, a, m, f, w;
61
- class A extends v {
62
- /**
63
- * Creates an instance of PluginAnalytics.
64
- *
65
- * @param {PluginContext} context - The context object containing plugin configurations.
66
- */
67
- constructor(e) {
68
- super(e);
69
- r(this, f);
70
- // HTML form element associated with the plugin
71
- r(this, o);
72
- // Session instance for tracking analytics data
73
- r(this, a);
74
- // Bound method for form submission handling
75
- r(this, m, E(this, f, w).bind(this));
76
- if (T(this, o, this.context.el.closest("form")), i(this, o)) {
77
- let n = i(this, o).getAttribute("data-beacon-url");
78
- const h = i(this, o).getAttribute("action");
79
- !n && h && (n = h + "/beacon"), i(this, o).addEventListener("submit", i(this, m)), T(this, a, new N(i(this, o), n));
80
- }
81
- }
82
- /**
83
- * Destroys the plugin instance, removing event listeners and cleaning up the session.
84
- */
85
- destroy() {
86
- var e, n;
87
- (e = i(this, o)) == null || e.removeEventListener("submit", i(this, m)), (n = i(this, a)) == null || n.destroy();
88
- }
89
- /**
90
- * Tracks errors by forwarding them to the session instance.
91
- *
92
- * @param {string | null} err - The error message, or `null` if no error exists.
93
- */
94
- onErrorChange(e) {
95
- var n;
96
- (n = i(this, a)) == null || n.trackError(e);
97
- }
98
- }
99
- o = new WeakMap(), a = new WeakMap(), m = new WeakMap(), f = new WeakSet(), /**
100
- * Handles form submission events, appending session data to the form if applicable.
101
- */
102
- w = function() {
103
- var e;
104
- if (i(this, a) && !i(this, a).submitTime) {
105
- i(this, a).end();
106
- const n = i(this, a).dataAsBase64();
107
- this.context.dispatch("session", n);
108
- const h = document.createElement("input");
109
- h.type = "hidden", h.name = "__session", h.value = n, (e = i(this, o)) == null || e.appendChild(h);
110
- }
111
- }, l(A, "pluginName", "analytics");
112
- var c, u, d, g, b;
113
- class N {
114
- /**
115
- * Creates a new Session instance.
116
- *
117
- * @param {HTMLFormElement} elForm - The form element being tracked.
118
- * @param {string | null} [beaconUrl=null] - The URL to send analytics data to.
119
- */
120
- constructor(t, e = null) {
121
- // Error message associated with the session
122
- l(this, "error", null);
123
- // Timestamp when the form was loaded
124
- l(this, "loadTime", Date.now());
125
- // Timestamp when the form was submitted
126
- l(this, "submitTime", null);
127
- // Timestamp when the user started interacting with the form
128
- l(this, "startTime", null);
129
- // Minimum time in milliseconds required to consider the form "viewed"
130
- l(this, "viewTimeThresholdMs", 1500);
131
- // Tracks the number of changes made to each form field
132
- r(this, c, {});
133
- // Name of the last input field focused by the user
134
- r(this, u, null);
135
- // Bound method for handling form change events
136
- r(this, d, this.onFormChange.bind(this));
137
- // Bound method for handling form focus events
138
- r(this, g, this.onFormFocus.bind(this));
139
- // Bound method for handling the unload event
140
- r(this, b, this.onUnload.bind(this));
141
- 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));
142
- }
143
- /**
144
- * Collects and returns analytics data about the form interaction.
145
- *
146
- * @returns {Record<string, unknown>} - An object containing analytics data.
147
- */
148
- data() {
149
- const t = Object.entries(i(this, c));
150
- return {
151
- correction: t.length && t.filter(([e, n]) => n > 1).length / t.length || 0,
152
- dropoff: !this.submitTime && !this.error && i(this, u) ? i(this, u) : null,
153
- error: this.error,
154
- mobile: this.isMobile(),
155
- start: this.startTime,
156
- submit: this.submitTime,
157
- tz: L()
158
- };
159
- }
160
- /**
161
- * Encodes the session data as a base64 string.
162
- *
163
- * @returns {string} - The base64-encoded session data.
164
- */
165
- dataAsBase64() {
166
- try {
167
- return btoa(JSON.stringify(this.data()));
168
- } catch (t) {
169
- console.error("failed to encode ALTCHA session data to base64", t);
170
- }
171
- return "";
172
- }
173
- /**
174
- * Destroys the session, removing event listeners.
175
- */
176
- destroy() {
177
- window.removeEventListener("unload", i(this, b)), this.elForm.removeEventListener("change", i(this, d)), this.elForm.removeEventListener("focusin", i(this, g));
178
- }
179
- /**
180
- * Marks the session as ended by recording the submission time.
181
- */
182
- end() {
183
- this.submitTime || (this.submitTime = Date.now());
184
- }
185
- /**
186
- * Retrieves the name of a form field, including a group label if available.
187
- *
188
- * @param {HTMLInputElement} el - The input element.
189
- * @param {number} [maxLength=40] - The maximum length of the field name.
190
- * @returns {string} - The field name, truncated to `maxLength` if necessary.
191
- */
192
- getFieldName(t, e = 40) {
193
- const n = t.getAttribute("data-group-label"), h = t.getAttribute("name") || t.getAttribute("aria-label");
194
- return ((n ? n + ": " : "") + h).slice(0, e);
195
- }
196
- /**
197
- * Determines if the current device is a mobile device.
198
- *
199
- * @returns {boolean} - `true` if the device is mobile, otherwise `false`.
200
- */
201
- isMobile() {
202
- const t = "userAgentData" in navigator && navigator.userAgentData ? navigator.userAgentData : {};
203
- return "mobile" in t ? t.mobile === !0 : /Mobi/i.test(window.navigator.userAgent);
204
- }
205
- /**
206
- * Checks if a given element is an input element (input, select, or textarea).
207
- *
208
- * @param {HTMLElement} el - The element to check.
209
- * @returns {boolean} - `true` if the element is an input, otherwise `false`.
210
- */
211
- isInput(t) {
212
- return ["INPUT", "SELECT", "TEXTAREA"].includes(t.tagName);
213
- }
214
- /**
215
- * Tracks changes to a specific form field.
216
- *
217
- * @param {HTMLInputElement} el - The input element that changed.
218
- */
219
- onFormFieldChange(t) {
220
- const e = this.getFieldName(t);
221
- e && this.trackFieldChange(e);
222
- }
223
- /**
224
- * Handles form change events, tracking changes to input fields.
225
- *
226
- * @param {Event} ev - The change event.
227
- */
228
- onFormChange(t) {
229
- const e = t.target;
230
- e && this.isInput(e) && this.onFormFieldChange(e);
231
- }
232
- /**
233
- * Handles form focus events, marking the session start time and tracking the last focused field.
234
- *
235
- * @param {FocusEvent} ev - The focus event.
236
- */
237
- onFormFocus(t) {
238
- const e = t.target;
239
- if (this.startTime || this.start(), e && this.isInput(e)) {
240
- const n = this.getFieldName(e);
241
- n && T(this, u, n);
242
- }
243
- }
244
- /**
245
- * Handles the window unload event, sending a beacon with session data if the form was viewed but not submitted.
246
- */
247
- onUnload() {
248
- this.loadTime <= Date.now() - this.viewTimeThresholdMs && !this.submitTime && this.sendBeacon();
249
- }
250
- /**
251
- * Sends a beacon with session data to the specified beacon URL.
252
- */
253
- async sendBeacon() {
254
- if (this.beaconUrl && "sendBeacon" in navigator)
255
- try {
256
- navigator.sendBeacon(
257
- new URL(this.beaconUrl, location.origin),
258
- JSON.stringify(this.data())
259
- );
260
- } catch {
261
- }
262
- }
263
- /**
264
- * Marks the session as started by recording the start time.
265
- */
266
- start() {
267
- this.startTime = Date.now();
268
- }
269
- /**
270
- * Tracks an error associated with the session.
271
- *
272
- * @param {string | null} err - The error message, or `null` if no error exists.
273
- */
274
- trackError(t) {
275
- this.error = t === null ? null : String(t);
276
- }
277
- /**
278
- * Tracks a change to a specific form field.
279
- *
280
- * @param {string} name - The name of the form field.
281
- */
282
- trackFieldChange(t) {
283
- i(this, c)[t] = (i(this, c)[t] || 0) + 1;
284
- }
285
- }
286
- c = new WeakMap(), u = new WeakMap(), d = new WeakMap(), g = new WeakMap(), b = new WeakMap();
287
- v.register(A);
288
- export {
289
- A as PluginAnalytics
290
- };
@@ -1 +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"})});
@@ -1 +0,0 @@
1
- declare module 'altcha/obfuscation';
@@ -1,138 +0,0 @@
1
- var N = Object.defineProperty;
2
- var B = (t) => {
3
- throw TypeError(t);
4
- };
5
- var O = (t, e, i) => e in t ? N(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
6
- var f = (t, e, i) => O(t, typeof e != "symbol" ? e + "" : e, i), b = (t, e, i) => e.has(t) || B("Cannot " + i);
7
- 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);
8
- var E = (t, e, i) => (b(t, e, "access private method"), i);
9
- class y {
10
- /**
11
- * Constructs a new instance of the Plugin.
12
- *
13
- * @param {PluginContext} context - The context provided to the plugin, containing necessary configurations and dependencies.
14
- */
15
- constructor(e) {
16
- this.context = e;
17
- }
18
- /**
19
- * Registers a plugin class in the global `altchaPlugins` array.
20
- * Ensures the plugin is added only once.
21
- *
22
- * @param {new(context: PluginContext) => Plugin} cls - The plugin class to register.
23
- */
24
- static register(e) {
25
- typeof globalThis.altchaPlugins != "object" && (globalThis.altchaPlugins = []), globalThis.altchaPlugins.includes(e) || globalThis.altchaPlugins.push(e);
26
- }
27
- /**
28
- * Clean up resources when the plugin is destroyed.
29
- * Override this method in subclasses to implement custom destruction logic.
30
- */
31
- destroy() {
32
- }
33
- /**
34
- * Callback triggered when an error changes.
35
- * Override this method in subclasses to handle error state changes.
36
- *
37
- * @param {string | null} err - The error message or `null` if there's no error.
38
- */
39
- onErrorChange(e) {
40
- }
41
- /**
42
- * Callback triggered when the plugin state changes.
43
- * Override this method in subclasses to handle state changes.
44
- *
45
- * @param {State} state - The new state of the plugin.
46
- */
47
- onStateChange(e) {
48
- }
49
- }
50
- /**
51
- * A distinct name of the plugin. Every plugin must have it's own name.
52
- */
53
- f(y, "pluginName");
54
- var l = /* @__PURE__ */ ((t) => (t.CODE = "code", t.ERROR = "error", t.VERIFIED = "verified", t.VERIFYING = "verifying", t.UNVERIFIED = "unverified", t.EXPIRED = "expired", t))(l || {}), r, a, I, x;
55
- class v extends y {
56
- /**
57
- * Creates an instance of PluginObfuscation.
58
- *
59
- * @param {PluginContext} context - The context object containing plugin configurations.
60
- */
61
- constructor(i) {
62
- var n, o;
63
- super(i);
64
- g(this, a);
65
- // The button element associated with revealing the obfuscated data
66
- f(this, "elButton");
67
- // Bound method for handling button click events
68
- g(this, r, E(this, a, I).bind(this));
69
- const s = i.el;
70
- 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));
71
- }
72
- /**
73
- * Destroys the plugin instance, removing event listeners.
74
- */
75
- destroy() {
76
- this.elButton && this.elButton.removeEventListener("click", p(this, r));
77
- }
78
- /**
79
- * Handles the clarification process by decrypting the obfuscated data and rendering the clear text.
80
- */
81
- async clarify() {
82
- const {
83
- el: i,
84
- getConfiguration: s,
85
- getFloatingAnchor: n,
86
- setFloatingAnchor: o,
87
- reset: d,
88
- solve: C,
89
- setState: m
90
- } = this.context, { delay: P, floating: F, maxnumber: T, obfuscated: R } = s();
91
- if (this.elButton && !n() && o(this.elButton), !R) {
92
- m(l.ERROR);
93
- return;
94
- }
95
- d(l.VERIFYING), await new Promise((h) => setTimeout(h, P || 0));
96
- const [k, D] = R.split("?");
97
- let c = new URLSearchParams(D || "").get("key") || void 0;
98
- if (c) {
99
- const h = c.match(/^\(prompt:?(.*)\)$/);
100
- h && (c = prompt(h[1] || "Enter Key:") || void 0);
101
- }
102
- const { solution: u } = await C({
103
- obfuscated: k,
104
- key: c,
105
- maxnumber: T
106
- });
107
- 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.");
108
- }
109
- }
110
- r = new WeakMap(), a = new WeakSet(), /**
111
- * Handles the button click event, triggering the clarification process.
112
- *
113
- * @param {Event} ev - The click event.
114
- */
115
- I = function(i) {
116
- i.preventDefault();
117
- const { auto: s } = this.context.getConfiguration();
118
- s === "off" || this.clarify();
119
- }, /**
120
- * Renders the clear text data by creating an appropriate element (e.g., a link or text node).
121
- *
122
- * @param {string} clearText - The decrypted clear text data to render.
123
- */
124
- x = function(i) {
125
- var o;
126
- const s = i.match(/^(mailto|tel|sms|https?):/);
127
- let n;
128
- if (s) {
129
- const [d] = i.slice(i.indexOf(":") + 1).replace(/^\/\//, "").split("?");
130
- n = document.createElement("a"), n.href = i, n.innerHTML = d;
131
- } else
132
- n = document.createTextNode(i);
133
- this.elButton && n && (this.elButton.after(n), (o = this.elButton.parentElement) == null || o.removeChild(this.elButton));
134
- }, f(v, "pluginName", "obfuscation");
135
- y.register(v);
136
- export {
137
- v as PluginObfuscation
138
- };
@@ -1 +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 N=Object.defineProperty;var v=e=>{throw TypeError(e)};var V=(e,t,i)=>t in e?N(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 y=(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.CODE="code",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",y(this,u))}destroy(){this.elButton&&this.elButton.removeEventListener("click",y(this,u))}async clarify(){const{el:n,getConfiguration:a,getFloatingAnchor:o,setFloatingAnchor:r,reset:g,solve:T,setState:E}=this.context,{delay:C,floating:F,maxnumber:O,obfuscated:B}=a();if(this.elButton&&!o()&&r(this.elButton),!B){E(i.ERROR);return}g(i.VERIFYING),await new Promise(d=>setTimeout(d,C||0));const[k,D]=B.split("?");let h=new URLSearchParams(D||"").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:k,key:h,maxnumber:O});f&&"clearText"in f?(R(this,c,P).call(this,f.clearText),E(i.VERIFIED),this.context.dispatch("cleartext",f.clearText),F&&n&&(n.style.display="none")):E(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"})});
@@ -1 +0,0 @@
1
- declare module 'altcha/upload';