@xpert-ai/chatkit-host-automation 0.3.5 → 0.3.6

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +127 -1
  2. package/dist/index.js +884 -359
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const it = [
1
+ const vt = [
2
2
  "host_page_snapshot",
3
3
  "host_page_click",
4
4
  "host_page_fill",
@@ -10,10 +10,441 @@ const it = [
10
10
  "host_page_focus",
11
11
  "host_page_pointer",
12
12
  "host_page_screenshot",
13
+ "host_page_read",
13
14
  "host_page_wait_for"
14
- ], rt = new Set(
15
- it
16
- ), st = [
15
+ ];
16
+ function dt(t) {
17
+ return (t ?? "").replace(/\s+/g, " ").trim();
18
+ }
19
+ function J(t, e = 600) {
20
+ return t.length > e ? `${t.slice(0, e)}... [truncated ${t.length - e} chars]` : t;
21
+ }
22
+ function xt(t, e = 600) {
23
+ return t ? J(t, e) : void 0;
24
+ }
25
+ function C(t) {
26
+ const e = dt(t.textContent);
27
+ return e ? J(e) : void 0;
28
+ }
29
+ function ft(t) {
30
+ const e = dt(
31
+ Array.from(t.childNodes).filter((n) => n.nodeType === Node.TEXT_NODE).map((n) => n.textContent ?? "").join(" ")
32
+ );
33
+ return e ? J(e) : void 0;
34
+ }
35
+ function D(t) {
36
+ var o;
37
+ if (!(t instanceof HTMLElement || t instanceof SVGElement) || t instanceof HTMLElement && t.hidden)
38
+ return !1;
39
+ const e = (o = t.ownerDocument.defaultView) == null ? void 0 : o.getComputedStyle(t);
40
+ if (e && (e.display === "none" || e.visibility === "hidden" || e.opacity === "0"))
41
+ return !1;
42
+ const n = t.getBoundingClientRect();
43
+ return n.width > 0 && n.height > 0;
44
+ }
45
+ function k(t) {
46
+ const e = t.getBoundingClientRect();
47
+ return {
48
+ x: e.left,
49
+ y: e.top,
50
+ width: e.width,
51
+ height: e.height
52
+ };
53
+ }
54
+ function _t(t) {
55
+ return t instanceof Document ? t : t.ownerDocument;
56
+ }
57
+ function Q(t) {
58
+ let e = t;
59
+ for (; e; ) {
60
+ let n = e.previousElementSibling;
61
+ for (; n; ) {
62
+ if (n.matches('h1,h2,h3,h4,h5,h6,[role="heading"]'))
63
+ return C(n);
64
+ const o = n.querySelector(
65
+ 'h1,h2,h3,h4,h5,h6,[role="heading"]'
66
+ );
67
+ if (o)
68
+ return C(o);
69
+ n = n.previousElementSibling;
70
+ }
71
+ e = e.parentElement;
72
+ }
73
+ }
74
+ function W(t) {
75
+ const e = Array.from(t.children).map((n) => ft(n) ?? C(n)).filter((n) => !!n);
76
+ return e.length > 1 ? e : t.children.length === 1 ? W(t.children[0]) : e;
77
+ }
78
+ function Tt(t) {
79
+ if (Array.from(t.children).some(
80
+ (i) => W(i).length === 2
81
+ ))
82
+ return;
83
+ const e = W(t);
84
+ if (e.length !== 2)
85
+ return;
86
+ const [n, o] = e;
87
+ if (!(!n || !o || n === o || n.length > 120))
88
+ return { name: n, value: o };
89
+ }
90
+ function St(t) {
91
+ return t.fields ? t.fields.slice(0, 2).map((e) => `${e.name}: ${e.value}`) : t.items ? t.items.slice(0, 2) : t.rows ? t.rows.slice(0, 2).map((e) => e.join(" | ")) : t.text ? [t.text] : [];
92
+ }
93
+ function Ct(t) {
94
+ return t.fields ? t.fields.length : t.items ? t.items.length : t.rows ? t.rows.length : t.text ? 1 : 0;
95
+ }
96
+ function Mt(t) {
97
+ return [
98
+ t.heading,
99
+ t.text,
100
+ ...t.items ?? [],
101
+ ...(t.fields ?? []).flatMap((e) => [e.name, e.value]),
102
+ ...t.headers ?? [],
103
+ ...(t.rows ?? []).flat()
104
+ ].reduce((e, n) => e + ((n == null ? void 0 : n.length) ?? 0), 0);
105
+ }
106
+ function At(t) {
107
+ return t.slice(0, 80).map((e, n) => {
108
+ const o = Mt(e), i = `b${n + 1}`;
109
+ return {
110
+ ...e,
111
+ blockId: i,
112
+ preview: St(e),
113
+ itemCount: Ct(e),
114
+ chars: o,
115
+ truncated: o > 4e3,
116
+ readHint: {
117
+ tool: "host_page_read",
118
+ args: { blockId: i }
119
+ }
120
+ };
121
+ });
122
+ }
123
+ function Lt(t) {
124
+ return t.map((e, n) => ({
125
+ index: n,
126
+ blockId: e.blockId,
127
+ type: e.type,
128
+ heading: e.heading,
129
+ level: e.level,
130
+ itemCount: e.itemCount,
131
+ chars: e.chars,
132
+ truncated: e.truncated
133
+ }));
134
+ }
135
+ function Rt(t) {
136
+ return t.truncated ? "block_truncated" : t.type === "keyValueList" ? "structured_fields" : t.type === "table" ? "structured_table" : t.itemCount > 2 ? "preview_incomplete" : "long_readable_block";
137
+ }
138
+ function kt(t) {
139
+ return (t.type === "keyValueList" ? 100 : t.type === "table" ? 90 : t.type === "list" ? 80 : t.type === "paragraph" ? 50 : 10) + (t.truncated ? 40 : 0) + Math.min(t.itemCount, 20) + Math.min(Math.floor(t.chars / 400), 20);
140
+ }
141
+ function Pt(t) {
142
+ return t.filter(
143
+ (e) => e.type !== "heading" && (e.truncated || e.itemCount > 2 || e.chars > 600)
144
+ ).map((e, n) => ({
145
+ block: e,
146
+ index: n,
147
+ score: kt(e)
148
+ })).sort((e, n) => n.score - e.score || e.index - n.index).slice(0, 12).sort((e, n) => e.index - n.index).map(({ block: e }) => ({
149
+ blockId: e.blockId,
150
+ type: e.type,
151
+ heading: e.heading,
152
+ reason: Rt(e),
153
+ args: {
154
+ blockId: e.blockId,
155
+ pageSize: e.fields || e.items || e.rows ? Math.min(20, Math.max(1, e.itemCount)) : void 0
156
+ }
157
+ }));
158
+ }
159
+ function Nt(t) {
160
+ const e = Lt(t.blocks), n = Pt(t.blocks);
161
+ return {
162
+ ...t,
163
+ outline: e,
164
+ suggestedReads: n,
165
+ blocks: t.blocks.map((o) => ({
166
+ blockId: o.blockId,
167
+ type: o.type,
168
+ heading: o.heading,
169
+ level: o.level,
170
+ preview: o.preview,
171
+ itemCount: o.itemCount,
172
+ chars: o.chars,
173
+ truncated: o.truncated,
174
+ rect: o.rect,
175
+ readHint: o.readHint
176
+ }))
177
+ };
178
+ }
179
+ function It(t, e, n) {
180
+ const o = [], i = _t(t).createTreeWalker(
181
+ t,
182
+ NodeFilter.SHOW_ELEMENT
183
+ );
184
+ let r = i.nextNode();
185
+ for (; r; ) {
186
+ const s = r;
187
+ if (D(s)) {
188
+ const a = Tt(s);
189
+ a && o.push({ ...a, element: s });
190
+ }
191
+ r = i.nextNode();
192
+ }
193
+ if (o.length !== 0) {
194
+ e.push({
195
+ type: "keyValueList",
196
+ heading: Q(o[0].element),
197
+ fields: o.slice(0, 80).map(({ name: s, value: a }) => ({ name: s, value: a })),
198
+ rect: k(o[0].element)
199
+ });
200
+ for (const s of o)
201
+ n.add(s.element);
202
+ }
203
+ }
204
+ function Ht(t, e, n) {
205
+ for (const o of Array.from(t.querySelectorAll('ul,ol,[role="list"]'))) {
206
+ if (!D(o))
207
+ continue;
208
+ const i = Array.from(o.children).map((r) => C(r)).filter((r) => !!r).slice(0, 80);
209
+ if (i.length !== 0) {
210
+ e.push({
211
+ type: "list",
212
+ heading: Q(o),
213
+ items: i,
214
+ rect: k(o)
215
+ }), n.add(o);
216
+ for (const r of Array.from(o.children))
217
+ n.add(r);
218
+ }
219
+ }
220
+ }
221
+ function Ot(t, e, n) {
222
+ var o;
223
+ for (const i of Array.from(t.querySelectorAll('table,[role="table"],[role="grid"]'))) {
224
+ if (!D(i))
225
+ continue;
226
+ const r = Array.from(i.querySelectorAll('tr,[role="row"]')).map(
227
+ (a) => Array.from(a.querySelectorAll('th,td,[role="columnheader"],[role="cell"],[role="gridcell"]')).map((u) => C(u)).filter((u) => !!u).slice(0, 12)
228
+ ).filter((a) => a.length > 0).slice(0, 80);
229
+ if (r.length === 0)
230
+ continue;
231
+ const s = (o = r[0]) != null && o.every((a) => a.length <= 120) ? r[0] : void 0;
232
+ e.push({
233
+ type: "table",
234
+ heading: Q(i),
235
+ headers: s,
236
+ rows: s ? r.slice(1) : r,
237
+ rect: k(i)
238
+ }), n.add(i);
239
+ }
240
+ }
241
+ function Bt(t, e, n) {
242
+ const o = 'h1,h2,h3,h4,h5,h6,[role="heading"],p,article,section';
243
+ for (const i of Array.from(t.querySelectorAll(o))) {
244
+ if (e.length >= 80)
245
+ break;
246
+ if (n.has(i) || !D(i))
247
+ continue;
248
+ const r = i.tagName.toLowerCase(), s = ft(i) ?? C(i);
249
+ if (s) {
250
+ if (r.match(/^h[1-6]$/) || i.getAttribute("role") === "heading") {
251
+ const a = r.match(/^h[1-6]$/) ? Number(r.slice(1)) : Number(i.getAttribute("aria-level") ?? 0) || 2;
252
+ e.push({
253
+ type: "heading",
254
+ level: a,
255
+ text: s,
256
+ rect: k(i)
257
+ });
258
+ continue;
259
+ }
260
+ s.length >= 24 && e.push({
261
+ type: "paragraph",
262
+ text: s,
263
+ rect: k(i)
264
+ });
265
+ }
266
+ }
267
+ }
268
+ function Vt(t) {
269
+ return t.querySelectorAll(
270
+ '[aria-expanded="false"],[data-expanded="false"],details:not([open]),[hidden]'
271
+ ).length;
272
+ }
273
+ function Dt(t) {
274
+ return Array.from(t.querySelectorAll("iframe")).filter((e) => {
275
+ try {
276
+ return !e.contentDocument;
277
+ } catch {
278
+ return !0;
279
+ }
280
+ }).length;
281
+ }
282
+ function ot(t) {
283
+ const e = t instanceof Document ? t.body ?? t.documentElement : t;
284
+ if (!e)
285
+ return {
286
+ blocks: [],
287
+ totalBlocks: 0,
288
+ truncated: !1,
289
+ coverage: {
290
+ status: "complete",
291
+ visibleTextCaptured: !1,
292
+ truncatedBlocks: 0,
293
+ collapsedSections: 0,
294
+ crossOriginFrames: 0,
295
+ virtualizedListsDetected: 0,
296
+ visualOnlyRegions: 0
297
+ }
298
+ };
299
+ const n = [], o = /* @__PURE__ */ new Set();
300
+ It(e, n, o), Ht(e, n, o), Ot(e, n, o), Bt(e, n, o);
301
+ const i = At(n), r = i.filter((l) => l.truncated).length, s = Vt(e), a = Dt(e), u = n.length > i.length || r > 0 || s > 0 || a > 0, d = [];
302
+ return s > 0 && d.push("Some content is inside collapsed sections."), a > 0 && d.push("Some frame content could not be read from DOM."), {
303
+ blocks: i,
304
+ totalBlocks: n.length,
305
+ truncated: n.length > i.length || r > 0,
306
+ coverage: {
307
+ status: u ? "partial" : "complete",
308
+ visibleTextCaptured: i.length > 0,
309
+ truncatedBlocks: r,
310
+ collapsedSections: s,
311
+ crossOriginFrames: a,
312
+ virtualizedListsDetected: 0,
313
+ visualOnlyRegions: 0
314
+ },
315
+ ...d.length > 0 ? { warnings: d } : {}
316
+ };
317
+ }
318
+ function I(t, e, n) {
319
+ const o = Math.max(1, Math.min(100, Math.floor(n))), i = Math.max(1, Math.ceil(t / o)), r = Math.max(1, Math.min(i, Math.floor(e))), s = (r - 1) * o;
320
+ return {
321
+ page: r,
322
+ pageSize: o,
323
+ pageCount: i,
324
+ start: s,
325
+ end: Math.min(t, s + o)
326
+ };
327
+ }
328
+ function U(t) {
329
+ return JSON.stringify(t).length;
330
+ }
331
+ function F(t, e) {
332
+ const n = t[e];
333
+ return typeof n == "number" && Number.isFinite(n) ? n : void 0;
334
+ }
335
+ function H(t, e) {
336
+ const n = t[e];
337
+ return typeof n == "string" && n.trim() ? n : void 0;
338
+ }
339
+ function G(t, e, n = !1) {
340
+ const o = {
341
+ ...t,
342
+ truncated: !!t.truncated || n
343
+ }, i = U(o), r = {
344
+ ...o,
345
+ chars: i
346
+ };
347
+ return U(r) <= e ? r : {
348
+ blockId: H(t, "blockId"),
349
+ type: H(t, "type"),
350
+ heading: xt(H(t, "heading"), 120),
351
+ scope: H(t, "scope"),
352
+ page: F(t, "page"),
353
+ pageSize: 0,
354
+ pageCount: F(t, "pageCount"),
355
+ nextPage: F(t, "nextPage"),
356
+ chars: i,
357
+ truncated: !0,
358
+ budgetExceeded: !0,
359
+ warning: "Read result exceeded maxChars; retry with a smaller pageSize or a narrower blockId/query."
360
+ };
361
+ }
362
+ function O(t, e, n) {
363
+ let o = e;
364
+ for (; o >= 1; ) {
365
+ const i = n(o), r = G(
366
+ i,
367
+ t,
368
+ o < e
369
+ );
370
+ if (U(r) <= t)
371
+ return r;
372
+ o = Math.floor(o / 2);
373
+ }
374
+ return G(n(1), t, !0);
375
+ }
376
+ function qt(t, e = {}) {
377
+ var u;
378
+ const n = typeof e.page == "number" ? e.page : 1, o = typeof e.pageSize == "number" ? e.pageSize : 20, i = typeof e.maxChars == "number" && Number.isFinite(e.maxChars) ? Math.max(500, Math.min(12e3, Math.floor(e.maxChars))) : 4e3, r = (u = e.query) == null ? void 0 : u.trim().toLowerCase(), s = r ? t.blocks.filter(
379
+ (d) => JSON.stringify(d).toLowerCase().includes(r)
380
+ ) : t.blocks, a = e.blockId ? t.blocks.find((d) => d.blockId === e.blockId) : void 0;
381
+ if (a) {
382
+ if (a.fields && a.fields.length > 0) {
383
+ const d = a.fields;
384
+ return O(i, o, (l) => {
385
+ const c = I(d.length, n, l);
386
+ return {
387
+ ...a,
388
+ fields: d.slice(c.start, c.end),
389
+ page: c.page,
390
+ pageSize: c.pageSize,
391
+ pageCount: c.pageCount,
392
+ nextPage: c.page < c.pageCount ? c.page + 1 : void 0
393
+ };
394
+ });
395
+ }
396
+ if (a.items && a.items.length > 0) {
397
+ const d = a.items;
398
+ return O(i, o, (l) => {
399
+ const c = I(d.length, n, l);
400
+ return {
401
+ ...a,
402
+ items: d.slice(c.start, c.end),
403
+ page: c.page,
404
+ pageSize: c.pageSize,
405
+ pageCount: c.pageCount,
406
+ nextPage: c.page < c.pageCount ? c.page + 1 : void 0
407
+ };
408
+ });
409
+ }
410
+ if (a.rows && a.rows.length > 0) {
411
+ const d = a.rows;
412
+ return O(i, o, (l) => {
413
+ const c = I(d.length, n, l);
414
+ return {
415
+ ...a,
416
+ rows: d.slice(c.start, c.end),
417
+ page: c.page,
418
+ pageSize: c.pageSize,
419
+ pageCount: c.pageCount,
420
+ nextPage: c.page < c.pageCount ? c.page + 1 : void 0
421
+ };
422
+ });
423
+ }
424
+ return G(a, i);
425
+ }
426
+ return O(i, o, (d) => {
427
+ const l = I(s.length, n, d);
428
+ return {
429
+ scope: "visible",
430
+ blocks: s.slice(l.start, l.end),
431
+ page: l.page,
432
+ pageSize: l.pageSize,
433
+ pageCount: l.pageCount,
434
+ nextPage: l.page < l.pageCount ? l.page + 1 : void 0,
435
+ coverage: t.coverage,
436
+ warnings: t.warnings
437
+ };
438
+ });
439
+ }
440
+ class Xt extends Error {
441
+ constructor(e, n) {
442
+ super(e), this.details = n;
443
+ }
444
+ }
445
+ const Ft = new Set(
446
+ vt
447
+ ), zt = [
17
448
  "a[href]",
18
449
  "button",
19
450
  "input",
@@ -28,34 +459,34 @@ const it = [
28
459
  "[data-testid]",
29
460
  "[data-test-id]",
30
461
  "[data-qa]"
31
- ].join(","), X = 100, at = 1e4, ct = 6e4;
32
- function lt(t) {
33
- return rt.has(t);
462
+ ].join(","), it = 100, jt = 1e4, $t = 6e4;
463
+ function Wt(t) {
464
+ return Ft.has(t);
34
465
  }
35
466
  function T(t) {
36
467
  return t instanceof Document ? t : t.ownerDocument;
37
468
  }
38
- function N(t) {
469
+ function V(t) {
39
470
  return T(t).defaultView ?? window;
40
471
  }
41
- function m(t) {
472
+ function b(t) {
42
473
  return typeof t == "object" && t !== null && !Array.isArray(t) ? t : {};
43
474
  }
44
- function O(t, e) {
475
+ function z(t, e) {
45
476
  if (typeof t != "string" || t.trim() === "")
46
477
  throw new Error(`${e} must be a non-empty string.`);
47
478
  return t;
48
479
  }
49
- function x(t) {
480
+ function w(t) {
50
481
  return typeof t == "string" && t.trim() ? t : void 0;
51
482
  }
52
- function ut(t) {
483
+ function Ut(t) {
53
484
  return t === "viewport_normalized" ? "viewport_normalized" : "viewport-css-px";
54
485
  }
55
- function U(t, e) {
56
- const n = z(e.x, "x"), o = z(e.y, "y");
57
- if (ut(e.coordinateSpace) === "viewport_normalized") {
58
- const i = N(t);
486
+ function rt(t, e) {
487
+ const n = st(e.x, "x"), o = st(e.y, "y");
488
+ if (Ut(e.coordinateSpace) === "viewport_normalized") {
489
+ const i = V(t);
59
490
  return {
60
491
  x: Number((n * i.innerWidth).toFixed(3)),
61
492
  y: Number((o * i.innerHeight).toFixed(3))
@@ -63,58 +494,58 @@ function U(t, e) {
63
494
  }
64
495
  return { x: n, y: o };
65
496
  }
66
- function dt(t) {
497
+ function B(t) {
67
498
  return typeof t == "number" && Number.isInteger(t) ? t : void 0;
68
499
  }
69
- function z(t, e) {
500
+ function st(t, e) {
70
501
  if (typeof t != "number" || !Number.isFinite(t))
71
502
  throw new Error(`${e} must be a finite number.`);
72
503
  return t;
73
504
  }
74
- function k(t) {
505
+ function A(t) {
75
506
  return typeof t == "number" && Number.isFinite(t) ? t : void 0;
76
507
  }
77
- function Y(t, e) {
508
+ function at(t, e) {
78
509
  return typeof t == "string" && e.includes(t) ? t : void 0;
79
510
  }
80
- function ft(t) {
511
+ function Gt(t) {
81
512
  if (typeof t == "string")
82
513
  return [t];
83
514
  if (Array.isArray(t) && t.every((e) => typeof e == "string"))
84
515
  return t;
85
516
  throw new Error("value or values must be a string or an array of strings.");
86
517
  }
87
- function b(t) {
518
+ function m(t) {
88
519
  const e = (t.textContent ?? "").replace(/\s+/g, " ").trim();
89
520
  return e ? e.slice(0, 160) : void 0;
90
521
  }
91
- function P(t) {
522
+ function q(t) {
92
523
  const e = Array.from(t.childNodes).filter((n) => n.nodeType === Node.TEXT_NODE).map((n) => n.textContent ?? "").join(" ").replace(/\s+/g, " ").trim();
93
524
  return e ? e.slice(0, 160) : void 0;
94
525
  }
95
- function F(t) {
526
+ function Z(t) {
96
527
  if (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement)
97
528
  return t.value;
98
529
  }
99
- function Q(t) {
530
+ function ht(t) {
100
531
  return t instanceof HTMLInputElement && (t.type === "checkbox" || t.type === "radio");
101
532
  }
102
- function pt(t) {
533
+ function Yt(t) {
103
534
  return t instanceof HTMLInputElement || t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement ? Array.from(t.labels ?? []) : [];
104
535
  }
105
- function ht(t, e) {
536
+ function Kt(t, e) {
106
537
  var o;
107
- return (((o = t.getAttribute(e)) == null ? void 0 : o.trim().split(/\s+/)) ?? []).map((i) => t.ownerDocument.getElementById(i)).filter((i) => !!i).map((i) => b(i)).filter((i) => !!i);
538
+ return (((o = t.getAttribute(e)) == null ? void 0 : o.trim().split(/\s+/)) ?? []).map((i) => t.ownerDocument.getElementById(i)).filter((i) => !!i).map((i) => m(i)).filter((i) => !!i);
108
539
  }
109
- function gt(t) {
110
- const e = ht(t, "aria-labelledby");
540
+ function Jt(t) {
541
+ const e = Kt(t, "aria-labelledby");
111
542
  if (e.length > 0)
112
543
  return e.join(" ").slice(0, 160);
113
- const n = pt(t).map((o) => b(o)).filter((o) => !!o);
544
+ const n = Yt(t).map((o) => m(o)).filter((o) => !!o);
114
545
  if (n.length > 0)
115
546
  return n.join(" ").slice(0, 160);
116
547
  }
117
- function bt(t) {
548
+ function Qt(t) {
118
549
  const e = [];
119
550
  let n = t.nextSibling;
120
551
  for (; n; ) {
@@ -130,8 +561,8 @@ function bt(t) {
130
561
  'input,textarea,select,button,a[href],[role="button"],[role="link"]'
131
562
  ))
132
563
  break;
133
- const s = b(i);
134
- s && e.push(s);
564
+ const r = m(i);
565
+ r && e.push(r);
135
566
  break;
136
567
  }
137
568
  }
@@ -142,7 +573,7 @@ function bt(t) {
142
573
  const o = e.join(" ").replace(/\s+/g, " ").trim();
143
574
  return o ? o.slice(0, 160) : void 0;
144
575
  }
145
- function G(t, e) {
576
+ function ct(t, e) {
146
577
  var d;
147
578
  const n = t.ownerDocument, o = n.body;
148
579
  if (!o)
@@ -150,86 +581,86 @@ function G(t, e) {
150
581
  const i = t.getBoundingClientRect();
151
582
  if (i.width <= 0 || i.height <= 0)
152
583
  return;
153
- const s = i.top + i.height / 2, r = [], a = n.createTreeWalker(o, NodeFilter.SHOW_ELEMENT);
154
- let c = a.nextNode();
155
- for (; c; ) {
156
- const u = c;
157
- if (u !== t && !u.contains(t) && j(u)) {
158
- const l = u.getBoundingClientRect(), f = P(u) ?? b(u);
584
+ const r = i.top + i.height / 2, s = [], a = n.createTreeWalker(o, NodeFilter.SHOW_ELEMENT);
585
+ let u = a.nextNode();
586
+ for (; u; ) {
587
+ const l = u;
588
+ if (l !== t && !l.contains(t) && tt(l)) {
589
+ const c = l.getBoundingClientRect(), f = q(l) ?? m(l);
159
590
  if (f) {
160
- const p = l.top + l.height / 2, y = Math.abs(p - s) <= Math.max(28, i.height * 1.25), h = e === "left" ? i.left - l.right : l.left - i.right;
161
- y && h >= -8 && h <= 240 && r.push({
591
+ const h = c.top + c.height / 2, y = Math.abs(h - r) <= Math.max(28, i.height * 1.25), p = e === "left" ? i.left - c.right : c.left - i.right;
592
+ y && p >= -8 && p <= 240 && s.push({
162
593
  text: f,
163
- score: Math.abs(h) + Math.abs(p - s)
594
+ score: Math.abs(p) + Math.abs(h - r)
164
595
  });
165
596
  }
166
597
  }
167
- c = a.nextNode();
598
+ u = a.nextNode();
168
599
  }
169
- return (d = r.sort((u, l) => u.score - l.score)[0]) == null ? void 0 : d.text;
600
+ return (d = s.sort((l, c) => l.score - c.score)[0]) == null ? void 0 : d.text;
170
601
  }
171
- function H(t) {
602
+ function X(t) {
172
603
  if (!(t instanceof HTMLInputElement || t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement))
173
604
  return;
174
- const e = gt(t);
175
- return e || (Q(t) ? G(t, "right") ?? bt(t) ?? C(t)[0] : G(t, "left") ?? C(t)[0]);
605
+ const e = Jt(t);
606
+ return e || (ht(t) ? ct(t, "right") ?? Qt(t) ?? P(t)[0] : ct(t, "left") ?? P(t)[0]);
176
607
  }
177
- function K(t, e) {
608
+ function lt(t, e) {
178
609
  const n = e.trim().toLowerCase();
179
610
  return t instanceof HTMLInputElement && t.type === "radio" ? n === "radio" || n === "radio button" : t instanceof HTMLInputElement && t.type === "checkbox" ? n === "checkbox" || n === "check box" : t instanceof HTMLSelectElement ? n === "select" || n === "select menu" || n === "combobox" || n === "combo box" : !1;
180
611
  }
181
- function v(t) {
182
- const e = H(t), n = t.getAttribute("aria-label");
183
- if (n != null && n.trim() && !K(t, n))
612
+ function x(t) {
613
+ const e = X(t), n = t.getAttribute("aria-label");
614
+ if (n != null && n.trim() && !lt(t, n))
184
615
  return n.trim();
185
616
  const o = t.getAttribute("title");
186
- if (o != null && o.trim() && !K(t, o))
617
+ if (o != null && o.trim() && !lt(t, o))
187
618
  return o.trim();
188
619
  if (e)
189
620
  return e;
190
- const i = C(t)[0];
191
- return i || b(t);
621
+ const i = P(t)[0];
622
+ return i || m(t);
192
623
  }
193
- function j(t) {
194
- if (!(t instanceof HTMLElement || t instanceof SVGElement) || !_(t) || t.matches(
624
+ function tt(t) {
625
+ if (!(t instanceof HTMLElement || t instanceof SVGElement) || !S(t) || t.matches(
195
626
  'input,textarea,select,button,a[href],[role="button"],[role="link"]'
196
627
  ))
197
628
  return !1;
198
- const e = P(t) ?? b(t);
629
+ const e = q(t) ?? m(t);
199
630
  return !!(e && e.length <= 120);
200
631
  }
201
- function Z(t) {
202
- var l;
203
- if (!Q(t))
632
+ function pt(t) {
633
+ var c;
634
+ if (!ht(t))
204
635
  return;
205
- const e = t.closest("fieldset"), n = e == null ? void 0 : e.querySelector("legend"), o = n ? b(n) : void 0;
636
+ const e = t.closest("fieldset"), n = e == null ? void 0 : e.querySelector("legend"), o = n ? m(n) : void 0;
206
637
  if (o)
207
638
  return o;
208
- const i = t.ownerDocument, s = i.body;
209
- if (!s)
639
+ const i = t.ownerDocument, r = i.body;
640
+ if (!r)
210
641
  return;
211
- const r = t.getBoundingClientRect();
212
- if (r.width <= 0 || r.height <= 0)
642
+ const s = t.getBoundingClientRect();
643
+ if (s.width <= 0 || s.height <= 0)
213
644
  return;
214
- const a = r.left + r.width / 2, c = [], d = i.createTreeWalker(s, NodeFilter.SHOW_ELEMENT);
215
- let u = d.nextNode();
216
- for (; u; ) {
217
- const f = u;
218
- if (f !== t && !f.contains(t) && f.matches('legend,strong,b,[role="heading"],h1,h2,h3,h4,h5,h6') && j(f)) {
219
- const p = f.getBoundingClientRect(), y = P(f) ?? b(f);
220
- if (y && p.bottom <= r.top + 8) {
221
- const h = r.top - p.bottom, E = p.left + p.width / 2;
222
- h <= 160 && E >= r.left - 120 && E <= r.right + 320 && c.push({
645
+ const a = s.left + s.width / 2, u = [], d = i.createTreeWalker(r, NodeFilter.SHOW_ELEMENT);
646
+ let l = d.nextNode();
647
+ for (; l; ) {
648
+ const f = l;
649
+ if (f !== t && !f.contains(t) && f.matches('legend,strong,b,[role="heading"],h1,h2,h3,h4,h5,h6') && tt(f)) {
650
+ const h = f.getBoundingClientRect(), y = q(f) ?? m(f);
651
+ if (y && h.bottom <= s.top + 8) {
652
+ const p = s.top - h.bottom, E = h.left + h.width / 2;
653
+ p <= 160 && E >= s.left - 120 && E <= s.right + 320 && u.push({
223
654
  text: y,
224
- score: h + Math.abs(E - a) * 0.25
655
+ score: p + Math.abs(E - a) * 0.25
225
656
  });
226
657
  }
227
658
  }
228
- u = d.nextNode();
659
+ l = d.nextNode();
229
660
  }
230
- return (l = c.sort((f, p) => f.score - p.score)[0]) == null ? void 0 : l.text;
661
+ return (c = u.sort((f, h) => f.score - h.score)[0]) == null ? void 0 : c.text;
231
662
  }
232
- function yt(t) {
663
+ function Zt(t) {
233
664
  if (!(t instanceof HTMLSelectElement))
234
665
  return;
235
666
  const e = Array.from(t.options).map((n) => ({
@@ -240,45 +671,45 @@ function yt(t) {
240
671
  }));
241
672
  return e.length ? e : void 0;
242
673
  }
243
- function Et(t) {
674
+ function te(t) {
244
675
  if (!(t instanceof HTMLSelectElement))
245
676
  return;
246
677
  const e = t.selectedOptions[0], n = e ? (e.label || e.textContent || e.value).replace(/\s+/g, " ").trim() : void 0;
247
678
  return n ? n.slice(0, 160) : void 0;
248
679
  }
249
- function C(t) {
680
+ function P(t) {
250
681
  const e = t.ownerDocument, n = e.body;
251
682
  if (!n)
252
683
  return [];
253
684
  const o = t.getBoundingClientRect();
254
685
  if (o.width <= 0 || o.height <= 0)
255
686
  return [];
256
- const i = o.top + o.height / 2, s = o.left + o.width / 2, r = [], a = e.createTreeWalker(n, NodeFilter.SHOW_ELEMENT);
257
- let c = a.nextNode();
258
- for (; c; ) {
259
- const u = c;
260
- if (u !== t && !u.contains(t) && j(u)) {
261
- const l = u.getBoundingClientRect(), f = P(u) ?? b(u);
687
+ const i = o.top + o.height / 2, r = o.left + o.width / 2, s = [], a = e.createTreeWalker(n, NodeFilter.SHOW_ELEMENT);
688
+ let u = a.nextNode();
689
+ for (; u; ) {
690
+ const l = u;
691
+ if (l !== t && !l.contains(t) && tt(l)) {
692
+ const c = l.getBoundingClientRect(), f = q(l) ?? m(l);
262
693
  if (f) {
263
- const p = l.top + l.height / 2, y = l.left + l.width / 2, h = l.right <= o.left + 12 && Math.abs(p - i) <= Math.max(28, o.height * 1.25), E = l.left >= o.right - 8 && l.left - o.right <= 240 && Math.abs(p - i) <= Math.max(28, o.height * 1.25), W = l.bottom <= o.top + 8 && o.top - l.bottom <= 80 && y >= o.left - 80 && y <= o.right + 80;
264
- if (h || E || W) {
265
- const ot = h ? o.left - l.right + Math.abs(p - i) : E ? l.left - o.right + Math.abs(p - i) : o.top - l.bottom + Math.abs(y - s);
266
- r.push({
694
+ const h = c.top + c.height / 2, y = c.left + c.width / 2, p = c.right <= o.left + 12 && Math.abs(h - i) <= Math.max(28, o.height * 1.25), E = c.left >= o.right - 8 && c.left - o.right <= 240 && Math.abs(h - i) <= Math.max(28, o.height * 1.25), nt = c.bottom <= o.top + 8 && o.top - c.bottom <= 80 && y >= o.left - 80 && y <= o.right + 80;
695
+ if (p || E || nt) {
696
+ const wt = p ? o.left - c.right + Math.abs(h - i) : E ? c.left - o.right + Math.abs(h - i) : o.top - c.bottom + Math.abs(y - r);
697
+ s.push({
267
698
  text: f,
268
- score: ot + (h ? 0 : E ? 5 : 100)
699
+ score: wt + (p ? 0 : E ? 5 : 100)
269
700
  });
270
701
  }
271
702
  }
272
703
  }
273
- c = a.nextNode();
704
+ u = a.nextNode();
274
705
  }
275
706
  const d = /* @__PURE__ */ new Set();
276
- return r.sort((u, l) => u.score - l.score).map((u) => u.text).filter((u) => d.has(u) ? !1 : (d.add(u), !0)).slice(0, 4);
707
+ return s.sort((l, c) => l.score - c.score).map((l) => l.text).filter((l) => d.has(l) ? !1 : (d.add(l), !0)).slice(0, 4);
277
708
  }
278
- function mt(t) {
709
+ function ee(t) {
279
710
  return t.getAttribute("data-testid") ?? t.getAttribute("data-test-id") ?? t.getAttribute("data-qa") ?? void 0;
280
711
  }
281
- function S(t) {
712
+ function M(t) {
282
713
  const e = t.getAttribute("role");
283
714
  if (e != null && e.trim())
284
715
  return e.trim();
@@ -302,55 +733,55 @@ function S(t) {
302
733
  return "textbox";
303
734
  }
304
735
  }
305
- function tt(t) {
736
+ function gt(t) {
306
737
  return t instanceof HTMLButtonElement || t instanceof HTMLInputElement || t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement ? t.disabled || void 0 : t.getAttribute("aria-disabled") === "true" || void 0;
307
738
  }
308
- function wt(t) {
739
+ function ne(t) {
309
740
  return t instanceof HTMLInputElement && (t.type === "checkbox" || t.type === "radio") ? t.checked : void 0;
310
741
  }
311
- function vt(t) {
312
- const e = A(t);
742
+ function oe(t) {
743
+ const e = N(t);
313
744
  if (!(e.width <= 0 || e.height <= 0))
314
745
  return {
315
746
  x: e.x + e.width / 2,
316
747
  y: e.y + e.height / 2
317
748
  };
318
749
  }
319
- function V(t) {
750
+ function _(t) {
320
751
  return {
321
752
  tag: t.tagName.toLowerCase(),
322
- role: S(t),
323
- name: v(t),
324
- selector: q(t)
753
+ role: M(t),
754
+ name: x(t),
755
+ selector: Y(t)
325
756
  };
326
757
  }
327
- function _(t) {
758
+ function S(t) {
328
759
  if (!(t instanceof HTMLElement || t instanceof SVGElement) || t instanceof HTMLElement && t.hidden)
329
760
  return !1;
330
761
  const e = t.ownerDocument.defaultView, n = e == null ? void 0 : e.getComputedStyle(t);
331
762
  return !(n && (n.display === "none" || n.visibility === "hidden" || n.opacity === "0"));
332
763
  }
333
- function et(t) {
334
- return t.matches(st) && _(t);
764
+ function mt(t) {
765
+ return t.matches(zt) && S(t);
335
766
  }
336
- function xt(t) {
337
- return tt(t) !== !0;
767
+ function ie(t) {
768
+ return gt(t) !== !0;
338
769
  }
339
- function Tt(t) {
770
+ function re(t) {
340
771
  var n;
341
- if (et(t))
772
+ if (mt(t))
342
773
  return !0;
343
774
  if (!(t instanceof HTMLElement))
344
775
  return !1;
345
776
  const e = (n = t.ownerDocument.defaultView) == null ? void 0 : n.getComputedStyle(t);
346
- return ((e == null ? void 0 : e.cursor) === "pointer" || !!t.onclick) && _(t);
777
+ return ((e == null ? void 0 : e.cursor) === "pointer" || !!t.onclick) && S(t);
347
778
  }
348
- function A(t) {
349
- var s, r;
779
+ function N(t) {
780
+ var r, s;
350
781
  const e = t.getBoundingClientRect();
351
782
  let n = e.left, o = e.top, i = null;
352
783
  try {
353
- i = ((s = t.ownerDocument.defaultView) == null ? void 0 : s.frameElement) ?? null;
784
+ i = ((r = t.ownerDocument.defaultView) == null ? void 0 : r.frameElement) ?? null;
354
785
  } catch {
355
786
  i = null;
356
787
  }
@@ -358,7 +789,7 @@ function A(t) {
358
789
  const a = i.getBoundingClientRect();
359
790
  n += a.left, o += a.top;
360
791
  try {
361
- i = ((r = i.ownerDocument.defaultView) == null ? void 0 : r.frameElement) ?? null;
792
+ i = ((s = i.ownerDocument.defaultView) == null ? void 0 : s.frameElement) ?? null;
362
793
  } catch {
363
794
  i = null;
364
795
  }
@@ -370,7 +801,7 @@ function A(t) {
370
801
  height: e.height
371
802
  };
372
803
  }
373
- function q(t) {
804
+ function Y(t) {
374
805
  const e = (o) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(o) : o.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
375
806
  if (t.id)
376
807
  return `#${e(t.id)}`;
@@ -384,7 +815,7 @@ function q(t) {
384
815
  n
385
816
  )}"]` : t.tagName.toLowerCase();
386
817
  }
387
- function _t(t) {
818
+ function se(t) {
388
819
  const e = t.getBoundingClientRect();
389
820
  if (!(e.width <= 0 || e.height <= 0))
390
821
  return {
@@ -392,7 +823,7 @@ function _t(t) {
392
823
  y: e.top + e.height / 2
393
824
  };
394
825
  }
395
- function nt(t, e) {
826
+ function yt(t, e) {
396
827
  if (typeof t.elementsFromPoint == "function")
397
828
  return t.elementsFromPoint(e.x, e.y);
398
829
  if (typeof t.elementFromPoint != "function")
@@ -400,28 +831,31 @@ function nt(t, e) {
400
831
  const n = t.elementFromPoint(e.x, e.y);
401
832
  return n ? [n] : [];
402
833
  }
403
- function St(t) {
834
+ function ae(t) {
404
835
  return typeof t.elementsFromPoint == "function" || typeof t.elementFromPoint == "function";
405
836
  }
406
- function R(t, e) {
837
+ function ce(t, e) {
407
838
  return t === e || t.contains(e);
408
839
  }
409
- function kt(t) {
840
+ function le(t) {
410
841
  let e = t;
411
842
  for (; e; ) {
412
- if (Tt(e))
843
+ if (re(e))
413
844
  return e;
414
845
  e = e.parentElement;
415
846
  }
416
847
  return t;
417
848
  }
418
- function J(t) {
849
+ function ut(t) {
419
850
  return (t ?? "").replace(/\([^)]*\)/g, "").replace(/\s+/g, "").trim().toLowerCase();
420
851
  }
421
- function B(t) {
852
+ function K(t) {
853
+ return bt(t)[0];
854
+ }
855
+ function bt(t) {
422
856
  const e = t.getBoundingClientRect();
423
857
  if (e.width <= 0 || e.height <= 0)
424
- return;
858
+ return [];
425
859
  const n = t.ownerDocument;
426
860
  return [
427
861
  { x: e.left + e.width / 2, y: e.top + e.height / 2 },
@@ -429,85 +863,88 @@ function B(t) {
429
863
  { x: e.right - Math.min(8, e.width / 2), y: e.top + e.height / 2 },
430
864
  { x: e.left + e.width / 2, y: e.top + Math.min(8, e.height / 2) },
431
865
  { x: e.left + e.width / 2, y: e.bottom - Math.min(8, e.height / 2) }
432
- ].find(
433
- (i) => nt(n, i).some(
434
- (s) => R(t, s) || R(s, t)
435
- )
436
- );
866
+ ].filter((i) => {
867
+ const r = yt(n, i)[0];
868
+ return r ? ce(t, r) : !1;
869
+ });
437
870
  }
438
- function Mt(t, e) {
439
- const n = t.getBoundingClientRect(), o = A(t);
871
+ function Et(t, e) {
872
+ const n = t.getBoundingClientRect(), o = N(t);
440
873
  return {
441
874
  x: e.x + o.x - n.left,
442
875
  y: e.y + o.y - n.top
443
876
  };
444
877
  }
445
- function Lt(t, e) {
446
- var s;
447
- const n = S(e), o = J(v(e));
448
- return o ? ((s = $(t).filter((r) => r !== e).filter((r) => {
449
- const a = S(r), c = J(v(r));
450
- return n && a && n !== a ? !1 : c.includes(o) || o.includes(c);
451
- }).map((r) => ({
452
- candidate: r,
453
- point: B(r),
454
- rect: A(r)
878
+ function ue(t, e) {
879
+ var r;
880
+ const n = M(e), o = ut(x(e));
881
+ return o ? ((r = et(t).filter((s) => s !== e).filter((s) => {
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)
455
888
  })).filter(
456
- (r) => !!r.point
457
- ).sort((r, a) => a.rect.y - r.rect.y)[0]) == null ? void 0 : s.candidate) ?? null : null;
889
+ (s) => !!s.point
890
+ ).sort((s, a) => a.rect.y - s.rect.y)[0]) == null ? void 0 : r.candidate) ?? null : null;
458
891
  }
459
892
  function g(t) {
460
- const e = t.ownerDocument, n = _t(t), o = _(t) && !!n, i = xt(t), s = n ? nt(e, n) : [], r = s[0], a = !!(r && (R(t, r) || R(r, 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;
461
896
  return {
462
897
  visible: o,
463
898
  enabled: i,
464
- receivesEvents: a,
465
- actionable: o && i && a,
466
- center: vt(t),
467
- hitTarget: r,
468
- hitStack: s
899
+ receivesEvents: u,
900
+ actionable: o && i && u,
901
+ center: oe(t),
902
+ hitTarget: s,
903
+ hitStack: r,
904
+ safeClickPoints: a,
905
+ occludedBy: o && i && !u ? s : void 0
469
906
  };
470
907
  }
471
- function Ct(t, e) {
472
- var a, c, d;
473
- const n = x(e.testId);
908
+ function de(t, e) {
909
+ var a, u, d;
910
+ const n = w(e.testId);
474
911
  if (n) {
475
- const u = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(n) : n.replaceAll("\\", "\\\\").replaceAll('"', '\\"'), l = t.querySelector(
476
- `[data-testid="${u}"],[data-test-id="${u}"],[data-qa="${u}"]`
912
+ const l = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(n) : n.replaceAll("\\", "\\\\").replaceAll('"', '\\"'), c = t.querySelector(
913
+ `[data-testid="${l}"],[data-test-id="${l}"],[data-qa="${l}"]`
477
914
  );
478
- if (l)
479
- return l;
915
+ if (c)
916
+ return c;
480
917
  }
481
- const o = (a = x(e.role)) == null ? void 0 : a.toLowerCase(), i = (c = x(e.name)) == null ? void 0 : c.toLowerCase(), s = (d = x(e.text)) == null ? void 0 : d.toLowerCase();
482
- return !o && !i && !s ? null : $(t).find((u) => {
483
- var y, h, E;
484
- const l = (y = S(u)) == null ? void 0 : y.toLowerCase(), f = (h = v(u)) == null ? void 0 : h.toLowerCase(), p = (E = b(u)) == null ? void 0 : E.toLowerCase();
485
- return !(o && l !== o || i && !(f != null && f.includes(i)) || s && !(p != null && p.includes(s)));
918
+ const o = (a = w(e.role)) == null ? void 0 : a.toLowerCase(), i = (u = w(e.name)) == null ? void 0 : u.toLowerCase(), r = (d = w(e.text)) == null ? void 0 : d.toLowerCase();
919
+ return !o && !i && !r ? null : et(t).find((l) => {
920
+ var y, p, E;
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)));
486
923
  }) ?? null;
487
924
  }
488
- function At(t) {
925
+ function fe(t) {
489
926
  return [
490
- v(t),
491
- H(t),
492
- Z(t),
493
- b(t),
494
- F(t)
927
+ x(t),
928
+ X(t),
929
+ pt(t),
930
+ m(t),
931
+ Z(t)
495
932
  ].filter((e) => !!e).join(" ").toLowerCase();
496
933
  }
497
- function Nt(t, e) {
934
+ function he(t, e) {
498
935
  const n = e.trim().toLowerCase();
499
936
  let o = t, i = 0;
500
937
  for (; o && i < 5; ) {
501
- const s = o.tagName.toLowerCase();
502
- if (s === "body" || s === "html")
938
+ const r = o.tagName.toLowerCase();
939
+ if (r === "body" || r === "html")
503
940
  return !1;
504
- if (At(o).includes(n))
941
+ if (fe(o).includes(n))
505
942
  return !0;
506
943
  o = o.parentElement, i += 1;
507
944
  }
508
945
  return !1;
509
946
  }
510
- function Rt(t) {
947
+ function pe(t) {
511
948
  if (!t || typeof t != "object" || Array.isArray(t))
512
949
  return;
513
950
  const e = t;
@@ -518,70 +955,70 @@ function Rt(t) {
518
955
  value: e.value
519
956
  };
520
957
  }
521
- function Pt(t, e) {
958
+ function ge(t, e) {
522
959
  const n = e.trim().toLowerCase();
523
960
  return Array.from(t.querySelectorAll("input,textarea,select")).find(
524
961
  (o) => [
525
- H(o),
526
- v(o),
962
+ X(o),
963
+ x(o),
527
964
  o.getAttribute("name") ?? void 0,
528
965
  o.getAttribute("placeholder") ?? void 0,
529
- ...C(o)
966
+ ...P(o)
530
967
  ].some(
531
- (s) => s == null ? void 0 : s.trim().toLowerCase().includes(n)
968
+ (r) => r == null ? void 0 : r.trim().toLowerCase().includes(n)
532
969
  )
533
970
  );
534
971
  }
535
- function Ht(t, e) {
972
+ function me(t, e) {
536
973
  if (!e)
537
974
  return;
538
- const n = Pt(t, e.field), o = n ? F(n) ?? "" : void 0;
975
+ const n = ge(t, e.field), o = n ? Z(n) ?? "" : void 0;
539
976
  return {
540
977
  ...e,
541
978
  ok: typeof o == "string" && o.toLowerCase().includes(e.value.toLowerCase()),
542
979
  actual: o,
543
- matchedField: n ? V(n) : void 0
980
+ matchedField: n ? _(n) : void 0
544
981
  };
545
982
  }
546
- function $(t) {
983
+ function et(t) {
547
984
  const e = t instanceof Element ? t.ownerDocument : T(t), n = t instanceof Document ? t.body ?? t.documentElement : t;
548
985
  if (!n)
549
986
  return [];
550
- const o = [], i = (s) => {
551
- const r = e.createTreeWalker(s, NodeFilter.SHOW_ELEMENT);
552
- let a = r.nextNode();
987
+ const o = [], i = (r) => {
988
+ const s = e.createTreeWalker(r, NodeFilter.SHOW_ELEMENT);
989
+ let a = s.nextNode();
553
990
  for (; a; ) {
554
- const c = a;
555
- et(c) && o.push(c);
556
- const d = c.shadowRoot;
557
- if (d && i(d), c instanceof HTMLIFrameElement)
991
+ const u = a;
992
+ mt(u) && o.push(u);
993
+ const d = u.shadowRoot;
994
+ if (d && i(d), u instanceof HTMLIFrameElement)
558
995
  try {
559
- c.contentDocument && i(c.contentDocument);
996
+ u.contentDocument && i(u.contentDocument);
560
997
  } catch {
561
998
  }
562
- if (o.length >= X)
999
+ if (o.length >= it)
563
1000
  return;
564
- a = r.nextNode();
1001
+ a = s.nextNode();
565
1002
  }
566
1003
  };
567
- return i(n), o.slice(0, X);
1004
+ return i(n), o.slice(0, it);
568
1005
  }
569
- function Ot(t, e) {
1006
+ function ye(t, e) {
570
1007
  var i;
571
1008
  const n = Object.getPrototypeOf(t), o = Object.getOwnPropertyDescriptor(n, "value");
572
1009
  (i = o == null ? void 0 : o.set) == null || i.call(t, e);
573
1010
  }
574
- function I(t) {
1011
+ function j(t) {
575
1012
  t.dispatchEvent(new Event("input", { bubbles: !0 })), t.dispatchEvent(new Event("change", { bubbles: !0 }));
576
1013
  }
577
- function M(t) {
1014
+ function L(t) {
578
1015
  var e, n;
579
1016
  (t instanceof HTMLElement || t instanceof SVGElement) && ((e = t.scrollIntoView) == null || e.call(t, { block: "center", inline: "center" })), t instanceof HTMLElement && ((n = t.focus) == null || n.call(t));
580
1017
  }
581
- function L(t, e) {
1018
+ function R(t, e) {
582
1019
  return typeof PointerEvent == "function" ? new PointerEvent(t, e) : new MouseEvent(t.replace("pointer", "mouse"), e);
583
1020
  }
584
- class It {
1021
+ class be {
585
1022
  constructor(e = {}) {
586
1023
  this.options = e, this.refs = /* @__PURE__ */ new Map(), this.nextRef = 1;
587
1024
  }
@@ -611,17 +1048,19 @@ class It {
611
1048
  return this.pointer(n);
612
1049
  case "host_page_screenshot":
613
1050
  return this.screenshot();
1051
+ case "host_page_read":
1052
+ return this.read(n);
614
1053
  case "host_page_wait_for":
615
1054
  return this.waitFor(n);
616
1055
  }
617
1056
  }
618
1057
  snapshot() {
619
- var s, r;
1058
+ var r, s;
620
1059
  this.refs.clear(), this.nextRef = 1;
621
- const e = this.getRoot(), n = T(e), o = N(e), i = $(e).map(
1060
+ const e = this.getRoot(), n = T(e), o = V(e), i = et(e).map(
622
1061
  (a) => this.snapshotElement(a)
623
1062
  );
624
- return {
1063
+ return this.readableContent = ot(e), {
625
1064
  url: o.location.href,
626
1065
  title: n.title,
627
1066
  capabilities: {
@@ -644,7 +1083,7 @@ class It {
644
1083
  readyState: n.readyState,
645
1084
  visibilityState: n.visibilityState,
646
1085
  focusedElement: n.activeElement && n.activeElement !== n.body ? this.snapshotElementWithoutRef(n.activeElement) : void 0,
647
- selection: ((r = (s = n.getSelection) == null ? void 0 : s.call(n)) == null ? void 0 : r.toString()) || void 0
1086
+ selection: ((s = (r = n.getSelection) == null ? void 0 : r.call(n)) == null ? void 0 : s.toString()) || void 0
648
1087
  },
649
1088
  navigation: this.getNavigationState(o),
650
1089
  frames: this.getFrameState(n),
@@ -657,15 +1096,21 @@ class It {
657
1096
  checked: a.checked,
658
1097
  focused: n.activeElement === this.refs.get(a.ref)
659
1098
  })),
1099
+ readableContent: Nt(
1100
+ this.readableContent
1101
+ ),
660
1102
  elements: i
661
1103
  };
662
1104
  }
663
1105
  getRoot() {
664
1106
  return this.options.root ?? document;
665
1107
  }
1108
+ invalidateReadableContent() {
1109
+ this.readableContent = void 0;
1110
+ }
666
1111
  getNavigationState(e) {
667
- var o, i, s;
668
- const n = (s = (i = (o = e.performance) == null ? void 0 : o.getEntriesByType) == null ? void 0 : i.call(o, "navigation")) == null ? void 0 : s[0];
1112
+ var o, i, r;
1113
+ const n = (r = (i = (o = e.performance) == null ? void 0 : o.getEntriesByType) == null ? void 0 : i.call(o, "navigation")) == null ? void 0 : r[0];
669
1114
  if (!(typeof PerformanceNavigationTiming != "function" || !(n instanceof PerformanceNavigationTiming)))
670
1115
  return {
671
1116
  type: n.type,
@@ -676,12 +1121,12 @@ class It {
676
1121
  }
677
1122
  getFrameState(e) {
678
1123
  return Array.from(e.querySelectorAll("iframe")).map((n) => {
679
- var i, s;
680
- const o = A(n);
1124
+ var i, r;
1125
+ const o = N(n);
681
1126
  try {
682
1127
  return {
683
1128
  url: (i = n.contentWindow) == null ? void 0 : i.location.href,
684
- title: (s = n.contentDocument) == null ? void 0 : s.title,
1129
+ title: (r = n.contentDocument) == null ? void 0 : r.title,
685
1130
  sameOrigin: !0,
686
1131
  rect: o
687
1132
  };
@@ -706,89 +1151,126 @@ class It {
706
1151
  return {
707
1152
  ref: n,
708
1153
  tag: e.tagName.toLowerCase(),
709
- role: S(e),
710
- name: v(e),
711
- label: H(e),
712
- groupLabel: Z(e),
713
- text: b(e),
714
- nearbyText: C(e),
715
- testId: mt(e),
716
- value: F(e),
717
- selectedLabel: Et(e),
718
- options: yt(e),
1154
+ role: M(e),
1155
+ name: x(e),
1156
+ label: X(e),
1157
+ groupLabel: pt(e),
1158
+ text: m(e),
1159
+ nearbyText: P(e),
1160
+ testId: ee(e),
1161
+ value: Z(e),
1162
+ selectedLabel: te(e),
1163
+ options: Zt(e),
719
1164
  placeholder: o,
720
- selector: q(e),
721
- disabled: tt(e),
1165
+ selector: Y(e),
1166
+ disabled: gt(e),
722
1167
  enabled: i.enabled,
723
- checked: wt(e),
1168
+ checked: ne(e),
724
1169
  visible: i.visible,
725
1170
  actionable: i.actionable,
726
- rect: A(e),
1171
+ receivesEvents: i.receivesEvents,
1172
+ occludedBy: i.occludedBy ? _(i.occludedBy) : void 0,
1173
+ safeClickPoints: i.safeClickPoints,
1174
+ rect: N(e),
727
1175
  center: i.center,
728
- hitTarget: i.hitTarget ? V(i.hitTarget) : void 0,
729
- hitStack: i.hitStack.slice(0, 5).map(V)
1176
+ hitTarget: i.hitTarget ? _(i.hitTarget) : void 0,
1177
+ hitStack: i.hitStack.slice(0, 5).map(_)
730
1178
  };
731
1179
  }
732
1180
  resolveElement(e) {
733
- const n = x(e.ref) ?? x(e.axRef);
1181
+ const n = w(e.ref) ?? w(e.axRef);
734
1182
  if (n) {
735
- const s = this.refs.get(n);
736
- if (!s)
1183
+ const r = this.refs.get(n);
1184
+ if (!r)
737
1185
  throw new Error(`Unknown element ref: ${n}. Take a new snapshot.`);
738
- return s;
1186
+ return r;
739
1187
  }
740
- const o = x(e.selector);
1188
+ const o = w(e.selector);
741
1189
  if (o) {
742
- const s = this.getRoot().querySelector(o);
743
- if (!s)
1190
+ const r = this.getRoot().querySelector(o);
1191
+ if (!r)
744
1192
  throw new Error(`No element matches selector: ${o}.`);
745
- return s;
1193
+ return r;
746
1194
  }
747
- const i = Ct(this.getRoot(), e);
1195
+ const i = de(this.getRoot(), e);
748
1196
  if (i)
749
1197
  return i;
750
1198
  if (typeof e.x < "u" || typeof e.y < "u") {
751
- const s = U(this.getRoot(), e), r = T(this.getRoot()).elementFromPoint(
752
- s.x,
753
- s.y
1199
+ const r = rt(this.getRoot(), e), s = T(this.getRoot()).elementFromPoint(
1200
+ r.x,
1201
+ r.y
754
1202
  );
755
- if (!r)
756
- throw new Error(`No element found at (${s.x}, ${s.y}).`);
757
- return r;
1203
+ if (!s)
1204
+ throw new Error(`No element found at (${r.x}, ${r.y}).`);
1205
+ return s;
758
1206
  }
759
1207
  throw new Error(
760
1208
  "Expected one of ref, selector, role/name/text/testId, or x/y."
761
1209
  );
762
1210
  }
763
1211
  async click(e) {
764
- const n = m(e), o = this.resolveElement(n), i = g(o), r = (i.actionable ? null : Lt(this.getRoot(), o)) ?? kt(o);
765
- if (!B(r) && !i.actionable && St(o.ownerDocument))
766
- throw new Error(
767
- `Target "${v(o) ?? o.tagName.toLowerCase()}" is not receiving pointer events. Take a screenshot or use host_page_pointer coordinates.`
1212
+ const n = b(e), o = this.resolveElement(n), i = g(o), s = (i.actionable ? null : ue(this.getRoot(), o)) ?? le(o);
1213
+ if (!K(s) && !i.actionable && ae(o.ownerDocument))
1214
+ throw new Xt(
1215
+ `Target "${x(o) ?? o.tagName.toLowerCase()}" is not receiving pointer events.`,
1216
+ {
1217
+ reason: "target_occluded",
1218
+ target: this.describeElement(o),
1219
+ occluder: i.occludedBy ? _(i.occludedBy) : void 0,
1220
+ targetVisible: i.visible,
1221
+ targetEnabled: i.enabled,
1222
+ targetReceivesEvents: i.receivesEvents,
1223
+ recoverable: !0,
1224
+ hitStack: i.hitStack.slice(0, 5).map(_),
1225
+ nextActions: [
1226
+ {
1227
+ tool: "host_page_press",
1228
+ args: { key: "Escape" }
1229
+ },
1230
+ {
1231
+ tool: "host_page_screenshot",
1232
+ args: {}
1233
+ }
1234
+ ]
1235
+ }
768
1236
  );
769
- M(r);
770
- const c = B(r), d = g(r), u = g(o), l = c ? Mt(r, c) : d.center ?? i.center;
771
- return l && await this.showVisualEffect({
1237
+ L(s);
1238
+ const u = K(s), d = g(s), l = g(o), c = u ? Et(s, u) : d.center ?? i.center;
1239
+ return c && await this.showVisualEffect({
772
1240
  type: "click",
773
- point: l,
1241
+ point: c,
774
1242
  anchor: "target",
775
- target: r,
1243
+ target: s,
776
1244
  requested: o
777
- }), r instanceof HTMLElement ? r.click() : r.dispatchEvent(new MouseEvent("click", { bubbles: !0 })), {
778
- clicked: this.describeElement(r),
1245
+ }), s instanceof HTMLElement ? s.click() : s.dispatchEvent(new MouseEvent("click", { bubbles: !0 })), this.invalidateReadableContent(), {
1246
+ clicked: this.describeElement(s),
779
1247
  requested: this.describeElement(o),
780
- strategy: r === o ? "dom" : "semantic_visible_fallback",
781
- point: l,
1248
+ strategy: s === o ? "dom" : "semantic_visible_fallback",
1249
+ point: c,
782
1250
  actionability: {
783
- visible: u.visible,
784
- enabled: u.enabled,
785
- receivesEvents: u.receivesEvents
1251
+ visible: l.visible,
1252
+ enabled: l.enabled,
1253
+ receivesEvents: l.receivesEvents,
1254
+ occludedBy: l.occludedBy ? _(l.occludedBy) : void 0,
1255
+ safeClickPoints: l.safeClickPoints
786
1256
  }
787
1257
  };
788
1258
  }
1259
+ read(e) {
1260
+ const n = b(e), o = this.getRoot(), i = this.readableContent ?? ot(o);
1261
+ this.readableContent = i;
1262
+ const r = {
1263
+ blockId: w(n.blockId),
1264
+ query: w(n.query),
1265
+ page: B(n.page),
1266
+ pageSize: B(n.pageSize),
1267
+ maxChars: B(n.maxChars)
1268
+ };
1269
+ return qt(i, r);
1270
+ }
789
1271
  async fill(e) {
790
- const n = m(e), o = O(n.value, "value"), i = this.resolveElement(n);
791
- if (M(i), i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement)
1272
+ const n = b(e), o = z(n.value, "value"), i = this.resolveElement(n);
1273
+ if (L(i), i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement)
792
1274
  return await this.showVisualEffect({
793
1275
  type: "fill",
794
1276
  target: i,
@@ -796,7 +1278,7 @@ class It {
796
1278
  value: o,
797
1279
  anchor: "target",
798
1280
  point: g(i).center
799
- }), Ot(i, o), I(i), { filled: this.describeElement(i), value: o };
1281
+ }), ye(i, o), j(i), this.invalidateReadableContent(), { filled: this.describeElement(i), value: o };
800
1282
  if (i instanceof HTMLElement && i.isContentEditable)
801
1283
  return await this.showVisualEffect({
802
1284
  type: "fill",
@@ -805,14 +1287,14 @@ class It {
805
1287
  value: o,
806
1288
  anchor: "target",
807
1289
  point: g(i).center
808
- }), i.textContent = o, I(i), { filled: this.describeElement(i), value: o };
1290
+ }), i.textContent = o, j(i), this.invalidateReadableContent(), { filled: this.describeElement(i), value: o };
809
1291
  throw new Error("Target element cannot be filled.");
810
1292
  }
811
1293
  async press(e) {
812
- const n = m(e), o = O(n.key, "key"), i = n.ref || n.selector || n.x !== void 0 && n.y !== void 0 ? this.resolveElement(n) : T(this.getRoot()).activeElement ?? T(this.getRoot()).body;
1294
+ const n = b(e), o = z(n.key, "key"), i = n.ref || n.selector || n.x !== void 0 && n.y !== void 0 ? this.resolveElement(n) : T(this.getRoot()).activeElement ?? T(this.getRoot()).body;
813
1295
  if (!i)
814
1296
  throw new Error("No target element is available for key press.");
815
- M(i), await this.showVisualEffect({
1297
+ L(i), await this.showVisualEffect({
816
1298
  type: "press",
817
1299
  target: i,
818
1300
  requested: i,
@@ -820,15 +1302,15 @@ class It {
820
1302
  anchor: "target",
821
1303
  point: g(i).center
822
1304
  });
823
- const s = { key: o, bubbles: !0, cancelable: !0 };
824
- return i.dispatchEvent(new KeyboardEvent("keydown", s)), o.length === 1 && i.dispatchEvent(new KeyboardEvent("keypress", s)), i.dispatchEvent(new KeyboardEvent("keyup", s)), { pressed: o, target: this.describeElement(i) };
1305
+ const r = { key: o, bubbles: !0, cancelable: !0 };
1306
+ 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) };
825
1307
  }
826
1308
  async select(e) {
827
- const n = m(e), o = ft(n.values ?? n.value), i = this.resolveElement(n);
1309
+ const n = b(e), o = Gt(n.values ?? n.value), i = this.resolveElement(n);
828
1310
  if (!(i instanceof HTMLSelectElement))
829
1311
  throw new Error("Target element is not a select.");
830
- M(i);
831
- const s = new Set(o);
1312
+ L(i);
1313
+ const r = new Set(o);
832
1314
  await this.showVisualEffect({
833
1315
  type: "select",
834
1316
  target: i,
@@ -837,21 +1319,21 @@ class It {
837
1319
  anchor: "target",
838
1320
  point: g(i).center
839
1321
  });
840
- for (const r of Array.from(i.options))
841
- r.selected = s.has(r.value);
842
- return I(i), {
1322
+ for (const s of Array.from(i.options))
1323
+ s.selected = r.has(s.value);
1324
+ return j(i), this.invalidateReadableContent(), {
843
1325
  selected: Array.from(i.selectedOptions).map(
844
- (r) => r.value
1326
+ (s) => s.value
845
1327
  ),
846
1328
  target: this.describeElement(i)
847
1329
  };
848
1330
  }
849
1331
  async scroll(e) {
850
- var c, d, u, l;
851
- const n = m(e), o = n.x !== void 0 || n.y !== void 0 ? {
852
- x: k(n.x) ?? 0,
853
- y: k(n.y) ?? 0
854
- } : null, i = k(n.deltaX) ?? 0, s = k(n.deltaY) ?? 0, r = this.getRoot(), a = N(r);
1332
+ var u, d, l, c;
1333
+ const n = b(e), o = n.x !== void 0 || n.y !== void 0 ? {
1334
+ x: A(n.x) ?? 0,
1335
+ y: A(n.y) ?? 0
1336
+ } : null, i = A(n.deltaX) ?? 0, r = A(n.deltaY) ?? 0, s = this.getRoot(), a = V(s);
855
1337
  if (n.ref || n.selector || n.role || n.name || n.text || n.testId) {
856
1338
  const f = this.resolveElement(n);
857
1339
  if (!(f instanceof HTMLElement))
@@ -861,10 +1343,10 @@ class It {
861
1343
  target: f,
862
1344
  requested: f,
863
1345
  deltaX: i,
864
- deltaY: s,
1346
+ deltaY: r,
865
1347
  anchor: "target",
866
1348
  point: g(f).center
867
- }), o ? (c = f.scrollTo) == null || c.call(f, o.x, o.y) : (d = f.scrollBy) == null || d.call(f, i, s), {
1349
+ }), o ? (u = f.scrollTo) == null || u.call(f, o.x, o.y) : (d = f.scrollBy) == null || d.call(f, i, r), this.invalidateReadableContent(), {
868
1350
  scrolled: this.describeElement(f),
869
1351
  scroll: { x: f.scrollLeft, y: f.scrollTop }
870
1352
  };
@@ -872,23 +1354,23 @@ class It {
872
1354
  return await this.showVisualEffect({
873
1355
  type: "scroll",
874
1356
  deltaX: i,
875
- deltaY: s,
1357
+ deltaY: r,
876
1358
  point: {
877
1359
  x: a.innerWidth / 2,
878
1360
  y: a.innerHeight / 2
879
1361
  }
880
- }), o ? (u = a.scrollTo) == null || u.call(a, o.x, o.y) : (l = a.scrollBy) == null || l.call(a, i, s), { scroll: { x: a.scrollX, y: a.scrollY } };
1362
+ }), o ? (l = a.scrollTo) == null || l.call(a, o.x, o.y) : (c = a.scrollBy) == null || c.call(a, i, r), this.invalidateReadableContent(), { scroll: { x: a.scrollX, y: a.scrollY } };
881
1363
  }
882
1364
  navigate(e) {
883
1365
  if (this.options.allowNavigation === !1)
884
1366
  throw new Error("Navigation is disabled for host page automation.");
885
- const n = m(e), o = this.getRoot(), i = N(o), s = O(n.url, "url"), r = new URL(s, i.location.href);
886
- if (r.protocol !== "http:" && r.protocol !== "https:")
1367
+ const n = b(e), o = this.getRoot(), i = V(o), r = z(n.url, "url"), s = new URL(r, i.location.href);
1368
+ if (s.protocol !== "http:" && s.protocol !== "https:")
887
1369
  throw new Error("Navigation only supports HTTP(S) URLs.");
888
- return this.refs.clear(), i.location.assign(r.toString()), { navigated: r.toString() };
1370
+ return this.refs.clear(), this.invalidateReadableContent(), i.location.assign(s.toString()), { navigated: s.toString() };
889
1371
  }
890
1372
  async hover(e) {
891
- const n = m(e), o = this.resolveElement(n), i = g(o).center;
1373
+ const n = b(e), o = this.resolveElement(n), i = g(o).center;
892
1374
  return await this.showVisualEffect({
893
1375
  type: "hover",
894
1376
  target: o,
@@ -912,8 +1394,8 @@ class It {
912
1394
  ), { hovered: this.describeElement(o), point: i };
913
1395
  }
914
1396
  async focus(e) {
915
- const n = m(e), o = this.resolveElement(n);
916
- return M(o), await this.showVisualEffect({
1397
+ const n = b(e), o = this.resolveElement(n);
1398
+ return L(o), await this.showVisualEffect({
917
1399
  type: "focus",
918
1400
  target: o,
919
1401
  requested: o,
@@ -922,61 +1404,61 @@ class It {
922
1404
  }), { focused: this.describeElement(o) };
923
1405
  }
924
1406
  async pointer(e) {
925
- const n = m(e), o = Y(n.action, ["move", "down", "up", "click"]) ?? "click", i = dt(n.button) ?? 0, s = typeof n.x < "u" || typeof n.y < "u", r = x(n.targetText);
926
- if (o === "click" && s && !r)
1407
+ const n = b(e), o = at(n.action, ["move", "down", "up", "click"]) ?? "click", i = B(n.button) ?? 0, r = typeof n.x < "u" || typeof n.y < "u", s = w(n.targetText);
1408
+ if (o === "click" && r && !s)
927
1409
  throw new Error(
928
1410
  "Pointer coordinate clicks require targetText to avoid unintended navigation."
929
1411
  );
930
- const a = n.ref || n.selector || n.role || n.name || n.text || n.testId ? this.resolveElement(n) : null, c = a ? g(a).center : U(this.getRoot(), n);
931
- if (!c)
1412
+ const a = n.ref || n.selector || n.role || n.name || n.text || n.testId ? this.resolveElement(n) : null, u = a ? g(a).center : rt(this.getRoot(), n);
1413
+ if (!u)
932
1414
  throw new Error("Target element has no clickable point.");
933
- const d = a ?? T(this.getRoot()).elementFromPoint(c.x, c.y);
1415
+ const d = a ?? T(this.getRoot()).elementFromPoint(u.x, u.y);
934
1416
  if (!d)
935
- throw new Error(`No element found at (${c.x}, ${c.y}).`);
936
- const u = r ? Nt(d, r) : void 0;
937
- if (r && !u)
1417
+ throw new Error(`No element found at (${u.x}, ${u.y}).`);
1418
+ const l = s ? he(d, s) : void 0;
1419
+ if (s && !l)
938
1420
  throw new Error(
939
- `Pointer target text mismatch: expected hit target to contain "${r}".`
1421
+ `Pointer target text mismatch: expected hit target to contain "${s}".`
940
1422
  );
941
- const l = {
1423
+ const c = {
942
1424
  bubbles: !0,
943
1425
  cancelable: !0,
944
- clientX: c.x,
945
- clientY: c.y,
1426
+ clientX: u.x,
1427
+ clientY: u.y,
946
1428
  button: i
947
1429
  };
948
1430
  return o === "move" ? (await this.showVisualEffect({
949
1431
  type: "pointer",
950
1432
  action: o,
951
1433
  anchor: "point",
952
- point: c,
1434
+ point: u,
953
1435
  target: d
954
- }), d.dispatchEvent(L("pointermove", l)), d.dispatchEvent(new MouseEvent("mousemove", l))) : o === "down" ? (await this.showVisualEffect({
1436
+ }), d.dispatchEvent(R("pointermove", c)), d.dispatchEvent(new MouseEvent("mousemove", c))) : o === "down" ? (await this.showVisualEffect({
955
1437
  type: "pointer",
956
1438
  action: o,
957
1439
  anchor: "point",
958
- point: c,
1440
+ point: u,
959
1441
  target: d
960
- }), d.dispatchEvent(L("pointerdown", l)), d.dispatchEvent(new MouseEvent("mousedown", l))) : o === "up" ? (await this.showVisualEffect({
1442
+ }), d.dispatchEvent(R("pointerdown", c)), d.dispatchEvent(new MouseEvent("mousedown", c))) : o === "up" ? (await this.showVisualEffect({
961
1443
  type: "pointer",
962
1444
  action: o,
963
1445
  anchor: "point",
964
- point: c,
1446
+ point: u,
965
1447
  target: d
966
- }), d.dispatchEvent(L("pointerup", l)), d.dispatchEvent(new MouseEvent("mouseup", l))) : (await this.showVisualEffect({
1448
+ }), d.dispatchEvent(R("pointerup", c)), d.dispatchEvent(new MouseEvent("mouseup", c))) : (await this.showVisualEffect({
967
1449
  type: "click",
968
1450
  anchor: "point",
969
- point: c,
1451
+ point: u,
970
1452
  target: d
971
- }), d.dispatchEvent(L("pointerdown", l)), d.dispatchEvent(new MouseEvent("mousedown", l)), d.dispatchEvent(L("pointerup", l)), d.dispatchEvent(new MouseEvent("mouseup", l)), d instanceof HTMLElement ? d.click() : d.dispatchEvent(new MouseEvent("click", l))), {
1453
+ }), d.dispatchEvent(R("pointerdown", c)), d.dispatchEvent(new MouseEvent("mousedown", c)), d.dispatchEvent(R("pointerup", c)), d.dispatchEvent(new MouseEvent("mouseup", c)), d instanceof HTMLElement ? d.click() : d.dispatchEvent(new MouseEvent("click", c)), this.invalidateReadableContent()), {
972
1454
  pointer: o,
973
- point: c,
1455
+ point: u,
974
1456
  coordinateSpace: "viewport-css-px",
975
1457
  target: this.describeElement(d),
976
- targetTextMatched: u,
977
- expectedAfterClick: o === "click" ? Ht(
1458
+ targetTextMatched: l,
1459
+ expectedAfterClick: o === "click" ? me(
978
1460
  this.getRoot(),
979
- Rt(n.expectedAfterClick)
1461
+ pe(n.expectedAfterClick)
980
1462
  ) : void 0
981
1463
  };
982
1464
  }
@@ -986,14 +1468,14 @@ class It {
986
1468
  );
987
1469
  }
988
1470
  async showVisualEffect(e) {
989
- var n, o, i, s;
1471
+ var n, o, i, r;
990
1472
  try {
991
1473
  await ((o = (n = this.options).showVisualEffect) == null ? void 0 : o.call(n, e));
992
1474
  } catch {
993
1475
  }
994
1476
  if (!(e.type !== "click" || !e.point || !e.target || this.options.showVisualEffect))
995
1477
  try {
996
- await ((s = (i = this.options).showClickEffect) == null ? void 0 : s.call(i, {
1478
+ await ((r = (i = this.options).showClickEffect) == null ? void 0 : r.call(i, {
997
1479
  point: e.point,
998
1480
  target: e.target,
999
1481
  requested: e.requested
@@ -1002,15 +1484,15 @@ class It {
1002
1484
  }
1003
1485
  }
1004
1486
  async waitFor(e) {
1005
- const n = m(e), o = Y(n.state, [
1487
+ const n = b(e), o = at(n.state, [
1006
1488
  "attached",
1007
1489
  "visible",
1008
1490
  "hidden",
1009
1491
  "detached"
1010
- ]) ?? "visible", i = k(n.timeoutSeconds), s = Math.min(
1011
- ct,
1012
- Math.max(0, (i ?? at / 1e3) * 1e3)
1013
- ), r = Date.now(), a = this.tryResolveElement(n);
1492
+ ]) ?? "visible", i = A(n.timeoutSeconds), r = Math.min(
1493
+ $t,
1494
+ Math.max(0, (i ?? jt / 1e3) * 1e3)
1495
+ ), s = Date.now(), a = this.tryResolveElement(n);
1014
1496
  for (await this.showVisualEffect({
1015
1497
  type: "wait_for",
1016
1498
  state: o,
@@ -1018,15 +1500,15 @@ class It {
1018
1500
  requested: a ?? void 0,
1019
1501
  ...a ? { anchor: "target" } : {},
1020
1502
  point: a ? g(a).center : void 0
1021
- }); Date.now() - r <= s; ) {
1022
- const c = this.tryResolveElement(n);
1023
- if (o === "attached" ? !!c : o === "detached" ? !c : o === "hidden" ? !c || !_(c) : !!(c && _(c)))
1503
+ }); Date.now() - s <= r; ) {
1504
+ const u = this.tryResolveElement(n);
1505
+ if (o === "attached" ? !!u : o === "detached" ? !u : o === "hidden" ? !u || !S(u) : !!(u && S(u)))
1024
1506
  return {
1025
1507
  waitedFor: o,
1026
- elapsedMs: Date.now() - r,
1027
- target: c ? this.describeElement(c) : void 0
1508
+ elapsedMs: Date.now() - s,
1509
+ target: u ? this.describeElement(u) : void 0
1028
1510
  };
1029
- await new Promise((u) => setTimeout(u, 100));
1511
+ await new Promise((l) => setTimeout(l, 100));
1030
1512
  }
1031
1513
  throw new Error(`Timed out waiting for target to become ${o}.`);
1032
1514
  }
@@ -1040,52 +1522,59 @@ class It {
1040
1522
  describeElement(e) {
1041
1523
  return {
1042
1524
  tag: e.tagName.toLowerCase(),
1043
- role: S(e),
1044
- name: v(e),
1045
- selector: q(e)
1525
+ role: M(e),
1526
+ name: x(e),
1527
+ selector: Y(e)
1046
1528
  };
1047
1529
  }
1048
1530
  }
1049
- function Dt(t) {
1531
+ function Ee(t) {
1050
1532
  return typeof t == "object" && t !== null && !Array.isArray(t) ? t : {};
1051
1533
  }
1052
- function Vt(t) {
1534
+ function we(t) {
1053
1535
  return JSON.stringify(t);
1054
1536
  }
1055
- function D(t, e, n) {
1537
+ function $(t, e, n) {
1056
1538
  return {
1057
1539
  tool_call_id: t.tool_call_id ?? t.id,
1058
1540
  name: t.name,
1059
1541
  status: e,
1060
- content: Vt(n)
1542
+ content: we(n)
1061
1543
  };
1062
1544
  }
1063
- function qt(t) {
1545
+ function ve(t) {
1064
1546
  return t instanceof Error ? t.message : String(t);
1065
1547
  }
1066
- function jt(t = {}) {
1067
- const e = new It(t);
1548
+ function xe(t) {
1549
+ if (!t || typeof t != "object" || Array.isArray(t))
1550
+ return {};
1551
+ const e = Reflect.get(t, "details");
1552
+ return e && typeof e == "object" && !Array.isArray(e) ? e : {};
1553
+ }
1554
+ function Se(t = {}) {
1555
+ const e = new be(t);
1068
1556
  return async (n) => {
1069
- if (!lt(n.name))
1070
- return D(n, "error", {
1557
+ if (!Wt(n.name))
1558
+ return $(n, "error", {
1071
1559
  ok: !1,
1072
1560
  error: `Unknown host page automation tool: ${n.name}`
1073
1561
  });
1074
1562
  try {
1075
1563
  const o = await e.execute(
1076
1564
  n.name,
1077
- Dt(n.params)
1565
+ Ee(n.params)
1078
1566
  );
1079
- return D(n, "success", { ok: !0, result: o });
1567
+ return $(n, "success", { ok: !0, result: o });
1080
1568
  } catch (o) {
1081
- return D(n, "error", {
1569
+ return $(n, "error", {
1082
1570
  ok: !1,
1083
- error: qt(o)
1571
+ error: ve(o),
1572
+ ...xe(o)
1084
1573
  });
1085
1574
  }
1086
1575
  };
1087
1576
  }
1088
- const w = {
1577
+ const v = {
1089
1578
  ref: {
1090
1579
  type: ["string", "number"],
1091
1580
  description: "Element ref from host_page_snapshot."
@@ -1122,13 +1611,13 @@ const w = {
1122
1611
  type: "number",
1123
1612
  description: "Viewport y coordinate."
1124
1613
  }
1125
- }, Bt = {
1614
+ }, _e = {
1126
1615
  coordinateSpace: {
1127
1616
  type: "string",
1128
1617
  enum: ["viewport-css-px", "viewport_normalized"],
1129
1618
  description: "Coordinate space for x/y. Use viewport_normalized for screenshot-derived points."
1130
1619
  }
1131
- }, Ft = {
1620
+ }, Te = {
1132
1621
  type: "object",
1133
1622
  properties: {
1134
1623
  type: {
@@ -1146,7 +1635,7 @@ const w = {
1146
1635
  },
1147
1636
  required: ["type", "field", "value"],
1148
1637
  additionalProperties: !1
1149
- }, $t = {
1638
+ }, Ce = {
1150
1639
  host_page_snapshot: {
1151
1640
  type: "object",
1152
1641
  properties: {},
@@ -1155,14 +1644,14 @@ const w = {
1155
1644
  host_page_click: {
1156
1645
  type: "object",
1157
1646
  properties: {
1158
- ...w
1647
+ ...v
1159
1648
  },
1160
1649
  additionalProperties: !1
1161
1650
  },
1162
1651
  host_page_fill: {
1163
1652
  type: "object",
1164
1653
  properties: {
1165
- ...w,
1654
+ ...v,
1166
1655
  value: {
1167
1656
  type: "string",
1168
1657
  description: "Text value to set on the target field."
@@ -1174,7 +1663,7 @@ const w = {
1174
1663
  host_page_press: {
1175
1664
  type: "object",
1176
1665
  properties: {
1177
- ...w,
1666
+ ...v,
1178
1667
  key: {
1179
1668
  type: "string",
1180
1669
  description: "Keyboard key to press."
@@ -1186,7 +1675,7 @@ const w = {
1186
1675
  host_page_select: {
1187
1676
  type: "object",
1188
1677
  properties: {
1189
- ...w,
1678
+ ...v,
1190
1679
  value: {
1191
1680
  type: ["string", "array"],
1192
1681
  description: "Select option value or values.",
@@ -1203,7 +1692,7 @@ const w = {
1203
1692
  host_page_scroll: {
1204
1693
  type: "object",
1205
1694
  properties: {
1206
- ...w,
1695
+ ...v,
1207
1696
  deltaX: {
1208
1697
  type: "number",
1209
1698
  description: "Horizontal scroll delta."
@@ -1229,22 +1718,22 @@ const w = {
1229
1718
  host_page_hover: {
1230
1719
  type: "object",
1231
1720
  properties: {
1232
- ...w
1721
+ ...v
1233
1722
  },
1234
1723
  additionalProperties: !1
1235
1724
  },
1236
1725
  host_page_focus: {
1237
1726
  type: "object",
1238
1727
  properties: {
1239
- ...w
1728
+ ...v
1240
1729
  },
1241
1730
  additionalProperties: !1
1242
1731
  },
1243
1732
  host_page_pointer: {
1244
1733
  type: "object",
1245
1734
  properties: {
1246
- ...w,
1247
- ...Bt,
1735
+ ...v,
1736
+ ..._e,
1248
1737
  action: {
1249
1738
  type: "string",
1250
1739
  enum: ["move", "down", "up", "click"],
@@ -1262,7 +1751,7 @@ const w = {
1262
1751
  type: "string",
1263
1752
  description: "Required for explicit coordinate clicks. The actual hit target or near ancestor must contain this text."
1264
1753
  },
1265
- expectedAfterClick: Ft
1754
+ expectedAfterClick: Te
1266
1755
  },
1267
1756
  additionalProperties: !1
1268
1757
  },
@@ -1281,10 +1770,46 @@ const w = {
1281
1770
  },
1282
1771
  additionalProperties: !1
1283
1772
  },
1773
+ host_page_read: {
1774
+ type: "object",
1775
+ properties: {
1776
+ blockId: {
1777
+ type: "string",
1778
+ description: "Readable content block id from host_page_snapshot."
1779
+ },
1780
+ scope: {
1781
+ type: "string",
1782
+ enum: ["visible"],
1783
+ description: "Visible content scope. Use blockId when a specific readable block is known."
1784
+ },
1785
+ query: {
1786
+ type: "string",
1787
+ description: "Optional text query for selecting relevant readable blocks."
1788
+ },
1789
+ page: {
1790
+ type: "number",
1791
+ minimum: 1,
1792
+ description: "1-based page for long block content."
1793
+ },
1794
+ pageSize: {
1795
+ type: "number",
1796
+ minimum: 1,
1797
+ maximum: 100,
1798
+ description: "Items, fields, rows, or blocks to return per page."
1799
+ },
1800
+ maxChars: {
1801
+ type: "number",
1802
+ minimum: 500,
1803
+ maximum: 12e3,
1804
+ description: "Maximum characters to return."
1805
+ }
1806
+ },
1807
+ additionalProperties: !1
1808
+ },
1284
1809
  host_page_wait_for: {
1285
1810
  type: "object",
1286
1811
  properties: {
1287
- ...w,
1812
+ ...v,
1288
1813
  state: {
1289
1814
  type: "string",
1290
1815
  enum: ["attached", "visible", "hidden", "detached"],
@@ -1299,9 +1824,9 @@ const w = {
1299
1824
  }
1300
1825
  };
1301
1826
  export {
1302
- it as HOST_PAGE_AUTOMATION_TOOL_NAMES,
1303
- $t as HOST_PAGE_AUTOMATION_TOOL_SCHEMAS,
1304
- It as HostPageAutomationExecutor,
1305
- jt as createHostPageAutomationClientToolHandler,
1306
- lt as isHostPageAutomationToolName
1827
+ vt as HOST_PAGE_AUTOMATION_TOOL_NAMES,
1828
+ Ce as HOST_PAGE_AUTOMATION_TOOL_SCHEMAS,
1829
+ be as HostPageAutomationExecutor,
1830
+ Se as createHostPageAutomationClientToolHandler,
1831
+ Wt as isHostPageAutomationToolName
1307
1832
  };