@opentiny/next-sdk 0.4.2 → 0.4.3

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 (88) hide show
  1. package/dist/{SimulatorMask-BHVXyogh-CARX3Rff.js → SimulatorMask-BHVXyogh-CKmEDsYG.js} +1 -1
  2. package/dist/{index-R_HIbfUX.js → index-CHMa2zG4.js} +1065 -1042
  3. package/dist/index.js +1 -1
  4. package/dist/page-tools/a11y/config.d.ts +6 -3
  5. package/dist/page-tools/a11y/constants.d.ts +20 -0
  6. package/dist/page-tools/a11y/utils.d.ts +14 -0
  7. package/dist/page-tools/constants.d.ts +4 -2
  8. package/dist/page-tools/context.d.ts +2 -0
  9. package/dist/page-tools/handlers/hover.d.ts +9 -0
  10. package/dist/page-tools/schema.d.ts +3 -3
  11. package/dist/page-tools/utils/dom.d.ts +8 -2
  12. package/dist/runtime.js +19 -172
  13. package/package.json +6 -1
  14. package/WebMcpClient.ts +0 -505
  15. package/WebMcpServer.ts +0 -447
  16. package/agent/AgentModelProvider.ts +0 -932
  17. package/agent/type.ts +0 -91
  18. package/agent/utils/generateReActPrompt.ts +0 -71
  19. package/agent/utils/getAISDKTools.ts +0 -34
  20. package/agent/utils/getBuiltinMcpTools.ts +0 -86
  21. package/agent/utils/parseReActAction.ts +0 -34
  22. package/core.ts +0 -26
  23. package/index.ts +0 -91
  24. package/page-tools/a11y/build.ts +0 -74
  25. package/page-tools/a11y/config.ts +0 -465
  26. package/page-tools/a11y/constants.ts +0 -131
  27. package/page-tools/a11y/search.ts +0 -127
  28. package/page-tools/a11y/types.ts +0 -105
  29. package/page-tools/a11y/utils.ts +0 -239
  30. package/page-tools/a11y/vnode.ts +0 -439
  31. package/page-tools/a11y-tree.ts +0 -14
  32. package/page-tools/bridge.ts +0 -722
  33. package/page-tools/configs/console-cloud.ts +0 -172
  34. package/page-tools/constants.ts +0 -12
  35. package/page-tools/context.ts +0 -50
  36. package/page-tools/effects.ts +0 -345
  37. package/page-tools/handlers/browserState.ts +0 -12
  38. package/page-tools/handlers/click.ts +0 -30
  39. package/page-tools/handlers/executeJavascript.ts +0 -22
  40. package/page-tools/handlers/fill.ts +0 -65
  41. package/page-tools/handlers/scroll.ts +0 -66
  42. package/page-tools/handlers/searchTree.ts +0 -27
  43. package/page-tools/handlers/select.ts +0 -39
  44. package/page-tools/initialize-builtin-WebMCP.ts +0 -20
  45. package/page-tools/page-agent-highlight/index.ts +0 -245
  46. package/page-tools/page-agent-mask/SimulatorMask.module.css +0 -14
  47. package/page-tools/page-agent-mask/SimulatorMask.ts +0 -299
  48. package/page-tools/page-agent-mask/checkDarkMode.ts +0 -181
  49. package/page-tools/page-agent-mask/cursor-border.svg +0 -3
  50. package/page-tools/page-agent-mask/cursor-fill.svg +0 -5
  51. package/page-tools/page-agent-mask/cursor.module.css +0 -70
  52. package/page-tools/page-agent-mask/hauwei.svg +0 -25
  53. package/page-tools/page-agent-prompt.md +0 -139
  54. package/page-tools/page-agent-tool-event.ts +0 -113
  55. package/page-tools/page-agent-tool.ts +0 -207
  56. package/page-tools/page-state-cache.ts +0 -78
  57. package/page-tools/schema.ts +0 -52
  58. package/page-tools/tool-config.ts +0 -100
  59. package/page-tools/utils/dom.ts +0 -158
  60. package/page-tools/utils/scroll.ts +0 -58
  61. package/remoter/QrCode.ts +0 -54
  62. package/remoter/createRemoter.ts +0 -957
  63. package/remoter/svgs/chat.svg +0 -43
  64. package/remoter/svgs/icon-copy.svg +0 -25
  65. package/remoter/svgs/link.svg +0 -28
  66. package/remoter/svgs/logo.svg +0 -45
  67. package/remoter/svgs/qrcode.svg +0 -35
  68. package/remoter/svgs/scan.svg +0 -21
  69. package/remoter/tooltips.ts +0 -260
  70. package/runtime.html +0 -39
  71. package/runtime.ts +0 -44
  72. package/script/utils.ts +0 -26
  73. package/skills/index.ts +0 -287
  74. package/test/page-tools/a11y/build.test.ts +0 -638
  75. package/test/page-tools/a11y/config.test.ts +0 -370
  76. package/test/page-tools/configs/console-cloud.test.ts +0 -168
  77. package/test/page-tools/page-agent-highlight.test.ts +0 -110
  78. package/test/page-tools/page-agent-tool-dispatch.test.ts +0 -208
  79. package/test/page-tools/page-agent-tool.test.ts +0 -102
  80. package/test/page-tools/tool-config.test.ts +0 -112
  81. package/test/page-tools/utils/dom.test.ts +0 -122
  82. package/tsconfig.json +0 -16
  83. package/utils/builtinProxy.ts +0 -144
  84. package/utils/env.ts +0 -13
  85. package/utils/uuid.ts +0 -10
  86. package/vite.config.runtime.ts +0 -22
  87. package/vite.config.ts +0 -63
  88. package/vitest.config.ts +0 -10
@@ -97,9 +97,9 @@ class Tooltip {
97
97
  this.applyStyle(this.calcStyle("top"));
98
98
  }
99
99
  calcStyle(e) {
100
- const n = this.el.getBoundingClientRect(), i = this.tip.getBoundingClientRect(), r = window.pageYOffset || document.documentElement.scrollTop, o = window.pageXOffset || document.documentElement.scrollLeft, a = 6, [s, c = "center"] = e.split("-");
100
+ const n = this.el.getBoundingClientRect(), i = this.tip.getBoundingClientRect(), r = window.pageYOffset || document.documentElement.scrollTop, o = window.pageXOffset || document.documentElement.scrollLeft, s = 6, [a, c = "center"] = e.split("-");
101
101
  let d = 0, u = 0;
102
- return s === "top" ? d = n.top + r - i.height - a : s === "bottom" ? d = n.bottom + r + a : s === "left" ? u = n.left + o - i.width - a : s === "right" && (u = n.right + o + a), (s === "top" || s === "bottom") && (c === "start" ? u = n.left + o : c === "end" ? u = n.right + o - i.width : u = (n.left + n.right) / 2 + o - i.width / 2), (s === "left" || s === "right") && (c === "start" ? d = n.top + r : c === "end" ? d = n.bottom + r - i.height : d = (n.top + n.bottom) / 2 + r - i.height / 2), { top: Math.round(d), left: Math.round(u) };
102
+ return a === "top" ? d = n.top + r - i.height - s : a === "bottom" ? d = n.bottom + r + s : a === "left" ? u = n.left + o - i.width - s : a === "right" && (u = n.right + o + s), (a === "top" || a === "bottom") && (c === "start" ? u = n.left + o : c === "end" ? u = n.right + o - i.width : u = (n.left + n.right) / 2 + o - i.width / 2), (a === "left" || a === "right") && (c === "start" ? d = n.top + r : c === "end" ? d = n.bottom + r - i.height : d = (n.top + n.bottom) / 2 + r - i.height / 2), { top: Math.round(d), left: Math.round(u) };
103
103
  }
