@xpert-ai/chatkit-host-automation 0.3.7 → 0.4.2
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/index.d.ts +848 -76
- package/dist/index.js +1972 -880
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Qt = [
|
|
2
2
|
"host_page_snapshot",
|
|
3
3
|
"host_page_click",
|
|
4
4
|
"host_page_fill",
|
|
@@ -13,104 +13,104 @@ const vt = [
|
|
|
13
13
|
"host_page_read",
|
|
14
14
|
"host_page_wait_for"
|
|
15
15
|
];
|
|
16
|
-
function
|
|
17
|
-
return (
|
|
16
|
+
function Zt(e) {
|
|
17
|
+
return (e ?? "").replace(/\s+/g, " ").trim();
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function It(e, t = 600) {
|
|
20
|
+
return e.length > t ? `${e.slice(0, t)}... [truncated ${e.length - t} chars]` : e;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
22
|
+
function ue(e, t = 600) {
|
|
23
|
+
return e ? It(e, t) : void 0;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
return
|
|
25
|
+
function $(e) {
|
|
26
|
+
const t = Zt(e.textContent);
|
|
27
|
+
return t ? It(t) : void 0;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
const
|
|
31
|
-
Array.from(
|
|
29
|
+
function te(e) {
|
|
30
|
+
const t = Zt(
|
|
31
|
+
Array.from(e.childNodes).filter((n) => n.nodeType === Node.TEXT_NODE).map((n) => n.textContent ?? "").join(" ")
|
|
32
32
|
);
|
|
33
|
-
return
|
|
33
|
+
return t ? It(t) : void 0;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function ft(e) {
|
|
36
36
|
var o;
|
|
37
|
-
if (!(
|
|
37
|
+
if (!(e instanceof HTMLElement || e instanceof SVGElement) || e instanceof HTMLElement && e.hidden)
|
|
38
38
|
return !1;
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
39
|
+
const t = (o = e.ownerDocument.defaultView) == null ? void 0 : o.getComputedStyle(e);
|
|
40
|
+
if (t && (t.display === "none" || t.visibility === "hidden" || t.opacity === "0"))
|
|
41
41
|
return !1;
|
|
42
|
-
const n =
|
|
42
|
+
const n = e.getBoundingClientRect();
|
|
43
43
|
return n.width > 0 && n.height > 0;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
45
|
+
function nt(e) {
|
|
46
|
+
const t = e.getBoundingClientRect();
|
|
47
47
|
return {
|
|
48
|
-
x:
|
|
49
|
-
y:
|
|
50
|
-
width:
|
|
51
|
-
height:
|
|
48
|
+
x: t.left,
|
|
49
|
+
y: t.top,
|
|
50
|
+
width: t.width,
|
|
51
|
+
height: t.height
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
return
|
|
54
|
+
function he(e) {
|
|
55
|
+
return e instanceof Document ? e : e.ownerDocument;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
let
|
|
59
|
-
for (;
|
|
60
|
-
let n =
|
|
57
|
+
function Mt(e) {
|
|
58
|
+
let t = e;
|
|
59
|
+
for (; t; ) {
|
|
60
|
+
let n = t.previousElementSibling;
|
|
61
61
|
for (; n; ) {
|
|
62
62
|
if (n.matches('h1,h2,h3,h4,h5,h6,[role="heading"]'))
|
|
63
|
-
return
|
|
63
|
+
return $(n);
|
|
64
64
|
const o = n.querySelector(
|
|
65
65
|
'h1,h2,h3,h4,h5,h6,[role="heading"]'
|
|
66
66
|
);
|
|
67
67
|
if (o)
|
|
68
|
-
return
|
|
68
|
+
return $(o);
|
|
69
69
|
n = n.previousElementSibling;
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
t = t.parentElement;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
const
|
|
76
|
-
return
|
|
74
|
+
function Et(e) {
|
|
75
|
+
const t = Array.from(e.children).map((n) => te(n) ?? $(n)).filter((n) => !!n);
|
|
76
|
+
return t.length > 1 ? t : e.children.length === 1 ? Et(e.children[0]) : t;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
if (Array.from(
|
|
80
|
-
(i) =>
|
|
78
|
+
function fe(e) {
|
|
79
|
+
if (Array.from(e.children).some(
|
|
80
|
+
(i) => Et(i).length === 2
|
|
81
81
|
))
|
|
82
82
|
return;
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
83
|
+
const t = Et(e);
|
|
84
|
+
if (t.length !== 2)
|
|
85
85
|
return;
|
|
86
|
-
const [n, o] =
|
|
86
|
+
const [n, o] = t;
|
|
87
87
|
if (!(!n || !o || n === o || n.length > 120))
|
|
88
88
|
return { name: n, value: o };
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
return
|
|
90
|
+
function pe(e) {
|
|
91
|
+
return e.fields ? e.fields.slice(0, 2).map((t) => `${t.name}: ${t.value}`) : e.items ? e.items.slice(0, 2) : e.rows ? e.rows.slice(0, 2).map((t) => t.join(" | ")) : e.text ? [e.text] : [];
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
return
|
|
93
|
+
function ge(e) {
|
|
94
|
+
return e.fields ? e.fields.length : e.items ? e.items.length : e.rows ? e.rows.length : e.text ? 1 : 0;
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function me(e) {
|
|
97
97
|
return [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
...
|
|
101
|
-
...(
|
|
102
|
-
...
|
|
103
|
-
...(
|
|
104
|
-
].reduce((
|
|
105
|
-
}
|
|
106
|
-
function
|
|
107
|
-
return
|
|
108
|
-
const o =
|
|
98
|
+
e.heading,
|
|
99
|
+
e.text,
|
|
100
|
+
...e.items ?? [],
|
|
101
|
+
...(e.fields ?? []).flatMap((t) => [t.name, t.value]),
|
|
102
|
+
...e.headers ?? [],
|
|
103
|
+
...(e.rows ?? []).flat()
|
|
104
|
+
].reduce((t, n) => t + ((n == null ? void 0 : n.length) ?? 0), 0);
|
|
105
|
+
}
|
|
106
|
+
function ye(e) {
|
|
107
|
+
return e.slice(0, 80).map((t, n) => {
|
|
108
|
+
const o = me(t), i = `b${n + 1}`;
|
|
109
109
|
return {
|
|
110
|
-
...
|
|
110
|
+
...t,
|
|
111
111
|
blockId: i,
|
|
112
|
-
preview:
|
|
113
|
-
itemCount:
|
|
112
|
+
preview: pe(t),
|
|
113
|
+
itemCount: ge(t),
|
|
114
114
|
chars: o,
|
|
115
115
|
truncated: o > 4e3,
|
|
116
116
|
readHint: {
|
|
@@ -120,49 +120,49 @@ function At(t) {
|
|
|
120
120
|
};
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
return
|
|
123
|
+
function be(e) {
|
|
124
|
+
return e.map((t, n) => ({
|
|
125
125
|
index: n,
|
|
126
|
-
blockId:
|
|
127
|
-
type:
|
|
128
|
-
heading:
|
|
129
|
-
level:
|
|
130
|
-
itemCount:
|
|
131
|
-
chars:
|
|
132
|
-
truncated:
|
|
126
|
+
blockId: t.blockId,
|
|
127
|
+
type: t.type,
|
|
128
|
+
heading: t.heading,
|
|
129
|
+
level: t.level,
|
|
130
|
+
itemCount: t.itemCount,
|
|
131
|
+
chars: t.chars,
|
|
132
|
+
truncated: t.truncated
|
|
133
133
|
}));
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
return
|
|
135
|
+
function ve(e) {
|
|
136
|
+
return e.truncated ? "block_truncated" : e.type === "keyValueList" ? "structured_fields" : e.type === "table" ? "structured_table" : e.itemCount > 2 ? "preview_incomplete" : "long_readable_block";
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
return (
|
|
138
|
+
function we(e) {
|
|
139
|
+
return (e.type === "keyValueList" ? 100 : e.type === "table" ? 90 : e.type === "list" ? 80 : e.type === "paragraph" ? 50 : 10) + (e.truncated ? 40 : 0) + Math.min(e.itemCount, 20) + Math.min(Math.floor(e.chars / 400), 20);
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
return
|
|
143
|
-
(
|
|
144
|
-
).map((
|
|
145
|
-
block:
|
|
141
|
+
function Se(e) {
|
|
142
|
+
return e.filter(
|
|
143
|
+
(t) => t.type !== "heading" && (t.truncated || t.itemCount > 2 || t.chars > 600)
|
|
144
|
+
).map((t, n) => ({
|
|
145
|
+
block: t,
|
|
146
146
|
index: n,
|
|
147
|
-
score:
|
|
148
|
-
})).sort((
|
|
149
|
-
blockId:
|
|
150
|
-
type:
|
|
151
|
-
heading:
|
|
152
|
-
reason:
|
|
147
|
+
score: we(t)
|
|
148
|
+
})).sort((t, n) => n.score - t.score || t.index - n.index).slice(0, 12).sort((t, n) => t.index - n.index).map(({ block: t }) => ({
|
|
149
|
+
blockId: t.blockId,
|
|
150
|
+
type: t.type,
|
|
151
|
+
heading: t.heading,
|
|
152
|
+
reason: ve(t),
|
|
153
153
|
args: {
|
|
154
|
-
blockId:
|
|
155
|
-
pageSize:
|
|
154
|
+
blockId: t.blockId,
|
|
155
|
+
pageSize: t.fields || t.items || t.rows ? Math.min(20, Math.max(1, t.itemCount)) : void 0
|
|
156
156
|
}
|
|
157
157
|
}));
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
const
|
|
159
|
+
function Ee(e) {
|
|
160
|
+
const t = be(e.blocks), n = Se(e.blocks);
|
|
161
161
|
return {
|
|
162
|
-
...
|
|
163
|
-
outline:
|
|
162
|
+
...e,
|
|
163
|
+
outline: t,
|
|
164
164
|
suggestedReads: n,
|
|
165
|
-
blocks:
|
|
165
|
+
blocks: e.blocks.map((o) => ({
|
|
166
166
|
blockId: o.blockId,
|
|
167
167
|
type: o.type,
|
|
168
168
|
heading: o.heading,
|
|
@@ -176,112 +176,112 @@ function Nt(t) {
|
|
|
176
176
|
}))
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
const o = [], i =
|
|
181
|
-
|
|
179
|
+
function _e(e, t, n) {
|
|
180
|
+
const o = [], i = he(e).createTreeWalker(
|
|
181
|
+
e,
|
|
182
182
|
NodeFilter.SHOW_ELEMENT
|
|
183
183
|
);
|
|
184
184
|
let r = i.nextNode();
|
|
185
185
|
for (; r; ) {
|
|
186
|
-
const
|
|
187
|
-
if (
|
|
188
|
-
const
|
|
189
|
-
|
|
186
|
+
const a = r;
|
|
187
|
+
if (ft(a)) {
|
|
188
|
+
const s = fe(a);
|
|
189
|
+
s && o.push({ ...s, element: a });
|
|
190
190
|
}
|
|
191
191
|
r = i.nextNode();
|
|
192
192
|
}
|
|
193
193
|
if (o.length !== 0) {
|
|
194
|
-
|
|
194
|
+
t.push({
|
|
195
195
|
type: "keyValueList",
|
|
196
|
-
heading:
|
|
197
|
-
fields: o.slice(0, 80).map(({ name:
|
|
198
|
-
rect:
|
|
196
|
+
heading: Mt(o[0].element),
|
|
197
|
+
fields: o.slice(0, 80).map(({ name: a, value: s }) => ({ name: a, value: s })),
|
|
198
|
+
rect: nt(o[0].element)
|
|
199
199
|
});
|
|
200
|
-
for (const
|
|
201
|
-
n.add(
|
|
200
|
+
for (const a of o)
|
|
201
|
+
n.add(a.element);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
function
|
|
205
|
-
for (const o of Array.from(
|
|
206
|
-
if (!
|
|
204
|
+
function xe(e, t, n) {
|
|
205
|
+
for (const o of Array.from(e.querySelectorAll('ul,ol,[role="list"]'))) {
|
|
206
|
+
if (!ft(o))
|
|
207
207
|
continue;
|
|
208
|
-
const i = Array.from(o.children).map((r) =>
|
|
208
|
+
const i = Array.from(o.children).map((r) => $(r)).filter((r) => !!r).slice(0, 80);
|
|
209
209
|
if (i.length !== 0) {
|
|
210
|
-
|
|
210
|
+
t.push({
|
|
211
211
|
type: "list",
|
|
212
|
-
heading:
|
|
212
|
+
heading: Mt(o),
|
|
213
213
|
items: i,
|
|
214
|
-
rect:
|
|
214
|
+
rect: nt(o)
|
|
215
215
|
}), n.add(o);
|
|
216
216
|
for (const r of Array.from(o.children))
|
|
217
217
|
n.add(r);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function Re(e, t, n) {
|
|
222
222
|
var o;
|
|
223
|
-
for (const i of Array.from(
|
|
224
|
-
if (!
|
|
223
|
+
for (const i of Array.from(e.querySelectorAll('table,[role="table"],[role="grid"]'))) {
|
|
224
|
+
if (!ft(i))
|
|
225
225
|
continue;
|
|
226
226
|
const r = Array.from(i.querySelectorAll('tr,[role="row"]')).map(
|
|
227
|
-
(
|
|
228
|
-
).filter((
|
|
227
|
+
(s) => Array.from(s.querySelectorAll('th,td,[role="columnheader"],[role="cell"],[role="gridcell"]')).map((d) => $(d)).filter((d) => !!d).slice(0, 12)
|
|
228
|
+
).filter((s) => s.length > 0).slice(0, 80);
|
|
229
229
|
if (r.length === 0)
|
|
230
230
|
continue;
|
|
231
|
-
const
|
|
232
|
-
|
|
231
|
+
const a = (o = r[0]) != null && o.every((s) => s.length <= 120) ? r[0] : void 0;
|
|
232
|
+
t.push({
|
|
233
233
|
type: "table",
|
|
234
|
-
heading:
|
|
235
|
-
headers:
|
|
236
|
-
rows:
|
|
237
|
-
rect:
|
|
234
|
+
heading: Mt(i),
|
|
235
|
+
headers: a,
|
|
236
|
+
rows: a ? r.slice(1) : r,
|
|
237
|
+
rect: nt(i)
|
|
238
238
|
}), n.add(i);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function Te(e, t, n) {
|
|
242
242
|
const o = 'h1,h2,h3,h4,h5,h6,[role="heading"],p,article,section';
|
|
243
|
-
for (const i of Array.from(
|
|
244
|
-
if (
|
|
243
|
+
for (const i of Array.from(e.querySelectorAll(o))) {
|
|
244
|
+
if (t.length >= 80)
|
|
245
245
|
break;
|
|
246
|
-
if (n.has(i) || !
|
|
246
|
+
if (n.has(i) || !ft(i))
|
|
247
247
|
continue;
|
|
248
|
-
const r = i.tagName.toLowerCase(),
|
|
249
|
-
if (
|
|
248
|
+
const r = i.tagName.toLowerCase(), a = te(i) ?? $(i);
|
|
249
|
+
if (a) {
|
|
250
250
|
if (r.match(/^h[1-6]$/) || i.getAttribute("role") === "heading") {
|
|
251
|
-
const
|
|
252
|
-
|
|
251
|
+
const s = r.match(/^h[1-6]$/) ? Number(r.slice(1)) : Number(i.getAttribute("aria-level") ?? 0) || 2;
|
|
252
|
+
t.push({
|
|
253
253
|
type: "heading",
|
|
254
|
-
level:
|
|
255
|
-
text:
|
|
256
|
-
rect:
|
|
254
|
+
level: s,
|
|
255
|
+
text: a,
|
|
256
|
+
rect: nt(i)
|
|
257
257
|
});
|
|
258
258
|
continue;
|
|
259
259
|
}
|
|
260
|
-
|
|
260
|
+
a.length >= 24 && t.push({
|
|
261
261
|
type: "paragraph",
|
|
262
|
-
text:
|
|
263
|
-
rect:
|
|
262
|
+
text: a,
|
|
263
|
+
rect: nt(i)
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
|
-
function
|
|
269
|
-
return
|
|
268
|
+
function Ae(e) {
|
|
269
|
+
return e.querySelectorAll(
|
|
270
270
|
'[aria-expanded="false"],[data-expanded="false"],details:not([open]),[hidden]'
|
|
271
271
|
).length;
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
return Array.from(
|
|
273
|
+
function Ce(e) {
|
|
274
|
+
return Array.from(e.querySelectorAll("iframe")).filter((t) => {
|
|
275
275
|
try {
|
|
276
|
-
return !
|
|
276
|
+
return !t.contentDocument;
|
|
277
277
|
} catch {
|
|
278
278
|
return !0;
|
|
279
279
|
}
|
|
280
280
|
}).length;
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
const
|
|
284
|
-
if (!
|
|
282
|
+
function Nt(e) {
|
|
283
|
+
const t = e instanceof Document ? e.body ?? e.documentElement : e;
|
|
284
|
+
if (!t)
|
|
285
285
|
return {
|
|
286
286
|
blocks: [],
|
|
287
287
|
totalBlocks: 0,
|
|
@@ -297,154 +297,154 @@ function ot(t) {
|
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
299
|
const n = [], o = /* @__PURE__ */ new Set();
|
|
300
|
-
|
|
301
|
-
const i =
|
|
302
|
-
return
|
|
300
|
+
_e(t, n, o), xe(t, n, o), Re(t, n, o), Te(t, n, o);
|
|
301
|
+
const i = ye(n), r = i.filter((c) => c.truncated).length, a = Ae(t), s = Ce(t), d = n.length > i.length || r > 0 || a > 0 || s > 0, u = [];
|
|
302
|
+
return a > 0 && u.push("Some content is inside collapsed sections."), s > 0 && u.push("Some frame content could not be read from DOM."), {
|
|
303
303
|
blocks: i,
|
|
304
304
|
totalBlocks: n.length,
|
|
305
305
|
truncated: n.length > i.length || r > 0,
|
|
306
306
|
coverage: {
|
|
307
|
-
status:
|
|
307
|
+
status: d ? "partial" : "complete",
|
|
308
308
|
visibleTextCaptured: i.length > 0,
|
|
309
309
|
truncatedBlocks: r,
|
|
310
|
-
collapsedSections:
|
|
311
|
-
crossOriginFrames:
|
|
310
|
+
collapsedSections: a,
|
|
311
|
+
crossOriginFrames: s,
|
|
312
312
|
virtualizedListsDetected: 0,
|
|
313
313
|
visualOnlyRegions: 0
|
|
314
314
|
},
|
|
315
|
-
...
|
|
315
|
+
...u.length > 0 ? { warnings: u } : {}
|
|
316
316
|
};
|
|
317
317
|
}
|
|
318
|
-
function
|
|
319
|
-
const o = Math.max(1, Math.min(100, Math.floor(n))), i = Math.max(1, Math.ceil(
|
|
318
|
+
function rt(e, t, n) {
|
|
319
|
+
const o = Math.max(1, Math.min(100, Math.floor(n))), i = Math.max(1, Math.ceil(e / o)), r = Math.max(1, Math.min(i, Math.floor(t))), a = (r - 1) * o;
|
|
320
320
|
return {
|
|
321
321
|
page: r,
|
|
322
322
|
pageSize: o,
|
|
323
323
|
pageCount: i,
|
|
324
|
-
start:
|
|
325
|
-
end: Math.min(
|
|
324
|
+
start: a,
|
|
325
|
+
end: Math.min(e, a + o)
|
|
326
326
|
};
|
|
327
327
|
}
|
|
328
|
-
function
|
|
329
|
-
return JSON.stringify(
|
|
328
|
+
function _t(e) {
|
|
329
|
+
return JSON.stringify(e).length;
|
|
330
330
|
}
|
|
331
|
-
function
|
|
332
|
-
const n = t
|
|
331
|
+
function yt(e, t) {
|
|
332
|
+
const n = e[t];
|
|
333
333
|
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
334
334
|
}
|
|
335
|
-
function
|
|
336
|
-
const n = t
|
|
335
|
+
function st(e, t) {
|
|
336
|
+
const n = e[t];
|
|
337
337
|
return typeof n == "string" && n.trim() ? n : void 0;
|
|
338
338
|
}
|
|
339
|
-
function
|
|
339
|
+
function xt(e, t, n = !1) {
|
|
340
340
|
const o = {
|
|
341
|
-
...
|
|
342
|
-
truncated: !!
|
|
343
|
-
}, i =
|
|
341
|
+
...e,
|
|
342
|
+
truncated: !!e.truncated || n
|
|
343
|
+
}, i = _t(o), r = {
|
|
344
344
|
...o,
|
|
345
345
|
chars: i
|
|
346
346
|
};
|
|
347
|
-
return
|
|
348
|
-
blockId:
|
|
349
|
-
type:
|
|
350
|
-
heading:
|
|
351
|
-
scope:
|
|
352
|
-
page:
|
|
347
|
+
return _t(r) <= t ? r : {
|
|
348
|
+
blockId: st(e, "blockId"),
|
|
349
|
+
type: st(e, "type"),
|
|
350
|
+
heading: ue(st(e, "heading"), 120),
|
|
351
|
+
scope: st(e, "scope"),
|
|
352
|
+
page: yt(e, "page"),
|
|
353
353
|
pageSize: 0,
|
|
354
|
-
pageCount:
|
|
355
|
-
nextPage:
|
|
354
|
+
pageCount: yt(e, "pageCount"),
|
|
355
|
+
nextPage: yt(e, "nextPage"),
|
|
356
356
|
chars: i,
|
|
357
357
|
truncated: !0,
|
|
358
358
|
budgetExceeded: !0,
|
|
359
359
|
warning: "Read result exceeded maxChars; retry with a smaller pageSize or a narrower blockId/query."
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
|
-
function
|
|
363
|
-
let o =
|
|
362
|
+
function at(e, t, n) {
|
|
363
|
+
let o = t;
|
|
364
364
|
for (; o >= 1; ) {
|
|
365
|
-
const i = n(o), r =
|
|
365
|
+
const i = n(o), r = xt(
|
|
366
366
|
i,
|
|
367
|
-
|
|
368
|
-
o <
|
|
367
|
+
e,
|
|
368
|
+
o < t
|
|
369
369
|
);
|
|
370
|
-
if (
|
|
370
|
+
if (_t(r) <= e)
|
|
371
371
|
return r;
|
|
372
372
|
o = Math.floor(o / 2);
|
|
373
373
|
}
|
|
374
|
-
return
|
|
374
|
+
return xt(n(1), e, !0);
|
|
375
375
|
}
|
|
376
|
-
function
|
|
377
|
-
var
|
|
378
|
-
const n = typeof
|
|
379
|
-
(
|
|
380
|
-
) :
|
|
381
|
-
if (
|
|
382
|
-
if (
|
|
383
|
-
const
|
|
384
|
-
return
|
|
385
|
-
const
|
|
376
|
+
function Ie(e, t = {}) {
|
|
377
|
+
var d;
|
|
378
|
+
const n = typeof t.page == "number" ? t.page : 1, o = typeof t.pageSize == "number" ? t.pageSize : 20, i = typeof t.maxChars == "number" && Number.isFinite(t.maxChars) ? Math.max(500, Math.min(12e3, Math.floor(t.maxChars))) : 4e3, r = (d = t.query) == null ? void 0 : d.trim().toLowerCase(), a = r ? e.blocks.filter(
|
|
379
|
+
(u) => JSON.stringify(u).toLowerCase().includes(r)
|
|
380
|
+
) : e.blocks, s = t.blockId ? e.blocks.find((u) => u.blockId === t.blockId) : void 0;
|
|
381
|
+
if (s) {
|
|
382
|
+
if (s.fields && s.fields.length > 0) {
|
|
383
|
+
const u = s.fields;
|
|
384
|
+
return at(i, o, (c) => {
|
|
385
|
+
const l = rt(u.length, n, c);
|
|
386
386
|
return {
|
|
387
|
-
...
|
|
388
|
-
fields:
|
|
389
|
-
page:
|
|
390
|
-
pageSize:
|
|
391
|
-
pageCount:
|
|
392
|
-
nextPage:
|
|
387
|
+
...s,
|
|
388
|
+
fields: u.slice(l.start, l.end),
|
|
389
|
+
page: l.page,
|
|
390
|
+
pageSize: l.pageSize,
|
|
391
|
+
pageCount: l.pageCount,
|
|
392
|
+
nextPage: l.page < l.pageCount ? l.page + 1 : void 0
|
|
393
393
|
};
|
|
394
394
|
});
|
|
395
395
|
}
|
|
396
|
-
if (
|
|
397
|
-
const
|
|
398
|
-
return
|
|
399
|
-
const
|
|
396
|
+
if (s.items && s.items.length > 0) {
|
|
397
|
+
const u = s.items;
|
|
398
|
+
return at(i, o, (c) => {
|
|
399
|
+
const l = rt(u.length, n, c);
|
|
400
400
|
return {
|
|
401
|
-
...
|
|
402
|
-
items:
|
|
403
|
-
page:
|
|
404
|
-
pageSize:
|
|
405
|
-
pageCount:
|
|
406
|
-
nextPage:
|
|
401
|
+
...s,
|
|
402
|
+
items: u.slice(l.start, l.end),
|
|
403
|
+
page: l.page,
|
|
404
|
+
pageSize: l.pageSize,
|
|
405
|
+
pageCount: l.pageCount,
|
|
406
|
+
nextPage: l.page < l.pageCount ? l.page + 1 : void 0
|
|
407
407
|
};
|
|
408
408
|
});
|
|
409
409
|
}
|
|
410
|
-
if (
|
|
411
|
-
const
|
|
412
|
-
return
|
|
413
|
-
const
|
|
410
|
+
if (s.rows && s.rows.length > 0) {
|
|
411
|
+
const u = s.rows;
|
|
412
|
+
return at(i, o, (c) => {
|
|
413
|
+
const l = rt(u.length, n, c);
|
|
414
414
|
return {
|
|
415
|
-
...
|
|
416
|
-
rows:
|
|
417
|
-
page:
|
|
418
|
-
pageSize:
|
|
419
|
-
pageCount:
|
|
420
|
-
nextPage:
|
|
415
|
+
...s,
|
|
416
|
+
rows: u.slice(l.start, l.end),
|
|
417
|
+
page: l.page,
|
|
418
|
+
pageSize: l.pageSize,
|
|
419
|
+
pageCount: l.pageCount,
|
|
420
|
+
nextPage: l.page < l.pageCount ? l.page + 1 : void 0
|
|
421
421
|
};
|
|
422
422
|
});
|
|
423
423
|
}
|
|
424
|
-
return
|
|
424
|
+
return xt(s, i);
|
|
425
425
|
}
|
|
426
|
-
return
|
|
427
|
-
const
|
|
426
|
+
return at(i, o, (u) => {
|
|
427
|
+
const c = rt(a.length, n, u);
|
|
428
428
|
return {
|
|
429
429
|
scope: "visible",
|
|
430
|
-
blocks:
|
|
431
|
-
page:
|
|
432
|
-
pageSize:
|
|
433
|
-
pageCount:
|
|
434
|
-
nextPage:
|
|
435
|
-
coverage:
|
|
436
|
-
warnings:
|
|
430
|
+
blocks: a.slice(c.start, c.end),
|
|
431
|
+
page: c.page,
|
|
432
|
+
pageSize: c.pageSize,
|
|
433
|
+
pageCount: c.pageCount,
|
|
434
|
+
nextPage: c.page < c.pageCount ? c.page + 1 : void 0,
|
|
435
|
+
coverage: e.coverage,
|
|
436
|
+
warnings: e.warnings
|
|
437
437
|
};
|
|
438
438
|
});
|
|
439
439
|
}
|
|
440
|
-
class
|
|
441
|
-
constructor(
|
|
442
|
-
super(
|
|
440
|
+
class W extends Error {
|
|
441
|
+
constructor(t, n) {
|
|
442
|
+
super(t), this.details = n;
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
),
|
|
445
|
+
const Me = new Set(
|
|
446
|
+
Qt
|
|
447
|
+
), ke = [
|
|
448
448
|
"a[href]",
|
|
449
449
|
"button",
|
|
450
450
|
"input",
|
|
@@ -459,34 +459,76 @@ const Ft = new Set(
|
|
|
459
459
|
"[data-testid]",
|
|
460
460
|
"[data-test-id]",
|
|
461
461
|
"[data-qa]"
|
|
462
|
-
].join(","),
|
|
463
|
-
|
|
464
|
-
|
|
462
|
+
].join(","), Ot = 100, De = 1e4, Pe = 6e4, qt = 1e4, Ne = 100, Oe = 6e4, Lt = 2 * 6e4, qe = [
|
|
463
|
+
"id",
|
|
464
|
+
"role",
|
|
465
|
+
"aria-label",
|
|
466
|
+
"aria-labelledby",
|
|
467
|
+
"data-testid",
|
|
468
|
+
"data-test-id",
|
|
469
|
+
"data-qa",
|
|
470
|
+
"name",
|
|
471
|
+
"disabled",
|
|
472
|
+
"aria-disabled",
|
|
473
|
+
"hidden"
|
|
474
|
+
];
|
|
475
|
+
function jt() {
|
|
476
|
+
var e, t;
|
|
477
|
+
return ((t = (e = globalThis.crypto) == null ? void 0 : e.randomUUID) == null ? void 0 : t.call(e)) ?? `page-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
465
478
|
}
|
|
466
|
-
function
|
|
467
|
-
|
|
479
|
+
function Rt(e) {
|
|
480
|
+
if (e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean")
|
|
481
|
+
return e;
|
|
482
|
+
if (Array.isArray(e))
|
|
483
|
+
return e.map(Rt);
|
|
484
|
+
if (typeof e == "object")
|
|
485
|
+
return Object.fromEntries(
|
|
486
|
+
Object.entries(e).filter(([t, n]) => t !== "actionToken" && n !== void 0).sort(([t], [n]) => t.localeCompare(n)).map(([t, n]) => [t, Rt(n)])
|
|
487
|
+
);
|
|
468
488
|
}
|
|
469
|
-
function
|
|
470
|
-
|
|
489
|
+
async function Bt(e) {
|
|
490
|
+
const t = new TextEncoder().encode(
|
|
491
|
+
JSON.stringify(Rt(e))
|
|
492
|
+
), n = await globalThis.crypto.subtle.digest("SHA-256", t);
|
|
493
|
+
return Array.from(
|
|
494
|
+
new Uint8Array(n),
|
|
495
|
+
(o) => o.toString(16).padStart(2, "0")
|
|
496
|
+
).join("");
|
|
471
497
|
}
|
|
472
|
-
function
|
|
473
|
-
return
|
|
498
|
+
function Le(e) {
|
|
499
|
+
return Me.has(e);
|
|
474
500
|
}
|
|
475
|
-
function
|
|
476
|
-
if (
|
|
477
|
-
|
|
478
|
-
|
|
501
|
+
function k(e) {
|
|
502
|
+
if (e.nodeType === 9)
|
|
503
|
+
return e;
|
|
504
|
+
if (!e.ownerDocument)
|
|
505
|
+
throw new Error("Host automation root has no owner document.");
|
|
506
|
+
return e.ownerDocument;
|
|
507
|
+
}
|
|
508
|
+
function O(e) {
|
|
509
|
+
return k(e).defaultView ?? window;
|
|
510
|
+
}
|
|
511
|
+
function A(e) {
|
|
512
|
+
return typeof e == "object" && e !== null && !Array.isArray(e) ? e : {};
|
|
513
|
+
}
|
|
514
|
+
function bt(e, t) {
|
|
515
|
+
if (typeof e != "string" || e.trim() === "")
|
|
516
|
+
throw new Error(`${t} must be a non-empty string.`);
|
|
517
|
+
return e;
|
|
479
518
|
}
|
|
480
|
-
function
|
|
481
|
-
return typeof
|
|
519
|
+
function m(e) {
|
|
520
|
+
return typeof e == "string" && e.trim() ? e : void 0;
|
|
482
521
|
}
|
|
483
|
-
function
|
|
484
|
-
return
|
|
522
|
+
function Q(e) {
|
|
523
|
+
return e === "viewport_normalized" ? "viewport_normalized" : "viewport-css-px";
|
|
485
524
|
}
|
|
486
|
-
function
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
525
|
+
function Vt(e) {
|
|
526
|
+
return ee(e, ["move", "down", "up", "click"]) ?? "click";
|
|
527
|
+
}
|
|
528
|
+
function Ft(e, t) {
|
|
529
|
+
const n = Ht(t.x, "x"), o = Ht(t.y, "y");
|
|
530
|
+
if (Q(t.coordinateSpace) === "viewport_normalized") {
|
|
531
|
+
const i = O(e);
|
|
490
532
|
return {
|
|
491
533
|
x: Number((n * i.innerWidth).toFixed(3)),
|
|
492
534
|
y: Number((o * i.innerHeight).toFixed(3))
|
|
@@ -494,64 +536,89 @@ function rt(t, e) {
|
|
|
494
536
|
}
|
|
495
537
|
return { x: n, y: o };
|
|
496
538
|
}
|
|
497
|
-
function
|
|
498
|
-
return typeof
|
|
539
|
+
function ct(e) {
|
|
540
|
+
return typeof e == "number" && Number.isInteger(e) ? e : void 0;
|
|
499
541
|
}
|
|
500
|
-
function
|
|
501
|
-
if (typeof
|
|
502
|
-
throw new Error(`${
|
|
503
|
-
return
|
|
542
|
+
function Ht(e, t) {
|
|
543
|
+
if (typeof e != "number" || !Number.isFinite(e))
|
|
544
|
+
throw new Error(`${t} must be a finite number.`);
|
|
545
|
+
return e;
|
|
504
546
|
}
|
|
505
|
-
function
|
|
506
|
-
return typeof
|
|
547
|
+
function G(e) {
|
|
548
|
+
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
507
549
|
}
|
|
508
|
-
function
|
|
509
|
-
return typeof
|
|
550
|
+
function ee(e, t) {
|
|
551
|
+
return typeof e == "string" && t.includes(e) ? e : void 0;
|
|
510
552
|
}
|
|
511
|
-
function
|
|
512
|
-
if (typeof
|
|
513
|
-
return [
|
|
514
|
-
if (Array.isArray(
|
|
515
|
-
return
|
|
553
|
+
function je(e) {
|
|
554
|
+
if (typeof e == "string")
|
|
555
|
+
return [e];
|
|
556
|
+
if (Array.isArray(e) && e.every((t) => typeof t == "string"))
|
|
557
|
+
return e;
|
|
516
558
|
throw new Error("value or values must be a string or an array of strings.");
|
|
517
559
|
}
|
|
518
|
-
function
|
|
519
|
-
const
|
|
520
|
-
return
|
|
560
|
+
function _(e) {
|
|
561
|
+
const t = (e.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
562
|
+
return t ? t.slice(0, 160) : void 0;
|
|
563
|
+
}
|
|
564
|
+
function pt(e) {
|
|
565
|
+
const t = Array.from(e.childNodes).filter((n) => n.nodeType === Node.TEXT_NODE).map((n) => n.textContent ?? "").join(" ").replace(/\s+/g, " ").trim();
|
|
566
|
+
return t ? t.slice(0, 160) : void 0;
|
|
521
567
|
}
|
|
522
|
-
function
|
|
523
|
-
|
|
524
|
-
return e ? e.slice(0, 160) : void 0;
|
|
568
|
+
function T(e) {
|
|
569
|
+
return e.tagName.toLowerCase() === "input";
|
|
525
570
|
}
|
|
526
|
-
function
|
|
527
|
-
|
|
528
|
-
return t.value;
|
|
571
|
+
function z(e) {
|
|
572
|
+
return e.tagName.toLowerCase() === "textarea";
|
|
529
573
|
}
|
|
530
|
-
function
|
|
531
|
-
return
|
|
574
|
+
function L(e) {
|
|
575
|
+
return e.tagName.toLowerCase() === "select";
|
|
532
576
|
}
|
|
533
|
-
function
|
|
534
|
-
return
|
|
577
|
+
function ne(e) {
|
|
578
|
+
return e.tagName.toLowerCase() === "button";
|
|
535
579
|
}
|
|
536
|
-
function
|
|
580
|
+
function Tt(e) {
|
|
581
|
+
return e.tagName.toLowerCase() === "iframe";
|
|
582
|
+
}
|
|
583
|
+
function I(e) {
|
|
584
|
+
var n;
|
|
585
|
+
const t = (n = e.ownerDocument.defaultView) == null ? void 0 : n.HTMLElement;
|
|
586
|
+
return !!(t && e instanceof t);
|
|
587
|
+
}
|
|
588
|
+
function kt(e) {
|
|
589
|
+
var n;
|
|
590
|
+
const t = (n = e.ownerDocument.defaultView) == null ? void 0 : n.SVGElement;
|
|
591
|
+
return !!(t && e instanceof t);
|
|
592
|
+
}
|
|
593
|
+
function ht(e) {
|
|
594
|
+
if (T(e) || z(e) || L(e))
|
|
595
|
+
return e.value;
|
|
596
|
+
}
|
|
597
|
+
function oe(e) {
|
|
598
|
+
return T(e) && (e.type === "checkbox" || e.type === "radio");
|
|
599
|
+
}
|
|
600
|
+
function Be(e) {
|
|
601
|
+
return T(e) || L(e) || z(e) ? Array.from(e.labels ?? []) : [];
|
|
602
|
+
}
|
|
603
|
+
function Ve(e, t) {
|
|
537
604
|
var o;
|
|
538
|
-
return (((o =
|
|
605
|
+
return (((o = e.getAttribute(t)) == null ? void 0 : o.trim().split(/\s+/)) ?? []).map((i) => e.ownerDocument.getElementById(i)).filter((i) => !!i).map((i) => _(i)).filter((i) => !!i);
|
|
539
606
|
}
|
|
540
|
-
function
|
|
541
|
-
const
|
|
542
|
-
if (
|
|
543
|
-
return
|
|
544
|
-
const n =
|
|
607
|
+
function Fe(e) {
|
|
608
|
+
const t = Ve(e, "aria-labelledby");
|
|
609
|
+
if (t.length > 0)
|
|
610
|
+
return t.join(" ").slice(0, 160);
|
|
611
|
+
const n = Be(e).map((o) => _(o)).filter((o) => !!o);
|
|
545
612
|
if (n.length > 0)
|
|
546
613
|
return n.join(" ").slice(0, 160);
|
|
547
614
|
}
|
|
548
|
-
function
|
|
549
|
-
const
|
|
550
|
-
let n =
|
|
615
|
+
function He(e) {
|
|
616
|
+
const t = [];
|
|
617
|
+
let n = e.nextSibling;
|
|
551
618
|
for (; n; ) {
|
|
552
619
|
if (n.nodeType === Node.TEXT_NODE) {
|
|
553
620
|
const i = (n.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
554
|
-
i &&
|
|
621
|
+
i && t.push(i);
|
|
555
622
|
} else {
|
|
556
623
|
if (n.nodeType === Node.ELEMENT_NODE && n.tagName.toLowerCase() === "br")
|
|
557
624
|
break;
|
|
@@ -561,166 +628,166 @@ function Qt(t) {
|
|
|
561
628
|
'input,textarea,select,button,a[href],[role="button"],[role="link"]'
|
|
562
629
|
))
|
|
563
630
|
break;
|
|
564
|
-
const r =
|
|
565
|
-
r &&
|
|
631
|
+
const r = _(i);
|
|
632
|
+
r && t.push(r);
|
|
566
633
|
break;
|
|
567
634
|
}
|
|
568
635
|
}
|
|
569
|
-
if (
|
|
636
|
+
if (t.join(" ").length >= 120)
|
|
570
637
|
break;
|
|
571
638
|
n = n.nextSibling;
|
|
572
639
|
}
|
|
573
|
-
const o =
|
|
640
|
+
const o = t.join(" ").replace(/\s+/g, " ").trim();
|
|
574
641
|
return o ? o.slice(0, 160) : void 0;
|
|
575
642
|
}
|
|
576
|
-
function
|
|
577
|
-
var
|
|
578
|
-
const n =
|
|
643
|
+
function Xt(e, t) {
|
|
644
|
+
var u;
|
|
645
|
+
const n = e.ownerDocument, o = n.body;
|
|
579
646
|
if (!o)
|
|
580
647
|
return;
|
|
581
|
-
const i =
|
|
648
|
+
const i = e.getBoundingClientRect();
|
|
582
649
|
if (i.width <= 0 || i.height <= 0)
|
|
583
650
|
return;
|
|
584
|
-
const r = i.top + i.height / 2,
|
|
585
|
-
let
|
|
586
|
-
for (;
|
|
587
|
-
const
|
|
588
|
-
if (
|
|
589
|
-
const
|
|
590
|
-
if (
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
text:
|
|
594
|
-
score: Math.abs(p) + Math.abs(
|
|
651
|
+
const r = i.top + i.height / 2, a = [], s = n.createTreeWalker(o, NodeFilter.SHOW_ELEMENT);
|
|
652
|
+
let d = s.nextNode();
|
|
653
|
+
for (; d; ) {
|
|
654
|
+
const c = d;
|
|
655
|
+
if (c !== e && !c.contains(e) && Dt(c)) {
|
|
656
|
+
const l = c.getBoundingClientRect(), h = pt(c) ?? _(c);
|
|
657
|
+
if (h) {
|
|
658
|
+
const g = l.top + l.height / 2, f = Math.abs(g - r) <= Math.max(28, i.height * 1.25), p = t === "left" ? i.left - l.right : l.left - i.right;
|
|
659
|
+
f && p >= -8 && p <= 240 && a.push({
|
|
660
|
+
text: h,
|
|
661
|
+
score: Math.abs(p) + Math.abs(g - r)
|
|
595
662
|
});
|
|
596
663
|
}
|
|
597
664
|
}
|
|
598
|
-
|
|
665
|
+
d = s.nextNode();
|
|
599
666
|
}
|
|
600
|
-
return (
|
|
667
|
+
return (u = a.sort((c, l) => c.score - l.score)[0]) == null ? void 0 : u.text;
|
|
601
668
|
}
|
|
602
|
-
function
|
|
603
|
-
if (!(
|
|
669
|
+
function ot(e) {
|
|
670
|
+
if (!(T(e) || L(e) || z(e)))
|
|
604
671
|
return;
|
|
605
|
-
const
|
|
606
|
-
return
|
|
672
|
+
const t = Fe(e);
|
|
673
|
+
return t || (oe(e) ? Xt(e, "right") ?? He(e) ?? U(e)[0] : Xt(e, "left") ?? U(e)[0]);
|
|
607
674
|
}
|
|
608
|
-
function
|
|
609
|
-
const n =
|
|
610
|
-
return
|
|
675
|
+
function $t(e, t) {
|
|
676
|
+
const n = t.trim().toLowerCase();
|
|
677
|
+
return T(e) && e.type === "radio" ? n === "radio" || n === "radio button" : T(e) && e.type === "checkbox" ? n === "checkbox" || n === "check box" : L(e) ? n === "select" || n === "select menu" || n === "combobox" || n === "combo box" : !1;
|
|
611
678
|
}
|
|
612
|
-
function
|
|
613
|
-
const
|
|
614
|
-
if (n != null && n.trim() &&
|
|
679
|
+
function R(e) {
|
|
680
|
+
const t = ot(e), n = e.getAttribute("aria-label");
|
|
681
|
+
if (n != null && n.trim() && !$t(e, n))
|
|
615
682
|
return n.trim();
|
|
616
|
-
const o =
|
|
617
|
-
if (o != null && o.trim() &&
|
|
683
|
+
const o = e.getAttribute("title");
|
|
684
|
+
if (o != null && o.trim() && !$t(e, o))
|
|
618
685
|
return o.trim();
|
|
619
|
-
if (
|
|
620
|
-
return
|
|
621
|
-
const i =
|
|
622
|
-
return i ||
|
|
686
|
+
if (t)
|
|
687
|
+
return t;
|
|
688
|
+
const i = U(e)[0];
|
|
689
|
+
return i || _(e);
|
|
623
690
|
}
|
|
624
|
-
function
|
|
625
|
-
if (!(
|
|
691
|
+
function Dt(e) {
|
|
692
|
+
if (!(I(e) || kt(e)) || !D(e) || e.matches(
|
|
626
693
|
'input,textarea,select,button,a[href],[role="button"],[role="link"]'
|
|
627
694
|
))
|
|
628
695
|
return !1;
|
|
629
|
-
const
|
|
630
|
-
return !!(
|
|
696
|
+
const t = pt(e) ?? _(e);
|
|
697
|
+
return !!(t && t.length <= 120);
|
|
631
698
|
}
|
|
632
|
-
function
|
|
633
|
-
var
|
|
634
|
-
if (!
|
|
699
|
+
function ie(e) {
|
|
700
|
+
var l;
|
|
701
|
+
if (!oe(e))
|
|
635
702
|
return;
|
|
636
|
-
const
|
|
703
|
+
const t = e.closest("fieldset"), n = t == null ? void 0 : t.querySelector("legend"), o = n ? _(n) : void 0;
|
|
637
704
|
if (o)
|
|
638
705
|
return o;
|
|
639
|
-
const i =
|
|
706
|
+
const i = e.ownerDocument, r = i.body;
|
|
640
707
|
if (!r)
|
|
641
708
|
return;
|
|
642
|
-
const
|
|
643
|
-
if (
|
|
709
|
+
const a = e.getBoundingClientRect();
|
|
710
|
+
if (a.width <= 0 || a.height <= 0)
|
|
644
711
|
return;
|
|
645
|
-
const
|
|
646
|
-
let
|
|
647
|
-
for (;
|
|
648
|
-
const
|
|
649
|
-
if (
|
|
650
|
-
const
|
|
651
|
-
if (
|
|
652
|
-
const p =
|
|
653
|
-
p <= 160 &&
|
|
654
|
-
text:
|
|
655
|
-
score: p + Math.abs(
|
|
712
|
+
const s = a.left + a.width / 2, d = [], u = i.createTreeWalker(r, NodeFilter.SHOW_ELEMENT);
|
|
713
|
+
let c = u.nextNode();
|
|
714
|
+
for (; c; ) {
|
|
715
|
+
const h = c;
|
|
716
|
+
if (h !== e && !h.contains(e) && h.matches('legend,strong,b,[role="heading"],h1,h2,h3,h4,h5,h6') && Dt(h)) {
|
|
717
|
+
const g = h.getBoundingClientRect(), f = pt(h) ?? _(h);
|
|
718
|
+
if (f && g.bottom <= a.top + 8) {
|
|
719
|
+
const p = a.top - g.bottom, b = g.left + g.width / 2;
|
|
720
|
+
p <= 160 && b >= a.left - 120 && b <= a.right + 320 && d.push({
|
|
721
|
+
text: f,
|
|
722
|
+
score: p + Math.abs(b - s) * 0.25
|
|
656
723
|
});
|
|
657
724
|
}
|
|
658
725
|
}
|
|
659
|
-
|
|
726
|
+
c = u.nextNode();
|
|
660
727
|
}
|
|
661
|
-
return (
|
|
728
|
+
return (l = d.sort((h, g) => h.score - g.score)[0]) == null ? void 0 : l.text;
|
|
662
729
|
}
|
|
663
|
-
function
|
|
664
|
-
if (!(
|
|
730
|
+
function Xe(e) {
|
|
731
|
+
if (!L(e))
|
|
665
732
|
return;
|
|
666
|
-
const
|
|
733
|
+
const t = Array.from(e.options).map((n) => ({
|
|
667
734
|
label: ((n.label || n.textContent || n.value).replace(/\s+/g, " ").trim() || n.value).slice(0, 160),
|
|
668
735
|
value: n.value,
|
|
669
736
|
selected: n.selected || void 0,
|
|
670
737
|
disabled: n.disabled || void 0
|
|
671
738
|
}));
|
|
672
|
-
return
|
|
739
|
+
return t.length ? t : void 0;
|
|
673
740
|
}
|
|
674
|
-
function
|
|
675
|
-
if (!(
|
|
741
|
+
function $e(e) {
|
|
742
|
+
if (!L(e))
|
|
676
743
|
return;
|
|
677
|
-
const
|
|
744
|
+
const t = e.selectedOptions[0], n = t ? (t.label || t.textContent || t.value).replace(/\s+/g, " ").trim() : void 0;
|
|
678
745
|
return n ? n.slice(0, 160) : void 0;
|
|
679
746
|
}
|
|
680
|
-
function
|
|
681
|
-
const
|
|
747
|
+
function U(e) {
|
|
748
|
+
const t = e.ownerDocument, n = t.body;
|
|
682
749
|
if (!n)
|
|
683
750
|
return [];
|
|
684
|
-
const o =
|
|
751
|
+
const o = e.getBoundingClientRect();
|
|
685
752
|
if (o.width <= 0 || o.height <= 0)
|
|
686
753
|
return [];
|
|
687
|
-
const i = o.top + o.height / 2, r = o.left + o.width / 2,
|
|
688
|
-
let
|
|
689
|
-
for (;
|
|
690
|
-
const
|
|
691
|
-
if (
|
|
692
|
-
const
|
|
693
|
-
if (
|
|
694
|
-
const
|
|
695
|
-
if (p ||
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
text:
|
|
699
|
-
score:
|
|
754
|
+
const i = o.top + o.height / 2, r = o.left + o.width / 2, a = [], s = t.createTreeWalker(n, NodeFilter.SHOW_ELEMENT);
|
|
755
|
+
let d = s.nextNode();
|
|
756
|
+
for (; d; ) {
|
|
757
|
+
const c = d;
|
|
758
|
+
if (c !== e && !c.contains(e) && Dt(c)) {
|
|
759
|
+
const l = c.getBoundingClientRect(), h = pt(c) ?? _(c);
|
|
760
|
+
if (h) {
|
|
761
|
+
const g = l.top + l.height / 2, f = l.left + l.width / 2, p = l.right <= o.left + 12 && Math.abs(g - i) <= Math.max(28, o.height * 1.25), b = l.left >= o.right - 8 && l.left - o.right <= 240 && Math.abs(g - i) <= Math.max(28, o.height * 1.25), v = l.bottom <= o.top + 8 && o.top - l.bottom <= 80 && f >= o.left - 80 && f <= o.right + 80;
|
|
762
|
+
if (p || b || v) {
|
|
763
|
+
const x = p ? o.left - l.right + Math.abs(g - i) : b ? l.left - o.right + Math.abs(g - i) : o.top - l.bottom + Math.abs(f - r);
|
|
764
|
+
a.push({
|
|
765
|
+
text: h,
|
|
766
|
+
score: x + (p ? 0 : b ? 5 : 100)
|
|
700
767
|
});
|
|
701
768
|
}
|
|
702
769
|
}
|
|
703
770
|
}
|
|
704
|
-
|
|
771
|
+
d = s.nextNode();
|
|
705
772
|
}
|
|
706
|
-
const
|
|
707
|
-
return
|
|
773
|
+
const u = /* @__PURE__ */ new Set();
|
|
774
|
+
return a.sort((c, l) => c.score - l.score).map((c) => c.text).filter((c) => u.has(c) ? !1 : (u.add(c), !0)).slice(0, 4);
|
|
708
775
|
}
|
|
709
|
-
function
|
|
710
|
-
return
|
|
776
|
+
function Z(e) {
|
|
777
|
+
return e.getAttribute("data-testid") ?? e.getAttribute("data-test-id") ?? e.getAttribute("data-qa") ?? void 0;
|
|
711
778
|
}
|
|
712
|
-
function
|
|
713
|
-
const
|
|
714
|
-
if (
|
|
715
|
-
return
|
|
716
|
-
const n =
|
|
779
|
+
function q(e) {
|
|
780
|
+
const t = e.getAttribute("role");
|
|
781
|
+
if (t != null && t.trim())
|
|
782
|
+
return t.trim();
|
|
783
|
+
const n = e.tagName.toLowerCase();
|
|
717
784
|
if (n === "button") return "button";
|
|
718
785
|
if (n === "a") return "link";
|
|
719
786
|
if (n === "textarea") return "textbox";
|
|
720
787
|
if (n === "select") return "combobox";
|
|
721
788
|
if (n === "summary") return "button";
|
|
722
|
-
if (
|
|
723
|
-
switch (
|
|
789
|
+
if (T(e))
|
|
790
|
+
switch (e.type) {
|
|
724
791
|
case "checkbox":
|
|
725
792
|
return "checkbox";
|
|
726
793
|
case "radio":
|
|
@@ -733,63 +800,81 @@ function M(t) {
|
|
|
733
800
|
return "textbox";
|
|
734
801
|
}
|
|
735
802
|
}
|
|
736
|
-
function
|
|
737
|
-
return
|
|
803
|
+
function At(e) {
|
|
804
|
+
return {
|
|
805
|
+
tag: e.tagName.toLowerCase(),
|
|
806
|
+
role: q(e),
|
|
807
|
+
name: R(e),
|
|
808
|
+
testId: Z(e)
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
function ze(e, t) {
|
|
812
|
+
const n = At(t);
|
|
813
|
+
return n.tag !== e.tag || n.role !== e.role || S(n.name) !== S(e.name) || n.testId !== e.testId;
|
|
738
814
|
}
|
|
739
|
-
function
|
|
740
|
-
return
|
|
815
|
+
function re(e) {
|
|
816
|
+
return ne(e) || T(e) || L(e) || z(e) ? e.disabled || void 0 : e.getAttribute("aria-disabled") === "true" || void 0;
|
|
741
817
|
}
|
|
742
|
-
function
|
|
743
|
-
|
|
744
|
-
|
|
818
|
+
function zt(e) {
|
|
819
|
+
return T(e) && (e.type === "checkbox" || e.type === "radio") ? e.checked : void 0;
|
|
820
|
+
}
|
|
821
|
+
function Ue(e) {
|
|
822
|
+
const t = tt(e);
|
|
823
|
+
if (!(t.width <= 0 || t.height <= 0))
|
|
745
824
|
return {
|
|
746
|
-
x:
|
|
747
|
-
y:
|
|
825
|
+
x: t.x + t.width / 2,
|
|
826
|
+
y: t.y + t.height / 2
|
|
748
827
|
};
|
|
749
828
|
}
|
|
750
|
-
function
|
|
829
|
+
function H(e) {
|
|
751
830
|
return {
|
|
752
|
-
tag:
|
|
753
|
-
role:
|
|
754
|
-
name:
|
|
755
|
-
selector:
|
|
831
|
+
tag: e.tagName.toLowerCase(),
|
|
832
|
+
role: q(e),
|
|
833
|
+
name: R(e),
|
|
834
|
+
selector: Ct(e)
|
|
756
835
|
};
|
|
757
836
|
}
|
|
758
|
-
function
|
|
759
|
-
if (!(
|
|
837
|
+
function D(e) {
|
|
838
|
+
if (!(I(e) || kt(e)) || I(e) && e.hidden)
|
|
760
839
|
return !1;
|
|
761
|
-
const
|
|
840
|
+
const t = e.ownerDocument.defaultView, n = t == null ? void 0 : t.getComputedStyle(e);
|
|
762
841
|
return !(n && (n.display === "none" || n.visibility === "hidden" || n.opacity === "0"));
|
|
763
842
|
}
|
|
764
|
-
function
|
|
765
|
-
return
|
|
843
|
+
function se(e) {
|
|
844
|
+
return e.matches(ke) && D(e);
|
|
766
845
|
}
|
|
767
|
-
function
|
|
768
|
-
|
|
846
|
+
function Pt(e) {
|
|
847
|
+
let t = e;
|
|
848
|
+
for (; t; ) {
|
|
849
|
+
if (re(t) === !0)
|
|
850
|
+
return !1;
|
|
851
|
+
t = t.parentElement;
|
|
852
|
+
}
|
|
853
|
+
return !0;
|
|
769
854
|
}
|
|
770
|
-
function
|
|
855
|
+
function We(e) {
|
|
771
856
|
var n;
|
|
772
|
-
if (
|
|
857
|
+
if (se(e))
|
|
773
858
|
return !0;
|
|
774
|
-
if (!(
|
|
859
|
+
if (!I(e))
|
|
775
860
|
return !1;
|
|
776
|
-
const
|
|
777
|
-
return ((
|
|
861
|
+
const t = (n = e.ownerDocument.defaultView) == null ? void 0 : n.getComputedStyle(e);
|
|
862
|
+
return ((t == null ? void 0 : t.cursor) === "pointer" || !!e.onclick) && D(e);
|
|
778
863
|
}
|
|
779
|
-
function
|
|
780
|
-
var r,
|
|
781
|
-
const
|
|
782
|
-
let n =
|
|
864
|
+
function tt(e) {
|
|
865
|
+
var r, a;
|
|
866
|
+
const t = e.getBoundingClientRect();
|
|
867
|
+
let n = t.left, o = t.top, i = null;
|
|
783
868
|
try {
|
|
784
|
-
i = ((r =
|
|
869
|
+
i = ((r = e.ownerDocument.defaultView) == null ? void 0 : r.frameElement) ?? null;
|
|
785
870
|
} catch {
|
|
786
871
|
i = null;
|
|
787
872
|
}
|
|
788
873
|
for (; i; ) {
|
|
789
|
-
const
|
|
790
|
-
n +=
|
|
874
|
+
const s = i.getBoundingClientRect();
|
|
875
|
+
n += s.left, o += s.top;
|
|
791
876
|
try {
|
|
792
|
-
i = ((
|
|
877
|
+
i = ((a = i.ownerDocument.defaultView) == null ? void 0 : a.frameElement) ?? null;
|
|
793
878
|
} catch {
|
|
794
879
|
i = null;
|
|
795
880
|
}
|
|
@@ -797,255 +882,421 @@ function N(t) {
|
|
|
797
882
|
return {
|
|
798
883
|
x: n,
|
|
799
884
|
y: o,
|
|
800
|
-
width:
|
|
801
|
-
height:
|
|
885
|
+
width: t.width,
|
|
886
|
+
height: t.height
|
|
802
887
|
};
|
|
803
888
|
}
|
|
804
|
-
function
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
889
|
+
function Ut(e, t) {
|
|
890
|
+
var r, a;
|
|
891
|
+
let n = 0, o = 0, i = null;
|
|
892
|
+
try {
|
|
893
|
+
i = ((r = e.defaultView) == null ? void 0 : r.frameElement) ?? null;
|
|
894
|
+
} catch {
|
|
895
|
+
i = null;
|
|
896
|
+
}
|
|
897
|
+
for (; i; ) {
|
|
898
|
+
const s = i.getBoundingClientRect();
|
|
899
|
+
n += s.left, o += s.top;
|
|
900
|
+
try {
|
|
901
|
+
i = ((a = i.ownerDocument.defaultView) == null ? void 0 : a.frameElement) ?? null;
|
|
902
|
+
} catch {
|
|
903
|
+
i = null;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
return {
|
|
907
|
+
x: t.x - n,
|
|
908
|
+
y: t.y - o
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function Ct(e) {
|
|
912
|
+
const t = (i) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(i) : i.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
913
|
+
if (e.getRootNode() !== e.ownerDocument)
|
|
914
|
+
return;
|
|
915
|
+
const n = (i) => {
|
|
916
|
+
try {
|
|
917
|
+
return e.ownerDocument.querySelectorAll(i).length === 1 ? i : void 0;
|
|
918
|
+
} catch {
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
if (e.id)
|
|
923
|
+
return n(`#${t(e.id)}`);
|
|
924
|
+
for (const i of ["data-testid", "data-test-id", "data-qa"]) {
|
|
925
|
+
const r = e.getAttribute(i);
|
|
926
|
+
if (r)
|
|
927
|
+
return n(`[${i}="${t(r)}"]`);
|
|
928
|
+
}
|
|
929
|
+
const o = e.getAttribute("name");
|
|
930
|
+
if (o)
|
|
931
|
+
return n(
|
|
932
|
+
`${e.tagName.toLowerCase()}[name="${t(o)}"]`
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
function Ge(e) {
|
|
936
|
+
const t = e.getBoundingClientRect();
|
|
937
|
+
if (!(t.width <= 0 || t.height <= 0))
|
|
821
938
|
return {
|
|
822
|
-
x:
|
|
823
|
-
y:
|
|
939
|
+
x: t.left + t.width / 2,
|
|
940
|
+
y: t.top + t.height / 2
|
|
824
941
|
};
|
|
825
942
|
}
|
|
826
|
-
function
|
|
827
|
-
if (typeof
|
|
828
|
-
return
|
|
829
|
-
if (typeof
|
|
943
|
+
function X(e, t) {
|
|
944
|
+
if (typeof e.elementsFromPoint == "function")
|
|
945
|
+
return e.elementsFromPoint(t.x, t.y);
|
|
946
|
+
if (typeof e.elementFromPoint != "function")
|
|
830
947
|
return [];
|
|
831
|
-
const n =
|
|
948
|
+
const n = e.elementFromPoint(t.x, t.y);
|
|
832
949
|
return n ? [n] : [];
|
|
833
950
|
}
|
|
834
|
-
function
|
|
835
|
-
return typeof
|
|
951
|
+
function lt(e) {
|
|
952
|
+
return typeof e.elementsFromPoint == "function" || typeof e.elementFromPoint == "function";
|
|
836
953
|
}
|
|
837
|
-
function
|
|
838
|
-
return
|
|
954
|
+
function Ye(e, t) {
|
|
955
|
+
return e === t || e.contains(t);
|
|
839
956
|
}
|
|
840
|
-
function
|
|
841
|
-
let
|
|
842
|
-
for (;
|
|
843
|
-
if (
|
|
844
|
-
return
|
|
845
|
-
|
|
957
|
+
function dt(e) {
|
|
958
|
+
let t = e;
|
|
959
|
+
for (; t; ) {
|
|
960
|
+
if (We(t) && Pt(t))
|
|
961
|
+
return t;
|
|
962
|
+
t = t.parentElement;
|
|
846
963
|
}
|
|
847
|
-
return
|
|
964
|
+
return e;
|
|
848
965
|
}
|
|
849
|
-
function
|
|
850
|
-
|
|
966
|
+
function vt(e) {
|
|
967
|
+
const t = /* @__PURE__ */ new Set();
|
|
968
|
+
let n = e;
|
|
969
|
+
for (; n; ) {
|
|
970
|
+
const o = n.tagName.toLowerCase();
|
|
971
|
+
(ne(n) && n.form !== null && n.type === "submit" || T(n) && n.form !== null && (n.type === "submit" || n.type === "image")) && t.add("form_submit"), o === "a" && n.hasAttribute("download") && t.add("download"), n = n.parentElement;
|
|
972
|
+
}
|
|
973
|
+
return Array.from(t);
|
|
851
974
|
}
|
|
852
|
-
function
|
|
853
|
-
return
|
|
975
|
+
function S(e) {
|
|
976
|
+
return (e ?? "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
854
977
|
}
|
|
855
|
-
function
|
|
856
|
-
|
|
857
|
-
|
|
978
|
+
function Y(e) {
|
|
979
|
+
return ae(e)[0];
|
|
980
|
+
}
|
|
981
|
+
function ae(e) {
|
|
982
|
+
const t = e.getBoundingClientRect();
|
|
983
|
+
if (t.width <= 0 || t.height <= 0)
|
|
858
984
|
return [];
|
|
859
|
-
const n =
|
|
985
|
+
const n = e.ownerDocument;
|
|
860
986
|
return [
|
|
861
|
-
{ x:
|
|
862
|
-
{
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
987
|
+
{ x: t.left + t.width / 2, y: t.top + t.height / 2 },
|
|
988
|
+
{
|
|
989
|
+
x: t.left + Math.min(8, t.width / 2),
|
|
990
|
+
y: t.top + t.height / 2
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
x: t.right - Math.min(8, t.width / 2),
|
|
994
|
+
y: t.top + t.height / 2
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
x: t.left + t.width / 2,
|
|
998
|
+
y: t.top + Math.min(8, t.height / 2)
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
x: t.left + t.width / 2,
|
|
1002
|
+
y: t.bottom - Math.min(8, t.height / 2)
|
|
1003
|
+
}
|
|
866
1004
|
].filter((i) => {
|
|
867
|
-
const r =
|
|
868
|
-
return r ?
|
|
1005
|
+
const r = X(n, i)[0];
|
|
1006
|
+
return r ? Ye(e, r) : !1;
|
|
869
1007
|
});
|
|
870
1008
|
}
|
|
871
|
-
function
|
|
872
|
-
const n =
|
|
1009
|
+
function ut(e, t) {
|
|
1010
|
+
const n = e.getBoundingClientRect(), o = tt(e);
|
|
873
1011
|
return {
|
|
874
|
-
x:
|
|
875
|
-
y:
|
|
1012
|
+
x: t.x + o.x - n.left,
|
|
1013
|
+
y: t.y + o.y - n.top
|
|
876
1014
|
};
|
|
877
1015
|
}
|
|
878
|
-
function
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
const a = M(s), u = ut(x(s));
|
|
883
|
-
return n && a && n !== a ? !1 : u.includes(o) || o.includes(u);
|
|
884
|
-
}).map((s) => ({
|
|
885
|
-
candidate: s,
|
|
886
|
-
point: K(s),
|
|
887
|
-
rect: N(s)
|
|
888
|
-
})).filter(
|
|
889
|
-
(s) => !!s.point
|
|
890
|
-
).sort((s, a) => a.rect.y - s.rect.y)[0]) == null ? void 0 : r.candidate) ?? null : null;
|
|
891
|
-
}
|
|
892
|
-
function g(t) {
|
|
893
|
-
const e = t.ownerDocument, n = se(t), o = S(t) && !!n, i = ie(t), r = n ? yt(e, n) : [], s = r[0], a = bt(t).map(
|
|
894
|
-
(d) => Et(t, d)
|
|
895
|
-
), u = a.length > 0;
|
|
1016
|
+
function E(e) {
|
|
1017
|
+
const t = e.ownerDocument, n = Ge(e), o = D(e) && !!n, i = Pt(e), r = n ? X(t, n) : [], a = r[0], s = ae(e).map(
|
|
1018
|
+
(u) => ut(e, u)
|
|
1019
|
+
), d = s.length > 0;
|
|
896
1020
|
return {
|
|
897
1021
|
visible: o,
|
|
898
1022
|
enabled: i,
|
|
899
|
-
receivesEvents:
|
|
900
|
-
actionable: o && i &&
|
|
901
|
-
center:
|
|
902
|
-
hitTarget:
|
|
1023
|
+
receivesEvents: d,
|
|
1024
|
+
actionable: o && i && d,
|
|
1025
|
+
center: Ue(e),
|
|
1026
|
+
hitTarget: a,
|
|
903
1027
|
hitStack: r,
|
|
904
|
-
safeClickPoints:
|
|
905
|
-
occludedBy: o && i && !
|
|
1028
|
+
safeClickPoints: s,
|
|
1029
|
+
occludedBy: o && i && !d ? a : void 0
|
|
906
1030
|
};
|
|
907
1031
|
}
|
|
908
|
-
function
|
|
909
|
-
var a
|
|
910
|
-
const n =
|
|
911
|
-
if (n)
|
|
912
|
-
|
|
913
|
-
|
|
1032
|
+
function Wt(e, t) {
|
|
1033
|
+
var a;
|
|
1034
|
+
const n = m(t.testId);
|
|
1035
|
+
if (n)
|
|
1036
|
+
return et(e).filter(
|
|
1037
|
+
(s) => s.ownerDocument === e && Z(s) === n
|
|
914
1038
|
);
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
const c = (y = M(l)) == null ? void 0 : y.toLowerCase(), f = (p = x(l)) == null ? void 0 : p.toLowerCase(), h = (E = m(l)) == null ? void 0 : E.toLowerCase();
|
|
922
|
-
return !(o && c !== o || i && !(f != null && f.includes(i)) || r && !(h != null && h.includes(r)));
|
|
923
|
-
}) ?? null;
|
|
1039
|
+
const o = (a = m(t.role)) == null ? void 0 : a.toLowerCase(), i = S(m(t.name)), r = S(m(t.text));
|
|
1040
|
+
return !o && !i && !r ? [] : et(e).filter((s) => s.ownerDocument === e).filter((s) => {
|
|
1041
|
+
var l;
|
|
1042
|
+
const d = (l = q(s)) == null ? void 0 : l.toLowerCase(), u = S(R(s)), c = S(_(s));
|
|
1043
|
+
return !(o && d !== o || i && u !== i || r && c !== r);
|
|
1044
|
+
});
|
|
924
1045
|
}
|
|
925
|
-
function
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
].filter((e) => !!e).join(" ").toLowerCase();
|
|
933
|
-
}
|
|
934
|
-
function he(t, e) {
|
|
935
|
-
const n = e.trim().toLowerCase();
|
|
936
|
-
let o = t, i = 0;
|
|
1046
|
+
function Gt(e) {
|
|
1047
|
+
const t = e.trim().toLowerCase();
|
|
1048
|
+
return t === "*" || /^[a-z][a-z0-9-]*$/.test(t) || /^\[role(?:=[^\]]+)?\]$/.test(t) || /^\.[a-z_-][a-z0-9_-]*$/i.test(t);
|
|
1049
|
+
}
|
|
1050
|
+
function Ke(e, t) {
|
|
1051
|
+
const n = S(t);
|
|
1052
|
+
let o = e, i = 0;
|
|
937
1053
|
for (; o && i < 5; ) {
|
|
938
1054
|
const r = o.tagName.toLowerCase();
|
|
939
1055
|
if (r === "body" || r === "html")
|
|
940
1056
|
return !1;
|
|
941
|
-
if (
|
|
1057
|
+
if ([
|
|
1058
|
+
R(o),
|
|
1059
|
+
ot(o),
|
|
1060
|
+
ie(o),
|
|
1061
|
+
_(o),
|
|
1062
|
+
ht(o)
|
|
1063
|
+
].some((a) => S(a) === n))
|
|
942
1064
|
return !0;
|
|
943
1065
|
o = o.parentElement, i += 1;
|
|
944
1066
|
}
|
|
945
1067
|
return !1;
|
|
946
1068
|
}
|
|
947
|
-
function
|
|
948
|
-
|
|
1069
|
+
function Yt(e, t, n, o) {
|
|
1070
|
+
var d;
|
|
1071
|
+
if (n && S(q(e)) !== S(n))
|
|
1072
|
+
return !1;
|
|
1073
|
+
const i = S(t);
|
|
1074
|
+
if (![
|
|
1075
|
+
R(e),
|
|
1076
|
+
ot(e),
|
|
1077
|
+
_(e)
|
|
1078
|
+
].some((u) => S(u) === i))
|
|
1079
|
+
return !1;
|
|
1080
|
+
if (!o)
|
|
1081
|
+
return !0;
|
|
1082
|
+
const a = S(o);
|
|
1083
|
+
return [
|
|
1084
|
+
...U(e),
|
|
1085
|
+
((d = e.parentElement) == null ? void 0 : d.textContent) ?? void 0
|
|
1086
|
+
].map((u) => S(u)).join(" ").includes(a);
|
|
1087
|
+
}
|
|
1088
|
+
function Je(e) {
|
|
1089
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
949
1090
|
return;
|
|
950
|
-
const
|
|
951
|
-
if (
|
|
1091
|
+
const t = e;
|
|
1092
|
+
if (t.type === "field_contains" && typeof t.field == "string" && t.field.trim() && typeof t.value == "string")
|
|
952
1093
|
return {
|
|
953
1094
|
type: "field_contains",
|
|
954
|
-
field:
|
|
955
|
-
value:
|
|
1095
|
+
field: t.field,
|
|
1096
|
+
value: t.value
|
|
956
1097
|
};
|
|
957
1098
|
}
|
|
958
|
-
function
|
|
959
|
-
|
|
960
|
-
|
|
1099
|
+
function ce(e) {
|
|
1100
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1101
|
+
throw new Error("Expectation scope must be an object.");
|
|
1102
|
+
const t = Reflect.get(e, "documentScope");
|
|
1103
|
+
if (t === "current_top")
|
|
1104
|
+
return { documentScope: t };
|
|
1105
|
+
const n = Reflect.get(e, "documentRef");
|
|
1106
|
+
if (t === "same_document" && typeof n == "string" && n.trim())
|
|
1107
|
+
return { documentScope: t, documentRef: n };
|
|
1108
|
+
throw new Error("Expectation scope is invalid.");
|
|
1109
|
+
}
|
|
1110
|
+
function Qe(e) {
|
|
1111
|
+
const t = ce(e), n = Reflect.get(e, "kind");
|
|
1112
|
+
if (n === "test_id") {
|
|
1113
|
+
const o = Reflect.get(e, "testId");
|
|
1114
|
+
if (typeof o == "string" && o.trim())
|
|
1115
|
+
return { ...t, kind: n, testId: o };
|
|
1116
|
+
}
|
|
1117
|
+
if (n === "selector") {
|
|
1118
|
+
const o = Reflect.get(e, "selector");
|
|
1119
|
+
if (typeof o == "string" && o.trim())
|
|
1120
|
+
return { ...t, kind: n, selector: o };
|
|
1121
|
+
}
|
|
1122
|
+
if (n === "semantic" && Reflect.get(e, "match") === "exact") {
|
|
1123
|
+
const o = Reflect.get(e, "identity");
|
|
1124
|
+
if (o && typeof o == "object" && !Array.isArray(o)) {
|
|
1125
|
+
const i = Reflect.get(o, "role"), r = Reflect.get(o, "name"), a = Reflect.get(o, "text");
|
|
1126
|
+
if (typeof i == "string" && i.trim()) {
|
|
1127
|
+
if (typeof r == "string" && r.trim() && a === void 0)
|
|
1128
|
+
return {
|
|
1129
|
+
...t,
|
|
1130
|
+
kind: n,
|
|
1131
|
+
match: "exact",
|
|
1132
|
+
identity: { role: i, name: r }
|
|
1133
|
+
};
|
|
1134
|
+
if (typeof a == "string" && a.trim() && r === void 0)
|
|
1135
|
+
return {
|
|
1136
|
+
...t,
|
|
1137
|
+
kind: n,
|
|
1138
|
+
match: "exact",
|
|
1139
|
+
identity: { role: i, text: a }
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
throw new Error("Expectation target is invalid.");
|
|
1145
|
+
}
|
|
1146
|
+
function V(e) {
|
|
1147
|
+
if (e === void 0)
|
|
1148
|
+
return;
|
|
1149
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1150
|
+
throw new Error("expectation must be an object.");
|
|
1151
|
+
const t = Reflect.get(e, "type");
|
|
1152
|
+
if (t === "url_matches") {
|
|
1153
|
+
const n = Reflect.get(e, "mode"), o = Reflect.get(e, "value");
|
|
1154
|
+
if ((n === "exact" || n === "prefix") && typeof o == "string")
|
|
1155
|
+
return { type: t, mode: n, value: o };
|
|
1156
|
+
}
|
|
1157
|
+
if (t === "text_visible") {
|
|
1158
|
+
const n = Reflect.get(e, "value");
|
|
1159
|
+
if (typeof n == "string")
|
|
1160
|
+
return {
|
|
1161
|
+
type: t,
|
|
1162
|
+
scope: ce(Reflect.get(e, "scope")),
|
|
1163
|
+
value: n
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
if (t === "field_contains" || t === "checked_equals" || t === "element_visible" || t === "element_hidden") {
|
|
1167
|
+
const n = Qe(Reflect.get(e, "target"));
|
|
1168
|
+
if (t === "field_contains") {
|
|
1169
|
+
const o = Reflect.get(e, "value");
|
|
1170
|
+
if (typeof o == "string")
|
|
1171
|
+
return { type: t, target: n, value: o };
|
|
1172
|
+
} else if (t === "checked_equals") {
|
|
1173
|
+
const o = Reflect.get(e, "value");
|
|
1174
|
+
if (typeof o == "boolean")
|
|
1175
|
+
return { type: t, target: n, value: o };
|
|
1176
|
+
} else
|
|
1177
|
+
return { type: t, target: n };
|
|
1178
|
+
}
|
|
1179
|
+
throw new Error("Unsupported action expectation.");
|
|
1180
|
+
}
|
|
1181
|
+
function Ze(e, t) {
|
|
1182
|
+
const n = t.trim().toLowerCase();
|
|
1183
|
+
return Array.from(e.querySelectorAll("input,textarea,select")).find(
|
|
961
1184
|
(o) => [
|
|
962
|
-
|
|
963
|
-
|
|
1185
|
+
ot(o),
|
|
1186
|
+
R(o),
|
|
964
1187
|
o.getAttribute("name") ?? void 0,
|
|
965
1188
|
o.getAttribute("placeholder") ?? void 0,
|
|
966
|
-
...
|
|
1189
|
+
...U(o)
|
|
967
1190
|
].some(
|
|
968
1191
|
(r) => r == null ? void 0 : r.trim().toLowerCase().includes(n)
|
|
969
1192
|
)
|
|
970
1193
|
);
|
|
971
1194
|
}
|
|
972
|
-
function
|
|
973
|
-
if (!
|
|
1195
|
+
function tn(e, t) {
|
|
1196
|
+
if (!t)
|
|
974
1197
|
return;
|
|
975
|
-
const n =
|
|
1198
|
+
const n = Ze(e, t.field), o = n ? ht(n) ?? "" : void 0;
|
|
976
1199
|
return {
|
|
977
|
-
...
|
|
978
|
-
ok: typeof o == "string" && o.toLowerCase().includes(
|
|
1200
|
+
...t,
|
|
1201
|
+
ok: typeof o == "string" && o.toLowerCase().includes(t.value.toLowerCase()),
|
|
979
1202
|
actual: o,
|
|
980
|
-
matchedField: n ?
|
|
1203
|
+
matchedField: n ? H(n) : void 0
|
|
981
1204
|
};
|
|
982
1205
|
}
|
|
983
|
-
function et(
|
|
984
|
-
const
|
|
1206
|
+
function et(e) {
|
|
1207
|
+
const t = e.nodeType === 1 ? e.ownerDocument : k(e), n = e.nodeType === 9 ? e.body ?? e.documentElement : e;
|
|
985
1208
|
if (!n)
|
|
986
1209
|
return [];
|
|
987
1210
|
const o = [], i = (r) => {
|
|
988
|
-
const
|
|
989
|
-
let
|
|
990
|
-
for (;
|
|
991
|
-
const
|
|
992
|
-
|
|
993
|
-
const
|
|
994
|
-
if (
|
|
1211
|
+
const a = t.createTreeWalker(r, NodeFilter.SHOW_ELEMENT);
|
|
1212
|
+
let s = a.nextNode();
|
|
1213
|
+
for (; s; ) {
|
|
1214
|
+
const d = s;
|
|
1215
|
+
se(d) && o.push(d);
|
|
1216
|
+
const u = d.shadowRoot;
|
|
1217
|
+
if (u && i(u), Tt(d))
|
|
995
1218
|
try {
|
|
996
|
-
|
|
1219
|
+
d.contentDocument && i(d.contentDocument);
|
|
997
1220
|
} catch {
|
|
998
1221
|
}
|
|
999
|
-
if (o.length >=
|
|
1222
|
+
if (o.length >= Ot)
|
|
1000
1223
|
return;
|
|
1001
|
-
|
|
1224
|
+
s = a.nextNode();
|
|
1002
1225
|
}
|
|
1003
1226
|
};
|
|
1004
|
-
return i(n), o.slice(0,
|
|
1227
|
+
return i(n), o.slice(0, Ot);
|
|
1005
1228
|
}
|
|
1006
|
-
function
|
|
1229
|
+
function en(e, t) {
|
|
1007
1230
|
var i;
|
|
1008
|
-
const n = Object.getPrototypeOf(
|
|
1009
|
-
(i = o == null ? void 0 : o.set) == null || i.call(
|
|
1231
|
+
const n = Object.getPrototypeOf(e), o = Object.getOwnPropertyDescriptor(n, "value");
|
|
1232
|
+
(i = o == null ? void 0 : o.set) == null || i.call(e, t);
|
|
1010
1233
|
}
|
|
1011
|
-
function
|
|
1012
|
-
|
|
1234
|
+
function wt(e) {
|
|
1235
|
+
e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1013
1236
|
}
|
|
1014
|
-
function
|
|
1015
|
-
var
|
|
1016
|
-
(
|
|
1237
|
+
function K(e) {
|
|
1238
|
+
var t, n;
|
|
1239
|
+
(I(e) || kt(e)) && ((t = e.scrollIntoView) == null || t.call(e, { block: "center", inline: "center" })), I(e) && ((n = e.focus) == null || n.call(e));
|
|
1017
1240
|
}
|
|
1018
|
-
function
|
|
1019
|
-
return typeof PointerEvent == "function" ? new PointerEvent(
|
|
1241
|
+
function J(e, t) {
|
|
1242
|
+
return typeof PointerEvent == "function" ? new PointerEvent(e, t) : new MouseEvent(e.replace("pointer", "mouse"), t);
|
|
1020
1243
|
}
|
|
1021
|
-
class
|
|
1022
|
-
constructor(
|
|
1023
|
-
this.options =
|
|
1244
|
+
class nn {
|
|
1245
|
+
constructor(t = {}) {
|
|
1246
|
+
this.options = t, this.refs = /* @__PURE__ */ new Map(), this.nextRef = 1, this.pageStateId = "", this.documentRefs = /* @__PURE__ */ new Map(), this.documents = [], this.pageStateInvalidated = !1, this.cachedSnapshotCreatedAt = 0, this.mutationObservers = [], this.pendingActionApprovals = /* @__PURE__ */ new Map();
|
|
1024
1247
|
}
|
|
1025
|
-
async execute(
|
|
1248
|
+
async execute(t, n = {}) {
|
|
1026
1249
|
if (this.options.enabled === !1)
|
|
1027
1250
|
throw new Error("Host page automation is disabled.");
|
|
1028
|
-
switch (
|
|
1251
|
+
switch (t !== "host_page_snapshot" && t !== "host_page_read" && t !== "host_page_screenshot" && this.assertCurrentPageState(n), t) {
|
|
1029
1252
|
case "host_page_snapshot":
|
|
1030
|
-
return this.snapshot();
|
|
1253
|
+
return this.snapshot(n);
|
|
1031
1254
|
case "host_page_click":
|
|
1032
|
-
return this.
|
|
1255
|
+
return this.executeAction(
|
|
1256
|
+
() => this.click(n),
|
|
1257
|
+
!0,
|
|
1258
|
+
V(n.expectation)
|
|
1259
|
+
);
|
|
1033
1260
|
case "host_page_fill":
|
|
1034
|
-
return this.
|
|
1261
|
+
return this.executeAction(
|
|
1262
|
+
() => this.fill(n),
|
|
1263
|
+
!0,
|
|
1264
|
+
V(n.expectation)
|
|
1265
|
+
);
|
|
1035
1266
|
case "host_page_press":
|
|
1036
|
-
return this.
|
|
1267
|
+
return this.executeAction(
|
|
1268
|
+
() => this.press(n),
|
|
1269
|
+
!0,
|
|
1270
|
+
V(n.expectation)
|
|
1271
|
+
);
|
|
1037
1272
|
case "host_page_select":
|
|
1038
|
-
return this.
|
|
1273
|
+
return this.executeAction(
|
|
1274
|
+
() => this.select(n),
|
|
1275
|
+
!0,
|
|
1276
|
+
V(n.expectation)
|
|
1277
|
+
);
|
|
1039
1278
|
case "host_page_scroll":
|
|
1040
|
-
return this.
|
|
1279
|
+
return this.executeAction(
|
|
1280
|
+
() => this.scroll(n),
|
|
1281
|
+
!0,
|
|
1282
|
+
V(n.expectation)
|
|
1283
|
+
);
|
|
1041
1284
|
case "host_page_navigate":
|
|
1042
|
-
return this.
|
|
1285
|
+
return this.executeAction(
|
|
1286
|
+
async () => this.navigate(n),
|
|
1287
|
+
!0,
|
|
1288
|
+
V(n.expectation)
|
|
1289
|
+
);
|
|
1043
1290
|
case "host_page_hover":
|
|
1044
|
-
return this.hover(n);
|
|
1291
|
+
return this.executeAction(() => this.hover(n), !1);
|
|
1045
1292
|
case "host_page_focus":
|
|
1046
|
-
return this.focus(n);
|
|
1293
|
+
return this.executeAction(() => this.focus(n), !1);
|
|
1047
1294
|
case "host_page_pointer":
|
|
1048
|
-
return this.
|
|
1295
|
+
return this.executeAction(
|
|
1296
|
+
() => this.pointer(n),
|
|
1297
|
+
Vt(n.action) === "click",
|
|
1298
|
+
V(n.expectation)
|
|
1299
|
+
);
|
|
1049
1300
|
case "host_page_screenshot":
|
|
1050
1301
|
return this.screenshot();
|
|
1051
1302
|
case "host_page_read":
|
|
@@ -1054,63 +1305,132 @@ class be {
|
|
|
1054
1305
|
return this.waitFor(n);
|
|
1055
1306
|
}
|
|
1056
1307
|
}
|
|
1057
|
-
snapshot() {
|
|
1058
|
-
var
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
(
|
|
1308
|
+
snapshot(t = {}) {
|
|
1309
|
+
var d, u;
|
|
1310
|
+
const n = m(t.pageStateId);
|
|
1311
|
+
if (n) {
|
|
1312
|
+
if (this.cachedSnapshot && n === this.pageStateId && !this.pageStateInvalidated && Date.now() - this.cachedSnapshotCreatedAt <= Lt && this.cachedSnapshot.url === O(this.getRoot()).location.href)
|
|
1313
|
+
return this.cachedSnapshot;
|
|
1314
|
+
this.rejectStalePageState(n);
|
|
1315
|
+
}
|
|
1316
|
+
this.refs.clear(), this.pendingActionApprovals.clear(), this.nextRef = 1, this.disconnectMutationObservers();
|
|
1317
|
+
const o = this.getRoot(), i = k(o), r = O(o);
|
|
1318
|
+
this.pageStateId = jt(), this.pageStateInvalidated = !1, this.indexDocuments(i);
|
|
1319
|
+
const a = et(o).map(
|
|
1320
|
+
(c) => this.snapshotElement(c)
|
|
1062
1321
|
);
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1322
|
+
this.readableContent = Nt(o);
|
|
1323
|
+
const s = {
|
|
1324
|
+
pageStateId: this.pageStateId,
|
|
1325
|
+
url: r.location.href,
|
|
1326
|
+
title: i.title,
|
|
1066
1327
|
capabilities: {
|
|
1067
1328
|
cdp: !1,
|
|
1068
1329
|
realInput: !1,
|
|
1069
1330
|
screenshot: !1,
|
|
1070
1331
|
accessibility: !1,
|
|
1071
|
-
networkState: !1
|
|
1332
|
+
networkState: !1,
|
|
1333
|
+
targetingVersion: 2,
|
|
1334
|
+
strictRefs: !0,
|
|
1335
|
+
strictCoordinates: !0,
|
|
1336
|
+
freshState: !0,
|
|
1337
|
+
postconditions: !0,
|
|
1338
|
+
policyGate: !0,
|
|
1339
|
+
actionTrace: !0
|
|
1072
1340
|
},
|
|
1341
|
+
documents: this.documents,
|
|
1073
1342
|
viewport: {
|
|
1074
|
-
width:
|
|
1075
|
-
height:
|
|
1076
|
-
devicePixelRatio:
|
|
1343
|
+
width: r.innerWidth,
|
|
1344
|
+
height: r.innerHeight,
|
|
1345
|
+
devicePixelRatio: r.devicePixelRatio
|
|
1077
1346
|
},
|
|
1078
1347
|
scroll: {
|
|
1079
|
-
x:
|
|
1080
|
-
y:
|
|
1348
|
+
x: r.scrollX,
|
|
1349
|
+
y: r.scrollY
|
|
1081
1350
|
},
|
|
1082
1351
|
page: {
|
|
1083
|
-
readyState:
|
|
1084
|
-
visibilityState:
|
|
1085
|
-
focusedElement:
|
|
1086
|
-
selection: ((
|
|
1352
|
+
readyState: i.readyState,
|
|
1353
|
+
visibilityState: i.visibilityState,
|
|
1354
|
+
focusedElement: i.activeElement && i.activeElement !== i.body ? this.snapshotElementWithoutRef(i.activeElement) : void 0,
|
|
1355
|
+
selection: ((u = (d = i.getSelection) == null ? void 0 : d.call(i)) == null ? void 0 : u.toString()) || void 0
|
|
1087
1356
|
},
|
|
1088
|
-
navigation: this.getNavigationState(
|
|
1089
|
-
frames: this.getFrameState(
|
|
1090
|
-
accessibility:
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
),
|
|
1102
|
-
|
|
1357
|
+
navigation: this.getNavigationState(r),
|
|
1358
|
+
frames: this.getFrameState(i),
|
|
1359
|
+
accessibility: a.map((c) => {
|
|
1360
|
+
var l;
|
|
1361
|
+
return {
|
|
1362
|
+
ref: c.ref,
|
|
1363
|
+
role: c.role,
|
|
1364
|
+
name: c.name,
|
|
1365
|
+
value: c.value,
|
|
1366
|
+
disabled: c.disabled,
|
|
1367
|
+
checked: c.checked,
|
|
1368
|
+
focused: i.activeElement === ((l = this.refs.get(c.ref)) == null ? void 0 : l.element)
|
|
1369
|
+
};
|
|
1370
|
+
}),
|
|
1371
|
+
readableContent: Ee(this.readableContent),
|
|
1372
|
+
elements: a
|
|
1103
1373
|
};
|
|
1374
|
+
return this.cachedSnapshot = s, this.cachedSnapshotCreatedAt = Date.now(), this.observePageState(), s;
|
|
1104
1375
|
}
|
|
1105
1376
|
getRoot() {
|
|
1106
1377
|
return this.options.root ?? document;
|
|
1107
1378
|
}
|
|
1379
|
+
indexDocuments(t) {
|
|
1380
|
+
this.documentRefs = /* @__PURE__ */ new Map(), this.documents = [];
|
|
1381
|
+
let n = 1, o = 1;
|
|
1382
|
+
const i = (r, a, s) => {
|
|
1383
|
+
const d = `d${n}`;
|
|
1384
|
+
n += 1, this.documentRefs.set(r, d), this.documents.push({
|
|
1385
|
+
documentRef: d,
|
|
1386
|
+
parentDocumentRef: a,
|
|
1387
|
+
frameRef: s,
|
|
1388
|
+
sameOrigin: !0
|
|
1389
|
+
});
|
|
1390
|
+
for (const u of Array.from(r.querySelectorAll("iframe")))
|
|
1391
|
+
try {
|
|
1392
|
+
const c = u.contentDocument;
|
|
1393
|
+
if (!c)
|
|
1394
|
+
continue;
|
|
1395
|
+
const l = `f${o}`;
|
|
1396
|
+
o += 1, i(c, d, l);
|
|
1397
|
+
} catch {
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
i(t);
|
|
1401
|
+
}
|
|
1402
|
+
disconnectMutationObservers() {
|
|
1403
|
+
for (const t of this.mutationObservers)
|
|
1404
|
+
t.disconnect();
|
|
1405
|
+
this.mutationObservers = [];
|
|
1406
|
+
}
|
|
1407
|
+
observePageState() {
|
|
1408
|
+
var n;
|
|
1409
|
+
const t = this.pageStateId;
|
|
1410
|
+
for (const o of this.documentRefs.keys()) {
|
|
1411
|
+
const i = ((n = o.defaultView) == null ? void 0 : n.MutationObserver) ?? globalThis.MutationObserver;
|
|
1412
|
+
if (typeof i != "function")
|
|
1413
|
+
continue;
|
|
1414
|
+
const r = new i(() => {
|
|
1415
|
+
this.pageStateId === t && (this.pageStateInvalidated = !0);
|
|
1416
|
+
}), a = {
|
|
1417
|
+
subtree: !0,
|
|
1418
|
+
childList: !0,
|
|
1419
|
+
attributes: !0,
|
|
1420
|
+
attributeFilter: [...qe]
|
|
1421
|
+
};
|
|
1422
|
+
r.observe(o.documentElement ?? o, a);
|
|
1423
|
+
for (const s of Array.from(o.querySelectorAll("*")))
|
|
1424
|
+
s.shadowRoot && r.observe(s.shadowRoot, a);
|
|
1425
|
+
this.mutationObservers.push(r);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1108
1428
|
invalidateReadableContent() {
|
|
1109
1429
|
this.readableContent = void 0;
|
|
1110
1430
|
}
|
|
1111
|
-
getNavigationState(
|
|
1431
|
+
getNavigationState(t) {
|
|
1112
1432
|
var o, i, r;
|
|
1113
|
-
const n = (r = (i = (o =
|
|
1433
|
+
const n = (r = (i = (o = t.performance) == null ? void 0 : o.getEntriesByType) == null ? void 0 : i.call(o, "navigation")) == null ? void 0 : r[0];
|
|
1114
1434
|
if (!(typeof PerformanceNavigationTiming != "function" || !(n instanceof PerformanceNavigationTiming)))
|
|
1115
1435
|
return {
|
|
1116
1436
|
type: n.type,
|
|
@@ -1119,10 +1439,10 @@ class be {
|
|
|
1119
1439
|
loadEventEnd: n.loadEventEnd - n.startTime
|
|
1120
1440
|
};
|
|
1121
1441
|
}
|
|
1122
|
-
getFrameState(
|
|
1123
|
-
return Array.from(
|
|
1442
|
+
getFrameState(t) {
|
|
1443
|
+
return Array.from(t.querySelectorAll("iframe")).map((n) => {
|
|
1124
1444
|
var i, r;
|
|
1125
|
-
const o =
|
|
1445
|
+
const o = tt(n);
|
|
1126
1446
|
try {
|
|
1127
1447
|
return {
|
|
1128
1448
|
url: (i = n.contentWindow) == null ? void 0 : i.location.href,
|
|
@@ -1139,89 +1459,461 @@ class be {
|
|
|
1139
1459
|
}
|
|
1140
1460
|
});
|
|
1141
1461
|
}
|
|
1142
|
-
snapshotElement(
|
|
1462
|
+
snapshotElement(t) {
|
|
1143
1463
|
const n = `e${this.nextRef}`;
|
|
1144
|
-
return this.nextRef += 1, this.refs.set(n,
|
|
1464
|
+
return this.nextRef += 1, this.refs.set(n, {
|
|
1465
|
+
element: t,
|
|
1466
|
+
pageStateId: this.pageStateId,
|
|
1467
|
+
documentRef: this.documentRefs.get(t.ownerDocument) ?? "d1",
|
|
1468
|
+
fingerprint: At(t)
|
|
1469
|
+
}), this.createElementSnapshot(t, n);
|
|
1145
1470
|
}
|
|
1146
|
-
snapshotElementWithoutRef(
|
|
1147
|
-
return this.createElementSnapshot(
|
|
1471
|
+
snapshotElementWithoutRef(t) {
|
|
1472
|
+
return this.createElementSnapshot(t, "");
|
|
1148
1473
|
}
|
|
1149
|
-
createElementSnapshot(
|
|
1150
|
-
const o = (
|
|
1474
|
+
createElementSnapshot(t, n) {
|
|
1475
|
+
const o = (T(t) || z(t)) && t.placeholder || void 0, i = E(t);
|
|
1151
1476
|
return {
|
|
1477
|
+
documentRef: this.documentRefs.get(t.ownerDocument) ?? "d1",
|
|
1152
1478
|
ref: n,
|
|
1153
|
-
tag:
|
|
1154
|
-
role:
|
|
1155
|
-
name:
|
|
1156
|
-
label:
|
|
1157
|
-
groupLabel:
|
|
1158
|
-
text:
|
|
1159
|
-
nearbyText:
|
|
1160
|
-
testId:
|
|
1161
|
-
value:
|
|
1162
|
-
selectedLabel:
|
|
1163
|
-
options:
|
|
1479
|
+
tag: t.tagName.toLowerCase(),
|
|
1480
|
+
role: q(t),
|
|
1481
|
+
name: R(t),
|
|
1482
|
+
label: ot(t),
|
|
1483
|
+
groupLabel: ie(t),
|
|
1484
|
+
text: _(t),
|
|
1485
|
+
nearbyText: U(t),
|
|
1486
|
+
testId: Z(t),
|
|
1487
|
+
value: ht(t),
|
|
1488
|
+
selectedLabel: $e(t),
|
|
1489
|
+
options: Xe(t),
|
|
1164
1490
|
placeholder: o,
|
|
1165
|
-
selector:
|
|
1166
|
-
disabled:
|
|
1491
|
+
selector: Ct(t),
|
|
1492
|
+
disabled: re(t),
|
|
1167
1493
|
enabled: i.enabled,
|
|
1168
|
-
checked:
|
|
1494
|
+
checked: zt(t),
|
|
1169
1495
|
visible: i.visible,
|
|
1170
1496
|
actionable: i.actionable,
|
|
1171
1497
|
receivesEvents: i.receivesEvents,
|
|
1172
|
-
occludedBy: i.occludedBy ?
|
|
1498
|
+
occludedBy: i.occludedBy ? H(i.occludedBy) : void 0,
|
|
1173
1499
|
safeClickPoints: i.safeClickPoints,
|
|
1174
|
-
rect:
|
|
1500
|
+
rect: tt(t),
|
|
1175
1501
|
center: i.center,
|
|
1176
|
-
hitTarget: i.hitTarget ?
|
|
1177
|
-
hitStack: i.hitStack.slice(0, 5).map(
|
|
1502
|
+
hitTarget: i.hitTarget ? H(i.hitTarget) : void 0,
|
|
1503
|
+
hitStack: i.hitStack.slice(0, 5).map(H)
|
|
1178
1504
|
};
|
|
1179
1505
|
}
|
|
1180
|
-
resolveElement(
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1506
|
+
resolveElement(t) {
|
|
1507
|
+
var g, f;
|
|
1508
|
+
const n = m(t.pageStateId);
|
|
1509
|
+
this.pageStateId && !n && this.rejectStalePageState(this.pageStateId), n && n !== this.pageStateId && this.rejectStalePageState(n), this.documents.length && !m(t.documentRef) && this.rejectTarget(
|
|
1510
|
+
"unsupported_target_scope",
|
|
1511
|
+
"documentRef is required for strict targeting."
|
|
1512
|
+
);
|
|
1513
|
+
const o = m(t.documentRef) ?? ((g = this.documents[0]) == null ? void 0 : g.documentRef) ?? "legacy", i = this.documents.length ? (f = Array.from(this.documentRefs.entries()).find(
|
|
1514
|
+
([, p]) => p === o
|
|
1515
|
+
)) == null ? void 0 : f[0] : k(this.getRoot());
|
|
1516
|
+
(!o || !i) && this.rejectTarget(
|
|
1517
|
+
"unsupported_target_scope",
|
|
1518
|
+
"The requested document scope is not available."
|
|
1519
|
+
);
|
|
1520
|
+
const r = m(t.ref), a = m(t.axRef), s = m(t.selector), d = m(t.testId), u = m(t.role), c = m(t.name), l = m(t.text);
|
|
1521
|
+
this.pageStateId && [
|
|
1522
|
+
!!r,
|
|
1523
|
+
!!a,
|
|
1524
|
+
!!s,
|
|
1525
|
+
!!d,
|
|
1526
|
+
!!(u || c || l)
|
|
1527
|
+
].filter(Boolean).length !== 1 && this.rejectTarget(
|
|
1528
|
+
"ambiguous_target",
|
|
1529
|
+
"Strict targeting requires exactly one locator family."
|
|
1530
|
+
);
|
|
1531
|
+
const h = r ?? a;
|
|
1532
|
+
if (h) {
|
|
1533
|
+
const p = this.refs.get(h);
|
|
1534
|
+
if (!p || p.pageStateId !== this.pageStateId || !p.element.isConnected || this.documentRefs.get(p.element.ownerDocument) !== p.documentRef || o && o !== p.documentRef || ze(p.fingerprint, p.element))
|
|
1535
|
+
throw new W(
|
|
1536
|
+
`Element ref ${h} is stale. Take a new snapshot.`,
|
|
1537
|
+
{
|
|
1538
|
+
code: "stale_target",
|
|
1539
|
+
message: `Element ref ${h} is stale. Take a new snapshot.`,
|
|
1540
|
+
recoverable: !0,
|
|
1541
|
+
dispatched: !1,
|
|
1542
|
+
outcome: "rejected_before_execution",
|
|
1543
|
+
requiresFreshSnapshot: !0,
|
|
1544
|
+
invalidatedPageStateId: n ?? this.pageStateId
|
|
1545
|
+
}
|
|
1546
|
+
);
|
|
1547
|
+
return this.pageStateInvalidated && this.rejectStalePageState(n ?? this.pageStateId), this.lastResolution = {
|
|
1548
|
+
requested: r ? {
|
|
1549
|
+
kind: "ref",
|
|
1550
|
+
pageStateId: n ?? this.pageStateId,
|
|
1551
|
+
documentRef: p.documentRef,
|
|
1552
|
+
ref: r
|
|
1553
|
+
} : {
|
|
1554
|
+
kind: "ax_ref",
|
|
1555
|
+
pageStateId: n ?? this.pageStateId,
|
|
1556
|
+
documentRef: p.documentRef,
|
|
1557
|
+
axRef: a
|
|
1558
|
+
},
|
|
1559
|
+
strategy: r ? "ref" : "ax_ref",
|
|
1560
|
+
resolved: this.describeElementDescriptor(p.element, {
|
|
1561
|
+
ref: r ?? void 0,
|
|
1562
|
+
axRef: a ?? void 0
|
|
1563
|
+
}),
|
|
1564
|
+
pageStateId: this.pageStateId
|
|
1565
|
+
}, p.element;
|
|
1187
1566
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1567
|
+
if (this.pageStateInvalidated && this.rejectStalePageState(n ?? this.pageStateId), s) {
|
|
1568
|
+
const b = {
|
|
1569
|
+
requested: {
|
|
1570
|
+
kind: "selector",
|
|
1571
|
+
pageStateId: n ?? this.pageStateId,
|
|
1572
|
+
documentRef: o,
|
|
1573
|
+
selector: s
|
|
1574
|
+
},
|
|
1575
|
+
strategy: "unique_selector",
|
|
1576
|
+
pageStateId: this.pageStateId
|
|
1577
|
+
};
|
|
1578
|
+
Gt(s) && this.rejectTarget(
|
|
1579
|
+
"unsafe_selector",
|
|
1580
|
+
`Selector is too broad for strict targeting: ${s}.`,
|
|
1581
|
+
b
|
|
1582
|
+
);
|
|
1583
|
+
let v;
|
|
1584
|
+
try {
|
|
1585
|
+
v = Array.from(i.querySelectorAll(s));
|
|
1586
|
+
} catch {
|
|
1587
|
+
v = [];
|
|
1588
|
+
}
|
|
1589
|
+
v.length === 0 && this.rejectTarget(
|
|
1590
|
+
"target_not_found",
|
|
1591
|
+
`No element matches selector: ${s}.`,
|
|
1592
|
+
b
|
|
1593
|
+
), v.length > 1 && this.rejectTarget(
|
|
1594
|
+
"non_unique_selector",
|
|
1595
|
+
`Selector matches ${v.length} elements: ${s}.`,
|
|
1596
|
+
{
|
|
1597
|
+
...b,
|
|
1598
|
+
candidates: v.map(
|
|
1599
|
+
(P) => this.describeElementDescriptor(P)
|
|
1600
|
+
)
|
|
1601
|
+
}
|
|
1602
|
+
);
|
|
1603
|
+
const x = v[0];
|
|
1604
|
+
return this.lastResolution = {
|
|
1605
|
+
...b,
|
|
1606
|
+
resolved: this.describeElementDescriptor(x)
|
|
1607
|
+
}, x;
|
|
1608
|
+
}
|
|
1609
|
+
if (d || u || c || l) {
|
|
1610
|
+
const p = !!d;
|
|
1611
|
+
!p && (!u || !!c == !!l) && this.rejectTarget(
|
|
1612
|
+
"target_not_found",
|
|
1613
|
+
"Semantic targeting requires role plus exactly one of name or text."
|
|
1614
|
+
);
|
|
1615
|
+
const b = p ? {
|
|
1616
|
+
kind: "test_id",
|
|
1617
|
+
pageStateId: n ?? this.pageStateId,
|
|
1618
|
+
documentRef: o,
|
|
1619
|
+
testId: d
|
|
1620
|
+
} : {
|
|
1621
|
+
kind: "semantic",
|
|
1622
|
+
pageStateId: n ?? this.pageStateId,
|
|
1623
|
+
documentRef: o,
|
|
1624
|
+
match: "exact",
|
|
1625
|
+
identity: c ? { role: u, name: c } : { role: u, text: l }
|
|
1626
|
+
}, v = p ? "test_id" : "semantic_exact", x = Wt(i, t), P = {
|
|
1627
|
+
requested: b,
|
|
1628
|
+
strategy: v,
|
|
1629
|
+
pageStateId: this.pageStateId
|
|
1630
|
+
};
|
|
1631
|
+
x.length === 0 && this.rejectTarget(
|
|
1632
|
+
"target_not_found",
|
|
1633
|
+
"No element matches the strict target.",
|
|
1634
|
+
P
|
|
1635
|
+
), x.length > 1 && this.rejectTarget(
|
|
1636
|
+
"ambiguous_target",
|
|
1637
|
+
`Strict target matches ${x.length} elements.`,
|
|
1638
|
+
{
|
|
1639
|
+
...P,
|
|
1640
|
+
candidates: x.map(
|
|
1641
|
+
(w) => this.describeElementDescriptor(w)
|
|
1642
|
+
)
|
|
1643
|
+
}
|
|
1644
|
+
);
|
|
1645
|
+
const y = x[0];
|
|
1646
|
+
return this.lastResolution = {
|
|
1647
|
+
...P,
|
|
1648
|
+
resolved: this.describeElementDescriptor(y)
|
|
1649
|
+
}, y;
|
|
1194
1650
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
const r = rt(this.getRoot(), e), s = T(this.getRoot()).elementFromPoint(
|
|
1200
|
-
r.x,
|
|
1201
|
-
r.y
|
|
1651
|
+
if (typeof t.x < "u" || typeof t.y < "u") {
|
|
1652
|
+
const p = Ft(this.getRoot(), t), b = k(this.getRoot()).elementFromPoint(
|
|
1653
|
+
p.x,
|
|
1654
|
+
p.y
|
|
1202
1655
|
);
|
|
1203
|
-
if (!
|
|
1204
|
-
throw new Error(`No element found at (${
|
|
1205
|
-
return
|
|
1656
|
+
if (!b)
|
|
1657
|
+
throw new Error(`No element found at (${p.x}, ${p.y}).`);
|
|
1658
|
+
return this.lastResolution = {
|
|
1659
|
+
requested: {
|
|
1660
|
+
kind: "coordinate",
|
|
1661
|
+
pageStateId: n ?? this.pageStateId,
|
|
1662
|
+
documentRef: o,
|
|
1663
|
+
x: p.x,
|
|
1664
|
+
y: p.y,
|
|
1665
|
+
coordinateSpace: Q(t.coordinateSpace),
|
|
1666
|
+
targetText: m(t.targetText) ?? ""
|
|
1667
|
+
},
|
|
1668
|
+
strategy: "coordinate",
|
|
1669
|
+
resolved: this.describeElementDescriptor(b),
|
|
1670
|
+
point: p,
|
|
1671
|
+
pageStateId: this.pageStateId
|
|
1672
|
+
}, b;
|
|
1206
1673
|
}
|
|
1207
1674
|
throw new Error(
|
|
1208
1675
|
"Expected one of ref, selector, role/name/text/testId, or x/y."
|
|
1209
1676
|
);
|
|
1210
1677
|
}
|
|
1211
|
-
|
|
1212
|
-
const n =
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1678
|
+
rejectStalePageState(t) {
|
|
1679
|
+
const n = "The requested page state is stale. Take a new snapshot.";
|
|
1680
|
+
throw new W(n, {
|
|
1681
|
+
code: "stale_page_state",
|
|
1682
|
+
message: n,
|
|
1683
|
+
recoverable: !0,
|
|
1684
|
+
dispatched: !1,
|
|
1685
|
+
outcome: "rejected_before_execution",
|
|
1686
|
+
requiresFreshSnapshot: !0,
|
|
1687
|
+
invalidatedPageStateId: t
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
assertCurrentPageState(t) {
|
|
1691
|
+
var o;
|
|
1692
|
+
if (!this.pageStateId) return;
|
|
1693
|
+
const n = m(t.pageStateId);
|
|
1694
|
+
(!n || n !== this.pageStateId || this.pageStateInvalidated || Date.now() - this.cachedSnapshotCreatedAt > Lt || ((o = this.cachedSnapshot) == null ? void 0 : o.url) !== O(this.getRoot()).location.href) && this.rejectStalePageState(n ?? this.pageStateId);
|
|
1695
|
+
}
|
|
1696
|
+
async executeAction(t, n, o) {
|
|
1697
|
+
this.lastResolution = void 0;
|
|
1698
|
+
const i = this.pageStateId, r = await t();
|
|
1699
|
+
await Promise.resolve(), n && i && (this.pageStateInvalidated = !0);
|
|
1700
|
+
const a = !!i && (n || this.pageStateInvalidated), s = o ? await this.verifyExpectation(o) : void 0, d = s ? s.status === "passed" ? "verified" : "verification_failed" : "executed_unverified";
|
|
1701
|
+
return {
|
|
1702
|
+
...r,
|
|
1703
|
+
dispatched: !0,
|
|
1704
|
+
outcome: d,
|
|
1705
|
+
requiresFreshSnapshot: a,
|
|
1706
|
+
invalidatedPageStateId: a ? i : void 0,
|
|
1707
|
+
...this.lastResolution ? { resolution: this.lastResolution } : {},
|
|
1708
|
+
verification: s
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
async requireActionApproval(t, n, o, i) {
|
|
1712
|
+
if (o.length === 0)
|
|
1713
|
+
return;
|
|
1714
|
+
const r = O(this.getRoot()), a = await Bt({ action: t, params: n }), s = await Bt(
|
|
1715
|
+
i ? {
|
|
1716
|
+
documentRef: this.documentRefs.get(i.ownerDocument) ?? "legacy",
|
|
1717
|
+
...At(i)
|
|
1718
|
+
} : null
|
|
1719
|
+
), d = m(n.actionToken);
|
|
1720
|
+
let u = "approval_required";
|
|
1721
|
+
if (d) {
|
|
1722
|
+
const g = this.pendingActionApprovals.get(d);
|
|
1723
|
+
if (this.pendingActionApprovals.delete(d), !g)
|
|
1724
|
+
u = "invalid_or_used_token";
|
|
1725
|
+
else if (g.expiresAt <= Date.now())
|
|
1726
|
+
u = "expired_token";
|
|
1727
|
+
else if (g.pageStateId !== this.pageStateId || g.origin !== r.location.origin || g.url !== r.location.href)
|
|
1728
|
+
u = "state_mismatch";
|
|
1729
|
+
else if (g.action !== t || g.actionHash !== a || g.targetHash !== s || g.risks.join("\0") !== o.join("\0"))
|
|
1730
|
+
u = "action_mismatch";
|
|
1731
|
+
else
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
for (const [g, f] of this.pendingActionApprovals)
|
|
1735
|
+
f.expiresAt <= Date.now() && this.pendingActionApprovals.delete(g);
|
|
1736
|
+
const c = jt(), l = Date.now() + Oe;
|
|
1737
|
+
this.pendingActionApprovals.set(c, {
|
|
1738
|
+
action: t,
|
|
1739
|
+
actionHash: a,
|
|
1740
|
+
expiresAt: l,
|
|
1741
|
+
origin: r.location.origin,
|
|
1742
|
+
pageStateId: this.pageStateId,
|
|
1743
|
+
risks: o,
|
|
1744
|
+
targetHash: s,
|
|
1745
|
+
url: r.location.href
|
|
1746
|
+
});
|
|
1747
|
+
const h = `Action requires user approval: ${o.join(", ")}.`;
|
|
1748
|
+
throw new W(h, {
|
|
1749
|
+
code: "approval_required",
|
|
1750
|
+
message: h,
|
|
1751
|
+
recoverable: !0,
|
|
1752
|
+
dispatched: !1,
|
|
1753
|
+
outcome: "rejected_before_execution",
|
|
1754
|
+
requiresFreshSnapshot: !1,
|
|
1755
|
+
actionToken: c,
|
|
1756
|
+
approvalReason: u,
|
|
1757
|
+
expiresAt: new Date(l).toISOString(),
|
|
1758
|
+
risks: o,
|
|
1759
|
+
resolution: this.lastResolution
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
getObservationDocument(t) {
|
|
1763
|
+
var n;
|
|
1764
|
+
return t.documentScope === "current_top" ? k(this.getRoot()) : ((n = Array.from(this.documentRefs.entries()).find(
|
|
1765
|
+
([, o]) => o === t.documentRef
|
|
1766
|
+
)) == null ? void 0 : n[0]) ?? null;
|
|
1767
|
+
}
|
|
1768
|
+
resolveObservationTarget(t) {
|
|
1769
|
+
const n = this.getObservationDocument(t);
|
|
1770
|
+
if (!n)
|
|
1771
|
+
return { status: "not_found" };
|
|
1772
|
+
let o = [];
|
|
1773
|
+
if (t.kind === "selector") {
|
|
1774
|
+
if (Gt(t.selector))
|
|
1775
|
+
return { status: "ambiguous" };
|
|
1776
|
+
try {
|
|
1777
|
+
o = Array.from(n.querySelectorAll(t.selector));
|
|
1778
|
+
} catch {
|
|
1779
|
+
o = [];
|
|
1780
|
+
}
|
|
1781
|
+
} else t.kind === "test_id" ? o = et(n).filter(
|
|
1782
|
+
(i) => i.ownerDocument === n && Z(i) === t.testId
|
|
1783
|
+
) : o = Wt(n, {
|
|
1784
|
+
role: t.identity.role,
|
|
1785
|
+
..."name" in t.identity ? { name: t.identity.name } : { text: t.identity.text }
|
|
1786
|
+
});
|
|
1787
|
+
return o.length === 0 ? { status: "not_found" } : o.length > 1 ? { status: "ambiguous" } : { status: "unique", element: o[0] };
|
|
1788
|
+
}
|
|
1789
|
+
checkExpectation(t) {
|
|
1790
|
+
var r, a;
|
|
1791
|
+
if (t.type === "url_matches") {
|
|
1792
|
+
const s = O(this.getRoot()).location.href;
|
|
1793
|
+
return {
|
|
1794
|
+
matched: t.mode === "exact" ? s === t.value : s.startsWith(t.value),
|
|
1795
|
+
actual: s
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
if (t.type === "text_visible") {
|
|
1799
|
+
const s = this.getObservationDocument(t.scope), d = ((r = s == null ? void 0 : s.body) == null ? void 0 : r.innerText) ?? ((a = s == null ? void 0 : s.body) == null ? void 0 : a.textContent) ?? "";
|
|
1800
|
+
return {
|
|
1801
|
+
matched: S(d).includes(
|
|
1802
|
+
S(t.value)
|
|
1803
|
+
),
|
|
1804
|
+
actual: d
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
const n = this.resolveObservationTarget(t.target);
|
|
1808
|
+
if (n.status === "ambiguous")
|
|
1809
|
+
return { matched: !1, terminalFailure: !0, actual: null };
|
|
1810
|
+
if (n.status === "not_found")
|
|
1811
|
+
return {
|
|
1812
|
+
matched: t.type === "element_hidden",
|
|
1813
|
+
actual: null
|
|
1814
|
+
};
|
|
1815
|
+
const o = n.element;
|
|
1816
|
+
if (t.type === "field_contains") {
|
|
1817
|
+
const s = ht(o) ?? null;
|
|
1818
|
+
return {
|
|
1819
|
+
matched: typeof s == "string" && s.toLowerCase().includes(t.value.toLowerCase()),
|
|
1820
|
+
actual: s
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
if (t.type === "checked_equals") {
|
|
1824
|
+
const s = zt(o) ?? null;
|
|
1825
|
+
return { matched: s === t.value, actual: s };
|
|
1826
|
+
}
|
|
1827
|
+
const i = D(o);
|
|
1828
|
+
return {
|
|
1829
|
+
matched: t.type === "element_visible" ? i : !i,
|
|
1830
|
+
actual: i
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
async verifyExpectation(t) {
|
|
1834
|
+
const n = Date.now();
|
|
1835
|
+
let o;
|
|
1836
|
+
for (; Date.now() - n <= qt; ) {
|
|
1837
|
+
const i = this.checkExpectation(t);
|
|
1838
|
+
if (o = i.actual, i.matched)
|
|
1839
|
+
return {
|
|
1840
|
+
status: "passed",
|
|
1841
|
+
expectation: t,
|
|
1842
|
+
elapsedMs: Date.now() - n,
|
|
1843
|
+
actual: o
|
|
1844
|
+
};
|
|
1845
|
+
if (i.terminalFailure)
|
|
1846
|
+
return {
|
|
1847
|
+
status: "failed",
|
|
1848
|
+
expectation: t,
|
|
1849
|
+
elapsedMs: Date.now() - n,
|
|
1850
|
+
actual: o
|
|
1851
|
+
};
|
|
1852
|
+
if (Date.now() - n >= qt)
|
|
1853
|
+
break;
|
|
1854
|
+
await new Promise(
|
|
1855
|
+
(r) => setTimeout(r, Ne)
|
|
1856
|
+
);
|
|
1857
|
+
}
|
|
1858
|
+
return {
|
|
1859
|
+
status: "timed_out",
|
|
1860
|
+
expectation: t,
|
|
1861
|
+
elapsedMs: Date.now() - n,
|
|
1862
|
+
actual: o
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
rejectTarget(t, n, o) {
|
|
1866
|
+
throw new W(n, {
|
|
1867
|
+
code: t,
|
|
1868
|
+
message: n,
|
|
1869
|
+
recoverable: t !== "approval_required",
|
|
1870
|
+
dispatched: !1,
|
|
1871
|
+
outcome: "rejected_before_execution",
|
|
1872
|
+
requiresFreshSnapshot: t === "stale_page_state" || t === "stale_target",
|
|
1873
|
+
resolution: o
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
describeElementDescriptor(t, n = {}) {
|
|
1877
|
+
return {
|
|
1878
|
+
documentRef: this.documentRefs.get(t.ownerDocument) ?? "d1",
|
|
1879
|
+
...n,
|
|
1880
|
+
tag: t.tagName.toLowerCase(),
|
|
1881
|
+
role: q(t),
|
|
1882
|
+
name: R(t),
|
|
1883
|
+
text: _(t),
|
|
1884
|
+
testId: Z(t),
|
|
1885
|
+
rect: tt(t)
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
async click(t) {
|
|
1889
|
+
const n = A(t), o = this.resolveElement(n), i = E(o), r = dt(o), a = Y(r);
|
|
1890
|
+
if (i.enabled || this.rejectTarget(
|
|
1891
|
+
"target_disabled",
|
|
1892
|
+
`Target "${R(o) ?? o.tagName.toLowerCase()}" is disabled.`,
|
|
1893
|
+
this.lastResolution
|
|
1894
|
+
), !a && lt(o.ownerDocument))
|
|
1895
|
+
throw this.lastResolution && (this.lastResolution = {
|
|
1896
|
+
...this.lastResolution,
|
|
1897
|
+
adjustment: r === o ? void 0 : "actionable_ancestor",
|
|
1898
|
+
hitTarget: i.hitTarget ? this.describeElementDescriptor(i.hitTarget) : void 0,
|
|
1899
|
+
hitStack: i.hitStack.slice(0, 5).map((f) => this.describeElementDescriptor(f))
|
|
1900
|
+
}), new W(
|
|
1901
|
+
`Target "${R(o) ?? o.tagName.toLowerCase()}" is not receiving pointer events.`,
|
|
1216
1902
|
{
|
|
1903
|
+
code: "target_occluded",
|
|
1217
1904
|
reason: "target_occluded",
|
|
1905
|
+
message: `Target "${R(o) ?? o.tagName.toLowerCase()}" is not receiving pointer events.`,
|
|
1906
|
+
dispatched: !1,
|
|
1907
|
+
outcome: "rejected_before_execution",
|
|
1908
|
+
requiresFreshSnapshot: !1,
|
|
1909
|
+
resolution: this.lastResolution,
|
|
1218
1910
|
target: this.describeElement(o),
|
|
1219
|
-
occluder: i.occludedBy ?
|
|
1911
|
+
occluder: i.occludedBy ? H(i.occludedBy) : void 0,
|
|
1220
1912
|
targetVisible: i.visible,
|
|
1221
1913
|
targetEnabled: i.enabled,
|
|
1222
1914
|
targetReceivesEvents: i.receivesEvents,
|
|
1223
1915
|
recoverable: !0,
|
|
1224
|
-
hitStack: i.hitStack.slice(0, 5).map(
|
|
1916
|
+
hitStack: i.hitStack.slice(0, 5).map(H),
|
|
1225
1917
|
nextActions: [
|
|
1226
1918
|
{
|
|
1227
1919
|
tool: "host_page_press",
|
|
@@ -1234,82 +1926,129 @@ class be {
|
|
|
1234
1926
|
]
|
|
1235
1927
|
}
|
|
1236
1928
|
);
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1929
|
+
const s = Y(r), d = E(r), u = s ? ut(r, s) : lt(r.ownerDocument) ? void 0 : d.center ?? i.center;
|
|
1930
|
+
if (this.lastResolution) {
|
|
1931
|
+
const f = this.describeElementDescriptor(r);
|
|
1932
|
+
this.lastResolution = {
|
|
1933
|
+
...this.lastResolution,
|
|
1934
|
+
adjustment: r === o ? void 0 : "actionable_ancestor",
|
|
1935
|
+
point: u,
|
|
1936
|
+
resolved: r === o ? {
|
|
1937
|
+
...this.lastResolution.resolved,
|
|
1938
|
+
...f
|
|
1939
|
+
} : f
|
|
1940
|
+
};
|
|
1941
|
+
}
|
|
1942
|
+
await this.requireActionApproval(
|
|
1943
|
+
"host_page_click",
|
|
1944
|
+
n,
|
|
1945
|
+
vt(r),
|
|
1946
|
+
r
|
|
1947
|
+
), K(r), u && await this.showVisualEffect({
|
|
1240
1948
|
type: "click",
|
|
1241
|
-
point:
|
|
1949
|
+
point: u,
|
|
1242
1950
|
anchor: "target",
|
|
1243
|
-
target:
|
|
1951
|
+
target: r,
|
|
1244
1952
|
requested: o
|
|
1245
|
-
})
|
|
1246
|
-
|
|
1953
|
+
});
|
|
1954
|
+
const c = Y(r), l = E(r);
|
|
1955
|
+
!c && lt(r.ownerDocument) && (this.lastResolution && (this.lastResolution = {
|
|
1956
|
+
...this.lastResolution,
|
|
1957
|
+
hitTarget: l.hitTarget ? this.describeElementDescriptor(
|
|
1958
|
+
l.hitTarget
|
|
1959
|
+
) : void 0,
|
|
1960
|
+
hitStack: l.hitStack.slice(0, 5).map((f) => this.describeElementDescriptor(f))
|
|
1961
|
+
}), this.rejectTarget(
|
|
1962
|
+
"target_occluded",
|
|
1963
|
+
`Target "${R(o) ?? o.tagName.toLowerCase()}" stopped receiving pointer events before dispatch.`,
|
|
1964
|
+
this.lastResolution
|
|
1965
|
+
));
|
|
1966
|
+
const h = c ? ut(r, c) : u, g = E(o);
|
|
1967
|
+
return this.lastResolution && (this.lastResolution = {
|
|
1968
|
+
...this.lastResolution,
|
|
1969
|
+
point: h,
|
|
1970
|
+
resolved: {
|
|
1971
|
+
...this.lastResolution.resolved,
|
|
1972
|
+
...this.describeElementDescriptor(r)
|
|
1973
|
+
}
|
|
1974
|
+
}), I(r) ? r.click() : r.dispatchEvent(new MouseEvent("click", { bubbles: !0 })), this.invalidateReadableContent(), {
|
|
1975
|
+
clicked: this.describeElement(r),
|
|
1247
1976
|
requested: this.describeElement(o),
|
|
1248
|
-
strategy:
|
|
1249
|
-
point:
|
|
1977
|
+
strategy: r === o ? "dom" : "actionable_ancestor",
|
|
1978
|
+
point: h,
|
|
1250
1979
|
actionability: {
|
|
1251
|
-
visible:
|
|
1252
|
-
enabled:
|
|
1253
|
-
receivesEvents:
|
|
1254
|
-
occludedBy:
|
|
1255
|
-
safeClickPoints:
|
|
1980
|
+
visible: g.visible,
|
|
1981
|
+
enabled: g.enabled,
|
|
1982
|
+
receivesEvents: g.receivesEvents,
|
|
1983
|
+
occludedBy: g.occludedBy ? H(g.occludedBy) : void 0,
|
|
1984
|
+
safeClickPoints: g.safeClickPoints
|
|
1256
1985
|
}
|
|
1257
1986
|
};
|
|
1258
1987
|
}
|
|
1259
|
-
read(
|
|
1260
|
-
const n =
|
|
1988
|
+
read(t) {
|
|
1989
|
+
const n = A(t), o = this.getRoot(), i = this.readableContent ?? Nt(o);
|
|
1261
1990
|
this.readableContent = i;
|
|
1262
1991
|
const r = {
|
|
1263
|
-
blockId:
|
|
1264
|
-
query:
|
|
1265
|
-
page:
|
|
1266
|
-
pageSize:
|
|
1267
|
-
maxChars:
|
|
1992
|
+
blockId: m(n.blockId),
|
|
1993
|
+
query: m(n.query),
|
|
1994
|
+
page: ct(n.page),
|
|
1995
|
+
pageSize: ct(n.pageSize),
|
|
1996
|
+
maxChars: ct(n.maxChars)
|
|
1268
1997
|
};
|
|
1269
|
-
return
|
|
1998
|
+
return Ie(i, r);
|
|
1270
1999
|
}
|
|
1271
|
-
async fill(
|
|
1272
|
-
const n =
|
|
1273
|
-
if (
|
|
2000
|
+
async fill(t) {
|
|
2001
|
+
const n = A(t), o = bt(n.value, "value"), i = this.resolveElement(n);
|
|
2002
|
+
if (await this.requireActionApproval(
|
|
2003
|
+
"host_page_fill",
|
|
2004
|
+
n,
|
|
2005
|
+
T(i) ? i.type === "password" ? ["password_input"] : i.type === "file" ? ["file_input"] : [] : [],
|
|
2006
|
+
i
|
|
2007
|
+
), K(i), T(i) || z(i))
|
|
1274
2008
|
return await this.showVisualEffect({
|
|
1275
2009
|
type: "fill",
|
|
1276
2010
|
target: i,
|
|
1277
2011
|
requested: i,
|
|
1278
2012
|
value: o,
|
|
1279
2013
|
anchor: "target",
|
|
1280
|
-
point:
|
|
1281
|
-
}),
|
|
1282
|
-
if (i
|
|
2014
|
+
point: E(i).center
|
|
2015
|
+
}), en(i, o), wt(i), this.invalidateReadableContent(), { filled: this.describeElement(i), value: o };
|
|
2016
|
+
if (I(i) && i.isContentEditable)
|
|
1283
2017
|
return await this.showVisualEffect({
|
|
1284
2018
|
type: "fill",
|
|
1285
2019
|
target: i,
|
|
1286
2020
|
requested: i,
|
|
1287
2021
|
value: o,
|
|
1288
2022
|
anchor: "target",
|
|
1289
|
-
point:
|
|
1290
|
-
}), i.textContent = o,
|
|
2023
|
+
point: E(i).center
|
|
2024
|
+
}), i.textContent = o, wt(i), this.invalidateReadableContent(), { filled: this.describeElement(i), value: o };
|
|
1291
2025
|
throw new Error("Target element cannot be filled.");
|
|
1292
2026
|
}
|
|
1293
|
-
async press(
|
|
1294
|
-
const n =
|
|
2027
|
+
async press(t) {
|
|
2028
|
+
const n = A(t), o = bt(n.key, "key"), i = n.ref || n.selector || n.x !== void 0 && n.y !== void 0 ? this.resolveElement(n) : k(this.getRoot()).activeElement ?? k(this.getRoot()).body;
|
|
1295
2029
|
if (!i)
|
|
1296
2030
|
throw new Error("No target element is available for key press.");
|
|
1297
|
-
|
|
2031
|
+
await this.requireActionApproval(
|
|
2032
|
+
"host_page_press",
|
|
2033
|
+
n,
|
|
2034
|
+
o === "Enter" || o === " " ? vt(i) : [],
|
|
2035
|
+
i
|
|
2036
|
+
), K(i), await this.showVisualEffect({
|
|
1298
2037
|
type: "press",
|
|
1299
2038
|
target: i,
|
|
1300
2039
|
requested: i,
|
|
1301
2040
|
key: o,
|
|
1302
2041
|
anchor: "target",
|
|
1303
|
-
point:
|
|
2042
|
+
point: E(i).center
|
|
1304
2043
|
});
|
|
1305
2044
|
const r = { key: o, bubbles: !0, cancelable: !0 };
|
|
1306
2045
|
return i.dispatchEvent(new KeyboardEvent("keydown", r)), o.length === 1 && i.dispatchEvent(new KeyboardEvent("keypress", r)), i.dispatchEvent(new KeyboardEvent("keyup", r)), this.invalidateReadableContent(), { pressed: o, target: this.describeElement(i) };
|
|
1307
2046
|
}
|
|
1308
|
-
async select(
|
|
1309
|
-
const n =
|
|
1310
|
-
if (!(i
|
|
2047
|
+
async select(t) {
|
|
2048
|
+
const n = A(t), o = je(n.values ?? n.value), i = this.resolveElement(n);
|
|
2049
|
+
if (!L(i))
|
|
1311
2050
|
throw new Error("Target element is not a select.");
|
|
1312
|
-
|
|
2051
|
+
K(i);
|
|
1313
2052
|
const r = new Set(o);
|
|
1314
2053
|
await this.showVisualEffect({
|
|
1315
2054
|
type: "select",
|
|
@@ -1317,38 +2056,38 @@ class be {
|
|
|
1317
2056
|
requested: i,
|
|
1318
2057
|
values: o,
|
|
1319
2058
|
anchor: "target",
|
|
1320
|
-
point:
|
|
2059
|
+
point: E(i).center
|
|
1321
2060
|
});
|
|
1322
|
-
for (const
|
|
1323
|
-
|
|
1324
|
-
return
|
|
2061
|
+
for (const a of Array.from(i.options))
|
|
2062
|
+
a.selected = r.has(a.value);
|
|
2063
|
+
return wt(i), this.invalidateReadableContent(), {
|
|
1325
2064
|
selected: Array.from(i.selectedOptions).map(
|
|
1326
|
-
(
|
|
2065
|
+
(a) => a.value
|
|
1327
2066
|
),
|
|
1328
2067
|
target: this.describeElement(i)
|
|
1329
2068
|
};
|
|
1330
2069
|
}
|
|
1331
|
-
async scroll(
|
|
1332
|
-
var u,
|
|
1333
|
-
const n =
|
|
1334
|
-
x:
|
|
1335
|
-
y:
|
|
1336
|
-
} : null, i =
|
|
2070
|
+
async scroll(t) {
|
|
2071
|
+
var d, u, c, l;
|
|
2072
|
+
const n = A(t), o = n.x !== void 0 || n.y !== void 0 ? {
|
|
2073
|
+
x: G(n.x) ?? 0,
|
|
2074
|
+
y: G(n.y) ?? 0
|
|
2075
|
+
} : null, i = G(n.deltaX) ?? 0, r = G(n.deltaY) ?? 0, a = this.getRoot(), s = O(a);
|
|
1337
2076
|
if (n.ref || n.selector || n.role || n.name || n.text || n.testId) {
|
|
1338
|
-
const
|
|
1339
|
-
if (!(
|
|
2077
|
+
const h = this.resolveElement(n);
|
|
2078
|
+
if (!I(h))
|
|
1340
2079
|
throw new Error("Target element cannot be scrolled.");
|
|
1341
2080
|
return await this.showVisualEffect({
|
|
1342
2081
|
type: "scroll",
|
|
1343
|
-
target:
|
|
1344
|
-
requested:
|
|
2082
|
+
target: h,
|
|
2083
|
+
requested: h,
|
|
1345
2084
|
deltaX: i,
|
|
1346
2085
|
deltaY: r,
|
|
1347
2086
|
anchor: "target",
|
|
1348
|
-
point:
|
|
1349
|
-
}), o ? (
|
|
1350
|
-
scrolled: this.describeElement(
|
|
1351
|
-
scroll: { x:
|
|
2087
|
+
point: E(h).center
|
|
2088
|
+
}), o ? (d = h.scrollTo) == null || d.call(h, o.x, o.y) : (u = h.scrollBy) == null || u.call(h, i, r), this.invalidateReadableContent(), {
|
|
2089
|
+
scrolled: this.describeElement(h),
|
|
2090
|
+
scroll: { x: h.scrollLeft, y: h.scrollTop }
|
|
1352
2091
|
};
|
|
1353
2092
|
}
|
|
1354
2093
|
return await this.showVisualEffect({
|
|
@@ -1356,21 +2095,21 @@ class be {
|
|
|
1356
2095
|
deltaX: i,
|
|
1357
2096
|
deltaY: r,
|
|
1358
2097
|
point: {
|
|
1359
|
-
x:
|
|
1360
|
-
y:
|
|
2098
|
+
x: s.innerWidth / 2,
|
|
2099
|
+
y: s.innerHeight / 2
|
|
1361
2100
|
}
|
|
1362
|
-
}), o ? (
|
|
2101
|
+
}), o ? (c = s.scrollTo) == null || c.call(s, o.x, o.y) : (l = s.scrollBy) == null || l.call(s, i, r), this.invalidateReadableContent(), { scroll: { x: s.scrollX, y: s.scrollY } };
|
|
1363
2102
|
}
|
|
1364
|
-
navigate(
|
|
2103
|
+
async navigate(t) {
|
|
1365
2104
|
if (this.options.allowNavigation === !1)
|
|
1366
2105
|
throw new Error("Navigation is disabled for host page automation.");
|
|
1367
|
-
const n =
|
|
1368
|
-
if (
|
|
2106
|
+
const n = A(t), o = this.getRoot(), i = O(o), r = bt(n.url, "url"), a = new URL(r, i.location.href);
|
|
2107
|
+
if (a.protocol !== "http:" && a.protocol !== "https:")
|
|
1369
2108
|
throw new Error("Navigation only supports HTTP(S) URLs.");
|
|
1370
|
-
return this.refs.clear(), this.invalidateReadableContent(), i.location.assign(
|
|
2109
|
+
return this.refs.clear(), this.invalidateReadableContent(), i.location.assign(a.toString()), { navigated: a.toString() };
|
|
1371
2110
|
}
|
|
1372
|
-
async hover(
|
|
1373
|
-
const n =
|
|
2111
|
+
async hover(t) {
|
|
2112
|
+
const n = A(t), o = this.resolveElement(n), i = E(o).center;
|
|
1374
2113
|
return await this.showVisualEffect({
|
|
1375
2114
|
type: "hover",
|
|
1376
2115
|
target: o,
|
|
@@ -1393,73 +2132,267 @@ class be {
|
|
|
1393
2132
|
})
|
|
1394
2133
|
), { hovered: this.describeElement(o), point: i };
|
|
1395
2134
|
}
|
|
1396
|
-
async focus(
|
|
1397
|
-
const n =
|
|
1398
|
-
return
|
|
2135
|
+
async focus(t) {
|
|
2136
|
+
const n = A(t), o = this.resolveElement(n);
|
|
2137
|
+
return K(o), await this.showVisualEffect({
|
|
1399
2138
|
type: "focus",
|
|
1400
2139
|
target: o,
|
|
1401
2140
|
requested: o,
|
|
1402
2141
|
anchor: "target",
|
|
1403
|
-
point:
|
|
2142
|
+
point: E(o).center
|
|
1404
2143
|
}), { focused: this.describeElement(o) };
|
|
1405
2144
|
}
|
|
1406
|
-
async pointer(
|
|
1407
|
-
|
|
1408
|
-
|
|
2145
|
+
async pointer(t) {
|
|
2146
|
+
var x, P;
|
|
2147
|
+
const n = A(t), o = Vt(n.action), i = ct(n.button) ?? 0, r = typeof n.x < "u" || typeof n.y < "u", a = m(n.targetText), s = m(n.targetRole), d = m(n.targetContext);
|
|
2148
|
+
if (o === "click" && r && !a)
|
|
1409
2149
|
throw new Error(
|
|
1410
2150
|
"Pointer coordinate clicks require targetText to avoid unintended navigation."
|
|
1411
2151
|
);
|
|
1412
|
-
|
|
1413
|
-
if (
|
|
2152
|
+
let u = k(this.getRoot()), c = ((x = this.documents[0]) == null ? void 0 : x.documentRef) ?? "legacy";
|
|
2153
|
+
if (r && this.pageStateId) {
|
|
2154
|
+
const y = m(n.pageStateId);
|
|
2155
|
+
(!y || y !== this.pageStateId || this.pageStateInvalidated) && this.rejectStalePageState(y ?? this.pageStateId);
|
|
2156
|
+
const w = m(n.documentRef);
|
|
2157
|
+
w || this.rejectTarget(
|
|
2158
|
+
"unsupported_target_scope",
|
|
2159
|
+
"documentRef is required for coordinate targeting."
|
|
2160
|
+
);
|
|
2161
|
+
const N = (P = Array.from(this.documentRefs.entries()).find(
|
|
2162
|
+
([, j]) => j === w
|
|
2163
|
+
)) == null ? void 0 : P[0];
|
|
2164
|
+
N || this.rejectTarget(
|
|
2165
|
+
"unsupported_target_scope",
|
|
2166
|
+
"The requested coordinate document scope is not available."
|
|
2167
|
+
), u = N, c = w;
|
|
2168
|
+
}
|
|
2169
|
+
const l = n.ref || n.selector || n.role || n.name || n.text || n.testId ? this.resolveElement(n) : null, h = l ? E(l).center : Ft(this.getRoot(), n);
|
|
2170
|
+
if (!h)
|
|
1414
2171
|
throw new Error("Target element has no clickable point.");
|
|
1415
|
-
const
|
|
1416
|
-
if (!
|
|
1417
|
-
throw new Error(`No element found at (${
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
2172
|
+
const g = r ? Ut(u, h) : h, f = l ?? X(u, g)[0];
|
|
2173
|
+
if (!f)
|
|
2174
|
+
throw new Error(`No element found at (${h.x}, ${h.y}).`);
|
|
2175
|
+
if (Tt(f)) {
|
|
2176
|
+
const y = r ? {
|
|
2177
|
+
requested: {
|
|
2178
|
+
kind: "coordinate",
|
|
2179
|
+
pageStateId: m(n.pageStateId) ?? this.pageStateId,
|
|
2180
|
+
documentRef: c,
|
|
2181
|
+
x: h.x,
|
|
2182
|
+
y: h.y,
|
|
2183
|
+
coordinateSpace: Q(n.coordinateSpace),
|
|
2184
|
+
targetText: a ?? "",
|
|
2185
|
+
targetRole: s,
|
|
2186
|
+
targetContext: d
|
|
2187
|
+
},
|
|
2188
|
+
strategy: "coordinate",
|
|
2189
|
+
resolved: this.describeElementDescriptor(f),
|
|
2190
|
+
point: h,
|
|
2191
|
+
hitTarget: this.describeElementDescriptor(f),
|
|
2192
|
+
hitStack: X(u, g).slice(0, 5).map((w) => this.describeElementDescriptor(w)),
|
|
2193
|
+
pageStateId: this.pageStateId
|
|
2194
|
+
} : this.lastResolution;
|
|
2195
|
+
this.rejectTarget(
|
|
2196
|
+
"unsupported_target_scope",
|
|
2197
|
+
"Coordinate targeting cannot resolve an inaccessible frame document.",
|
|
2198
|
+
y
|
|
2199
|
+
);
|
|
2200
|
+
}
|
|
2201
|
+
const p = a ? Ke(f, a) : void 0;
|
|
2202
|
+
if (a && !p && this.rejectTarget(
|
|
2203
|
+
"coordinate_target_mismatch",
|
|
2204
|
+
`Pointer target text mismatch: expected exact hit target "${a}".`
|
|
2205
|
+
), s) {
|
|
2206
|
+
const y = dt(f);
|
|
2207
|
+
S(q(y)) !== S(s) && this.rejectTarget(
|
|
2208
|
+
"coordinate_target_mismatch",
|
|
2209
|
+
`Pointer target role mismatch: expected "${s}".`
|
|
1422
2210
|
);
|
|
1423
|
-
|
|
2211
|
+
}
|
|
2212
|
+
if (a) {
|
|
2213
|
+
const y = et(u).filter(
|
|
2214
|
+
(w) => w.ownerDocument === u && Pt(w) && D(w) && !!Y(w) && Yt(
|
|
2215
|
+
w,
|
|
2216
|
+
a,
|
|
2217
|
+
s,
|
|
2218
|
+
d
|
|
2219
|
+
)
|
|
2220
|
+
);
|
|
2221
|
+
if (y.length > 1) {
|
|
2222
|
+
const w = {
|
|
2223
|
+
kind: "coordinate",
|
|
2224
|
+
pageStateId: m(n.pageStateId) ?? this.pageStateId,
|
|
2225
|
+
documentRef: c,
|
|
2226
|
+
x: h.x,
|
|
2227
|
+
y: h.y,
|
|
2228
|
+
coordinateSpace: Q(n.coordinateSpace),
|
|
2229
|
+
targetText: a,
|
|
2230
|
+
targetRole: s,
|
|
2231
|
+
targetContext: d
|
|
2232
|
+
};
|
|
2233
|
+
this.rejectTarget(
|
|
2234
|
+
"coordinate_target_ambiguous",
|
|
2235
|
+
`Coordinate target matches ${y.length} actionable regions.`,
|
|
2236
|
+
{
|
|
2237
|
+
requested: w,
|
|
2238
|
+
strategy: "coordinate",
|
|
2239
|
+
candidates: y.map(
|
|
2240
|
+
(N) => this.describeElementDescriptor(N)
|
|
2241
|
+
),
|
|
2242
|
+
point: h,
|
|
2243
|
+
pageStateId: this.pageStateId
|
|
2244
|
+
}
|
|
2245
|
+
);
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
r && (this.lastResolution = {
|
|
2249
|
+
requested: {
|
|
2250
|
+
kind: "coordinate",
|
|
2251
|
+
pageStateId: m(n.pageStateId) ?? this.pageStateId,
|
|
2252
|
+
documentRef: c,
|
|
2253
|
+
x: h.x,
|
|
2254
|
+
y: h.y,
|
|
2255
|
+
coordinateSpace: Q(n.coordinateSpace),
|
|
2256
|
+
targetText: a ?? "",
|
|
2257
|
+
targetRole: s,
|
|
2258
|
+
targetContext: d
|
|
2259
|
+
},
|
|
2260
|
+
strategy: "coordinate",
|
|
2261
|
+
resolved: this.describeElementDescriptor(f),
|
|
2262
|
+
point: h,
|
|
2263
|
+
hitTarget: this.describeElementDescriptor(f),
|
|
2264
|
+
hitStack: X(u, g).slice(0, 5).map((y) => this.describeElementDescriptor(y)),
|
|
2265
|
+
pageStateId: this.pageStateId
|
|
2266
|
+
}), o === "click" && await this.requireActionApproval(
|
|
2267
|
+
"host_page_pointer",
|
|
2268
|
+
n,
|
|
2269
|
+
vt(f),
|
|
2270
|
+
f
|
|
2271
|
+
);
|
|
2272
|
+
const b = r ? g : Ut(f.ownerDocument, h), v = {
|
|
1424
2273
|
bubbles: !0,
|
|
1425
2274
|
cancelable: !0,
|
|
1426
|
-
clientX:
|
|
1427
|
-
clientY:
|
|
2275
|
+
clientX: b.x,
|
|
2276
|
+
clientY: b.y,
|
|
1428
2277
|
button: i
|
|
1429
2278
|
};
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
2279
|
+
if (o === "move")
|
|
2280
|
+
await this.showVisualEffect({
|
|
2281
|
+
type: "pointer",
|
|
2282
|
+
action: o,
|
|
2283
|
+
anchor: "point",
|
|
2284
|
+
point: h,
|
|
2285
|
+
target: f
|
|
2286
|
+
}), f.dispatchEvent(J("pointermove", v)), f.dispatchEvent(new MouseEvent("mousemove", v));
|
|
2287
|
+
else if (o === "down")
|
|
2288
|
+
await this.showVisualEffect({
|
|
2289
|
+
type: "pointer",
|
|
2290
|
+
action: o,
|
|
2291
|
+
anchor: "point",
|
|
2292
|
+
point: h,
|
|
2293
|
+
target: f
|
|
2294
|
+
}), f.dispatchEvent(J("pointerdown", v)), f.dispatchEvent(new MouseEvent("mousedown", v));
|
|
2295
|
+
else if (o === "up")
|
|
2296
|
+
await this.showVisualEffect({
|
|
2297
|
+
type: "pointer",
|
|
2298
|
+
action: o,
|
|
2299
|
+
anchor: "point",
|
|
2300
|
+
point: h,
|
|
2301
|
+
target: f
|
|
2302
|
+
}), f.dispatchEvent(J("pointerup", v)), f.dispatchEvent(new MouseEvent("mouseup", v));
|
|
2303
|
+
else {
|
|
2304
|
+
await this.showVisualEffect({
|
|
2305
|
+
type: "click",
|
|
2306
|
+
anchor: "point",
|
|
2307
|
+
point: h,
|
|
2308
|
+
target: f
|
|
2309
|
+
});
|
|
2310
|
+
let y = f, w = h, N = h;
|
|
2311
|
+
if (lt(f.ownerDocument)) {
|
|
2312
|
+
f.isConnected || this.rejectTarget(
|
|
2313
|
+
"stale_target",
|
|
2314
|
+
"The coordinate target was replaced before pointer dispatch.",
|
|
2315
|
+
this.lastResolution
|
|
2316
|
+
);
|
|
2317
|
+
const it = r ? g : Y(f);
|
|
2318
|
+
if (!it) {
|
|
2319
|
+
const B = E(f);
|
|
2320
|
+
this.lastResolution && (this.lastResolution = {
|
|
2321
|
+
...this.lastResolution,
|
|
2322
|
+
hitTarget: B.hitTarget ? this.describeElementDescriptor(B.hitTarget) : void 0,
|
|
2323
|
+
hitStack: B.hitStack.slice(0, 5).map((de) => this.describeElementDescriptor(de))
|
|
2324
|
+
}), this.rejectTarget(
|
|
2325
|
+
"target_occluded",
|
|
2326
|
+
"The coordinate target stopped receiving pointer events before dispatch.",
|
|
2327
|
+
this.lastResolution
|
|
2328
|
+
);
|
|
2329
|
+
}
|
|
2330
|
+
const gt = X(
|
|
2331
|
+
r ? u : f.ownerDocument,
|
|
2332
|
+
it
|
|
2333
|
+
), M = gt[0];
|
|
2334
|
+
M && Tt(M) && this.rejectTarget(
|
|
2335
|
+
"unsupported_target_scope",
|
|
2336
|
+
"The coordinate target became an inaccessible frame before pointer dispatch.",
|
|
2337
|
+
this.lastResolution
|
|
2338
|
+
);
|
|
2339
|
+
const mt = M ? dt(M) : void 0, le = dt(f);
|
|
2340
|
+
this.lastResolution && (this.lastResolution = {
|
|
2341
|
+
...this.lastResolution,
|
|
2342
|
+
point: w,
|
|
2343
|
+
hitTarget: M ? this.describeElementDescriptor(M) : void 0,
|
|
2344
|
+
hitStack: gt.slice(0, 5).map((B) => this.describeElementDescriptor(B))
|
|
2345
|
+
}), (!M || mt !== le || a && (!mt || !Yt(
|
|
2346
|
+
mt,
|
|
2347
|
+
a,
|
|
2348
|
+
s,
|
|
2349
|
+
d
|
|
2350
|
+
))) && this.rejectTarget(
|
|
2351
|
+
"coordinate_target_mismatch",
|
|
2352
|
+
"The coordinate target identity changed before pointer dispatch.",
|
|
2353
|
+
this.lastResolution
|
|
2354
|
+
), y = M, N = it, w = r ? h : ut(f, it), this.lastResolution && (this.lastResolution = {
|
|
2355
|
+
...this.lastResolution,
|
|
2356
|
+
point: w,
|
|
2357
|
+
resolved: this.describeElementDescriptor(f),
|
|
2358
|
+
hitTarget: this.describeElementDescriptor(M),
|
|
2359
|
+
hitStack: gt.slice(0, 5).map((B) => this.describeElementDescriptor(B))
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2362
|
+
const j = {
|
|
2363
|
+
...v,
|
|
2364
|
+
clientX: N.x,
|
|
2365
|
+
clientY: N.y
|
|
2366
|
+
};
|
|
2367
|
+
return y.dispatchEvent(
|
|
2368
|
+
J("pointerdown", j)
|
|
2369
|
+
), y.dispatchEvent(
|
|
2370
|
+
new MouseEvent("mousedown", j)
|
|
2371
|
+
), y.dispatchEvent(
|
|
2372
|
+
J("pointerup", j)
|
|
2373
|
+
), y.dispatchEvent(
|
|
2374
|
+
new MouseEvent("mouseup", j)
|
|
2375
|
+
), I(y) ? y.click() : y.dispatchEvent(
|
|
2376
|
+
new MouseEvent("click", j)
|
|
2377
|
+
), this.invalidateReadableContent(), {
|
|
2378
|
+
pointer: o,
|
|
2379
|
+
point: w,
|
|
2380
|
+
coordinateSpace: "viewport-css-px",
|
|
2381
|
+
target: this.describeElement(y),
|
|
2382
|
+
targetTextMatched: p,
|
|
2383
|
+
expectedAfterClick: tn(
|
|
2384
|
+
this.getRoot(),
|
|
2385
|
+
Je(n.expectedAfterClick)
|
|
2386
|
+
)
|
|
2387
|
+
};
|
|
2388
|
+
}
|
|
2389
|
+
return {
|
|
1454
2390
|
pointer: o,
|
|
1455
|
-
point:
|
|
2391
|
+
point: h,
|
|
1456
2392
|
coordinateSpace: "viewport-css-px",
|
|
1457
|
-
target: this.describeElement(
|
|
1458
|
-
targetTextMatched:
|
|
1459
|
-
expectedAfterClick:
|
|
1460
|
-
this.getRoot(),
|
|
1461
|
-
pe(n.expectedAfterClick)
|
|
1462
|
-
) : void 0
|
|
2393
|
+
target: this.describeElement(f),
|
|
2394
|
+
targetTextMatched: p,
|
|
2395
|
+
expectedAfterClick: void 0
|
|
1463
2396
|
};
|
|
1464
2397
|
}
|
|
1465
2398
|
screenshot() {
|
|
@@ -1467,114 +2400,182 @@ class be {
|
|
|
1467
2400
|
"host_page_screenshot requires the browser extension CDP adapter."
|
|
1468
2401
|
);
|
|
1469
2402
|
}
|
|
1470
|
-
async showVisualEffect(
|
|
2403
|
+
async showVisualEffect(t) {
|
|
1471
2404
|
var n, o, i, r;
|
|
1472
2405
|
try {
|
|
1473
|
-
await ((o = (n = this.options).showVisualEffect) == null ? void 0 : o.call(n,
|
|
2406
|
+
await ((o = (n = this.options).showVisualEffect) == null ? void 0 : o.call(n, t));
|
|
1474
2407
|
} catch {
|
|
1475
2408
|
}
|
|
1476
|
-
if (!(
|
|
2409
|
+
if (!(t.type !== "click" || !t.point || !t.target || this.options.showVisualEffect))
|
|
1477
2410
|
try {
|
|
1478
2411
|
await ((r = (i = this.options).showClickEffect) == null ? void 0 : r.call(i, {
|
|
1479
|
-
point:
|
|
1480
|
-
target:
|
|
1481
|
-
requested:
|
|
2412
|
+
point: t.point,
|
|
2413
|
+
target: t.target,
|
|
2414
|
+
requested: t.requested
|
|
1482
2415
|
}));
|
|
1483
2416
|
} catch {
|
|
1484
2417
|
}
|
|
1485
2418
|
}
|
|
1486
|
-
async waitFor(
|
|
1487
|
-
const n =
|
|
2419
|
+
async waitFor(t) {
|
|
2420
|
+
const n = A(t), o = ee(n.state, [
|
|
1488
2421
|
"attached",
|
|
1489
2422
|
"visible",
|
|
1490
2423
|
"hidden",
|
|
1491
2424
|
"detached"
|
|
1492
|
-
]) ?? "visible", i =
|
|
1493
|
-
|
|
1494
|
-
Math.max(
|
|
1495
|
-
|
|
2425
|
+
]) ?? "visible", i = G(n.timeoutSeconds), r = Math.min(
|
|
2426
|
+
Pe,
|
|
2427
|
+
Math.max(
|
|
2428
|
+
0,
|
|
2429
|
+
(i ?? De / 1e3) * 1e3
|
|
2430
|
+
)
|
|
2431
|
+
), a = Date.now(), s = this.tryResolveElement(n);
|
|
1496
2432
|
for (await this.showVisualEffect({
|
|
1497
2433
|
type: "wait_for",
|
|
1498
2434
|
state: o,
|
|
1499
|
-
target:
|
|
1500
|
-
requested:
|
|
1501
|
-
...
|
|
1502
|
-
point:
|
|
1503
|
-
}); Date.now() -
|
|
1504
|
-
const
|
|
1505
|
-
if (o === "attached" ? !!
|
|
2435
|
+
target: s ?? void 0,
|
|
2436
|
+
requested: s ?? void 0,
|
|
2437
|
+
...s ? { anchor: "target" } : {},
|
|
2438
|
+
point: s ? E(s).center : void 0
|
|
2439
|
+
}); Date.now() - a <= r; ) {
|
|
2440
|
+
const d = this.tryResolveElement(n);
|
|
2441
|
+
if (o === "attached" ? !!d : o === "detached" ? !d : o === "hidden" ? !d || !D(d) : !!(d && D(d)))
|
|
1506
2442
|
return {
|
|
1507
2443
|
waitedFor: o,
|
|
1508
|
-
elapsedMs: Date.now() -
|
|
1509
|
-
target:
|
|
2444
|
+
elapsedMs: Date.now() - a,
|
|
2445
|
+
target: d ? this.describeElement(d) : void 0
|
|
1510
2446
|
};
|
|
1511
|
-
await new Promise((
|
|
2447
|
+
await new Promise((c) => setTimeout(c, 100));
|
|
1512
2448
|
}
|
|
1513
2449
|
throw new Error(`Timed out waiting for target to become ${o}.`);
|
|
1514
2450
|
}
|
|
1515
|
-
tryResolveElement(
|
|
2451
|
+
tryResolveElement(t) {
|
|
1516
2452
|
try {
|
|
1517
|
-
return this.resolveElement(
|
|
2453
|
+
return this.resolveElement(t);
|
|
1518
2454
|
} catch {
|
|
1519
2455
|
return null;
|
|
1520
2456
|
}
|
|
1521
2457
|
}
|
|
1522
|
-
describeElement(
|
|
2458
|
+
describeElement(t) {
|
|
1523
2459
|
return {
|
|
1524
|
-
tag:
|
|
1525
|
-
role:
|
|
1526
|
-
name:
|
|
1527
|
-
selector:
|
|
2460
|
+
tag: t.tagName.toLowerCase(),
|
|
2461
|
+
role: q(t),
|
|
2462
|
+
name: R(t),
|
|
2463
|
+
selector: Ct(t)
|
|
1528
2464
|
};
|
|
1529
2465
|
}
|
|
1530
2466
|
}
|
|
1531
|
-
|
|
1532
|
-
|
|
2467
|
+
const on = /* @__PURE__ */ new Set([
|
|
2468
|
+
"verified",
|
|
2469
|
+
"verification_failed",
|
|
2470
|
+
"executed_unverified",
|
|
2471
|
+
"rejected_before_execution"
|
|
2472
|
+
]), rn = /(?:token|secret|password|passwd|api[-_]?key|auth|session|code|signature|credential)/i;
|
|
2473
|
+
function sn(e) {
|
|
2474
|
+
try {
|
|
2475
|
+
const t = new URL(e);
|
|
2476
|
+
for (const n of t.searchParams.keys())
|
|
2477
|
+
rn.test(n) && t.searchParams.set(n, "[REDACTED]");
|
|
2478
|
+
return t.hash = "", t.toString();
|
|
2479
|
+
} catch {
|
|
2480
|
+
return "[REDACTED_URL]";
|
|
2481
|
+
}
|
|
1533
2482
|
}
|
|
1534
|
-
function
|
|
1535
|
-
|
|
2483
|
+
function Kt(e, t, n) {
|
|
2484
|
+
var a, s;
|
|
2485
|
+
if (!n || typeof n != "object" || Array.isArray(n) || !Qt.includes(
|
|
2486
|
+
e
|
|
2487
|
+
))
|
|
2488
|
+
return n;
|
|
2489
|
+
const o = n;
|
|
2490
|
+
if (!o.outcome || !on.has(o.outcome))
|
|
2491
|
+
return n;
|
|
2492
|
+
const i = ((a = o.resolution) == null ? void 0 : a.pageStateId) ?? o.invalidatedPageStateId;
|
|
2493
|
+
if (!i)
|
|
2494
|
+
return n;
|
|
2495
|
+
const r = {
|
|
2496
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2497
|
+
pageStateId: i,
|
|
2498
|
+
url: sn(t),
|
|
2499
|
+
action: e,
|
|
2500
|
+
outcome: o.outcome,
|
|
2501
|
+
...(s = o.resolution) != null && s.requested ? { requested: o.resolution.requested } : {},
|
|
2502
|
+
...o.resolution ? { resolution: o.resolution } : {},
|
|
2503
|
+
...o.verification ? { verification: o.verification } : {}
|
|
2504
|
+
};
|
|
2505
|
+
return { ...o, evidence: r };
|
|
2506
|
+
}
|
|
2507
|
+
function an(e) {
|
|
2508
|
+
return typeof e == "object" && e !== null && !Array.isArray(e) ? e : {};
|
|
1536
2509
|
}
|
|
1537
|
-
function
|
|
2510
|
+
function cn(e) {
|
|
2511
|
+
return JSON.stringify(e);
|
|
2512
|
+
}
|
|
2513
|
+
function St(e, t, n) {
|
|
1538
2514
|
return {
|
|
1539
|
-
tool_call_id:
|
|
1540
|
-
name:
|
|
1541
|
-
status:
|
|
1542
|
-
content:
|
|
2515
|
+
tool_call_id: e.tool_call_id ?? e.id,
|
|
2516
|
+
name: e.name,
|
|
2517
|
+
status: t,
|
|
2518
|
+
content: cn(n)
|
|
1543
2519
|
};
|
|
1544
2520
|
}
|
|
1545
|
-
function
|
|
1546
|
-
return
|
|
2521
|
+
function ln(e) {
|
|
2522
|
+
return e instanceof Error ? e.message : String(e);
|
|
1547
2523
|
}
|
|
1548
|
-
function
|
|
1549
|
-
if (!
|
|
2524
|
+
function dn(e) {
|
|
2525
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1550
2526
|
return {};
|
|
1551
|
-
const
|
|
1552
|
-
return
|
|
2527
|
+
const t = Reflect.get(e, "details");
|
|
2528
|
+
return t && typeof t == "object" && !Array.isArray(t) ? t : {};
|
|
2529
|
+
}
|
|
2530
|
+
function un(e) {
|
|
2531
|
+
return e !== null && typeof e == "object" && !Array.isArray(e) && Reflect.get(e, "outcome") === "verification_failed";
|
|
1553
2532
|
}
|
|
1554
|
-
function
|
|
1555
|
-
|
|
2533
|
+
function Jt(e) {
|
|
2534
|
+
var n, o, i;
|
|
2535
|
+
const t = e.root && "location" in e.root ? e.root : (n = e.root) == null ? void 0 : n.ownerDocument;
|
|
2536
|
+
return ((o = t == null ? void 0 : t.location) == null ? void 0 : o.href) ?? ((i = globalThis.location) == null ? void 0 : i.href) ?? "";
|
|
2537
|
+
}
|
|
2538
|
+
function gn(e = {}) {
|
|
2539
|
+
const t = new nn(e);
|
|
1556
2540
|
return async (n) => {
|
|
1557
|
-
if (!
|
|
1558
|
-
return
|
|
2541
|
+
if (!Le(n.name))
|
|
2542
|
+
return St(n, "error", {
|
|
1559
2543
|
ok: !1,
|
|
1560
2544
|
error: `Unknown host page automation tool: ${n.name}`
|
|
1561
2545
|
});
|
|
1562
2546
|
try {
|
|
1563
|
-
const o =
|
|
2547
|
+
const o = Kt(
|
|
1564
2548
|
n.name,
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
2549
|
+
Jt(e),
|
|
2550
|
+
await t.execute(n.name, an(n.params))
|
|
2551
|
+
), i = un(o);
|
|
2552
|
+
return St(n, i ? "error" : "success", {
|
|
2553
|
+
ok: !i,
|
|
2554
|
+
result: o
|
|
2555
|
+
});
|
|
1568
2556
|
} catch (o) {
|
|
1569
|
-
|
|
2557
|
+
const i = Kt(
|
|
2558
|
+
n.name,
|
|
2559
|
+
Jt(e),
|
|
2560
|
+
dn(o)
|
|
2561
|
+
);
|
|
2562
|
+
return St(n, "error", {
|
|
1570
2563
|
ok: !1,
|
|
1571
|
-
error:
|
|
1572
|
-
...
|
|
2564
|
+
error: ln(o),
|
|
2565
|
+
...i
|
|
1573
2566
|
});
|
|
1574
2567
|
}
|
|
1575
2568
|
};
|
|
1576
2569
|
}
|
|
1577
|
-
const
|
|
2570
|
+
const C = {
|
|
2571
|
+
pageStateId: {
|
|
2572
|
+
type: "string",
|
|
2573
|
+
description: "Opaque page state id from the latest v2 host_page_snapshot."
|
|
2574
|
+
},
|
|
2575
|
+
documentRef: {
|
|
2576
|
+
type: "string",
|
|
2577
|
+
description: "Document scope from the latest v2 host_page_snapshot."
|
|
2578
|
+
},
|
|
1578
2579
|
ref: {
|
|
1579
2580
|
type: ["string", "number"],
|
|
1580
2581
|
description: "Element ref from host_page_snapshot."
|
|
@@ -1602,7 +2603,8 @@ const v = {
|
|
|
1602
2603
|
text: {
|
|
1603
2604
|
type: "string",
|
|
1604
2605
|
description: "Visible text to match."
|
|
1605
|
-
}
|
|
2606
|
+
}
|
|
2607
|
+
}, hn = {
|
|
1606
2608
|
x: {
|
|
1607
2609
|
type: "number",
|
|
1608
2610
|
description: "Viewport x coordinate."
|
|
@@ -1610,14 +2612,73 @@ const v = {
|
|
|
1610
2612
|
y: {
|
|
1611
2613
|
type: "number",
|
|
1612
2614
|
description: "Viewport y coordinate."
|
|
1613
|
-
}
|
|
1614
|
-
}, _e = {
|
|
2615
|
+
},
|
|
1615
2616
|
coordinateSpace: {
|
|
1616
2617
|
type: "string",
|
|
1617
2618
|
enum: ["viewport-css-px", "viewport_normalized"],
|
|
1618
2619
|
description: "Coordinate space for x/y. Use viewport_normalized for screenshot-derived points."
|
|
1619
2620
|
}
|
|
1620
|
-
},
|
|
2621
|
+
}, fn = {
|
|
2622
|
+
type: "object",
|
|
2623
|
+
properties: {
|
|
2624
|
+
documentScope: {
|
|
2625
|
+
type: "string",
|
|
2626
|
+
enum: ["same_document", "current_top"]
|
|
2627
|
+
},
|
|
2628
|
+
documentRef: { type: "string" },
|
|
2629
|
+
kind: {
|
|
2630
|
+
type: "string",
|
|
2631
|
+
enum: ["test_id", "selector", "semantic"]
|
|
2632
|
+
},
|
|
2633
|
+
testId: { type: "string" },
|
|
2634
|
+
selector: { type: "string" },
|
|
2635
|
+
match: { const: "exact" },
|
|
2636
|
+
identity: {
|
|
2637
|
+
type: "object",
|
|
2638
|
+
properties: {
|
|
2639
|
+
role: { type: "string" },
|
|
2640
|
+
name: { type: "string" },
|
|
2641
|
+
text: { type: "string" }
|
|
2642
|
+
},
|
|
2643
|
+
required: ["role"],
|
|
2644
|
+
additionalProperties: !1
|
|
2645
|
+
}
|
|
2646
|
+
},
|
|
2647
|
+
required: ["documentScope", "kind"],
|
|
2648
|
+
additionalProperties: !1
|
|
2649
|
+
}, F = {
|
|
2650
|
+
type: "object",
|
|
2651
|
+
properties: {
|
|
2652
|
+
type: {
|
|
2653
|
+
type: "string",
|
|
2654
|
+
enum: [
|
|
2655
|
+
"field_contains",
|
|
2656
|
+
"checked_equals",
|
|
2657
|
+
"element_visible",
|
|
2658
|
+
"element_hidden",
|
|
2659
|
+
"url_matches",
|
|
2660
|
+
"text_visible"
|
|
2661
|
+
]
|
|
2662
|
+
},
|
|
2663
|
+
target: fn,
|
|
2664
|
+
scope: {
|
|
2665
|
+
type: "object",
|
|
2666
|
+
properties: {
|
|
2667
|
+
documentScope: {
|
|
2668
|
+
type: "string",
|
|
2669
|
+
enum: ["same_document", "current_top"]
|
|
2670
|
+
},
|
|
2671
|
+
documentRef: { type: "string" }
|
|
2672
|
+
},
|
|
2673
|
+
required: ["documentScope"],
|
|
2674
|
+
additionalProperties: !1
|
|
2675
|
+
},
|
|
2676
|
+
mode: { type: "string", enum: ["exact", "prefix"] },
|
|
2677
|
+
value: { type: ["string", "boolean"] }
|
|
2678
|
+
},
|
|
2679
|
+
required: ["type"],
|
|
2680
|
+
additionalProperties: !1
|
|
2681
|
+
}, pn = {
|
|
1621
2682
|
type: "object",
|
|
1622
2683
|
properties: {
|
|
1623
2684
|
type: {
|
|
@@ -1635,27 +2696,34 @@ const v = {
|
|
|
1635
2696
|
},
|
|
1636
2697
|
required: ["type", "field", "value"],
|
|
1637
2698
|
additionalProperties: !1
|
|
1638
|
-
},
|
|
2699
|
+
}, mn = {
|
|
1639
2700
|
host_page_snapshot: {
|
|
1640
2701
|
type: "object",
|
|
1641
|
-
properties: {
|
|
2702
|
+
properties: {
|
|
2703
|
+
pageStateId: {
|
|
2704
|
+
type: "string",
|
|
2705
|
+
description: "Reuse the cached snapshot state when reading another paginated page."
|
|
2706
|
+
}
|
|
2707
|
+
},
|
|
1642
2708
|
additionalProperties: !1
|
|
1643
2709
|
},
|
|
1644
2710
|
host_page_click: {
|
|
1645
2711
|
type: "object",
|
|
1646
2712
|
properties: {
|
|
1647
|
-
...
|
|
2713
|
+
...C,
|
|
2714
|
+
expectation: F
|
|
1648
2715
|
},
|
|
1649
2716
|
additionalProperties: !1
|
|
1650
2717
|
},
|
|
1651
2718
|
host_page_fill: {
|
|
1652
2719
|
type: "object",
|
|
1653
2720
|
properties: {
|
|
1654
|
-
...
|
|
2721
|
+
...C,
|
|
1655
2722
|
value: {
|
|
1656
2723
|
type: "string",
|
|
1657
2724
|
description: "Text value to set on the target field."
|
|
1658
|
-
}
|
|
2725
|
+
},
|
|
2726
|
+
expectation: F
|
|
1659
2727
|
},
|
|
1660
2728
|
required: ["value"],
|
|
1661
2729
|
additionalProperties: !1
|
|
@@ -1663,11 +2731,12 @@ const v = {
|
|
|
1663
2731
|
host_page_press: {
|
|
1664
2732
|
type: "object",
|
|
1665
2733
|
properties: {
|
|
1666
|
-
...
|
|
2734
|
+
...C,
|
|
1667
2735
|
key: {
|
|
1668
2736
|
type: "string",
|
|
1669
2737
|
description: "Keyboard key to press."
|
|
1670
|
-
}
|
|
2738
|
+
},
|
|
2739
|
+
expectation: F
|
|
1671
2740
|
},
|
|
1672
2741
|
required: ["key"],
|
|
1673
2742
|
additionalProperties: !1
|
|
@@ -1675,7 +2744,7 @@ const v = {
|
|
|
1675
2744
|
host_page_select: {
|
|
1676
2745
|
type: "object",
|
|
1677
2746
|
properties: {
|
|
1678
|
-
...
|
|
2747
|
+
...C,
|
|
1679
2748
|
value: {
|
|
1680
2749
|
type: ["string", "array"],
|
|
1681
2750
|
description: "Select option value or values.",
|
|
@@ -1685,14 +2754,15 @@ const v = {
|
|
|
1685
2754
|
type: ["string", "array"],
|
|
1686
2755
|
description: "Select option values.",
|
|
1687
2756
|
items: { type: "string" }
|
|
1688
|
-
}
|
|
2757
|
+
},
|
|
2758
|
+
expectation: F
|
|
1689
2759
|
},
|
|
1690
2760
|
additionalProperties: !1
|
|
1691
2761
|
},
|
|
1692
2762
|
host_page_scroll: {
|
|
1693
2763
|
type: "object",
|
|
1694
2764
|
properties: {
|
|
1695
|
-
...
|
|
2765
|
+
...C,
|
|
1696
2766
|
deltaX: {
|
|
1697
2767
|
type: "number",
|
|
1698
2768
|
description: "Horizontal scroll delta."
|
|
@@ -1700,17 +2770,29 @@ const v = {
|
|
|
1700
2770
|
deltaY: {
|
|
1701
2771
|
type: "number",
|
|
1702
2772
|
description: "Vertical scroll delta."
|
|
1703
|
-
}
|
|
2773
|
+
},
|
|
2774
|
+
x: {
|
|
2775
|
+
type: "number",
|
|
2776
|
+
description: "Absolute horizontal scroll position."
|
|
2777
|
+
},
|
|
2778
|
+
y: {
|
|
2779
|
+
type: "number",
|
|
2780
|
+
description: "Absolute vertical scroll position."
|
|
2781
|
+
},
|
|
2782
|
+
expectation: F
|
|
1704
2783
|
},
|
|
1705
2784
|
additionalProperties: !1
|
|
1706
2785
|
},
|
|
1707
2786
|
host_page_navigate: {
|
|
1708
2787
|
type: "object",
|
|
1709
2788
|
properties: {
|
|
2789
|
+
pageStateId: C.pageStateId,
|
|
2790
|
+
documentRef: C.documentRef,
|
|
1710
2791
|
url: {
|
|
1711
2792
|
type: "string",
|
|
1712
2793
|
description: "HTTP(S) URL to navigate to."
|
|
1713
|
-
}
|
|
2794
|
+
},
|
|
2795
|
+
expectation: F
|
|
1714
2796
|
},
|
|
1715
2797
|
required: ["url"],
|
|
1716
2798
|
additionalProperties: !1
|
|
@@ -1718,22 +2800,22 @@ const v = {
|
|
|
1718
2800
|
host_page_hover: {
|
|
1719
2801
|
type: "object",
|
|
1720
2802
|
properties: {
|
|
1721
|
-
...
|
|
2803
|
+
...C
|
|
1722
2804
|
},
|
|
1723
2805
|
additionalProperties: !1
|
|
1724
2806
|
},
|
|
1725
2807
|
host_page_focus: {
|
|
1726
2808
|
type: "object",
|
|
1727
2809
|
properties: {
|
|
1728
|
-
...
|
|
2810
|
+
...C
|
|
1729
2811
|
},
|
|
1730
2812
|
additionalProperties: !1
|
|
1731
2813
|
},
|
|
1732
2814
|
host_page_pointer: {
|
|
1733
2815
|
type: "object",
|
|
1734
2816
|
properties: {
|
|
1735
|
-
...
|
|
1736
|
-
...
|
|
2817
|
+
...C,
|
|
2818
|
+
...hn,
|
|
1737
2819
|
action: {
|
|
1738
2820
|
type: "string",
|
|
1739
2821
|
enum: ["move", "down", "up", "click"],
|
|
@@ -1749,9 +2831,18 @@ const v = {
|
|
|
1749
2831
|
},
|
|
1750
2832
|
targetText: {
|
|
1751
2833
|
type: "string",
|
|
1752
|
-
description: "Required for explicit coordinate clicks.
|
|
2834
|
+
description: "Required for explicit coordinate clicks. Must exactly match the hit target or a finite actionable ancestor."
|
|
2835
|
+
},
|
|
2836
|
+
targetRole: {
|
|
2837
|
+
type: "string",
|
|
2838
|
+
description: "Exact role used to disambiguate coordinate targets."
|
|
2839
|
+
},
|
|
2840
|
+
targetContext: {
|
|
2841
|
+
type: "string",
|
|
2842
|
+
description: "Nearby exact context used to disambiguate coordinates."
|
|
1753
2843
|
},
|
|
1754
|
-
|
|
2844
|
+
expectation: F,
|
|
2845
|
+
expectedAfterClick: pn
|
|
1755
2846
|
},
|
|
1756
2847
|
additionalProperties: !1
|
|
1757
2848
|
},
|
|
@@ -1809,7 +2900,7 @@ const v = {
|
|
|
1809
2900
|
host_page_wait_for: {
|
|
1810
2901
|
type: "object",
|
|
1811
2902
|
properties: {
|
|
1812
|
-
...
|
|
2903
|
+
...C,
|
|
1813
2904
|
state: {
|
|
1814
2905
|
type: "string",
|
|
1815
2906
|
enum: ["attached", "visible", "hidden", "detached"],
|
|
@@ -1824,9 +2915,10 @@ const v = {
|
|
|
1824
2915
|
}
|
|
1825
2916
|
};
|
|
1826
2917
|
export {
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
2918
|
+
Qt as HOST_PAGE_AUTOMATION_TOOL_NAMES,
|
|
2919
|
+
mn as HOST_PAGE_AUTOMATION_TOOL_SCHEMAS,
|
|
2920
|
+
nn as HostPageAutomationExecutor,
|
|
2921
|
+
Kt as addBrowserActionEvidence,
|
|
2922
|
+
gn as createHostPageAutomationClientToolHandler,
|
|
2923
|
+
Le as isHostPageAutomationToolName
|
|
1832
2924
|
};
|