tomation 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js ADDED
@@ -0,0 +1,1350 @@
1
+ var _ = Object.defineProperty;
2
+ var ee = (t, e, n) => e in t ? _(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var o = (t, e, n) => (ee(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ class te {
5
+ constructor(e, n, s, i) {
6
+ o(this, "name");
7
+ o(this, "selector");
8
+ o(this, "parent");
9
+ o(this, "postProcess");
10
+ this.name = e, this.selector = n, this.parent = s || null, this.postProcess = i;
11
+ }
12
+ getElementName() {
13
+ let e = "";
14
+ return this.parent && (e = " in " + this.parent.getElementName()), `${this.name}${e}`;
15
+ }
16
+ }
17
+ let M;
18
+ const ne = (t) => {
19
+ M = t;
20
+ }, X = (t, e) => (s = M, i) => {
21
+ s = s || M, console.log("Searching elem from Root = ", s);
22
+ const r = [];
23
+ s.querySelectorAll(t).forEach((l) => {
24
+ l.style.display !== "none" && r.push(l);
25
+ });
26
+ let a;
27
+ return e ? (console.log("Applying filter ", e), console.log(" -- to " + r.length + "elements: ", r), a = r.filter((l, f, N) => {
28
+ console.log("Apply filter to item " + f + ": ", l);
29
+ const x = e(l, f, N);
30
+ return console.log(` -> Item ${f} ${x ? "Match" : "Discarded"}`), x;
31
+ })[0]) : a = r[0], a && i && (console.log("Apply post process to = ", a), a = i(a)), console.log("Return elem = ", a), a;
32
+ }, L = (t, e, n) => ({
33
+ /**
34
+ * Sets the UI element identifier
35
+ * @param uiElementId
36
+ * @returns
37
+ */
38
+ as: (s) => new te(s, t, e, n)
39
+ }), se = (t, e) => ({
40
+ ...L(t, e),
41
+ /**
42
+ * Tansform the UI element that will be returned
43
+ * @param postProcessFn
44
+ * @returns
45
+ */
46
+ postProcess: (n) => ({
47
+ ...L(t, e, n)
48
+ })
49
+ }), z = (t) => ({
50
+ ...L(t, null),
51
+ childOf: (e) => ({
52
+ ...se(t, e)
53
+ }),
54
+ /**
55
+ * Tansform the UI element that will be returned
56
+ * @param postProcessFn
57
+ * @returns
58
+ */
59
+ postProcess: (e) => ({
60
+ ...L(t, null, e)
61
+ })
62
+ }), I = (t) => ({
63
+ where: (e) => z(X(t, e))
64
+ }), ie = I("div"), oe = I("button"), re = I("input"), ae = I("textarea"), ce = (t) => z(X("#" + t)), le = (t) => I(t);
65
+ let j = !1;
66
+ const ze = (t) => {
67
+ j = t;
68
+ }, w = (...t) => {
69
+ j && console.log("[UIElement Filter]", ...t);
70
+ }, je = (t) => (e) => {
71
+ const n = e.className == t;
72
+ return w(`classIs('${t}') on`, e, "=>", n), n;
73
+ }, Ge = (t) => (e) => {
74
+ const n = e.className.split(" ").includes(t);
75
+ return w(`classIncludes('${t}') on`, e, "=>", n), n;
76
+ }, Qe = (t) => (e) => {
77
+ var s;
78
+ const n = ((s = e.textContent) == null ? void 0 : s.trim()) == t;
79
+ return w(`innerTextIs('${t}') on`, e, "=>", n), n;
80
+ }, Ye = (t) => (e) => {
81
+ const n = e.innerText.trim().includes(t);
82
+ return w(`innerTextContains('${t}') on`, e, "=>", n), n;
83
+ }, Ze = (t) => (e) => {
84
+ const n = e.title == t;
85
+ return w(`titleIs('${t}') on`, e, "=>", n), n;
86
+ }, _e = (t) => (e) => {
87
+ const n = e.placeholder === t;
88
+ return w(`placeholderIs('${t}') on`, e, "=>", n), n;
89
+ }, et = () => (t, e) => {
90
+ const n = e === 0;
91
+ return w("isFirstElement on", t, "index", e, "=>", n), n;
92
+ }, tt = (t) => (e, n) => {
93
+ const s = n === t;
94
+ return w(`elementIndexIs(${t}) on`, e, "elemIndex", n, "=>", s), s;
95
+ }, nt = (t) => (e) => {
96
+ const n = (e == null ? void 0 : e.firstChild).innerText.trim() === t;
97
+ return w(`firstChildTextIs('${t}') on`, e, "=>", n), n;
98
+ }, st = (t) => (e, n) => {
99
+ let s = !0, i = 0;
100
+ for (; s && i < t.length; ) {
101
+ const r = t[i](e, n);
102
+ w(`and condition[${i}] on`, e, "elemIndex", n, "=>", r), s = s && r, i++;
103
+ }
104
+ return w("and final result on", e, "elemIndex", n, "=>", s), s;
105
+ }, it = {
106
+ DIV: ie,
107
+ BUTTON: oe,
108
+ INPUT: re,
109
+ TEXTAREA: ae,
110
+ ELEMENT: le,
111
+ identifiedBy: ce
112
+ };
113
+ let O;
114
+ const ue = new Uint8Array(16);
115
+ function he() {
116
+ if (!O && (O = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !O))
117
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
118
+ return O(ue);
119
+ }
120
+ const d = [];
121
+ for (let t = 0; t < 256; ++t)
122
+ d.push((t + 256).toString(16).slice(1));
123
+ function de(t, e = 0) {
124
+ return (d[t[e + 0]] + d[t[e + 1]] + d[t[e + 2]] + d[t[e + 3]] + "-" + d[t[e + 4]] + d[t[e + 5]] + "-" + d[t[e + 6]] + d[t[e + 7]] + "-" + d[t[e + 8]] + d[t[e + 9]] + "-" + d[t[e + 10]] + d[t[e + 11]] + d[t[e + 12]] + d[t[e + 13]] + d[t[e + 14]] + d[t[e + 15]]).toLowerCase();
125
+ }
126
+ const pe = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), H = {
127
+ randomUUID: pe
128
+ };
129
+ function me(t, e, n) {
130
+ if (H.randomUUID && !e && !t)
131
+ return H.randomUUID();
132
+ t = t || {};
133
+ const s = t.random || (t.rng || he)();
134
+ if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, e) {
135
+ n = n || 0;
136
+ for (let i = 0; i < 16; ++i)
137
+ e[n + i] = s[i];
138
+ return e;
139
+ }
140
+ return de(s);
141
+ }
142
+ const y = (t = 2e3) => new Promise((e) => {
143
+ setTimeout(() => {
144
+ e(null);
145
+ }, t);
146
+ }), A = (t, e) => {
147
+ Object.entries(e).map(([s, i]) => ({
148
+ key: s,
149
+ value: i
150
+ })).forEach((s) => {
151
+ const { key: i, value: r } = s;
152
+ t.style[i] = r;
153
+ });
154
+ };
155
+ class ge {
156
+ constructor(e) {
157
+ o(this, "window");
158
+ o(this, "document");
159
+ o(this, "devToolsMessageContainer");
160
+ o(this, "devToolsCheckElementContainer");
161
+ o(this, "darkLayerLeft");
162
+ o(this, "darkLayerTop");
163
+ o(this, "darkLayerRight");
164
+ o(this, "darkLayerBottom");
165
+ o(this, "currentCheckElem");
166
+ o(this, "contextViewerContainer");
167
+ o(this, "devToolsAlertContainer");
168
+ this.document = e.document, this.window = e, this.devToolsMessageContainer = this.createElement("DIV", {
169
+ id: "dev-tools-message-container",
170
+ styles: {
171
+ width: "500px",
172
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
173
+ color: "white",
174
+ position: "fixed",
175
+ bottom: "10px",
176
+ right: "10px",
177
+ fontFamily: "monospace",
178
+ zIndex: "9999"
179
+ },
180
+ parent: this.document.body
181
+ }), this.devToolsAlertContainer = this.createElement("DIV", {
182
+ id: "dev-tools-alert-container",
183
+ styles: {
184
+ width: "100%",
185
+ height: "30px",
186
+ backgroundColor: "#b00",
187
+ color: "white",
188
+ position: "absolute ",
189
+ top: 0,
190
+ fontFamily: "monospace",
191
+ zIndex: "9999",
192
+ display: "none",
193
+ alignItems: "center",
194
+ justifyContent: "center",
195
+ padding: "5px"
196
+ },
197
+ parent: this.document.body
198
+ }), this.devToolsCheckElementContainer = this.createElement("DIV", {
199
+ id: "dev-tools-check-element-container",
200
+ styles: {
201
+ width: "100%",
202
+ height: this.document.body.clientHeight + "px",
203
+ position: "absolute",
204
+ top: "0px",
205
+ left: "0px",
206
+ zIndex: "9990",
207
+ display: "none",
208
+ opacity: "0",
209
+ transition: "opacity .2s"
210
+ },
211
+ parent: this.document.body
212
+ });
213
+ const n = {
214
+ zIndex: "9991",
215
+ backgroundColor: "rgba(0,0,0,0.3)",
216
+ position: "absolute"
217
+ };
218
+ this.darkLayerLeft = this.createElement("DIV", {
219
+ id: "dark-layer-left",
220
+ styles: n,
221
+ parent: this.devToolsCheckElementContainer
222
+ }), this.darkLayerTop = this.createElement("DIV", {
223
+ id: "dark-layer-top",
224
+ styles: n,
225
+ parent: this.devToolsCheckElementContainer
226
+ }), this.darkLayerRight = this.createElement("DIV", {
227
+ id: "dark-layer-right",
228
+ styles: n,
229
+ parent: this.devToolsCheckElementContainer
230
+ }), this.darkLayerBottom = this.createElement("DIV", {
231
+ id: "dark-layer-bottom",
232
+ styles: n,
233
+ parent: this.devToolsCheckElementContainer
234
+ }), this.currentCheckElem = this.createElement("DIV", {
235
+ id: "current-check-elem",
236
+ parent: this.devToolsCheckElementContainer
237
+ }), this.contextViewerContainer = this.createElement("DIV", {
238
+ id: "context-viewer-container",
239
+ styles: {
240
+ width: "100%",
241
+ height: this.document.body.clientHeight + "px",
242
+ position: "absolute",
243
+ top: "0px",
244
+ left: "0px",
245
+ zIndex: "10000",
246
+ display: "none"
247
+ },
248
+ parent: this.document.body
249
+ });
250
+ }
251
+ createElement(e, n) {
252
+ const s = this.document.createElement(e);
253
+ return n && (n.id && (s.id = n == null ? void 0 : n.id), n.styles && A(s, n.styles), n.parent && n.parent.appendChild(s)), s;
254
+ }
255
+ /**
256
+ *
257
+ * @param message @deprecated
258
+ */
259
+ async logAction(e) {
260
+ const n = c.document.createElement("DIV");
261
+ n.innerText = e, A(n, {
262
+ padding: "3px 10px",
263
+ opacity: "1",
264
+ transition: "opacity 1s"
265
+ }), this.devToolsMessageContainer.appendChild(n), await y(4e3), n.style.opacity = "0", await y(4e3), this.devToolsMessageContainer.removeChild(n), await y(1e3);
266
+ }
267
+ async checkElement(e, n) {
268
+ if (!e)
269
+ return;
270
+ const s = e.getBoundingClientRect(), i = this.document.body.getBoundingClientRect();
271
+ this.darkLayerLeft.style.left = "0px", this.darkLayerLeft.style.top = s.top + "px", this.darkLayerLeft.style.width = this.window.scrollX + s.left + "px", this.darkLayerLeft.style.height = s.height + "px", this.darkLayerTop.style.left = this.window.scrollX + "px", this.darkLayerTop.style.top = "0px", this.darkLayerTop.style.width = "100%", this.darkLayerTop.style.height = s.top + "px", this.darkLayerRight.style.left = this.window.scrollX + s.left + s.width + "px", this.darkLayerRight.style.top = s.top + "px", this.darkLayerRight.style.width = i.width - (s.left + s.width) + "px", this.darkLayerRight.style.height = s.height + "px", this.darkLayerBottom.style.left = this.window.scrollX + "px", this.darkLayerBottom.style.top = s.top + s.height + "px", this.darkLayerBottom.style.width = "100%", this.darkLayerBottom.style.height = i.height - (s.top + s.height) + "px", this.currentCheckElem.id = `dev-tools-current-check-elem-${n}`, this.currentCheckElem.style.top = s.top + "px", this.currentCheckElem.style.left = this.window.scrollX + s.left + "px", this.currentCheckElem.style.height = s.height + "px", this.currentCheckElem.style.width = s.width + "px", this.currentCheckElem.style.boxShadow = "0px 0px 5px 2px lightgreen", this.currentCheckElem.style.position = "absolute", this.currentCheckElem.style.zIndex = "9992", this.devToolsCheckElementContainer.style.display = "block", this.devToolsCheckElementContainer.style.opacity = "1", await y(200);
272
+ }
273
+ async showAlert(e) {
274
+ const n = c.document.createElement("DIV"), s = c.document.body;
275
+ n.innerText = e, A(s, {
276
+ paddingTop: "30px"
277
+ }), A(this.devToolsAlertContainer, {
278
+ display: "flex"
279
+ }), this.devToolsAlertContainer.appendChild(n);
280
+ }
281
+ async hideAlert() {
282
+ A(this.devToolsAlertContainer, {
283
+ display: "none"
284
+ });
285
+ const e = c.document.body;
286
+ A(e, {
287
+ paddingTop: "0"
288
+ }), this.devToolsAlertContainer.firstChild && this.devToolsAlertContainer.removeChild(this.devToolsAlertContainer.firstChild);
289
+ }
290
+ async hideCheckElementContainer() {
291
+ this.devToolsCheckElementContainer.style.opacity = "0", await y(200), this.devToolsCheckElementContainer.style.display = "none";
292
+ }
293
+ displayContext(e) {
294
+ A(this.contextViewerContainer, {
295
+ display: "flex",
296
+ "background-color": "white",
297
+ position: "absolute",
298
+ top: "0px",
299
+ left: "0px",
300
+ "z-index": "9999"
301
+ });
302
+ const n = this.document.createElement("DIV");
303
+ n.id = "context-viewer-before", A(n, {
304
+ flex: "50%",
305
+ width: "100%",
306
+ height: "auto",
307
+ border: "2px solid orange"
308
+ });
309
+ const s = this.document.createElement("DIV");
310
+ s.id = "context-viewer-after", A(s, {
311
+ flex: "50%",
312
+ width: "100%",
313
+ height: "auto",
314
+ border: "2px solid green"
315
+ });
316
+ const i = this.document.createElement("DIV");
317
+ i.innerHTML = e.beforeHTML, q(i, e.beforeInputValues);
318
+ const r = this.document.createElement("DIV");
319
+ r.innerHTML = e.afterHTML, q(r, e.afterInputValues), this.contextViewerContainer.appendChild(n), n.appendChild(i), setTimeout(() => {
320
+ this.contextViewerContainer.removeChild(n), this.contextViewerContainer.appendChild(s), s.appendChild(r), setTimeout(() => {
321
+ this.contextViewerContainer.removeChild(s), A(this.contextViewerContainer, { display: "none" });
322
+ }, 2e3);
323
+ }, 2e3);
324
+ }
325
+ }
326
+ const q = (t, e) => {
327
+ t.querySelectorAll("input").forEach((n) => {
328
+ const s = n.getAttribute("input-id") || "";
329
+ n.value = e[s];
330
+ });
331
+ }, K = null, P = async (t, e, n, s = 1e3, i = 0, r = 10, a = !1) => {
332
+ if (console.log("Automation Status: ", c.status), c.isPaused)
333
+ return new Promise((l, f) => {
334
+ c.saveCurrentAction(async (N) => {
335
+ if (N.status == "skipped")
336
+ return l(null);
337
+ try {
338
+ const x = await P(N, e, n, s, i, r, a);
339
+ l(x);
340
+ } catch (x) {
341
+ f(x);
342
+ }
343
+ }, t);
344
+ });
345
+ if (c.isStopped)
346
+ throw new Error("Test stopped manually");
347
+ if (console.groupCollapsed(`tries ${i}/${r}`), t && (t.updateTries(i), await m.notifyActionUpdated(t)), i === r)
348
+ throw console.groupEnd(), a ? new Error(`UI Element ${e.getElementName() || "UNKNNOWN"} still present after 10 tries`) : new Error(`UI Element ${e.getElementName() || "UNKNNOWN"} not found after 10 tries`);
349
+ {
350
+ const l = e.selector(n, e.postProcess);
351
+ return console.groupEnd(), l ? a ? (await y(s), await P(t, e, n, s, ++i, r, a)) : (console.log("Element found = ", l), l) : a ? (console.log("Element removed."), K) : (await y(s), await P(t, e, n, s, ++i, r, a));
352
+ }
353
+ }, $ = async (t, e, n = 1e3, s = 10, i = !1) => {
354
+ const r = e == null ? void 0 : e.getElementName();
355
+ console.group("Looking for Element: " + r);
356
+ let a = null;
357
+ if (e.parent)
358
+ try {
359
+ console.groupCollapsed("Look for Parent ", e.parent.getElementName()), a = await $(t, e.parent, n, s, i), console.groupEnd();
360
+ } catch (l) {
361
+ if (console.groupEnd(), i && l.message.includes("not found"))
362
+ return console.log("Parent not found, so element was removed"), console.groupEnd(), K;
363
+ throw console.groupEnd(), l;
364
+ }
365
+ try {
366
+ console.log("Using parent element: ", a);
367
+ const l = await P(t, e, a, n, 0, s, i);
368
+ return console.groupEnd(), l;
369
+ } catch (l) {
370
+ if (i && l.message.includes("not found"))
371
+ return console.log("Parent not found, so element was removed"), console.groupEnd(), K;
372
+ throw console.groupEnd(), l;
373
+ }
374
+ };
375
+ var G = /* @__PURE__ */ ((t) => (t.WAITING = "waiting", t.RUNNING = "running", t.STOPPED = "stopped", t.PAUSED = "paused", t.SUCCESS = "success", t.ERROR = "error", t.SKIPPED = "skipped", t))(G || {});
376
+ class m {
377
+ constructor() {
378
+ o(this, "status");
379
+ o(this, "error");
380
+ o(this, "id");
381
+ o(this, "context");
382
+ this.status = "waiting", this.error = "", this.id = me(), this.context = {
383
+ beforeHTML: "",
384
+ beforeInputValues: {},
385
+ afterInputValues: {},
386
+ afterHTML: "",
387
+ url: "",
388
+ startTimestamp: "",
389
+ endTimestamp: ""
390
+ };
391
+ }
392
+ getJSON() {
393
+ return {
394
+ id: this.id,
395
+ description: this.getDescription(),
396
+ context: this.context,
397
+ status: this.status,
398
+ error: this.error
399
+ };
400
+ }
401
+ reset() {
402
+ this.status = "waiting", this.error = "", this.resetAction();
403
+ }
404
+ getInputValuesFromPage() {
405
+ const e = {};
406
+ return c.document.querySelectorAll("input").forEach((s, i) => {
407
+ const r = `value-id-${i}`;
408
+ s.setAttribute("input-id", r), e[r] = s.value;
409
+ }), e;
410
+ }
411
+ async execute() {
412
+ try {
413
+ this.status = "running", this.context.beforeInputValues = this.getInputValuesFromPage(), this.context.beforeHTML = c.document.body.innerHTML, await m.notifyActionUpdated(this), console.log("Action: ", this.getDescription()), await this.executeAction(), this.status = "success", this.error = "", c.isStepByStepMode && c.pause();
414
+ } catch (e) {
415
+ if (this.status = "error", this.error = e.message, e.message == "Test stopped manually")
416
+ throw Error("Error in Action " + this.getDescription() + ". Message: " + e.message);
417
+ this.status = "paused", c.pause();
418
+ } finally {
419
+ this.context.afterInputValues = this.getInputValuesFromPage(), this.context.afterHTML = c.document.body.innerHTML, await m.notifyActionUpdated(this);
420
+ }
421
+ }
422
+ static async notifyActionUpdated(e) {
423
+ E.dispatch(b.ACTION_UPDATE, {
424
+ action: e.getJSON()
425
+ });
426
+ }
427
+ }
428
+ class Q extends m {
429
+ constructor(n, s) {
430
+ super();
431
+ o(this, "name");
432
+ o(this, "stepsFn");
433
+ o(this, "steps");
434
+ o(this, "params");
435
+ o(this, "index");
436
+ this.name = n, this.stepsFn = s, this.steps = [], this.index = 0;
437
+ }
438
+ getDescription() {
439
+ return this.name;
440
+ }
441
+ compileSteps() {
442
+ super.reset(), this.stepsFn(this.params);
443
+ }
444
+ stepsToJSON() {
445
+ return this.steps.reduce((n, s) => (n.push(s.getJSON()), n), []);
446
+ }
447
+ getJSON() {
448
+ return {
449
+ ...super.getJSON(),
450
+ type: "Action",
451
+ params: this.params,
452
+ steps: this.stepsToJSON()
453
+ };
454
+ }
455
+ resetAction() {
456
+ this.steps.length = 0, this.index = 0;
457
+ }
458
+ async continue() {
459
+ if (c.isPaused)
460
+ return new Promise((n, s) => {
461
+ c.saveCurrentAction(async (i) => {
462
+ if (i.status == "skipped")
463
+ return n();
464
+ try {
465
+ await i.continue(), n();
466
+ } catch (r) {
467
+ s(r);
468
+ }
469
+ }, this);
470
+ });
471
+ if (c.isStopped)
472
+ throw new Error("Test stopped manually");
473
+ if (this.index < this.steps.length) {
474
+ const n = this.steps[this.index];
475
+ try {
476
+ if (await y(c.speed), await n.execute(), !c.isPaused)
477
+ this.index++, await this.continue();
478
+ else
479
+ return new Promise((s, i) => {
480
+ c.saveCurrentAction(async (r) => {
481
+ if (r.status == "skipped")
482
+ return this.index++, await m.notifyActionUpdated(n), await this.continue(), s();
483
+ try {
484
+ await r.continue(), s();
485
+ } catch (a) {
486
+ i(a);
487
+ }
488
+ }, n);
489
+ });
490
+ } catch (s) {
491
+ throw s;
492
+ }
493
+ }
494
+ }
495
+ async executeAction() {
496
+ this.index = 0, await this.continue();
497
+ }
498
+ setParams(n) {
499
+ this.params = n;
500
+ }
501
+ addStep(n) {
502
+ this.steps.push(n);
503
+ }
504
+ }
505
+ class p extends m {
506
+ constructor(n) {
507
+ super();
508
+ o(this, "uiElement");
509
+ o(this, "element");
510
+ o(this, "tries");
511
+ this.uiElement = n, this.element = null, this.tries = 0;
512
+ }
513
+ getElementName() {
514
+ var n;
515
+ return (n = this.uiElement) == null ? void 0 : n.getElementName();
516
+ }
517
+ updateTries(n) {
518
+ this.tries = n;
519
+ }
520
+ resetTries() {
521
+ this.tries = 0;
522
+ }
523
+ getJSON() {
524
+ return {
525
+ id: this.id,
526
+ element: this.getElementName(),
527
+ description: this.getDescription(),
528
+ status: this.status,
529
+ error: this.error,
530
+ context: this.context,
531
+ tries: this.tries
532
+ };
533
+ }
534
+ /**
535
+ *
536
+ * @param uiElement
537
+ * @param delay of each try. Defaults to 1 second
538
+ */
539
+ static waitForElement(n, s, i = 1e3, r = 10, a = !1) {
540
+ const l = s.getElementName();
541
+ return new Promise(async (f, N) => {
542
+ var B;
543
+ const x = async (C, D = 1e3, T = 0, v = !1) => {
544
+ if (console.groupCollapsed(`tries ${T}/${r}`), n.updateTries(T), await m.notifyActionUpdated(n), T === r)
545
+ throw console.groupEnd(), v ? new Error(`UI Element ${l || "UNKNNOWN"} still present after 10 tries`) : new Error(`UI Element ${l || "UNKNNOWN"} not found after 10 tries`);
546
+ {
547
+ const R = s.selector(C, s.postProcess);
548
+ return console.groupEnd(), R ? v ? (await y(D), await x(C, D, ++T, v)) : (console.log("Element found = ", R), R) : v ? (console.log("Element removed."), null) : (await y(D), await x(C, D, ++T, v));
549
+ }
550
+ };
551
+ console.group("[Action On Element] Looking for Element: " + l);
552
+ let V = null, W = !0;
553
+ if (s.parent) {
554
+ console.groupCollapsed("Look for Parent ", s.parent.getElementName());
555
+ try {
556
+ V = await p.waitForElement(n, s.parent, i, r, a);
557
+ } catch {
558
+ W = !1;
559
+ } finally {
560
+ console.groupEnd();
561
+ }
562
+ }
563
+ if (W) {
564
+ console.log("using parent element: ", V);
565
+ try {
566
+ const C = await x(V, i, 0, a);
567
+ console.groupEnd(), f(C);
568
+ } catch (C) {
569
+ console.groupEnd(), N(new Error(C.message));
570
+ }
571
+ } else
572
+ console.groupEnd(), N(new Error(`Parent ${(B = s.parent) == null ? void 0 : B.getElementName()} of UI Element ${s.name || "UNKNNOWN"} not found`));
573
+ });
574
+ }
575
+ async executeAction() {
576
+ var n;
577
+ try {
578
+ this.element = await $(this, this.uiElement), (n = this.element) == null || n.setAttribute("test-id", this.getElementName()), await c.uiUtils.checkElement(this.element, this.getElementName()), this.executeActionOnElement(), await c.uiUtils.hideCheckElementContainer();
579
+ } catch (s) {
580
+ throw Error(s.message);
581
+ }
582
+ }
583
+ resetAction() {
584
+ this.element = null, this.resetTries();
585
+ }
586
+ }
587
+ class ye extends p {
588
+ constructor(e) {
589
+ super(e);
590
+ }
591
+ executeActionOnElement() {
592
+ var e;
593
+ return (e = this.element) == null ? void 0 : e.click();
594
+ }
595
+ getDescription() {
596
+ return "Click in " + this.getElementName();
597
+ }
598
+ getJSON() {
599
+ return {
600
+ ...super.getJSON(),
601
+ type: "Click"
602
+ };
603
+ }
604
+ }
605
+ class Ee extends p {
606
+ constructor(n, s) {
607
+ super(n);
608
+ o(this, "text");
609
+ this.text = s;
610
+ }
611
+ executeActionOnElement() {
612
+ var s;
613
+ if (!(((s = this.element) == null ? void 0 : s.innerText) === this.text))
614
+ throw new Error(`Text in element ${this.getElementName()} is not '${this.text}'`);
615
+ }
616
+ getDescription() {
617
+ return `Assert that text in ${this.getElementName()} is '${this.text}'`;
618
+ }
619
+ getJSON() {
620
+ return {
621
+ ...super.getJSON(),
622
+ type: "AssertTextIsAction",
623
+ value: this.text
624
+ };
625
+ }
626
+ }
627
+ class we extends p {
628
+ constructor(n, s) {
629
+ super(n);
630
+ o(this, "text");
631
+ this.text = s;
632
+ }
633
+ executeActionOnElement() {
634
+ var s;
635
+ if (!((s = this.element) == null ? void 0 : s.innerText.includes(this.text)))
636
+ throw new Error(`Text in element ${this.getElementName()} doesn't contain '${this.text}'`);
637
+ }
638
+ getDescription() {
639
+ return `Assert that ${this.getElementName()} contains '${this.text}'`;
640
+ }
641
+ getJSON() {
642
+ return {
643
+ ...super.getJSON(),
644
+ type: "AssertContainsText",
645
+ value: this.text
646
+ };
647
+ }
648
+ }
649
+ class fe extends p {
650
+ constructor(n, s) {
651
+ super(n);
652
+ o(this, "value");
653
+ this.value = s;
654
+ }
655
+ executeActionOnElement() {
656
+ if (!(this.element.value === this.value))
657
+ throw new Error(`Value in element ${this.getElementName()} is not '${this.value}'`);
658
+ }
659
+ getDescription() {
660
+ return `Assert that value in ${this.getElementName()} is '${this.value}'`;
661
+ }
662
+ getJSON() {
663
+ return {
664
+ ...super.getJSON(),
665
+ type: "AssertValueIsAction",
666
+ value: this.value
667
+ };
668
+ }
669
+ }
670
+ class xe extends p {
671
+ constructor(e) {
672
+ super(e);
673
+ }
674
+ executeActionOnElement() {
675
+ if (!!!this.element)
676
+ throw new Error(`Element ${this.getElementName()} doesn't exist`);
677
+ }
678
+ getDescription() {
679
+ return `Assert that ${this.getElementName()} exists`;
680
+ }
681
+ getJSON() {
682
+ return {
683
+ ...super.getJSON(),
684
+ type: "AssertExistsAction"
685
+ };
686
+ }
687
+ }
688
+ class Ae extends p {
689
+ constructor(e) {
690
+ super(e);
691
+ }
692
+ async executeAction() {
693
+ var e;
694
+ try {
695
+ this.element = await $(this, this.uiElement, 1e3, 5, !0), (e = this.element) == null || e.setAttribute("test-id", this.getElementName()), await c.uiUtils.checkElement(this.element, this.getElementName()), this.executeActionOnElement(), await c.uiUtils.hideCheckElementContainer();
696
+ } catch (n) {
697
+ throw Error(n.message);
698
+ }
699
+ }
700
+ executeActionOnElement() {
701
+ if (!!this.element)
702
+ throw new Error(`Element ${this.getElementName()} was not expected to exist`);
703
+ }
704
+ getDescription() {
705
+ return `Assert that ${this.getElementName()} doesn't exist`;
706
+ }
707
+ getJSON() {
708
+ return {
709
+ ...super.getJSON(),
710
+ type: "AssertNotExistsAction"
711
+ };
712
+ }
713
+ }
714
+ class Ce extends p {
715
+ constructor(n, s) {
716
+ super(n);
717
+ o(this, "value");
718
+ this.value = s;
719
+ }
720
+ executeActionOnElement() {
721
+ var s, i, r, a;
722
+ let n = this.element;
723
+ if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((i = this.element) == null ? void 0 : i.tagName) !== "SELECT" && ((r = this.element) == null ? void 0 : r.tagName) !== "TEXTAREA" && (n = (a = this.element) == null ? void 0 : a.querySelectorAll("input")[0], !n))
724
+ throw new Error("Input element not found. Not able to type value in element " + this.getElementName());
725
+ n.value = this.value, n.dispatchEvent(new Event("change"));
726
+ }
727
+ getDescription() {
728
+ return `Select value '${this.value}' in ${this.getElementName()}`;
729
+ }
730
+ getJSON() {
731
+ return {
732
+ ...super.getJSON(),
733
+ type: "Select",
734
+ value: this.value
735
+ };
736
+ }
737
+ }
738
+ class Y extends p {
739
+ constructor(n, s) {
740
+ super(n);
741
+ o(this, "value");
742
+ this.value = s;
743
+ }
744
+ executeActionOnElement() {
745
+ var s, i, r, a;
746
+ let n = this.element;
747
+ if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((i = this.element) == null ? void 0 : i.tagName) !== "SELECT" && ((r = this.element) == null ? void 0 : r.tagName) !== "TEXTAREA" && (n = (a = this.element) == null ? void 0 : a.querySelectorAll("input")[0], !n))
748
+ throw new Error("Input element not found. Not able to type value in element " + this.getElementName());
749
+ n.value = this.value, n.dispatchEvent(new Event("change")), n.dispatchEvent(new Event("keyup"));
750
+ }
751
+ getDescription() {
752
+ return `Type value '${this.value}' in ${this.getElementName()}`;
753
+ }
754
+ getJSON() {
755
+ return {
756
+ ...super.getJSON(),
757
+ type: "Type",
758
+ value: this.value
759
+ };
760
+ }
761
+ }
762
+ class Ne extends p {
763
+ constructor(n, s) {
764
+ super(n);
765
+ o(this, "value");
766
+ this.value = s;
767
+ }
768
+ executeActionOnElement() {
769
+ var s, i, r, a;
770
+ let n = this.element;
771
+ if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((i = this.element) == null ? void 0 : i.tagName) !== "SELECT" && ((r = this.element) == null ? void 0 : r.tagName) !== "TEXTAREA" && (n = (a = this.element) == null ? void 0 : a.querySelectorAll("input")[0], !n))
772
+ throw new Error("Input element not found. Not able to type value in element " + this.getElementName());
773
+ n.value = this.value, n.dispatchEvent(new Event("change"));
774
+ }
775
+ getDescription() {
776
+ return `Type a password in ${this.getElementName()}`;
777
+ }
778
+ getJSON() {
779
+ return {
780
+ ...super.getJSON(),
781
+ type: "TypePassword",
782
+ value: this.value
783
+ };
784
+ }
785
+ }
786
+ class ke extends p {
787
+ constructor(e) {
788
+ super(e);
789
+ }
790
+ executeActionOnElement() {
791
+ var e;
792
+ (e = this.element) == null || e.dispatchEvent(
793
+ new KeyboardEvent("keydown", {
794
+ altKey: !1,
795
+ code: "Escape",
796
+ ctrlKey: !1,
797
+ isComposing: !1,
798
+ key: "Escape",
799
+ location: 0,
800
+ metaKey: !1,
801
+ repeat: !1,
802
+ shiftKey: !1,
803
+ which: 27,
804
+ charCode: 0,
805
+ keyCode: 27
806
+ })
807
+ );
808
+ }
809
+ getDescription() {
810
+ return `Press Esc key in ${this.getElementName()}`;
811
+ }
812
+ getJSON() {
813
+ return {
814
+ ...super.getJSON(),
815
+ type: "PressEscKey"
816
+ };
817
+ }
818
+ }
819
+ class Te extends p {
820
+ constructor(e) {
821
+ super(e);
822
+ }
823
+ executeActionOnElement() {
824
+ var e;
825
+ (e = this.element) == null || e.dispatchEvent(
826
+ new KeyboardEvent("keyup", {
827
+ altKey: !1,
828
+ code: "Down",
829
+ ctrlKey: !1,
830
+ isComposing: !1,
831
+ key: "Down",
832
+ location: 0,
833
+ metaKey: !1,
834
+ repeat: !1,
835
+ shiftKey: !1,
836
+ which: 40,
837
+ charCode: 0,
838
+ keyCode: 40
839
+ })
840
+ );
841
+ }
842
+ getDescription() {
843
+ return `Press Down key in ${this.getElementName()}`;
844
+ }
845
+ getJSON() {
846
+ return {
847
+ ...super.getJSON(),
848
+ type: "PressDownKey"
849
+ };
850
+ }
851
+ }
852
+ class ve extends p {
853
+ constructor(e) {
854
+ super(e);
855
+ }
856
+ executeActionOnElement() {
857
+ var e;
858
+ (e = this.element) == null || e.dispatchEvent(
859
+ new KeyboardEvent("keydown", {
860
+ altKey: !1,
861
+ code: "Tab",
862
+ ctrlKey: !1,
863
+ isComposing: !1,
864
+ key: "Tab",
865
+ location: 0,
866
+ metaKey: !1,
867
+ repeat: !1,
868
+ shiftKey: !1,
869
+ which: 9,
870
+ charCode: 0,
871
+ keyCode: 9
872
+ })
873
+ );
874
+ }
875
+ getDescription() {
876
+ return `Press Tab key in ${this.getElementName()}`;
877
+ }
878
+ getJSON() {
879
+ return {
880
+ ...super.getJSON(),
881
+ type: "PressTabKey"
882
+ };
883
+ }
884
+ }
885
+ class Se extends p {
886
+ constructor(n, s) {
887
+ super(n);
888
+ o(this, "file");
889
+ this.file = s;
890
+ }
891
+ executeActionOnElement() {
892
+ const n = this.element, s = new DataTransfer();
893
+ s.items.add(this.file);
894
+ const i = s.files;
895
+ n.files = i, n.dispatchEvent(new Event("change"));
896
+ function r(l) {
897
+ var f;
898
+ return l != null && l.parentElement ? ((f = l.parentElement) == null ? void 0 : f.tagName.toLowerCase()) === "form" ? l.parentElement : r(l.parentElement) : null;
899
+ }
900
+ const a = r(n);
901
+ a && a.dispatchEvent(new Event("change"));
902
+ }
903
+ getDescription() {
904
+ return `Upload file in ${this.getElementName()}`;
905
+ }
906
+ getJSON() {
907
+ return {
908
+ ...super.getJSON(),
909
+ type: "UploadFile"
910
+ };
911
+ }
912
+ }
913
+ class be extends p {
914
+ constructor(n, s) {
915
+ super(n);
916
+ o(this, "memorySlotName");
917
+ this.memorySlotName = s;
918
+ }
919
+ executeActionOnElement() {
920
+ var s, i, r, a;
921
+ let n = this.element;
922
+ if (((s = this.element) == null ? void 0 : s.tagName) !== "INPUT" && ((i = this.element) == null ? void 0 : i.tagName) !== "SELECT" && ((r = this.element) == null ? void 0 : r.tagName) !== "TEXTAREA" && (n = (a = this.element) == null ? void 0 : a.querySelectorAll("input")[0], !n))
923
+ throw new Error("Input element not found. Not able to save value from element " + this.getElementName());
924
+ E.dispatch(b.SAVE_VALUE, {
925
+ memorySlotName: this.memorySlotName,
926
+ value: n.value
927
+ });
928
+ }
929
+ getDescription() {
930
+ return `Save value of ${this.getElementName()} in ${this.memorySlotName}`;
931
+ }
932
+ getJSON() {
933
+ return {
934
+ ...super.getJSON(),
935
+ type: "SaveValue",
936
+ memorySlotName: this.memorySlotName
937
+ };
938
+ }
939
+ }
940
+ class Ie extends m {
941
+ constructor(n) {
942
+ super();
943
+ o(this, "miliseconds");
944
+ this.miliseconds = n;
945
+ }
946
+ getDescription() {
947
+ return "Wait " + this.miliseconds + " miliseconds";
948
+ }
949
+ getJSON() {
950
+ return {
951
+ ...super.getJSON(),
952
+ type: "Wait"
953
+ };
954
+ }
955
+ async executeAction() {
956
+ await y(this.miliseconds);
957
+ }
958
+ resetAction() {
959
+ }
960
+ }
961
+ class De extends m {
962
+ constructor(n) {
963
+ super();
964
+ o(this, "uiElement");
965
+ o(this, "tries");
966
+ this.uiElement = n, this.tries = 0;
967
+ }
968
+ updateTries(n) {
969
+ this.tries = n;
970
+ }
971
+ resetAction() {
972
+ this.tries = 0;
973
+ }
974
+ getElementName() {
975
+ var n;
976
+ return (n = this.uiElement) == null ? void 0 : n.getElementName();
977
+ }
978
+ async executeAction() {
979
+ await $(this, this.uiElement, 1e3, 10, !0);
980
+ }
981
+ getDescription() {
982
+ return "Wait until " + this.getElementName() + " is removed";
983
+ }
984
+ getJSON() {
985
+ return {
986
+ ...super.getJSON(),
987
+ type: "WaitUntilElementRemoved"
988
+ };
989
+ }
990
+ }
991
+ class Oe extends m {
992
+ constructor() {
993
+ super();
994
+ }
995
+ getDescription() {
996
+ return "Paused";
997
+ }
998
+ getJSON() {
999
+ return {
1000
+ ...super.getJSON(),
1001
+ type: "Pause"
1002
+ };
1003
+ }
1004
+ async executeAction() {
1005
+ await c.pause();
1006
+ }
1007
+ resetAction() {
1008
+ }
1009
+ }
1010
+ class Pe extends m {
1011
+ constructor(n) {
1012
+ super();
1013
+ o(this, "description");
1014
+ this.description = n;
1015
+ }
1016
+ getDescription() {
1017
+ return "Manual Step: " + this.description;
1018
+ }
1019
+ getJSON() {
1020
+ return {
1021
+ ...super.getJSON(),
1022
+ type: "ManualStep"
1023
+ };
1024
+ }
1025
+ async executeAction() {
1026
+ return await c.uiUtils.showAlert("Waiting manual step..."), new Promise((n, s) => {
1027
+ E.on(b.USER_ACCEPT, async () => (await c.uiUtils.hideAlert(), n(!0))), E.on(b.USER_REJECT, async () => (await c.uiUtils.hideAlert(), s()));
1028
+ });
1029
+ }
1030
+ resetAction() {
1031
+ }
1032
+ }
1033
+ class Le extends m {
1034
+ constructor() {
1035
+ super();
1036
+ }
1037
+ getDescription() {
1038
+ return "Reload page";
1039
+ }
1040
+ getJSON() {
1041
+ return {
1042
+ ...super.getJSON(),
1043
+ type: "ReloadPage"
1044
+ };
1045
+ }
1046
+ async executeAction() {
1047
+ await location.reload();
1048
+ }
1049
+ resetAction() {
1050
+ }
1051
+ }
1052
+ const U = (t) => t.toLocaleDateString("en-US", { year: "numeric", month: "2-digit", day: "2-digit" }), J = (t) => {
1053
+ const e = /* @__PURE__ */ new Date();
1054
+ return U(new Date(e.setDate(e.getDate() + t)));
1055
+ }, Z = (t) => {
1056
+ const e = /* @__PURE__ */ new Date();
1057
+ return U(new Date(e.setMonth(e.getMonth() + t)));
1058
+ }, Ue = J(1), $e = J(-1), Je = J(7), Ve = J(-7), Re = Z(1), Me = Z(-1), ot = {
1059
+ formatDate: U,
1060
+ today: U(/* @__PURE__ */ new Date()),
1061
+ tomorrow: Ue,
1062
+ nextWeek: Je,
1063
+ nextMonth: Re,
1064
+ yesterday: $e,
1065
+ lastWeek: Ve,
1066
+ lastMonth: Me
1067
+ };
1068
+ class Ke {
1069
+ constructor() {
1070
+ o(this, "enabled", !1);
1071
+ }
1072
+ setEnabled(e) {
1073
+ this.enabled = e;
1074
+ }
1075
+ log(...e) {
1076
+ this.enabled && console.log("[Automation]", ...e);
1077
+ }
1078
+ groupCollapsed(...e) {
1079
+ this.enabled && console.groupCollapsed("[Automation]", ...e);
1080
+ }
1081
+ groupEnd() {
1082
+ this.enabled && console.groupEnd();
1083
+ }
1084
+ error(...e) {
1085
+ this.enabled && console.error("[Automation]", ...e);
1086
+ }
1087
+ }
1088
+ const u = new Ke(), Fe = (t) => {
1089
+ u.setEnabled(t);
1090
+ }, g = class g {
1091
+ static compileAction(e) {
1092
+ const n = g.currentAction;
1093
+ g.currentAction = e, e.compileSteps(), g.currentAction = n;
1094
+ }
1095
+ static addAction(e) {
1096
+ u.log("Add action: ", e.getDescription()), g.currentAction.addStep(e);
1097
+ }
1098
+ static init(e) {
1099
+ g.currentAction = e, g.isCompiling = !0, u.groupCollapsed("Compile: " + e.getDescription()), e.compileSteps(), g.isCompiling = !1, u.log("Compilation finished"), u.groupEnd();
1100
+ }
1101
+ };
1102
+ o(g, "currentAction"), o(g, "isCompiling");
1103
+ let h = g;
1104
+ var b = /* @__PURE__ */ ((t) => (t.START = "start", t.END = "end", t.ACTION_UPDATE = "action-update", t.SAVE_VALUE = "save-value", t.REGISTER_TEST = "register-test", t.TEST_STARTED = "test-started", t.TEST_PASSED = "test-passed", t.TEST_FAILED = "test-failed", t.TEST_END = "test-end", t.USER_ACCEPT = "user-accept", t.USER_REJECT = "user-reject", t))(b || {});
1105
+ class We {
1106
+ constructor() {
1107
+ o(this, "events");
1108
+ this.events = /* @__PURE__ */ new Map();
1109
+ }
1110
+ on(e, n) {
1111
+ var s;
1112
+ this.events.has(e) || this.events.set(e, []), (s = this.events.get(e)) == null || s.push(n);
1113
+ }
1114
+ off(e, n) {
1115
+ var s;
1116
+ this.events.has(e) && this.events.set(e, ((s = this.events.get(e)) == null ? void 0 : s.filter((i) => i !== n)) || []);
1117
+ }
1118
+ dispatch(e, n) {
1119
+ var s;
1120
+ this.events.has(e) && ((s = this.events.get(e)) == null || s.forEach((i) => {
1121
+ console.log(`Dispatch Event ${e}:`, n), i(n);
1122
+ }));
1123
+ }
1124
+ }
1125
+ const E = new We();
1126
+ var Be = /* @__PURE__ */ ((t) => (t[t.SLOW = 2e3] = "SLOW", t[t.NORMAL = 1e3] = "NORMAL", t[t.FAST = 200] = "FAST", t))(Be || {});
1127
+ const S = class S {
1128
+ static async start(e) {
1129
+ S.running = !0, c.status = "Playing", c.runMode = "Normal", u.groupCollapsed("Start Action: ", e.getDescription()), E.dispatch("start", {
1130
+ action: e == null ? void 0 : e.getJSON()
1131
+ });
1132
+ try {
1133
+ await (e == null ? void 0 : e.execute());
1134
+ } catch (n) {
1135
+ throw c.uiUtils.hideCheckElementContainer(), u.error(`🤖 Error running task ${e.getDescription()}. Reason: ${n.message}`), n;
1136
+ } finally {
1137
+ u.groupEnd(), S.running = !1, E.dispatch("end", {
1138
+ action: e == null ? void 0 : e.getJSON()
1139
+ });
1140
+ }
1141
+ }
1142
+ };
1143
+ o(S, "running", !1);
1144
+ let k = S;
1145
+ const F = {}, rt = (t, e) => {
1146
+ const n = new Q(t, e);
1147
+ h.init(n);
1148
+ const s = async () => {
1149
+ if (k.running)
1150
+ throw u.error("Not able to run test while other test is running."), new Error("Not able to run test while other test is running.");
1151
+ try {
1152
+ E.dispatch("test-started", { action: n.getJSON() }), await k.start(n), E.dispatch("test-passed", { id: t });
1153
+ } catch {
1154
+ E.dispatch("test-failed", { id: t });
1155
+ } finally {
1156
+ E.dispatch("test-end", { id: t });
1157
+ }
1158
+ };
1159
+ E.dispatch("register-test", { id: t, action: n.getJSON() }), F[t] = s;
1160
+ }, at = (t) => {
1161
+ if (F[t])
1162
+ F[t]();
1163
+ else
1164
+ throw new Error(`Test with id ${t} not found.`);
1165
+ }, ct = (t, e) => async (n) => {
1166
+ const s = new Q(t, e);
1167
+ if (s.setParams(n), !k.running && !h.isCompiling)
1168
+ try {
1169
+ u.log(`Compilation of Task ${t} starts...`), h.init(s), u.log(`Compilation of Task ${t} Finished.`), u.log(`Start running Task ${t}...`), await k.start(s), u.log(`End of Task ${t}: SUCCESS`);
1170
+ } catch (i) {
1171
+ u.error("Error running task " + t + ". " + i.message);
1172
+ }
1173
+ else
1174
+ u.log(`Adding action ${t} to compilation stack`), h.addAction(s), h.compileAction(s);
1175
+ }, lt = (t) => {
1176
+ const e = new ye(t);
1177
+ h.addAction(e);
1178
+ }, ut = (t) => ({
1179
+ textIs: (e) => {
1180
+ h.addAction(new Ee(t, e));
1181
+ },
1182
+ containsText: (e) => {
1183
+ h.addAction(new we(t, e));
1184
+ },
1185
+ valueIs: (e) => {
1186
+ h.addAction(new fe(t, e));
1187
+ },
1188
+ exists: () => {
1189
+ h.addAction(new xe(t));
1190
+ },
1191
+ notExists: () => {
1192
+ h.addAction(new Ae(t));
1193
+ }
1194
+ }), ht = (t) => ({
1195
+ in: (e) => {
1196
+ const n = new Ce(e, t);
1197
+ h.addAction(n);
1198
+ }
1199
+ }), dt = (t) => ({
1200
+ in: (e) => {
1201
+ const n = new Y(e, t);
1202
+ h.addAction(n);
1203
+ }
1204
+ }), pt = () => ({
1205
+ in: (t) => {
1206
+ const e = new Y(t, "");
1207
+ h.addAction(e);
1208
+ }
1209
+ }), mt = () => ({
1210
+ in: (t) => {
1211
+ h.addAction(new ke(t));
1212
+ }
1213
+ }), gt = () => ({
1214
+ in: (t) => {
1215
+ h.addAction(new Te(t));
1216
+ }
1217
+ }), yt = () => ({
1218
+ in: (t) => {
1219
+ h.addAction(new ve(t));
1220
+ }
1221
+ }), Et = (t) => ({
1222
+ in: (e) => {
1223
+ const n = new Ne(e, t);
1224
+ h.addAction(n);
1225
+ }
1226
+ }), wt = (t) => ({
1227
+ in: (e) => {
1228
+ const n = new Se(e, t);
1229
+ h.addAction(n);
1230
+ }
1231
+ }), ft = (t) => ({
1232
+ in: (e) => {
1233
+ const n = new be(t, e);
1234
+ h.addAction(n);
1235
+ }
1236
+ }), He = (t) => {
1237
+ h.addAction(new Ie(t));
1238
+ };
1239
+ He.untilElement = (t) => ({
1240
+ isRemoved: () => {
1241
+ h.addAction(new De(t));
1242
+ }
1243
+ });
1244
+ const xt = () => {
1245
+ h.addAction(new Oe());
1246
+ }, At = (t) => {
1247
+ h.addAction(new Pe(t));
1248
+ }, Ct = () => {
1249
+ h.addAction(new Le());
1250
+ };
1251
+ class qe {
1252
+ constructor(e) {
1253
+ o(this, "_document");
1254
+ o(this, "debug");
1255
+ o(this, "_uiUtils");
1256
+ o(this, "speed");
1257
+ o(this, "status");
1258
+ o(this, "runMode");
1259
+ o(this, "currentActionCallback");
1260
+ o(this, "currentAction");
1261
+ this._document = e.document, this.debug = !0, this._uiUtils = new ge(e), this.speed = 1e3, this.status = "Stopped", this.runMode = "Normal";
1262
+ }
1263
+ get document() {
1264
+ return this._document;
1265
+ }
1266
+ get uiUtils() {
1267
+ return this._uiUtils;
1268
+ }
1269
+ get isStepByStepMode() {
1270
+ return this.runMode == "Step By Step";
1271
+ }
1272
+ get isStopped() {
1273
+ return this.status == "Stopped";
1274
+ }
1275
+ get isPlaying() {
1276
+ return this.status == "Playing";
1277
+ }
1278
+ get isPaused() {
1279
+ return this.status == "Paused";
1280
+ }
1281
+ pause() {
1282
+ u.log("Pause Test"), this.status = "Paused";
1283
+ }
1284
+ continue() {
1285
+ u.log("Continue Test"), this.status = "Playing", this.runMode = "Normal", this.currentActionCallback && this.currentAction && (u.log("Continue: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1286
+ }
1287
+ next() {
1288
+ u.log("Continue Test to Next Step..."), this.status = "Playing", this.runMode = "Step By Step", this.currentActionCallback && this.currentAction && (u.log("Next: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1289
+ }
1290
+ stop() {
1291
+ u.log("Stop Test"), this.status = "Stopped", this.currentActionCallback && this.currentAction && (u.log("Stop: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1292
+ }
1293
+ retryAction() {
1294
+ u.log("Retry current step"), this.status = "Playing", this.currentActionCallback && this.currentAction && (this.currentAction.resetTries && (u.log("Retry: Resetting tries for current action"), this.currentAction.resetTries()), u.log("Retry: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1295
+ }
1296
+ skipAction() {
1297
+ u.log("Skip current step"), this.status = "Playing", this.currentActionCallback && this.currentAction && (this.currentAction.status = G.SKIPPED, u.log("Skip: Marked current action as SKIPPED"), m.notifyActionUpdated(this.currentAction), u.log("Skip: Executing current action callback"), this.currentActionCallback(this.currentAction), this.currentActionCallback = void 0);
1298
+ }
1299
+ saveCurrentAction(e, n) {
1300
+ u.log("Save current action"), this.currentActionCallback = e, this.currentAction = n;
1301
+ }
1302
+ setDebug(e) {
1303
+ Fe(e);
1304
+ }
1305
+ }
1306
+ let c;
1307
+ const Nt = (t, e) => (c = new qe(t), ne(c.document), e == null || e.forEach((n) => n()), c);
1308
+ export {
1309
+ G as ACTION_STATUS,
1310
+ ut as Assert,
1311
+ E as AutomationEvents,
1312
+ c as AutomationInstance,
1313
+ pt as ClearValue,
1314
+ lt as Click,
1315
+ ot as DateUtils,
1316
+ b as EVENT_NAMES,
1317
+ At as ManualTask,
1318
+ xt as Pause,
1319
+ gt as PressDownKey,
1320
+ mt as PressEscKey,
1321
+ yt as PressTabKey,
1322
+ Ct as ReloadPage,
1323
+ at as RunTest,
1324
+ ft as SaveValue,
1325
+ ht as Select,
1326
+ X as SelectorBuilder,
1327
+ Nt as Setup,
1328
+ ct as Task,
1329
+ rt as Test,
1330
+ Be as TestSpeed,
1331
+ dt as Type,
1332
+ Et as TypePassword,
1333
+ te as UIElement,
1334
+ wt as UploadFile,
1335
+ He as Wait,
1336
+ st as and,
1337
+ Ge as classIncludes,
1338
+ je as classIs,
1339
+ tt as elementIndexIs,
1340
+ nt as firstChildTextIs,
1341
+ Ye as innerTextContains,
1342
+ Qe as innerTextIs,
1343
+ it as is,
1344
+ et as isFirstElement,
1345
+ _e as placeholderIs,
1346
+ Fe as setAutomationLogs,
1347
+ ze as setFilterLogs,
1348
+ Ze as titleIs,
1349
+ y as wait
1350
+ };