104
104
  applyStyle({ top: e, left: n }) {
105
105
  Object.assign(this.tip.style, {
@@ -109,8 +109,8 @@ class Tooltip {
109
109
  });
110
110
  }
111
111
  checkViewport({ top: e, left: n }) {
112
- const r = window.innerWidth, o = window.innerHeight, a = this.tip.getBoundingClientRect();
113
- return n >= 5 && e >= 5 && n + a.width <= r - 5 && e + a.height <= o - 5;
112
+ const r = window.innerWidth, o = window.innerHeight, s = this.tip.getBoundingClientRect();
113
+ return n >= 5 && e >= 5 && n + s.width <= r - 5 && e + s.height <= o - 5;
114
114
  }
115
115
  placementList(e) {
116
116
  const n = {
@@ -330,8 +330,8 @@ class FloatingBlock {
330
330
  const n = e.target, i = n.closest(".tiny-remoter-copy-icon");
331
331
  if (i) {
332
332
  e.stopPropagation();
333
- const a = i.dataset.action;
334
- a && this.handleAction(a);
333
+ const s = i.dataset.action;
334
+ s && this.handleAction(s);
335
335
  return;
336
336
  }
337
337
  const o = n.closest(".tiny-remoter-dropdown-item")?.dataset.action;
@@ -880,14 +880,14 @@ async function parseSkillFrontMatter(t) {
880
880
  if (typeof t != "string" && typeof t != "function") return null;
881
881
  const n = (typeof t == "string" ? t : await t()).match(FRONT_MATTER_BLOCK_REG);
882
882
  if (!n?.[1]) return null;
883
- const i = n[1], r = i.match(/^name:\s*(.+)$/m), o = i.match(/^description:\s*(.+)$/m), a = r?.[1]?.trim(), s = o?.[1]?.trim();
884
- return a && s ? { name: a, description: s } : null;
883
+ const i = n[1], r = i.match(/^name:\s*(.+)$/m), o = i.match(/^description:\s*(.+)$/m), s = r?.[1]?.trim(), a = o?.[1]?.trim();
884
+ return s && a ? { name: s, description: a } : null;
885
885
  }
886
886
  async function normalizeSkillModuleKeys(t) {
887
887
  const e = {};
888
888
  for (const [n, i] of Object.entries(t)) {
889
- const r = n.replace(/\\/g, "/"), o = r.lastIndexOf("skills/"), a = o >= 0 ? r.slice(o + 7) : r, s = a.startsWith("./") ? a : `./${a}`, c = typeof i == "string" ? i : await i();
890
- e[s] = c;
889
+ const r = n.replace(/\\/g, "/"), o = r.lastIndexOf("skills/"), s = o >= 0 ? r.slice(o + 7) : r, a = s.startsWith("./") ? s : `./${s}`, c = typeof i == "string" ? i : await i();
890
+ e[a] = c;
891
891
  }
892
892
  return e;
893
893
  }
@@ -900,10 +900,10 @@ async function getSkillOverviews(t) {
900
900
  for (const r of n) {
901
901
  const o = e[r];
902
902
  if (!o) continue;
903
- const a = await parseSkillFrontMatter(o);
904
- a && i.push({
905
- name: a.name,
906
- description: a.description,
903
+ const s = await parseSkillFrontMatter(o);
904
+ s && i.push({
905
+ name: s.name,
906
+ description: s.description,
907
907
  path: r
908
908
  });
909
909
  }
@@ -920,17 +920,17 @@ ${t.map((n) => `- **${n.name}**: ${n.description}`).join(`
920
920
  async function getSkillMdContent(t, e) {
921
921
  const n = await normalizeSkillModuleKeys(t), i = n[e];
922
922
  if (i) return i;
923
- const r = e.replace(/^\.?\//, "/"), o = Object.keys(n).find((a) => a.endsWith(r));
923
+ const r = e.replace(/^\.?\//, "/"), o = Object.keys(n).find((s) => s.endsWith(r));
924
924
  return o ? n[o] : void 0;
925
925
  }
926
926
  async function getMainSkillPathByName(t, e) {
927
927
  const n = await normalizeSkillModuleKeys(t), i = await getMainSkillPaths(n), r = i.find((o) => o.startsWith(`./${e}/SKILL.md`));
928
928
  if (r) return r;
929
929
  for (const o of i) {
930
- const a = n[o];
931
- if (a) {
932
- const s = await parseSkillFrontMatter(a);
933
- if (s && s.name === e)
930
+ const s = n[o];
931
+ if (s) {
932
+ const a = await parseSkillFrontMatter(s);
933
+ if (a && a.name === e)
934
934
  return o;
935
935
  }
936
936
  }
@@ -952,34 +952,34 @@ function createSkillTools(t) {
952
952
  inputSchema: SKILL_INPUT_SCHEMA,
953
953
  execute: async (r) => {
954
954
  e || (n = await normalizeSkillModuleKeys(t), e = !0);
955
- const o = n, { skillName: a, path: s, currentPath: c } = r;
955
+ const o = n, { skillName: s, path: a, currentPath: c } = r;
956
956
  let d, u = "";
957
- if (s) {
958
- let p = ".";
957
+ if (a) {
958
+ let h = ".";
959
959
  if (c) {
960
- const y = c.lastIndexOf("/");
961
- y >= 0 && (p = c.slice(0, y));
960
+ const g = c.lastIndexOf("/");
961
+ g >= 0 && (h = c.slice(0, g));
962
962
  }
963
- const h = `http://localhost/${p}/`;
964
- if (u = "." + new URL(s, h).pathname, d = await getSkillMdContent(o, u), d === void 0 && (s.startsWith("./") || s.startsWith("../")) && c) {
965
- const y = c.split("/");
966
- if (y.length >= 2) {
967
- const C = `http://localhost/${y[1]}/`, m = "." + new URL(s, C).pathname;
968
- d = await getSkillMdContent(o, m), d && (u = m);
963
+ const p = `http://localhost/${h}/`;
964
+ if (u = "." + new URL(a, p).pathname, d = await getSkillMdContent(o, u), d === void 0 && (a.startsWith("./") || a.startsWith("../")) && c) {
965
+ const g = c.split("/");
966
+ if (g.length >= 2) {
967
+ const L = `http://localhost/${g[1]}/`, b = "." + new URL(a, L).pathname;
968
+ d = await getSkillMdContent(o, b), d && (u = b);
969
969
  }
970
970
  }
971
971
  if (d && !o[u]) {
972
- const y = u.replace(/^\.?\//, "/"), T = Object.keys(o).find((C) => C.endsWith(y));
973
- T && (u = T);
972
+ const g = u.replace(/^\.?\//, "/"), E = Object.keys(o).find((L) => L.endsWith(g));
973
+ E && (u = E);
974
974
  }
975
- } else if (a) {
976
- const p = await getMainSkillPathByName(o, a);
977
- p && (u = p, d = await getSkillMdContent(o, p));
975
+ } else if (s) {
976
+ const h = await getMainSkillPathByName(o, s);
977
+ h && (u = h, d = await getSkillMdContent(o, h));
978
978
  }
979
979
  return d === void 0 ? {
980
980
  error: "未找到对应技能文档",
981
- skillName: a,
982
- path: s,
981
+ skillName: s,
982
+ path: a,
983
983
  providedCurrentPath: c,
984
984
  attemptedPath: u
985
985
  } : { content: d, path: u };
@@ -1184,13 +1184,13 @@ function parseIntersectionDef(t, e) {
1184
1184
  if (isJsonSchema7AllOfType(o))
1185
1185
  r.push(...o.allOf), o.unevaluatedProperties === void 0 && (i = void 0);
1186
1186
  else {
1187
- let a = o;
1187
+ let s = o;
1188
1188
  if ("additionalProperties" in o && o.additionalProperties === !1) {
1189
- const { additionalProperties: s, ...c } = o;
1190
- a = c;
1189
+ const { additionalProperties: a, ...c } = o;
1190
+ s = c;
1191
1191
  } else
1192
1192
  i = void 0;
1193
- r.push(a);
1193
+ r.push(s);
1194
1194
  }
1195
1195
  }), r.length ? {
1196
1196
  allOf: r,
@@ -1402,16 +1402,16 @@ function stringifyRegExpWithFlags(t, e) {
1402
1402
  s: t.flags.includes("s")
1403
1403
  // `.` matches newlines
1404
1404
  }, i = n.i ? t.source.toLowerCase() : t.source;
1405
- let r = "", o = !1, a = !1, s = !1;
1405
+ let r = "", o = !1, s = !1, a = !1;
1406
1406
  for (let c = 0; c < i.length; c++) {
1407
1407
  if (o) {
1408
1408
  r += i[c], o = !1;
1409
1409
  continue;
1410
1410
  }
1411
1411
  if (n.i) {
1412
- if (a) {
1412
+ if (s) {
1413
1413
  if (i[c].match(/[a-z]/)) {
1414
- s ? (r += i[c], r += `${i[c - 2]}-${i[c]}`.toUpperCase(), s = !1) : i[c + 1] === "-" && i[c + 2]?.match(/[a-z]/) ? (r += i[c], s = !0) : r += `${i[c]}${i[c].toUpperCase()}`;
1414
+ a ? (r += i[c], r += `${i[c - 2]}-${i[c]}`.toUpperCase(), a = !1) : i[c + 1] === "-" && i[c + 2]?.match(/[a-z]/) ? (r += i[c], a = !0) : r += `${i[c]}${i[c].toUpperCase()}`;
1415
1415
  continue;
1416
1416
  }
1417
1417
  } else if (i[c].match(/[a-z]/)) {
@@ -1431,12 +1431,12 @@ function stringifyRegExpWithFlags(t, e) {
1431
1431
  }
1432
1432
  }
1433
1433
  if (n.s && i[c] === ".") {
1434
- r += a ? `${i[c]}\r
1434
+ r += s ? `${i[c]}\r
1435
1435
  ` : `[${i[c]}\r
1436
1436
  ]`;
1437
1437
  continue;
1438
1438
  }
1439
- r += i[c], i[c] === "\\" ? o = !0 : a && i[c] === "]" ? a = !1 : !a && i[c] === "[" && (a = !0);
1439
+ r += i[c], i[c] === "\\" ? o = !0 : s && i[c] === "]" ? s = !1 : !s && i[c] === "[" && (s = !0);
1440
1440
  }
1441
1441
  try {
1442
1442
  new RegExp(r);
@@ -1549,20 +1549,20 @@ function parseUnionDef(t, e) {
1549
1549
  const n = t.options instanceof Map ? Array.from(t.options.values()) : t.options;
1550
1550
  if (n.every((i) => i._def.typeName in primitiveMappings && (!i._def.checks || !i._def.checks.length))) {
1551
1551
  const i = n.reduce((r, o) => {
1552
- const a = primitiveMappings[o._def.typeName];
1553
- return a && !r.includes(a) ? [...r, a] : r;
1552
+ const s = primitiveMappings[o._def.typeName];
1553
+ return s && !r.includes(s) ? [...r, s] : r;
1554
1554
  }, []);
1555
1555
  return {
1556
1556
  type: i.length > 1 ? i : i[0]
1557
1557
  };
1558
1558
  } else if (n.every((i) => i._def.typeName === "ZodLiteral" && !i.description)) {
1559
1559
  const i = n.reduce((r, o) => {
1560
- const a = typeof o._def.value;
1561
- switch (a) {
1560
+ const s = typeof o._def.value;
1561
+ switch (s) {
1562
1562
  case "string":
1563
1563
  case "number":
1564
1564
  case "boolean":
1565
- return [...r, a];
1565
+ return [...r, s];
1566
1566
  case "bigint":
1567
1567
  return [...r, "integer"];
1568
1568
  case "object":
@@ -1576,10 +1576,10 @@ function parseUnionDef(t, e) {
1576
1576
  }
1577
1577
  }, []);
1578
1578
  if (i.length === n.length) {
1579
- const r = i.filter((o, a, s) => s.indexOf(o) === a);
1579
+ const r = i.filter((o, s, a) => a.indexOf(o) === s);
1580
1580
  return {
1581
1581
  type: r.length > 1 ? r : r[0],
1582
- enum: n.reduce((o, a) => o.includes(a._def.value) ? o : [...o, a._def.value], [])
1582
+ enum: n.reduce((o, s) => o.includes(s._def.value) ? o : [...o, s._def.value], [])
1583
1583
  };
1584
1584
  }
1585
1585
  } else if (n.every((i) => i._def.typeName === "ZodEnum"))
@@ -1651,22 +1651,22 @@ function parseObjectDef(t, e) {
1651
1651
  type: "object",
1652
1652
  properties: {}
1653
1653
  }, r = [], o = t.shape();
1654
- for (const s in o) {
1655
- let c = o[s];
1654
+ for (const a in o) {
1655
+ let c = o[a];
1656
1656
  if (c === void 0 || c._def === void 0)
1657
1657
  continue;
1658
1658
  let d = safeIsOptional(c);
1659
1659
  d && n && (c._def.typeName === "ZodOptional" && (c = c._def.innerType), c.isNullable() || (c = c.nullable()), d = !1);
1660
1660
  const u = parseDef(c._def, {
1661
1661
  ...e,
1662
- currentPath: [...e.currentPath, "properties", s],
1663
- propertyPath: [...e.currentPath, "properties", s]
1662
+ currentPath: [...e.currentPath, "properties", a],
1663
+ propertyPath: [...e.currentPath, "properties", a]
1664
1664
  });
1665
- u !== void 0 && (i.properties[s] = u, d || r.push(s));
1665
+ u !== void 0 && (i.properties[a] = u, d || r.push(a));
1666
1666
  }
1667
1667
  r.length && (i.required = r);
1668
- const a = decideAdditionalProperties(t, e);
1669
- return a !== void 0 && (i.additionalProperties = a), i;
1668
+ const s = decideAdditionalProperties(t, e);
1669
+ return s !== void 0 && (i.additionalProperties = s), i;
1670
1670
  }
1671
1671
  function decideAdditionalProperties(t, e) {
1672
1672
  if (t.catchall._def.typeName !== "ZodNever")
@@ -1843,23 +1843,23 @@ const parseReadonlyDef = (t, e) => parseDef(t.innerType._def, e), selectParser =
1843
1843
  function parseDef(t, e, n = !1) {
1844
1844
  const i = e.seen.get(t);
1845
1845
  if (e.override) {
1846
- const s = e.override?.(t, e, i, n);
1847
- if (s !== ignoreOverride)
1848
- return s;
1846
+ const a = e.override?.(t, e, i, n);
1847
+ if (a !== ignoreOverride)
1848
+ return a;
1849
1849
  }
1850
1850
  if (i && !n) {
1851
- const s = get$ref(i, e);
1852
- if (s !== void 0)
1853
- return s;
1851
+ const a = get$ref(i, e);
1852
+ if (a !== void 0)
1853
+ return a;
1854
1854
  }
1855
1855
  const r = { def: t, path: e.currentPath, jsonSchema: void 0 };
1856
1856
  e.seen.set(t, r);
1857
- const o = selectParser(t, t.typeName, e), a = typeof o == "function" ? parseDef(o(), e) : o;
1858
- if (a && addMeta(t, e, a), e.postProcess) {
1859
- const s = e.postProcess(a, t, e);
1860
- return r.jsonSchema = a, s;
1857
+ const o = selectParser(t, t.typeName, e), s = typeof o == "function" ? parseDef(o(), e) : o;
1858
+ if (s && addMeta(t, e, s), e.postProcess) {
1859
+ const a = e.postProcess(s, t, e);
1860
+ return r.jsonSchema = s, a;
1861
1861
  }
1862
- return r.jsonSchema = a, a;
1862
+ return r.jsonSchema = s, s;
1863
1863
  }
1864
1864
  const get$ref = (t, e) => {
1865
1865
  switch (e.$refStrategy) {
@@ -1890,7 +1890,7 @@ const get$ref = (t, e) => {
1890
1890
  ].join("/")
1891
1891
  }
1892
1892
  }));
1893
- const a = r === void 0 ? i ? {
1893
+ const s = r === void 0 ? i ? {
1894
1894
  ...o,
1895
1895
  [n.definitionPath]: i
1896
1896
  } : o : {
@@ -1904,147 +1904,8 @@ const get$ref = (t, e) => {
1904
1904
  [r]: o
1905
1905
  }
1906
1906
  };
1907
- return n.target === "jsonSchema7" ? a.$schema = "http://json-schema.org/draft-07/schema#" : (n.target === "jsonSchema2019-09" || n.target === "openAi") && (a.$schema = "https://json-schema.org/draft/2019-09/schema#"), n.target === "openAi" && ("anyOf" in a || "oneOf" in a || "allOf" in a || "type" in a && Array.isArray(a.type)) && console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."), a;
1908
- }, pageAgentPrompt = `## 角色
1909
-
1910
- 你是浏览器页面的操作工具,你拥有识别网页内容,点击,填写,选择下拉框和滚动页面等功能。
1911
-
1912
- 在执行页面操作之前,你必须先调用\`browserState\`工具一次,根据最新的网页状态,再调用操作动作,比如 'click','fill','select' 等动作。
1913
-
1914
- <intro>
1915
- 你擅长以下任务:
1916
- 1. 导航复杂网站并提取精确信息
1917
- 2. 自动化表单提交和交互式网页操作
1918
- 3. 收集和保存信息
1919
- 4. 在代理循环中有效运行
1920
- 5. 高效执行多样化的网页任务
1921
- </intro>
1922
-
1923
- <input>
1924
- 在每一步,你的输入将包括:
1925
- 1. <agent_history>:一个按时间顺序排列的事件流,包括你之前的操作及其结果。
1926
- 2. <agent_state>:当前的 <user_request> 和 <step_info>。
1927
- 3. <browser_state>:当前 URL、页面标题、可交互元素总数以及语义化 YAML 树。
1928
- </input>
1929
-
1930
- <browser_state>
1931
-
1932
- 浏览器状态包含以下内容:
1933
-
1934
- - url: 当前查看页面的 URL。
1935
- - title: 当前查看页面的标题。
1936
- - 可交互元素总数:带有 \`#N\` 标记的元素数量。
1937
- - YAML 树:页面的语义化结构,格式如下:
1938
-
1939
- \`\`\`yaml
1940
- - region:
1941
- - main:
1942
- - button #9 [cursor=pointer] "产品文档"
1943
- - button #47 [selected] [cursor=pointer] "40元/月 2核CPU 2GB内存"
1944
- - radio #53 [checked] [cursor=pointer] "自动生成密码"
1945
- - button #74 [cursor=pointer] "立即购买"
1946
- - generic #6 [cf-uba="serviceList..Flexus云服务"] "Flexus云服务"
1947
- \`\`\`
1948
-
1949
- 节点格式说明:
1950
- - \`- role #N [token1] [token2] "accessible name"\`
1951
- - \`role\`:ARIA 语义角色(如 button/link/radio/heading/listitem/generic 等)
1952
- - \`#N\`:可交互元素的唯一操作索引,**只有带 \`#N\` 的节点才能被操作**,操作时将 N 作为 \`index\` 参数传入
1953
- - \`[token]\`:可选 token,包括状态标记(如 \`[checked]\` \`[selected]\` \`[pressed]\` \`[current]\` \`[expanded]\` \`[disabled]\` \`[readonly]\` \`[required]\` \`[invalid]\` \`[busy]\` \`[error]\` \`[warning]\` \`[cursor=pointer]\`)和定制属性(如 \`[cf-uba="..."]\`)
1954
- - \`"accessible name"\`:元素的语义化名称,**用双引号包裹**(通过 aria-label/aria-labelledby/innerText 等计算得出);无名称的节点此字段省略
1955
- - 缩进表示父子关系
1956
-
1957
- </browser_state>
1958
-
1959
- <responseMode>
1960
-
1961
- \`page-agent-tool\` 支持 \`responseMode\` 参数,用于控制操作后返回的页面状态形式:
1962
-
1963
- - **\`diff\`**(默认):仅返回自上一次状态以来的增量 DOM 差异,极大节省 Token。
1964
- - **\`full\`**:返回当前视口中完整的语义化 ARIA YAML 树。
1965
- - **\`both\`**:同时返回全量树和增量差异。
1966
-
1967
- 执行 \`click\`、\`fill\`、\`select\`、\`scroll\` 操作后,工具默认自动以 \`diff\` 模式返回最新页面状态,无需再次手动调用 \`browserState\`。
1968
-
1969
- </responseMode>
1970
-
1971
- <browser_state_diff>
1972
-
1973
- 在交互过程中,为了提高效率和减少上下文占用,工具会生成页面的增量差异(Diff)信息。
1974
- Diff 格式示例如下:
1975
- \`\`\`diff
1976
- - button #9: 产品文档
1977
- + button #9: 产品文档 (已点击)
1978
- \`\`\`
1979
- 或者,当页面结构发生改变时,会展示新增或移除的节点差异。
1980
-
1981
- ### 页面状态获取四原则(重要,请严格遵守):
1982
-
1983
- > 与业界 AI 编辑器(Cursor / Windsurf)按需读取文件而非全量加载的理念完全一致——**先精准搜索,再按需拉取全量**,将发送给大模型的 token 降至最低。
1984
-
1985
- 1. **按关键词精准搜索(最高优先级)**:当你已知要找什么类型的元素(如按钮、输入框、特定名称的链接)时,**优先使用 \`searchTree\` 动作**,传入 role 名称、元素文本或状态关键词搜索。它只返回命中行和上下文,token 消耗比全量树减少 80%+。
1986
- - 示例:查找所有按钮 → \`{"action": "searchTree", "query": "button"}\`
1987
- - 示例:查找含"提交"文本的节点 → \`{"action": "searchTree", "query": "提交"}\`
1988
- - 示例:查找已勾选的复选框 → \`{"action": "searchTree", "query": "checked"}\`
1989
- - 示例:精确定位某个 ref → \`{"action": "searchTree", "query": "#5"}\`
1990
- 2. **首次获取全量**:首次进入页面、页面发生重大刷新、或 \`searchTree\` 无法找到所需信息时,调用 \`browserState\` 并指定 \`responseMode\` 为 \`full\` 或 \`both\` 获取完整 A11y 树。
1991
- 3. **增量优先**:执行 \`click\`、\`fill\`、\`select\`、\`scroll\` 操作后,工具默认自动返回 \`diff\` 增量信息。优先阅读这些 Diff,以便快速确认操作是否生效。
1992
- 4. **按需拉取全量**:如果增量 Diff 不足以支持下一步操作,或需要寻找不在 Diff 中的 \`#N\` 节点,且 \`searchTree\` 也无法定位时,再显式调用 \`browserState\` 拉取完整树。
1993
-
1994
- </browser_state_diff>
1995
-
1996
-
1997
-
1998
- <browser_rules>
1999
- 在使用浏览器和浏览网页时严格遵守以下规则:
2000
-
2001
- - 仅与分配有 \`#N\` 索引的元素进行交互,将 N 作为 \`index\` 参数传入。
2002
- - 仅使用明确出现在树中的 \`#N\` 索引,切勿猜测或沿用过期索引。
2003
- - 每次操作后 \`#N\` 索引会重新分配,不要使用旧的索引。
2004
- - 如果页面在执行操作后发生变化(例如输入文本操作),分析是否需要与新元素进行交互,例如从列表中选择正确的选项。
2005
- - 默认情况下,仅列出可见视口中的元素。如果你怀疑需要交互的相关内容在屏幕外,请使用滚动操作。仅在页面下方或上方还有更多像素时才滚动。
2006
- - 你可以使用 num_pages 参数滚动特定页数(例如,0.5 表示半页,2.0 表示两页)。
2007
- - 如果出现验证码,告诉用户你无法解决验证码。完成任务并请用户解决它。
2008
- - 如果缺少预期元素,尝试滚动或导航回退。
2009
- - 除非某些条件发生变化,否则不要重复同一操作超过 3 次。
2010
- - 如果你向输入字段填充文本且操作序列被中断,通常意味着某些内容发生了变化,例如下拉建议弹出。
2011
- - 如果 <user_request> 包含特定的页面信息,如产品类型、评分、价格、位置等,尝试应用过滤器以提高效率。
2012
- - <user_request> 是最终目标。如果用户指定了明确的步骤,它们始终具有最高优先级。
2013
- - 如果你向字段输入文本,可能需要按回车键、点击搜索按钮或从下拉列表中选择以完成操作。
2014
- - **不要通过 executeJavascript 向页面插入 DOM 元素**(如创建 div 显示调试信息)。这会污染页面结构并影响后续操作。如需读取数据,使用 return 语句返回结果即可。
2015
- - 如果操作返回中出现 \`[校验提示]\`,说明页面有表单校验错误未通过,请先根据提示修复错误后再继续操作。
2016
- - 如果操作后页面没有发生预期变化,优先检查是否有 \`[校验提示]\` 或 \`[error]\` token 的错误信息,而非重复操作。
2017
- - 如果不需要,不要登录页面。如果没有凭据,不要登录。
2018
- - 有两种类型的任务,首先思考你正在处理哪种类型的请求:
2019
-
2020
- 1. 非常具体的逐步说明:
2021
-
2022
- - 非常精确地遵循它们,不要跳过步骤。尝试按要求完成所有内容。
2023
-
2024
- 2. 开放式任务。自己规划,在实现目标时保持创造性。
2025
-
2026
- - 如果在开放式任务中陷入困境(例如登录或验证码),可以重新评估任务并尝试替代方法,例如有时即使页面的某些部分可访问或通过 Web 搜索获取一些信息,也会意外弹出登录框。
2027
- </browser_rules>
2028
-
2029
- <capability>
2030
- - 你只能处理单页应用。不要跳出当前页面。
2031
- - 如果链接将在新页面中打开(例如,<a target="_blank">),不要点击该链接。
2032
- - 任务失败是可以接受的。
2033
- - 用户可能是错的。如果用户的请求无法实现、不适当,或者你没有足够的信息或工具来实现它。告诉用户提出更好的请求。
2034
- - 网页可能已损坏。所有网页或应用都有 bug。有些 bug 会使你的工作变得困难。鼓励你告诉用户当前页面的问题。你的反馈(包括失败)对用户很有价值。
2035
- - 过于努力可能有害。来回重复某些操作或在知识有限的情况下推动复杂程序可能导致不良结果和有害副作用。用户宁愿你以失败告终完成任务。
2036
- - 如果你对当前网页或任务没有相关知识。你必须要求用户提供具体说明和详细步骤。
2037
- </capability>
2038
-
2039
- <task_completion_rules>
2040
- 你必须在以下情况时结束任务:
2041
-
2042
- - 当你完全完成用户请求时。
2043
- - 当你感到困惑或无法解决用户请求时。或者用户请求不清楚或包含不当内容。
2044
- - 如果绝对不可能继续。
2045
-
2046
- </task_completion_rules>
2047
- `;
1907
+ return n.target === "jsonSchema7" ? s.$schema = "http://json-schema.org/draft-07/schema#" : (n.target === "jsonSchema2019-09" || n.target === "openAi") && (s.$schema = "https://json-schema.org/draft/2019-09/schema#"), n.target === "openAi" && ("anyOf" in s || "oneOf" in s || "allOf" in s || "type" in s && Array.isArray(s.type)) && console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."), s;
1908
+ }, pageAgentPrompt = '## 角色\n\n你是浏览器页面的操作工具,你拥有识别网页内容,点击,填写,选择下拉框、悬浮(hover)和滚动页面等功能。\n\n在执行页面操作之前,你必须先调用`browserState`工具一次,根据最新的网页状态,再调用操作动作,比如 \'click\',\'fill\',\'select\',\'hover\' 等动作。\n\n<intro>\n你擅长以下任务:\n1. 导航复杂网站并提取精确信息\n2. 自动化表单提交和交互式网页操作\n3. 收集和保存信息\n4. 在代理循环中有效运行\n5. 高效执行多样化的网页任务\n</intro>\n\n<input>\n在每一步,你的输入将包括:\n1. <agent_history>:一个按时间顺序排列的事件流,包括你之前的操作及其结果。\n2. <agent_state>:当前的 <user_request> 和 <step_info>。\n3. <browser_state>:当前 URL、页面标题、可交互元素总数以及语义化 YAML 树。\n</input>\n\n<browser_state>\n\n浏览器状态包含以下内容:\n\n- url: 当前查看页面的 URL。\n- title: 当前查看页面的标题。\n- content: 语义化 YAML 树(或增量 Diff,取决于 responseMode)。\n- dialogs(可选): 当前可见的模态弹窗列表,每项含 `text` 与 `buttons`;若存在请优先处理。\n- validationErrors(可选): 当前可见的表单校验错误文案列表;若存在请先修复。\n- tooltips(可选): 当前可见的 tooltip / 浮层提示文案列表(常见于 hover 后)。\n- 可交互元素总数:带有 `#N` 标记的元素数量。\n- YAML 树:页面的语义化结构,格式如下:\n\n```yaml\n- region:\n - main:\n - button #9 [cursor=pointer] "产品文档"\n - button #47 [selected] [cursor=pointer] "40元/月 2核CPU 2GB内存"\n - radio #53 [checked] [cursor=pointer] "自动生成密码"\n - button #74 [cursor=pointer] "立即购买"\n - generic #6 [cf-uba="serviceList..Flexus云服务"] "Flexus云服务"\n```\n\n节点格式说明:\n- `- role #N [token1] [token2] "accessible name"`\n- `role`:ARIA 语义角色(如 button/link/radio/heading/listitem/generic 等)\n- `#N`:可交互元素的唯一操作索引,**只有带 `#N` 的节点才能被操作**,操作时将 N 作为 `index` 参数传入\n- `[token]`:可选 token,包括状态标记(如 `[checked]` `[selected]` `[pressed]` `[current]` `[expanded]` `[hasPopup]` `[disabled]` `[readonly]` `[required]` `[invalid]` `[busy]` `[error]` `[warning]` `[cursor=pointer]` `[tooltip="帮助文本"]`)和定制属性(如 `[cf-uba="..."]`)\n- `"accessible name"`:元素的语义化名称,**用双引号包裹**(通过 aria-label/aria-labelledby/innerText 等计算得出);无名称的节点此字段省略\n- 缩进表示父子关系\n\n</browser_state>\n\n<responseMode>\n\n`page-agent-tool` 支持 `responseMode` 参数,用于控制操作后返回的页面状态形式:\n\n- **`diff`**(默认):仅返回自上一次状态以来的增量 DOM 差异,极大节省 Token。\n- **`full`**:返回当前视口中完整的语义化 ARIA YAML 树。\n- **`both`**:同时返回全量树和增量差异。\n\n执行 `click`、`fill`、`select`、`scroll` 操作后,工具默认自动以 `diff` 模式返回最新页面状态,无需再次手动调用 `browserState`。`hover` 动作返回重建后的页面状态(含 `tooltips` 等结构化字段)。\n\n</responseMode>\n\n<browser_state_diff>\n\n在交互过程中,为了提高效率和减少上下文占用,工具会生成页面的增量差异(Diff)信息。\nDiff 格式示例如下:\n```diff\n- button #9: 产品文档\n+ button #9: 产品文档 (已点击)\n```\n或者,当页面结构发生改变时,会展示新增或移除的节点差异。\n\n### 页面状态获取四原则(重要,请严格遵守):\n\n> 与业界 AI 编辑器(Cursor / Windsurf)按需读取文件而非全量加载的理念完全一致——**先精准搜索,再按需拉取全量**,将发送给大模型的 token 降至最低。\n\n1. **按关键词精准搜索(最高优先级)**:当你已知要找什么类型的元素(如按钮、输入框、特定名称的链接)时,**优先使用 `searchTree` 动作**,传入 role 名称、元素文本或状态关键词搜索。它只返回命中行和上下文,token 消耗比全量树减少 80%+。\n - 示例:查找所有按钮 → `{"action": "searchTree", "query": "button"}`\n - 示例:查找含"提交"文本的节点 → `{"action": "searchTree", "query": "提交"}`\n - 示例:查找已勾选的复选框 → `{"action": "searchTree", "query": "checked"}`\n - 示例:精确定位某个 ref → `{"action": "searchTree", "query": "#5"}`\n2. **首次获取全量**:首次进入页面、页面发生重大刷新、或 `searchTree` 无法找到所需信息时,调用 `browserState` 并指定 `responseMode` 为 `full` 或 `both` 获取完整 A11y 树。\n3. **增量优先**:执行 `click`、`fill`、`select`、`scroll` 操作后,工具默认自动返回 `diff` 增量信息。优先阅读这些 Diff,以便快速确认操作是否生效。\n4. **按需拉取全量**:如果增量 Diff 不足以支持下一步操作,或需要寻找不在 Diff 中的 `#N` 节点,且 `searchTree` 也无法定位时,再显式调用 `browserState` 拉取完整树。\n\n</browser_state_diff>\n\n\n\n<browser_rules>\n在使用浏览器和浏览网页时严格遵守以下规则:\n\n- 仅与分配有 `#N` 索引的元素进行交互,将 N 作为 `index` 参数传入。\n- 仅使用明确出现在树中的 `#N` 索引,切勿猜测或沿用过期索引。\n- 每次操作后 `#N` 索引会重新分配,不要使用旧的索引。\n- 如果页面在执行操作后发生变化(例如输入文本操作),分析是否需要与新元素进行交互,例如从列表中选择正确的选项。\n- 默认情况下,仅列出可见视口中的元素。如果你怀疑需要交互的相关内容在屏幕外,请使用滚动操作。仅在页面下方或上方还有更多像素时才滚动。\n- 你可以使用 num_pages 参数滚动特定页数(例如,0.5 表示半页,2.0 表示两页)。\n- 如果出现验证码,告诉用户你无法解决验证码。完成任务并请用户解决它。\n- 如果缺少预期元素,尝试滚动或导航回退。\n- 除非某些条件发生变化,否则不要重复同一操作超过 3 次。\n- 如果你向输入字段填充文本且操作序列被中断,通常意味着某些内容发生了变化,例如下拉建议弹出。\n- 如果 <user_request> 包含特定的页面信息,如产品类型、评分、价格、位置等,尝试应用过滤器以提高效率。\n- <user_request> 是最终目标。如果用户指定了明确的步骤,它们始终具有最高优先级。\n- 如果你向字段输入文本,可能需要按回车键、点击搜索按钮或从下拉列表中选择以完成操作。\n- 对于带有 `[tooltip="..."]` token 的元素,可以直接阅读提示文本。对于标记为 `tooltip [hasPopup]` 的元素(如帮助提示图标),tooltip 文本需 hover 才会动态出现——**使用 `hover` 动作并传入元素索引即可触发并获取 tooltip 内容**。hover 返回浮层提示文本 + 重建后的完整页面状态,`#N` 索引会更新,可继续操作新出现的交互元素。\n- **对 tooltip 触发元素优先使用 `hover` 而非 `click`**:click 可能触发标签页切换或 DOM 重建导致 ref 索引失效,而 hover 只触发 pointer/mouse 事件,安全且返回 tooltip 内容。\n- **不要通过 executeJavascript 向页面插入 DOM 元素**(如创建 div 显示调试信息)。这会污染页面结构并影响后续操作。如需读取数据,使用 return 语句返回结果即可。\n- 如果操作返回中出现 `[校验提示]`,说明页面有表单校验错误未通过,请先根据提示修复错误后再继续操作。\n- 如果操作后页面没有发生预期变化,优先检查是否有 `[校验提示]` 或 `[error]` token 的错误信息,而非重复操作。\n- 如果不需要,不要登录页面。如果没有凭据,不要登录。\n- 有两种类型的任务,首先思考你正在处理哪种类型的请求:\n\n1. 非常具体的逐步说明:\n\n- 非常精确地遵循它们,不要跳过步骤。尝试按要求完成所有内容。\n\n2. 开放式任务。自己规划,在实现目标时保持创造性。\n\n- 如果在开放式任务中陷入困境(例如登录或验证码),可以重新评估任务并尝试替代方法,例如有时即使页面的某些部分可访问或通过 Web 搜索获取一些信息,也会意外弹出登录框。\n </browser_rules>\n\n<capability>\n- 你只能处理单页应用。不要跳出当前页面。\n- 如果链接将在新页面中打开(例如,<a target="_blank">),不要点击该链接。\n- 任务失败是可以接受的。\n - 用户可能是错的。如果用户的请求无法实现、不适当,或者你没有足够的信息或工具来实现它。告诉用户提出更好的请求。\n - 网页可能已损坏。所有网页或应用都有 bug。有些 bug 会使你的工作变得困难。鼓励你告诉用户当前页面的问题。你的反馈(包括失败)对用户很有价值。\n - 过于努力可能有害。来回重复某些操作或在知识有限的情况下推动复杂程序可能导致不良结果和有害副作用。用户宁愿你以失败告终完成任务。\n- 如果你对当前网页或任务没有相关知识。你必须要求用户提供具体说明和详细步骤。\n</capability>\n\n<task_completion_rules>\n你必须在以下情况时结束任务:\n\n- 当你完全完成用户请求时。\n- 当你感到困惑或无法解决用户请求时。或者用户请求不清楚或包含不当内容。\n- 如果绝对不可能继续。\n\n</task_completion_rules>\n';
2048
1909
  function isHTMLElement(t) {
2049
1910
  return !!t && t.nodeType === 1;
2050
1911
  }
@@ -2114,9 +1975,9 @@ async function clickElement(t) {
2114
1975
  await movePointerToElement(t, i, r), await clickPointer(), await waitFor(0.1);
2115
1976
  const o = t.ownerDocument;
2116
1977
  await enablePassThrough();
2117
- const a = o.elementFromPoint(i, r);
1978
+ const s = o.elementFromPoint(i, r);
2118
1979
  await disablePassThrough();
2119
- const s = a instanceof HTMLElement && t.contains(a) ? a : t, c = {
1980
+ const a = s instanceof HTMLElement && t.contains(s) ? s : t, c = {
2120
1981
  bubbles: !0,
2121
1982
  cancelable: !0,
2122
1983
  clientX: i,
@@ -2129,13 +1990,13 @@ async function clickElement(t) {
2129
1990
  clientY: r,
2130
1991
  button: 0
2131
1992
  };
2132
- s.dispatchEvent(new PointerEvent("pointerover", c)), s.dispatchEvent(new PointerEvent("pointerenter", {
1993
+ a.dispatchEvent(new PointerEvent("pointerover", c)), a.dispatchEvent(new PointerEvent("pointerenter", {
2133
1994
  ...c,
2134
1995
  bubbles: !1
2135
- })), s.dispatchEvent(new MouseEvent("mouseover", d)), s.dispatchEvent(new MouseEvent("mouseenter", {
1996
+ })), a.dispatchEvent(new MouseEvent("mouseover", d)), a.dispatchEvent(new MouseEvent("mouseenter", {
2136
1997
  ...d,
2137
1998
  bubbles: !1
2138
- })), s.dispatchEvent(new PointerEvent("pointerdown", c)), s.dispatchEvent(new MouseEvent("mousedown", d)), t.focus({ preventScroll: !0 }), s.dispatchEvent(new PointerEvent("pointerup", c)), s.dispatchEvent(new MouseEvent("mouseup", d)), s.click(), await waitFor(0.2);
1999
+ })), a.dispatchEvent(new PointerEvent("pointerdown", c)), a.dispatchEvent(new MouseEvent("mousedown", d)), t.focus({ preventScroll: !0 }), a.dispatchEvent(new PointerEvent("pointerup", c)), a.dispatchEvent(new MouseEvent("mouseup", d)), a.click(), await waitFor(0.2);
2139
2000
  }
2140
2001
  async function inputTextElement(t, e) {
2141
2002
  const n = t.isContentEditable;
@@ -2182,94 +2043,94 @@ async function scrollIntoViewIfNeeded(t) {
2182
2043
  }
2183
2044
  async function scrollVertically(t, e) {
2184
2045
  if (e) {
2185
- const a = e;
2186
- let s = a, c = !1, d = null, u = 0, p = 0;
2187
- const h = t;
2188
- for (; s && p < 10; ) {
2189
- const g = window.getComputedStyle(s), y = /(auto|scroll|overlay)/.test(g.overflowY) || g.scrollbarWidth && g.scrollbarWidth !== "auto" || g.scrollbarGutter && g.scrollbarGutter !== "auto", T = s.scrollHeight > s.clientHeight;
2190
- if (y && T) {
2191
- const C = s.scrollTop, f = s.scrollHeight - s.clientHeight;
2192
- let m = h / 3;
2193
- m > 0 ? m = Math.min(m, f - C) : m = Math.max(m, -C), s.scrollTop = C + m;
2194
- const E = s.scrollTop - C;
2195
- if (Math.abs(E) > 0.5) {
2196
- c = !0, d = s, u = E;
2046
+ const s = e;
2047
+ let a = s, c = !1, d = null, u = 0, h = 0;
2048
+ const p = t;
2049
+ for (; a && h < 10; ) {
2050
+ const m = window.getComputedStyle(a), g = /(auto|scroll|overlay)/.test(m.overflowY) || m.scrollbarWidth && m.scrollbarWidth !== "auto" || m.scrollbarGutter && m.scrollbarGutter !== "auto", E = a.scrollHeight > a.clientHeight;
2051
+ if (g && E) {
2052
+ const L = a.scrollTop, f = a.scrollHeight - a.clientHeight;
2053
+ let b = p / 3;
2054
+ b > 0 ? b = Math.min(b, f - L) : b = Math.max(b, -L), a.scrollTop = L + b;
2055
+ const T = a.scrollTop - L;
2056
+ if (Math.abs(T) > 0.5) {
2057
+ c = !0, d = a, u = T;
2197
2058
  break;
2198
2059
  }
2199
2060
  }
2200
- if (s === document.body || s === document.documentElement) break;
2201
- s = s.parentElement, p++;
2061
+ if (a === document.body || a === document.documentElement) break;
2062
+ a = a.parentElement, h++;
2202
2063
  }
2203
- return c ? `Scrolled container (${d?.tagName}) by ${u}px` : `No scrollable container found for element (${a.tagName})`;
2064
+ return c ? `Scrolled container (${d?.tagName}) by ${u}px` : `No scrollable container found for element (${s.tagName})`;
2204
2065
  }
2205
- const n = t, i = (a) => a.clientHeight >= window.innerHeight * 0.5, r = (a) => !!(a && /(auto|scroll|overlay)/.test(getComputedStyle(a).overflowY) && a.scrollHeight > a.clientHeight && i(a));
2066
+ const n = t, i = (s) => s.clientHeight >= window.innerHeight * 0.5, r = (s) => !!(s && /(auto|scroll|overlay)/.test(getComputedStyle(s).overflowY) && s.scrollHeight > s.clientHeight && i(s));
2206
2067
  let o = document.activeElement;
2207
2068
  for (; o && !r(o) && o !== document.body; ) o = o.parentElement;
2208
2069
  if (o = r(o) ? o : Array.from(document.querySelectorAll("*")).find(r) || document.scrollingElement || document.documentElement, o === document.scrollingElement || o === document.documentElement || o === document.body) {
2209
- const a = window.scrollY, s = document.documentElement.scrollHeight - window.innerHeight;
2070
+ const s = window.scrollY, a = document.documentElement.scrollHeight - window.innerHeight;
2210
2071
  window.scrollBy(0, n);
2211
- const c = window.scrollY, d = c - a;
2072
+ const c = window.scrollY, d = c - s;
2212
2073
  if (Math.abs(d) < 1) return n > 0 ? "⚠️ Already at the bottom of the page, cannot scroll down further." : "⚠️ Already at the top of the page, cannot scroll up further.";
2213
- const u = n > 0 && c >= s - 1, p = n < 0 && c <= 1;
2214
- return u ? `✅ Scrolled page by ${d}px. Reached the bottom of the page.` : p ? `✅ Scrolled page by ${d}px. Reached the top of the page.` : `✅ Scrolled page by ${d}px.`;
2074
+ const u = n > 0 && c >= a - 1, h = n < 0 && c <= 1;
2075
+ return u ? `✅ Scrolled page by ${d}px. Reached the bottom of the page.` : h ? `✅ Scrolled page by ${d}px. Reached the top of the page.` : `✅ Scrolled page by ${d}px.`;
2215
2076
  } else {
2216
- const a = "The document is not scrollable. Falling back to container scroll.";
2217
- console.log(`[PageController] ${a}`);
2218
- const s = o.scrollTop, c = o.scrollHeight - o.clientHeight;
2077
+ const s = "The document is not scrollable. Falling back to container scroll.";
2078
+ console.log(`[PageController] ${s}`);
2079
+ const a = o.scrollTop, c = o.scrollHeight - o.clientHeight;
2219
2080
  o.scrollBy({
2220
2081
  top: n,
2221
2082
  behavior: "smooth"
2222
2083
  }), await waitFor(0.1);
2223
- const d = o.scrollTop, u = d - s;
2224
- if (Math.abs(u) < 1) return n > 0 ? `⚠️ ${a} Already at the bottom of container (${o.tagName}), cannot scroll down further.` : `⚠️ ${a} Already at the top of container (${o.tagName}), cannot scroll up further.`;
2225
- const p = n > 0 && d >= c - 1, h = n < 0 && d <= 1;
2226
- return p ? `✅ ${a} Scrolled container (${o.tagName}) by ${u}px. Reached the bottom.` : h ? `✅ ${a} Scrolled container (${o.tagName}) by ${u}px. Reached the top.` : `✅ ${a} Scrolled container (${o.tagName}) by ${u}px.`;
2084
+ const d = o.scrollTop, u = d - a;
2085
+ if (Math.abs(u) < 1) return n > 0 ? `⚠️ ${s} Already at the bottom of container (${o.tagName}), cannot scroll down further.` : `⚠️ ${s} Already at the top of container (${o.tagName}), cannot scroll up further.`;
2086
+ const h = n > 0 && d >= c - 1, p = n < 0 && d <= 1;
2087
+ return h ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the bottom.` : p ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the top.` : `✅ ${s} Scrolled container (${o.tagName}) by ${u}px.`;
2227
2088
  }
2228
2089
  }
2229
2090
  async function scrollHorizontally(t, e) {
2230
2091
  if (e) {
2231
- const a = e;
2232
- let s = a, c = !1, d = null, u = 0, p = 0;
2233
- const h = t;
2234
- for (; s && p < 10; ) {
2235
- const g = window.getComputedStyle(s), y = /(auto|scroll|overlay)/.test(g.overflowX) || g.scrollbarWidth && g.scrollbarWidth !== "auto" || g.scrollbarGutter && g.scrollbarGutter !== "auto", T = s.scrollWidth > s.clientWidth;
2236
- if (y && T) {
2237
- const C = s.scrollLeft, f = s.scrollWidth - s.clientWidth;
2238
- let m = h / 3;
2239
- m > 0 ? m = Math.min(m, f - C) : m = Math.max(m, -C), s.scrollLeft = C + m;
2240
- const E = s.scrollLeft - C;
2241
- if (Math.abs(E) > 0.5) {
2242
- c = !0, d = s, u = E;
2092
+ const s = e;
2093
+ let a = s, c = !1, d = null, u = 0, h = 0;
2094
+ const p = t;
2095
+ for (; a && h < 10; ) {
2096
+ const m = window.getComputedStyle(a), g = /(auto|scroll|overlay)/.test(m.overflowX) || m.scrollbarWidth && m.scrollbarWidth !== "auto" || m.scrollbarGutter && m.scrollbarGutter !== "auto", E = a.scrollWidth > a.clientWidth;
2097
+ if (g && E) {
2098
+ const L = a.scrollLeft, f = a.scrollWidth - a.clientWidth;
2099
+ let b = p / 3;
2100
+ b > 0 ? b = Math.min(b, f - L) : b = Math.max(b, -L), a.scrollLeft = L + b;
2101
+ const T = a.scrollLeft - L;
2102
+ if (Math.abs(T) > 0.5) {
2103
+ c = !0, d = a, u = T;
2243
2104
  break;
2244
2105
  }
2245
2106
  }
2246
- if (s === document.body || s === document.documentElement) break;
2247
- s = s.parentElement, p++;
2107
+ if (a === document.body || a === document.documentElement) break;
2108
+ a = a.parentElement, h++;
2248
2109
  }
2249
- return c ? `Scrolled container (${d?.tagName}) horizontally by ${u}px` : `No horizontally scrollable container found for element (${a.tagName})`;
2110
+ return c ? `Scrolled container (${d?.tagName}) horizontally by ${u}px` : `No horizontally scrollable container found for element (${s.tagName})`;
2250
2111
  }
2251
- const n = t, i = (a) => a.clientWidth >= window.innerWidth * 0.5, r = (a) => !!(a && /(auto|scroll|overlay)/.test(getComputedStyle(a).overflowX) && a.scrollWidth > a.clientWidth && i(a));
2112
+ const n = t, i = (s) => s.clientWidth >= window.innerWidth * 0.5, r = (s) => !!(s && /(auto|scroll|overlay)/.test(getComputedStyle(s).overflowX) && s.scrollWidth > s.clientWidth && i(s));
2252
2113
  let o = document.activeElement;
2253
2114
  for (; o && !r(o) && o !== document.body; ) o = o.parentElement;
2254
2115
  if (o = r(o) ? o : Array.from(document.querySelectorAll("*")).find(r) || document.scrollingElement || document.documentElement, o === document.scrollingElement || o === document.documentElement || o === document.body) {
2255
- const a = window.scrollX, s = document.documentElement.scrollWidth - window.innerWidth;
2116
+ const s = window.scrollX, a = document.documentElement.scrollWidth - window.innerWidth;
2256
2117
  window.scrollBy(n, 0);
2257
- const c = window.scrollX, d = c - a;
2118
+ const c = window.scrollX, d = c - s;
2258
2119
  if (Math.abs(d) < 1) return n > 0 ? "⚠️ Already at the right edge of the page, cannot scroll right further." : "⚠️ Already at the left edge of the page, cannot scroll left further.";
2259
- const u = n > 0 && c >= s - 1, p = n < 0 && c <= 1;
2260
- return u ? `✅ Scrolled page by ${d}px. Reached the right edge of the page.` : p ? `✅ Scrolled page by ${d}px. Reached the left edge of the page.` : `✅ Scrolled page horizontally by ${d}px.`;
2120
+ const u = n > 0 && c >= a - 1, h = n < 0 && c <= 1;
2121
+ return u ? `✅ Scrolled page by ${d}px. Reached the right edge of the page.` : h ? `✅ Scrolled page by ${d}px. Reached the left edge of the page.` : `✅ Scrolled page horizontally by ${d}px.`;
2261
2122
  } else {
2262
- const a = "The document is not scrollable. Falling back to container scroll.";
2263
- console.log(`[PageController] ${a}`);
2264
- const s = o.scrollLeft, c = o.scrollWidth - o.clientWidth;
2123
+ const s = "The document is not scrollable. Falling back to container scroll.";
2124
+ console.log(`[PageController] ${s}`);
2125
+ const a = o.scrollLeft, c = o.scrollWidth - o.clientWidth;
2265
2126
  o.scrollBy({
2266
2127
  left: n,
2267
2128
  behavior: "smooth"
2268
2129
  }), await waitFor(0.1);
2269
- const d = o.scrollLeft, u = d - s;
2270
- if (Math.abs(u) < 1) return n > 0 ? `⚠️ ${a} Already at the right edge of container (${o.tagName}), cannot scroll right further.` : `⚠️ ${a} Already at the left edge of container (${o.tagName}), cannot scroll left further.`;
2271
- const p = n > 0 && d >= c - 1, h = n < 0 && d <= 1;
2272
- return p ? `✅ ${a} Scrolled container (${o.tagName}) by ${u}px. Reached the right edge.` : h ? `✅ ${a} Scrolled container (${o.tagName}) by ${u}px. Reached the left edge.` : `✅ ${a} Scrolled container (${o.tagName}) horizontally by ${u}px.`;
2130
+ const d = o.scrollLeft, u = d - a;
2131
+ if (Math.abs(u) < 1) return n > 0 ? `⚠️ ${s} Already at the right edge of container (${o.tagName}), cannot scroll right further.` : `⚠️ ${s} Already at the left edge of container (${o.tagName}), cannot scroll left further.`;
2132
+ const h = n > 0 && d >= c - 1, p = n < 0 && d <= 1;
2133
+ return h ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the right edge.` : p ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the left edge.` : `✅ ${s} Scrolled container (${o.tagName}) horizontally by ${u}px.`;
2273
2134
  }
2274
2135
  }
2275
2136
  var dom_tree_default = (t = {
@@ -2287,51 +2148,51 @@ var dom_tree_default = (t = {
2287
2148
  highlightOpacity: 0.1,
2288
2149
  highlightLabelOpacity: 0.5
2289
2150
  }) => {
2290
- const { interactiveBlacklist: e, interactiveWhitelist: n, highlightOpacity: i, highlightLabelOpacity: r } = t, { doHighlightElements: o, focusHighlightIndex: a, viewportExpansion: s, debugMode: c } = t;
2151
+ const { interactiveBlacklist: e, interactiveWhitelist: n, highlightOpacity: i, highlightLabelOpacity: r } = t, { doHighlightElements: o, focusHighlightIndex: s, viewportExpansion: a, debugMode: c } = t;
2291
2152
  let d = 0;
2292
2153
  const u = /* @__PURE__ */ new WeakMap();
2293
- function p(l, b) {
2154
+ function h(l, w) {
2294
2155
  !l || l.nodeType !== Node.ELEMENT_NODE || u.set(l, {
2295
2156
  ...u.get(l),
2296
- ...b
2157
+ ...w
2297
2158
  });
2298
2159
  }
2299
- const h = {
2160
+ const p = {
2300
2161
  boundingRects: /* @__PURE__ */ new WeakMap(),
2301
2162
  clientRects: /* @__PURE__ */ new WeakMap(),
2302
2163
  computedStyles: /* @__PURE__ */ new WeakMap(),
2303
2164
  clearCache: () => {
2304
- h.boundingRects = /* @__PURE__ */ new WeakMap(), h.clientRects = /* @__PURE__ */ new WeakMap(), h.computedStyles = /* @__PURE__ */ new WeakMap();
2165
+ p.boundingRects = /* @__PURE__ */ new WeakMap(), p.clientRects = /* @__PURE__ */ new WeakMap(), p.computedStyles = /* @__PURE__ */ new WeakMap();
2305
2166
  }
2306
2167
  };
2307
- function g(l) {
2168
+ function m(l) {
2308
2169
  if (!l) return null;
2309
- if (h.boundingRects.has(l)) return h.boundingRects.get(l);
2310
- const b = l.getBoundingClientRect();
2311
- return b && h.boundingRects.set(l, b), b;
2170
+ if (p.boundingRects.has(l)) return p.boundingRects.get(l);
2171
+ const w = l.getBoundingClientRect();
2172
+ return w && p.boundingRects.set(l, w), w;
2312
2173
  }
2313
- function y(l) {
2174
+ function g(l) {
2314
2175
  if (!l) return null;
2315
- if (h.computedStyles.has(l)) return h.computedStyles.get(l);
2316
- const b = window.getComputedStyle(l);
2317
- return b && h.computedStyles.set(l, b), b;
2176
+ if (p.computedStyles.has(l)) return p.computedStyles.get(l);
2177
+ const w = window.getComputedStyle(l);
2178
+ return w && p.computedStyles.set(l, w), w;
2318
2179
  }
2319
- function T(l) {
2180
+ function E(l) {
2320
2181
  if (!l) return null;
2321
- if (h.clientRects.has(l)) return h.clientRects.get(l);
2322
- const b = l.getClientRects();
2323
- return b && h.clientRects.set(l, b), b;
2324
- }
2325
- const C = {}, f = { current: 0 }, m = "playwright-highlight-container";
2326
- function E(l, b, R = null) {
2327
- if (!l) return b;
2328
- const w = [];
2329
- let _ = null, D = 20, x = 16, P = null;
2182
+ if (p.clientRects.has(l)) return p.clientRects.get(l);
2183
+ const w = l.getClientRects();
2184
+ return w && p.clientRects.set(l, w), w;
2185
+ }
2186
+ const L = {}, f = { current: 0 }, b = "playwright-highlight-container";
2187
+ function T(l, w, M = null) {
2188
+ if (!l) return w;
2189
+ const v = [];
2190
+ let _ = null, O = 20, x = 16, N = null;
2330
2191
  try {
2331
- let k = document.getElementById(m);
2332
- k || (k = document.createElement("div"), k.id = m, k.style.position = "fixed", k.style.pointerEvents = "none", k.style.top = "0", k.style.left = "0", k.style.width = "100%", k.style.height = "100%", k.style.zIndex = "2147483640", k.style.backgroundColor = "transparent", document.body.appendChild(k));
2192
+ let k = document.getElementById(b);
2193
+ k || (k = document.createElement("div"), k.id = b, k.style.position = "fixed", k.style.pointerEvents = "none", k.style.top = "0", k.style.left = "0", k.style.width = "100%", k.style.height = "100%", k.style.zIndex = "2147483640", k.style.backgroundColor = "transparent", document.body.appendChild(k));
2333
2194
  const I = l.getClientRects();
2334
- if (!I || I.length === 0) return b;
2195
+ if (!I || I.length === 0) return w;
2335
2196
  const Y = [
2336
2197
  "#FF0000",
2337
2198
  "#00FF00",
@@ -2346,33 +2207,33 @@ var dom_tree_default = (t = {
2346
2207
  "#DC143C",
2347
2208
  "#4682B4"
2348
2209
  ];
2349
- let V = Y[b % Y.length];
2210
+ let V = Y[w % Y.length];
2350
2211
  const K = V + Math.floor(i * 255).toString(16).padStart(2, "0");
2351
2212
  V = V + Math.floor(r * 255).toString(16).padStart(2, "0");
2352
2213
  let j = {
2353
2214
  x: 0,
2354
2215
  y: 0
2355
2216
  };
2356
- if (R) {
2357
- const H = R.getBoundingClientRect();
2217
+ if (M) {
2218
+ const H = M.getBoundingClientRect();
2358
2219
  j.x = H.left, j.y = H.top;
2359
2220
  }
2360
- const ae = document.createDocumentFragment();
2221
+ const se = document.createDocumentFragment();
2361
2222
  for (const H of I) {
2362
2223
  if (H.width === 0 || H.height === 0) continue;
2363
2224
  const U = document.createElement("div");
2364
2225
  U.style.position = "fixed", U.style.border = `2px solid ${V}`, U.style.backgroundColor = K, U.style.pointerEvents = "none", U.style.boxSizing = "border-box";
2365
2226
  const $ = H.top + j.y, X = H.left + j.x;
2366
- U.style.top = `${$}px`, U.style.left = `${X}px`, U.style.width = `${H.width}px`, U.style.height = `${H.height}px`, ae.appendChild(U), w.push({
2227
+ U.style.top = `${$}px`, U.style.left = `${X}px`, U.style.width = `${H.width}px`, U.style.height = `${H.height}px`, se.appendChild(U), v.push({
2367
2228
  element: U,
2368
2229
  initialRect: H
2369
2230
  });
2370
2231
  }
2371
2232
  const ie = I[0];
2372
- _ = document.createElement("div"), _.className = "playwright-highlight-label", _.style.position = "fixed", _.style.background = V, _.style.color = "white", _.style.padding = "1px 4px", _.style.borderRadius = "4px", _.style.fontSize = `${Math.min(12, Math.max(8, ie.height / 2))}px`, _.textContent = b.toString(), D = _.offsetWidth > 0 ? _.offsetWidth : D, x = _.offsetHeight > 0 ? _.offsetHeight : x;
2233
+ _ = document.createElement("div"), _.className = "playwright-highlight-label", _.style.position = "fixed", _.style.background = V, _.style.color = "white", _.style.padding = "1px 4px", _.style.borderRadius = "4px", _.style.fontSize = `${Math.min(12, Math.max(8, ie.height / 2))}px`, _.textContent = w.toString(), O = _.offsetWidth > 0 ? _.offsetWidth : O, x = _.offsetHeight > 0 ? _.offsetHeight : x;
2373
2234
  const de = ie.top + j.y, ue = ie.left + j.x;
2374
- let se = de + 2, re = ue + ie.width - D - 2;
2375
- (ie.width < D + 4 || ie.height < x + 4) && (se = de - x - 2, re = ue + ie.width - D, re < j.x && (re = ue)), se = Math.max(0, Math.min(se, window.innerHeight - x)), re = Math.max(0, Math.min(re, window.innerWidth - D)), _.style.top = `${se}px`, _.style.left = `${re}px`, ae.appendChild(_);
2235
+ let ae = de + 2, re = ue + ie.width - O - 2;
2236
+ (ie.width < O + 4 || ie.height < x + 4) && (ae = de - x - 2, re = ue + ie.width - O, re < j.x && (re = ue)), ae = Math.max(0, Math.min(ae, window.innerHeight - x)), re = Math.max(0, Math.min(re, window.innerWidth - O)), _.style.top = `${ae}px`, _.style.left = `${re}px`, se.appendChild(_);
2376
2237
  const le = ((H, U) => {
2377
2238
  let $ = 0;
2378
2239
  return (...X) => {
@@ -2386,53 +2247,53 @@ var dom_tree_default = (t = {
2386
2247
  x: 0,
2387
2248
  y: 0
2388
2249
  };
2389
- if (R) {
2390
- const $ = R.getBoundingClientRect();
2250
+ if (M) {
2251
+ const $ = M.getBoundingClientRect();
2391
2252
  U.x = $.left, U.y = $.top;
2392
2253
  }
2393
- if (w.forEach(($, X) => {
2254
+ if (v.forEach(($, X) => {
2394
2255
  if (X < H.length) {
2395
2256
  const q = H[X], oe = q.top + U.y, ne = q.left + U.x;
2396
2257
  $.element.style.top = `${oe}px`, $.element.style.left = `${ne}px`, $.element.style.width = `${q.width}px`, $.element.style.height = `${q.height}px`, $.element.style.display = q.width === 0 || q.height === 0 ? "none" : "block";
2397
2258
  } else $.element.style.display = "none";
2398
- }), H.length < w.length) for (let $ = H.length; $ < w.length; $++) w[$].element.style.display = "none";
2259
+ }), H.length < v.length) for (let $ = H.length; $ < v.length; $++) v[$].element.style.display = "none";
2399
2260
  if (_ && H.length > 0) {
2400
2261
  const $ = H[0], X = $.top + U.y, q = $.left + U.x;
2401
- let oe = X + 2, ne = q + $.width - D - 2;
2402
- ($.width < D + 4 || $.height < x + 4) && (oe = X - x - 2, ne = q + $.width - D, ne < U.x && (ne = q)), oe = Math.max(0, Math.min(oe, window.innerHeight - x)), ne = Math.max(0, Math.min(ne, window.innerWidth - D)), _.style.top = `${oe}px`, _.style.left = `${ne}px`, _.style.display = "block";
2262
+ let oe = X + 2, ne = q + $.width - O - 2;
2263
+ ($.width < O + 4 || $.height < x + 4) && (oe = X - x - 2, ne = q + $.width - O, ne < U.x && (ne = q)), oe = Math.max(0, Math.min(oe, window.innerHeight - x)), ne = Math.max(0, Math.min(ne, window.innerWidth - O)), _.style.top = `${oe}px`, _.style.left = `${ne}px`, _.style.display = "block";
2403
2264
  } else _ && (_.style.display = "none");
2404
2265
  }, 16);
2405
- return window.addEventListener("scroll", le, !0), window.addEventListener("resize", le), P = () => {
2406
- window.removeEventListener("scroll", le, !0), window.removeEventListener("resize", le), w.forEach((H) => H.element.remove()), _ && _.remove();
2407
- }, k.appendChild(ae), b + 1;
2266
+ return window.addEventListener("scroll", le, !0), window.addEventListener("resize", le), N = () => {
2267
+ window.removeEventListener("scroll", le, !0), window.removeEventListener("resize", le), v.forEach((H) => H.element.remove()), _ && _.remove();
2268
+ }, k.appendChild(se), w + 1;
2408
2269
  } finally {
2409
- P && (window._highlightCleanupFunctions = window._highlightCleanupFunctions || []).push(P);
2270
+ N && (window._highlightCleanupFunctions = window._highlightCleanupFunctions || []).push(N);
2410
2271
  }
2411
2272
  }
2412
- function v(l) {
2273
+ function y(l) {
2413
2274
  if (!l || l.nodeType !== Node.ELEMENT_NODE) return null;
2414
- const b = y(l);
2415
- if (!b) return null;
2416
- const R = b.display;
2417
- if (R === "inline" || R === "inline-block") return null;
2418
- const w = b.overflowX, _ = b.overflowY, D = b.scrollbarWidth && b.scrollbarWidth !== "auto" || b.scrollbarGutter && b.scrollbarGutter !== "auto", x = w === "auto" || w === "scroll", P = _ === "auto" || _ === "scroll";
2419
- if (!x && !P && !D) return null;
2275
+ const w = g(l);
2276
+ if (!w) return null;
2277
+ const M = w.display;
2278
+ if (M === "inline" || M === "inline-block") return null;
2279
+ const v = w.overflowX, _ = w.overflowY, O = w.scrollbarWidth && w.scrollbarWidth !== "auto" || w.scrollbarGutter && w.scrollbarGutter !== "auto", x = v === "auto" || v === "scroll", N = _ === "auto" || _ === "scroll";
2280
+ if (!x && !N && !O) return null;
2420
2281
  const k = l.scrollWidth - l.clientWidth, I = l.scrollHeight - l.clientHeight, Y = 4;
2421
- if (k < Y && I < Y || !P && !D && k < Y || !x && !D && I < Y) return null;
2282
+ if (k < Y && I < Y || !N && !O && k < Y || !x && !O && I < Y) return null;
2422
2283
  const V = l.scrollTop, K = l.scrollLeft, j = {
2423
2284
  top: V,
2424
2285
  right: l.scrollWidth - l.clientWidth - l.scrollLeft,
2425
2286
  bottom: l.scrollHeight - l.clientHeight - l.scrollTop,
2426
2287
  left: K
2427
2288
  };
2428
- return p(l, {
2289
+ return h(l, {
2429
2290
  scrollable: !0,
2430
2291
  scrollData: j
2431
2292
  }), j;
2432
2293
  }
2433
- function L(l) {
2294
+ function C(l) {
2434
2295
  try {
2435
- if (s === -1) {
2296
+ if (a === -1) {
2436
2297
  const x = l.parentElement;
2437
2298
  if (!x) return !1;
2438
2299
  try {
@@ -2445,34 +2306,34 @@ var dom_tree_default = (t = {
2445
2306
  return k.display !== "none" && k.visibility !== "hidden" && k.opacity !== "0";
2446
2307
  }
2447
2308
  }
2448
- const b = document.createRange();
2449
- b.selectNodeContents(l);
2450
- const R = b.getClientRects();
2451
- if (!R || R.length === 0) return !1;
2452
- let w = !1, _ = !1;
2453
- for (const x of R) if (x.width > 0 && x.height > 0 && (w = !0, !(x.bottom < -s || x.top > window.innerHeight + s || x.right < -s || x.left > window.innerWidth + s))) {
2309
+ const w = document.createRange();
2310
+ w.selectNodeContents(l);
2311
+ const M = w.getClientRects();
2312
+ if (!M || M.length === 0) return !1;
2313
+ let v = !1, _ = !1;
2314
+ for (const x of M) if (x.width > 0 && x.height > 0 && (v = !0, !(x.bottom < -a || x.top > window.innerHeight + a || x.right < -a || x.left > window.innerWidth + a))) {
2454
2315
  _ = !0;
2455
2316
  break;
2456
2317
  }
2457
- if (!w || !_) return !1;
2458
- const D = l.parentElement;
2459
- if (!D) return !1;
2318
+ if (!v || !_) return !1;
2319
+ const O = l.parentElement;
2320
+ if (!O) return !1;
2460
2321
  try {
2461
- return D.checkVisibility({
2322
+ return O.checkVisibility({
2462
2323
  checkOpacity: !0,
2463
2324
  checkVisibilityCSS: !0
2464
2325
  });
2465
2326
  } catch {
2466
- const P = window.getComputedStyle(D);
2467
- return P.display !== "none" && P.visibility !== "hidden" && P.opacity !== "0";
2327
+ const N = window.getComputedStyle(O);
2328
+ return N.display !== "none" && N.visibility !== "hidden" && N.opacity !== "0";
2468
2329
  }
2469
- } catch (b) {
2470
- return console.warn("Error checking text node visibility:", b), !1;
2330
+ } catch (w) {
2331
+ return console.warn("Error checking text node visibility:", w), !1;
2471
2332
  }
2472
2333
  }
2473
2334
  function S(l) {
2474
2335
  if (!l || !l.tagName) return !1;
2475
- const b = /* @__PURE__ */ new Set([
2336
+ const w = /* @__PURE__ */ new Set([
2476
2337
  "body",
2477
2338
  "div",
2478
2339
  "main",
@@ -2481,8 +2342,8 @@ var dom_tree_default = (t = {
2481
2342
  "nav",
2482
2343
  "header",
2483
2344
  "footer"
2484
- ]), R = l.tagName.toLowerCase();
2485
- return b.has(R) ? !0 : !(/* @__PURE__ */ new Set([
2345
+ ]), M = l.tagName.toLowerCase();
2346
+ return w.has(M) ? !0 : !(/* @__PURE__ */ new Set([
2486
2347
  "svg",
2487
2348
  "script",
2488
2349
  "style",
@@ -2490,16 +2351,16 @@ var dom_tree_default = (t = {
2490
2351
  "meta",
2491
2352
  "noscript",
2492
2353
  "template"
2493
- ])).has(R);
2354
+ ])).has(M);
2494
2355
  }
2495
2356
  function A(l) {
2496
- const b = y(l);
2497
- return l.offsetWidth > 0 && l.offsetHeight > 0 && b?.visibility !== "hidden" && b?.display !== "none";
2357
+ const w = g(l);
2358
+ return l.offsetWidth > 0 && l.offsetHeight > 0 && w?.visibility !== "hidden" && w?.display !== "none";
2498
2359
  }
2499
- function N(l) {
2360
+ function D(l) {
2500
2361
  if (!l || l.nodeType !== Node.ELEMENT_NODE || e.includes(l)) return !1;
2501
2362
  if (n.includes(l)) return !0;
2502
- const b = l.tagName.toLowerCase(), R = y(l), w = /* @__PURE__ */ new Set([
2363
+ const w = l.tagName.toLowerCase(), M = g(l), v = /* @__PURE__ */ new Set([
2503
2364
  "pointer",
2504
2365
  "move",
2505
2366
  "text",
@@ -2537,10 +2398,10 @@ var dom_tree_default = (t = {
2537
2398
  "initial",
2538
2399
  "inherit"
2539
2400
  ]);
2540
- function D(V) {
2541
- return V.tagName.toLowerCase() === "html" ? !1 : !!(R?.cursor && w.has(R.cursor));
2401
+ function O(V) {
2402
+ return V.tagName.toLowerCase() === "html" ? !1 : !!(M?.cursor && v.has(M.cursor));
2542
2403
  }
2543
- if (D(l)) return !0;
2404
+ if (O(l)) return !0;
2544
2405
  const x = /* @__PURE__ */ new Set([
2545
2406
  "a",
2546
2407
  "button",
@@ -2554,10 +2415,10 @@ var dom_tree_default = (t = {
2554
2415
  "optgroup",
2555
2416
  "fieldset",
2556
2417
  "legend"
2557
- ]), P = /* @__PURE__ */ new Set(["disabled", "readonly"]);
2558
- if (x.has(b)) {
2559
- if (R?.cursor && _.has(R.cursor)) return !1;
2560
- for (const V of P) if (l.hasAttribute(V) || l.getAttribute(V) === "true" || l.getAttribute(V) === "") return !1;
2418
+ ]), N = /* @__PURE__ */ new Set(["disabled", "readonly"]);
2419
+ if (x.has(w)) {
2420
+ if (M?.cursor && _.has(M.cursor)) return !1;
2421
+ for (const V of N) if (l.hasAttribute(V) || l.getAttribute(V) === "true" || l.getAttribute(V) === "") return !1;
2561
2422
  return !(l.disabled || l.readOnly || l.inert);
2562
2423
  }
2563
2424
  const k = l.getAttribute("role"), I = l.getAttribute("aria-role");
@@ -2582,7 +2443,7 @@ var dom_tree_default = (t = {
2582
2443
  "option",
2583
2444
  "scrollbar"
2584
2445
  ]);
2585
- if (x.has(b) || k && Y.has(k) || I && Y.has(I)) return !0;
2446
+ if (x.has(w) || k && Y.has(k) || I && Y.has(I)) return !0;
2586
2447
  try {
2587
2448
  if (typeof getEventListeners == "function") {
2588
2449
  const K = getEventListeners(l);
@@ -2607,7 +2468,7 @@ var dom_tree_default = (t = {
2607
2468
  "input",
2608
2469
  "focus",
2609
2470
  "blur"
2610
- ]) for (const ae of K) if (ae.type === j) return !0;
2471
+ ]) for (const se of K) if (se.type === j) return !0;
2611
2472
  }
2612
2473
  for (const K of [
2613
2474
  "onclick",
@@ -2617,26 +2478,26 @@ var dom_tree_default = (t = {
2617
2478
  ]) if (l.hasAttribute(K) || typeof l[K] == "function") return !0;
2618
2479
  } catch {
2619
2480
  }
2620
- return !!v(l);
2621
- }
2622
- function M(l) {
2623
- if (s === -1) return !0;
2624
- const b = T(l);
2625
- if (!b || b.length === 0) return !1;
2626
- let R = !1;
2627
- for (const x of b) if (x.width > 0 && x.height > 0 && !(x.bottom < -s || x.top > window.innerHeight + s || x.right < -s || x.left > window.innerWidth + s)) {
2628
- R = !0;
2481
+ return !!y(l);
2482
+ }
2483
+ function P(l) {
2484
+ if (a === -1) return !0;
2485
+ const w = E(l);
2486
+ if (!w || w.length === 0) return !1;
2487
+ let M = !1;
2488
+ for (const x of w) if (x.width > 0 && x.height > 0 && !(x.bottom < -a || x.top > window.innerHeight + a || x.right < -a || x.left > window.innerWidth + a)) {
2489
+ M = !0;
2629
2490
  break;
2630
2491
  }
2631
- if (!R) return !1;
2492
+ if (!M) return !1;
2632
2493
  if (l.ownerDocument !== window.document) return !0;
2633
- let w = Array.from(b).find((x) => x.width > 0 && x.height > 0);
2634
- if (!w) return !1;
2494
+ let v = Array.from(w).find((x) => x.width > 0 && x.height > 0);
2495
+ if (!v) return !1;
2635
2496
  const _ = l.getRootNode();
2636
2497
  if (_ instanceof ShadowRoot) {
2637
- const x = w.left + w.width / 2, P = w.top + w.height / 2;
2498
+ const x = v.left + v.width / 2, N = v.top + v.height / 2;
2638
2499
  try {
2639
- const k = _.elementFromPoint(x, P);
2500
+ const k = _.elementFromPoint(x, N);
2640
2501
  if (!k) return !1;
2641
2502
  let I = k;
2642
2503
  for (; I && I !== _; ) {
@@ -2648,23 +2509,23 @@ var dom_tree_default = (t = {
2648
2509
  return !0;
2649
2510
  }
2650
2511
  }
2651
- const D = 5;
2512
+ const O = 5;
2652
2513
  return [
2653
2514
  {
2654
- x: w.left + w.width / 2,
2655
- y: w.top + w.height / 2
2515
+ x: v.left + v.width / 2,
2516
+ y: v.top + v.height / 2
2656
2517
  },
2657
2518
  {
2658
- x: w.left + D,
2659
- y: w.top + D
2519
+ x: v.left + O,
2520
+ y: v.top + O
2660
2521
  },
2661
2522
  {
2662
- x: w.right - D,
2663
- y: w.bottom - D
2523
+ x: v.right - O,
2524
+ y: v.bottom - O
2664
2525
  }
2665
- ].some(({ x, y: P }) => {
2526
+ ].some(({ x, y: N }) => {
2666
2527
  try {
2667
- const k = document.elementFromPoint(x, P);
2528
+ const k = document.elementFromPoint(x, N);
2668
2529
  if (!k) return !1;
2669
2530
  let I = k;
2670
2531
  for (; I && I !== document.documentElement; ) {
@@ -2677,15 +2538,15 @@ var dom_tree_default = (t = {
2677
2538
  }
2678
2539
  });
2679
2540
  }
2680
- function O(l, b) {
2681
- if (b === -1) return !0;
2682
- const R = l.getClientRects();
2683
- if (!R || R.length === 0) {
2684
- const w = g(l);
2685
- return !w || w.width === 0 || w.height === 0 ? !1 : !(w.bottom < -b || w.top > window.innerHeight + b || w.right < -b || w.left > window.innerWidth + b);
2541
+ function R(l, w) {
2542
+ if (w === -1) return !0;
2543
+ const M = l.getClientRects();
2544
+ if (!M || M.length === 0) {
2545
+ const v = m(l);
2546
+ return !v || v.width === 0 || v.height === 0 ? !1 : !(v.bottom < -w || v.top > window.innerHeight + w || v.right < -w || v.left > window.innerWidth + w);
2686
2547
  }
2687
- for (const w of R)
2688
- if (!(w.width === 0 || w.height === 0) && !(w.bottom < -b || w.top > window.innerHeight + b || w.right < -b || w.left > window.innerWidth + b))
2548
+ for (const v of M)
2549
+ if (!(v.width === 0 || v.height === 0) && !(v.bottom < -w || v.top > window.innerHeight + w || v.right < -w || v.left > window.innerWidth + w))
2689
2550
  return !0;
2690
2551
  return !1;
2691
2552
  }
@@ -2705,12 +2566,12 @@ var dom_tree_default = (t = {
2705
2566
  "aria-autocomplete"
2706
2567
  ];
2707
2568
  function B(l) {
2708
- for (let b = 0; b < F.length; b++) if (l.hasAttribute(F[b])) return !0;
2569
+ for (let w = 0; w < F.length; w++) if (l.hasAttribute(F[w])) return !0;
2709
2570
  return !1;
2710
2571
  }
2711
2572
  function J(l) {
2712
2573
  if (!l || l.nodeType !== Node.ELEMENT_NODE) return !1;
2713
- const b = l.tagName.toLowerCase();
2574
+ const w = l.tagName.toLowerCase();
2714
2575
  return (/* @__PURE__ */ new Set([
2715
2576
  "a",
2716
2577
  "button",
@@ -2720,7 +2581,7 @@ var dom_tree_default = (t = {
2720
2581
  "details",
2721
2582
  "summary",
2722
2583
  "label"
2723
- ])).has(b) ? !0 : l.hasAttribute("onclick") || l.hasAttribute("role") || l.hasAttribute("tabindex") || B(l) || l.hasAttribute("data-action") || l.getAttribute("contenteditable") === "true";
2584
+ ])).has(w) ? !0 : l.hasAttribute("onclick") || l.hasAttribute("role") || l.hasAttribute("tabindex") || B(l) || l.hasAttribute("data-action") || l.getAttribute("contenteditable") === "true";
2724
2585
  }
2725
2586
  const G = /* @__PURE__ */ new Set([
2726
2587
  "a",
@@ -2757,18 +2618,18 @@ var dom_tree_default = (t = {
2757
2618
  ]);
2758
2619
  function ee(l) {
2759
2620
  if (!l || l.nodeType !== Node.ELEMENT_NODE || !A(l)) return !1;
2760
- const b = l.hasAttribute("role") || l.hasAttribute("tabindex") || l.hasAttribute("onclick") || typeof l.onclick == "function", R = /\b(btn|clickable|menu|item|entry|link)\b/i.test(l.className || ""), w = !!l.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'), _ = [...l.children].some(A), D = l.parentElement && l.parentElement.isSameNode(document.body);
2761
- return (N(l) || b || R) && _ && w && !D;
2621
+ const w = l.hasAttribute("role") || l.hasAttribute("tabindex") || l.hasAttribute("onclick") || typeof l.onclick == "function", M = /\b(btn|clickable|menu|item|entry|link)\b/i.test(l.className || ""), v = !!l.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'), _ = [...l.children].some(A), O = l.parentElement && l.parentElement.isSameNode(document.body);
2622
+ return (D(l) || w || M) && _ && v && !O;
2762
2623
  }
2763
2624
  function te(l) {
2764
2625
  if (!l || l.nodeType !== Node.ELEMENT_NODE) return !1;
2765
- const b = l.tagName.toLowerCase(), R = l.getAttribute("role");
2766
- if (b === "iframe" || G.has(b) || R && Q.has(R) || l.isContentEditable || l.getAttribute("contenteditable") === "true" || l.hasAttribute("data-testid") || l.hasAttribute("data-cy") || l.hasAttribute("data-test") || l.hasAttribute("onclick") || typeof l.onclick == "function" || B(l)) return !0;
2626
+ const w = l.tagName.toLowerCase(), M = l.getAttribute("role");
2627
+ if (w === "iframe" || G.has(w) || M && Q.has(M) || l.isContentEditable || l.getAttribute("contenteditable") === "true" || l.hasAttribute("data-testid") || l.hasAttribute("data-cy") || l.hasAttribute("data-test") || l.hasAttribute("onclick") || typeof l.onclick == "function" || B(l)) return !0;
2767
2628
  try {
2768
- const w = l?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
2769
- if (typeof w == "function") {
2770
- const _ = w(l);
2771
- for (const D of [
2629
+ const v = l?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
2630
+ if (typeof v == "function") {
2631
+ const _ = v(l);
2632
+ for (const O of [
2772
2633
  "click",
2773
2634
  "mousedown",
2774
2635
  "mouseup",
@@ -2779,7 +2640,7 @@ var dom_tree_default = (t = {
2779
2640
  "input",
2780
2641
  "focus",
2781
2642
  "blur"
2782
- ]) for (const x of _) if (x.type === D) return !0;
2643
+ ]) for (const x of _) if (x.type === O) return !0;
2783
2644
  }
2784
2645
  if ([
2785
2646
  "onmousedown",
@@ -2796,13 +2657,13 @@ var dom_tree_default = (t = {
2796
2657
  }
2797
2658
  return !!(ee(l) || u.get(l)?.scrollable);
2798
2659
  }
2799
- function W(l, b, R, w) {
2660
+ function W(l, w, M, v) {
2800
2661
  if (!l.isInteractive) return !1;
2801
2662
  let _ = !1;
2802
- return w ? te(b) ? _ = !0 : _ = !1 : _ = !0, _ && (l.isInViewport = O(b, s), (l.isInViewport || s === -1) && (l.highlightIndex = d++, o)) ? (a >= 0 ? a === l.highlightIndex && E(b, l.highlightIndex, R) : E(b, l.highlightIndex, R), !0) : !1;
2663
+ return v ? te(w) ? _ = !0 : _ = !1 : _ = !0, _ && (l.isInViewport = R(w, a), (l.isInViewport || a === -1) && (l.highlightIndex = d++, o)) ? (s >= 0 ? s === l.highlightIndex && T(w, l.highlightIndex, M) : T(w, l.highlightIndex, M), !0) : !1;
2803
2664
  }
2804
- function Z(l, b = null, R = !1) {
2805
- if (!l || l.id === m || l.nodeType !== Node.ELEMENT_NODE && l.nodeType !== Node.TEXT_NODE || !l || l.id === m || l.dataset?.browserUseIgnore === "true" || l.dataset?.pageAgentIgnore === "true" || l.getAttribute && l.getAttribute("aria-hidden") === "true") return null;
2665
+ function Z(l, w = null, M = !1) {
2666
+ if (!l || l.id === b || l.nodeType !== Node.ELEMENT_NODE && l.nodeType !== Node.TEXT_NODE || !l || l.id === b || l.dataset?.browserUseIgnore === "true" || l.dataset?.pageAgentIgnore === "true" || l.getAttribute && l.getAttribute("aria-hidden") === "true") return null;
2806
2667
  if (l === document.body) {
2807
2668
  const x = {
2808
2669
  tagName: "body",
@@ -2811,31 +2672,31 @@ var dom_tree_default = (t = {
2811
2672
  children: []
2812
2673
  };
2813
2674
  for (const k of l.childNodes) {
2814
- const I = Z(k, b, !1);
2675
+ const I = Z(k, w, !1);
2815
2676
  I && x.children.push(I);
2816
2677
  }
2817
- const P = `${f.current++}`;
2818
- return C[P] = x, P;
2678
+ const N = `${f.current++}`;
2679
+ return L[N] = x, N;
2819
2680
  }
2820
2681
  if (l.nodeType !== Node.ELEMENT_NODE && l.nodeType !== Node.TEXT_NODE) return null;
2821
2682
  if (l.nodeType === Node.TEXT_NODE) {
2822
2683
  const x = l.textContent?.trim();
2823
2684
  if (!x) return null;
2824
- const P = l.parentElement;
2825
- if (!P || P.tagName.toLowerCase() === "script") return null;
2685
+ const N = l.parentElement;
2686
+ if (!N || N.tagName.toLowerCase() === "script") return null;
2826
2687
  const k = `${f.current++}`;
2827
- return C[k] = {
2688
+ return L[k] = {
2828
2689
  type: "TEXT_NODE",
2829
2690
  text: x,
2830
- isVisible: L(l)
2691
+ isVisible: C(l)
2831
2692
  }, k;
2832
2693
  }
2833
2694
  if (l.nodeType === Node.ELEMENT_NODE && !S(l)) return null;
2834
- if (s !== -1 && !l.shadowRoot) {
2835
- const x = g(l), P = y(l), k = P && (P.position === "fixed" || P.position === "sticky"), I = l.offsetWidth > 0 || l.offsetHeight > 0;
2836
- if (!x || !k && !I && (x.bottom < -s || x.top > window.innerHeight + s || x.right < -s || x.left > window.innerWidth + s)) return null;
2695
+ if (a !== -1 && !l.shadowRoot) {
2696
+ const x = m(l), N = g(l), k = N && (N.position === "fixed" || N.position === "sticky"), I = l.offsetWidth > 0 || l.offsetHeight > 0;
2697
+ if (!x || !k && !I && (x.bottom < -a || x.top > window.innerHeight + a || x.right < -a || x.left > window.innerWidth + a)) return null;
2837
2698
  }
2838
- const w = {
2699
+ const v = {
2839
2700
  tagName: l.tagName.toLowerCase(),
2840
2701
  attributes: {},
2841
2702
  /**
@@ -2845,65 +2706,65 @@ var dom_tree_default = (t = {
2845
2706
  };
2846
2707
  if (J(l) || l.tagName.toLowerCase() === "iframe" || l.tagName.toLowerCase() === "body") {
2847
2708
  const x = l.getAttributeNames?.() || [];
2848
- for (const P of x) {
2849
- const k = l.getAttribute(P);
2850
- w.attributes[P] = k;
2709
+ for (const N of x) {
2710
+ const k = l.getAttribute(N);
2711
+ v.attributes[N] = k;
2851
2712
  }
2852
- l.tagName.toLowerCase() === "input" && (l.type === "checkbox" || l.type === "radio") && (w.attributes.checked = l.checked ? "true" : "false");
2713
+ l.tagName.toLowerCase() === "input" && (l.type === "checkbox" || l.type === "radio") && (v.attributes.checked = l.checked ? "true" : "false");
2853
2714
  }
2854
2715
  let _ = !1;
2855
- if (l.nodeType === Node.ELEMENT_NODE && (w.isVisible = A(l), w.isVisible)) {
2856
- w.isTopElement = M(l);
2857
- const x = l.getAttribute("role"), P = x === "menu" || x === "menubar" || x === "listbox";
2858
- if ((w.isTopElement || P) && (w.isInteractive = N(l), _ = W(w, l, b, R), w.ref = l, w.isInteractive && Object.keys(w.attributes).length === 0)) {
2716
+ if (l.nodeType === Node.ELEMENT_NODE && (v.isVisible = A(l), v.isVisible)) {
2717
+ v.isTopElement = P(l);
2718
+ const x = l.getAttribute("role"), N = x === "menu" || x === "menubar" || x === "listbox";
2719
+ if ((v.isTopElement || N) && (v.isInteractive = D(l), _ = W(v, l, w, M), v.ref = l, v.isInteractive && Object.keys(v.attributes).length === 0)) {
2859
2720
  const k = l.getAttributeNames?.() || [];
2860
2721
  for (const I of k) {
2861
2722
  const Y = l.getAttribute(I);
2862
- w.attributes[I] = Y;
2723
+ v.attributes[I] = Y;
2863
2724
  }
2864
2725
  }
2865
2726
  }
2866
2727
  if (l.tagName) {
2867
2728
  const x = l.tagName.toLowerCase();
2868
2729
  if (x === "iframe") try {
2869
- const P = l.contentDocument || l.contentWindow?.document;
2870
- if (P) for (const k of P.childNodes) {
2730
+ const N = l.contentDocument || l.contentWindow?.document;
2731
+ if (N) for (const k of N.childNodes) {
2871
2732
  const I = Z(k, l, !1);
2872
- I && w.children.push(I);
2733
+ I && v.children.push(I);
2873
2734
  }
2874
- } catch (P) {
2875
- console.warn("Unable to access iframe:", P);
2735
+ } catch (N) {
2736
+ console.warn("Unable to access iframe:", N);
2876
2737
  }
2877
- else if (l.isContentEditable || l.getAttribute("contenteditable") === "true" || l.id === "tinymce" || l.classList.contains("mce-content-body") || x === "body" && l.getAttribute("data-id")?.startsWith("mce_")) for (const P of l.childNodes) {
2878
- const k = Z(P, b, _);
2879
- k && w.children.push(k);
2738
+ else if (l.isContentEditable || l.getAttribute("contenteditable") === "true" || l.id === "tinymce" || l.classList.contains("mce-content-body") || x === "body" && l.getAttribute("data-id")?.startsWith("mce_")) for (const N of l.childNodes) {
2739
+ const k = Z(N, w, _);
2740
+ k && v.children.push(k);
2880
2741
  }
2881
2742
  else {
2882
2743
  if (l.shadowRoot) {
2883
- w.shadowRoot = !0;
2884
- for (const P of l.shadowRoot.childNodes) {
2885
- const k = Z(P, b, _);
2886
- k && w.children.push(k);
2744
+ v.shadowRoot = !0;
2745
+ for (const N of l.shadowRoot.childNodes) {
2746
+ const k = Z(N, w, _);
2747
+ k && v.children.push(k);
2887
2748
  }
2888
2749
  }
2889
- for (const P of l.childNodes) {
2890
- const k = Z(P, b, _ || R);
2891
- k && w.children.push(k);
2750
+ for (const N of l.childNodes) {
2751
+ const k = Z(N, w, _ || M);
2752
+ k && v.children.push(k);
2892
2753
  }
2893
2754
  }
2894
2755
  }
2895
- if (w.tagName === "a" && w.children.length === 0 && !w.attributes.href) {
2896
- const x = g(l);
2756
+ if (v.tagName === "a" && v.children.length === 0 && !v.attributes.href) {
2757
+ const x = m(l);
2897
2758
  if (!(x && x.width > 0 && x.height > 0 || l.offsetWidth > 0 || l.offsetHeight > 0)) return null;
2898
2759
  }
2899
- w.extra = u.get(l) || null;
2900
- const D = `${f.current++}`;
2901
- return C[D] = w, D;
2760
+ v.extra = u.get(l) || null;
2761
+ const O = `${f.current++}`;
2762
+ return L[O] = v, O;
2902
2763
  }
2903
2764
  const ce = Z(document.body);
2904
- return h.clearCache(), {
2765
+ return p.clearCache(), {
2905
2766
  rootId: ce,
2906
- map: C
2767
+ map: L
2907
2768
  };
2908
2769
  }, DEFAULT_VIEWPORT_EXPANSION = -1;
2909
2770
  function resolveViewportExpansion(t) {
@@ -2919,9 +2780,9 @@ var SEMANTIC_TAGS = /* @__PURE__ */ new Set([
2919
2780
  ]), newElementsCache = /* @__PURE__ */ new WeakMap();
2920
2781
  function getFlatTree(t) {
2921
2782
  const e = resolveViewportExpansion(t.viewportExpansion), n = [];
2922
- for (const a of t.interactiveBlacklist || []) typeof a == "function" ? n.push(a()) : n.push(a);
2783
+ for (const s of t.interactiveBlacklist || []) typeof s == "function" ? n.push(s()) : n.push(s);
2923
2784
  const i = [];
2924
- for (const a of t.interactiveWhitelist || []) typeof a == "function" ? i.push(a()) : i.push(a);
2785
+ for (const s of t.interactiveWhitelist || []) typeof s == "function" ? i.push(s()) : i.push(s);
2925
2786
  const r = dom_tree_default({
2926
2787
  doHighlightElements: !0,
2927
2788
  debugMode: !0,
@@ -2932,11 +2793,11 @@ function getFlatTree(t) {
2932
2793
  highlightOpacity: t.highlightOpacity ?? 0,
2933
2794
  highlightLabelOpacity: t.highlightLabelOpacity ?? 0.1
2934
2795
  }), o = window.location.href;
2935
- for (const a in r.map) {
2936
- const s = r.map[a];
2937
- if (s.isInteractive && s.ref) {
2938
- const c = s.ref;
2939
- newElementsCache.has(c) || (newElementsCache.set(c, o), s.isNew = !0);
2796
+ for (const s in r.map) {
2797
+ const a = r.map[s];
2798
+ if (a.isInteractive && a.ref) {
2799
+ const c = a.ref;
2800
+ newElementsCache.has(c) || (newElementsCache.set(c, o), a.isNew = !0);
2940
2801
  }
2941
2802
  }
2942
2803
  return r;
@@ -2983,106 +2844,106 @@ function flatTreeToString(t, e = [], n = !1) {
2983
2844
  "aria-controls",
2984
2845
  "aria-owns",
2985
2846
  "contenteditable"
2986
- ], r = [...e, ...i], o = (h, g) => h.length > g ? h.substring(0, g) + "..." : h, a = (h) => {
2987
- const g = t.map[h];
2988
- if (!g) return null;
2989
- if (g.type === "TEXT_NODE") {
2990
- const y = g;
2847
+ ], r = [...e, ...i], o = (p, m) => p.length > m ? p.substring(0, m) + "..." : p, s = (p) => {
2848
+ const m = t.map[p];
2849
+ if (!m) return null;
2850
+ if (m.type === "TEXT_NODE") {
2851
+ const g = m;
2991
2852
  return {
2992
2853
  type: "text",
2993
- text: y.text,
2994
- isVisible: y.isVisible,
2854
+ text: g.text,
2855
+ isVisible: g.isVisible,
2995
2856
  parent: null,
2996
2857
  children: []
2997
2858
  };
2998
2859
  } else {
2999
- const y = g, T = [];
3000
- if (y.children) for (const C of y.children) {
3001
- const f = a(C);
3002
- f && (f.parent = null, T.push(f));
2860
+ const g = m, E = [];
2861
+ if (g.children) for (const L of g.children) {
2862
+ const f = s(L);
2863
+ f && (f.parent = null, E.push(f));
3003
2864
  }
3004
2865
  return {
3005
2866
  type: "element",
3006
- tagName: y.tagName,
3007
- attributes: y.attributes ?? {},
3008
- isVisible: y.isVisible ?? !1,
3009
- isInteractive: y.isInteractive ?? !1,
3010
- isTopElement: y.isTopElement ?? !1,
3011
- isNew: y.isNew ?? !1,
3012
- highlightIndex: y.highlightIndex,
2867
+ tagName: g.tagName,
2868
+ attributes: g.attributes ?? {},
2869
+ isVisible: g.isVisible ?? !1,
2870
+ isInteractive: g.isInteractive ?? !1,
2871
+ isTopElement: g.isTopElement ?? !1,
2872
+ isNew: g.isNew ?? !1,
2873
+ highlightIndex: g.highlightIndex,
3013
2874
  parent: null,
3014
- children: T,
3015
- extra: y.extra ?? {}
2875
+ children: E,
2876
+ extra: g.extra ?? {}
3016
2877
  };
3017
2878
  }
3018
- }, s = (h, g = null) => {
3019
- h.parent = g;
3020
- for (const y of h.children) s(y, h);
3021
- }, c = a(t.rootId);
2879
+ }, a = (p, m = null) => {
2880
+ p.parent = m;
2881
+ for (const g of p.children) a(g, p);
2882
+ }, c = s(t.rootId);
3022
2883
  if (!c) return "";
3023
- s(c);
3024
- const d = (h) => {
3025
- let g = h.parent;
3026
- for (; g; ) {
3027
- if (g.type === "element" && g.highlightIndex !== void 0) return !0;
3028
- g = g.parent;
2884
+ a(c);
2885
+ const d = (p) => {
2886
+ let m = p.parent;
2887
+ for (; m; ) {
2888
+ if (m.type === "element" && m.highlightIndex !== void 0) return !0;
2889
+ m = m.parent;
3029
2890
  }
3030
2891
  return !1;
3031
- }, u = (h, g, y) => {
3032
- let T = g;
3033
- const C = " ".repeat(g);
3034
- if (h.type === "element") {
3035
- const f = n && h.tagName && SEMANTIC_TAGS.has(h.tagName);
3036
- if (h.highlightIndex !== void 0) {
3037
- T += 1;
3038
- const v = getAllTextTillNextClickableElement(h);
3039
- let L = "";
3040
- if (r.length > 0 && h.attributes) {
3041
- const A = matchAttributes(h.attributes, r), N = Object.keys(A);
3042
- if (N.length > 1) {
3043
- const M = /* @__PURE__ */ new Set(), O = {};
3044
- for (const F of N) {
2892
+ }, u = (p, m, g) => {
2893
+ let E = m;
2894
+ const L = " ".repeat(m);
2895
+ if (p.type === "element") {
2896
+ const f = n && p.tagName && SEMANTIC_TAGS.has(p.tagName);
2897
+ if (p.highlightIndex !== void 0) {
2898
+ E += 1;
2899
+ const y = getAllTextTillNextClickableElement(p);
2900
+ let C = "";
2901
+ if (r.length > 0 && p.attributes) {
2902
+ const A = matchAttributes(p.attributes, r), D = Object.keys(A);
2903
+ if (D.length > 1) {
2904
+ const P = /* @__PURE__ */ new Set(), R = {};
2905
+ for (const F of D) {
3045
2906
  const B = A[F];
3046
- B.length > 5 && (B in O ? M.add(F) : O[B] = F);
2907
+ B.length > 5 && (B in R ? P.add(F) : R[B] = F);
3047
2908
  }
3048
- for (const F of M) delete A[F];
2909
+ for (const F of P) delete A[F];
3049
2910
  }
3050
- A.role === h.tagName && delete A.role;
3051
- for (const M of [
2911
+ A.role === p.tagName && delete A.role;
2912
+ for (const P of [
3052
2913
  "aria-label",
3053
2914
  "placeholder",
3054
2915
  "title"
3055
- ]) A[M] && A[M].toLowerCase().trim() === v.toLowerCase().trim() && delete A[M];
3056
- Object.keys(A).length > 0 && (L = Object.entries(A).map(([M, O]) => `${M}=${o(O, 20)}`).join(" "));
2916
+ ]) A[P] && A[P].toLowerCase().trim() === y.toLowerCase().trim() && delete A[P];
2917
+ Object.keys(A).length > 0 && (C = Object.entries(A).map(([P, R]) => `${P}=${o(R, 20)}`).join(" "));
3057
2918
  }
3058
- let S = `${C}${h.isNew ? `*[${h.highlightIndex}]` : `[${h.highlightIndex}]`}<${h.tagName ?? ""}`;
3059
- if (L && (S += ` ${L}`), h.extra && h.extra.scrollable) {
2919
+ let S = `${L}${p.isNew ? `*[${p.highlightIndex}]` : `[${p.highlightIndex}]`}<${p.tagName ?? ""}`;
2920
+ if (C && (S += ` ${C}`), p.extra && p.extra.scrollable) {
3060
2921
  let A = "";
3061
- h.extra.scrollData?.left && (A += `left=${h.extra.scrollData.left}, `), h.extra.scrollData?.top && (A += `top=${h.extra.scrollData.top}, `), h.extra.scrollData?.right && (A += `right=${h.extra.scrollData.right}, `), h.extra.scrollData?.bottom && (A += `bottom=${h.extra.scrollData.bottom}`), S += ` data-scrollable="${A}"`;
2922
+ p.extra.scrollData?.left && (A += `left=${p.extra.scrollData.left}, `), p.extra.scrollData?.top && (A += `top=${p.extra.scrollData.top}, `), p.extra.scrollData?.right && (A += `right=${p.extra.scrollData.right}, `), p.extra.scrollData?.bottom && (A += `bottom=${p.extra.scrollData.bottom}`), S += ` data-scrollable="${A}"`;
3062
2923
  }
3063
- if (v) {
3064
- const A = v.trim();
3065
- L || (S += " "), S += `>${A}`;
3066
- } else L || (S += " ");
3067
- S += " />", y.push(S);
2924
+ if (y) {
2925
+ const A = y.trim();
2926
+ C || (S += " "), S += `>${A}`;
2927
+ } else C || (S += " ");
2928
+ S += " />", g.push(S);
3068
2929
  }
3069
- const m = f && h.highlightIndex === void 0, E = m ? y.length : -1;
3070
- m && (y.push(`${C}<${h.tagName}>`), T += 1);
3071
- for (const v of h.children) u(v, T, y);
3072
- m && (y.length === E + 1 ? y.pop() : y.push(`${C}</${h.tagName}>`));
3073
- } else if (h.type === "text") {
3074
- if (d(h)) return;
3075
- h.parent && h.parent.type === "element" && h.parent.isVisible && h.parent.isTopElement && y.push(`${C}${h.text ?? ""}`);
2930
+ const b = f && p.highlightIndex === void 0, T = b ? g.length : -1;
2931
+ b && (g.push(`${L}<${p.tagName}>`), E += 1);
2932
+ for (const y of p.children) u(y, E, g);
2933
+ b && (g.length === T + 1 ? g.pop() : g.push(`${L}</${p.tagName}>`));
2934
+ } else if (p.type === "text") {
2935
+ if (d(p)) return;
2936
+ p.parent && p.parent.type === "element" && p.parent.isVisible && p.parent.isTopElement && g.push(`${L}${p.text ?? ""}`);
3076
2937
  }
3077
- }, p = [];
3078
- return u(c, 0, p), p.join(`
2938
+ }, h = [];
2939
+ return u(c, 0, h), h.join(`
3079
2940
  `);
3080
2941
  }
3081
2942
  var getAllTextTillNextClickableElement = (t, e = -1) => {
3082
2943
  const n = [], i = (r, o) => {
3083
2944
  if (!(e !== -1 && o > e) && !(r.type === "element" && r !== t && r.highlightIndex !== void 0)) {
3084
2945
  if (r.type === "text" && r.text) n.push(r.text);
3085
- else if (r.type === "element") for (const a of r.children) i(a, o + 1);
2946
+ else if (r.type === "element") for (const s of r.children) i(s, o + 1);
3086
2947
  }
3087
2948
  };
3088
2949
  return i(t, 0), n.join(`
@@ -3133,7 +2994,7 @@ else {
3133
2994
  }, 500);
3134
2995
  }
3135
2996
  function getPageInfo() {
3136
- const t = window.innerWidth, e = window.innerHeight, n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth || 0), i = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight || 0), r = window.scrollX || window.pageXOffset || document.documentElement.scrollLeft || 0, o = window.scrollY || window.pageYOffset || document.documentElement.scrollTop || 0, a = Math.max(0, i - (window.innerHeight + o)), s = Math.max(0, n - (window.innerWidth + r));
2997
+ const t = window.innerWidth, e = window.innerHeight, n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth || 0), i = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight || 0), r = window.scrollX || window.pageXOffset || document.documentElement.scrollLeft || 0, o = window.scrollY || window.pageYOffset || document.documentElement.scrollTop || 0, s = Math.max(0, i - (window.innerHeight + o)), a = Math.max(0, n - (window.innerWidth + r));
3137
2998
  return {
3138
2999
  viewport_width: t,
3139
3000
  viewport_height: e,
@@ -3142,13 +3003,13 @@ function getPageInfo() {
3142
3003
  scroll_x: r,
3143
3004
  scroll_y: o,
3144
3005
  pixels_above: o,
3145
- pixels_below: a,
3006
+ pixels_below: s,
3146
3007
  pages_above: e > 0 ? o / e : 0,
3147
- pages_below: e > 0 ? a / e : 0,
3008
+ pages_below: e > 0 ? s / e : 0,
3148
3009
  total_pages: e > 0 ? i / e : 0,
3149
3010
  current_page_position: o / Math.max(1, i - e),
3150
3011
  pixels_left: r,
3151
- pixels_right: s
3012
+ pixels_right: a
3152
3013
  };
3153
3014
  }
3154
3015
  function patchReact(t) {
@@ -3186,7 +3047,7 @@ var PageController = class extends EventTarget {
3186
3047
  */
3187
3048
  initMask() {
3188
3049
  this.maskReady === null && (this.maskReady = (async () => {
3189
- const { SimulatorMask: t } = await import("./SimulatorMask-BHVXyogh-CARX3Rff.js");
3050
+ const { SimulatorMask: t } = await import("./SimulatorMask-BHVXyogh-CKmEDsYG.js");
3190
3051
  this.mask = new t();
3191
3052
  })());
3192
3053
  }
@@ -3383,11 +3244,6 @@ ${n.pixels_above > 4 && i !== -1 ? `... ${n.pixels_above} pixels above (${n.page
3383
3244
  const DEFAULT_ERROR_SELECTORS = [
3384
3245
  '[role="alert"]',
3385
3246
  '[aria-invalid="true"]',
3386
- ".ti3-unifyvalid-error",
3387
- ".ti3-error",
3388
- ".ti-error",
3389
- ".lego-text-error",
3390
- ".lego-error",
3391
3247
  ".el-form-item__error",
3392
3248
  ".ant-form-item-explain-error",
3393
3249
  ".is-invalid",
@@ -3403,9 +3259,6 @@ const DEFAULT_ERROR_SELECTORS = [
3403
3259
  ".validate-error",
3404
3260
  ".valid-error"
3405
3261
  ], DEFAULT_WARNING_SELECTORS = [
3406
- ".ti3-warning",
3407
- ".ti-warning",
3408
- ".lego-text-warning",
3409
3262
  ".warning-msg",
3410
3263
  ".warning-text",
3411
3264
  ".is-warning",
@@ -3414,9 +3267,6 @@ const DEFAULT_ERROR_SELECTORS = [
3414
3267
  // W3C ARIA 标准
3415
3268
  '[role="dialog"]',
3416
3269
  '[role="alertdialog"]',
3417
- // Tiny3 / Lego(云控制台)
3418
- '[class*="ti3-modal"]',
3419
- '[class*="ti3-message-box"]',
3420
3270
  // Element UI / Element Plus
3421
3271
  '[class*="el-dialog"]',
3422
3272
  '[class*="el-message-box"]',
@@ -3428,6 +3278,21 @@ const DEFAULT_ERROR_SELECTORS = [
3428
3278
  '[class*="v-dialog"]',
3429
3279
  // Naive UI
3430
3280
  '[class*="n-modal"]'
3281
+ ], DEFAULT_TOOLTIP_SELECTORS = [
3282
+ // W3C ARIA 标准
3283
+ '[role="tooltip"]',
3284
+ // Element Plus
3285
+ '[class*="el-tooltip-popper"]',
3286
+ '[class*="el-popper"]',
3287
+ // Ant Design
3288
+ '[class*="ant-tooltip"]',
3289
+ '[class*="ant-popover"]',
3290
+ // Naive UI
3291
+ '[class*="n-tooltip"]',
3292
+ '[class*="n-popover"]',
3293
+ // Vuetify
3294
+ '[class*="v-tooltip"]',
3295
+ '[class*="v-menu"]'
3431
3296
  ], TAG_ROLE_MAP = {
3432
3297
  a: "link",
3433
3298
  article: "article",
@@ -3490,7 +3355,7 @@ const DEFAULT_ERROR_SELECTORS = [
3490
3355
  time: "time",
3491
3356
  tr: "row",
3492
3357
  ul: "list"
3493
- }, INPUT_TYPE_ROLE = {
3358
+ }, DEFAULT_ROLE_OVERRIDES = [], INPUT_TYPE_ROLE = {
3494
3359
  button: "button",
3495
3360
  checkbox: "checkbox",
3496
3361
  color: "textbox",
@@ -3535,7 +3400,15 @@ function defaultSelectedMatch(t) {
3535
3400
  return ["button", "option", "a", "li", "generic"].includes(n) || n.startsWith("tab");
3536
3401
  }
3537
3402
  const DEFAULT_A11Y_CONFIG = markResolved({
3538
- roles: [],
3403
+ // 框架级 role 覆盖:Tiny3 Tabs、tp-helptip 等非标准 UI 组件(规则定义见 constants.ts)
3404
+ // + dialog/tooltip 选择器转为 role 规则,统一走 roles 通道做 role 推断与 DOM 检测
3405
+ roles: [
3406
+ ...DEFAULT_ROLE_OVERRIDES,
3407
+ // Dialog:补齐缺失的 role="dialog"(如 Tiny3 ti3-modal、Element Plus el-dialog)
3408
+ ...DEFAULT_DIALOG_SELECTORS.map((t) => ({ selector: t, role: "dialog" })),
3409
+ // Tooltip:补齐缺失的 role="tooltip"(如 Tiny3 ti3-tooltip、Element Plus el-tooltip-popper)
3410
+ ...DEFAULT_TOOLTIP_SELECTORS.map((t) => ({ selector: t, role: "tooltip" }))
3411
+ ],
3539
3412
  states: {
3540
3413
  selected: [
3541
3414
  { match: defaultSelectedMatch },
@@ -3548,12 +3421,17 @@ const DEFAULT_A11Y_CONFIG = markResolved({
3548
3421
  },
3549
3422
  whitelist: [],
3550
3423
  blacklist: [],
3551
- exposedAttributes: [],
3552
- dialogSelectors: DEFAULT_DIALOG_SELECTORS
3424
+ exposedAttributes: []
3553
3425
  });
3554
3426
  function normalizeSelector(t) {
3555
3427
  return t && (Array.isArray(t) ? t.filter(Boolean).join(", ") : t) || void 0;
3556
3428
  }
3429
+ function getSelectorsForRole(t, e) {
3430
+ const n = [];
3431
+ for (const i of t)
3432
+ i.role !== e || !i.selector || (Array.isArray(i.selector) ? n.push(...i.selector.filter(Boolean)) : n.push(i.selector));
3433
+ return n;
3434
+ }
3557
3435
  function matchesRule(t, e) {
3558
3436
  if (e.match)
3559
3437
  try {
@@ -3610,8 +3488,7 @@ function mergeA11yConfigs(t, e) {
3610
3488
  states: mergeStates(t.states, e.states),
3611
3489
  whitelist: concatArr(t.whitelist, e.whitelist),
3612
3490
  blacklist: concatArr(t.blacklist, e.blacklist),
3613
- exposedAttributes: concatArr(t.exposedAttributes, e.exposedAttributes),
3614
- dialogSelectors: concatArr(t.dialogSelectors, e.dialogSelectors)
3491
+ exposedAttributes: concatArr(t.exposedAttributes, e.exposedAttributes)
3615
3492
  });
3616
3493
  }
3617
3494
  function mergeA11yConfig(t) {
@@ -3637,63 +3514,63 @@ function computeRole(t, e) {
3637
3514
  return TAG_ROLE_MAP[r] ?? "generic";
3638
3515
  }
3639
3516
  function computeStates(t, e) {
3640
- const n = [], i = (m) => t.getAttribute(m), r = e.states, o = (m) => matchesAnyRule(t, r[m]), a = i("aria-checked");
3641
- if (a === "true")
3517
+ const n = [], i = (b) => t.getAttribute(b), r = e.states, o = (b) => matchesAnyRule(t, r[b]), s = i("aria-checked");
3518
+ if (s === "true")
3642
3519
  n.push("checked");
3643
- else if (a === "mixed")
3520
+ else if (s === "mixed")
3644
3521
  n.push("checked=mixed");
3645
- else if (a === "false")
3522
+ else if (s === "false")
3646
3523
  n.push("unchecked");
3647
3524
  else {
3648
- const m = t.tagName.toLowerCase();
3649
- let E;
3650
- if (m === "input" && (t.type === "checkbox" || t.type === "radio"))
3651
- E = t.checked;
3652
- else if (m === "label" && t.hasAttribute("for")) {
3653
- const v = document.getElementById(t.getAttribute("for"));
3654
- v instanceof HTMLInputElement && (v.type === "checkbox" || v.type === "radio") && (E = v.checked);
3525
+ const b = t.tagName.toLowerCase();
3526
+ let T;
3527
+ if (b === "input" && (t.type === "checkbox" || t.type === "radio"))
3528
+ T = t.checked;
3529
+ else if (b === "label" && t.hasAttribute("for")) {
3530
+ const y = document.getElementById(t.getAttribute("for"));
3531
+ y instanceof HTMLInputElement && (y.type === "checkbox" || y.type === "radio") && (T = y.checked);
3655
3532
  }
3656
- E !== void 0 ? n.push(E ? "checked" : "unchecked") : o("checked") && n.push("checked");
3533
+ T !== void 0 ? n.push(T ? "checked" : "unchecked") : o("checked") && n.push("checked");
3657
3534
  }
3658
3535
  (i("aria-selected") === "true" || o("selected")) && n.push("selected");
3659
- const s = i("aria-pressed");
3660
- s === "true" ? n.push("pressed") : s === "mixed" ? n.push("pressed=mixed") : s !== "false" && o("pressed") && n.push("pressed");
3536
+ const a = i("aria-pressed");
3537
+ a === "true" ? n.push("pressed") : a === "mixed" ? n.push("pressed=mixed") : a !== "false" && o("pressed") && n.push("pressed");
3661
3538
  const c = i("aria-current");
3662
3539
  c && c !== "false" ? n.push(c === "true" ? "current" : `current=${c}`) : o("current") && n.push("current"), (i("aria-disabled") === "true" || t.disabled || o("disabled")) && n.push("disabled");
3663
3540
  const d = i("aria-haspopup");
3664
3541
  (d && d !== "false" || o("hasPopup")) && n.push("hasPopup"), (i("aria-expanded") === "true" || o("expanded")) && n.push("expanded");
3665
3542
  const u = i("aria-invalid");
3666
3543
  u && u !== "false" ? n.push(u === "true" ? "invalid" : `invalid=${u}`) : o("invalid") && n.push("invalid"), (i("aria-readonly") === "true" || t.readOnly || o("readonly")) && n.push("readonly"), (i("aria-required") === "true" || t.required || o("required")) && n.push("required"), (i("aria-busy") === "true" || o("busy")) && n.push("busy");
3667
- const p = i("aria-orientation");
3668
- p && n.push(`orientation=${p}`);
3669
- const h = i("aria-sort");
3670
- h && h !== "none" && n.push(`sort=${h}`), i("aria-multiselectable") === "true" && n.push("multiselectable");
3671
- const g = t.tagName.match(/^H([1-6])$/);
3672
- g && n.push(`level=${g[1]}`);
3673
- const y = i("aria-level");
3674
- y && !g && n.push(`level=${y}`);
3544
+ const h = i("aria-orientation");
3545
+ h && n.push(`orientation=${h}`);
3546
+ const p = i("aria-sort");
3547
+ p && p !== "none" && n.push(`sort=${p}`), i("aria-multiselectable") === "true" && n.push("multiselectable");
3548
+ const m = t.tagName.match(/^H([1-6])$/);
3549
+ m && n.push(`level=${m[1]}`);
3550
+ const g = i("aria-level");
3551
+ g && !m && n.push(`level=${g}`);
3675
3552
  try {
3676
3553
  window.getComputedStyle(t).cursor === "pointer" && n.push("cursor=pointer");
3677
3554
  } catch {
3678
3555
  }
3679
- const T = t.tagName.toLowerCase();
3680
- if (T === "input" || T === "textarea" || T === "select") {
3681
- const m = t.value;
3682
- m !== void 0 && m !== "" && n.push(`value="${m}"`);
3556
+ const E = t.tagName.toLowerCase();
3557
+ if (E === "input" || E === "textarea" || E === "select") {
3558
+ const b = t.value;
3559
+ b !== void 0 && b !== "" && n.push(`value="${b}"`);
3683
3560
  }
3684
- const C = i("aria-valuenow");
3685
- C && n.push(`valuenow="${C}"`);
3561
+ const L = i("aria-valuenow");
3562
+ L && n.push(`valuenow="${L}"`);
3686
3563
  const f = i("aria-valuetext");
3687
- if (f && n.push(`valuetext="${f}"`), T === "a") {
3688
- const m = i("target");
3689
- m && n.push(`target=${m}`);
3564
+ if (f && n.push(`valuetext="${f}"`), E === "a") {
3565
+ const b = i("target");
3566
+ b && n.push(`target=${b}`);
3690
3567
  }
3691
3568
  o("error") ? n.push("error") : o("warning") && n.push("warning");
3692
- for (const m of Object.keys(r))
3693
- STANDARD_STATE_NAMES.includes(m) || matchesAnyRule(t, r[m]) && n.push(m);
3694
- for (const m of e.exposedAttributes) {
3695
- const E = t.getAttribute(m);
3696
- E !== null && n.push(`${m}="${E}"`);
3569
+ for (const b of Object.keys(r))
3570
+ STANDARD_STATE_NAMES.includes(b) || matchesAnyRule(t, r[b]) && n.push(b);
3571
+ for (const b of e.exposedAttributes) {
3572
+ const T = t.getAttribute(b);
3573
+ T !== null && n.push(`${b}="${T}"`);
3697
3574
  }
3698
3575
  return Array.from(new Set(n));
3699
3576
  }
@@ -3741,16 +3618,16 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3741
3618
  }, isTabbableRadio = function t(e) {
3742
3619
  if (!e.name)
3743
3620
  return !0;
3744
- var n = e.form || getRootNode(e), i = function(s) {
3745
- return n.querySelectorAll('input[type="radio"][name="' + s + '"]');
3621
+ var n = e.form || getRootNode(e), i = function(a) {
3622
+ return n.querySelectorAll('input[type="radio"][name="' + a + '"]');
3746
3623
  }, r;
3747
3624
  if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
3748
3625
  r = i(window.CSS.escape(e.name));
3749
3626
  else
3750
3627
  try {
3751
3628
  r = i(e.name);
3752
- } catch (a) {
3753
- return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", a.message), !1;
3629
+ } catch (s) {
3630
+ return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", s.message), !1;
3754
3631
  }
3755
3632
  var o = getCheckedRadio(r, e.form);
3756
3633
  return !o || o === e;
@@ -3761,10 +3638,10 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3761
3638
  }, isNodeAttached = function t(e) {
3762
3639
  var n, i = e && getRootNode(e), r = (n = i) === null || n === void 0 ? void 0 : n.host, o = !1;
3763
3640
  if (i && i !== e) {
3764
- var a, s, c;
3765
- for (o = !!((a = r) !== null && a !== void 0 && (s = a.ownerDocument) !== null && s !== void 0 && s.contains(r) || e != null && (c = e.ownerDocument) !== null && c !== void 0 && c.contains(e)); !o && r; ) {
3766
- var d, u, p;
3767
- i = getRootNode(r), r = (d = i) === null || d === void 0 ? void 0 : d.host, o = !!((u = r) !== null && u !== void 0 && (p = u.ownerDocument) !== null && p !== void 0 && p.contains(r));
3641
+ var s, a, c;
3642
+ for (o = !!((s = r) !== null && s !== void 0 && (a = s.ownerDocument) !== null && a !== void 0 && a.contains(r) || e != null && (c = e.ownerDocument) !== null && c !== void 0 && c.contains(e)); !o && r; ) {
3643
+ var d, u, h;
3644
+ i = getRootNode(r), r = (d = i) === null || d === void 0 ? void 0 : d.host, o = !!((u = r) !== null && u !== void 0 && (h = u.ownerDocument) !== null && h !== void 0 && h.contains(r));
3768
3645
  }
3769
3646
  }
3770
3647
  return o;
@@ -3789,8 +3666,8 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3789
3666
  });
3790
3667
  return !o;
3791
3668
  }
3792
- var a = getComputedStyle(e), s = a.visibility;
3793
- if (s === "hidden" || s === "collapse")
3669
+ var s = getComputedStyle(e), a = s.visibility;
3670
+ if (a === "hidden" || a === "collapse")
3794
3671
  return !0;
3795
3672
  var c = matches.call(e, "details>summary:first-of-type"), d = c ? e.parentElement : e;
3796
3673
  if (matches.call(d, "details:not([open]) *"))
@@ -3800,10 +3677,10 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3800
3677
  i === "full-native" || i === "legacy-full") {
3801
3678
  if (typeof r == "function") {
3802
3679
  for (var u = e; e; ) {
3803
- var p = e.parentElement, h = getRootNode(e);
3804
- if (p && !p.shadowRoot && r(p) === !0)
3680
+ var h = e.parentElement, p = getRootNode(e);
3681
+ if (h && !h.shadowRoot && r(h) === !0)
3805
3682
  return isZeroArea(e);
3806
- e.assignedSlot ? e = e.assignedSlot : !p && h !== e.ownerDocument ? e = h.host : e = p;
3683
+ e.assignedSlot ? e = e.assignedSlot : !h && p !== e.ownerDocument ? e = p.host : e = h;
3807
3684
  }
3808
3685
  e = u;
3809
3686
  }
@@ -3879,11 +3756,11 @@ function waitForDomSettled(t = 600, e = 150) {
3879
3756
  return new Promise((n) => {
3880
3757
  let i = !1, r;
3881
3758
  const o = () => {
3882
- i || (i = !0, a.disconnect(), r && clearTimeout(r), n());
3883
- }, a = new MutationObserver(() => {
3759
+ i || (i = !0, s.disconnect(), r && clearTimeout(r), n());
3760
+ }, s = new MutationObserver(() => {
3884
3761
  r && clearTimeout(r), r = setTimeout(o, e);
3885
3762
  });
3886
- r = setTimeout(o, e), setTimeout(o, t), a.observe(document.body, {
3763
+ r = setTimeout(o, e), setTimeout(o, t), s.observe(document.body, {
3887
3764
  childList: !0,
3888
3765
  subtree: !0,
3889
3766
  attributes: !0,
@@ -3892,33 +3769,29 @@ function waitForDomSettled(t = 600, e = 150) {
3892
3769
  });
3893
3770
  }
3894
3771
  function detectPageDialog() {
3895
- const t = /* @__PURE__ */ new Set(), e = [], n = getPageAgentToolConfig().a11yConfig.dialogSelectors;
3772
+ const t = /* @__PURE__ */ new Set(), e = [], n = getSelectorsForRole(getPageAgentToolConfig().a11yConfig.roles, "dialog");
3896
3773
  for (const i of n)
3897
3774
  try {
3898
3775
  for (const r of deepQuerySelectorAll(i)) {
3899
3776
  if (t.has(r) || r.id?.includes("page-agent-runtime") || r.closest("#page-agent-runtime_simulator-mask")) continue;
3900
3777
  const o = r.getBoundingClientRect();
3901
3778
  if (o.width < 50 || o.height < 50) continue;
3902
- const a = window.getComputedStyle(r);
3903
- if (a.display === "none" || a.visibility === "hidden") continue;
3904
- const s = a.position === "fixed" || a.position === "absolute", c = parseInt(a.zIndex || "0", 10);
3905
- if (!s || c < 100) continue;
3779
+ const s = window.getComputedStyle(r);
3780
+ if (s.display === "none" || s.visibility === "hidden") continue;
3781
+ const a = s.position === "fixed" || s.position === "absolute", c = parseInt(s.zIndex || "0", 10);
3782
+ if (!a || c < 100) continue;
3906
3783
  const d = window.innerWidth, u = window.innerHeight;
3907
3784
  if (!(o.left < d * 0.6 && o.right > d * 0.4 && o.top < u * 0.6 && o.bottom > u * 0.4)) continue;
3908
3785
  t.add(r);
3909
- const h = (r.textContent || "").trim().replace(/\s+/g, " ");
3910
- if (h.length > 5) {
3911
- const g = r.querySelectorAll('button, [role="button"], a'), y = Array.from(g).map((C) => (C.textContent || "").trim()).filter((C) => C.length > 0 && C.length < 20).slice(0, 5), T = y.length ? ` [可操作按钮: ${y.join(" / ")}]` : "";
3912
- e.push(`${h.substring(0, 300)}${T}`);
3786
+ const p = (r.textContent || "").trim().replace(/\s+/g, " ");
3787
+ if (p.length > 5) {
3788
+ const m = r.querySelectorAll('button, [role="button"], a'), g = Array.from(m).map((E) => (E.textContent || "").trim()).filter((E) => E.length > 0 && E.length < 20).slice(0, 5);
3789
+ e.push({ text: p.substring(0, 300), buttons: g });
3913
3790
  }
3914
3791
  }
3915
3792
  } catch {
3916
3793
  }
3917
- return e.length === 0 ? "" : `
3918
- [页面弹窗检测] 检测到 ${e.length} 个模态弹窗,请优先处理:
3919
- ${e.map((i, r) => `${r + 1}. ${i}`).join(`
3920
- `)}
3921
- `;
3794
+ return e;
3922
3795
  }
3923
3796
  function detectValidationErrors() {
3924
3797
  const t = /* @__PURE__ */ new Set(), e = [], n = extractSelectors(getPageAgentToolConfig().a11yConfig.states.error);
@@ -3928,18 +3801,37 @@ function detectValidationErrors() {
3928
3801
  if (t.has(r) || Array.from(t).some((c) => c.contains(r))) continue;
3929
3802
  const o = r.getBoundingClientRect();
3930
3803
  if (o.width < 1 || o.height < 1) continue;
3931
- const a = window.getComputedStyle(r);
3932
- if (a.display === "none" || a.visibility === "hidden") continue;
3933
- const s = (r.textContent || "").trim().replace(/\s+/g, " ");
3934
- s.length > 2 && s.length < 200 && (t.add(r), e.push(s));
3804
+ const s = window.getComputedStyle(r);
3805
+ if (s.display === "none" || s.visibility === "hidden") continue;
3806
+ const a = (r.textContent || "").trim().replace(/\s+/g, " ");
3807
+ a.length > 2 && a.length < 200 && (t.add(r), e.push(a));
3935
3808
  }
3936
3809
  } catch {
3937
3810
  }
3938
- return e.length === 0 ? "" : `
3939
- [校验提示] 检测到 ${e.length} 个表单校验错误,请先修复后再继续:
3940
- ${e.map((i, r) => `${r + 1}. ${i}`).join(`
3941
- `)}
3942
- `;
3811
+ return e;
3812
+ }
3813
+ function getVisibleTooltipElements() {
3814
+ const t = /* @__PURE__ */ new Set(), e = [], n = getSelectorsForRole(getPageAgentToolConfig().a11yConfig.roles, "tooltip");
3815
+ for (const i of n)
3816
+ try {
3817
+ for (const r of deepQuerySelectorAll(i)) {
3818
+ if (t.has(r) || Array.from(t).some((c) => c.contains(r))) continue;
3819
+ const o = r.getBoundingClientRect();
3820
+ if (o.width < 1 || o.height < 1) continue;
3821
+ const s = window.getComputedStyle(r);
3822
+ if (s.display === "none" || s.visibility === "hidden" || s.opacity === "0") continue;
3823
+ const a = (r.textContent || "").trim().replace(/\s+/g, " ");
3824
+ if (a.length > 1) {
3825
+ if (r.querySelector?.('[name="cloudx-action-help"]')) continue;
3826
+ t.add(r), e.push({ el: r, text: a });
3827
+ }
3828
+ }
3829
+ } catch {
3830
+ }
3831
+ return e;
3832
+ }
3833
+ function detectVisibleTooltips() {
3834
+ return getVisibleTooltipElements().map((t) => t.text);
3943
3835
  }
3944
3836
  const NON_CONTENT_TAGS = /* @__PURE__ */ new Set([
3945
3837
  "script",
@@ -3973,9 +3865,9 @@ function collectInteractivePointerSelectors(t, e) {
3973
3865
  }
3974
3866
  const o = i.selectorText;
3975
3867
  if (!(!o || !i.style || i.style.cursor !== "pointer") && /:(hover|focus|focus-visible|focus-within|active)\b/i.test(o))
3976
- for (const a of o.split(",")) {
3977
- const s = a.replace(INTERACTION_PSEUDO_RE, "").trim();
3978
- s && s !== "*" && e.add(s);
3868
+ for (const s of o.split(",")) {
3869
+ const a = s.replace(INTERACTION_PSEUDO_RE, "").trim();
3870
+ a && a !== "*" && e.add(a);
3979
3871
  }
3980
3872
  }
3981
3873
  }
@@ -4034,12 +3926,12 @@ function collectDescendantText(t, e) {
4034
3926
  const o = r;
4035
3927
  if (o !== t && isNonContentElement(o) || isHidden$1(o) && o !== t || o === t && isNonContentElement(o)) return;
4036
3928
  if (o !== t) {
4037
- const a = o.tagName.toLowerCase(), s = resolveA11yRole(o, e), c = ["button", "a", "input", "select", "textarea", "li", "option"].includes(a), d = ["button", "link", "checkbox", "radio", "textbox", "listitem", "option", "combobox", "listbox"].includes(s), u = isTabbable(o), p = hasOwnPointerCursor(o);
4038
- if (u && !(s === "generic" && !p) || c || d)
3929
+ const s = o.tagName.toLowerCase(), a = resolveA11yRole(o, e), c = ["button", "a", "input", "select", "textarea", "li", "option"].includes(s), d = ["button", "link", "checkbox", "radio", "textbox", "listitem", "option", "combobox", "listbox"].includes(a), u = isTabbable(o), h = hasOwnPointerCursor(o);
3930
+ if (u && !(a === "generic" && !h) || c || d)
4039
3931
  return;
4040
3932
  }
4041
- for (const a of Array.from(o.childNodes))
4042
- i(a);
3933
+ for (const s of Array.from(o.childNodes))
3934
+ i(s);
4043
3935
  }
4044
3936
  };
4045
3937
  return i(t), n.trim().replace(/\s+/g, " ");
@@ -4054,6 +3946,37 @@ function getComposedChildren(t) {
4054
3946
  n.push(i);
4055
3947
  return n;
4056
3948
  }
3949
+ function extractTooltipText(t) {
3950
+ const e = t.getAttribute("title");
3951
+ if (e && e.trim())
3952
+ return e.trim().replace(/"/g, '\\"').substring(0, 200);
3953
+ const n = t.getAttribute("aria-describedby");
3954
+ if (n)
3955
+ for (const o of n.split(/\s+/)) {
3956
+ const s = document.getElementById(o);
3957
+ if (s) {
3958
+ const a = (s.textContent || "").trim().replace(/\s+/g, " ");
3959
+ if (a)
3960
+ return a.replace(/"/g, '\\"').substring(0, 200);
3961
+ }
3962
+ }
3963
+ for (const o of ["data-tooltip", "data-tips", "data-tip"]) {
3964
+ const s = t.getAttribute(o);
3965
+ if (s && s.trim())
3966
+ return s.trim().replace(/"/g, '\\"').substring(0, 200);
3967
+ }
3968
+ const i = t.tagName.toLowerCase();
3969
+ if (i === "tp-helptip" || t.closest("tp-helptip")) {
3970
+ const s = (i === "tp-helptip" ? t : t.closest("tp-helptip")).querySelector('.tp-helptip-label, [class*="tp-helptip-label"]');
3971
+ if (s) {
3972
+ const a = (s.textContent || "").trim();
3973
+ if (a)
3974
+ return a.replace(/"/g, '\\"').substring(0, 200);
3975
+ }
3976
+ }
3977
+ const r = t.getAttribute("mattooltip") || t.getAttribute("matTooltip");
3978
+ return r && r.trim() ? r.trim().replace(/"/g, '\\"').substring(0, 200) : "";
3979
+ }
4057
3980
  var toStr = Object.prototype.toString;
4058
3981
  function isCallable(t) {
4059
3982
  return typeof t == "function" || toStr.call(t) === "[object Function]";
@@ -4071,8 +3994,8 @@ function arrayFrom(t, e) {
4071
3994
  var n = Array, i = Object(t);
4072
3995
  if (t == null)
4073
3996
  throw new TypeError("Array.from requires an array-like object - not null or undefined");
4074
- for (var r = toLength(i.length), o = isCallable(n) ? Object(new n(r)) : new Array(r), a = 0, s; a < r; )
4075
- s = i[a], o[a] = s, a += 1;
3997
+ for (var r = toLength(i.length), o = isCallable(n) ? Object(new n(r)) : new Array(r), s = 0, a; s < r; )
3998
+ a = i[s], o[s] = a, s += 1;
4076
3999
  return o.length = r, o;
4077
4000
  }
4078
4001
  function _typeof$1(t) {
@@ -4477,43 +4400,43 @@ function getSlotContents(t) {
4477
4400
  return e.length === 0 ? arrayFrom(t.childNodes) : e;
4478
4401
  }
4479
4402
  function computeTextAlternative(t) {
4480
- var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = new SetLike$1(), i = safeWindow(t), r = e.compute, o = r === void 0 ? "name" : r, a = e.computedStyleSupportsPseudoElements, s = a === void 0 ? e.getComputedStyle !== void 0 : a, c = e.getComputedStyle, d = c === void 0 ? i.getComputedStyle.bind(i) : c, u = e.hidden, p = u === void 0 ? !1 : u;
4481
- function h(f, m) {
4482
- var E = "";
4483
- if (isElement(f) && s) {
4484
- var v = d(f, "::before"), L = getTextualContent(v);
4485
- E = "".concat(L, " ").concat(E);
4403
+ var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = new SetLike$1(), i = safeWindow(t), r = e.compute, o = r === void 0 ? "name" : r, s = e.computedStyleSupportsPseudoElements, a = s === void 0 ? e.getComputedStyle !== void 0 : s, c = e.getComputedStyle, d = c === void 0 ? i.getComputedStyle.bind(i) : c, u = e.hidden, h = u === void 0 ? !1 : u;
4404
+ function p(f, b) {
4405
+ var T = "";
4406
+ if (isElement(f) && a) {
4407
+ var y = d(f, "::before"), C = getTextualContent(y);
4408
+ T = "".concat(C, " ").concat(T);
4486
4409
  }
4487
4410
  var S = isHTMLSlotElement(f) ? getSlotContents(f) : arrayFrom(f.childNodes).concat(queryIdRefs(f, "aria-owns"));
4488
- if (S.forEach(function(M) {
4489
- var O = C(M, {
4490
- isEmbeddedInLabel: m.isEmbeddedInLabel,
4411
+ if (S.forEach(function(P) {
4412
+ var R = L(P, {
4413
+ isEmbeddedInLabel: b.isEmbeddedInLabel,
4491
4414
  isReferenced: !1,
4492
4415
  recursion: !0
4493
- }), F = isElement(M) ? d(M).getPropertyValue("display") : "inline", B = F !== "inline" ? " " : "";
4494
- E += "".concat(B).concat(O).concat(B);
4495
- }), isElement(f) && s) {
4496
- var A = d(f, "::after"), N = getTextualContent(A);
4497
- E = "".concat(E, " ").concat(N);
4416
+ }), F = isElement(P) ? d(P).getPropertyValue("display") : "inline", B = F !== "inline" ? " " : "";
4417
+ T += "".concat(B).concat(R).concat(B);
4418
+ }), isElement(f) && a) {
4419
+ var A = d(f, "::after"), D = getTextualContent(A);
4420
+ T = "".concat(T, " ").concat(D);
4498
4421
  }
4499
- return E.trim();
4422
+ return T.trim();
4500
4423
  }
4501
- function g(f, m) {
4502
- var E = f.getAttributeNode(m);
4503
- return E !== null && !n.has(E) && E.value.trim() !== "" ? (n.add(E), E.value) : null;
4424
+ function m(f, b) {
4425
+ var T = f.getAttributeNode(b);
4426
+ return T !== null && !n.has(T) && T.value.trim() !== "" ? (n.add(T), T.value) : null;
4504
4427
  }
4505
- function y(f) {
4506
- return isElement(f) ? g(f, "title") : null;
4428
+ function g(f) {
4429
+ return isElement(f) ? m(f, "title") : null;
4507
4430
  }
4508
- function T(f) {
4431
+ function E(f) {
4509
4432
  if (!isElement(f))
4510
4433
  return null;
4511
4434
  if (isHTMLFieldSetElement(f)) {
4512
4435
  n.add(f);
4513
- for (var m = arrayFrom(f.childNodes), E = 0; E < m.length; E += 1) {
4514
- var v = m[E];
4515
- if (isHTMLLegendElement(v))
4516
- return C(v, {
4436
+ for (var b = arrayFrom(f.childNodes), T = 0; T < b.length; T += 1) {
4437
+ var y = b[T];
4438
+ if (isHTMLLegendElement(y))
4439
+ return L(y, {
4517
4440
  isEmbeddedInLabel: !1,
4518
4441
  isReferenced: !1,
4519
4442
  recursion: !1
@@ -4521,10 +4444,10 @@ function computeTextAlternative(t) {
4521
4444
  }
4522
4445
  } else if (isHTMLTableElement(f)) {
4523
4446
  n.add(f);
4524
- for (var L = arrayFrom(f.childNodes), S = 0; S < L.length; S += 1) {
4525
- var A = L[S];
4447
+ for (var C = arrayFrom(f.childNodes), S = 0; S < C.length; S += 1) {
4448
+ var A = C[S];
4526
4449
  if (isHTMLTableCaptionElement(A))
4527
- return C(A, {
4450
+ return L(A, {
4528
4451
  isEmbeddedInLabel: !1,
4529
4452
  isReferenced: !1,
4530
4453
  recursion: !1
@@ -4532,23 +4455,23 @@ function computeTextAlternative(t) {
4532
4455
  }
4533
4456
  } else if (isSVGSVGElement(f)) {
4534
4457
  n.add(f);
4535
- for (var N = arrayFrom(f.childNodes), M = 0; M < N.length; M += 1) {
4536
- var O = N[M];
4537
- if (isSVGTitleElement(O))
4538
- return O.textContent;
4458
+ for (var D = arrayFrom(f.childNodes), P = 0; P < D.length; P += 1) {
4459
+ var R = D[P];
4460
+ if (isSVGTitleElement(R))
4461
+ return R.textContent;
4539
4462
  }
4540
4463
  return null;
4541
4464
  } else if (getLocalName(f) === "img" || getLocalName(f) === "area") {
4542
- var F = g(f, "alt");
4465
+ var F = m(f, "alt");
4543
4466
  if (F !== null)
4544
4467
  return F;
4545
4468
  } else if (isHTMLOptGroupElement(f)) {
4546
- var B = g(f, "label");
4469
+ var B = m(f, "label");
4547
4470
  if (B !== null)
4548
4471
  return B;
4549
4472
  }
4550
4473
  if (isHTMLInputElement(f) && (f.type === "button" || f.type === "submit" || f.type === "reset")) {
4551
- var J = g(f, "value");
4474
+ var J = m(f, "value");
4552
4475
  if (J !== null)
4553
4476
  return J;
4554
4477
  if (f.type === "submit")
@@ -4559,7 +4482,7 @@ function computeTextAlternative(t) {
4559
4482
  var G = getLabels(f);
4560
4483
  if (G !== null && G.length !== 0)
4561
4484
  return n.add(f), arrayFrom(G).map(function(W) {
4562
- return C(W, {
4485
+ return L(W, {
4563
4486
  isEmbeddedInLabel: !0,
4564
4487
  isReferenced: !1,
4565
4488
  recursion: !0
@@ -4568,14 +4491,14 @@ function computeTextAlternative(t) {
4568
4491
  return W.length > 0;
4569
4492
  }).join(" ");
4570
4493
  if (isHTMLInputElement(f) && f.type === "image") {
4571
- var Q = g(f, "alt");
4494
+ var Q = m(f, "alt");
4572
4495
  if (Q !== null)
4573
4496
  return Q;
4574
- var ee = g(f, "title");
4497
+ var ee = m(f, "title");
4575
4498
  return ee !== null ? ee : "Submit Query";
4576
4499
  }
4577
4500
  if (hasAnyConcreteRoles(f, ["button"])) {
4578
- var te = h(f, {
4501
+ var te = p(f, {
4579
4502
  isEmbeddedInLabel: !1
4580
4503
  });
4581
4504
  if (te !== "")
@@ -4583,16 +4506,16 @@ function computeTextAlternative(t) {
4583
4506
  }
4584
4507
  return null;
4585
4508
  }
4586
- function C(f, m) {
4509
+ function L(f, b) {
4587
4510
  if (n.has(f))
4588
4511
  return "";
4589
- if (!p && isHidden(f, d) && !m.isReferenced)
4512
+ if (!h && isHidden(f, d) && !b.isReferenced)
4590
4513
  return n.add(f), "";
4591
- var E = isElement(f) ? f.getAttributeNode("aria-labelledby") : null, v = E !== null && !n.has(E) ? queryIdRefs(f, "aria-labelledby") : [];
4592
- if (o === "name" && !m.isReferenced && v.length > 0)
4593
- return n.add(E), v.map(function(F) {
4594
- return C(F, {
4595
- isEmbeddedInLabel: m.isEmbeddedInLabel,
4514
+ var T = isElement(f) ? f.getAttributeNode("aria-labelledby") : null, y = T !== null && !n.has(T) ? queryIdRefs(f, "aria-labelledby") : [];
4515
+ if (o === "name" && !b.isReferenced && y.length > 0)
4516
+ return n.add(T), y.map(function(F) {
4517
+ return L(F, {
4518
+ isEmbeddedInLabel: b.isEmbeddedInLabel,
4596
4519
  isReferenced: !0,
4597
4520
  // this isn't recursion as specified, otherwise we would skip
4598
4521
  // `aria-label` in
@@ -4600,26 +4523,26 @@ function computeTextAlternative(t) {
4600
4523
  recursion: !1
4601
4524
  });
4602
4525
  }).join(" ");
4603
- var L = m.recursion && isControl(f) && o === "name";
4604
- if (!L) {
4526
+ var C = b.recursion && isControl(f) && o === "name";
4527
+ if (!C) {
4605
4528
  var S = (isElement(f) && f.getAttribute("aria-label") || "").trim();
4606
4529
  if (S !== "" && o === "name")
4607
4530
  return n.add(f), S;
4608
4531
  if (!isMarkedPresentational(f)) {
4609
- var A = T(f);
4532
+ var A = E(f);
4610
4533
  if (A !== null)
4611
4534
  return n.add(f), A;
4612
4535
  }
4613
4536
  }
4614
4537
  if (hasAnyConcreteRoles(f, ["menu"]))
4615
4538
  return n.add(f), "";
4616
- if (L || m.isEmbeddedInLabel || m.isReferenced) {
4539
+ if (C || b.isEmbeddedInLabel || b.isReferenced) {
4617
4540
  if (hasAnyConcreteRoles(f, ["combobox", "listbox"])) {
4618
4541
  n.add(f);
4619
- var N = querySelectedOptions(f);
4620
- return N.length === 0 ? isHTMLInputElement(f) ? f.value : "" : arrayFrom(N).map(function(F) {
4621
- return C(F, {
4622
- isEmbeddedInLabel: m.isEmbeddedInLabel,
4542
+ var D = querySelectedOptions(f);
4543
+ return D.length === 0 ? isHTMLInputElement(f) ? f.value : "" : arrayFrom(D).map(function(F) {
4544
+ return L(F, {
4545
+ isEmbeddedInLabel: b.isEmbeddedInLabel,
4623
4546
  isReferenced: !1,
4624
4547
  recursion: !0
4625
4548
  });
@@ -4630,23 +4553,23 @@ function computeTextAlternative(t) {
4630
4553
  if (hasAnyConcreteRoles(f, ["textbox"]))
4631
4554
  return n.add(f), getValueOfTextbox(f);
4632
4555
  }
4633
- if (allowsNameFromContent(f) || isElement(f) && m.isReferenced || isNativeHostLanguageTextAlternativeElement(f) || isDescendantOfNativeHostLanguageTextAlternativeElement()) {
4634
- var M = h(f, {
4635
- isEmbeddedInLabel: m.isEmbeddedInLabel
4556
+ if (allowsNameFromContent(f) || isElement(f) && b.isReferenced || isNativeHostLanguageTextAlternativeElement(f) || isDescendantOfNativeHostLanguageTextAlternativeElement()) {
4557
+ var P = p(f, {
4558
+ isEmbeddedInLabel: b.isEmbeddedInLabel
4636
4559
  });
4637
- if (M !== "")
4638
- return n.add(f), M;
4560
+ if (P !== "")
4561
+ return n.add(f), P;
4639
4562
  }
4640
4563
  if (f.nodeType === f.TEXT_NODE)
4641
4564
  return n.add(f), f.textContent || "";
4642
- if (m.recursion)
4643
- return n.add(f), h(f, {
4644
- isEmbeddedInLabel: m.isEmbeddedInLabel
4565
+ if (b.recursion)
4566
+ return n.add(f), p(f, {
4567
+ isEmbeddedInLabel: b.isEmbeddedInLabel
4645
4568
  });
4646
- var O = y(f);
4647
- return O !== null ? (n.add(f), O) : (n.add(f), "");
4569
+ var R = g(f);
4570
+ return R !== null ? (n.add(f), R) : (n.add(f), "");
4648
4571
  }
4649
- return asFlatString(C(t, {
4572
+ return asFlatString(L(t, {
4650
4573
  isEmbeddedInLabel: !1,
4651
4574
  // by spec computeAccessibleDescription starts with the referenced elements as roots
4652
4575
  isReferenced: o === "description",
@@ -4678,43 +4601,54 @@ const INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
4678
4601
  "tab",
4679
4602
  "treeitem"
4680
4603
  ]);
4681
- function buildVNode(t, e, n, i, r, o, a = /* @__PURE__ */ new Set()) {
4604
+ function buildVNode(t, e, n, i, r, o, s = /* @__PURE__ */ new Set()) {
4682
4605
  if (isNonContentElement(t) || isHidden$1(t) || i.has(t)) return null;
4683
- const { role: s, tokens: c } = resolveA11yInfo(t, o);
4684
- let d = computeAccessibleName(t);
4685
- const u = isTabbable(t), p = c.includes("cursor=pointer"), h = hasOwnPointerCursor(t) || a.has(t), g = r.has(t), y = t.tagName.toLowerCase() === "label" && t.hasAttribute("for");
4686
- if (!d.trim()) {
4687
- const A = t.tagName.toLowerCase();
4688
- if (!(A === "select" || s === "combobox" || s === "listbox")) {
4689
- const M = ["button", "a", "input", "textarea", "li", "label"].includes(A);
4690
- (u || g || p || h || M || s === "listitem" || s === "option") && (d = collectDescendantText(t, o));
4606
+ const { role: a, tokens: c } = resolveA11yInfo(t, o), d = extractTooltipText(t);
4607
+ d && c.push(`tooltip="${d}"`);
4608
+ const u = c.some((P) => P.startsWith("tooltip="));
4609
+ let h = computeAccessibleName(t);
4610
+ const p = isTabbable(t), m = c.includes("cursor=pointer"), g = hasOwnPointerCursor(t) || s.has(t), E = r.has(t), L = t.tagName.toLowerCase() === "label" && t.hasAttribute("for");
4611
+ if (!h.trim()) {
4612
+ const P = t.tagName.toLowerCase();
4613
+ if (!(P === "select" || a === "combobox" || a === "listbox")) {
4614
+ const F = ["button", "a", "input", "textarea", "li", "label"].includes(P);
4615
+ (p || E || m || g || F || a === "listitem" || a === "option" || a === "button") && (h = collectDescendantText(t, o));
4691
4616
  }
4692
4617
  }
4693
- if (!d.trim() && (u || g || p || h || s === "button") && (d = collectTitleLabel(t)), !d.trim() && ["tab", "menuitem", "option", "treeitem", "button"].includes(s) && (d = collectVisiblePlainText(t)), !d.trim() && !(getComposedChildren(t).length > 0)) {
4694
- const N = collectDescendantText(t, o);
4695
- N && (d = N);
4618
+ if (!h.trim() && (p || E || m || g || a === "button") && (h = collectTitleLabel(t)), !h.trim() && a === "button") {
4619
+ const P = t.getAttribute("name") || "";
4620
+ (P.includes("help") || P.includes("tip") || P.includes("info")) && (h = "帮助");
4621
+ }
4622
+ if (!h.trim() && u) {
4623
+ const P = c.find((R) => R.startsWith("tooltip="));
4624
+ P && (h = P.replace(/^tooltip="/, "").replace(/"$/, ""));
4625
+ }
4626
+ if (!h.trim() && ["tab", "menuitem", "option", "treeitem", "button"].includes(a) && (h = collectVisiblePlainText(t)), !h.trim() && !(getComposedChildren(t).length > 0)) {
4627
+ const R = collectDescendantText(t, o);
4628
+ R && (h = R);
4696
4629
  }
4697
- const T = t.tagName.toLowerCase(), C = T === "a" && t.hasAttribute("href") || ["button", "input", "select", "textarea"].includes(T) && !t.hasAttribute("disabled"), f = u && !(s === "generic" && !h), m = c.includes("disabled"), E = !m && f || g || y || C || !m && INTERACTIVE_ROLES.has(s) || // hasClickableCursor 已排除 CSS 继承(hasOwnPointerCursor)并覆盖 hover 态手势,
4630
+ const f = t.tagName.toLowerCase(), b = f === "a" && t.hasAttribute("href") || ["button", "input", "select", "textarea"].includes(f) && !t.hasAttribute("disabled") || a === "button" && m && !["button", "a", "input", "select", "textarea"].includes(f), T = p && !(a === "generic" && !g), y = c.includes("disabled"), C = !y && T || E || L || b || !y && INTERACTIVE_ROLES.has(a) || // hasClickableCursor 已排除 CSS 继承(hasOwnPointerCursor)并覆盖 hover 态手势,
4698
4631
  // 无需再要求 role≠generic 或 name≠''——否则无文本的图标按钮(tp-icon.common-icon 等)
4699
4632
  // 虽是真正的可点击边界,仍会因 generic+空名被漏判。
4700
- !m && h;
4701
- let v;
4702
- E && (v = e.value, n.set(v, t), e.value++);
4703
- const L = [];
4704
- for (const A of getComposedChildren(t)) {
4705
- const N = buildVNode(
4706
- A,
4633
+ !y && g || // 有 tooltip 的元素分配 ref,使 AI 能 hover 触发动态 tip
4634
+ u;
4635
+ let S;
4636
+ C && (S = e.value, n.set(S, t), e.value++);
4637
+ const A = [];
4638
+ for (const P of getComposedChildren(t)) {
4639
+ const R = buildVNode(
4640
+ P,
4707
4641
  e,
4708
4642
  n,
4709
4643
  i,
4710
4644
  r,
4711
4645
  o,
4712
- a
4646
+ s
4713
4647
  );
4714
- N && L.push(N);
4648
+ R && A.push(R);
4715
4649
  }
4716
- const S = { role: s, name: d, tokens: c, ref: v, el: t, children: L };
4717
- return hasInteractiveDescendant(S) && (S.name = getOwnDeclaredName(t)), S;
4650
+ const D = { role: a, name: h, tokens: c, ref: S, el: t, children: A };
4651
+ return hasInteractiveDescendant(D) && (D.name = getOwnDeclaredName(t)), D;
4718
4652
  }
4719
4653
  function getOwnDeclaredName(t) {
4720
4654
  return t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby") ? computeAccessibleName(t).trim() : "";
@@ -4725,11 +4659,17 @@ function isStaticBranch(t) {
4725
4659
  function collectVisiblePlainText(t) {
4726
4660
  return collectDescendantText(t).replace(/\s+/g, " ").trim();
4727
4661
  }
4662
+ function collectDirectTextNodes(t) {
4663
+ let e = "";
4664
+ for (const n of Array.from(t.childNodes))
4665
+ n.nodeType === Node.TEXT_NODE && (e += (n.textContent ?? "") + " ");
4666
+ return e.replace(/\s+/g, " ").trim();
4667
+ }
4728
4668
  function getStaticDisplayText(t) {
4729
4669
  const e = t.children.length > 0 ? t.children.map(getStaticDisplayText).filter(Boolean).join(" ").replace(/\s+/g, " ").trim() : "", n = t.children.length === 0 ? collectVisiblePlainText(t.el) : "", i = t.name.trim(), r = [];
4730
4670
  if (i && !isNoiseAccessibleName(i) && r.push(i), e && !isNoiseAccessibleName(e)) {
4731
- const o = i.replace(/\s+/g, " ").trim(), a = e.replace(/\s+/g, " ").trim();
4732
- (!o || a !== o && !o.includes(a)) && r.push(e);
4671
+ const o = i.replace(/\s+/g, " ").trim(), s = e.replace(/\s+/g, " ").trim();
4672
+ (!o || s !== o && !o.includes(s)) && r.push(e);
4733
4673
  }
4734
4674
  return r.length === 0 && n && !isNoiseAccessibleName(n) && r.push(n), r.join(" ").replace(/\s+/g, " ").trim();
4735
4675
  }
@@ -4763,30 +4703,30 @@ function formatNameAttr(t) {
4763
4703
  return e ? ` "${e}"` : "";
4764
4704
  }
4765
4705
  function serializeVNode(t, e, n) {
4766
- const i = hasInteractiveDescendant(t), r = n.preserveRoles.includes(t.role), o = " ".repeat(e), a = t.ref !== void 0 ? ` #${t.ref}` : "", s = t.tokens.map((m) => m.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"')), c = s.length > 0 ? ` [${s.join(" ")}]` : "";
4706
+ const i = hasInteractiveDescendant(t), r = n.preserveRoles.includes(t.role), o = " ".repeat(e), s = t.ref !== void 0 ? ` #${t.ref}` : "", a = t.tokens.map((y) => y.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"')), c = a.length > 0 ? ` [${a.join(" ")}]` : "";
4767
4707
  if (!i && !r) {
4768
4708
  if (shouldPassThrough(t, n))
4769
- return t.children.filter((E) => hasValue(E)).flatMap((E) => serializeVNode(E, e, n));
4770
- let m = t.name.trim();
4771
- return !m && t.children.length > 0 && (m = collectVisiblePlainText(t.el)), isNoiseAccessibleName(m) && (m = ""), [`${o}- ${t.role}${a}${c}${formatNameAttr(m)}`];
4709
+ return t.children.filter((C) => hasValue(C)).flatMap((C) => serializeVNode(C, e, n));
4710
+ let y = t.name.trim();
4711
+ return !y && t.children.length > 0 && (y = collectVisiblePlainText(t.el)), isNoiseAccessibleName(y) && (y = ""), [`${o}- ${t.role}${s}${c}${formatNameAttr(y)}`];
4772
4712
  }
4773
4713
  if (!i && r) {
4774
- const m = getOwnDeclaredName(t.el), E = `${o}- ${t.role}${a}${c}${formatNameAttr(m)}`, v = t.children.flatMap((L) => serializeVNode(L, e + 1, n));
4775
- return [E, ...v];
4714
+ const y = getOwnDeclaredName(t.el), C = `${o}- ${t.role}${s}${c}${formatNameAttr(y)}`, S = t.children.flatMap((A) => serializeVNode(A, e + 1, n));
4715
+ return [C, ...S];
4776
4716
  }
4777
- const d = getOwnDeclaredName(t.el), u = d !== "", p = t.children.filter(isStaticBranch), h = p.map(getStaticDisplayText).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
4778
- let g = u ? d : h;
4779
- if (isNoiseAccessibleName(g) && (g = ""), !u && isNoiseAccessibleName(t.name) && (g = h && !isNoiseAccessibleName(h) ? h : ""), !(t.ref !== void 0 || g !== "" || r || !n.pruneUnnamed))
4780
- return t.children.filter((m) => hasValue(m)).flatMap((m) => serializeVNode(m, e, n));
4717
+ const d = getOwnDeclaredName(t.el), u = d !== "", h = t.children.filter(isStaticBranch), p = h.map(getStaticDisplayText).filter(Boolean).join(" ").replace(/\s+/g, " ").trim(), m = collectDirectTextNodes(t.el), g = [p, m].filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
4718
+ let E = u ? d : g;
4719
+ if (isNoiseAccessibleName(E) && (E = ""), !u && isNoiseAccessibleName(t.name) && (E = g && !isNoiseAccessibleName(g) ? g : ""), !(t.ref !== void 0 || E !== "" || r || !n.pruneUnnamed))
4720
+ return t.children.filter((y) => hasValue(y)).flatMap((y) => serializeVNode(y, e, n));
4781
4721
  if (t.ref !== void 0) {
4782
- const m = findSingleRefDescendant(t);
4783
- if (m && m.role === "generic" && !hasInteractiveDescendant(m) && p.length === 0) {
4784
- const E = g.trim() || m.name.trim(), v = m.ref !== void 0 ? ` #${m.ref}` : a;
4785
- return [`${o}- ${t.role}${v}${c}${formatNameAttr(E)}`];
4722
+ const y = findSingleRefDescendant(t);
4723
+ if (y && y.role === "generic" && !hasInteractiveDescendant(y) && h.length === 0) {
4724
+ const C = E.trim() || y.name.trim(), S = y.ref !== void 0 ? ` #${y.ref}` : s;
4725
+ return [`${o}- ${t.role}${S}${c}${formatNameAttr(C)}`];
4786
4726
  }
4787
4727
  }
4788
- const T = t.children.filter((m) => isStaticBranch(m) ? !canOmitStaticChild(m, g, u) : !0), C = `${o}- ${t.role}${a}${c}${formatNameAttr(g)}`, f = T.flatMap((m) => serializeVNode(m, e + 1, n));
4789
- return [C, ...f];
4728
+ const f = t.children.filter((y) => isStaticBranch(y) ? !canOmitStaticChild(y, E, u) : !0), b = `${o}- ${t.role}${s}${c}${formatNameAttr(E)}`, T = f.flatMap((y) => serializeVNode(y, e + 1, n));
4729
+ return [b, ...T];
4790
4730
  }
4791
4731
  const HIGHLIGHT_CONTAINER_ID = "webmcpcli-highlight-container", HIGHLIGHT_CONTAINER_STYLE_ID = "webmcpcli-highlight-container-style", colors = [
4792
4732
  "#FF0000",
@@ -4870,32 +4810,32 @@ const doHighlight = (t, e = null) => {
4870
4810
  i.x = o.left, i.y = o.top;
4871
4811
  }
4872
4812
  const r = document.createDocumentFragment();
4873
- for (const [o, a] of t.entries()) {
4874
- const s = resolveHighlightRect(a);
4875
- if (!s) continue;
4876
- const c = s.top + i.y, d = s.left + i.x, u = { top: c, left: d, width: s.width, height: s.height };
4813
+ for (const [o, s] of t.entries()) {
4814
+ const a = resolveHighlightRect(s);
4815
+ if (!a) continue;
4816
+ const c = a.top + i.y, d = a.left + i.x, u = { top: c, left: d, width: a.width, height: a.height };
4877
4817
  if (!isRectInViewport(u)) continue;
4878
- const h = colors[o % colors.length] + opacity, g = document.createElement("div");
4879
- g.style.border = `2px solid ${h}`, g.dataset.refIndex = String(o), g.style.top = `${c}px`, g.style.left = `${d}px`, g.style.width = `${s.width}px`, g.style.height = `${s.height}px`;
4880
- const y = document.createElement("span");
4881
- y.style.backgroundColor = h, y.style.height = `${Math.max(s.height - 4, 0)}px`, y.style.lineHeight = `${Math.max(s.height - 4, 0)}px`, y.textContent = o.toString(), g.appendChild(y), r.appendChild(g);
4818
+ const p = colors[o % colors.length] + opacity, m = document.createElement("div");
4819
+ m.style.border = `2px solid ${p}`, m.dataset.refIndex = String(o), m.style.top = `${c}px`, m.style.left = `${d}px`, m.style.width = `${a.width}px`, m.style.height = `${a.height}px`;
4820
+ const g = document.createElement("span");
4821
+ g.style.backgroundColor = p, g.style.height = `${Math.max(a.height - 4, 0)}px`, g.style.lineHeight = `${Math.max(a.height - 4, 0)}px`, g.textContent = o.toString(), m.appendChild(g), r.appendChild(m);
4882
4822
  }
4883
4823
  n.appendChild(r);
4884
4824
  }, highlight = (t, e = null) => {
4885
4825
  doHighlight(t, e);
4886
- const r = ((s, c) => {
4826
+ const r = ((a, c) => {
4887
4827
  let d = 0;
4888
4828
  return (...u) => {
4889
- const p = performance.now();
4890
- if (!(p - d < c))
4891
- return d = p, s(...u);
4829
+ const h = performance.now();
4830
+ if (!(h - d < c))
4831
+ return d = h, a(...u);
4892
4832
  };
4893
4833
  })(() => doHighlight(t, e), 16);
4894
4834
  window.addEventListener("scroll", r, !0), window.addEventListener("resize", r);
4895
4835
  const o = () => {
4896
4836
  window.removeEventListener("scroll", r, !0), window.removeEventListener("resize", r);
4897
- }, a = window;
4898
- (a._highlightCleanupFunctions = a._highlightCleanupFunctions || []).push(o);
4837
+ }, s = window;
4838
+ (s._highlightCleanupFunctions = s._highlightCleanupFunctions || []).push(o);
4899
4839
  }, unhighlight = () => {
4900
4840
  document.getElementById(HIGHLIGHT_CONTAINER_ID)?.remove();
4901
4841
  const t = window._highlightCleanupFunctions || [];
@@ -4935,19 +4875,19 @@ function resolveElementList(t, e) {
4935
4875
  return n;
4936
4876
  }
4937
4877
  function buildA11yTree(t = document.body, e) {
4938
- const { pruneUnnamed: n = !0, preserveRoles: i = [], ...r } = e ?? {}, o = ensureResolvedA11yConfig(r), a = { pruneUnnamed: n, preserveRoles: i }, s = { value: 0 }, c = /* @__PURE__ */ new Map(), d = resolveElementList(o.blacklist, t), u = resolveElementList(o.whitelist, t), p = [], h = document.getElementById(HIGHLIGHT_CONTAINER_ID);
4939
- h && d.add(h);
4940
- const g = collectHoverPointerElements(t);
4941
- for (const T of getComposedChildren(t)) {
4942
- const C = buildVNode(T, s, c, d, u, o, g);
4943
- C && p.push(...serializeVNode(C, 0, a));
4878
+ const { pruneUnnamed: n = !0, preserveRoles: i = [], ...r } = e ?? {}, o = ensureResolvedA11yConfig(r), s = { pruneUnnamed: n, preserveRoles: i }, a = { value: 0 }, c = /* @__PURE__ */ new Map(), d = resolveElementList(o.blacklist, t), u = resolveElementList(o.whitelist, t), h = [], p = document.getElementById(HIGHLIGHT_CONTAINER_ID);
4879
+ p && d.add(p);
4880
+ const m = collectHoverPointerElements(t);
4881
+ for (const E of getComposedChildren(t)) {
4882
+ const L = buildVNode(E, a, c, d, u, o, m);
4883
+ L && h.push(...serializeVNode(L, 0, s));
4944
4884
  }
4945
4885
  return {
4946
- yaml: "```yaml\n" + p.join(`
4886
+ yaml: "```yaml\n" + h.join(`
4947
4887
  `) + "\n```",
4948
4888
  refMap: c,
4949
4889
  interactiveCount: c.size,
4950
- lines: p
4890
+ lines: h
4951
4891
  };
4952
4892
  }
4953
4893
  function searchA11yTree(t, e = document.body, n) {
@@ -4955,51 +4895,51 @@ function searchA11yTree(t, e = document.body, n) {
4955
4895
  contextLines: i = 2,
4956
4896
  caseInsensitive: r = !0,
4957
4897
  maxMatches: o = 20,
4958
- ...a
4959
- } = n ?? {}, s = Math.max(0, i), c = Math.max(1, o), { lines: d, refMap: u, yaml: p } = buildA11yTree(e, a), h = r ? t.toLowerCase() : t, g = d.length, T = /^#\d+$/.test(t) ? new RegExp(`\\s${t}(?:\\s|[\\[]|$)`) : null, C = [];
4960
- for (let L = 0; L < d.length; L++) {
4898
+ ...s
4899
+ } = n ?? {}, a = Math.max(0, i), c = Math.max(1, o), { lines: d, refMap: u, yaml: h } = buildA11yTree(e, s), p = r ? t.toLowerCase() : t, m = d.length, E = /^#\d+$/.test(t) ? new RegExp(`\\s${t}(?:\\s|[\\[]|$)`) : null, L = [];
4900
+ for (let C = 0; C < d.length; C++) {
4961
4901
  let S = !1;
4962
- T ? S = T.test(d[L]) : S = (r ? d[L].toLowerCase() : d[L]).includes(h), S && C.push(L);
4902
+ E ? S = E.test(d[C]) : S = (r ? d[C].toLowerCase() : d[C]).includes(p), S && L.push(C);
4963
4903
  }
4964
4904
  const f = [];
4965
- let m = !1;
4966
- for (const L of C) {
4967
- const S = Math.max(0, L - s), A = Math.min(g - 1, L + s), N = f[f.length - 1];
4968
- if (N && S <= N.end + 1)
4969
- N.end = Math.max(N.end, A), N.hits.push(L);
4905
+ let b = !1;
4906
+ for (const C of L) {
4907
+ const S = Math.max(0, C - a), A = Math.min(m - 1, C + a), D = f[f.length - 1];
4908
+ if (D && S <= D.end + 1)
4909
+ D.end = Math.max(D.end, A), D.hits.push(C);
4970
4910
  else {
4971
4911
  if (f.length >= c) {
4972
- m = !0;
4912
+ b = !0;
4973
4913
  break;
4974
4914
  }
4975
- f.push({ start: S, end: A, hits: [L] });
4915
+ f.push({ start: S, end: A, hits: [C] });
4976
4916
  }
4977
4917
  }
4978
- const E = f.map((L) => ({
4979
- lineNumber: L.hits[0] + 1,
4980
- line: d[L.hits[0]],
4981
- context: Array.from({ length: L.end - L.start + 1 }, (S, A) => ({
4982
- lineNumber: L.start + A + 1,
4983
- line: d[L.start + A]
4918
+ const T = f.map((C) => ({
4919
+ lineNumber: C.hits[0] + 1,
4920
+ line: d[C.hits[0]],
4921
+ context: Array.from({ length: C.end - C.start + 1 }, (S, A) => ({
4922
+ lineNumber: C.start + A + 1,
4923
+ line: d[C.start + A]
4984
4924
  }))
4985
- })), v = [
4986
- `无障碍树搜索结果 — 关键词: "${t}" | 总行数: ${g} | 命中: ${C.length} 行 | 返回分组: ${E.length}`,
4925
+ })), y = [
4926
+ `无障碍树搜索结果 — 关键词: "${t}" | 总行数: ${m} | 命中: ${L.length} 行 | 返回分组: ${T.length}`,
4987
4927
  ""
4988
4928
  ];
4989
- return E.length === 0 ? v.push("(未找到匹配项)") : (E.forEach((L, S) => {
4929
+ return T.length === 0 ? y.push("(未找到匹配项)") : (T.forEach((C, S) => {
4990
4930
  const A = f[S];
4991
- v.push(`── 分组 ${S + 1}(第 ${A.start + 1}–${A.end + 1} 行)──`), L.context.forEach(({ lineNumber: N, line: M }) => {
4992
- const O = A.hits.includes(N - 1), F = String(N).padStart(4);
4993
- v.push(O ? `>>>${F} | ${M}` : ` ${F} | ${M}`);
4994
- }), v.push("");
4995
- }), m && v.push(`⚠️ 命中过多,已截断至前 ${c} 个分组,建议缩小搜索范围`), v.push("提示:如需操作命中元素,使用其 #N 索引;如需查看完整树,请使用 browserState。")), {
4996
- text: v.join(`
4931
+ y.push(`── 分组 ${S + 1}(第 ${A.start + 1}–${A.end + 1} 行)──`), C.context.forEach(({ lineNumber: D, line: P }) => {
4932
+ const R = A.hits.includes(D - 1), F = String(D).padStart(4);
4933
+ y.push(R ? `>>>${F} | ${P}` : ` ${F} | ${P}`);
4934
+ }), y.push("");
4935
+ }), b && y.push(`⚠️ 命中过多,已截断至前 ${c} 个分组,建议缩小搜索范围`), y.push("提示:如需操作命中元素,使用其 #N 索引;如需查看完整树,请使用 browserState。")), {
4936
+ text: y.join(`
4997
4937
  `),
4998
- matches: E,
4999
- totalLines: g,
5000
- matchCount: C.length,
4938
+ matches: T,
4939
+ totalLines: m,
4940
+ matchCount: L.length,
5001
4941
  refMap: u,
5002
- yaml: p
4942
+ yaml: h
5003
4943
  };
5004
4944
  }
5005
4945
  function Diff() {
@@ -5008,66 +4948,66 @@ Diff.prototype = {
5008
4948
  diff: function t(e, n) {
5009
4949
  var i, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, o = r.callback;
5010
4950
  typeof r == "function" && (o = r, r = {});
5011
- var a = this;
5012
- function s(v) {
5013
- return v = a.postProcess(v, r), o ? (setTimeout(function() {
5014
- o(v);
5015
- }, 0), !0) : v;
4951
+ var s = this;
4952
+ function a(y) {
4953
+ return y = s.postProcess(y, r), o ? (setTimeout(function() {
4954
+ o(y);
4955
+ }, 0), !0) : y;
5016
4956
  }
5017
4957
  e = this.castInput(e, r), n = this.castInput(n, r), e = this.removeEmpty(this.tokenize(e, r)), n = this.removeEmpty(this.tokenize(n, r));
5018
- var c = n.length, d = e.length, u = 1, p = c + d;
5019
- r.maxEditLength != null && (p = Math.min(p, r.maxEditLength));
5020
- var h = (i = r.timeout) !== null && i !== void 0 ? i : 1 / 0, g = Date.now() + h, y = [{
4958
+ var c = n.length, d = e.length, u = 1, h = c + d;
4959
+ r.maxEditLength != null && (h = Math.min(h, r.maxEditLength));
4960
+ var p = (i = r.timeout) !== null && i !== void 0 ? i : 1 / 0, m = Date.now() + p, g = [{
5021
4961
  oldPos: -1,
5022
4962
  lastComponent: void 0
5023
- }], T = this.extractCommon(y[0], n, e, 0, r);
5024
- if (y[0].oldPos + 1 >= d && T + 1 >= c)
5025
- return s(buildValues(a, y[0].lastComponent, n, e, a.useLongestToken));
5026
- var C = -1 / 0, f = 1 / 0;
5027
- function m() {
5028
- for (var v = Math.max(C, -u); v <= Math.min(f, u); v += 2) {
5029
- var L = void 0, S = y[v - 1], A = y[v + 1];
5030
- S && (y[v - 1] = void 0);
5031
- var N = !1;
4963
+ }], E = this.extractCommon(g[0], n, e, 0, r);
4964
+ if (g[0].oldPos + 1 >= d && E + 1 >= c)
4965
+ return a(buildValues(s, g[0].lastComponent, n, e, s.useLongestToken));
4966
+ var L = -1 / 0, f = 1 / 0;
4967
+ function b() {
4968
+ for (var y = Math.max(L, -u); y <= Math.min(f, u); y += 2) {
4969
+ var C = void 0, S = g[y - 1], A = g[y + 1];
4970
+ S && (g[y - 1] = void 0);
4971
+ var D = !1;
5032
4972
  if (A) {
5033
- var M = A.oldPos - v;
5034
- N = A && 0 <= M && M < c;
4973
+ var P = A.oldPos - y;
4974
+ D = A && 0 <= P && P < c;
5035
4975
  }
5036
- var O = S && S.oldPos + 1 < d;
5037
- if (!N && !O) {
5038
- y[v] = void 0;
4976
+ var R = S && S.oldPos + 1 < d;
4977
+ if (!D && !R) {
4978
+ g[y] = void 0;
5039
4979
  continue;
5040
4980
  }
5041
- if (!O || N && S.oldPos < A.oldPos ? L = a.addToPath(A, !0, !1, 0, r) : L = a.addToPath(S, !1, !0, 1, r), T = a.extractCommon(L, n, e, v, r), L.oldPos + 1 >= d && T + 1 >= c)
5042
- return s(buildValues(a, L.lastComponent, n, e, a.useLongestToken));
5043
- y[v] = L, L.oldPos + 1 >= d && (f = Math.min(f, v - 1)), T + 1 >= c && (C = Math.max(C, v + 1));
4981
+ if (!R || D && S.oldPos < A.oldPos ? C = s.addToPath(A, !0, !1, 0, r) : C = s.addToPath(S, !1, !0, 1, r), E = s.extractCommon(C, n, e, y, r), C.oldPos + 1 >= d && E + 1 >= c)
4982
+ return a(buildValues(s, C.lastComponent, n, e, s.useLongestToken));
4983
+ g[y] = C, C.oldPos + 1 >= d && (f = Math.min(f, y - 1)), E + 1 >= c && (L = Math.max(L, y + 1));
5044
4984
  }
5045
4985
  u++;
5046
4986
  }
5047
4987
  if (o)
5048
- (function v() {
4988
+ (function y() {
5049
4989
  setTimeout(function() {
5050
- if (u > p || Date.now() > g)
4990
+ if (u > h || Date.now() > m)
5051
4991
  return o();
5052
- m() || v();
4992
+ b() || y();
5053
4993
  }, 0);
5054
4994
  })();
5055
4995
  else
5056
- for (; u <= p && Date.now() <= g; ) {
5057
- var E = m();
5058
- if (E)
5059
- return E;
4996
+ for (; u <= h && Date.now() <= m; ) {
4997
+ var T = b();
4998
+ if (T)
4999
+ return T;
5060
5000
  }
5061
5001
  },
5062
5002
  addToPath: function t(e, n, i, r, o) {
5063
- var a = e.lastComponent;
5064
- return a && !o.oneChangePerToken && a.added === n && a.removed === i ? {
5003
+ var s = e.lastComponent;
5004
+ return s && !o.oneChangePerToken && s.added === n && s.removed === i ? {
5065
5005
  oldPos: e.oldPos + r,
5066
5006
  lastComponent: {
5067
- count: a.count + 1,
5007
+ count: s.count + 1,
5068
5008
  added: n,
5069
5009
  removed: i,
5070
- previousComponent: a.previousComponent
5010
+ previousComponent: s.previousComponent
5071
5011
  }
5072
5012
  } : {
5073
5013
  oldPos: e.oldPos + r,
@@ -5075,12 +5015,12 @@ Diff.prototype = {
5075
5015
  count: 1,
5076
5016
  added: n,
5077
5017
  removed: i,
5078
- previousComponent: a
5018
+ previousComponent: s
5079
5019
  }
5080
5020
  };
5081
5021
  },
5082
5022
  extractCommon: function t(e, n, i, r, o) {
5083
- for (var a = n.length, s = i.length, c = e.oldPos, d = c - r, u = 0; d + 1 < a && c + 1 < s && this.equals(i[c + 1], n[d + 1], o); )
5023
+ for (var s = n.length, a = i.length, c = e.oldPos, d = c - r, u = 0; d + 1 < s && c + 1 < a && this.equals(i[c + 1], n[d + 1], o); )
5084
5024
  d++, c++, u++, o.oneChangePerToken && (e.lastComponent = {
5085
5025
  count: 1,
5086
5026
  previousComponent: e.lastComponent,
@@ -5116,23 +5056,23 @@ Diff.prototype = {
5116
5056
  }
5117
5057
  };
5118
5058
  function buildValues(t, e, n, i, r) {
5119
- for (var o = [], a; e; )
5120
- o.push(e), a = e.previousComponent, delete e.previousComponent, e = a;
5059
+ for (var o = [], s; e; )
5060
+ o.push(e), s = e.previousComponent, delete e.previousComponent, e = s;
5121
5061
  o.reverse();
5122
- for (var s = 0, c = o.length, d = 0, u = 0; s < c; s++) {
5123
- var p = o[s];
5124
- if (p.removed)
5125
- p.value = t.join(i.slice(u, u + p.count)), u += p.count;
5062
+ for (var a = 0, c = o.length, d = 0, u = 0; a < c; a++) {
5063
+ var h = o[a];
5064
+ if (h.removed)
5065
+ h.value = t.join(i.slice(u, u + h.count)), u += h.count;
5126
5066
  else {
5127
- if (!p.added && r) {
5128
- var h = n.slice(d, d + p.count);
5129
- h = h.map(function(g, y) {
5130
- var T = i[u + y];
5131
- return T.length > g.length ? T : g;
5132
- }), p.value = t.join(h);
5067
+ if (!h.added && r) {
5068
+ var p = n.slice(d, d + h.count);
5069
+ p = p.map(function(m, g) {
5070
+ var E = i[u + g];
5071
+ return E.length > m.length ? E : m;
5072
+ }), h.value = t.join(p);
5133
5073
  } else
5134
- p.value = t.join(n.slice(d, d + p.count));
5135
- d += p.count, p.added || (u += p.count);
5074
+ h.value = t.join(n.slice(d, d + h.count));
5075
+ d += h.count, h.added || (u += h.count);
5136
5076
  }
5137
5077
  }
5138
5078
  return o;
@@ -5181,16 +5121,16 @@ function overlapCount(t, e) {
5181
5121
  t.length < e.length && (i = t.length);
5182
5122
  var r = Array(i), o = 0;
5183
5123
  r[0] = 0;
5184
- for (var a = 1; a < i; a++) {
5185
- for (e[a] == e[o] ? r[a] = r[o] : r[a] = o; o > 0 && e[a] != e[o]; )
5124
+ for (var s = 1; s < i; s++) {
5125
+ for (e[s] == e[o] ? r[s] = r[o] : r[s] = o; o > 0 && e[s] != e[o]; )
5186
5126
  o = r[o];
5187
- e[a] == e[o] && o++;
5127
+ e[s] == e[o] && o++;
5188
5128
  }
5189
5129
  o = 0;
5190
- for (var s = n; s < t.length; s++) {
5191
- for (; o > 0 && t[s] != e[o]; )
5130
+ for (var a = n; a < t.length; a++) {
5131
+ for (; o > 0 && t[a] != e[o]; )
5192
5132
  o = r[o];
5193
- t[s] == e[o] && o++;
5133
+ t[a] == e[o] && o++;
5194
5134
  }
5195
5135
  return o;
5196
5136
  }
@@ -5228,28 +5168,28 @@ wordDiff.postProcess = function(t, e) {
5228
5168
  };
5229
5169
  function dedupeWhitespaceInChangeObjects(t, e, n, i) {
5230
5170
  if (e && n) {
5231
- var r = e.value.match(/^\s*/)[0], o = e.value.match(/\s*$/)[0], a = n.value.match(/^\s*/)[0], s = n.value.match(/\s*$/)[0];
5171
+ var r = e.value.match(/^\s*/)[0], o = e.value.match(/\s*$/)[0], s = n.value.match(/^\s*/)[0], a = n.value.match(/\s*$/)[0];
5232
5172
  if (t) {
5233
- var c = longestCommonPrefix(r, a);
5234
- t.value = replaceSuffix(t.value, a, c), e.value = removePrefix(e.value, c), n.value = removePrefix(n.value, c);
5173
+ var c = longestCommonPrefix(r, s);
5174
+ t.value = replaceSuffix(t.value, s, c), e.value = removePrefix(e.value, c), n.value = removePrefix(n.value, c);
5235
5175
  }
5236
5176
  if (i) {
5237
- var d = longestCommonSuffix(o, s);
5238
- i.value = replacePrefix(i.value, s, d), e.value = removeSuffix(e.value, d), n.value = removeSuffix(n.value, d);
5177
+ var d = longestCommonSuffix(o, a);
5178
+ i.value = replacePrefix(i.value, a, d), e.value = removeSuffix(e.value, d), n.value = removeSuffix(n.value, d);
5239
5179
  }
5240
5180
  } else if (n)
5241
5181
  t && (n.value = n.value.replace(/^\s*/, "")), i && (i.value = i.value.replace(/^\s*/, ""));
5242
5182
  else if (t && i) {
5243
- var u = i.value.match(/^\s*/)[0], p = e.value.match(/^\s*/)[0], h = e.value.match(/\s*$/)[0], g = longestCommonPrefix(u, p);
5244
- e.value = removePrefix(e.value, g);
5245
- var y = longestCommonSuffix(removePrefix(u, g), h);
5246
- e.value = removeSuffix(e.value, y), i.value = replacePrefix(i.value, u, y), t.value = replaceSuffix(t.value, u, u.slice(0, u.length - y.length));
5183
+ var u = i.value.match(/^\s*/)[0], h = e.value.match(/^\s*/)[0], p = e.value.match(/\s*$/)[0], m = longestCommonPrefix(u, h);
5184
+ e.value = removePrefix(e.value, m);
5185
+ var g = longestCommonSuffix(removePrefix(u, m), p);
5186
+ e.value = removeSuffix(e.value, g), i.value = replacePrefix(i.value, u, g), t.value = replaceSuffix(t.value, u, u.slice(0, u.length - g.length));
5247
5187
  } else if (i) {
5248
- var T = i.value.match(/^\s*/)[0], C = e.value.match(/\s*$/)[0], f = maximumOverlap(C, T);
5188
+ var E = i.value.match(/^\s*/)[0], L = e.value.match(/\s*$/)[0], f = maximumOverlap(L, E);
5249
5189
  e.value = removeSuffix(e.value, f);
5250
5190
  } else if (t) {
5251
- var m = t.value.match(/\s*$/)[0], E = e.value.match(/^\s*/)[0], v = maximumOverlap(m, E);
5252
- e.value = removePrefix(e.value, v);
5191
+ var b = t.value.match(/\s*$/)[0], T = e.value.match(/^\s*/)[0], y = maximumOverlap(b, T);
5192
+ e.value = removePrefix(e.value, y);
5253
5193
  }
5254
5194
  }
5255
5195
  var wordWithSpaceDiff = new Diff();
@@ -5299,8 +5239,8 @@ var jsonDiff = new Diff();
5299
5239
  jsonDiff.useLongestToken = !0;
5300
5240
  jsonDiff.tokenize = lineDiff.tokenize;
5301
5241
  jsonDiff.castInput = function(t, e) {
5302
- var n = e.undefinedReplacement, i = e.stringifyReplacer, r = i === void 0 ? function(o, a) {
5303
- return typeof a > "u" ? n : a;
5242
+ var n = e.undefinedReplacement, i = e.stringifyReplacer, r = i === void 0 ? function(o, s) {
5243
+ return typeof s > "u" ? n : s;
5304
5244
  } : i;
5305
5245
  return typeof t == "string" ? t : JSON.stringify(canonicalize(t, null, null, r), r, " ");
5306
5246
  };
@@ -5313,23 +5253,23 @@ function canonicalize(t, e, n, i, r) {
5313
5253
  for (o = 0; o < e.length; o += 1)
5314
5254
  if (e[o] === t)
5315
5255
  return n[o];
5316
- var a;
5256
+ var s;
5317
5257
  if (Object.prototype.toString.call(t) === "[object Array]") {
5318
- for (e.push(t), a = new Array(t.length), n.push(a), o = 0; o < t.length; o += 1)
5319
- a[o] = canonicalize(t[o], e, n, i, r);
5320
- return e.pop(), n.pop(), a;
5258
+ for (e.push(t), s = new Array(t.length), n.push(s), o = 0; o < t.length; o += 1)
5259
+ s[o] = canonicalize(t[o], e, n, i, r);
5260
+ return e.pop(), n.pop(), s;
5321
5261
  }
5322
5262
  if (t && t.toJSON && (t = t.toJSON()), _typeof(t) === "object" && t !== null) {
5323
- e.push(t), a = {}, n.push(a);
5324
- var s = [], c;
5263
+ e.push(t), s = {}, n.push(s);
5264
+ var a = [], c;
5325
5265
  for (c in t)
5326
- Object.prototype.hasOwnProperty.call(t, c) && s.push(c);
5327
- for (s.sort(), o = 0; o < s.length; o += 1)
5328
- c = s[o], a[c] = canonicalize(t[c], e, n, i, c);
5266
+ Object.prototype.hasOwnProperty.call(t, c) && a.push(c);
5267
+ for (a.sort(), o = 0; o < a.length; o += 1)
5268
+ c = a[o], s[c] = canonicalize(t[c], e, n, i, c);
5329
5269
  e.pop(), n.pop();
5330
5270
  } else
5331
- a = t;
5332
- return a;
5271
+ s = t;
5272
+ return s;
5333
5273
  }
5334
5274
  var arrayDiff = new Diff();
5335
5275
  arrayDiff.tokenize = function(t) {
@@ -5353,18 +5293,18 @@ class PageStateCache {
5353
5293
  */
5354
5294
  update(e, n) {
5355
5295
  const i = this.isFullRefresh(e), r = this.prev?.url ?? "";
5356
- let o = 0, a = 0, s = "";
5296
+ let o = 0, s = 0, a = "";
5357
5297
  if (!i && this.prev) {
5358
5298
  const c = diffLines(this.prev.yaml, n), d = [];
5359
5299
  c.forEach((u) => {
5360
5300
  if (!u.added && !u.removed) return;
5361
- const p = u.value.split(`
5301
+ const h = u.value.split(`
5362
5302
  `).filter(Boolean);
5363
- u.added ? (o += p.length, p.forEach((h) => d.push(`+ ${h}`))) : (a += p.length, p.forEach((h) => d.push(`- ${h}`)));
5364
- }), s = d.join(`
5303
+ u.added ? (o += h.length, h.forEach((p) => d.push(`+ ${p}`))) : (s += h.length, h.forEach((p) => d.push(`- ${p}`)));
5304
+ }), a = d.join(`
5365
5305
  `);
5366
5306
  }
5367
- return this.prev = { url: e, yaml: n }, { isFullRefresh: i, prevUrl: r, addedLines: o, removedLines: a, diffText: s };
5307
+ return this.prev = { url: e, yaml: n }, { isFullRefresh: i, prevUrl: r, addedLines: o, removedLines: s, diffText: a };
5368
5308
  }
5369
5309
  /** 强制清空缓存(页面刷新 / 手动重置场景) */
5370
5310
  invalidate() {
@@ -5372,58 +5312,58 @@ class PageStateCache {
5372
5312
  }
5373
5313
  }
5374
5314
  function computeBorderGeometry(t, e, n, i) {
5375
- const r = Math.max(1, Math.min(t, e)), o = Math.min(n, 20), s = Math.min(o + i, r), c = Math.min(s, Math.floor(t / 2)), d = Math.min(s, Math.floor(e / 2)), u = (b) => b / t * 2 - 1, p = (b) => b / e * 2 - 1, h = 0, g = t, y = 0, T = e, C = c, f = t - c, m = d, E = e - d, v = u(h), L = u(g), S = p(y), A = p(T), N = u(C), M = u(f), O = p(m), F = p(E), B = 0, J = 0, G = 1, Q = 1, ee = c / t, te = 1 - c / t, W = d / e, Z = 1 - d / e, ce = new Float32Array([
5315
+ const r = Math.max(1, Math.min(t, e)), o = Math.min(n, 20), a = Math.min(o + i, r), c = Math.min(a, Math.floor(t / 2)), d = Math.min(a, Math.floor(e / 2)), u = (w) => w / t * 2 - 1, h = (w) => w / e * 2 - 1, p = 0, m = t, g = 0, E = e, L = c, f = t - c, b = d, T = e - d, y = u(p), C = u(m), S = h(g), A = h(E), D = u(L), P = u(f), R = h(b), F = h(T), B = 0, J = 0, G = 1, Q = 1, ee = c / t, te = 1 - c / t, W = d / e, Z = 1 - d / e, ce = new Float32Array([
5376
5316
  // Top strip
5377
- v,
5317
+ y,
5378
5318
  S,
5379
- L,
5319
+ C,
5380
5320
  S,
5381
- v,
5382
- O,
5383
- v,
5384
- O,
5385
- L,
5321
+ y,
5322
+ R,
5323
+ y,
5324
+ R,
5325
+ C,
5386
5326
  S,
5387
- L,
5388
- O,
5327
+ C,
5328
+ R,
5389
5329
  // Bottom strip
5390
- v,
5330
+ y,
5391
5331
  F,
5392
- L,
5332
+ C,
5393
5333
  F,
5394
- v,
5334
+ y,
5395
5335
  A,
5396
- v,
5336
+ y,
5397
5337
  A,
5398
- L,
5338
+ C,
5399
5339
  F,
5400
- L,
5340
+ C,
5401
5341
  A,
5402
5342
  // Left strip
5403
- v,
5404
- O,
5405
- N,
5406
- O,
5407
- v,
5343
+ y,
5344
+ R,
5345
+ D,
5346
+ R,
5347
+ y,
5408
5348
  F,
5409
- v,
5349
+ y,
5410
5350
  F,
5411
- N,
5412
- O,
5413
- N,
5351
+ D,
5352
+ R,
5353
+ D,
5414
5354
  F,
5415
5355
  // Right strip
5416
- M,
5417
- O,
5418
- L,
5419
- O,
5420
- M,
5356
+ P,
5357
+ R,
5358
+ C,
5359
+ R,
5360
+ P,
5421
5361
  F,
5422
- M,
5362
+ P,
5423
5363
  F,
5424
- L,
5425
- O,
5426
- L,
5364
+ C,
5365
+ R,
5366
+ C,
5427
5367
  F
5428
5368
  ]), l = new Float32Array([
5429
5369
  // Top strip
@@ -5494,8 +5434,8 @@ function createProgram(t, e, n) {
5494
5434
  const i = compileShader(t, t.VERTEX_SHADER, e), r = compileShader(t, t.FRAGMENT_SHADER, n), o = t.createProgram();
5495
5435
  if (!o) throw new Error("Failed to create program");
5496
5436
  if (t.attachShader(o, i), t.attachShader(o, r), t.linkProgram(o), !t.getProgramParameter(o, t.LINK_STATUS)) {
5497
- const a = t.getProgramInfoLog(o) || "Unknown link error";
5498
- throw t.deleteProgram(o), t.deleteShader(i), t.deleteShader(r), new Error(a);
5437
+ const s = t.getProgramInfoLog(o) || "Unknown link error";
5438
+ throw t.deleteProgram(o), t.deleteShader(i), t.deleteShader(r), new Error(s);
5499
5439
  }
5500
5440
  return t.deleteShader(i), t.deleteShader(r), o;
5501
5441
  }
@@ -5678,23 +5618,23 @@ class Motion {
5678
5618
  resize(e, n, i) {
5679
5619
  if (this.disposed) throw new Error("Motion instance has been disposed.");
5680
5620
  if (this.options.width = e, this.options.height = n, i && (this.options.ratio = i), !this.running) return;
5681
- const { gl: r, program: o, vao: a, positionBuffer: s, uvBuffer: c, uResolution: d } = this.glr, u = i ?? this.options.ratio ?? window.devicePixelRatio ?? 1, p = Math.max(1, Math.floor(e * u)), h = Math.max(1, Math.floor(n * u));
5682
- this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, (this.canvas.width !== p || this.canvas.height !== h) && (this.canvas.width = p, this.canvas.height = h), r.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(r, "resize: after viewport setup");
5683
- const { positions: g, uvs: y } = computeBorderGeometry(
5621
+ const { gl: r, program: o, vao: s, positionBuffer: a, uvBuffer: c, uResolution: d } = this.glr, u = i ?? this.options.ratio ?? window.devicePixelRatio ?? 1, h = Math.max(1, Math.floor(e * u)), p = Math.max(1, Math.floor(n * u));
5622
+ this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, (this.canvas.width !== h || this.canvas.height !== p) && (this.canvas.width = h, this.canvas.height = p), r.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(r, "resize: after viewport setup");
5623
+ const { positions: m, uvs: g } = computeBorderGeometry(
5684
5624
  this.canvas.width,
5685
5625
  this.canvas.height,
5686
5626
  this.options.borderWidth * u,
5687
5627
  this.options.glowWidth * u
5688
5628
  );
5689
- r.bindVertexArray(a), r.bindBuffer(r.ARRAY_BUFFER, s), r.bufferData(r.ARRAY_BUFFER, g, r.STATIC_DRAW);
5690
- const T = r.getAttribLocation(o, "aPosition");
5691
- r.enableVertexAttribArray(T), r.vertexAttribPointer(T, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after position buffer update"), r.bindBuffer(r.ARRAY_BUFFER, c), r.bufferData(r.ARRAY_BUFFER, y, r.STATIC_DRAW);
5692
- const C = r.getAttribLocation(o, "aUV");
5693
- r.enableVertexAttribArray(C), r.vertexAttribPointer(C, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after UV buffer update"), r.useProgram(o), r.uniform2f(d, this.canvas.width, this.canvas.height), r.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * u), r.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * u), r.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * u), this.checkGLError(r, "resize: after uniform updates");
5629
+ r.bindVertexArray(s), r.bindBuffer(r.ARRAY_BUFFER, a), r.bufferData(r.ARRAY_BUFFER, m, r.STATIC_DRAW);
5630
+ const E = r.getAttribLocation(o, "aPosition");
5631
+ r.enableVertexAttribArray(E), r.vertexAttribPointer(E, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after position buffer update"), r.bindBuffer(r.ARRAY_BUFFER, c), r.bufferData(r.ARRAY_BUFFER, g, r.STATIC_DRAW);
5632
+ const L = r.getAttribLocation(o, "aUV");
5633
+ r.enableVertexAttribArray(L), r.vertexAttribPointer(L, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after UV buffer update"), r.useProgram(o), r.uniform2f(d, this.canvas.width, this.canvas.height), r.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * u), r.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * u), r.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * u), this.checkGLError(r, "resize: after uniform updates");
5694
5634
  const f = performance.now();
5695
5635
  this.lastTime = f;
5696
- const m = (f - this.startTime) * 1e-3;
5697
- this.render(m);
5636
+ const b = (f - this.startTime) * 1e-3;
5637
+ this.render(b);
5698
5638
  }
5699
5639
  /**
5700
5640
  * Automatically resizes the canvas to match the dimensions of the given element.
@@ -5768,35 +5708,35 @@ class Motion {
5768
5708
  this.checkGLError(e, "setupGL: after createProgram");
5769
5709
  const i = e.createVertexArray();
5770
5710
  e.bindVertexArray(i), this.checkGLError(e, "setupGL: after VAO creation");
5771
- const r = this.canvas.width || 2, o = this.canvas.height || 2, { positions: a, uvs: s } = computeBorderGeometry(
5711
+ const r = this.canvas.width || 2, o = this.canvas.height || 2, { positions: s, uvs: a } = computeBorderGeometry(
5772
5712
  r,
5773
5713
  o,
5774
5714
  this.options.borderWidth,
5775
5715
  this.options.glowWidth
5776
5716
  ), c = e.createBuffer();
5777
- e.bindBuffer(e.ARRAY_BUFFER, c), e.bufferData(e.ARRAY_BUFFER, a, e.STATIC_DRAW);
5717
+ e.bindBuffer(e.ARRAY_BUFFER, c), e.bufferData(e.ARRAY_BUFFER, s, e.STATIC_DRAW);
5778
5718
  const d = e.getAttribLocation(n, "aPosition");
5779
5719
  e.enableVertexAttribArray(d), e.vertexAttribPointer(d, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after position buffer setup");
5780
5720
  const u = e.createBuffer();
5781
- e.bindBuffer(e.ARRAY_BUFFER, u), e.bufferData(e.ARRAY_BUFFER, s, e.STATIC_DRAW);
5782
- const p = e.getAttribLocation(n, "aUV");
5783
- e.enableVertexAttribArray(p), e.vertexAttribPointer(p, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
5784
- const h = e.getUniformLocation(n, "uResolution"), g = e.getUniformLocation(n, "uTime"), y = e.getUniformLocation(n, "uBorderWidth"), T = e.getUniformLocation(n, "uGlowWidth"), C = e.getUniformLocation(n, "uBorderRadius"), f = e.getUniformLocation(n, "uColors"), m = e.getUniformLocation(n, "uGlowExponent"), E = e.getUniformLocation(n, "uGlowFactor");
5785
- e.useProgram(n), e.uniform1f(y, this.options.borderWidth), e.uniform1f(T, this.options.glowWidth), e.uniform1f(C, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(m, 2), e.uniform1f(E, 1.8)) : (e.uniform1f(m, 1), e.uniform1f(E, 1));
5786
- const v = (this.options.colors || DEFAULT_COLORS).map(parseColor);
5787
- for (let L = 0; L < v.length; L++)
5788
- e.uniform3f(e.getUniformLocation(n, `uColors[${L}]`), ...v[L]);
5721
+ e.bindBuffer(e.ARRAY_BUFFER, u), e.bufferData(e.ARRAY_BUFFER, a, e.STATIC_DRAW);
5722
+ const h = e.getAttribLocation(n, "aUV");
5723
+ e.enableVertexAttribArray(h), e.vertexAttribPointer(h, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
5724
+ const p = e.getUniformLocation(n, "uResolution"), m = e.getUniformLocation(n, "uTime"), g = e.getUniformLocation(n, "uBorderWidth"), E = e.getUniformLocation(n, "uGlowWidth"), L = e.getUniformLocation(n, "uBorderRadius"), f = e.getUniformLocation(n, "uColors"), b = e.getUniformLocation(n, "uGlowExponent"), T = e.getUniformLocation(n, "uGlowFactor");
5725
+ e.useProgram(n), e.uniform1f(g, this.options.borderWidth), e.uniform1f(E, this.options.glowWidth), e.uniform1f(L, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(b, 2), e.uniform1f(T, 1.8)) : (e.uniform1f(b, 1), e.uniform1f(T, 1));
5726
+ const y = (this.options.colors || DEFAULT_COLORS).map(parseColor);
5727
+ for (let C = 0; C < y.length; C++)
5728
+ e.uniform3f(e.getUniformLocation(n, `uColors[${C}]`), ...y[C]);
5789
5729
  this.checkGLError(e, "setupGL: after uniform setup"), e.bindVertexArray(null), e.bindBuffer(e.ARRAY_BUFFER, null), this.glr = {
5790
5730
  gl: e,
5791
5731
  program: n,
5792
5732
  vao: i,
5793
5733
  positionBuffer: c,
5794
5734
  uvBuffer: u,
5795
- uResolution: h,
5796
- uTime: g,
5797
- uBorderWidth: y,
5798
- uGlowWidth: T,
5799
- uBorderRadius: C,
5735
+ uResolution: p,
5736
+ uTime: m,
5737
+ uBorderWidth: g,
5738
+ uGlowWidth: E,
5739
+ uBorderRadius: L,
5800
5740
  uColors: f
5801
5741
  };
5802
5742
  }
@@ -5854,8 +5794,8 @@ function isMainContentBackgroundDark() {
5854
5794
  for (const r of i) {
5855
5795
  const o = document.querySelector(r);
5856
5796
  if (!o) continue;
5857
- const a = o.getBoundingClientRect();
5858
- if (!(a.width * a.height < n) && isColorDark(window.getComputedStyle(o).backgroundColor))
5797
+ const s = o.getBoundingClientRect();
5798
+ if (!(s.width * s.height < n) && isColorDark(window.getComputedStyle(o).backgroundColor))
5859
5799
  return !0;
5860
5800
  }
5861
5801
  return !1;
@@ -5953,26 +5893,26 @@ class SimulatorMask extends EventTarget {
5953
5893
  constructor() {
5954
5894
  super(), this.shown = !1, this.wrapper = document.createElement("div"), this.motion = null, this.#i = !1, this.#e = document.createElement("div"), this.#t = 0, this.#n = 0, this.#r = 0, this.#o = 0, document.head.appendChild(document.createElement("style")).textContent = injectStyles, this.wrapper.id = "page-agent-runtime_simulator-mask", this.wrapper.className = "webmcp-page-agent-wrapper", this.wrapper.setAttribute("data-browser-use-ignore", "true"), this.wrapper.setAttribute("data-page-agent-ignore", "true");
5955
5895
  try {
5956
- const a = new Motion({
5896
+ const s = new Motion({
5957
5897
  mode: isPageDark() ? "dark" : "light",
5958
5898
  styles: { position: "absolute", inset: "0" },
5959
5899
  glowWidth: 80,
5960
5900
  borderWidth: 8,
5961
5901
  colors: ["rgb(121, 216, 247)", "rgb(171, 219, 110)", "rgb(252, 188, 114)", "rgb(235, 117, 231)"]
5962
5902
  });
5963
- this.motion = a, this.wrapper.appendChild(a.element), a.autoResize(this.wrapper);
5964
- } catch (a) {
5965
- console.warn("[SimulatorMask] Motion overlay unavailable:", a);
5903
+ this.motion = s, this.wrapper.appendChild(s.element), s.autoResize(this.wrapper);
5904
+ } catch (s) {
5905
+ console.warn("[SimulatorMask] Motion overlay unavailable:", s);
5966
5906
  }
5967
- const e = (a) => {
5968
- a.stopPropagation(), a.preventDefault();
5907
+ const e = (s) => {
5908
+ s.stopPropagation(), s.preventDefault();
5969
5909
  };
5970
5910
  ["click", "mousedown", "mouseup", "mousemove", "wheel", "keydown", "keyup"].forEach(
5971
- (a) => this.wrapper.addEventListener(a, e)
5972
- ), this.#s(), document.body.appendChild(this.wrapper), this.#a();
5973
- const n = (a) => {
5974
- const { x: s, y: c } = a.detail;
5975
- this.setCursorPosition(s, c);
5911
+ (s) => this.wrapper.addEventListener(s, e)
5912
+ ), this.#a(), document.body.appendChild(this.wrapper), this.#s();
5913
+ const n = (s) => {
5914
+ const { x: a, y: c } = s.detail;
5915
+ this.setCursorPosition(a, c);
5976
5916
  }, i = () => {
5977
5917
  this.triggerClickAnimation();
5978
5918
  }, r = () => {
@@ -5990,19 +5930,19 @@ class SimulatorMask extends EventTarget {
5990
5930
  #n;
5991
5931
  #r;
5992
5932
  #o;
5993
- #s() {
5933
+ #a() {
5994
5934
  this.#e.className = "webmcp-page-agent-cursor";
5995
5935
  const e = document.createElement("div");
5996
5936
  e.className = "webmcp-page-agent-cursorRipple", this.#e.appendChild(e);
5997
5937
  const n = document.createElement("div");
5998
5938
  n.className = "webmcp-page-agent-cursorFilling", this.#e.appendChild(n), this.wrapper.appendChild(this.#e);
5999
5939
  }
6000
- #a() {
5940
+ #s() {
6001
5941
  if (this.#i) return;
6002
5942
  const e = this.#t + (this.#r - this.#t) * 0.2, n = this.#n + (this.#o - this.#n) * 0.2, i = Math.abs(e - this.#r);
6003
5943
  i > 0 && (i < 2 ? this.#t = this.#r : this.#t = e, this.#e.style.left = `${this.#t}px`);
6004
5944
  const r = Math.abs(n - this.#o);
6005
- r > 0 && (r < 2 ? this.#n = this.#o : this.#n = n, this.#e.style.top = `${this.#n}px`), requestAnimationFrame(() => this.#a());
5945
+ r > 0 && (r < 2 ? this.#n = this.#o : this.#n = n, this.#e.style.top = `${this.#n}px`), requestAnimationFrame(() => this.#s());
6006
5946
  }
6007
5947
  setCursorPosition(e, n) {
6008
5948
  this.#i || (this.#r = e, this.#o = n);
@@ -6025,15 +5965,15 @@ class SimulatorMask extends EventTarget {
6025
5965
  borderElement(e) {
6026
5966
  if (!e) return;
6027
5967
  this.wrapper.querySelector(".webmcp-page-agent-border")?.remove();
6028
- const n = e.getBoundingClientRect(), i = 2, r = 2, o = i + r, a = document.createElement("div");
6029
- a.className = "webmcp-page-agent-border", a.style.position = "absolute", a.style.left = `${n.left - o}px`, a.style.top = `${n.top - o}px`, a.style.width = `${n.width + o * 2}px`, a.style.height = `${n.height + o * 2}px`, a.style.boxSizing = "border-box", a.style.pointerEvents = "none", a.style.zIndex = "10000", a.style.border = `${r}px solid transparent`, a.style.borderImageSource = "linear-gradient(to bottom right, #79D8F7, #ABDB6E, #FCBC72, #FA8682, #EB75E7)", a.style.borderImageSlice = "1", a.style.borderImageWidth = `${r}px`, this.wrapper.appendChild(a);
5968
+ const n = e.getBoundingClientRect(), i = 2, r = 2, o = i + r, s = document.createElement("div");
5969
+ s.className = "webmcp-page-agent-border", s.style.position = "absolute", s.style.left = `${n.left - o}px`, s.style.top = `${n.top - o}px`, s.style.width = `${n.width + o * 2}px`, s.style.height = `${n.height + o * 2}px`, s.style.boxSizing = "border-box", s.style.pointerEvents = "none", s.style.zIndex = "10000", s.style.border = `${r}px solid transparent`, s.style.borderImageSource = "linear-gradient(to bottom right, #79D8F7, #ABDB6E, #FCBC72, #FA8682, #EB75E7)", s.style.borderImageSlice = "1", s.style.borderImageWidth = `${r}px`, this.wrapper.appendChild(s);
6030
5970
  }
6031
5971
  removeBorderElement() {
6032
5972
  this.wrapper.querySelector(".webmcp-page-agent-border")?.remove();
6033
5973
  }
6034
5974
  }
6035
5975
  const inputSchema = z.object({
6036
- action: z.enum(["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree"]).describe(`执行的动作名称, 每一次执行 'click', 'fill', 'select'动作之前,**必须**要先调用 'browserState' 去获取页面的最新状态。
5976
+ action: z.enum(["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree", "hover"]).describe(`执行的动作名称, 每一次执行 'click', 'fill', 'select', 'hover'动作之前,**必须**要先调用 'browserState' 去获取页面的最新状态。
6037
5977
  browserState: '查询整个页面的浏览器状态;返回页面的标题、URL、YAML格式的语义化页面树',
6038
5978
  click: '根据元素索引点击;',
6039
5979
  fill: '根据元素索引填写文本;';
@@ -6041,8 +5981,9 @@ const inputSchema = z.object({
6041
5981
  scroll: '滚动页面的动作,可以指定水平滚动还是上下滚动; 不带元素索引时:滚动整个文档。带元素索引时:滚动该索引处的容器(或其最近的可滚动祖先元素)'
6042
5982
  executeJavascript: '执行javascript代码'
6043
5983
  searchTree: '按关键词搜索无障碍树,返回带行号的匹配节点及上下文,无需获取全量树。适合快速定位特定元素(如所有按钮、特定名称的链接等),显著减少上下文消耗。必须提供 query 参数。'
5984
+ hover: '根据元素索引悬浮(hover)目标元素; 触发 mouseover/mouseenter 等事件,用于显示 tooltip、展开悬浮菜单等交互; 操作后自动返回最新页面状态。'
6044
5985
  `),
6045
- index: z.number().min(0).optional().describe("执行动作 of the element index, 动作为 click,fill,select时,必须提供元素索引"),
5986
+ index: z.number().min(0).optional().describe("执行动作 of the element index, 动作为 click,fill,select,hover时,必须提供元素索引"),
6046
5987
  text: z.string().optional().describe("执行动作的文本内容, 动作为 fill,select 时,必须提供文本内容"),
6047
5988
  down: z.boolean().optional().describe("执行上下滚动时,必须提供down参数"),
6048
5989
  right: z.boolean().optional().describe("执行水平滚动方向, 必须提供right参数"),
@@ -6067,8 +6008,8 @@ function dispatchPageAgentToolResult(t) {
6067
6008
  function setupPageAgentToolEventBridge(t, e) {
6068
6009
  window.__nextSdkPageAgentToolEventCleanup?.();
6069
6010
  const n = async (r) => {
6070
- const o = r.detail, a = o?.requestId;
6071
- if (!a) {
6011
+ const o = r.detail, s = o?.requestId;
6012
+ if (!s) {
6072
6013
  dispatchPageAgentToolResult({
6073
6014
  requestId: "",
6074
6015
  data: {
@@ -6079,10 +6020,10 @@ function setupPageAgentToolEventBridge(t, e) {
6079
6020
  return;
6080
6021
  }
6081
6022
  try {
6082
- const s = inputSchema.parse(o.data), c = await t(s);
6023
+ const a = inputSchema.parse(o.data), c = await t(a);
6083
6024
  if (isPageAgentToolErrorResult(c)) {
6084
6025
  dispatchPageAgentToolResult({
6085
- requestId: a,
6026
+ requestId: s,
6086
6027
  data: {
6087
6028
  success: !1,
6088
6029
  error: c.error,
@@ -6092,18 +6033,18 @@ function setupPageAgentToolEventBridge(t, e) {
6092
6033
  return;
6093
6034
  }
6094
6035
  dispatchPageAgentToolResult({
6095
- requestId: a,
6036
+ requestId: s,
6096
6037
  data: {
6097
6038
  success: !0,
6098
6039
  result: c
6099
6040
  }
6100
6041
  });
6101
- } catch (s) {
6042
+ } catch (a) {
6102
6043
  dispatchPageAgentToolResult({
6103
- requestId: a,
6044
+ requestId: s,
6104
6045
  data: {
6105
6046
  success: !1,
6106
- error: s instanceof Error ? s.message : String(s)
6047
+ error: a instanceof Error ? a.message : String(a)
6107
6048
  }
6108
6049
  });
6109
6050
  }
@@ -6117,15 +6058,21 @@ function setupPageAgentToolEventBridge(t, e) {
6117
6058
  window.removeEventListener(PAGE_AGENT_TOOL_CALL_EVENT, n), window.removeEventListener(PAGE_AGENT_CHAT_END_EVENT, i), window.__nextSdkPageAgentToolEventCleanup = void 0;
6118
6059
  };
6119
6060
  }
6061
+ function withStateFields(t, e) {
6062
+ try {
6063
+ const n = JSON.parse(t);
6064
+ return JSON.stringify({ ...n, ...e });
6065
+ } catch {
6066
+ return JSON.stringify({ ...e, raw: t });
6067
+ }
6068
+ }
6120
6069
  async function createActionErrorResult(t, e) {
6121
6070
  try {
6122
6071
  const n = await e("full");
6123
6072
  return {
6124
6073
  isError: !0,
6125
6074
  error: t,
6126
- content: [{ type: "text", text: `${t}
6127
-
6128
- ${n.content[0].text}` }]
6075
+ content: [{ type: "text", text: withStateFields(n.content[0].text, { error: t }) }]
6129
6076
  };
6130
6077
  } catch (n) {
6131
6078
  return {
@@ -6134,9 +6081,10 @@ ${n.content[0].text}` }]
6134
6081
  content: [
6135
6082
  {
6136
6083
  type: "text",
6137
- text: `${t}
6138
-
6139
- 获取最新浏览器状态失败: ${n instanceof Error ? n.message : String(n)}`
6084
+ text: JSON.stringify({
6085
+ error: t,
6086
+ stateError: n instanceof Error ? n.message : String(n)
6087
+ })
6140
6088
  }
6141
6089
  ]
6142
6090
  };
@@ -6189,11 +6137,11 @@ async function handleFill(t, e) {
6189
6137
  try {
6190
6138
  await inputTextElement(r, t.text), o = !0;
6191
6139
  } catch {
6192
- const s = Object.getOwnPropertyDescriptor(
6140
+ const a = Object.getOwnPropertyDescriptor(
6193
6141
  (r instanceof HTMLTextAreaElement ? HTMLTextAreaElement : HTMLInputElement).prototype,
6194
6142
  "value"
6195
6143
  )?.set;
6196
- s && (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement) && (s.call(r, t.text), r.dispatchEvent(new Event("focus", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("blur", { bubbles: !0, composed: !0 })), o = !0);
6144
+ a && (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement) && (a.call(r, t.text), r.dispatchEvent(new Event("focus", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("blur", { bubbles: !0, composed: !0 })), o = !0);
6197
6145
  }
6198
6146
  if (!o)
6199
6147
  return e.actionError(`填写结果: 无法填写元素 ${t.index},元素不是 input、textarea 或 contenteditable`);
@@ -6221,20 +6169,20 @@ async function handleSelect(t, e) {
6221
6169
  }
6222
6170
  function getScrollInfo(t = window) {
6223
6171
  if (t === window) {
6224
- const e = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth), i = window.scrollY, r = window.scrollX, o = Math.max(0, e - (window.innerHeight + i)), a = Math.max(0, n - (window.innerWidth + r));
6172
+ const e = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth), i = window.scrollY, r = window.scrollX, o = Math.max(0, e - (window.innerHeight + i)), s = Math.max(0, n - (window.innerWidth + r));
6225
6173
  return {
6226
6174
  scrollY: i,
6227
6175
  scrollX: r,
6228
6176
  pixelsAbove: i,
6229
6177
  pixelsBelow: o,
6230
6178
  pixelsLeft: r,
6231
- pixelsRight: a,
6179
+ pixelsRight: s,
6232
6180
  pagesAbove: window.innerHeight > 0 ? i / window.innerHeight : 0,
6233
6181
  pagesBelow: window.innerHeight > 0 ? o / window.innerHeight : 0,
6234
6182
  atTop: i <= 1,
6235
6183
  atBottom: o <= 1,
6236
6184
  atLeft: r <= 1,
6237
- atRight: a <= 1
6185
+ atRight: s <= 1
6238
6186
  };
6239
6187
  } else {
6240
6188
  const e = t, n = e.scrollTop, i = e.scrollLeft, r = e.scrollHeight - e.clientHeight - n, o = e.scrollWidth - e.clientWidth - i;
@@ -6258,9 +6206,9 @@ function waitForScrollEnd(t, e = 2e3) {
6258
6206
  return new Promise((n) => {
6259
6207
  let i = !1;
6260
6208
  const r = t === window ? document : t, o = () => {
6261
- i || (i = !0, r.removeEventListener("scrollend", a), clearTimeout(s), n());
6262
- }, a = () => o(), s = setTimeout(o, e);
6263
- r.addEventListener("scrollend", a, { once: !0 });
6209
+ i || (i = !0, r.removeEventListener("scrollend", s), clearTimeout(a), n());
6210
+ }, s = () => o(), a = setTimeout(o, e);
6211
+ r.addEventListener("scrollend", s, { once: !0 });
6264
6212
  });
6265
6213
  }
6266
6214
  async function handleScroll(t, e) {
@@ -6268,33 +6216,31 @@ async function handleScroll(t, e) {
6268
6216
  if (t.down === void 0 && t.right === void 0) return e.errContent("滚动结果: 缺少滚动方向参数");
6269
6217
  let i = window;
6270
6218
  if (t.index !== void 0) {
6271
- const g = e.getRefMap().get(t.index);
6272
- if (!g) return e.refreshOnStaleRef("滚动", t.index);
6273
- i = g;
6219
+ const m = e.getRefMap().get(t.index);
6220
+ if (!m) return e.refreshOnStaleRef("滚动", t.index);
6221
+ i = m;
6274
6222
  }
6275
6223
  const r = getScrollInfo(i);
6276
6224
  if (t.right !== void 0) {
6277
- const g = t.pixels ?? 300;
6278
- i.scrollBy({ left: t.right ? g : -g, behavior: "smooth" });
6225
+ const m = t.pixels ?? 300;
6226
+ i.scrollBy({ left: t.right ? m : -m, behavior: "smooth" });
6279
6227
  } else {
6280
- const g = t.pixels ?? Math.round((t.numPages ?? 1) * window.innerHeight);
6281
- i.scrollBy({ top: t.down ? g : -g, behavior: "smooth" });
6228
+ const m = t.pixels ?? Math.round((t.numPages ?? 1) * window.innerHeight);
6229
+ i.scrollBy({ top: t.down ? m : -m, behavior: "smooth" });
6282
6230
  }
6283
6231
  await waitForScrollEnd(i);
6284
- const o = getScrollInfo(i), a = Math.round(o.scrollY - r.scrollY), s = Math.round(o.scrollX - r.scrollX), c = t.right !== void 0;
6232
+ const o = getScrollInfo(i), s = Math.round(o.scrollY - r.scrollY), a = Math.round(o.scrollX - r.scrollX), c = t.right !== void 0;
6285
6233
  let d;
6286
- if (Math.abs(a) < 1 && Math.abs(s) < 1)
6234
+ if (Math.abs(s) < 1 && Math.abs(a) < 1)
6287
6235
  c ? d = t.right ? "⚠️ 已到达右边界,无法继续向右滚动" : "⚠️ 已到达左边界,无法继续向左滚动" : d = t.down ? "⚠️ 已到达底部,无法继续向下滚动" : "⚠️ 已到达顶部,无法继续向上滚动";
6288
6236
  else {
6289
- const g = c ? `水平滚动 ${s}px` : `垂直滚动 ${a}px`;
6290
- let y = "";
6291
- c ? t.right && o.atRight ? y = ",已到达右边界" : !t.right && o.atLeft && (y = ",已到达左边界") : t.down && o.atBottom ? y = ",已到达底部" : !t.down && o.atTop && (y = ",已到达顶部"), d = `✅ ${g}${y}`;
6237
+ const m = c ? `水平滚动 ${a}px` : `垂直滚动 ${s}px`;
6238
+ let g = "";
6239
+ c ? t.right && o.atRight ? g = ",已到达右边界" : !t.right && o.atLeft && (g = ",已到达左边界") : t.down && o.atBottom ? g = ",已到达底部" : !t.down && o.atTop && (g = ",已到达顶部"), d = `✅ ${m}${g}`;
6292
6240
  }
6293
- const u = t.right !== void 0 ? `当前水平滚动位置: scrollX=${Math.round(o.scrollX)}px,左侧 ${o.pagesAbove.toFixed(1)} 屏,右侧 ${o.pagesBelow.toFixed(1)} 屏` : `当前滚动位置: scrollY=${Math.round(o.scrollY)}px,上方 ${o.pagesAbove.toFixed(1)} 屏,下方 ${o.pagesBelow.toFixed(1)} 屏`, p = `[滚动结果] ${d}
6294
- ${u}`, h = await e.buildBrowserStateResponse(n);
6295
- return h.content[0].text = `${p}
6296
-
6297
- ${h.content[0].text}`, h;
6241
+ const u = t.right !== void 0 ? `当前水平滚动位置: scrollX=${Math.round(o.scrollX)}px,左侧 ${o.pagesAbove.toFixed(1)} 屏,右侧 ${o.pagesBelow.toFixed(1)} 屏` : `当前滚动位置: scrollY=${Math.round(o.scrollY)}px,上方 ${o.pagesAbove.toFixed(1)} 屏,下方 ${o.pagesBelow.toFixed(1)} 屏`, h = `[滚动结果] ${d}
6242
+ ${u}`, p = await e.buildBrowserStateResponse(n);
6243
+ return p.content[0].text = withStateFields(p.content[0].text, { scrollResult: h }), p;
6298
6244
  }
6299
6245
  async function handleExecuteJavascript(t, e) {
6300
6246
  if (!t.script) return e.errContent("脚本执行异常: 缺少javascript代码");
@@ -6316,12 +6262,51 @@ async function handleSearchTree(t, e) {
6316
6262
  maxMatches: t.maxMatches
6317
6263
  });
6318
6264
  e.setRefMap(n.refMap), e.stateCache.update(window.location.href, n.yaml), await e.pageController.hideMask();
6319
- const i = detectPageDialog(), r = detectValidationErrors(), o = `${i}${r}`;
6265
+ const i = detectPageDialog(), r = detectValidationErrors();
6266
+ if (i.length === 0 && r.length === 0)
6267
+ return { content: [{ type: "text", text: n.text }] };
6268
+ const o = {
6269
+ ...i.length > 0 ? { dialogs: i } : {},
6270
+ ...r.length > 0 ? { validationErrors: r } : {}
6271
+ };
6320
6272
  return {
6321
- content: [{ type: "text", text: o ? `${o}
6322
- ${n.text}` : n.text }]
6273
+ content: [{ type: "text", text: `${JSON.stringify(o)}
6274
+ ${n.text}` }]
6323
6275
  };
6324
6276
  }
6277
+ async function handleHover(t, e) {
6278
+ if (t.index === void 0) return e.errContent("悬浮结果: 缺少元素索引");
6279
+ const n = e.getRefMap().get(t.index);
6280
+ if (!n) return e.refreshOnStaleRef("悬浮", t.index);
6281
+ let i = n;
6282
+ if (n.shadowRoot && !(n instanceof HTMLButtonElement) && !(n instanceof HTMLAnchorElement)) {
6283
+ const d = n.shadowRoot.querySelector(
6284
+ 'button, a, [role="button"], [role="link"]'
6285
+ );
6286
+ d && (i = d);
6287
+ }
6288
+ const r = i.getBoundingClientRect(), o = r.left + r.width / 2, s = r.top + r.height / 2, a = [
6289
+ { type: "pointerenter", bubbles: !1, usePointer: !0 },
6290
+ { type: "pointerover", bubbles: !0, usePointer: !0 },
6291
+ { type: "pointermove", bubbles: !0, usePointer: !0 },
6292
+ { type: "mouseenter", bubbles: !1, usePointer: !1 },
6293
+ { type: "mouseover", bubbles: !0, usePointer: !1 },
6294
+ { type: "mousemove", bubbles: !0, usePointer: !1 }
6295
+ ];
6296
+ for (const { type: d, bubbles: u, usePointer: h } of a) {
6297
+ const p = h ? PointerEvent : MouseEvent;
6298
+ i.dispatchEvent(new p(d, {
6299
+ bubbles: u,
6300
+ cancelable: !0,
6301
+ view: window,
6302
+ clientX: o,
6303
+ clientY: s
6304
+ }));
6305
+ }
6306
+ await waitForDomSettled();
6307
+ const c = t.responseMode ?? "diff";
6308
+ return e.buildBrowserStateResponse(c);
6309
+ }
6325
6310
  function registerPageAgentTool(t = {}) {
6326
6311
  initializeBuiltinWebMCP(), setPageAgentToolConfig(t, { mode: "replace" }), window.__webmcpcli_beforeGetBrowserState = window.__webmcpcli_beforeGetBrowserState || null;
6327
6312
  const e = new PageController({ enableMask: !1 });
@@ -6334,30 +6319,39 @@ function registerPageAgentTool(t = {}) {
6334
6319
  return { content: [{ type: "text", text: u }] };
6335
6320
  }
6336
6321
  async function o(u) {
6337
- const p = await createActionErrorResult(u, s);
6338
- return t.removeMaskAfterToolCall && await e.hideMask(), p;
6322
+ const h = await createActionErrorResult(u, a);
6323
+ return t.removeMaskAfterToolCall && await e.hideMask(), h;
6339
6324
  }
6340
- async function a(u, p) {
6341
- const h = await s("full");
6325
+ async function s(u, h) {
6326
+ const p = await a("full"), m = `⚠️ ${u}失败: ref 索引 ${h} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`;
6342
6327
  return {
6343
- content: [{ type: "text", text: `⚠️ ${u}失败: ref 索引 ${p} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。
6344
- ` + h.content[0].text }]
6328
+ content: [
6329
+ {
6330
+ type: "text",
6331
+ text: withStateFields(p.content[0].text, { warning: m })
6332
+ }
6333
+ ]
6345
6334
  };
6346
6335
  }
6347
- async function s(u = "diff") {
6348
- const p = window.location.href, h = document.title, { yaml: g, refMap: y } = buildA11yTree(document.body, getPageAgentToolConfig().a11yConfig);
6349
- i = y, getPageAgentToolConfig().enableHighlight && (highlight(y), globalRemoveListener());
6350
- const T = n.update(p, g), C = detectPageDialog(), f = detectValidationErrors();
6351
- let m = "";
6352
- return u === "full" ? m = g : u === "diff" ? m = T.isFullRefresh ? g : T.diffText : u === "both" && (m = `【全量页面树】:
6353
- ${g}
6336
+ async function a(u = "diff") {
6337
+ const h = window.location.href, p = document.title, { yaml: m, refMap: g } = buildA11yTree(document.body, getPageAgentToolConfig().a11yConfig);
6338
+ i = g, getPageAgentToolConfig().enableHighlight && (highlight(g), globalRemoveListener());
6339
+ const E = n.update(h, m), L = detectPageDialog(), f = detectValidationErrors(), b = detectVisibleTooltips();
6340
+ let T = "";
6341
+ u === "full" ? T = m : u === "diff" ? T = E.isFullRefresh ? m : E.diffText : u === "both" && (T = `【全量页面树】:
6342
+ ${m}
6354
6343
 
6355
6344
  【增量差异】:
6356
- ${T.isFullRefresh ? "(首次/刷新,无增量差异)" : T.diffText}`), { content: [{ type: "text", text: `浏览器状态: ${JSON.stringify({
6357
- url: p,
6358
- title: h,
6359
- content: m
6360
- })}${C}${f}` }] };
6345
+ ${E.isFullRefresh ? "(首次/刷新,无增量差异)" : E.diffText}`);
6346
+ const y = {
6347
+ url: h,
6348
+ title: p,
6349
+ content: T,
6350
+ ...L.length > 0 ? { dialogs: L } : {},
6351
+ ...f.length > 0 ? { validationErrors: f } : {},
6352
+ ...b.length > 0 ? { tooltips: b } : {}
6353
+ };
6354
+ return { content: [{ type: "text", text: JSON.stringify(y) }] };
6361
6355
  }
6362
6356
  const c = {
6363
6357
  pageController: e,
@@ -6366,51 +6360,54 @@ ${T.isFullRefresh ? "(首次/刷新,无增量差异)" : T.diffText}`), { c
6366
6360
  setRefMap: (u) => {
6367
6361
  i = u;
6368
6362
  },
6369
- buildBrowserStateResponse: s,
6370
- refreshOnStaleRef: a,
6363
+ buildBrowserStateResponse: a,
6364
+ refreshOnStaleRef: s,
6371
6365
  errContent: r,
6372
6366
  actionError: o
6373
6367
  };
6374
6368
  async function d(u) {
6375
6369
  try {
6376
- let p;
6370
+ let h;
6377
6371
  switch (u.action) {
6378
6372
  case "browserState":
6379
- p = await handleBrowserState(u, c);
6373
+ h = await handleBrowserState(u, c);
6380
6374
  break;
6381
6375
  case "click":
6382
- await e.showMask(), e.mask.borderElement(i.get(u.index)), p = await handleClick(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
6376
+ await e.showMask(), e.mask.borderElement(i.get(u.index)), h = await handleClick(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
6383
6377
  break;
6384
6378
  case "fill":
6385
- await e.showMask(), e.mask.borderElement(i.get(u.index)), p = await handleFill(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
6379
+ await e.showMask(), e.mask.borderElement(i.get(u.index)), h = await handleFill(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
6386
6380
  break;
6387
6381
  case "select":
6388
- await e.showMask(), e.mask.borderElement(i.get(u.index)), p = await handleSelect(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
6382
+ await e.showMask(), e.mask.borderElement(i.get(u.index)), h = await handleSelect(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
6389
6383
  break;
6390
6384
  case "scroll":
6391
- await e.showMask(), p = await handleScroll(u, c), t.removeMaskAfterToolCall && await e.hideMask();
6385
+ await e.showMask(), h = await handleScroll(u, c), t.removeMaskAfterToolCall && await e.hideMask();
6392
6386
  break;
6393
6387
  case "executeJavascript":
6394
- p = await handleExecuteJavascript(u, c);
6388
+ h = await handleExecuteJavascript(u, c);
6395
6389
  break;
6396
6390
  case "searchTree":
6397
- p = await handleSearchTree(u, c);
6391
+ h = await handleSearchTree(u, c);
6392
+ break;
6393
+ case "hover":
6394
+ h = await handleHover(u, c);
6398
6395
  break;
6399
6396
  default:
6400
- p = { content: [{ type: "text", text: `未知操作: ${u.action}` }] };
6397
+ h = { content: [{ type: "text", text: `未知操作: ${u.action}` }] };
6401
6398
  }
6402
- return p;
6403
- } catch (p) {
6404
- const h = {
6399
+ return h;
6400
+ } catch (h) {
6401
+ const p = {
6405
6402
  click: "点击",
6406
6403
  fill: "填写",
6407
6404
  select: "选择"
6408
6405
  };
6409
- if (u.action in h)
6406
+ if (u.action in p)
6410
6407
  return o(
6411
- `${h[u.action]}执行异常: ${p instanceof Error ? p.message : String(p)}`
6408
+ `${p[u.action]}执行异常: ${h instanceof Error ? h.message : String(h)}`
6412
6409
  );
6413
- throw t.removeMaskAfterToolCall && await e.hideMask(), p;
6410
+ throw t.removeMaskAfterToolCall && await e.hideMask(), h;
6414
6411
  }
6415
6412
  }
6416
6413
  document.modelContext.registerTool({
@@ -6421,8 +6418,8 @@ ${T.isFullRefresh ? "(首次/刷新,无增量差异)" : T.diffText}`), { c
6421
6418
  async execute(u) {
6422
6419
  try {
6423
6420
  return d(u);
6424
- } catch (p) {
6425
- return { content: [{ type: "text", text: `异常: ${String(p)}` }] };
6421
+ } catch (h) {
6422
+ return { content: [{ type: "text", text: `异常: ${String(h)}` }] };
6426
6423
  }
6427
6424
  }
6428
6425
  }), setupPageAgentToolEventBridge(d, e);
@@ -6491,6 +6488,21 @@ const consoleCloudPageAgentToolOptions = {
6491
6488
  ".modules-searchable-region-region-panel-recent-region-item",
6492
6489
  ".ti3-multiselect-box-cell"
6493
6490
  ]
6491
+ },
6492
+ // 模态弹窗:补齐缺失的 role="dialog"(Tiny3 modal/message-box/drawer/侧栏面板)
6493
+ {
6494
+ role: "dialog",
6495
+ selector: [
6496
+ '[class*="ti3-modal"]',
6497
+ '[class*="ti3-message-box"]',
6498
+ '[class*="drawer"]',
6499
+ ".modules-layout-module-sidebar-panel"
6500
+ ]
6501
+ },
6502
+ // Tiny3 tooltip / 帮助提示:补齐缺失的 role="tooltip"
6503
+ {
6504
+ role: "tooltip",
6505
+ selector: ["tp-helptip", '[class*="ti3-tooltip"]', ".tp-helptip-content", ".ti3-tooltip", ".ti3-tooltip-popper"]
6494
6506
  }
6495
6507
  ],
6496
6508
  states: {
@@ -6517,11 +6529,16 @@ const consoleCloudPageAgentToolOptions = {
6517
6529
  ".region-select",
6518
6530
  '[cf-uba="searchableRegion..open"]',
6519
6531
  '[cf-uba="serviceList..open"]',
6520
- '[cf-uba="userinfo"]'
6532
+ '[cf-uba="userinfo"]',
6533
+ "tp-helptip"
6521
6534
  ]
6522
6535
  }
6523
6536
  ],
6524
6537
  disabled: [{ selector: ".ti3-disabled" }],
6538
+ // Tiny3 / Lego 校验错误
6539
+ error: [{ selector: [".ti3-unifyvalid-error", ".ti3-error", ".ti-error", ".lego-text-error", ".lego-error"] }],
6540
+ // Tiny3 / Lego 警告
6541
+ warning: [{ selector: [".ti3-warning", ".ti-warning", ".lego-text-warning"] }],
6525
6542
  // 展开态:需结合计算样式,选择器表达不了「可见」
6526
6543
  expanded: [
6527
6544
  {
@@ -6545,6 +6562,7 @@ const consoleCloudPageAgentToolOptions = {
6545
6562
  whitelist: [
6546
6563
  ".modules-service-list-menu-service-icon-container",
6547
6564
  ".ti3-tabs-text",
6565
+ "tp-helptip",
6548
6566
  '[cf-uba="cloudShell"]',
6549
6567
  '[cf-uba="messageBox"]',
6550
6568
  '[cf-uba="helpFeedback"]',
@@ -6558,12 +6576,17 @@ const consoleCloudPageAgentToolOptions = {
6558
6576
  "ti-icon.common-icon",
6559
6577
  "ti-icon.ti3-icon-full-screen"
6560
6578
  ],
6561
- blacklist: ["noscript", "pan-gu", "#J_header"],
6562
- dialogSelectors: [
6563
- '[class*="ti3-modal"]',
6564
- '[class*="ti3-message-box"]',
6565
- '[class*="drawer"]',
6566
- ".modules-layout-module-sidebar-panel"
6579
+ blacklist: [
6580
+ "noscript",
6581
+ "pan-gu",
6582
+ // 忽略 WebMCP 高亮容器
6583
+ "#webmcpcli-highlight-container",
6584
+ "#page-agent-runtime_simulator-mask",
6585
+ // CFUI 忽略几个大区域
6586
+ "#J_header",
6587
+ "#J_rightSidebar",
6588
+ "#cf_service_icon",
6589
+ "tp-helptip"
6567
6590
  ]
6568
6591
  }
6569
6592
  };