@opentiny/next-sdk 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/{SimulatorMask-BHVXyogh-iNUb4dyF.js → SimulatorMask-BHVXyogh-CARX3Rff.js} +1 -1
  2. package/dist/core.js +1 -1
  3. package/dist/{index-CXK8CcKq.js → index-R_HIbfUX.js} +1698 -1170
  4. package/dist/index.d.ts +11 -0
  5. package/dist/index.js +69 -50
  6. package/dist/{initialize-builtin-WebMCP-rALfqS-o.js → initialize-builtin-WebMCP-JaoKwVlm.js} +355 -346
  7. package/dist/page-tools/a11y/build.d.ts +3 -4
  8. package/dist/page-tools/a11y/config.d.ts +96 -0
  9. package/dist/page-tools/a11y/constants.d.ts +2 -0
  10. package/dist/page-tools/a11y/search.d.ts +1 -1
  11. package/dist/page-tools/a11y/types.d.ts +13 -22
  12. package/dist/page-tools/a11y/utils.d.ts +32 -11
  13. package/dist/page-tools/a11y/vnode.d.ts +14 -11
  14. package/dist/page-tools/a11y-tree.d.ts +1 -0
  15. package/dist/page-tools/configs/console-cloud.d.ts +6 -0
  16. package/dist/page-tools/constants.d.ts +5 -17
  17. package/dist/page-tools/context.d.ts +12 -0
  18. package/dist/page-tools/handlers/searchTree.d.ts +2 -1
  19. package/dist/page-tools/page-agent-highlight/index.d.ts +12 -0
  20. package/dist/page-tools/page-agent-mask/SimulatorMask.d.ts +2 -0
  21. package/dist/page-tools/page-agent-tool-event.d.ts +26 -0
  22. package/dist/page-tools/schema.d.ts +1 -0
  23. package/dist/page-tools/tool-config.d.ts +50 -0
  24. package/dist/runtime.d.ts +4 -1
  25. package/dist/runtime.js +37 -49
  26. package/dist/vitest.config.d.ts +2 -0
  27. package/index.ts +35 -0
  28. package/package.json +21 -16
  29. package/page-tools/a11y/build.ts +38 -34
  30. package/page-tools/a11y/config.ts +465 -0
  31. package/page-tools/a11y/constants.ts +21 -0
  32. package/page-tools/a11y/search.ts +1 -3
  33. package/page-tools/a11y/types.ts +14 -17
  34. package/page-tools/a11y/utils.ts +129 -156
  35. package/page-tools/a11y/vnode.ts +277 -67
  36. package/page-tools/a11y-tree.ts +1 -0
  37. package/page-tools/bridge.ts +22 -2
  38. package/page-tools/configs/console-cloud.ts +172 -0
  39. package/page-tools/constants.ts +5 -65
  40. package/page-tools/context.ts +38 -1
  41. package/page-tools/handlers/click.ts +6 -2
  42. package/page-tools/handlers/fill.ts +10 -5
  43. package/page-tools/handlers/searchTree.ts +7 -10
  44. package/page-tools/handlers/select.ts +10 -5
  45. package/page-tools/page-agent-highlight/index.ts +66 -19
  46. package/page-tools/page-agent-mask/SimulatorMask.ts +42 -22
  47. package/page-tools/page-agent-mask/hauwei.svg +25 -0
  48. package/page-tools/page-agent-prompt.md +1 -1
  49. package/page-tools/page-agent-tool-event.ts +113 -0
  50. package/page-tools/page-agent-tool.ts +85 -53
  51. package/page-tools/schema.ts +1 -0
  52. package/page-tools/tool-config.ts +100 -0
  53. package/page-tools/utils/dom.ts +6 -3
  54. package/runtime.ts +37 -6
  55. package/test/page-tools/a11y/build.test.ts +638 -0
  56. package/test/page-tools/a11y/config.test.ts +370 -0
  57. package/test/page-tools/configs/console-cloud.test.ts +168 -0
  58. package/test/page-tools/page-agent-highlight.test.ts +110 -0
  59. package/test/page-tools/page-agent-tool-dispatch.test.ts +208 -0
  60. package/test/page-tools/page-agent-tool.test.ts +102 -0
  61. package/test/page-tools/tool-config.test.ts +112 -0
  62. package/test/page-tools/utils/dom.test.ts +122 -0
  63. package/vite.config.runtime.ts +1 -1
  64. package/vitest.config.ts +10 -0
@@ -6,7 +6,7 @@ import "@modelcontextprotocol/sdk/shared/uriTemplate.js";
6
6
  import "@modelcontextprotocol/sdk/server/completable.js";
7
7
  import "@modelcontextprotocol/sdk/shared/metadataUtils.js";
8
8
  import "@modelcontextprotocol/sdk/inMemory.js";
9
- import { i as initializeBuiltinWebMCP } from "./initialize-builtin-WebMCP-rALfqS-o.js";
9
+ import { i as initializeBuiltinWebMCP } from "./initialize-builtin-WebMCP-JaoKwVlm.js";
10
10
  import QRCodePck from "qrcode";
11
11
  import { tool } from "ai";
12
12
  import { ZodFirstPartyTypeKind } from "zod/v3";
@@ -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, [l, c = "center"] = e.split("-");
101
- let u = 0, d = 0;
102
- return l === "top" ? u = n.top + r - i.height - a : l === "bottom" ? u = n.bottom + r + a : l === "left" ? d = n.left + o - i.width - a : l === "right" && (d = n.right + o + a), (l === "top" || l === "bottom") && (c === "start" ? d = n.left + o : c === "end" ? d = n.right + o - i.width : d = (n.left + n.right) / 2 + o - i.width / 2), (l === "left" || l === "right") && (c === "start" ? u = n.top + r : c === "end" ? u = n.bottom + r - i.height : u = (n.top + n.bottom) / 2 + r - i.height / 2), { top: Math.round(u), left: Math.round(d) };
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("-");
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) };
103
103
  }
104
104
  applyStyle({ top: e, left: n }) {
105
105
  Object.assign(this.tip.style, {
@@ -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(), l = o?.[1]?.trim();
884
- return a && l ? { name: a, description: l } : 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;
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, l = a.startsWith("./") ? a : `./${a}`, c = typeof i == "string" ? i : await i();
890
- e[l] = c;
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;
891
891
  }
892
892
  return e;
893
893
  }
@@ -929,8 +929,8 @@ async function getMainSkillPathByName(t, e) {
929
929
  for (const o of i) {
930
930
  const a = n[o];
931
931
  if (a) {
932
- const l = await parseSkillFrontMatter(a);
933
- if (l && l.name === e)
932
+ const s = await parseSkillFrontMatter(a);
933
+ if (s && s.name === e)
934
934
  return o;
935
935
  }
936
936
  }
@@ -952,37 +952,37 @@ 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: l, currentPath: c } = r;
956
- let u, d = "";
957
- if (l) {
955
+ const o = n, { skillName: a, path: s, currentPath: c } = r;
956
+ let d, u = "";
957
+ if (s) {
958
958
  let p = ".";
959
959
  if (c) {
960
- const g = c.lastIndexOf("/");
961
- g >= 0 && (p = c.slice(0, g));
960
+ const y = c.lastIndexOf("/");
961
+ y >= 0 && (p = c.slice(0, y));
962
962
  }
963
- const f = `http://localhost/${p}/`;
964
- if (d = "." + new URL(l, f).pathname, u = await getSkillMdContent(o, d), u === void 0 && (l.startsWith("./") || l.startsWith("../")) && c) {
965
- const g = c.split("/");
966
- if (g.length >= 2) {
967
- const E = `http://localhost/${g[1]}/`, x = "." + new URL(l, E).pathname;
968
- u = await getSkillMdContent(o, x), u && (d = x);
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);
969
969
  }
970
970
  }
971
- if (u && !o[d]) {
972
- const g = d.replace(/^\.?\//, "/"), S = Object.keys(o).find((E) => E.endsWith(g));
973
- S && (d = S);
971
+ if (d && !o[u]) {
972
+ const y = u.replace(/^\.?\//, "/"), T = Object.keys(o).find((C) => C.endsWith(y));
973
+ T && (u = T);
974
974
  }
975
975
  } else if (a) {
976
976
  const p = await getMainSkillPathByName(o, a);
977
- p && (d = p, u = await getSkillMdContent(o, p));
977
+ p && (u = p, d = await getSkillMdContent(o, p));
978
978
  }
979
- return u === void 0 ? {
979
+ return d === void 0 ? {
980
980
  error: "未找到对应技能文档",
981
981
  skillName: a,
982
- path: l,
982
+ path: s,
983
983
  providedCurrentPath: c,
984
- attemptedPath: d
985
- } : { content: u, path: d };
984
+ attemptedPath: u
985
+ } : { content: d, path: u };
986
986
  }
987
987
  })
988
988
  };
@@ -1186,7 +1186,7 @@ function parseIntersectionDef(t, e) {
1186
1186
  else {
1187
1187
  let a = o;
1188
1188
  if ("additionalProperties" in o && o.additionalProperties === !1) {
1189
- const { additionalProperties: l, ...c } = o;
1189
+ const { additionalProperties: s, ...c } = o;
1190
1190
  a = c;
1191
1191
  } else
1192
1192
  i = void 0;
@@ -1402,7 +1402,7 @@ 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, l = !1;
1405
+ let r = "", o = !1, a = !1, s = !1;
1406
1406
  for (let c = 0; c < i.length; c++) {
1407
1407
  if (o) {
1408
1408
  r += i[c], o = !1;
@@ -1411,7 +1411,7 @@ function stringifyRegExpWithFlags(t, e) {
1411
1411
  if (n.i) {
1412
1412
  if (a) {
1413
1413
  if (i[c].match(/[a-z]/)) {
1414
- l ? (r += i[c], r += `${i[c - 2]}-${i[c]}`.toUpperCase(), l = !1) : i[c + 1] === "-" && i[c + 2]?.match(/[a-z]/) ? (r += i[c], l = !0) : r += `${i[c]}${i[c].toUpperCase()}`;
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()}`;
1415
1415
  continue;
1416
1416
  }
1417
1417
  } else if (i[c].match(/[a-z]/)) {
@@ -1576,7 +1576,7 @@ function parseUnionDef(t, e) {
1576
1576
  }
1577
1577
  }, []);
1578
1578
  if (i.length === n.length) {
1579
- const r = i.filter((o, a, l) => l.indexOf(o) === a);
1579
+ const r = i.filter((o, a, s) => s.indexOf(o) === a);
1580
1580
  return {
1581
1581
  type: r.length > 1 ? r : r[0],
1582
1582
  enum: n.reduce((o, a) => o.includes(a._def.value) ? o : [...o, a._def.value], [])
@@ -1651,18 +1651,18 @@ function parseObjectDef(t, e) {
1651
1651
  type: "object",
1652
1652
  properties: {}
1653
1653
  }, r = [], o = t.shape();
1654
- for (const l in o) {
1655
- let c = o[l];
1654
+ for (const s in o) {
1655
+ let c = o[s];
1656
1656
  if (c === void 0 || c._def === void 0)
1657
1657
  continue;
1658
- let u = safeIsOptional(c);
1659
- u && n && (c._def.typeName === "ZodOptional" && (c = c._def.innerType), c.isNullable() || (c = c.nullable()), u = !1);
1660
- const d = parseDef(c._def, {
1658
+ let d = safeIsOptional(c);
1659
+ d && n && (c._def.typeName === "ZodOptional" && (c = c._def.innerType), c.isNullable() || (c = c.nullable()), d = !1);
1660
+ const u = parseDef(c._def, {
1661
1661
  ...e,
1662
- currentPath: [...e.currentPath, "properties", l],
1663
- propertyPath: [...e.currentPath, "properties", l]
1662
+ currentPath: [...e.currentPath, "properties", s],
1663
+ propertyPath: [...e.currentPath, "properties", s]
1664
1664
  });
1665
- d !== void 0 && (i.properties[l] = d, u || r.push(l));
1665
+ u !== void 0 && (i.properties[s] = u, d || r.push(s));
1666
1666
  }
1667
1667
  r.length && (i.required = r);
1668
1668
  const a = decideAdditionalProperties(t, e);
@@ -1843,21 +1843,21 @@ 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 l = e.override?.(t, e, i, n);
1847
- if (l !== ignoreOverride)
1848
- return l;
1846
+ const s = e.override?.(t, e, i, n);
1847
+ if (s !== ignoreOverride)
1848
+ return s;
1849
1849
  }
1850
1850
  if (i && !n) {
1851
- const l = get$ref(i, e);
1852
- if (l !== void 0)
1853
- return l;
1851
+ const s = get$ref(i, e);
1852
+ if (s !== void 0)
1853
+ return s;
1854
1854
  }
1855
1855
  const r = { def: t, path: e.currentPath, jsonSchema: void 0 };
1856
1856
  e.seen.set(t, r);
1857
1857
  const o = selectParser(t, t.typeName, e), a = typeof o == "function" ? parseDef(o(), e) : o;
1858
1858
  if (a && addMeta(t, e, a), e.postProcess) {
1859
- const l = e.postProcess(a, t, e);
1860
- return r.jsonSchema = a, l;
1859
+ const s = e.postProcess(a, t, e);
1860
+ return r.jsonSchema = a, s;
1861
1861
  }
1862
1862
  return r.jsonSchema = a, a;
1863
1863
  }
@@ -1950,7 +1950,7 @@ const get$ref = (t, e) => {
1950
1950
  - \`- role #N [token1] [token2] "accessible name"\`
1951
1951
  - \`role\`:ARIA 语义角色(如 button/link/radio/heading/listitem/generic 等)
1952
1952
  - \`#N\`:可交互元素的唯一操作索引,**只有带 \`#N\` 的节点才能被操作**,操作时将 N 作为 \`index\` 参数传入
1953
- - \`[token]\`:可选 token,包括状态标记(如 \`[checked]\` \`[selected]\` \`[disabled]\` \`[cursor=pointer]\`)和定制属性(如 \`[cf-uba="..."]\`)
1953
+ - \`[token]\`:可选 token,包括状态标记(如 \`[checked]\` \`[selected]\` \`[pressed]\` \`[current]\` \`[expanded]\` \`[disabled]\` \`[readonly]\` \`[required]\` \`[invalid]\` \`[busy]\` \`[error]\` \`[warning]\` \`[cursor=pointer]\`)和定制属性(如 \`[cf-uba="..."]\`)
1954
1954
  - \`"accessible name"\`:元素的语义化名称,**用双引号包裹**(通过 aria-label/aria-labelledby/innerText 等计算得出);无名称的节点此字段省略
1955
1955
  - 缩进表示父子关系
1956
1956
 
@@ -2116,26 +2116,26 @@ async function clickElement(t) {
2116
2116
  await enablePassThrough();
2117
2117
  const a = o.elementFromPoint(i, r);
2118
2118
  await disablePassThrough();
2119
- const l = a instanceof HTMLElement && t.contains(a) ? a : t, c = {
2119
+ const s = a instanceof HTMLElement && t.contains(a) ? a : t, c = {
2120
2120
  bubbles: !0,
2121
2121
  cancelable: !0,
2122
2122
  clientX: i,
2123
2123
  clientY: r,
2124
2124
  pointerType: "mouse"
2125
- }, u = {
2125
+ }, d = {
2126
2126
  bubbles: !0,
2127
2127
  cancelable: !0,
2128
2128
  clientX: i,
2129
2129
  clientY: r,
2130
2130
  button: 0
2131
2131
  };
2132
- l.dispatchEvent(new PointerEvent("pointerover", c)), l.dispatchEvent(new PointerEvent("pointerenter", {
2132
+ s.dispatchEvent(new PointerEvent("pointerover", c)), s.dispatchEvent(new PointerEvent("pointerenter", {
2133
2133
  ...c,
2134
2134
  bubbles: !1
2135
- })), l.dispatchEvent(new MouseEvent("mouseover", u)), l.dispatchEvent(new MouseEvent("mouseenter", {
2136
- ...u,
2135
+ })), s.dispatchEvent(new MouseEvent("mouseover", d)), s.dispatchEvent(new MouseEvent("mouseenter", {
2136
+ ...d,
2137
2137
  bubbles: !1
2138
- })), l.dispatchEvent(new PointerEvent("pointerdown", c)), l.dispatchEvent(new MouseEvent("mousedown", u)), t.focus({ preventScroll: !0 }), l.dispatchEvent(new PointerEvent("pointerup", c)), l.dispatchEvent(new MouseEvent("mouseup", u)), l.click(), await waitFor(0.2);
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);
2139
2139
  }
2140
2140
  async function inputTextElement(t, e) {
2141
2141
  const n = t.isContentEditable;
@@ -2183,93 +2183,93 @@ async function scrollIntoViewIfNeeded(t) {
2183
2183
  async function scrollVertically(t, e) {
2184
2184
  if (e) {
2185
2185
  const a = e;
2186
- let l = a, c = !1, u = null, d = 0, p = 0;
2187
- const f = t;
2188
- for (; l && p < 10; ) {
2189
- const m = window.getComputedStyle(l), g = /(auto|scroll|overlay)/.test(m.overflowY) || m.scrollbarWidth && m.scrollbarWidth !== "auto" || m.scrollbarGutter && m.scrollbarGutter !== "auto", S = l.scrollHeight > l.clientHeight;
2190
- if (g && S) {
2191
- const E = l.scrollTop, h = l.scrollHeight - l.clientHeight;
2192
- let x = f / 3;
2193
- x > 0 ? x = Math.min(x, h - E) : x = Math.max(x, -E), l.scrollTop = E + x;
2194
- const T = l.scrollTop - E;
2195
- if (Math.abs(T) > 0.5) {
2196
- c = !0, u = l, d = T;
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;
2197
2197
  break;
2198
2198
  }
2199
2199
  }
2200
- if (l === document.body || l === document.documentElement) break;
2201
- l = l.parentElement, p++;
2200
+ if (s === document.body || s === document.documentElement) break;
2201
+ s = s.parentElement, p++;
2202
2202
  }
2203
- return c ? `Scrolled container (${u?.tagName}) by ${d}px` : `No scrollable container found for element (${a.tagName})`;
2203
+ return c ? `Scrolled container (${d?.tagName}) by ${u}px` : `No scrollable container found for element (${a.tagName})`;
2204
2204
  }
2205
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));
2206
2206
  let o = document.activeElement;
2207
2207
  for (; o && !r(o) && o !== document.body; ) o = o.parentElement;
2208
2208
  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, l = document.documentElement.scrollHeight - window.innerHeight;
2209
+ const a = window.scrollY, s = document.documentElement.scrollHeight - window.innerHeight;
2210
2210
  window.scrollBy(0, n);
2211
- const c = window.scrollY, u = c - a;
2212
- if (Math.abs(u) < 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 d = n > 0 && c >= l - 1, p = n < 0 && c <= 1;
2214
- return d ? `✅ Scrolled page by ${u}px. Reached the bottom of the page.` : p ? `✅ Scrolled page by ${u}px. Reached the top of the page.` : `✅ Scrolled page by ${u}px.`;
2211
+ const c = window.scrollY, d = c - a;
2212
+ 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.`;
2215
2215
  } else {
2216
2216
  const a = "The document is not scrollable. Falling back to container scroll.";
2217
2217
  console.log(`[PageController] ${a}`);
2218
- const l = o.scrollTop, c = o.scrollHeight - o.clientHeight;
2218
+ const s = o.scrollTop, c = o.scrollHeight - o.clientHeight;
2219
2219
  o.scrollBy({
2220
2220
  top: n,
2221
2221
  behavior: "smooth"
2222
2222
  }), await waitFor(0.1);
2223
- const u = o.scrollTop, d = u - l;
2224
- if (Math.abs(d) < 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 && u >= c - 1, f = n < 0 && u <= 1;
2226
- return p ? `✅ ${a} Scrolled container (${o.tagName}) by ${d}px. Reached the bottom.` : f ? `✅ ${a} Scrolled container (${o.tagName}) by ${d}px. Reached the top.` : `✅ ${a} Scrolled container (${o.tagName}) by ${d}px.`;
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.`;
2227
2227
  }
2228
2228
  }
2229
2229
  async function scrollHorizontally(t, e) {
2230
2230
  if (e) {
2231
2231
  const a = e;
2232
- let l = a, c = !1, u = null, d = 0, p = 0;
2233
- const f = t;
2234
- for (; l && p < 10; ) {
2235
- const m = window.getComputedStyle(l), g = /(auto|scroll|overlay)/.test(m.overflowX) || m.scrollbarWidth && m.scrollbarWidth !== "auto" || m.scrollbarGutter && m.scrollbarGutter !== "auto", S = l.scrollWidth > l.clientWidth;
2236
- if (g && S) {
2237
- const E = l.scrollLeft, h = l.scrollWidth - l.clientWidth;
2238
- let x = f / 3;
2239
- x > 0 ? x = Math.min(x, h - E) : x = Math.max(x, -E), l.scrollLeft = E + x;
2240
- const T = l.scrollLeft - E;
2241
- if (Math.abs(T) > 0.5) {
2242
- c = !0, u = l, d = T;
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;
2243
2243
  break;
2244
2244
  }
2245
2245
  }
2246
- if (l === document.body || l === document.documentElement) break;
2247
- l = l.parentElement, p++;
2246
+ if (s === document.body || s === document.documentElement) break;
2247
+ s = s.parentElement, p++;
2248
2248
  }
2249
- return c ? `Scrolled container (${u?.tagName}) horizontally by ${d}px` : `No horizontally scrollable container found for element (${a.tagName})`;
2249
+ return c ? `Scrolled container (${d?.tagName}) horizontally by ${u}px` : `No horizontally scrollable container found for element (${a.tagName})`;
2250
2250
  }
2251
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));
2252
2252
  let o = document.activeElement;
2253
2253
  for (; o && !r(o) && o !== document.body; ) o = o.parentElement;
2254
2254
  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, l = document.documentElement.scrollWidth - window.innerWidth;
2255
+ const a = window.scrollX, s = document.documentElement.scrollWidth - window.innerWidth;
2256
2256
  window.scrollBy(n, 0);
2257
- const c = window.scrollX, u = c - a;
2258
- if (Math.abs(u) < 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 d = n > 0 && c >= l - 1, p = n < 0 && c <= 1;
2260
- return d ? `✅ Scrolled page by ${u}px. Reached the right edge of the page.` : p ? `✅ Scrolled page by ${u}px. Reached the left edge of the page.` : `✅ Scrolled page horizontally by ${u}px.`;
2257
+ const c = window.scrollX, d = c - a;
2258
+ 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.`;
2261
2261
  } else {
2262
2262
  const a = "The document is not scrollable. Falling back to container scroll.";
2263
2263
  console.log(`[PageController] ${a}`);
2264
- const l = o.scrollLeft, c = o.scrollWidth - o.clientWidth;
2264
+ const s = o.scrollLeft, c = o.scrollWidth - o.clientWidth;
2265
2265
  o.scrollBy({
2266
2266
  left: n,
2267
2267
  behavior: "smooth"
2268
2268
  }), await waitFor(0.1);
2269
- const u = o.scrollLeft, d = u - l;
2270
- if (Math.abs(d) < 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 && u >= c - 1, f = n < 0 && u <= 1;
2272
- return p ? `✅ ${a} Scrolled container (${o.tagName}) by ${d}px. Reached the right edge.` : f ? `✅ ${a} Scrolled container (${o.tagName}) by ${d}px. Reached the left edge.` : `✅ ${a} Scrolled container (${o.tagName}) horizontally by ${d}px.`;
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.`;
2273
2273
  }
2274
2274
  }
2275
2275
  var dom_tree_default = (t = {
@@ -2287,51 +2287,51 @@ var dom_tree_default = (t = {
2287
2287
  highlightOpacity: 0.1,
2288
2288
  highlightLabelOpacity: 0.5
2289
2289
  }) => {
2290
- const { interactiveBlacklist: e, interactiveWhitelist: n, highlightOpacity: i, highlightLabelOpacity: r } = t, { doHighlightElements: o, focusHighlightIndex: a, viewportExpansion: l, debugMode: c } = t;
2291
- let u = 0;
2292
- const d = /* @__PURE__ */ new WeakMap();
2293
- function p(s, b) {
2294
- !s || s.nodeType !== Node.ELEMENT_NODE || d.set(s, {
2295
- ...d.get(s),
2290
+ const { interactiveBlacklist: e, interactiveWhitelist: n, highlightOpacity: i, highlightLabelOpacity: r } = t, { doHighlightElements: o, focusHighlightIndex: a, viewportExpansion: s, debugMode: c } = t;
2291
+ let d = 0;
2292
+ const u = /* @__PURE__ */ new WeakMap();
2293
+ function p(l, b) {
2294
+ !l || l.nodeType !== Node.ELEMENT_NODE || u.set(l, {
2295
+ ...u.get(l),
2296
2296
  ...b
2297
2297
  });
2298
2298
  }
2299
- const f = {
2299
+ const h = {
2300
2300
  boundingRects: /* @__PURE__ */ new WeakMap(),
2301
2301
  clientRects: /* @__PURE__ */ new WeakMap(),
2302
2302
  computedStyles: /* @__PURE__ */ new WeakMap(),
2303
2303
  clearCache: () => {
2304
- f.boundingRects = /* @__PURE__ */ new WeakMap(), f.clientRects = /* @__PURE__ */ new WeakMap(), f.computedStyles = /* @__PURE__ */ new WeakMap();
2304
+ h.boundingRects = /* @__PURE__ */ new WeakMap(), h.clientRects = /* @__PURE__ */ new WeakMap(), h.computedStyles = /* @__PURE__ */ new WeakMap();
2305
2305
  }
2306
2306
  };
2307
- function m(s) {
2308
- if (!s) return null;
2309
- if (f.boundingRects.has(s)) return f.boundingRects.get(s);
2310
- const b = s.getBoundingClientRect();
2311
- return b && f.boundingRects.set(s, b), b;
2312
- }
2313
- function g(s) {
2314
- if (!s) return null;
2315
- if (f.computedStyles.has(s)) return f.computedStyles.get(s);
2316
- const b = window.getComputedStyle(s);
2317
- return b && f.computedStyles.set(s, b), b;
2318
- }
2319
- function S(s) {
2320
- if (!s) return null;
2321
- if (f.clientRects.has(s)) return f.clientRects.get(s);
2322
- const b = s.getClientRects();
2323
- return b && f.clientRects.set(s, b), b;
2324
- }
2325
- const E = {}, h = { current: 0 }, x = "playwright-highlight-container";
2326
- function T(s, b, I = null) {
2327
- if (!s) return b;
2307
+ function g(l) {
2308
+ 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;
2312
+ }
2313
+ function y(l) {
2314
+ 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;
2318
+ }
2319
+ function T(l) {
2320
+ 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
2328
  const w = [];
2329
- let _ = null, F = 20, C = 16, P = null;
2329
+ let _ = null, D = 20, x = 16, P = null;
2330
2330
  try {
2331
- let k = document.getElementById(x);
2332
- k || (k = document.createElement("div"), k.id = x, 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
- const D = s.getClientRects();
2334
- if (!D || D.length === 0) return b;
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));
2333
+ const I = l.getClientRects();
2334
+ if (!I || I.length === 0) return b;
2335
2335
  const Y = [
2336
2336
  "#FF0000",
2337
2337
  "#00FF00",
@@ -2346,60 +2346,60 @@ var dom_tree_default = (t = {
2346
2346
  "#DC143C",
2347
2347
  "#4682B4"
2348
2348
  ];
2349
- let Z = Y[b % Y.length];
2350
- const X = Z + Math.floor(i * 255).toString(16).padStart(2, "0");
2351
- Z = Z + Math.floor(r * 255).toString(16).padStart(2, "0");
2349
+ let V = Y[b % Y.length];
2350
+ const K = V + Math.floor(i * 255).toString(16).padStart(2, "0");
2351
+ V = V + Math.floor(r * 255).toString(16).padStart(2, "0");
2352
2352
  let j = {
2353
2353
  x: 0,
2354
2354
  y: 0
2355
2355
  };
2356
- if (I) {
2357
- const H = I.getBoundingClientRect();
2356
+ if (R) {
2357
+ const H = R.getBoundingClientRect();
2358
2358
  j.x = H.left, j.y = H.top;
2359
2359
  }
2360
2360
  const ae = document.createDocumentFragment();
2361
- for (const H of D) {
2361
+ for (const H of I) {
2362
2362
  if (H.width === 0 || H.height === 0) continue;
2363
2363
  const U = document.createElement("div");
2364
- U.style.position = "fixed", U.style.border = `2px solid ${Z}`, U.style.backgroundColor = X, U.style.pointerEvents = "none", U.style.boxSizing = "border-box";
2365
- const O = H.top + j.y, Q = H.left + j.x;
2366
- U.style.top = `${O}px`, U.style.left = `${Q}px`, U.style.width = `${H.width}px`, U.style.height = `${H.height}px`, ae.appendChild(U), w.push({
2364
+ U.style.position = "fixed", U.style.border = `2px solid ${V}`, U.style.backgroundColor = K, U.style.pointerEvents = "none", U.style.boxSizing = "border-box";
2365
+ 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({
2367
2367
  element: U,
2368
2368
  initialRect: H
2369
2369
  });
2370
2370
  }
2371
- const ie = D[0];
2372
- _ = document.createElement("div"), _.className = "playwright-highlight-label", _.style.position = "fixed", _.style.background = Z, _.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(), F = _.offsetWidth > 0 ? _.offsetWidth : F, C = _.offsetHeight > 0 ? _.offsetHeight : C;
2371
+ 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;
2373
2373
  const de = ie.top + j.y, ue = ie.left + j.x;
2374
- let se = de + 2, re = ue + ie.width - F - 2;
2375
- (ie.width < F + 4 || ie.height < C + 4) && (se = de - C - 2, re = ue + ie.width - F, re < j.x && (re = ue)), se = Math.max(0, Math.min(se, window.innerHeight - C)), re = Math.max(0, Math.min(re, window.innerWidth - F)), _.style.top = `${se}px`, _.style.left = `${re}px`, ae.appendChild(_);
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(_);
2376
2376
  const le = ((H, U) => {
2377
- let O = 0;
2378
- return (...Q) => {
2377
+ let $ = 0;
2378
+ return (...X) => {
2379
2379
  const q = performance.now();
2380
- if (!(q - O < U))
2381
- return O = q, H(...Q);
2380
+ if (!(q - $ < U))
2381
+ return $ = q, H(...X);
2382
2382
  };
2383
2383
  })(() => {
2384
- const H = s.getClientRects();
2384
+ const H = l.getClientRects();
2385
2385
  let U = {
2386
2386
  x: 0,
2387
2387
  y: 0
2388
2388
  };
2389
- if (I) {
2390
- const O = I.getBoundingClientRect();
2391
- U.x = O.left, U.y = O.top;
2389
+ if (R) {
2390
+ const $ = R.getBoundingClientRect();
2391
+ U.x = $.left, U.y = $.top;
2392
2392
  }
2393
- if (w.forEach((O, Q) => {
2394
- if (Q < H.length) {
2395
- const q = H[Q], oe = q.top + U.y, ne = q.left + U.x;
2396
- O.element.style.top = `${oe}px`, O.element.style.left = `${ne}px`, O.element.style.width = `${q.width}px`, O.element.style.height = `${q.height}px`, O.element.style.display = q.width === 0 || q.height === 0 ? "none" : "block";
2397
- } else O.element.style.display = "none";
2398
- }), H.length < w.length) for (let O = H.length; O < w.length; O++) w[O].element.style.display = "none";
2393
+ if (w.forEach(($, X) => {
2394
+ if (X < H.length) {
2395
+ const q = H[X], oe = q.top + U.y, ne = q.left + U.x;
2396
+ $.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
+ } else $.element.style.display = "none";
2398
+ }), H.length < w.length) for (let $ = H.length; $ < w.length; $++) w[$].element.style.display = "none";
2399
2399
  if (_ && H.length > 0) {
2400
- const O = H[0], Q = O.top + U.y, q = O.left + U.x;
2401
- let oe = Q + 2, ne = q + O.width - F - 2;
2402
- (O.width < F + 4 || O.height < C + 4) && (oe = Q - C - 2, ne = q + O.width - F, ne < U.x && (ne = q)), oe = Math.max(0, Math.min(oe, window.innerHeight - C)), ne = Math.max(0, Math.min(ne, window.innerWidth - F)), _.style.top = `${oe}px`, _.style.left = `${ne}px`, _.style.display = "block";
2400
+ 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";
2403
2403
  } else _ && (_.style.display = "none");
2404
2404
  }, 16);
2405
2405
  return window.addEventListener("scroll", le, !0), window.addEventListener("resize", le), P = () => {
@@ -2409,69 +2409,69 @@ var dom_tree_default = (t = {
2409
2409
  P && (window._highlightCleanupFunctions = window._highlightCleanupFunctions || []).push(P);
2410
2410
  }
2411
2411
  }
2412
- function L(s) {
2413
- if (!s || s.nodeType !== Node.ELEMENT_NODE) return null;
2414
- const b = g(s);
2412
+ function v(l) {
2413
+ if (!l || l.nodeType !== Node.ELEMENT_NODE) return null;
2414
+ const b = y(l);
2415
2415
  if (!b) return null;
2416
- const I = b.display;
2417
- if (I === "inline" || I === "inline-block") return null;
2418
- const w = b.overflowX, _ = b.overflowY, F = b.scrollbarWidth && b.scrollbarWidth !== "auto" || b.scrollbarGutter && b.scrollbarGutter !== "auto", C = w === "auto" || w === "scroll", P = _ === "auto" || _ === "scroll";
2419
- if (!C && !P && !F) return null;
2420
- const k = s.scrollWidth - s.clientWidth, D = s.scrollHeight - s.clientHeight, Y = 4;
2421
- if (k < Y && D < Y || !P && !F && k < Y || !C && !F && D < Y) return null;
2422
- const Z = s.scrollTop, X = s.scrollLeft, j = {
2423
- top: Z,
2424
- right: s.scrollWidth - s.clientWidth - s.scrollLeft,
2425
- bottom: s.scrollHeight - s.clientHeight - s.scrollTop,
2426
- left: X
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;
2420
+ 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;
2422
+ const V = l.scrollTop, K = l.scrollLeft, j = {
2423
+ top: V,
2424
+ right: l.scrollWidth - l.clientWidth - l.scrollLeft,
2425
+ bottom: l.scrollHeight - l.clientHeight - l.scrollTop,
2426
+ left: K
2427
2427
  };
2428
- return p(s, {
2428
+ return p(l, {
2429
2429
  scrollable: !0,
2430
2430
  scrollData: j
2431
2431
  }), j;
2432
2432
  }
2433
- function A(s) {
2433
+ function L(l) {
2434
2434
  try {
2435
- if (l === -1) {
2436
- const C = s.parentElement;
2437
- if (!C) return !1;
2435
+ if (s === -1) {
2436
+ const x = l.parentElement;
2437
+ if (!x) return !1;
2438
2438
  try {
2439
- return C.checkVisibility({
2439
+ return x.checkVisibility({
2440
2440
  checkOpacity: !0,
2441
2441
  checkVisibilityCSS: !0
2442
2442
  });
2443
2443
  } catch {
2444
- const k = window.getComputedStyle(C);
2444
+ const k = window.getComputedStyle(x);
2445
2445
  return k.display !== "none" && k.visibility !== "hidden" && k.opacity !== "0";
2446
2446
  }
2447
2447
  }
2448
2448
  const b = document.createRange();
2449
- b.selectNodeContents(s);
2450
- const I = b.getClientRects();
2451
- if (!I || I.length === 0) return !1;
2449
+ b.selectNodeContents(l);
2450
+ const R = b.getClientRects();
2451
+ if (!R || R.length === 0) return !1;
2452
2452
  let w = !1, _ = !1;
2453
- for (const C of I) if (C.width > 0 && C.height > 0 && (w = !0, !(C.bottom < -l || C.top > window.innerHeight + l || C.right < -l || C.left > window.innerWidth + l))) {
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))) {
2454
2454
  _ = !0;
2455
2455
  break;
2456
2456
  }
2457
2457
  if (!w || !_) return !1;
2458
- const F = s.parentElement;
2459
- if (!F) return !1;
2458
+ const D = l.parentElement;
2459
+ if (!D) return !1;
2460
2460
  try {
2461
- return F.checkVisibility({
2461
+ return D.checkVisibility({
2462
2462
  checkOpacity: !0,
2463
2463
  checkVisibilityCSS: !0
2464
2464
  });
2465
2465
  } catch {
2466
- const P = window.getComputedStyle(F);
2466
+ const P = window.getComputedStyle(D);
2467
2467
  return P.display !== "none" && P.visibility !== "hidden" && P.opacity !== "0";
2468
2468
  }
2469
2469
  } catch (b) {
2470
2470
  return console.warn("Error checking text node visibility:", b), !1;
2471
2471
  }
2472
2472
  }
2473
- function v(s) {
2474
- if (!s || !s.tagName) return !1;
2473
+ function S(l) {
2474
+ if (!l || !l.tagName) return !1;
2475
2475
  const b = /* @__PURE__ */ new Set([
2476
2476
  "body",
2477
2477
  "div",
@@ -2481,8 +2481,8 @@ var dom_tree_default = (t = {
2481
2481
  "nav",
2482
2482
  "header",
2483
2483
  "footer"
2484
- ]), I = s.tagName.toLowerCase();
2485
- return b.has(I) ? !0 : !(/* @__PURE__ */ new Set([
2484
+ ]), R = l.tagName.toLowerCase();
2485
+ return b.has(R) ? !0 : !(/* @__PURE__ */ new Set([
2486
2486
  "svg",
2487
2487
  "script",
2488
2488
  "style",
@@ -2490,16 +2490,16 @@ var dom_tree_default = (t = {
2490
2490
  "meta",
2491
2491
  "noscript",
2492
2492
  "template"
2493
- ])).has(I);
2493
+ ])).has(R);
2494
2494
  }
2495
- function y(s) {
2496
- const b = g(s);
2497
- return s.offsetWidth > 0 && s.offsetHeight > 0 && b?.visibility !== "hidden" && b?.display !== "none";
2495
+ function A(l) {
2496
+ const b = y(l);
2497
+ return l.offsetWidth > 0 && l.offsetHeight > 0 && b?.visibility !== "hidden" && b?.display !== "none";
2498
2498
  }
2499
- function M(s) {
2500
- if (!s || s.nodeType !== Node.ELEMENT_NODE || e.includes(s)) return !1;
2501
- if (n.includes(s)) return !0;
2502
- const b = s.tagName.toLowerCase(), I = g(s), w = /* @__PURE__ */ new Set([
2499
+ function N(l) {
2500
+ if (!l || l.nodeType !== Node.ELEMENT_NODE || e.includes(l)) return !1;
2501
+ if (n.includes(l)) return !0;
2502
+ const b = l.tagName.toLowerCase(), R = y(l), w = /* @__PURE__ */ new Set([
2503
2503
  "pointer",
2504
2504
  "move",
2505
2505
  "text",
@@ -2537,11 +2537,11 @@ var dom_tree_default = (t = {
2537
2537
  "initial",
2538
2538
  "inherit"
2539
2539
  ]);
2540
- function F(Z) {
2541
- return Z.tagName.toLowerCase() === "html" ? !1 : !!(I?.cursor && w.has(I.cursor));
2540
+ function D(V) {
2541
+ return V.tagName.toLowerCase() === "html" ? !1 : !!(R?.cursor && w.has(R.cursor));
2542
2542
  }
2543
- if (F(s)) return !0;
2544
- const C = /* @__PURE__ */ new Set([
2543
+ if (D(l)) return !0;
2544
+ const x = /* @__PURE__ */ new Set([
2545
2545
  "a",
2546
2546
  "button",
2547
2547
  "input",
@@ -2555,13 +2555,13 @@ var dom_tree_default = (t = {
2555
2555
  "fieldset",
2556
2556
  "legend"
2557
2557
  ]), P = /* @__PURE__ */ new Set(["disabled", "readonly"]);
2558
- if (C.has(b)) {
2559
- if (I?.cursor && _.has(I.cursor)) return !1;
2560
- for (const Z of P) if (s.hasAttribute(Z) || s.getAttribute(Z) === "true" || s.getAttribute(Z) === "") return !1;
2561
- return !(s.disabled || s.readOnly || s.inert);
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;
2561
+ return !(l.disabled || l.readOnly || l.inert);
2562
2562
  }
2563
- const k = s.getAttribute("role"), D = s.getAttribute("aria-role");
2564
- if (s.getAttribute("contenteditable") === "true" || s.isContentEditable || s.classList && (s.classList.contains("button") || s.classList.contains("dropdown-toggle") || s.getAttribute("data-index") || s.getAttribute("data-toggle") === "dropdown" || s.getAttribute("aria-haspopup") === "true")) return !0;
2563
+ const k = l.getAttribute("role"), I = l.getAttribute("aria-role");
2564
+ if (l.getAttribute("contenteditable") === "true" || l.isContentEditable || l.classList && (l.classList.contains("button") || l.classList.contains("dropdown-toggle") || l.getAttribute("data-index") || l.getAttribute("data-toggle") === "dropdown" || l.getAttribute("aria-haspopup") === "true")) return !0;
2565
2565
  const Y = /* @__PURE__ */ new Set([
2566
2566
  "button",
2567
2567
  "menu",
@@ -2582,20 +2582,20 @@ var dom_tree_default = (t = {
2582
2582
  "option",
2583
2583
  "scrollbar"
2584
2584
  ]);
2585
- if (C.has(b) || k && Y.has(k) || D && Y.has(D)) return !0;
2585
+ if (x.has(b) || k && Y.has(k) || I && Y.has(I)) return !0;
2586
2586
  try {
2587
2587
  if (typeof getEventListeners == "function") {
2588
- const X = getEventListeners(s);
2588
+ const K = getEventListeners(l);
2589
2589
  for (const j of [
2590
2590
  "click",
2591
2591
  "mousedown",
2592
2592
  "mouseup",
2593
2593
  "dblclick"
2594
- ]) if (X[j] && X[j].length > 0) return !0;
2594
+ ]) if (K[j] && K[j].length > 0) return !0;
2595
2595
  }
2596
- const Z = s?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
2597
- if (typeof Z == "function") {
2598
- const X = Z(s);
2596
+ const V = l?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
2597
+ if (typeof V == "function") {
2598
+ const K = V(l);
2599
2599
  for (const j of [
2600
2600
  "click",
2601
2601
  "mousedown",
@@ -2607,69 +2607,69 @@ var dom_tree_default = (t = {
2607
2607
  "input",
2608
2608
  "focus",
2609
2609
  "blur"
2610
- ]) for (const ae of X) if (ae.type === j) return !0;
2610
+ ]) for (const ae of K) if (ae.type === j) return !0;
2611
2611
  }
2612
- for (const X of [
2612
+ for (const K of [
2613
2613
  "onclick",
2614
2614
  "onmousedown",
2615
2615
  "onmouseup",
2616
2616
  "ondblclick"
2617
- ]) if (s.hasAttribute(X) || typeof s[X] == "function") return !0;
2617
+ ]) if (l.hasAttribute(K) || typeof l[K] == "function") return !0;
2618
2618
  } catch {
2619
2619
  }
2620
- return !!L(s);
2620
+ return !!v(l);
2621
2621
  }
2622
- function R(s) {
2623
- if (l === -1) return !0;
2624
- const b = S(s);
2622
+ function M(l) {
2623
+ if (s === -1) return !0;
2624
+ const b = T(l);
2625
2625
  if (!b || b.length === 0) return !1;
2626
- let I = !1;
2627
- for (const C of b) if (C.width > 0 && C.height > 0 && !(C.bottom < -l || C.top > window.innerHeight + l || C.right < -l || C.left > window.innerWidth + l)) {
2628
- I = !0;
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;
2629
2629
  break;
2630
2630
  }
2631
- if (!I) return !1;
2632
- if (s.ownerDocument !== window.document) return !0;
2633
- let w = Array.from(b).find((C) => C.width > 0 && C.height > 0);
2631
+ if (!R) return !1;
2632
+ if (l.ownerDocument !== window.document) return !0;
2633
+ let w = Array.from(b).find((x) => x.width > 0 && x.height > 0);
2634
2634
  if (!w) return !1;
2635
- const _ = s.getRootNode();
2635
+ const _ = l.getRootNode();
2636
2636
  if (_ instanceof ShadowRoot) {
2637
- const C = w.left + w.width / 2, P = w.top + w.height / 2;
2637
+ const x = w.left + w.width / 2, P = w.top + w.height / 2;
2638
2638
  try {
2639
- const k = _.elementFromPoint(C, P);
2639
+ const k = _.elementFromPoint(x, P);
2640
2640
  if (!k) return !1;
2641
- let D = k;
2642
- for (; D && D !== _; ) {
2643
- if (D === s) return !0;
2644
- D = D.parentElement;
2641
+ let I = k;
2642
+ for (; I && I !== _; ) {
2643
+ if (I === l) return !0;
2644
+ I = I.parentElement;
2645
2645
  }
2646
2646
  return !1;
2647
2647
  } catch {
2648
2648
  return !0;
2649
2649
  }
2650
2650
  }
2651
- const F = 5;
2651
+ const D = 5;
2652
2652
  return [
2653
2653
  {
2654
2654
  x: w.left + w.width / 2,
2655
2655
  y: w.top + w.height / 2
2656
2656
  },
2657
2657
  {
2658
- x: w.left + F,
2659
- y: w.top + F
2658
+ x: w.left + D,
2659
+ y: w.top + D
2660
2660
  },
2661
2661
  {
2662
- x: w.right - F,
2663
- y: w.bottom - F
2662
+ x: w.right - D,
2663
+ y: w.bottom - D
2664
2664
  }
2665
- ].some(({ x: C, y: P }) => {
2665
+ ].some(({ x, y: P }) => {
2666
2666
  try {
2667
- const k = document.elementFromPoint(C, P);
2667
+ const k = document.elementFromPoint(x, P);
2668
2668
  if (!k) return !1;
2669
- let D = k;
2670
- for (; D && D !== document.documentElement; ) {
2671
- if (D === s) return !0;
2672
- D = D.parentElement;
2669
+ let I = k;
2670
+ for (; I && I !== document.documentElement; ) {
2671
+ if (I === l) return !0;
2672
+ I = I.parentElement;
2673
2673
  }
2674
2674
  return !1;
2675
2675
  } catch {
@@ -2677,19 +2677,19 @@ var dom_tree_default = (t = {
2677
2677
  }
2678
2678
  });
2679
2679
  }
2680
- function N(s, b) {
2680
+ function O(l, b) {
2681
2681
  if (b === -1) return !0;
2682
- const I = s.getClientRects();
2683
- if (!I || I.length === 0) {
2684
- const w = m(s);
2682
+ const R = l.getClientRects();
2683
+ if (!R || R.length === 0) {
2684
+ const w = g(l);
2685
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);
2686
2686
  }
2687
- for (const w of I)
2687
+ for (const w of R)
2688
2688
  if (!(w.width === 0 || w.height === 0) && !(w.bottom < -b || w.top > window.innerHeight + b || w.right < -b || w.left > window.innerWidth + b))
2689
2689
  return !0;
2690
2690
  return !1;
2691
2691
  }
2692
- const $ = [
2692
+ const F = [
2693
2693
  "aria-expanded",
2694
2694
  "aria-checked",
2695
2695
  "aria-selected",
@@ -2704,13 +2704,13 @@ var dom_tree_default = (t = {
2704
2704
  "aria-valuemin",
2705
2705
  "aria-autocomplete"
2706
2706
  ];
2707
- function B(s) {
2708
- for (let b = 0; b < $.length; b++) if (s.hasAttribute($[b])) return !0;
2707
+ function B(l) {
2708
+ for (let b = 0; b < F.length; b++) if (l.hasAttribute(F[b])) return !0;
2709
2709
  return !1;
2710
2710
  }
2711
- function K(s) {
2712
- if (!s || s.nodeType !== Node.ELEMENT_NODE) return !1;
2713
- const b = s.tagName.toLowerCase();
2711
+ function J(l) {
2712
+ if (!l || l.nodeType !== Node.ELEMENT_NODE) return !1;
2713
+ const b = l.tagName.toLowerCase();
2714
2714
  return (/* @__PURE__ */ new Set([
2715
2715
  "a",
2716
2716
  "button",
@@ -2720,9 +2720,9 @@ var dom_tree_default = (t = {
2720
2720
  "details",
2721
2721
  "summary",
2722
2722
  "label"
2723
- ])).has(b) ? !0 : s.hasAttribute("onclick") || s.hasAttribute("role") || s.hasAttribute("tabindex") || B(s) || s.hasAttribute("data-action") || s.getAttribute("contenteditable") === "true";
2723
+ ])).has(b) ? !0 : l.hasAttribute("onclick") || l.hasAttribute("role") || l.hasAttribute("tabindex") || B(l) || l.hasAttribute("data-action") || l.getAttribute("contenteditable") === "true";
2724
2724
  }
2725
- const W = /* @__PURE__ */ new Set([
2725
+ const G = /* @__PURE__ */ new Set([
2726
2726
  "a",
2727
2727
  "button",
2728
2728
  "input",
@@ -2733,7 +2733,7 @@ var dom_tree_default = (t = {
2733
2733
  "label",
2734
2734
  "option",
2735
2735
  "li"
2736
- ]), J = /* @__PURE__ */ new Set([
2736
+ ]), Q = /* @__PURE__ */ new Set([
2737
2737
  "button",
2738
2738
  "link",
2739
2739
  "menuitem",
@@ -2755,20 +2755,20 @@ var dom_tree_default = (t = {
2755
2755
  "option",
2756
2756
  "scrollbar"
2757
2757
  ]);
2758
- function ee(s) {
2759
- if (!s || s.nodeType !== Node.ELEMENT_NODE || !y(s)) return !1;
2760
- const b = s.hasAttribute("role") || s.hasAttribute("tabindex") || s.hasAttribute("onclick") || typeof s.onclick == "function", I = /\b(btn|clickable|menu|item|entry|link)\b/i.test(s.className || ""), w = !!s.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'), _ = [...s.children].some(y), F = s.parentElement && s.parentElement.isSameNode(document.body);
2761
- return (M(s) || b || I) && _ && w && !F;
2762
- }
2763
- function te(s) {
2764
- if (!s || s.nodeType !== Node.ELEMENT_NODE) return !1;
2765
- const b = s.tagName.toLowerCase(), I = s.getAttribute("role");
2766
- if (b === "iframe" || W.has(b) || I && J.has(I) || s.isContentEditable || s.getAttribute("contenteditable") === "true" || s.hasAttribute("data-testid") || s.hasAttribute("data-cy") || s.hasAttribute("data-test") || s.hasAttribute("onclick") || typeof s.onclick == "function" || B(s)) return !0;
2758
+ function ee(l) {
2759
+ 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;
2762
+ }
2763
+ function te(l) {
2764
+ 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;
2767
2767
  try {
2768
- const w = s?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
2768
+ const w = l?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
2769
2769
  if (typeof w == "function") {
2770
- const _ = w(s);
2771
- for (const F of [
2770
+ const _ = w(l);
2771
+ for (const D of [
2772
2772
  "click",
2773
2773
  "mousedown",
2774
2774
  "mouseup",
@@ -2779,7 +2779,7 @@ var dom_tree_default = (t = {
2779
2779
  "input",
2780
2780
  "focus",
2781
2781
  "blur"
2782
- ]) for (const C of _) if (C.type === F) return !0;
2782
+ ]) for (const x of _) if (x.type === D) return !0;
2783
2783
  }
2784
2784
  if ([
2785
2785
  "onmousedown",
@@ -2791,119 +2791,119 @@ var dom_tree_default = (t = {
2791
2791
  "oninput",
2792
2792
  "onfocus",
2793
2793
  "onblur"
2794
- ].some((_) => s.hasAttribute(_))) return !0;
2794
+ ].some((_) => l.hasAttribute(_))) return !0;
2795
2795
  } catch {
2796
2796
  }
2797
- return !!(ee(s) || d.get(s)?.scrollable);
2797
+ return !!(ee(l) || u.get(l)?.scrollable);
2798
2798
  }
2799
- function G(s, b, I, w) {
2800
- if (!s.isInteractive) return !1;
2799
+ function W(l, b, R, w) {
2800
+ if (!l.isInteractive) return !1;
2801
2801
  let _ = !1;
2802
- return w ? te(b) ? _ = !0 : _ = !1 : _ = !0, _ && (s.isInViewport = N(b, l), (s.isInViewport || l === -1) && (s.highlightIndex = u++, o)) ? (a >= 0 ? a === s.highlightIndex && T(b, s.highlightIndex, I) : T(b, s.highlightIndex, I), !0) : !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;
2803
2803
  }
2804
- function V(s, b = null, I = !1) {
2805
- if (!s || s.id === x || s.nodeType !== Node.ELEMENT_NODE && s.nodeType !== Node.TEXT_NODE || !s || s.id === x || s.dataset?.browserUseIgnore === "true" || s.dataset?.pageAgentIgnore === "true" || s.getAttribute && s.getAttribute("aria-hidden") === "true") return null;
2806
- if (s === document.body) {
2807
- const C = {
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;
2806
+ if (l === document.body) {
2807
+ const x = {
2808
2808
  tagName: "body",
2809
2809
  attributes: {},
2810
2810
  xpath: "/body",
2811
2811
  children: []
2812
2812
  };
2813
- for (const k of s.childNodes) {
2814
- const D = V(k, b, !1);
2815
- D && C.children.push(D);
2813
+ for (const k of l.childNodes) {
2814
+ const I = Z(k, b, !1);
2815
+ I && x.children.push(I);
2816
2816
  }
2817
- const P = `${h.current++}`;
2818
- return E[P] = C, P;
2817
+ const P = `${f.current++}`;
2818
+ return C[P] = x, P;
2819
2819
  }
2820
- if (s.nodeType !== Node.ELEMENT_NODE && s.nodeType !== Node.TEXT_NODE) return null;
2821
- if (s.nodeType === Node.TEXT_NODE) {
2822
- const C = s.textContent?.trim();
2823
- if (!C) return null;
2824
- const P = s.parentElement;
2820
+ if (l.nodeType !== Node.ELEMENT_NODE && l.nodeType !== Node.TEXT_NODE) return null;
2821
+ if (l.nodeType === Node.TEXT_NODE) {
2822
+ const x = l.textContent?.trim();
2823
+ if (!x) return null;
2824
+ const P = l.parentElement;
2825
2825
  if (!P || P.tagName.toLowerCase() === "script") return null;
2826
- const k = `${h.current++}`;
2827
- return E[k] = {
2826
+ const k = `${f.current++}`;
2827
+ return C[k] = {
2828
2828
  type: "TEXT_NODE",
2829
- text: C,
2830
- isVisible: A(s)
2829
+ text: x,
2830
+ isVisible: L(l)
2831
2831
  }, k;
2832
2832
  }
2833
- if (s.nodeType === Node.ELEMENT_NODE && !v(s)) return null;
2834
- if (l !== -1 && !s.shadowRoot) {
2835
- const C = m(s), P = g(s), k = P && (P.position === "fixed" || P.position === "sticky"), D = s.offsetWidth > 0 || s.offsetHeight > 0;
2836
- if (!C || !k && !D && (C.bottom < -l || C.top > window.innerHeight + l || C.right < -l || C.left > window.innerWidth + l)) return null;
2833
+ 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;
2837
2837
  }
2838
2838
  const w = {
2839
- tagName: s.tagName.toLowerCase(),
2839
+ tagName: l.tagName.toLowerCase(),
2840
2840
  attributes: {},
2841
2841
  /**
2842
2842
  * @edit no need for xpath
2843
2843
  */
2844
2844
  children: []
2845
2845
  };
2846
- if (K(s) || s.tagName.toLowerCase() === "iframe" || s.tagName.toLowerCase() === "body") {
2847
- const C = s.getAttributeNames?.() || [];
2848
- for (const P of C) {
2849
- const k = s.getAttribute(P);
2846
+ if (J(l) || l.tagName.toLowerCase() === "iframe" || l.tagName.toLowerCase() === "body") {
2847
+ const x = l.getAttributeNames?.() || [];
2848
+ for (const P of x) {
2849
+ const k = l.getAttribute(P);
2850
2850
  w.attributes[P] = k;
2851
2851
  }
2852
- s.tagName.toLowerCase() === "input" && (s.type === "checkbox" || s.type === "radio") && (w.attributes.checked = s.checked ? "true" : "false");
2852
+ l.tagName.toLowerCase() === "input" && (l.type === "checkbox" || l.type === "radio") && (w.attributes.checked = l.checked ? "true" : "false");
2853
2853
  }
2854
2854
  let _ = !1;
2855
- if (s.nodeType === Node.ELEMENT_NODE && (w.isVisible = y(s), w.isVisible)) {
2856
- w.isTopElement = R(s);
2857
- const C = s.getAttribute("role"), P = C === "menu" || C === "menubar" || C === "listbox";
2858
- if ((w.isTopElement || P) && (w.isInteractive = M(s), _ = G(w, s, b, I), w.ref = s, w.isInteractive && Object.keys(w.attributes).length === 0)) {
2859
- const k = s.getAttributeNames?.() || [];
2860
- for (const D of k) {
2861
- const Y = s.getAttribute(D);
2862
- w.attributes[D] = Y;
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)) {
2859
+ const k = l.getAttributeNames?.() || [];
2860
+ for (const I of k) {
2861
+ const Y = l.getAttribute(I);
2862
+ w.attributes[I] = Y;
2863
2863
  }
2864
2864
  }
2865
2865
  }
2866
- if (s.tagName) {
2867
- const C = s.tagName.toLowerCase();
2868
- if (C === "iframe") try {
2869
- const P = s.contentDocument || s.contentWindow?.document;
2866
+ if (l.tagName) {
2867
+ const x = l.tagName.toLowerCase();
2868
+ if (x === "iframe") try {
2869
+ const P = l.contentDocument || l.contentWindow?.document;
2870
2870
  if (P) for (const k of P.childNodes) {
2871
- const D = V(k, s, !1);
2872
- D && w.children.push(D);
2871
+ const I = Z(k, l, !1);
2872
+ I && w.children.push(I);
2873
2873
  }
2874
2874
  } catch (P) {
2875
2875
  console.warn("Unable to access iframe:", P);
2876
2876
  }
2877
- else if (s.isContentEditable || s.getAttribute("contenteditable") === "true" || s.id === "tinymce" || s.classList.contains("mce-content-body") || C === "body" && s.getAttribute("data-id")?.startsWith("mce_")) for (const P of s.childNodes) {
2878
- const k = V(P, b, _);
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
2879
  k && w.children.push(k);
2880
2880
  }
2881
2881
  else {
2882
- if (s.shadowRoot) {
2882
+ if (l.shadowRoot) {
2883
2883
  w.shadowRoot = !0;
2884
- for (const P of s.shadowRoot.childNodes) {
2885
- const k = V(P, b, _);
2884
+ for (const P of l.shadowRoot.childNodes) {
2885
+ const k = Z(P, b, _);
2886
2886
  k && w.children.push(k);
2887
2887
  }
2888
2888
  }
2889
- for (const P of s.childNodes) {
2890
- const k = V(P, b, _ || I);
2889
+ for (const P of l.childNodes) {
2890
+ const k = Z(P, b, _ || R);
2891
2891
  k && w.children.push(k);
2892
2892
  }
2893
2893
  }
2894
2894
  }
2895
2895
  if (w.tagName === "a" && w.children.length === 0 && !w.attributes.href) {
2896
- const C = m(s);
2897
- if (!(C && C.width > 0 && C.height > 0 || s.offsetWidth > 0 || s.offsetHeight > 0)) return null;
2896
+ const x = g(l);
2897
+ if (!(x && x.width > 0 && x.height > 0 || l.offsetWidth > 0 || l.offsetHeight > 0)) return null;
2898
2898
  }
2899
- w.extra = d.get(s) || null;
2900
- const F = `${h.current++}`;
2901
- return E[F] = w, F;
2899
+ w.extra = u.get(l) || null;
2900
+ const D = `${f.current++}`;
2901
+ return C[D] = w, D;
2902
2902
  }
2903
- const ce = V(document.body);
2904
- return f.clearCache(), {
2903
+ const ce = Z(document.body);
2904
+ return h.clearCache(), {
2905
2905
  rootId: ce,
2906
- map: E
2906
+ map: C
2907
2907
  };
2908
2908
  }, DEFAULT_VIEWPORT_EXPANSION = -1;
2909
2909
  function resolveViewportExpansion(t) {
@@ -2933,10 +2933,10 @@ function getFlatTree(t) {
2933
2933
  highlightLabelOpacity: t.highlightLabelOpacity ?? 0.1
2934
2934
  }), o = window.location.href;
2935
2935
  for (const a in r.map) {
2936
- const l = r.map[a];
2937
- if (l.isInteractive && l.ref) {
2938
- const c = l.ref;
2939
- newElementsCache.has(c) || (newElementsCache.set(c, o), l.isNew = !0);
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);
2940
2940
  }
2941
2941
  }
2942
2942
  return r;
@@ -2983,99 +2983,99 @@ function flatTreeToString(t, e = [], n = !1) {
2983
2983
  "aria-controls",
2984
2984
  "aria-owns",
2985
2985
  "contenteditable"
2986
- ], r = [...e, ...i], o = (f, m) => f.length > m ? f.substring(0, m) + "..." : f, a = (f) => {
2987
- const m = t.map[f];
2988
- if (!m) return null;
2989
- if (m.type === "TEXT_NODE") {
2990
- const g = m;
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;
2991
2991
  return {
2992
2992
  type: "text",
2993
- text: g.text,
2994
- isVisible: g.isVisible,
2993
+ text: y.text,
2994
+ isVisible: y.isVisible,
2995
2995
  parent: null,
2996
2996
  children: []
2997
2997
  };
2998
2998
  } else {
2999
- const g = m, S = [];
3000
- if (g.children) for (const E of g.children) {
3001
- const h = a(E);
3002
- h && (h.parent = null, S.push(h));
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));
3003
3003
  }
3004
3004
  return {
3005
3005
  type: "element",
3006
- tagName: g.tagName,
3007
- attributes: g.attributes ?? {},
3008
- isVisible: g.isVisible ?? !1,
3009
- isInteractive: g.isInteractive ?? !1,
3010
- isTopElement: g.isTopElement ?? !1,
3011
- isNew: g.isNew ?? !1,
3012
- highlightIndex: g.highlightIndex,
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,
3013
3013
  parent: null,
3014
- children: S,
3015
- extra: g.extra ?? {}
3014
+ children: T,
3015
+ extra: y.extra ?? {}
3016
3016
  };
3017
3017
  }
3018
- }, l = (f, m = null) => {
3019
- f.parent = m;
3020
- for (const g of f.children) l(g, f);
3018
+ }, s = (h, g = null) => {
3019
+ h.parent = g;
3020
+ for (const y of h.children) s(y, h);
3021
3021
  }, c = a(t.rootId);
3022
3022
  if (!c) return "";
3023
- l(c);
3024
- const u = (f) => {
3025
- let m = f.parent;
3026
- for (; m; ) {
3027
- if (m.type === "element" && m.highlightIndex !== void 0) return !0;
3028
- m = m.parent;
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;
3029
3029
  }
3030
3030
  return !1;
3031
- }, d = (f, m, g) => {
3032
- let S = m;
3033
- const E = " ".repeat(m);
3034
- if (f.type === "element") {
3035
- const h = n && f.tagName && SEMANTIC_TAGS.has(f.tagName);
3036
- if (f.highlightIndex !== void 0) {
3037
- S += 1;
3038
- const L = getAllTextTillNextClickableElement(f);
3039
- let A = "";
3040
- if (r.length > 0 && f.attributes) {
3041
- const y = matchAttributes(f.attributes, r), M = Object.keys(y);
3042
- if (M.length > 1) {
3043
- const R = /* @__PURE__ */ new Set(), N = {};
3044
- for (const $ of M) {
3045
- const B = y[$];
3046
- B.length > 5 && (B in N ? R.add($) : N[B] = $);
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) {
3045
+ const B = A[F];
3046
+ B.length > 5 && (B in O ? M.add(F) : O[B] = F);
3047
3047
  }
3048
- for (const $ of R) delete y[$];
3048
+ for (const F of M) delete A[F];
3049
3049
  }
3050
- y.role === f.tagName && delete y.role;
3051
- for (const R of [
3050
+ A.role === h.tagName && delete A.role;
3051
+ for (const M of [
3052
3052
  "aria-label",
3053
3053
  "placeholder",
3054
3054
  "title"
3055
- ]) y[R] && y[R].toLowerCase().trim() === L.toLowerCase().trim() && delete y[R];
3056
- Object.keys(y).length > 0 && (A = Object.entries(y).map(([R, N]) => `${R}=${o(N, 20)}`).join(" "));
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(" "));
3057
3057
  }
3058
- let v = `${E}${f.isNew ? `*[${f.highlightIndex}]` : `[${f.highlightIndex}]`}<${f.tagName ?? ""}`;
3059
- if (A && (v += ` ${A}`), f.extra && f.extra.scrollable) {
3060
- let y = "";
3061
- f.extra.scrollData?.left && (y += `left=${f.extra.scrollData.left}, `), f.extra.scrollData?.top && (y += `top=${f.extra.scrollData.top}, `), f.extra.scrollData?.right && (y += `right=${f.extra.scrollData.right}, `), f.extra.scrollData?.bottom && (y += `bottom=${f.extra.scrollData.bottom}`), v += ` data-scrollable="${y}"`;
3058
+ let S = `${C}${h.isNew ? `*[${h.highlightIndex}]` : `[${h.highlightIndex}]`}<${h.tagName ?? ""}`;
3059
+ if (L && (S += ` ${L}`), h.extra && h.extra.scrollable) {
3060
+ 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}"`;
3062
3062
  }
3063
- if (L) {
3064
- const y = L.trim();
3065
- A || (v += " "), v += `>${y}`;
3066
- } else A || (v += " ");
3067
- v += " />", g.push(v);
3063
+ if (v) {
3064
+ const A = v.trim();
3065
+ L || (S += " "), S += `>${A}`;
3066
+ } else L || (S += " ");
3067
+ S += " />", y.push(S);
3068
3068
  }
3069
- const x = h && f.highlightIndex === void 0, T = x ? g.length : -1;
3070
- x && (g.push(`${E}<${f.tagName}>`), S += 1);
3071
- for (const L of f.children) d(L, S, g);
3072
- x && (g.length === T + 1 ? g.pop() : g.push(`${E}</${f.tagName}>`));
3073
- } else if (f.type === "text") {
3074
- if (u(f)) return;
3075
- f.parent && f.parent.type === "element" && f.parent.isVisible && f.parent.isTopElement && g.push(`${E}${f.text ?? ""}`);
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 ?? ""}`);
3076
3076
  }
3077
3077
  }, p = [];
3078
- return d(c, 0, p), p.join(`
3078
+ return u(c, 0, p), p.join(`
3079
3079
  `);
3080
3080
  }
3081
3081
  var getAllTextTillNextClickableElement = (t, e = -1) => {
@@ -3133,7 +3133,7 @@ else {
3133
3133
  }, 500);
3134
3134
  }
3135
3135
  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)), l = Math.max(0, n - (window.innerWidth + r));
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));
3137
3137
  return {
3138
3138
  viewport_width: t,
3139
3139
  viewport_height: e,
@@ -3148,7 +3148,7 @@ function getPageInfo() {
3148
3148
  total_pages: e > 0 ? i / e : 0,
3149
3149
  current_page_position: o / Math.max(1, i - e),
3150
3150
  pixels_left: r,
3151
- pixels_right: l
3151
+ pixels_right: s
3152
3152
  };
3153
3153
  }
3154
3154
  function patchReact(t) {
@@ -3186,7 +3186,7 @@ var PageController = class extends EventTarget {
3186
3186
  */
3187
3187
  initMask() {
3188
3188
  this.maskReady === null && (this.maskReady = (async () => {
3189
- const { SimulatorMask: t } = await import("./SimulatorMask-BHVXyogh-iNUb4dyF.js");
3189
+ const { SimulatorMask: t } = await import("./SimulatorMask-BHVXyogh-CARX3Rff.js");
3190
3190
  this.mask = new t();
3191
3191
  })());
3192
3192
  }
@@ -3380,7 +3380,7 @@ ${n.pixels_above > 4 && i !== -1 ? `... ${n.pixels_above} pixels above (${n.page
3380
3380
  cleanUpHighlights(), this.flatTree = null, this.selectorMap.clear(), this.elementTextMap.clear(), this.simplifiedHTML = "<EMPTY>", this.isIndexed = !1, this.mask?.dispose(), this.mask = null;
3381
3381
  }
3382
3382
  };
3383
- const DEFAULT_ERROR_SELECTORS$1 = [
3383
+ const DEFAULT_ERROR_SELECTORS = [
3384
3384
  '[role="alert"]',
3385
3385
  '[aria-invalid="true"]',
3386
3386
  ".ti3-unifyvalid-error",
@@ -3410,6 +3410,24 @@ const DEFAULT_ERROR_SELECTORS$1 = [
3410
3410
  ".warning-text",
3411
3411
  ".is-warning",
3412
3412
  ".has-warning"
3413
+ ], DEFAULT_DIALOG_SELECTORS = [
3414
+ // W3C ARIA 标准
3415
+ '[role="dialog"]',
3416
+ '[role="alertdialog"]',
3417
+ // Tiny3 / Lego(云控制台)
3418
+ '[class*="ti3-modal"]',
3419
+ '[class*="ti3-message-box"]',
3420
+ // Element UI / Element Plus
3421
+ '[class*="el-dialog"]',
3422
+ '[class*="el-message-box"]',
3423
+ // Ant Design
3424
+ '[class*="ant-modal"]',
3425
+ // Bootstrap
3426
+ '[class*="modal-content"]',
3427
+ // Vuetify
3428
+ '[class*="v-dialog"]',
3429
+ // Naive UI
3430
+ '[class*="n-modal"]'
3413
3431
  ], TAG_ROLE_MAP = {
3414
3432
  a: "link",
3415
3433
  article: "article",
@@ -3488,7 +3506,210 @@ const DEFAULT_ERROR_SELECTORS$1 = [
3488
3506
  tel: "textbox",
3489
3507
  text: "textbox",
3490
3508
  url: "textbox"
3491
- };
3509
+ }, RESOLVED_A11Y_BRAND = Symbol.for("@opentiny/next-sdk:ResolvedA11yConfig");
3510
+ function markResolved(t) {
3511
+ return Object.assign(t, { [RESOLVED_A11Y_BRAND]: !0 });
3512
+ }
3513
+ function isResolvedA11yConfig(t) {
3514
+ return !!t && t[RESOLVED_A11Y_BRAND] === !0;
3515
+ }
3516
+ const STANDARD_STATE_NAMES = [
3517
+ "checked",
3518
+ "selected",
3519
+ "pressed",
3520
+ "current",
3521
+ "expanded",
3522
+ "hasPopup",
3523
+ "disabled",
3524
+ "readonly",
3525
+ "required",
3526
+ "invalid",
3527
+ "busy",
3528
+ "error",
3529
+ "warning"
3530
+ ], DEFAULT_SELECTED_CLASS_RE = /\b(is-active|isActive|is-selected|isSelected|is-current|isCurrent|active-item|activeItem|tab-active|tabActive|active|selected|current)\b/;
3531
+ function defaultSelectedMatch(t) {
3532
+ const e = typeof t.className == "string" ? t.className : "";
3533
+ if (!e || !DEFAULT_SELECTED_CLASS_RE.test(e)) return !1;
3534
+ const n = t.getAttribute("role") || t.tagName.toLowerCase();
3535
+ return ["button", "option", "a", "li", "generic"].includes(n) || n.startsWith("tab");
3536
+ }
3537
+ const DEFAULT_A11Y_CONFIG = markResolved({
3538
+ roles: [],
3539
+ states: {
3540
+ selected: [
3541
+ { match: defaultSelectedMatch },
3542
+ // Tiny3 按钮组/单选按钮组:选中 class 在容器上(.ti3-btn-item-container.ti3-active),
3543
+ // 内部 button 自身无 aria-selected / ti3-active,需靠 closest 命中
3544
+ { selector: ".ti3-btn-item-container.ti3-active" }
3545
+ ],
3546
+ error: [{ selector: DEFAULT_ERROR_SELECTORS }],
3547
+ warning: [{ selector: DEFAULT_WARNING_SELECTORS }]
3548
+ },
3549
+ whitelist: [],
3550
+ blacklist: [],
3551
+ exposedAttributes: [],
3552
+ dialogSelectors: DEFAULT_DIALOG_SELECTORS
3553
+ });
3554
+ function normalizeSelector(t) {
3555
+ return t && (Array.isArray(t) ? t.filter(Boolean).join(", ") : t) || void 0;
3556
+ }
3557
+ function matchesRule(t, e) {
3558
+ if (e.match)
3559
+ try {
3560
+ return !!e.match(t);
3561
+ } catch {
3562
+ return !1;
3563
+ }
3564
+ const n = normalizeSelector(e.selector);
3565
+ if (n)
3566
+ try {
3567
+ return !!t.closest(n);
3568
+ } catch {
3569
+ return !1;
3570
+ }
3571
+ return !1;
3572
+ }
3573
+ function matchesRoleRule(t, e) {
3574
+ if (e.match)
3575
+ try {
3576
+ return !!e.match(t);
3577
+ } catch {
3578
+ return !1;
3579
+ }
3580
+ const n = normalizeSelector(e.selector);
3581
+ if (n)
3582
+ try {
3583
+ return !!t.matches(n);
3584
+ } catch {
3585
+ return !1;
3586
+ }
3587
+ return !1;
3588
+ }
3589
+ function matchesAnyRule(t, e) {
3590
+ return e ? (Array.isArray(e) ? e : [e]).some((i) => matchesRule(t, i)) : !1;
3591
+ }
3592
+ function extractSelectors(t) {
3593
+ return t ? (Array.isArray(t) ? t : [t]).flatMap((n) => Array.isArray(n.selector) ? n.selector.filter(Boolean) : n.selector ? [n.selector] : []) : [];
3594
+ }
3595
+ function concatArr(t, e) {
3596
+ return [...t ?? [], ...e ?? []];
3597
+ }
3598
+ function normalizeMatcherList(t) {
3599
+ return t ? Array.isArray(t) ? t : [t] : [];
3600
+ }
3601
+ function mergeStates(t, e) {
3602
+ const n = {}, i = /* @__PURE__ */ new Set([...Object.keys(t ?? {}), ...Object.keys(e ?? {})]);
3603
+ for (const r of i)
3604
+ n[r] = [...normalizeMatcherList(t?.[r]), ...normalizeMatcherList(e?.[r])];
3605
+ return n;
3606
+ }
3607
+ function mergeA11yConfigs(t, e) {
3608
+ return markResolved({
3609
+ roles: concatArr(t.roles, e.roles),
3610
+ states: mergeStates(t.states, e.states),
3611
+ whitelist: concatArr(t.whitelist, e.whitelist),
3612
+ blacklist: concatArr(t.blacklist, e.blacklist),
3613
+ exposedAttributes: concatArr(t.exposedAttributes, e.exposedAttributes),
3614
+ dialogSelectors: concatArr(t.dialogSelectors, e.dialogSelectors)
3615
+ });
3616
+ }
3617
+ function mergeA11yConfig(t) {
3618
+ return isResolvedA11yConfig(t) ? t : mergeA11yConfigs(DEFAULT_A11Y_CONFIG, t ?? {});
3619
+ }
3620
+ function ensureResolvedA11yConfig(t) {
3621
+ return isResolvedA11yConfig(t) ? t : mergeA11yConfig(t);
3622
+ }
3623
+ function defineA11yConfig(t) {
3624
+ return t;
3625
+ }
3626
+ function computeRole(t, e) {
3627
+ const n = t.getAttribute("role"), i = !!n && n !== "presentation" && n !== "none";
3628
+ for (const o of e.roles)
3629
+ if (!(i && !o.force) && matchesRoleRule(t, o))
3630
+ return o.role;
3631
+ if (i) return n;
3632
+ const r = t.tagName.toLowerCase();
3633
+ if (r === "input") {
3634
+ const o = t.type?.toLowerCase() ?? "text";
3635
+ return INPUT_TYPE_ROLE[o] ?? "textbox";
3636
+ }
3637
+ return TAG_ROLE_MAP[r] ?? "generic";
3638
+ }
3639
+ 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")
3642
+ n.push("checked");
3643
+ else if (a === "mixed")
3644
+ n.push("checked=mixed");
3645
+ else if (a === "false")
3646
+ n.push("unchecked");
3647
+ 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);
3655
+ }
3656
+ E !== void 0 ? n.push(E ? "checked" : "unchecked") : o("checked") && n.push("checked");
3657
+ }
3658
+ (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");
3661
+ const c = i("aria-current");
3662
+ 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
+ const d = i("aria-haspopup");
3664
+ (d && d !== "false" || o("hasPopup")) && n.push("hasPopup"), (i("aria-expanded") === "true" || o("expanded")) && n.push("expanded");
3665
+ const u = i("aria-invalid");
3666
+ 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}`);
3675
+ try {
3676
+ window.getComputedStyle(t).cursor === "pointer" && n.push("cursor=pointer");
3677
+ } catch {
3678
+ }
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}"`);
3683
+ }
3684
+ const C = i("aria-valuenow");
3685
+ C && n.push(`valuenow="${C}"`);
3686
+ 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}`);
3690
+ }
3691
+ 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}"`);
3697
+ }
3698
+ return Array.from(new Set(n));
3699
+ }
3700
+ function resolveA11yRole(t, e) {
3701
+ return computeRole(t, ensureResolvedA11yConfig(e));
3702
+ }
3703
+ function resolveA11yStates(t, e) {
3704
+ return computeStates(t, ensureResolvedA11yConfig(e));
3705
+ }
3706
+ function resolveA11yInfo(t, e) {
3707
+ const n = ensureResolvedA11yConfig(e);
3708
+ return {
3709
+ role: computeRole(t, n),
3710
+ tokens: computeStates(t, n)
3711
+ };
3712
+ }
3492
3713
  var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "area[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"], candidateSelector = /* @__PURE__ */ candidateSelectors.join(","), NoElement = typeof Element > "u", matches = NoElement ? function() {
3493
3714
  } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, getRootNode = !NoElement && Element.prototype.getRootNode ? function(t) {
3494
3715
  var e;
@@ -3520,8 +3741,8 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3520
3741
  }, isTabbableRadio = function t(e) {
3521
3742
  if (!e.name)
3522
3743
  return !0;
3523
- var n = e.form || getRootNode(e), i = function(l) {
3524
- return n.querySelectorAll('input[type="radio"][name="' + l + '"]');
3744
+ var n = e.form || getRootNode(e), i = function(s) {
3745
+ return n.querySelectorAll('input[type="radio"][name="' + s + '"]');
3525
3746
  }, r;
3526
3747
  if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
3527
3748
  r = i(window.CSS.escape(e.name));
@@ -3540,10 +3761,10 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3540
3761
  }, isNodeAttached = function t(e) {
3541
3762
  var n, i = e && getRootNode(e), r = (n = i) === null || n === void 0 ? void 0 : n.host, o = !1;
3542
3763
  if (i && i !== e) {
3543
- var a, l, c;
3544
- for (o = !!((a = r) !== null && a !== void 0 && (l = a.ownerDocument) !== null && l !== void 0 && l.contains(r) || e != null && (c = e.ownerDocument) !== null && c !== void 0 && c.contains(e)); !o && r; ) {
3545
- var u, d, p;
3546
- i = getRootNode(r), r = (u = i) === null || u === void 0 ? void 0 : u.host, o = !!((d = r) !== null && d !== void 0 && (p = d.ownerDocument) !== null && p !== void 0 && p.contains(r));
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));
3547
3768
  }
3548
3769
  }
3549
3770
  return o;
@@ -3568,23 +3789,23 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3568
3789
  });
3569
3790
  return !o;
3570
3791
  }
3571
- var a = getComputedStyle(e), l = a.visibility;
3572
- if (l === "hidden" || l === "collapse")
3792
+ var a = getComputedStyle(e), s = a.visibility;
3793
+ if (s === "hidden" || s === "collapse")
3573
3794
  return !0;
3574
- var c = matches.call(e, "details>summary:first-of-type"), u = c ? e.parentElement : e;
3575
- if (matches.call(u, "details:not([open]) *"))
3795
+ var c = matches.call(e, "details>summary:first-of-type"), d = c ? e.parentElement : e;
3796
+ if (matches.call(d, "details:not([open]) *"))
3576
3797
  return !0;
3577
3798
  if (!i || i === "full" || // full-native can run this branch when it falls through in case
3578
3799
  // Element#checkVisibility is unsupported
3579
3800
  i === "full-native" || i === "legacy-full") {
3580
3801
  if (typeof r == "function") {
3581
- for (var d = e; e; ) {
3582
- var p = e.parentElement, f = getRootNode(e);
3802
+ for (var u = e; e; ) {
3803
+ var p = e.parentElement, h = getRootNode(e);
3583
3804
  if (p && !p.shadowRoot && r(p) === !0)
3584
3805
  return isZeroArea(e);
3585
- e.assignedSlot ? e = e.assignedSlot : !p && f !== e.ownerDocument ? e = f.host : e = p;
3806
+ e.assignedSlot ? e = e.assignedSlot : !p && h !== e.ownerDocument ? e = h.host : e = p;
3586
3807
  }
3587
- e = d;
3808
+ e = u;
3588
3809
  }
3589
3810
  if (isNodeAttached(e))
3590
3811
  return !e.getClientRects().length;
@@ -3617,98 +3838,178 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
3617
3838
  throw new Error("No node provided");
3618
3839
  return matches.call(e, candidateSelector) === !1 ? !1 : isNodeMatchingSelectorTabbable(n, e);
3619
3840
  };
3620
- function inferRole(t) {
3621
- const e = t.getAttribute("role");
3622
- if (e && e !== "presentation" && e !== "none")
3623
- return e;
3624
- const n = t.tagName.toLowerCase();
3625
- if (n === "input") {
3626
- const i = t.type?.toLowerCase() ?? "text";
3627
- return INPUT_TYPE_ROLE[i] ?? "textbox";
3628
- }
3629
- return TAG_ROLE_MAP[n] ?? "generic";
3841
+ const DEFAULT_PAGE_AGENT_TOOL_CONFIG = {
3842
+ enableHighlight: !1,
3843
+ removeMaskAfterToolCall: !0,
3844
+ a11yConfig: DEFAULT_A11Y_CONFIG
3845
+ };
3846
+ function getPageAgentToolConfig() {
3847
+ return typeof window < "u" && window.__webmcpcli_toolConfig ? window.__webmcpcli_toolConfig : {
3848
+ enableHighlight: DEFAULT_PAGE_AGENT_TOOL_CONFIG.enableHighlight,
3849
+ removeMaskAfterToolCall: DEFAULT_PAGE_AGENT_TOOL_CONFIG.removeMaskAfterToolCall,
3850
+ a11yConfig: mergeA11yConfig()
3851
+ };
3630
3852
  }
3631
- function getStateTokens(t, e, n, i) {
3632
- const r = [], o = (v) => t.getAttribute(v), a = o("aria-checked");
3633
- if (a === "true")
3634
- r.push("checked");
3635
- else if (a === "false")
3636
- r.push("unchecked");
3637
- else {
3638
- const v = t.tagName.toLowerCase();
3639
- let y;
3640
- if (v === "input" && (t.type === "checkbox" || t.type === "radio"))
3641
- y = t.checked;
3642
- else if (v === "label" && t.hasAttribute("for")) {
3643
- const M = document.getElementById(t.getAttribute("for"));
3644
- M instanceof HTMLInputElement && (M.type === "checkbox" || M.type === "radio") && (y = M.checked);
3853
+ function resolvePatch(t, e) {
3854
+ return {
3855
+ enableHighlight: t.enableHighlight ?? e.enableHighlight,
3856
+ removeMaskAfterToolCall: t.removeMaskAfterToolCall ?? e.removeMaskAfterToolCall,
3857
+ a11yConfig: mergeA11yConfigs(e.a11yConfig, t.a11yConfig ?? {})
3858
+ };
3859
+ }
3860
+ function setPageAgentToolConfig(t, e) {
3861
+ const n = e?.mode ?? "merge", i = getPageAgentToolConfig(), r = typeof t == "function" ? resolvePatch(t(i), DEFAULT_PAGE_AGENT_TOOL_CONFIG) : resolvePatch(t, n === "replace" ? DEFAULT_PAGE_AGENT_TOOL_CONFIG : i);
3862
+ return typeof window < "u" && (window.__webmcpcli_toolConfig = r), r;
3863
+ }
3864
+ function isInShadowDom(t) {
3865
+ return t.getRootNode() instanceof ShadowRoot;
3866
+ }
3867
+ function dispatchComposedEvents(t, ...e) {
3868
+ for (const n of e)
3869
+ t.dispatchEvent(new Event(n, { bubbles: !0, composed: !0 }));
3870
+ }
3871
+ function deepQuerySelectorAll(t, e = document) {
3872
+ const n = Array.from(e.querySelectorAll(t)), i = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, null);
3873
+ let r = i.currentNode;
3874
+ for (; r; )
3875
+ r.shadowRoot && n.push(...deepQuerySelectorAll(t, r.shadowRoot)), r = i.nextNode();
3876
+ return n;
3877
+ }
3878
+ function waitForDomSettled(t = 600, e = 150) {
3879
+ return new Promise((n) => {
3880
+ let i = !1, r;
3881
+ const o = () => {
3882
+ i || (i = !0, a.disconnect(), r && clearTimeout(r), n());
3883
+ }, a = new MutationObserver(() => {
3884
+ r && clearTimeout(r), r = setTimeout(o, e);
3885
+ });
3886
+ r = setTimeout(o, e), setTimeout(o, t), a.observe(document.body, {
3887
+ childList: !0,
3888
+ subtree: !0,
3889
+ attributes: !0,
3890
+ attributeFilter: ["class", "style", "hidden"]
3891
+ });
3892
+ });
3893
+ }
3894
+ function detectPageDialog() {
3895
+ const t = /* @__PURE__ */ new Set(), e = [], n = getPageAgentToolConfig().a11yConfig.dialogSelectors;
3896
+ for (const i of n)
3897
+ try {
3898
+ for (const r of deepQuerySelectorAll(i)) {
3899
+ if (t.has(r) || r.id?.includes("page-agent-runtime") || r.closest("#page-agent-runtime_simulator-mask")) continue;
3900
+ const o = r.getBoundingClientRect();
3901
+ 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;
3906
+ const d = window.innerWidth, u = window.innerHeight;
3907
+ if (!(o.left < d * 0.6 && o.right > d * 0.4 && o.top < u * 0.6 && o.bottom > u * 0.4)) continue;
3908
+ 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}`);
3913
+ }
3914
+ }
3915
+ } catch {
3916
+ }
3917
+ return e.length === 0 ? "" : `
3918
+ [页面弹窗检测] 检测到 ${e.length} 个模态弹窗,请优先处理:
3919
+ ${e.map((i, r) => `${r + 1}. ${i}`).join(`
3920
+ `)}
3921
+ `;
3922
+ }
3923
+ function detectValidationErrors() {
3924
+ const t = /* @__PURE__ */ new Set(), e = [], n = extractSelectors(getPageAgentToolConfig().a11yConfig.states.error);
3925
+ for (const i of n)
3926
+ try {
3927
+ for (const r of deepQuerySelectorAll(i)) {
3928
+ if (t.has(r) || Array.from(t).some((c) => c.contains(r))) continue;
3929
+ const o = r.getBoundingClientRect();
3930
+ 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));
3935
+ }
3936
+ } catch {
3645
3937
  }
3646
- y !== void 0 && r.push(y ? "checked" : "unchecked");
3647
- }
3648
- o("aria-selected") === "true" && r.push("selected"), (o("aria-disabled") === "true" || t.disabled) && r.push("disabled");
3649
- const c = o("aria-haspopup");
3650
- c && c !== "false" && r.push("hasPopup"), o("aria-expanded") === "true" && r.push("expanded");
3651
- const u = t.tagName.match(/^H([1-6])$/);
3652
- u && r.push(`level=${u[1]}`);
3653
- const d = o("aria-level");
3654
- d && !u && r.push(`level=${d}`);
3938
+ return e.length === 0 ? "" : `
3939
+ [校验提示] 检测到 ${e.length} 个表单校验错误,请先修复后再继续:
3940
+ ${e.map((i, r) => `${r + 1}. ${i}`).join(`
3941
+ `)}
3942
+ `;
3943
+ }
3944
+ const NON_CONTENT_TAGS = /* @__PURE__ */ new Set([
3945
+ "script",
3946
+ "style",
3947
+ "noscript",
3948
+ "template",
3949
+ "link",
3950
+ "meta",
3951
+ "head",
3952
+ "title"
3953
+ ]);
3954
+ function isNonContentElement(t) {
3955
+ return NON_CONTENT_TAGS.has(t.tagName.toLowerCase());
3956
+ }
3957
+ function hasOwnPointerCursor(t) {
3655
3958
  try {
3656
- window.getComputedStyle(t).cursor === "pointer" && r.push("cursor=pointer");
3959
+ if (window.getComputedStyle(t).cursor !== "pointer") return !1;
3960
+ const e = t.parentElement;
3961
+ return e ? window.getComputedStyle(e).cursor !== "pointer" : !0;
3657
3962
  } catch {
3963
+ return !1;
3658
3964
  }
3659
- const p = t.tagName.toLowerCase();
3660
- if (p === "input" || p === "textarea" || p === "select") {
3661
- const v = t.value;
3662
- v !== void 0 && v !== "" && r.push(`value="${v}"`);
3663
- }
3664
- const f = t.getAttribute("aria-valuenow");
3665
- f && r.push(`valuenow="${f}"`), t.tagName.toLowerCase() === "a" && t.getAttribute("target") === "_blank" && r.push("opens-new-tab");
3666
- const m = typeof t.className == "string" ? t.className : "", S = [
3667
- "is-active",
3668
- "isActive",
3669
- "is-selected",
3670
- "isSelected",
3671
- "is-current",
3672
- "isCurrent",
3673
- "active-item",
3674
- "activeItem",
3675
- "tab-active",
3676
- "tabActive",
3677
- // 仅当作为独立 class 词或有连字符前缀时匹配 "active",避免误匹配 "interactive" 等
3678
- /\bactive\b/,
3679
- /\bselected\b/,
3680
- /\bcurrent\b/
3681
- ].some(
3682
- (v) => typeof v == "string" ? m.split(/\s+/).includes(v) : v.test(m)
3683
- ), x = (t.getAttribute("role") || t.tagName.toLowerCase()).split(/\s+/).some((v) => ["button", "option", "a", "li", "generic"].includes(v) || v.startsWith("tab"));
3684
- S && x && !r.includes("checked") && !r.includes("selected") && r.push("active");
3685
- const T = Array.isArray(n) ? n.join(", ") : n || DEFAULT_ERROR_SELECTORS$1.join(", "), L = Array.isArray(i) ? i.join(", ") : i || DEFAULT_WARNING_SELECTORS.join(", ");
3686
- let A = null;
3687
- if (T)
3688
- try {
3689
- A = t.closest(T);
3690
- } catch {
3965
+ }
3966
+ const INTERACTION_PSEUDO_RE = /:(hover|focus|focus-visible|focus-within|active)\b/gi;
3967
+ function collectInteractivePointerSelectors(t, e) {
3968
+ for (const n of Array.from(t)) {
3969
+ const i = n, r = n;
3970
+ if (!i.selectorText && r.cssRules) {
3971
+ collectInteractivePointerSelectors(r.cssRules, e);
3972
+ continue;
3691
3973
  }
3692
- if (A)
3693
- r.push("error");
3694
- else {
3695
- let v = null;
3696
- if (L)
3974
+ const o = i.selectorText;
3975
+ 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);
3979
+ }
3980
+ }
3981
+ }
3982
+ function collectHoverPointerElements(t) {
3983
+ const e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
3984
+ try {
3985
+ for (const r of Array.from(document.styleSheets)) {
3986
+ let o = null;
3697
3987
  try {
3698
- v = t.closest(L);
3988
+ o = r.cssRules;
3699
3989
  } catch {
3990
+ continue;
3700
3991
  }
3701
- v && r.push("warning");
3702
- }
3703
- if (e)
3704
- for (const v of e) {
3705
- const y = t.getAttribute(v);
3706
- y !== null && r.push(`${v}="${y}"`);
3992
+ o && collectInteractivePointerSelectors(o, n);
3707
3993
  }
3708
- return r;
3994
+ } catch {
3995
+ return e;
3996
+ }
3997
+ if (n.size === 0) return e;
3998
+ const i = Array.from(n);
3999
+ try {
4000
+ for (const r of deepQuerySelectorAll(i.join(", "), t)) e.add(r);
4001
+ return e;
4002
+ } catch {
4003
+ for (const r of i)
4004
+ try {
4005
+ for (const o of deepQuerySelectorAll(r, t)) e.add(o);
4006
+ } catch {
4007
+ }
4008
+ }
4009
+ return e;
3709
4010
  }
3710
4011
  function isHidden$1(t) {
3711
- if (t.getAttribute("aria-hidden") === "true" || t.hidden) return !0;
4012
+ if (isNonContentElement(t) || t.getAttribute("aria-hidden") === "true" || t.hidden) return !0;
3712
4013
  try {
3713
4014
  const e = window.getComputedStyle(t);
3714
4015
  if (e.display === "none" || e.visibility === "hidden" || e.opacity === "0") return !0;
@@ -3718,29 +4019,30 @@ function isHidden$1(t) {
3718
4019
  }
3719
4020
  return !1;
3720
4021
  }
3721
- function collectDescendantText(t) {
3722
- let e = "";
3723
- const n = (i) => {
3724
- if (i.nodeType === Node.TEXT_NODE)
3725
- e += (i.textContent ?? "") + " ";
3726
- else if (i.nodeType === Node.ELEMENT_NODE) {
3727
- const r = i;
3728
- if (isHidden$1(r)) return;
3729
- if (r !== t) {
3730
- const o = r.tagName.toLowerCase(), a = inferRole(r), l = ["button", "a", "input", "select", "textarea", "li", "option"].includes(o), c = ["button", "link", "checkbox", "radio", "textbox", "listitem", "option", "combobox", "listbox"].includes(a), u = isTabbable(r);
3731
- let d = !1;
3732
- try {
3733
- d = window.getComputedStyle(r).cursor === "pointer";
3734
- } catch {
3735
- }
3736
- if (u && !(a === "generic" && !d) || l || c)
4022
+ function collectTitleLabel(t) {
4023
+ const e = t.getAttribute("title")?.trim();
4024
+ if (e) return e;
4025
+ const i = t.querySelector("[title]")?.getAttribute("title")?.trim();
4026
+ return i || "";
4027
+ }
4028
+ function collectDescendantText(t, e) {
4029
+ let n = "";
4030
+ const i = (r) => {
4031
+ if (r.nodeType === Node.TEXT_NODE)
4032
+ n += (r.textContent ?? "") + " ";
4033
+ else if (r.nodeType === Node.ELEMENT_NODE) {
4034
+ const o = r;
4035
+ if (o !== t && isNonContentElement(o) || isHidden$1(o) && o !== t || o === t && isNonContentElement(o)) return;
4036
+ 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)
3737
4039
  return;
3738
4040
  }
3739
- for (const o of Array.from(r.childNodes))
3740
- n(o);
4041
+ for (const a of Array.from(o.childNodes))
4042
+ i(a);
3741
4043
  }
3742
4044
  };
3743
- return n(t), e.trim().replace(/\s+/g, " ");
4045
+ return i(t), n.trim().replace(/\s+/g, " ");
3744
4046
  }
3745
4047
  function getComposedChildren(t) {
3746
4048
  const e = t.shadowRoot ? t.shadowRoot.children : t.children, n = [];
@@ -3769,8 +4071,8 @@ function arrayFrom(t, e) {
3769
4071
  var n = Array, i = Object(t);
3770
4072
  if (t == null)
3771
4073
  throw new TypeError("Array.from requires an array-like object - not null or undefined");
3772
- for (var r = toLength(i.length), o = isCallable(n) ? Object(new n(r)) : new Array(r), a = 0, l; a < r; )
3773
- l = i[a], o[a] = l, a += 1;
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;
3774
4076
  return o.length = r, o;
3775
4077
  }
3776
4078
  function _typeof$1(t) {
@@ -4175,105 +4477,105 @@ function getSlotContents(t) {
4175
4477
  return e.length === 0 ? arrayFrom(t.childNodes) : e;
4176
4478
  }
4177
4479
  function computeTextAlternative(t) {
4178
- 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, l = a === void 0 ? e.getComputedStyle !== void 0 : a, c = e.getComputedStyle, u = c === void 0 ? i.getComputedStyle.bind(i) : c, d = e.hidden, p = d === void 0 ? !1 : d;
4179
- function f(h, x) {
4180
- var T = "";
4181
- if (isElement(h) && l) {
4182
- var L = u(h, "::before"), A = getTextualContent(L);
4183
- T = "".concat(A, " ").concat(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);
4184
4486
  }
4185
- var v = isHTMLSlotElement(h) ? getSlotContents(h) : arrayFrom(h.childNodes).concat(queryIdRefs(h, "aria-owns"));
4186
- if (v.forEach(function(R) {
4187
- var N = E(R, {
4188
- isEmbeddedInLabel: x.isEmbeddedInLabel,
4487
+ 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,
4189
4491
  isReferenced: !1,
4190
4492
  recursion: !0
4191
- }), $ = isElement(R) ? u(R).getPropertyValue("display") : "inline", B = $ !== "inline" ? " " : "";
4192
- T += "".concat(B).concat(N).concat(B);
4193
- }), isElement(h) && l) {
4194
- var y = u(h, "::after"), M = getTextualContent(y);
4195
- T = "".concat(T, " ").concat(M);
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);
4196
4498
  }
4197
- return T.trim();
4499
+ return E.trim();
4198
4500
  }
4199
- function m(h, x) {
4200
- var T = h.getAttributeNode(x);
4201
- return T !== null && !n.has(T) && T.value.trim() !== "" ? (n.add(T), T.value) : null;
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;
4202
4504
  }
4203
- function g(h) {
4204
- return isElement(h) ? m(h, "title") : null;
4505
+ function y(f) {
4506
+ return isElement(f) ? g(f, "title") : null;
4205
4507
  }
4206
- function S(h) {
4207
- if (!isElement(h))
4508
+ function T(f) {
4509
+ if (!isElement(f))
4208
4510
  return null;
4209
- if (isHTMLFieldSetElement(h)) {
4210
- n.add(h);
4211
- for (var x = arrayFrom(h.childNodes), T = 0; T < x.length; T += 1) {
4212
- var L = x[T];
4213
- if (isHTMLLegendElement(L))
4214
- return E(L, {
4511
+ if (isHTMLFieldSetElement(f)) {
4512
+ 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, {
4215
4517
  isEmbeddedInLabel: !1,
4216
4518
  isReferenced: !1,
4217
4519
  recursion: !1
4218
4520
  });
4219
4521
  }
4220
- } else if (isHTMLTableElement(h)) {
4221
- n.add(h);
4222
- for (var A = arrayFrom(h.childNodes), v = 0; v < A.length; v += 1) {
4223
- var y = A[v];
4224
- if (isHTMLTableCaptionElement(y))
4225
- return E(y, {
4522
+ } else if (isHTMLTableElement(f)) {
4523
+ n.add(f);
4524
+ for (var L = arrayFrom(f.childNodes), S = 0; S < L.length; S += 1) {
4525
+ var A = L[S];
4526
+ if (isHTMLTableCaptionElement(A))
4527
+ return C(A, {
4226
4528
  isEmbeddedInLabel: !1,
4227
4529
  isReferenced: !1,
4228
4530
  recursion: !1
4229
4531
  });
4230
4532
  }
4231
- } else if (isSVGSVGElement(h)) {
4232
- n.add(h);
4233
- for (var M = arrayFrom(h.childNodes), R = 0; R < M.length; R += 1) {
4234
- var N = M[R];
4235
- if (isSVGTitleElement(N))
4236
- return N.textContent;
4533
+ } else if (isSVGSVGElement(f)) {
4534
+ 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;
4237
4539
  }
4238
4540
  return null;
4239
- } else if (getLocalName(h) === "img" || getLocalName(h) === "area") {
4240
- var $ = m(h, "alt");
4241
- if ($ !== null)
4242
- return $;
4243
- } else if (isHTMLOptGroupElement(h)) {
4244
- var B = m(h, "label");
4541
+ } else if (getLocalName(f) === "img" || getLocalName(f) === "area") {
4542
+ var F = g(f, "alt");
4543
+ if (F !== null)
4544
+ return F;
4545
+ } else if (isHTMLOptGroupElement(f)) {
4546
+ var B = g(f, "label");
4245
4547
  if (B !== null)
4246
4548
  return B;
4247
4549
  }
4248
- if (isHTMLInputElement(h) && (h.type === "button" || h.type === "submit" || h.type === "reset")) {
4249
- var K = m(h, "value");
4250
- if (K !== null)
4251
- return K;
4252
- if (h.type === "submit")
4550
+ if (isHTMLInputElement(f) && (f.type === "button" || f.type === "submit" || f.type === "reset")) {
4551
+ var J = g(f, "value");
4552
+ if (J !== null)
4553
+ return J;
4554
+ if (f.type === "submit")
4253
4555
  return "Submit";
4254
- if (h.type === "reset")
4556
+ if (f.type === "reset")
4255
4557
  return "Reset";
4256
4558
  }
4257
- var W = getLabels(h);
4258
- if (W !== null && W.length !== 0)
4259
- return n.add(h), arrayFrom(W).map(function(G) {
4260
- return E(G, {
4559
+ var G = getLabels(f);
4560
+ if (G !== null && G.length !== 0)
4561
+ return n.add(f), arrayFrom(G).map(function(W) {
4562
+ return C(W, {
4261
4563
  isEmbeddedInLabel: !0,
4262
4564
  isReferenced: !1,
4263
4565
  recursion: !0
4264
4566
  });
4265
- }).filter(function(G) {
4266
- return G.length > 0;
4567
+ }).filter(function(W) {
4568
+ return W.length > 0;
4267
4569
  }).join(" ");
4268
- if (isHTMLInputElement(h) && h.type === "image") {
4269
- var J = m(h, "alt");
4270
- if (J !== null)
4271
- return J;
4272
- var ee = m(h, "title");
4570
+ if (isHTMLInputElement(f) && f.type === "image") {
4571
+ var Q = g(f, "alt");
4572
+ if (Q !== null)
4573
+ return Q;
4574
+ var ee = g(f, "title");
4273
4575
  return ee !== null ? ee : "Submit Query";
4274
4576
  }
4275
- if (hasAnyConcreteRoles(h, ["button"])) {
4276
- var te = f(h, {
4577
+ if (hasAnyConcreteRoles(f, ["button"])) {
4578
+ var te = h(f, {
4277
4579
  isEmbeddedInLabel: !1
4278
4580
  });
4279
4581
  if (te !== "")
@@ -4281,16 +4583,16 @@ function computeTextAlternative(t) {
4281
4583
  }
4282
4584
  return null;
4283
4585
  }
4284
- function E(h, x) {
4285
- if (n.has(h))
4586
+ function C(f, m) {
4587
+ if (n.has(f))
4286
4588
  return "";
4287
- if (!p && isHidden(h, u) && !x.isReferenced)
4288
- return n.add(h), "";
4289
- var T = isElement(h) ? h.getAttributeNode("aria-labelledby") : null, L = T !== null && !n.has(T) ? queryIdRefs(h, "aria-labelledby") : [];
4290
- if (o === "name" && !x.isReferenced && L.length > 0)
4291
- return n.add(T), L.map(function($) {
4292
- return E($, {
4293
- isEmbeddedInLabel: x.isEmbeddedInLabel,
4589
+ if (!p && isHidden(f, d) && !m.isReferenced)
4590
+ 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,
4294
4596
  isReferenced: !0,
4295
4597
  // this isn't recursion as specified, otherwise we would skip
4296
4598
  // `aria-label` in
@@ -4298,53 +4600,53 @@ function computeTextAlternative(t) {
4298
4600
  recursion: !1
4299
4601
  });
4300
4602
  }).join(" ");
4301
- var A = x.recursion && isControl(h) && o === "name";
4302
- if (!A) {
4303
- var v = (isElement(h) && h.getAttribute("aria-label") || "").trim();
4304
- if (v !== "" && o === "name")
4305
- return n.add(h), v;
4306
- if (!isMarkedPresentational(h)) {
4307
- var y = S(h);
4308
- if (y !== null)
4309
- return n.add(h), y;
4603
+ var L = m.recursion && isControl(f) && o === "name";
4604
+ if (!L) {
4605
+ var S = (isElement(f) && f.getAttribute("aria-label") || "").trim();
4606
+ if (S !== "" && o === "name")
4607
+ return n.add(f), S;
4608
+ if (!isMarkedPresentational(f)) {
4609
+ var A = T(f);
4610
+ if (A !== null)
4611
+ return n.add(f), A;
4310
4612
  }
4311
4613
  }
4312
- if (hasAnyConcreteRoles(h, ["menu"]))
4313
- return n.add(h), "";
4314
- if (A || x.isEmbeddedInLabel || x.isReferenced) {
4315
- if (hasAnyConcreteRoles(h, ["combobox", "listbox"])) {
4316
- n.add(h);
4317
- var M = querySelectedOptions(h);
4318
- return M.length === 0 ? isHTMLInputElement(h) ? h.value : "" : arrayFrom(M).map(function($) {
4319
- return E($, {
4320
- isEmbeddedInLabel: x.isEmbeddedInLabel,
4614
+ if (hasAnyConcreteRoles(f, ["menu"]))
4615
+ return n.add(f), "";
4616
+ if (L || m.isEmbeddedInLabel || m.isReferenced) {
4617
+ if (hasAnyConcreteRoles(f, ["combobox", "listbox"])) {
4618
+ 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,
4321
4623
  isReferenced: !1,
4322
4624
  recursion: !0
4323
4625
  });
4324
4626
  }).join(" ");
4325
4627
  }
4326
- if (hasAbstractRole(h, "range"))
4327
- return n.add(h), h.hasAttribute("aria-valuetext") ? h.getAttribute("aria-valuetext") : h.hasAttribute("aria-valuenow") ? h.getAttribute("aria-valuenow") : h.getAttribute("value") || "";
4328
- if (hasAnyConcreteRoles(h, ["textbox"]))
4329
- return n.add(h), getValueOfTextbox(h);
4628
+ if (hasAbstractRole(f, "range"))
4629
+ return n.add(f), f.hasAttribute("aria-valuetext") ? f.getAttribute("aria-valuetext") : f.hasAttribute("aria-valuenow") ? f.getAttribute("aria-valuenow") : f.getAttribute("value") || "";
4630
+ if (hasAnyConcreteRoles(f, ["textbox"]))
4631
+ return n.add(f), getValueOfTextbox(f);
4330
4632
  }
4331
- if (allowsNameFromContent(h) || isElement(h) && x.isReferenced || isNativeHostLanguageTextAlternativeElement(h) || isDescendantOfNativeHostLanguageTextAlternativeElement()) {
4332
- var R = f(h, {
4333
- isEmbeddedInLabel: x.isEmbeddedInLabel
4633
+ if (allowsNameFromContent(f) || isElement(f) && m.isReferenced || isNativeHostLanguageTextAlternativeElement(f) || isDescendantOfNativeHostLanguageTextAlternativeElement()) {
4634
+ var M = h(f, {
4635
+ isEmbeddedInLabel: m.isEmbeddedInLabel
4334
4636
  });
4335
- if (R !== "")
4336
- return n.add(h), R;
4637
+ if (M !== "")
4638
+ return n.add(f), M;
4337
4639
  }
4338
- if (h.nodeType === h.TEXT_NODE)
4339
- return n.add(h), h.textContent || "";
4340
- if (x.recursion)
4341
- return n.add(h), f(h, {
4342
- isEmbeddedInLabel: x.isEmbeddedInLabel
4640
+ if (f.nodeType === f.TEXT_NODE)
4641
+ return n.add(f), f.textContent || "";
4642
+ if (m.recursion)
4643
+ return n.add(f), h(f, {
4644
+ isEmbeddedInLabel: m.isEmbeddedInLabel
4343
4645
  });
4344
- var N = g(h);
4345
- return N !== null ? (n.add(h), N) : (n.add(h), "");
4646
+ var O = y(f);
4647
+ return O !== null ? (n.add(f), O) : (n.add(f), "");
4346
4648
  }
4347
- return asFlatString(E(t, {
4649
+ return asFlatString(C(t, {
4348
4650
  isEmbeddedInLabel: !1,
4349
4651
  // by spec computeAccessibleDescription starts with the referenced elements as roots
4350
4652
  isReferenced: o === "description",
@@ -4358,42 +4660,88 @@ function computeAccessibleName(t) {
4358
4660
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
4359
4661
  return prohibitsNaming(t) ? "" : computeTextAlternative(t, e);
4360
4662
  }
4361
- function buildVNode(t, e, n, i, r, o, a, l, c = !1) {
4362
- if (isHidden$1(t) || i.has(t)) return null;
4363
- const u = inferRole(t), d = getStateTokens(t, o, a, l);
4364
- let p = computeAccessibleName(t);
4365
- const f = isTabbable(t), m = d.includes("cursor=pointer"), g = r.has(t) || (o?.some((v) => t.hasAttribute(v)) ?? !1), S = t.tagName.toLowerCase() === "label" && t.hasAttribute("for");
4366
- if (!p.trim()) {
4367
- const v = t.tagName.toLowerCase();
4368
- if (!(v === "select" || u === "combobox" || u === "listbox")) {
4369
- const M = ["button", "a", "input", "textarea", "li", "label"].includes(v);
4370
- (f || g || m || M || u === "listitem" || u === "option") && (p = collectDescendantText(t));
4663
+ const INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
4664
+ "button",
4665
+ "link",
4666
+ "textbox",
4667
+ "searchbox",
4668
+ "combobox",
4669
+ "listbox",
4670
+ "checkbox",
4671
+ "radio",
4672
+ "switch",
4673
+ "slider",
4674
+ "spinbutton",
4675
+ "menuitem",
4676
+ "menuitemcheckbox",
4677
+ "menuitemradio",
4678
+ "tab",
4679
+ "treeitem"
4680
+ ]);
4681
+ function buildVNode(t, e, n, i, r, o, a = /* @__PURE__ */ new Set()) {
4682
+ 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));
4371
4691
  }
4372
4692
  }
4373
- if (!p.trim() && !(getComposedChildren(t).length > 0)) {
4374
- const y = collectDescendantText(t);
4375
- y && (p = y);
4376
- }
4377
- const E = t.tagName.toLowerCase(), h = E === "a" && t.hasAttribute("href") || ["button", "input", "select", "textarea"].includes(E) && !t.hasAttribute("disabled"), T = f && !(u === "generic" && !m) || g || S || h || !c && m && (u !== "generic" || p !== "");
4378
- let L;
4379
- T && (L = e.value, n.set(L, t), e.value++);
4380
- const A = [];
4381
- for (const v of getComposedChildren(t)) {
4382
- const y = buildVNode(
4383
- v,
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);
4696
+ }
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 态手势,
4698
+ // 无需再要求 role≠generic 或 name≠''——否则无文本的图标按钮(tp-icon.common-icon 等)
4699
+ // 虽是真正的可点击边界,仍会因 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,
4384
4707
  e,
4385
4708
  n,
4386
4709
  i,
4387
4710
  r,
4388
4711
  o,
4389
- a,
4390
- l,
4391
- // 将当前节点的交互性向下传递,子节点据此决定是否抑制 cursor=pointer
4392
- T || c
4712
+ a
4393
4713
  );
4394
- y && A.push(y);
4714
+ N && L.push(N);
4715
+ }
4716
+ const S = { role: s, name: d, tokens: c, ref: v, el: t, children: L };
4717
+ return hasInteractiveDescendant(S) && (S.name = getOwnDeclaredName(t)), S;
4718
+ }
4719
+ function getOwnDeclaredName(t) {
4720
+ return t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby") ? computeAccessibleName(t).trim() : "";
4721
+ }
4722
+ function isStaticBranch(t) {
4723
+ return t.ref === void 0 && !hasInteractiveDescendant(t);
4724
+ }
4725
+ function collectVisiblePlainText(t) {
4726
+ return collectDescendantText(t).replace(/\s+/g, " ").trim();
4727
+ }
4728
+ function getStaticDisplayText(t) {
4729
+ 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
+ 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);
4395
4733
  }
4396
- return { role: u, name: p, tokens: d, ref: L, el: t, children: A };
4734
+ return r.length === 0 && n && !isNoiseAccessibleName(n) && r.push(n), r.join(" ").replace(/\s+/g, " ").trim();
4735
+ }
4736
+ function isNoiseAccessibleName(t) {
4737
+ const e = t.trim();
4738
+ return e ? !!(/@font-face\b/i.test(e) || /data:(?:font|application|image)\//i.test(e) || /base64,[A-Za-z0-9+/=]{80,}/.test(e)) : !1;
4739
+ }
4740
+ function canOmitStaticChild(t, e, n) {
4741
+ const i = getStaticDisplayText(t);
4742
+ if (!i || !e.trim()) return !1;
4743
+ const r = e.replace(/\s+/g, " ").trim(), o = i.replace(/\s+/g, " ").trim();
4744
+ return n ? o === r : r.includes(o);
4397
4745
  }
4398
4746
  function hasValue(t) {
4399
4747
  return t.ref !== void 0 || t.name.trim() !== "" ? !0 : t.children.some(hasValue);
@@ -4410,23 +4758,35 @@ function findSingleRefDescendant(t) {
4410
4758
  function shouldPassThrough(t, e) {
4411
4759
  return !(!e.pruneUnnamed || e.preserveRoles.includes(t.role) || t.ref !== void 0 || t.name.trim() !== "");
4412
4760
  }
4761
+ function formatNameAttr(t) {
4762
+ const e = t.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"').trim();
4763
+ return e ? ` "${e}"` : "";
4764
+ }
4413
4765
  function serializeVNode(t, e, n) {
4414
- if (shouldPassThrough(t, n))
4415
- return t.children.filter((p) => hasValue(p)).flatMap((p) => serializeVNode(p, e, n));
4416
- const i = " ".repeat(e), r = t.ref !== void 0 ? ` #${t.ref}` : "", o = t.tokens.map((p) => p.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"')), a = o.length > 0 ? ` [${o.join(" ")}]` : "";
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(" ")}]` : "";
4767
+ if (!i && !r) {
4768
+ 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)}`];
4772
+ }
4773
+ 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];
4776
+ }
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));
4417
4781
  if (t.ref !== void 0) {
4418
- if (!hasInteractiveDescendant(t)) {
4419
- const f = t.name ? t.name.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"') : "", m = f ? ` "${f}"` : "";
4420
- return [`${i}- ${t.role}${r}${a}${m}`];
4421
- }
4422
- const p = findSingleRefDescendant(t);
4423
- if (p && p.role === "generic" && !hasInteractiveDescendant(p)) {
4424
- const f = (t.name.trim() || p.name.trim()).replace(/[\r\n]+/g, " ").replace(/"/g, '\\"'), m = f ? ` "${f}"` : "";
4425
- return [`${i}- ${t.role}${r}${a}${m}`];
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)}`];
4426
4786
  }
4427
4787
  }
4428
- const l = t.name ? t.name.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"') : "", c = l ? ` "${l}"` : "", u = `${i}- ${t.role}${r}${a}${c}`, d = t.children.flatMap((p) => serializeVNode(p, e + 1, n));
4429
- return [u, ...d];
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];
4430
4790
  }
4431
4791
  const HIGHLIGHT_CONTAINER_ID = "webmcpcli-highlight-container", HIGHLIGHT_CONTAINER_STYLE_ID = "webmcpcli-highlight-container-style", colors = [
4432
4792
  "#FF0000",
@@ -4468,10 +4828,34 @@ const HIGHLIGHT_CONTAINER_ID = "webmcpcli-highlight-container", HIGHLIGHT_CONTAI
4468
4828
  padding: 0 2px;
4469
4829
  border-radius: 4px;
4470
4830
  }
4471
- `;
4472
- function isElementViewport(t) {
4831
+ `, MAX_ICON_FALLBACK_SIZE = 48;
4832
+ function resolveHighlightRect(t) {
4473
4833
  const e = t.getBoundingClientRect();
4474
- return e.top >= 0 && e.left >= 0 && e.bottom <= (window.innerHeight || document.documentElement.clientHeight) && e.right <= (window.innerWidth || document.documentElement.clientWidth);
4834
+ if (e.width > 0 && e.height > 0)
4835
+ return { top: e.top, left: e.left, width: e.width, height: e.height };
4836
+ let n = t.parentElement;
4837
+ for (let i = 0; i < 3 && n; i++) {
4838
+ const r = n.getBoundingClientRect();
4839
+ if (r.width > 0 && r.height > 0 && r.width <= MAX_ICON_FALLBACK_SIZE && r.height <= MAX_ICON_FALLBACK_SIZE)
4840
+ return { top: r.top, left: r.left, width: r.width, height: r.height };
4841
+ n = n.parentElement;
4842
+ }
4843
+ if (e.width > 0 || e.height > 0)
4844
+ try {
4845
+ const i = parseFloat(getComputedStyle(t).fontSize) || 16, r = e.width > 0 ? e.width : i, o = e.height > 0 ? e.height : i;
4846
+ return {
4847
+ top: e.height > 0 ? e.top : e.top - (o - e.height) / 2,
4848
+ left: e.width > 0 ? e.left : e.left - (r - e.width) / 2,
4849
+ width: r,
4850
+ height: o
4851
+ };
4852
+ } catch {
4853
+ }
4854
+ return null;
4855
+ }
4856
+ function isRectInViewport(t) {
4857
+ const e = window.innerHeight || document.documentElement.clientHeight, n = window.innerWidth || document.documentElement.clientWidth;
4858
+ return t.top < e && t.top + t.height > 0 && t.left < n && t.left + t.width > 0;
4475
4859
  }
4476
4860
  const doHighlight = (t, e = null) => {
4477
4861
  if (!document.head.querySelector(`#${HIGHLIGHT_CONTAINER_STYLE_ID}`)) {
@@ -4487,25 +4871,24 @@ const doHighlight = (t, e = null) => {
4487
4871
  }
4488
4872
  const r = document.createDocumentFragment();
4489
4873
  for (const [o, a] of t.entries()) {
4490
- if (!isElementViewport(a)) continue;
4491
- const c = colors[o % colors.length] + opacity, u = a.getBoundingClientRect();
4492
- if (u.width === 0 || u.height === 0) continue;
4493
- const d = document.createElement("div");
4494
- d.style.border = `2px solid ${c}`;
4495
- const p = u.top + i.y, f = u.left + i.x;
4496
- d.style.top = `${p}px`, d.style.left = `${f}px`, d.style.width = `${u.width}px`, d.style.height = `${u.height}px`;
4497
- const m = document.createElement("span");
4498
- m.style.backgroundColor = c, m.style.height = `${u.height - 4}px`, m.style.lineHeight = `${u.height - 4}px`, m.textContent = o.toString(), d.appendChild(m), r.appendChild(d);
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 };
4877
+ 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);
4499
4882
  }
4500
4883
  n.appendChild(r);
4501
4884
  }, highlight = (t, e = null) => {
4502
4885
  doHighlight(t, e);
4503
- const r = ((l, c) => {
4504
- let u = 0;
4505
- return (...d) => {
4886
+ const r = ((s, c) => {
4887
+ let d = 0;
4888
+ return (...u) => {
4506
4889
  const p = performance.now();
4507
- if (!(p - u < c))
4508
- return u = p, l(...d);
4890
+ if (!(p - d < c))
4891
+ return d = p, s(...u);
4509
4892
  };
4510
4893
  })(() => doHighlight(t, e), 16);
4511
4894
  window.addEventListener("scroll", r, !0), window.addEventListener("resize", r);
@@ -4539,87 +4922,84 @@ const doHighlight = (t, e = null) => {
4539
4922
  window.location.href !== e && (e = window.location.href, unhighlight());
4540
4923
  }, 500);
4541
4924
  }
4542
- }, DEFAULT_OPTIONS = {
4543
- pruneUnnamed: !0,
4544
- preserveRoles: [],
4545
- exposedAttributes: [],
4546
- errorSelectors: DEFAULT_ERROR_SELECTORS$1,
4547
- warningSelectors: DEFAULT_WARNING_SELECTORS
4548
4925
  };
4549
- function buildA11yTree(t = document.body, e = [], n = [], i) {
4550
- const r = { ...DEFAULT_OPTIONS, ...i }, o = { value: 0 }, a = /* @__PURE__ */ new Map(), l = new Set(e), c = new Set(n), u = [];
4551
- l.add(document.getElementById(HIGHLIGHT_CONTAINER_ID));
4552
- for (const p of getComposedChildren(t)) {
4553
- const f = buildVNode(
4554
- p,
4555
- o,
4556
- a,
4557
- l,
4558
- c,
4559
- r.exposedAttributes,
4560
- r.errorSelectors,
4561
- r.warningSelectors
4562
- );
4563
- f && u.push(...serializeVNode(f, 0, r));
4926
+ function resolveElementList(t, e) {
4927
+ const n = /* @__PURE__ */ new Set();
4928
+ for (const i of t)
4929
+ if (typeof i == "string")
4930
+ try {
4931
+ for (const r of deepQuerySelectorAll(i, e)) n.add(r);
4932
+ } catch {
4933
+ }
4934
+ else i && n.add(i);
4935
+ return n;
4936
+ }
4937
+ 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));
4564
4944
  }
4565
4945
  return {
4566
- yaml: "```yaml\n" + u.join(`
4946
+ yaml: "```yaml\n" + p.join(`
4567
4947
  `) + "\n```",
4568
- refMap: a,
4569
- interactiveCount: a.size,
4570
- lines: u
4948
+ refMap: c,
4949
+ interactiveCount: c.size,
4950
+ lines: p
4571
4951
  };
4572
4952
  }
4573
- function searchA11yTree(t, e = document.body, n = [], i = [], r) {
4953
+ function searchA11yTree(t, e = document.body, n) {
4574
4954
  const {
4575
- contextLines: o = 2,
4576
- caseInsensitive: a = !0,
4577
- maxMatches: l = 20,
4578
- ...c
4579
- } = r ?? {}, u = Math.max(0, o), d = Math.max(1, l), { lines: p, refMap: f, yaml: m } = buildA11yTree(e, n, i, c), g = a ? t.toLowerCase() : t, S = p.length, h = /^#\d+$/.test(t) ? new RegExp(`\\s${t}(?:\\s|[\\[]|$)`) : null, x = [];
4580
- for (let y = 0; y < p.length; y++) {
4581
- let M = !1;
4582
- h ? M = h.test(p[y]) : M = (a ? p[y].toLowerCase() : p[y]).includes(g), M && x.push(y);
4583
- }
4584
- const T = [];
4585
- let L = !1;
4586
- for (const y of x) {
4587
- const M = Math.max(0, y - u), R = Math.min(S - 1, y + u), N = T[T.length - 1];
4588
- if (N && M <= N.end + 1)
4589
- N.end = Math.max(N.end, R), N.hits.push(y);
4955
+ contextLines: i = 2,
4956
+ caseInsensitive: r = !0,
4957
+ 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++) {
4961
+ let S = !1;
4962
+ T ? S = T.test(d[L]) : S = (r ? d[L].toLowerCase() : d[L]).includes(h), S && C.push(L);
4963
+ }
4964
+ 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);
4590
4970
  else {
4591
- if (T.length >= d) {
4592
- L = !0;
4971
+ if (f.length >= c) {
4972
+ m = !0;
4593
4973
  break;
4594
4974
  }
4595
- T.push({ start: M, end: R, hits: [y] });
4975
+ f.push({ start: S, end: A, hits: [L] });
4596
4976
  }
4597
4977
  }
4598
- const A = T.map((y) => ({
4599
- lineNumber: y.hits[0] + 1,
4600
- line: p[y.hits[0]],
4601
- context: Array.from({ length: y.end - y.start + 1 }, (M, R) => ({
4602
- lineNumber: y.start + R + 1,
4603
- line: p[y.start + R]
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]
4604
4984
  }))
4605
4985
  })), v = [
4606
- `无障碍树搜索结果 — 关键词: "${t}" | 总行数: ${S} | 命中: ${x.length} 行 | 返回分组: ${A.length}`,
4986
+ `无障碍树搜索结果 — 关键词: "${t}" | 总行数: ${g} | 命中: ${C.length} 行 | 返回分组: ${E.length}`,
4607
4987
  ""
4608
4988
  ];
4609
- return A.length === 0 ? v.push("(未找到匹配项)") : (A.forEach((y, M) => {
4610
- const R = T[M];
4611
- v.push(`── 分组 ${M + 1}(第 ${R.start + 1}–${R.end + 1} 行)──`), y.context.forEach(({ lineNumber: N, line: $ }) => {
4612
- const B = R.hits.includes(N - 1), K = String(N).padStart(4);
4613
- v.push(B ? `>>>${K} | ${$}` : ` ${K} | ${$}`);
4989
+ return E.length === 0 ? v.push("(未找到匹配项)") : (E.forEach((L, S) => {
4990
+ 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}`);
4614
4994
  }), v.push("");
4615
- }), L && v.push(`⚠️ 命中过多,已截断至前 ${d} 个分组,建议缩小搜索范围`), v.push("提示:如需操作命中元素,使用其 #N 索引;如需查看完整树,请使用 browserState。")), {
4995
+ }), m && v.push(`⚠️ 命中过多,已截断至前 ${c} 个分组,建议缩小搜索范围`), v.push("提示:如需操作命中元素,使用其 #N 索引;如需查看完整树,请使用 browserState。")), {
4616
4996
  text: v.join(`
4617
4997
  `),
4618
- matches: A,
4619
- totalLines: S,
4620
- matchCount: x.length,
4621
- refMap: f,
4622
- yaml: m
4998
+ matches: E,
4999
+ totalLines: g,
5000
+ matchCount: C.length,
5001
+ refMap: u,
5002
+ yaml: p
4623
5003
  };
4624
5004
  }
4625
5005
  function Diff() {
@@ -4629,54 +5009,54 @@ Diff.prototype = {
4629
5009
  var i, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, o = r.callback;
4630
5010
  typeof r == "function" && (o = r, r = {});
4631
5011
  var a = this;
4632
- function l(L) {
4633
- return L = a.postProcess(L, r), o ? (setTimeout(function() {
4634
- o(L);
4635
- }, 0), !0) : L;
5012
+ function s(v) {
5013
+ return v = a.postProcess(v, r), o ? (setTimeout(function() {
5014
+ o(v);
5015
+ }, 0), !0) : v;
4636
5016
  }
4637
5017
  e = this.castInput(e, r), n = this.castInput(n, r), e = this.removeEmpty(this.tokenize(e, r)), n = this.removeEmpty(this.tokenize(n, r));
4638
- var c = n.length, u = e.length, d = 1, p = c + u;
5018
+ var c = n.length, d = e.length, u = 1, p = c + d;
4639
5019
  r.maxEditLength != null && (p = Math.min(p, r.maxEditLength));
4640
- var f = (i = r.timeout) !== null && i !== void 0 ? i : 1 / 0, m = Date.now() + f, g = [{
5020
+ var h = (i = r.timeout) !== null && i !== void 0 ? i : 1 / 0, g = Date.now() + h, y = [{
4641
5021
  oldPos: -1,
4642
5022
  lastComponent: void 0
4643
- }], S = this.extractCommon(g[0], n, e, 0, r);
4644
- if (g[0].oldPos + 1 >= u && S + 1 >= c)
4645
- return l(buildValues(a, g[0].lastComponent, n, e, a.useLongestToken));
4646
- var E = -1 / 0, h = 1 / 0;
4647
- function x() {
4648
- for (var L = Math.max(E, -d); L <= Math.min(h, d); L += 2) {
4649
- var A = void 0, v = g[L - 1], y = g[L + 1];
4650
- v && (g[L - 1] = void 0);
4651
- var M = !1;
4652
- if (y) {
4653
- var R = y.oldPos - L;
4654
- M = y && 0 <= R && R < c;
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;
5032
+ if (A) {
5033
+ var M = A.oldPos - v;
5034
+ N = A && 0 <= M && M < c;
4655
5035
  }
4656
- var N = v && v.oldPos + 1 < u;
4657
- if (!M && !N) {
4658
- g[L] = void 0;
5036
+ var O = S && S.oldPos + 1 < d;
5037
+ if (!N && !O) {
5038
+ y[v] = void 0;
4659
5039
  continue;
4660
5040
  }
4661
- if (!N || M && v.oldPos < y.oldPos ? A = a.addToPath(y, !0, !1, 0, r) : A = a.addToPath(v, !1, !0, 1, r), S = a.extractCommon(A, n, e, L, r), A.oldPos + 1 >= u && S + 1 >= c)
4662
- return l(buildValues(a, A.lastComponent, n, e, a.useLongestToken));
4663
- g[L] = A, A.oldPos + 1 >= u && (h = Math.min(h, L - 1)), S + 1 >= c && (E = Math.max(E, L + 1));
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));
4664
5044
  }
4665
- d++;
5045
+ u++;
4666
5046
  }
4667
5047
  if (o)
4668
- (function L() {
5048
+ (function v() {
4669
5049
  setTimeout(function() {
4670
- if (d > p || Date.now() > m)
5050
+ if (u > p || Date.now() > g)
4671
5051
  return o();
4672
- x() || L();
5052
+ m() || v();
4673
5053
  }, 0);
4674
5054
  })();
4675
5055
  else
4676
- for (; d <= p && Date.now() <= m; ) {
4677
- var T = x();
4678
- if (T)
4679
- return T;
5056
+ for (; u <= p && Date.now() <= g; ) {
5057
+ var E = m();
5058
+ if (E)
5059
+ return E;
4680
5060
  }
4681
5061
  },
4682
5062
  addToPath: function t(e, n, i, r, o) {
@@ -4700,19 +5080,19 @@ Diff.prototype = {
4700
5080
  };
4701
5081
  },
4702
5082
  extractCommon: function t(e, n, i, r, o) {
4703
- for (var a = n.length, l = i.length, c = e.oldPos, u = c - r, d = 0; u + 1 < a && c + 1 < l && this.equals(i[c + 1], n[u + 1], o); )
4704
- u++, c++, d++, o.oneChangePerToken && (e.lastComponent = {
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); )
5084
+ d++, c++, u++, o.oneChangePerToken && (e.lastComponent = {
4705
5085
  count: 1,
4706
5086
  previousComponent: e.lastComponent,
4707
5087
  added: !1,
4708
5088
  removed: !1
4709
5089
  });
4710
- return d && !o.oneChangePerToken && (e.lastComponent = {
4711
- count: d,
5090
+ return u && !o.oneChangePerToken && (e.lastComponent = {
5091
+ count: u,
4712
5092
  previousComponent: e.lastComponent,
4713
5093
  added: !1,
4714
5094
  removed: !1
4715
- }), e.oldPos = c, u;
5095
+ }), e.oldPos = c, d;
4716
5096
  },
4717
5097
  equals: function t(e, n, i) {
4718
5098
  return i.comparator ? i.comparator(e, n) : e === n || i.ignoreCase && e.toLowerCase() === n.toLowerCase();
@@ -4739,20 +5119,20 @@ function buildValues(t, e, n, i, r) {
4739
5119
  for (var o = [], a; e; )
4740
5120
  o.push(e), a = e.previousComponent, delete e.previousComponent, e = a;
4741
5121
  o.reverse();
4742
- for (var l = 0, c = o.length, u = 0, d = 0; l < c; l++) {
4743
- var p = o[l];
5122
+ for (var s = 0, c = o.length, d = 0, u = 0; s < c; s++) {
5123
+ var p = o[s];
4744
5124
  if (p.removed)
4745
- p.value = t.join(i.slice(d, d + p.count)), d += p.count;
5125
+ p.value = t.join(i.slice(u, u + p.count)), u += p.count;
4746
5126
  else {
4747
5127
  if (!p.added && r) {
4748
- var f = n.slice(u, u + p.count);
4749
- f = f.map(function(m, g) {
4750
- var S = i[d + g];
4751
- return S.length > m.length ? S : m;
4752
- }), p.value = t.join(f);
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);
4753
5133
  } else
4754
- p.value = t.join(n.slice(u, u + p.count));
4755
- u += p.count, p.added || (d += p.count);
5134
+ p.value = t.join(n.slice(d, d + p.count));
5135
+ d += p.count, p.added || (u += p.count);
4756
5136
  }
4757
5137
  }
4758
5138
  return o;
@@ -4807,10 +5187,10 @@ function overlapCount(t, e) {
4807
5187
  e[a] == e[o] && o++;
4808
5188
  }
4809
5189
  o = 0;
4810
- for (var l = n; l < t.length; l++) {
4811
- for (; o > 0 && t[l] != e[o]; )
5190
+ for (var s = n; s < t.length; s++) {
5191
+ for (; o > 0 && t[s] != e[o]; )
4812
5192
  o = r[o];
4813
- t[l] == e[o] && o++;
5193
+ t[s] == e[o] && o++;
4814
5194
  }
4815
5195
  return o;
4816
5196
  }
@@ -4848,28 +5228,28 @@ wordDiff.postProcess = function(t, e) {
4848
5228
  };
4849
5229
  function dedupeWhitespaceInChangeObjects(t, e, n, i) {
4850
5230
  if (e && n) {
4851
- var r = e.value.match(/^\s*/)[0], o = e.value.match(/\s*$/)[0], a = n.value.match(/^\s*/)[0], l = n.value.match(/\s*$/)[0];
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];
4852
5232
  if (t) {
4853
5233
  var c = longestCommonPrefix(r, a);
4854
5234
  t.value = replaceSuffix(t.value, a, c), e.value = removePrefix(e.value, c), n.value = removePrefix(n.value, c);
4855
5235
  }
4856
5236
  if (i) {
4857
- var u = longestCommonSuffix(o, l);
4858
- i.value = replacePrefix(i.value, l, u), e.value = removeSuffix(e.value, u), n.value = removeSuffix(n.value, u);
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);
4859
5239
  }
4860
5240
  } else if (n)
4861
5241
  t && (n.value = n.value.replace(/^\s*/, "")), i && (i.value = i.value.replace(/^\s*/, ""));
4862
5242
  else if (t && i) {
4863
- var d = i.value.match(/^\s*/)[0], p = e.value.match(/^\s*/)[0], f = e.value.match(/\s*$/)[0], m = longestCommonPrefix(d, p);
4864
- e.value = removePrefix(e.value, m);
4865
- var g = longestCommonSuffix(removePrefix(d, m), f);
4866
- e.value = removeSuffix(e.value, g), i.value = replacePrefix(i.value, d, g), t.value = replaceSuffix(t.value, d, d.slice(0, d.length - g.length));
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));
4867
5247
  } else if (i) {
4868
- var S = i.value.match(/^\s*/)[0], E = e.value.match(/\s*$/)[0], h = maximumOverlap(E, S);
4869
- e.value = removeSuffix(e.value, h);
5248
+ var T = i.value.match(/^\s*/)[0], C = e.value.match(/\s*$/)[0], f = maximumOverlap(C, T);
5249
+ e.value = removeSuffix(e.value, f);
4870
5250
  } else if (t) {
4871
- var x = t.value.match(/\s*$/)[0], T = e.value.match(/^\s*/)[0], L = maximumOverlap(x, T);
4872
- e.value = removePrefix(e.value, L);
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);
4873
5253
  }
4874
5254
  }
4875
5255
  var wordWithSpaceDiff = new Diff();
@@ -4941,11 +5321,11 @@ function canonicalize(t, e, n, i, r) {
4941
5321
  }
4942
5322
  if (t && t.toJSON && (t = t.toJSON()), _typeof(t) === "object" && t !== null) {
4943
5323
  e.push(t), a = {}, n.push(a);
4944
- var l = [], c;
5324
+ var s = [], c;
4945
5325
  for (c in t)
4946
- Object.prototype.hasOwnProperty.call(t, c) && l.push(c);
4947
- for (l.sort(), o = 0; o < l.length; o += 1)
4948
- c = l[o], a[c] = canonicalize(t[c], e, n, i, c);
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);
4949
5329
  e.pop(), n.pop();
4950
5330
  } else
4951
5331
  a = t;
@@ -4973,18 +5353,18 @@ class PageStateCache {
4973
5353
  */
4974
5354
  update(e, n) {
4975
5355
  const i = this.isFullRefresh(e), r = this.prev?.url ?? "";
4976
- let o = 0, a = 0, l = "";
5356
+ let o = 0, a = 0, s = "";
4977
5357
  if (!i && this.prev) {
4978
- const c = diffLines(this.prev.yaml, n), u = [];
4979
- c.forEach((d) => {
4980
- if (!d.added && !d.removed) return;
4981
- const p = d.value.split(`
5358
+ const c = diffLines(this.prev.yaml, n), d = [];
5359
+ c.forEach((u) => {
5360
+ if (!u.added && !u.removed) return;
5361
+ const p = u.value.split(`
4982
5362
  `).filter(Boolean);
4983
- d.added ? (o += p.length, p.forEach((f) => u.push(`+ ${f}`))) : (a += p.length, p.forEach((f) => u.push(`- ${f}`)));
4984
- }), l = u.join(`
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(`
4985
5365
  `);
4986
5366
  }
4987
- return this.prev = { url: e, yaml: n }, { isFullRefresh: i, prevUrl: r, addedLines: o, removedLines: a, diffText: l };
5367
+ return this.prev = { url: e, yaml: n }, { isFullRefresh: i, prevUrl: r, addedLines: o, removedLines: a, diffText: s };
4988
5368
  }
4989
5369
  /** 强制清空缓存(页面刷新 / 手动重置场景) */
4990
5370
  invalidate() {
@@ -4992,114 +5372,114 @@ class PageStateCache {
4992
5372
  }
4993
5373
  }
4994
5374
  function computeBorderGeometry(t, e, n, i) {
4995
- const r = Math.max(1, Math.min(t, e)), o = Math.min(n, 20), l = Math.min(o + i, r), c = Math.min(l, Math.floor(t / 2)), u = Math.min(l, Math.floor(e / 2)), d = (b) => b / t * 2 - 1, p = (b) => b / e * 2 - 1, f = 0, m = t, g = 0, S = e, E = c, h = t - c, x = u, T = e - u, L = d(f), A = d(m), v = p(g), y = p(S), M = d(E), R = d(h), N = p(x), $ = p(T), B = 0, K = 0, W = 1, J = 1, ee = c / t, te = 1 - c / t, G = u / e, V = 1 - u / e, ce = new Float32Array([
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([
4996
5376
  // Top strip
5377
+ v,
5378
+ S,
4997
5379
  L,
5380
+ S,
4998
5381
  v,
4999
- A,
5382
+ O,
5000
5383
  v,
5384
+ O,
5001
5385
  L,
5002
- N,
5386
+ S,
5003
5387
  L,
5004
- N,
5005
- A,
5006
- v,
5007
- A,
5008
- N,
5388
+ O,
5009
5389
  // Bottom strip
5390
+ v,
5391
+ F,
5010
5392
  L,
5011
- $,
5393
+ F,
5394
+ v,
5395
+ A,
5396
+ v,
5012
5397
  A,
5013
- $,
5014
5398
  L,
5015
- y,
5399
+ F,
5016
5400
  L,
5017
- y,
5018
- A,
5019
- $,
5020
5401
  A,
5021
- y,
5022
5402
  // Left strip
5023
- L,
5403
+ v,
5404
+ O,
5024
5405
  N,
5025
- M,
5406
+ O,
5407
+ v,
5408
+ F,
5409
+ v,
5410
+ F,
5026
5411
  N,
5412
+ O,
5413
+ N,
5414
+ F,
5415
+ // Right strip
5416
+ M,
5417
+ O,
5027
5418
  L,
5028
- $,
5029
- L,
5030
- $,
5419
+ O,
5031
5420
  M,
5032
- N,
5421
+ F,
5033
5422
  M,
5034
- $,
5035
- // Right strip
5036
- R,
5037
- N,
5038
- A,
5039
- N,
5040
- R,
5041
- $,
5042
- R,
5043
- $,
5044
- A,
5045
- N,
5046
- A,
5047
- $
5048
- ]), s = new Float32Array([
5423
+ F,
5424
+ L,
5425
+ O,
5426
+ L,
5427
+ F
5428
+ ]), l = new Float32Array([
5049
5429
  // Top strip
5050
5430
  B,
5051
- K,
5052
- W,
5053
- K,
5054
- B,
5431
+ J,
5055
5432
  G,
5433
+ J,
5056
5434
  B,
5057
- G,
5058
5435
  W,
5059
- K,
5436
+ B,
5060
5437
  W,
5061
5438
  G,
5439
+ J,
5440
+ G,
5441
+ W,
5062
5442
  // Bottom strip
5063
5443
  B,
5064
- V,
5065
- W,
5066
- V,
5444
+ Z,
5445
+ G,
5446
+ Z,
5067
5447
  B,
5068
- J,
5448
+ Q,
5069
5449
  B,
5070
- J,
5071
- W,
5072
- V,
5073
- W,
5074
- J,
5450
+ Q,
5451
+ G,
5452
+ Z,
5453
+ G,
5454
+ Q,
5075
5455
  // Left strip
5076
5456
  B,
5077
- G,
5457
+ W,
5078
5458
  ee,
5079
- G,
5459
+ W,
5080
5460
  B,
5081
- V,
5461
+ Z,
5082
5462
  B,
5083
- V,
5463
+ Z,
5084
5464
  ee,
5085
- G,
5465
+ W,
5086
5466
  ee,
5087
- V,
5467
+ Z,
5088
5468
  // Right strip
5089
5469
  te,
5090
- G,
5091
5470
  W,
5092
5471
  G,
5472
+ W,
5093
5473
  te,
5094
- V,
5474
+ Z,
5095
5475
  te,
5096
- V,
5097
- W,
5476
+ Z,
5098
5477
  G,
5099
5478
  W,
5100
- V
5479
+ G,
5480
+ Z
5101
5481
  ]);
5102
- return { positions: ce, uvs: s };
5482
+ return { positions: ce, uvs: l };
5103
5483
  }
5104
5484
  function compileShader(t, e, n) {
5105
5485
  const i = t.createShader(e);
@@ -5298,23 +5678,23 @@ class Motion {
5298
5678
  resize(e, n, i) {
5299
5679
  if (this.disposed) throw new Error("Motion instance has been disposed.");
5300
5680
  if (this.options.width = e, this.options.height = n, i && (this.options.ratio = i), !this.running) return;
5301
- const { gl: r, program: o, vao: a, positionBuffer: l, uvBuffer: c, uResolution: u } = this.glr, d = i ?? this.options.ratio ?? window.devicePixelRatio ?? 1, p = Math.max(1, Math.floor(e * d)), f = Math.max(1, Math.floor(n * d));
5302
- this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, (this.canvas.width !== p || this.canvas.height !== f) && (this.canvas.width = p, this.canvas.height = f), r.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(r, "resize: after viewport setup");
5303
- const { positions: m, uvs: g } = computeBorderGeometry(
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(
5304
5684
  this.canvas.width,
5305
5685
  this.canvas.height,
5306
- this.options.borderWidth * d,
5307
- this.options.glowWidth * d
5686
+ this.options.borderWidth * u,
5687
+ this.options.glowWidth * u
5308
5688
  );
5309
- r.bindVertexArray(a), r.bindBuffer(r.ARRAY_BUFFER, l), r.bufferData(r.ARRAY_BUFFER, m, r.STATIC_DRAW);
5310
- const S = r.getAttribLocation(o, "aPosition");
5311
- r.enableVertexAttribArray(S), r.vertexAttribPointer(S, 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);
5312
- const E = r.getAttribLocation(o, "aUV");
5313
- r.enableVertexAttribArray(E), r.vertexAttribPointer(E, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after UV buffer update"), r.useProgram(o), r.uniform2f(u, this.canvas.width, this.canvas.height), r.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * d), r.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * d), r.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * d), this.checkGLError(r, "resize: after uniform updates");
5314
- const h = performance.now();
5315
- this.lastTime = h;
5316
- const x = (h - this.startTime) * 1e-3;
5317
- this.render(x);
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");
5694
+ const f = performance.now();
5695
+ this.lastTime = f;
5696
+ const m = (f - this.startTime) * 1e-3;
5697
+ this.render(m);
5318
5698
  }
5319
5699
  /**
5320
5700
  * Automatically resizes the canvas to match the dimensions of the given element.
@@ -5388,36 +5768,36 @@ class Motion {
5388
5768
  this.checkGLError(e, "setupGL: after createProgram");
5389
5769
  const i = e.createVertexArray();
5390
5770
  e.bindVertexArray(i), this.checkGLError(e, "setupGL: after VAO creation");
5391
- const r = this.canvas.width || 2, o = this.canvas.height || 2, { positions: a, uvs: l } = computeBorderGeometry(
5771
+ const r = this.canvas.width || 2, o = this.canvas.height || 2, { positions: a, uvs: s } = computeBorderGeometry(
5392
5772
  r,
5393
5773
  o,
5394
5774
  this.options.borderWidth,
5395
5775
  this.options.glowWidth
5396
5776
  ), c = e.createBuffer();
5397
5777
  e.bindBuffer(e.ARRAY_BUFFER, c), e.bufferData(e.ARRAY_BUFFER, a, e.STATIC_DRAW);
5398
- const u = e.getAttribLocation(n, "aPosition");
5399
- e.enableVertexAttribArray(u), e.vertexAttribPointer(u, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after position buffer setup");
5400
- const d = e.createBuffer();
5401
- e.bindBuffer(e.ARRAY_BUFFER, d), e.bufferData(e.ARRAY_BUFFER, l, e.STATIC_DRAW);
5778
+ const d = e.getAttribLocation(n, "aPosition");
5779
+ e.enableVertexAttribArray(d), e.vertexAttribPointer(d, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after position buffer setup");
5780
+ const u = e.createBuffer();
5781
+ e.bindBuffer(e.ARRAY_BUFFER, u), e.bufferData(e.ARRAY_BUFFER, s, e.STATIC_DRAW);
5402
5782
  const p = e.getAttribLocation(n, "aUV");
5403
5783
  e.enableVertexAttribArray(p), e.vertexAttribPointer(p, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
5404
- const f = e.getUniformLocation(n, "uResolution"), m = e.getUniformLocation(n, "uTime"), g = e.getUniformLocation(n, "uBorderWidth"), S = e.getUniformLocation(n, "uGlowWidth"), E = e.getUniformLocation(n, "uBorderRadius"), h = e.getUniformLocation(n, "uColors"), x = e.getUniformLocation(n, "uGlowExponent"), T = e.getUniformLocation(n, "uGlowFactor");
5405
- e.useProgram(n), e.uniform1f(g, this.options.borderWidth), e.uniform1f(S, this.options.glowWidth), e.uniform1f(E, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(x, 2), e.uniform1f(T, 1.8)) : (e.uniform1f(x, 1), e.uniform1f(T, 1));
5406
- const L = (this.options.colors || DEFAULT_COLORS).map(parseColor);
5407
- for (let A = 0; A < L.length; A++)
5408
- e.uniform3f(e.getUniformLocation(n, `uColors[${A}]`), ...L[A]);
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]);
5409
5789
  this.checkGLError(e, "setupGL: after uniform setup"), e.bindVertexArray(null), e.bindBuffer(e.ARRAY_BUFFER, null), this.glr = {
5410
5790
  gl: e,
5411
5791
  program: n,
5412
5792
  vao: i,
5413
5793
  positionBuffer: c,
5414
- uvBuffer: d,
5415
- uResolution: f,
5416
- uTime: m,
5417
- uBorderWidth: g,
5418
- uGlowWidth: S,
5419
- uBorderRadius: E,
5420
- uColors: h
5794
+ uvBuffer: u,
5795
+ uResolution: h,
5796
+ uTime: g,
5797
+ uBorderWidth: y,
5798
+ uGlowWidth: T,
5799
+ uBorderRadius: C,
5800
+ uColors: f
5421
5801
  };
5422
5802
  }
5423
5803
  render(e) {
@@ -5507,31 +5887,15 @@ const injectStyles = `
5507
5887
  z-index: 10000;
5508
5888
  }
5509
5889
 
5510
- .webmcp-page-agent-cursorBorder {
5511
- position: absolute;
5512
- width: 100%;
5513
- height: 100%;
5514
- background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));
5515
- mask-image: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");
5516
- mask-size: 100% 100%;
5517
- mask-repeat: no-repeat;
5518
-
5519
- transform-origin: center;
5520
- transform: rotate(-90deg) scale(0.8);
5521
- margin-left: -10px;
5522
- margin-top: -18px;
5523
- }
5524
-
5525
5890
  .webmcp-page-agent-cursorFilling {
5526
5891
  position: absolute;
5527
5892
  width: 100%;
5528
5893
  height: 100%;
5529
- background: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e");
5530
- background-size: 100% 100%;
5894
+ background: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2079.0834%2079.4553%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20%20width%3D%2779.083374%27%20height%3D%2779.455322%27%20fill%3D%27none%27%20%3E--%3Cdefs%3E%3Cfilter%20id%3D%27filter_0%27%20width%3D%2779.083374%27%20height%3D%2779.455322%27%20x%3D%270.000000%27%20y%3D%270.000000%27%20filterUnits%3D%27userSpaceOnUse%27%20%20color-interpolation-filters%3D%27sRGB%27%3E%3CfeFlood%20flood-opacity%3D%270%27%20result%3D%27BackgroundImageFix%27%20%2F%3E%3CfeOffset%20dx%3D%276.000000%27%20dy%3D%276.000000%27%20in%3D%27SourceAlpha%27%20%2F%3E%3CfeGaussianBlur%20stdDeviation%3D%276.66666651%27%20%2F%3E%3CfeColorMatrix%20type%3D%27matrix%27%20values%3D%270%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.18%200%20%27%20%2F%3E%3CfeBlend%20result%3D%27effect_dropShadow_1%27%20in2%3D%27BackgroundImageFix%27%20mode%3D%27normal%27%20%2F%3E%3CfeBlend%20result%3D%27shape%27%20in%3D%27SourceGraphic%27%20in2%3D%27effect_dropShadow_1%27%20mode%3D%27normal%27%20%2F%3E%3C%2Ffilter%3E%3ClinearGradient%20id%3D%27paint_linear_0%27%20x1%3D%2718.4743214%27%20x2%3D%2718.4213886%27%20y1%3D%27-1.86264515e-09%27%20y2%3D%2734.9221306%27%20gradientUnits%3D%27userSpaceOnUse%27%3E%3Cstop%20stop-color%3D%27rgb%28255%2C181%2C96%29%27%20offset%3D%270%27%20stop-opacity%3D%271%27%20%2F%3E%3Cstop%20stop-color%3D%27rgb%28255%2C120%2C114%29%27%20offset%3D%270.5%27%20stop-opacity%3D%271%27%20%2F%3E%3Cstop%20stop-color%3D%27rgb%28241%2C109%2C237%29%27%20offset%3D%271%27%20stop-opacity%3D%271%27%20%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Cg%20filter%3D%27url%28%23filter_0%29%27%3E%3Cpath%20d%3D%27M20.2632%203.57771L34.6257%2032.3027C35.4444%2033.9402%2033.8152%2035.7258%2032.1097%2035.0603L19.2014%2030.0229C18.7339%2029.8404%2018.2148%2029.8404%2017.7472%2030.0229L4.83891%2035.0603C3.13343%2035.7258%201.50423%2033.9402%202.32297%2032.3027L16.6855%203.57771C17.4225%202.10361%2019.5261%202.10361%2020.2632%203.57771Z%27%20fill%3D%27url%28%23paint_linear_0%29%27%20fill-rule%3D%27evenodd%27%20transform%3D%27matrix%280.719908%2C-0.69407%2C0.69407%2C0.719908%2C2.00256%2C28.0095%29%27%20%2F%3E%3Cpath%20d%3D%27M37.2169%2032.6848C37.1578%2032.189%2037.0096%2031.7039%2036.7723%2031.2294L22.4098%202.5044C22.1973%202.07946%2021.9328%201.70554%2021.6163%201.38261C21.3524%201.11342%2021.0524%200.879671%2020.7162%200.681366C20.3925%200.490407%2020.0558%200.34434%2019.7061%200.243163C19.312%200.129145%2018.9014%200.0721366%2018.4743%200.0721366C18.0472%200.0721366%2017.6367%200.129145%2017.2426%200.243163C16.8929%200.34434%2016.5562%200.490407%2016.2324%200.681366C15.8962%200.879671%2015.5962%201.11342%2015.3323%201.38261C15.0158%201.70553%2014.7513%202.07946%2014.5388%202.5044L0.176342%2031.2294C-0.0609121%2031.7039%20-0.209128%2032.189%20-0.268305%2032.6848C-0.316251%2033.0865%20-0.305747%2033.4951%20-0.236792%2033.9108C-0.171059%2034.307%20-0.0570567%2034.6809%200.105216%2035.0326C0.292784%2035.4391%200.544845%2035.8158%200.861397%2036.1627C1.17794%2036.5097%201.53001%2036.7951%201.91761%2037.0191C2.25297%2037.2128%202.61492%2037.3606%203.00348%2037.4623C3.41106%2037.5689%203.81704%2037.6168%204.22142%2037.6058C4.72053%2037.5922%205.21719%2037.4889%205.71141%2037.2961L18.4743%2032.3154L31.2372%2037.2961C31.7315%2037.4889%2032.2281%2037.5922%2032.7272%2037.6058C33.1316%2037.6168%2033.5376%2037.5689%2033.9452%2037.4623C34.3337%2037.3606%2034.6957%2037.2128%2035.0311%2037.0191C35.4187%2036.7951%2035.7707%2036.5097%2036.0873%2036.1627C36.4038%2035.8158%2036.6558%2035.4391%2036.8434%2035.0327C37.0057%2034.681%2037.1197%2034.307%2037.1854%2033.9108C37.2544%2033.4951%2037.2649%2033.0865%2037.2169%2032.6848ZM34.6257%2032.3027L20.2632%203.57771C19.5261%202.10361%2017.4225%202.10361%2016.6855%203.57771L2.32297%2032.3027C1.50423%2033.9402%203.13343%2035.7258%204.83891%2035.0603L17.7472%2030.0229C18.2148%2029.8404%2018.7339%2029.8404%2019.2014%2030.0229L32.1097%2035.0603C33.8152%2035.7258%2035.4444%2033.9402%2034.6257%2032.3027Z%27%20fill%3D%27rgb%28255%2C255%2C255%29%27%20fill-rule%3D%27evenodd%27%20transform%3D%27matrix%280.719908%2C-0.69407%2C0.69407%2C0.719908%2C2.00256%2C28.0095%29%27%20%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
5895
+ background-size: 100% 100%;
5531
5896
  background-repeat: no-repeat;
5532
5897
 
5533
5898
  transform-origin: center;
5534
- transform: rotate(-90deg) scale(0.8);
5535
5899
  margin-left: -10px;
5536
5900
  margin-top: -18px;
5537
5901
  }
@@ -5591,7 +5955,10 @@ class SimulatorMask extends EventTarget {
5591
5955
  try {
5592
5956
  const a = new Motion({
5593
5957
  mode: isPageDark() ? "dark" : "light",
5594
- styles: { position: "absolute", inset: "0" }
5958
+ styles: { position: "absolute", inset: "0" },
5959
+ glowWidth: 80,
5960
+ borderWidth: 8,
5961
+ colors: ["rgb(121, 216, 247)", "rgb(171, 219, 110)", "rgb(252, 188, 114)", "rgb(235, 117, 231)"]
5595
5962
  });
5596
5963
  this.motion = a, this.wrapper.appendChild(a.element), a.autoResize(this.wrapper);
5597
5964
  } catch (a) {
@@ -5604,8 +5971,8 @@ class SimulatorMask extends EventTarget {
5604
5971
  (a) => this.wrapper.addEventListener(a, e)
5605
5972
  ), this.#s(), document.body.appendChild(this.wrapper), this.#a();
5606
5973
  const n = (a) => {
5607
- const { x: l, y: c } = a.detail;
5608
- this.setCursorPosition(l, c);
5974
+ const { x: s, y: c } = a.detail;
5975
+ this.setCursorPosition(s, c);
5609
5976
  }, i = () => {
5610
5977
  this.triggerClickAnimation();
5611
5978
  }, r = () => {
@@ -5628,9 +5995,7 @@ class SimulatorMask extends EventTarget {
5628
5995
  const e = document.createElement("div");
5629
5996
  e.className = "webmcp-page-agent-cursorRipple", this.#e.appendChild(e);
5630
5997
  const n = document.createElement("div");
5631
- n.className = "webmcp-page-agent-cursorFilling", this.#e.appendChild(n);
5632
- const i = document.createElement("div");
5633
- i.className = "webmcp-page-agent-cursorBorder", this.#e.appendChild(i), this.wrapper.appendChild(this.#e);
5998
+ n.className = "webmcp-page-agent-cursorFilling", this.#e.appendChild(n), this.wrapper.appendChild(this.#e);
5634
5999
  }
5635
6000
  #a() {
5636
6001
  if (this.#i) return;
@@ -5656,55 +6021,18 @@ class SimulatorMask extends EventTarget {
5656
6021
  dispose() {
5657
6022
  this.#i = !0, this.motion?.dispose(), this.wrapper.remove(), this.dispatchEvent(new Event("dispose"));
5658
6023
  }
6024
+ // 根据目标元素大小,在 wrapper 添加绝对定位边框:2px 宽、与目标间距 2px,对角渐变 (0,0 → 1,1)
6025
+ borderElement(e) {
6026
+ if (!e) return;
6027
+ 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);
6030
+ }
6031
+ removeBorderElement() {
6032
+ this.wrapper.querySelector(".webmcp-page-agent-border")?.remove();
6033
+ }
5659
6034
  }
5660
- const DEFAULT_ERROR_SELECTORS = [
5661
- // W3C ARIA 标准(最可靠,框架无关)
5662
- '[role="alert"]',
5663
- '[aria-invalid="true"]',
5664
- // Tiny3 / Lego(华为云)
5665
- ".ti3-unifyvalid-error",
5666
- ".ti3-error",
5667
- ".ti-error",
5668
- ".lego-text-error",
5669
- ".lego-error",
5670
- // Element UI / Element Plus
5671
- ".el-form-item__error",
5672
- // Ant Design
5673
- ".ant-form-item-explain-error",
5674
- // Bootstrap
5675
- ".is-invalid",
5676
- ".invalid-feedback",
5677
- // Angular
5678
- ".ng-invalid",
5679
- // 通用命名约定
5680
- ".error-msg",
5681
- ".error-message",
5682
- ".error-text",
5683
- ".field-error",
5684
- ".form-error",
5685
- ".is-error",
5686
- ".has-error",
5687
- ".validate-error",
5688
- ".valid-error"
5689
- ], DEFAULT_DIALOG_SELECTORS = [
5690
- // W3C ARIA 标准
5691
- '[role="dialog"]',
5692
- '[role="alertdialog"]',
5693
- // Tiny3 / Lego(华为云)
5694
- '[class*="ti3-modal"]',
5695
- '[class*="ti3-message-box"]',
5696
- // Element UI / Element Plus
5697
- '[class*="el-dialog"]',
5698
- '[class*="el-message-box"]',
5699
- // Ant Design
5700
- '[class*="ant-modal"]',
5701
- // Bootstrap
5702
- '[class*="modal-content"]',
5703
- // Vuetify
5704
- '[class*="v-dialog"]',
5705
- // Naive UI
5706
- '[class*="n-modal"]'
5707
- ], inputSchema = z.object({
6035
+ const inputSchema = z.object({
5708
6036
  action: z.enum(["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree"]).describe(`执行的动作名称, 每一次执行 'click', 'fill', 'select'动作之前,**必须**要先调用 'browserState' 去获取页面的最新状态。
5709
6037
  browserState: '查询整个页面的浏览器状态;返回页面的标题、URL、YAML格式的语义化页面树',
5710
6038
  click: '根据元素索引点击;',
@@ -5729,86 +6057,90 @@ const DEFAULT_ERROR_SELECTORS = [
5729
6057
  responseMode: z.enum(["full", "diff", "both"]).optional().default("diff").describe(
5730
6058
  "返回浏览器状态的模式。full: 仅返回当前全量 A11y 树;diff: 仅返回与上一次状态的增量差异;both: 同时返回全量 A11y 树与增量差异。默认值为 diff。"
5731
6059
  )
5732
- });
5733
- function isInShadowDom(t) {
5734
- return t.getRootNode() instanceof ShadowRoot;
5735
- }
5736
- function dispatchComposedEvents(t, ...e) {
5737
- for (const n of e)
5738
- t.dispatchEvent(new Event(n, { bubbles: !0, composed: !0 }));
5739
- }
5740
- function deepQuerySelectorAll(t, e = document) {
5741
- const n = Array.from(e.querySelectorAll(t)), i = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, null);
5742
- let r = i.currentNode;
5743
- for (; r; )
5744
- r.shadowRoot && n.push(...deepQuerySelectorAll(t, r.shadowRoot)), r = i.nextNode();
5745
- return n;
5746
- }
5747
- function waitForDomSettled(t = 600, e = 150) {
5748
- return new Promise((n) => {
5749
- let i = !1, r;
5750
- const o = () => {
5751
- i || (i = !0, a.disconnect(), r && clearTimeout(r), n());
5752
- }, a = new MutationObserver(() => {
5753
- r && clearTimeout(r), r = setTimeout(o, e);
5754
- });
5755
- r = setTimeout(o, e), setTimeout(o, t), a.observe(document.body, {
5756
- childList: !0,
5757
- subtree: !0,
5758
- attributes: !0,
5759
- attributeFilter: ["class", "style", "hidden"]
5760
- });
5761
- });
5762
- }
5763
- function detectPageDialog() {
5764
- const t = /* @__PURE__ */ new Set(), e = [], n = window.__webmcpcli_dialogSelectors ?? DEFAULT_DIALOG_SELECTORS;
5765
- for (const i of n)
5766
- try {
5767
- for (const r of deepQuerySelectorAll(i)) {
5768
- if (t.has(r) || r.id?.includes("page-agent-runtime") || r.closest("#page-agent-runtime_simulator-mask")) continue;
5769
- const o = r.getBoundingClientRect();
5770
- if (o.width < 50 || o.height < 50) continue;
5771
- const a = window.getComputedStyle(r);
5772
- if (a.display === "none" || a.visibility === "hidden") continue;
5773
- const l = a.position === "fixed" || a.position === "absolute", c = parseInt(a.zIndex || "0", 10);
5774
- if (!l || c < 100) continue;
5775
- const u = window.innerWidth, d = window.innerHeight;
5776
- if (!(o.left < u * 0.6 && o.right > u * 0.4 && o.top < d * 0.6 && o.bottom > d * 0.4)) continue;
5777
- t.add(r);
5778
- const f = (r.textContent || "").trim().replace(/\s+/g, " ");
5779
- if (f.length > 5) {
5780
- 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), S = g.length ? ` [可操作按钮: ${g.join(" / ")}]` : "";
5781
- e.push(`${f.substring(0, 300)}${S}`);
6060
+ }), PAGE_AGENT_TOOL_CALL_EVENT = "page-agent-tool-call", PAGE_AGENT_TOOL_RESULT_EVENT = "page-agent-tool-result", PAGE_AGENT_CHAT_END_EVENT = "page-agent-chat-end";
6061
+ function isPageAgentToolErrorResult(t) {
6062
+ return typeof t == "object" && t !== null && "isError" in t && t.isError === !0 && "error" in t && typeof t.error == "string";
6063
+ }
6064
+ function dispatchPageAgentToolResult(t) {
6065
+ window.dispatchEvent(new CustomEvent(PAGE_AGENT_TOOL_RESULT_EVENT, { detail: t }));
6066
+ }
6067
+ function setupPageAgentToolEventBridge(t, e) {
6068
+ window.__nextSdkPageAgentToolEventCleanup?.();
6069
+ const n = async (r) => {
6070
+ const o = r.detail, a = o?.requestId;
6071
+ if (!a) {
6072
+ dispatchPageAgentToolResult({
6073
+ requestId: "",
6074
+ data: {
6075
+ success: !1,
6076
+ error: "缺少 requestId"
5782
6077
  }
5783
- }
5784
- } catch {
6078
+ });
6079
+ return;
5785
6080
  }
5786
- return e.length === 0 ? "" : `
5787
- [页面弹窗检测] 检测到 ${e.length} 个模态弹窗,请优先处理:
5788
- ${e.map((i, r) => `${r + 1}. ${i}`).join(`
5789
- `)}
5790
- `;
5791
- }
5792
- function detectValidationErrors() {
5793
- const t = /* @__PURE__ */ new Set(), e = [], n = window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS;
5794
- for (const i of n)
5795
6081
  try {
5796
- for (const r of deepQuerySelectorAll(i)) {
5797
- if (t.has(r) || Array.from(t).some((c) => c.contains(r))) continue;
5798
- const o = r.getBoundingClientRect();
5799
- if (o.width < 1 || o.height < 1) continue;
5800
- const a = window.getComputedStyle(r);
5801
- if (a.display === "none" || a.visibility === "hidden") continue;
5802
- const l = (r.textContent || "").trim().replace(/\s+/g, " ");
5803
- l.length > 2 && l.length < 200 && (t.add(r), e.push(l));
6082
+ const s = inputSchema.parse(o.data), c = await t(s);
6083
+ if (isPageAgentToolErrorResult(c)) {
6084
+ dispatchPageAgentToolResult({
6085
+ requestId: a,
6086
+ data: {
6087
+ success: !1,
6088
+ error: c.error,
6089
+ result: c
6090
+ }
6091
+ });
6092
+ return;
5804
6093
  }
6094
+ dispatchPageAgentToolResult({
6095
+ requestId: a,
6096
+ data: {
6097
+ success: !0,
6098
+ result: c
6099
+ }
6100
+ });
6101
+ } catch (s) {
6102
+ dispatchPageAgentToolResult({
6103
+ requestId: a,
6104
+ data: {
6105
+ success: !1,
6106
+ error: s instanceof Error ? s.message : String(s)
6107
+ }
6108
+ });
6109
+ }
6110
+ }, i = async () => {
6111
+ try {
6112
+ await e.hideMask();
5805
6113
  } catch {
5806
6114
  }
5807
- return e.length === 0 ? "" : `
5808
- [校验提示] 检测到 ${e.length} 个表单校验错误,请先修复后再继续:
5809
- ${e.map((i, r) => `${r + 1}. ${i}`).join(`
5810
- `)}
5811
- `;
6115
+ };
6116
+ window.addEventListener(PAGE_AGENT_TOOL_CALL_EVENT, n), window.addEventListener(PAGE_AGENT_CHAT_END_EVENT, i), window.__nextSdkPageAgentToolEventCleanup = () => {
6117
+ window.removeEventListener(PAGE_AGENT_TOOL_CALL_EVENT, n), window.removeEventListener(PAGE_AGENT_CHAT_END_EVENT, i), window.__nextSdkPageAgentToolEventCleanup = void 0;
6118
+ };
6119
+ }
6120
+ async function createActionErrorResult(t, e) {
6121
+ try {
6122
+ const n = await e("full");
6123
+ return {
6124
+ isError: !0,
6125
+ error: t,
6126
+ content: [{ type: "text", text: `${t}
6127
+
6128
+ ${n.content[0].text}` }]
6129
+ };
6130
+ } catch (n) {
6131
+ return {
6132
+ isError: !0,
6133
+ error: t,
6134
+ content: [
6135
+ {
6136
+ type: "text",
6137
+ text: `${t}
6138
+
6139
+ 获取最新浏览器状态失败: ${n instanceof Error ? n.message : String(n)}`
6140
+ }
6141
+ ]
6142
+ };
6143
+ }
5812
6144
  }
5813
6145
  async function handleBrowserState(t, e) {
5814
6146
  if (window.__webmcpcli_beforeGetBrowserState)
@@ -5821,9 +6153,12 @@ async function handleBrowserState(t, e) {
5821
6153
  }
5822
6154
  async function handleClick(t, e) {
5823
6155
  const n = t.responseMode ?? "diff";
5824
- if (t.index === void 0) return e.errContent("点击结果: 缺少元素索引");
6156
+ if (t.index === void 0) return e.actionError("点击结果: 缺少元素索引");
5825
6157
  const i = e.getRefMap().get(t.index);
5826
- if (!i) return e.refreshOnStaleRef("点击", t.index);
6158
+ if (!i)
6159
+ return e.actionError(
6160
+ `点击失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
6161
+ );
5827
6162
  let r = i;
5828
6163
  if (i.shadowRoot && !(i instanceof HTMLButtonElement) && !(i instanceof HTMLAnchorElement)) {
5829
6164
  const o = i.shadowRoot.querySelector(
@@ -5835,9 +6170,13 @@ async function handleClick(t, e) {
5835
6170
  }
5836
6171
  async function handleFill(t, e) {
5837
6172
  const n = t.responseMode ?? "diff";
5838
- if (t.index === void 0 || typeof t.text != "string") return e.errContent("填写结果: 缺少元素索引或文本内容");
6173
+ if (t.index === void 0 || typeof t.text != "string")
6174
+ return e.actionError("填写结果: 缺少元素索引或文本内容");
5839
6175
  const i = e.getRefMap().get(t.index);
5840
- if (!i) return e.refreshOnStaleRef("填写", t.index);
6176
+ if (!i)
6177
+ return e.actionError(
6178
+ `填写失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
6179
+ );
5841
6180
  let r = i;
5842
6181
  if (!(r instanceof HTMLInputElement) && !(r instanceof HTMLTextAreaElement)) {
5843
6182
  const o = i.querySelector("input, textarea") ?? i.shadowRoot?.querySelector("input, textarea");
@@ -5850,23 +6189,27 @@ async function handleFill(t, e) {
5850
6189
  try {
5851
6190
  await inputTextElement(r, t.text), o = !0;
5852
6191
  } catch {
5853
- const l = Object.getOwnPropertyDescriptor(
6192
+ const s = Object.getOwnPropertyDescriptor(
5854
6193
  (r instanceof HTMLTextAreaElement ? HTMLTextAreaElement : HTMLInputElement).prototype,
5855
6194
  "value"
5856
6195
  )?.set;
5857
- l && (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement) && (l.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);
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);
5858
6197
  }
5859
6198
  if (!o)
5860
- return e.errContent(`填写结果: 无法填写元素 ${t.index},元素不是 input、textarea 或 contenteditable`);
6199
+ return e.actionError(`填写结果: 无法填写元素 ${t.index},元素不是 input、textarea 或 contenteditable`);
5861
6200
  isInShadowDom(r) && dispatchComposedEvents(r, "input", "change");
5862
6201
  }
5863
6202
  return await waitForDomSettled(), e.buildBrowserStateResponse(n);
5864
6203
  }
5865
6204
  async function handleSelect(t, e) {
5866
6205
  const n = t.responseMode ?? "diff";
5867
- if (t.index === void 0 || typeof t.text != "string") return e.errContent("选择结果: 缺少元素索引或文本内容");
6206
+ if (t.index === void 0 || typeof t.text != "string")
6207
+ return e.actionError("选择结果: 缺少元素索引或文本内容");
5868
6208
  let i = e.getRefMap().get(t.index);
5869
- if (!i) return e.refreshOnStaleRef("选择", t.index);
6209
+ if (!i)
6210
+ return e.actionError(
6211
+ `选择失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
6212
+ );
5870
6213
  let r = null;
5871
6214
  if (i instanceof HTMLSelectElement)
5872
6215
  r = i;
@@ -5874,7 +6217,7 @@ async function handleSelect(t, e) {
5874
6217
  const o = i.querySelector("select") ?? i.shadowRoot?.querySelector("select");
5875
6218
  o && (r = o);
5876
6219
  }
5877
- return r ? (await selectOptionElement(r, t.text), isInShadowDom(r) && dispatchComposedEvents(r, "change"), await waitForDomSettled(), e.buildBrowserStateResponse(n)) : e.errContent(`选择结果: 无法选择元素 ${t.index},未找到对应的 <select> 元素`);
6220
+ return r ? (await selectOptionElement(r, t.text), isInShadowDom(r) && dispatchComposedEvents(r, "change"), await waitForDomSettled(), e.buildBrowserStateResponse(n)) : e.actionError(`选择结果: 无法选择元素 ${t.index},未找到对应的 <select> 元素`);
5878
6221
  }
5879
6222
  function getScrollInfo(t = window) {
5880
6223
  if (t === window) {
@@ -5915,8 +6258,8 @@ function waitForScrollEnd(t, e = 2e3) {
5915
6258
  return new Promise((n) => {
5916
6259
  let i = !1;
5917
6260
  const r = t === window ? document : t, o = () => {
5918
- i || (i = !0, r.removeEventListener("scrollend", a), clearTimeout(l), n());
5919
- }, a = () => o(), l = setTimeout(o, e);
6261
+ i || (i = !0, r.removeEventListener("scrollend", a), clearTimeout(s), n());
6262
+ }, a = () => o(), s = setTimeout(o, e);
5920
6263
  r.addEventListener("scrollend", a, { once: !0 });
5921
6264
  });
5922
6265
  }
@@ -5925,33 +6268,33 @@ async function handleScroll(t, e) {
5925
6268
  if (t.down === void 0 && t.right === void 0) return e.errContent("滚动结果: 缺少滚动方向参数");
5926
6269
  let i = window;
5927
6270
  if (t.index !== void 0) {
5928
- const m = e.getRefMap().get(t.index);
5929
- if (!m) return e.refreshOnStaleRef("滚动", t.index);
5930
- i = m;
6271
+ const g = e.getRefMap().get(t.index);
6272
+ if (!g) return e.refreshOnStaleRef("滚动", t.index);
6273
+ i = g;
5931
6274
  }
5932
6275
  const r = getScrollInfo(i);
5933
6276
  if (t.right !== void 0) {
5934
- const m = t.pixels ?? 300;
5935
- i.scrollBy({ left: t.right ? m : -m, behavior: "smooth" });
6277
+ const g = t.pixels ?? 300;
6278
+ i.scrollBy({ left: t.right ? g : -g, behavior: "smooth" });
5936
6279
  } else {
5937
- const m = t.pixels ?? Math.round((t.numPages ?? 1) * window.innerHeight);
5938
- i.scrollBy({ top: t.down ? m : -m, behavior: "smooth" });
6280
+ const g = t.pixels ?? Math.round((t.numPages ?? 1) * window.innerHeight);
6281
+ i.scrollBy({ top: t.down ? g : -g, behavior: "smooth" });
5939
6282
  }
5940
6283
  await waitForScrollEnd(i);
5941
- const o = getScrollInfo(i), a = Math.round(o.scrollY - r.scrollY), l = Math.round(o.scrollX - r.scrollX), c = t.right !== void 0;
5942
- let u;
5943
- if (Math.abs(a) < 1 && Math.abs(l) < 1)
5944
- c ? u = t.right ? "⚠️ 已到达右边界,无法继续向右滚动" : "⚠️ 已到达左边界,无法继续向左滚动" : u = t.down ? "⚠️ 已到达底部,无法继续向下滚动" : "⚠️ 已到达顶部,无法继续向上滚动";
6284
+ const o = getScrollInfo(i), a = Math.round(o.scrollY - r.scrollY), s = Math.round(o.scrollX - r.scrollX), c = t.right !== void 0;
6285
+ let d;
6286
+ if (Math.abs(a) < 1 && Math.abs(s) < 1)
6287
+ c ? d = t.right ? "⚠️ 已到达右边界,无法继续向右滚动" : "⚠️ 已到达左边界,无法继续向左滚动" : d = t.down ? "⚠️ 已到达底部,无法继续向下滚动" : "⚠️ 已到达顶部,无法继续向上滚动";
5945
6288
  else {
5946
- const m = c ? `水平滚动 ${l}px` : `垂直滚动 ${a}px`;
5947
- let g = "";
5948
- c ? t.right && o.atRight ? g = ",已到达右边界" : !t.right && o.atLeft && (g = ",已到达左边界") : t.down && o.atBottom ? g = ",已到达底部" : !t.down && o.atTop && (g = ",已到达顶部"), u = `✅ ${m}${g}`;
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}`;
5949
6292
  }
5950
- const d = 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 = `[滚动结果] ${u}
5951
- ${d}`, f = await e.buildBrowserStateResponse(n);
5952
- return f.content[0].text = `${p}
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}
5953
6296
 
5954
- ${f.content[0].text}`, f;
6297
+ ${h.content[0].text}`, h;
5955
6298
  }
5956
6299
  async function handleExecuteJavascript(t, e) {
5957
6300
  if (!t.script) return e.errContent("脚本执行异常: 缺少javascript代码");
@@ -5967,110 +6310,295 @@ async function handleExecuteJavascript(t, e) {
5967
6310
  }
5968
6311
  async function handleSearchTree(t, e) {
5969
6312
  if (!t.query) return e.errContent("搜索失败: 缺少 query 参数");
5970
- const n = window.__webmcpcli_interactiveBlacklist ?? [], i = window.__webmcpcli_interactiveWhitelist ?? [], r = window.__webmcpcli_exposedAttributes ?? [], o = searchA11yTree(t.query, document.body, n, i, {
6313
+ const n = searchA11yTree(t.query, document.body, {
6314
+ ...getPageAgentToolConfig().a11yConfig,
5971
6315
  contextLines: t.contextLines,
5972
- maxMatches: t.maxMatches,
5973
- exposedAttributes: r,
5974
- errorSelectors: (window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS).join(", ")
6316
+ maxMatches: t.maxMatches
5975
6317
  });
5976
- e.setRefMap(o.refMap), e.stateCache.update(window.location.href, o.yaml), await e.pageController.hideMask();
5977
- const a = detectPageDialog(), l = detectValidationErrors(), c = `${a}${l}`;
6318
+ 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}`;
5978
6320
  return {
5979
- content: [{ type: "text", text: c ? `${c}
5980
- ${o.text}` : o.text }]
6321
+ content: [{ type: "text", text: o ? `${o}
6322
+ ${n.text}` : n.text }]
5981
6323
  };
5982
6324
  }
5983
6325
  function registerPageAgentTool(t = {}) {
5984
- initializeBuiltinWebMCP(), typeof t.enableHighlight > "u" && (t.enableHighlight = !0), window.__webmcpcli_interactiveWhitelist = window.__webmcpcli_interactiveWhitelist || [], window.__webmcpcli_interactiveBlacklist = window.__webmcpcli_interactiveBlacklist || [], window.__webmcpcli_exposedAttributes = window.__webmcpcli_exposedAttributes || t?.exposedAttributes || [], window.__webmcpcli_beforeGetBrowserState = window.__webmcpcli_beforeGetBrowserState || null, window.__webmcpcli_errorSelectors = window.__webmcpcli_errorSelectors || DEFAULT_ERROR_SELECTORS, window.__webmcpcli_dialogSelectors = window.__webmcpcli_dialogSelectors || DEFAULT_DIALOG_SELECTORS;
6326
+ initializeBuiltinWebMCP(), setPageAgentToolConfig(t, { mode: "replace" }), window.__webmcpcli_beforeGetBrowserState = window.__webmcpcli_beforeGetBrowserState || null;
5985
6327
  const e = new PageController({ enableMask: !1 });
5986
6328
  e.maskReady = (async () => {
5987
6329
  e.mask = new SimulatorMask();
5988
6330
  })();
5989
6331
  const n = new PageStateCache();
5990
6332
  let i = /* @__PURE__ */ new Map();
5991
- async function r(c) {
5992
- return await e.hideMask(), { content: [{ type: "text", text: c }] };
6333
+ async function r(u) {
6334
+ return { content: [{ type: "text", text: u }] };
6335
+ }
6336
+ async function o(u) {
6337
+ const p = await createActionErrorResult(u, s);
6338
+ return t.removeMaskAfterToolCall && await e.hideMask(), p;
5993
6339
  }
5994
- async function o(c, u) {
5995
- const d = await a("full");
6340
+ async function a(u, p) {
6341
+ const h = await s("full");
5996
6342
  return {
5997
- content: [{ type: "text", text: `⚠️ ${c}失败: ref 索引 ${u} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。
5998
- ` + d.content[0].text }]
6343
+ content: [{ type: "text", text: `⚠️ ${u}失败: ref 索引 ${p} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。
6344
+ ` + h.content[0].text }]
5999
6345
  };
6000
6346
  }
6001
- async function a(c = "diff") {
6002
- const u = window.location.href, d = document.title, p = window.__webmcpcli_interactiveBlacklist ?? [], f = window.__webmcpcli_interactiveWhitelist ?? [], m = window.__webmcpcli_exposedAttributes ?? [], { yaml: g, refMap: S } = buildA11yTree(document.body, p, f, {
6003
- exposedAttributes: m,
6004
- errorSelectors: (window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS).join(", ")
6005
- });
6006
- i = S, t?.enableHighlight && (highlight(S), globalRemoveListener());
6007
- const E = n.update(u, g);
6008
- await e.hideMask();
6009
- const h = detectPageDialog(), x = detectValidationErrors();
6010
- let T = "";
6011
- return c === "full" ? T = g : c === "diff" ? T = E.isFullRefresh ? g : E.diffText : c === "both" && (T = `【全量页面树】:
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 = `【全量页面树】:
6012
6353
  ${g}
6013
6354
 
6014
6355
  【增量差异】:
6015
- ${E.isFullRefresh ? "(首次/刷新,无增量差异)" : E.diffText}`), { content: [{ type: "text", text: `浏览器状态: ${JSON.stringify({
6016
- url: u,
6017
- title: d,
6018
- content: T
6019
- })}${h}${x}` }] };
6356
+ ${T.isFullRefresh ? "(首次/刷新,无增量差异)" : T.diffText}`), { content: [{ type: "text", text: `浏览器状态: ${JSON.stringify({
6357
+ url: p,
6358
+ title: h,
6359
+ content: m
6360
+ })}${C}${f}` }] };
6020
6361
  }
6021
- const l = {
6362
+ const c = {
6022
6363
  pageController: e,
6023
6364
  stateCache: n,
6024
6365
  getRefMap: () => i,
6025
- setRefMap: (c) => {
6026
- i = c;
6366
+ setRefMap: (u) => {
6367
+ i = u;
6027
6368
  },
6028
- buildBrowserStateResponse: a,
6029
- refreshOnStaleRef: o,
6030
- errContent: r
6369
+ buildBrowserStateResponse: s,
6370
+ refreshOnStaleRef: a,
6371
+ errContent: r,
6372
+ actionError: o
6031
6373
  };
6374
+ async function d(u) {
6375
+ try {
6376
+ let p;
6377
+ switch (u.action) {
6378
+ case "browserState":
6379
+ p = await handleBrowserState(u, c);
6380
+ break;
6381
+ 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();
6383
+ break;
6384
+ 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();
6386
+ break;
6387
+ 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();
6389
+ break;
6390
+ case "scroll":
6391
+ await e.showMask(), p = await handleScroll(u, c), t.removeMaskAfterToolCall && await e.hideMask();
6392
+ break;
6393
+ case "executeJavascript":
6394
+ p = await handleExecuteJavascript(u, c);
6395
+ break;
6396
+ case "searchTree":
6397
+ p = await handleSearchTree(u, c);
6398
+ break;
6399
+ default:
6400
+ p = { content: [{ type: "text", text: `未知操作: ${u.action}` }] };
6401
+ }
6402
+ return p;
6403
+ } catch (p) {
6404
+ const h = {
6405
+ click: "点击",
6406
+ fill: "填写",
6407
+ select: "选择"
6408
+ };
6409
+ if (u.action in h)
6410
+ return o(
6411
+ `${h[u.action]}执行异常: ${p instanceof Error ? p.message : String(p)}`
6412
+ );
6413
+ throw t.removeMaskAfterToolCall && await e.hideMask(), p;
6414
+ }
6415
+ }
6032
6416
  document.modelContext.registerTool({
6033
6417
  name: "page-agent-tool",
6034
6418
  description: pageAgentPrompt,
6035
6419
  // @ts-ignore
6036
6420
  inputSchema: zodToJsonSchema(inputSchema),
6037
- async execute(c) {
6038
- await e.showMask();
6421
+ async execute(u) {
6039
6422
  try {
6040
- switch (c.action) {
6041
- case "browserState":
6042
- return await handleBrowserState(c, l);
6043
- case "click":
6044
- return await handleClick(c, l);
6045
- case "fill":
6046
- return await handleFill(c, l);
6047
- case "select":
6048
- return await handleSelect(c, l);
6049
- case "scroll":
6050
- return await handleScroll(c, l);
6051
- case "executeJavascript":
6052
- return await handleExecuteJavascript(c, l);
6053
- case "searchTree":
6054
- return await handleSearchTree(c, l);
6055
- default:
6056
- return await e.hideMask(), { content: [{ type: "text", text: `未知操作: ${c.action}` }] };
6057
- }
6058
- } catch (u) {
6059
- return await e.hideMask(), { content: [{ type: "text", text: `异常: ${String(u)}` }] };
6423
+ return d(u);
6424
+ } catch (p) {
6425
+ return { content: [{ type: "text", text: `异常: ${String(p)}` }] };
6060
6426
  }
6061
6427
  }
6062
- });
6428
+ }), setupPageAgentToolEventBridge(d, e);
6429
+ }
6430
+ const consoleCloudPageAgentToolOptions = {
6431
+ enableHighlight: !1,
6432
+ a11yConfig: {
6433
+ roles: [
6434
+ // Tiny3 Tabs:真正可聚焦/可点击的是内部 .ti3-tabs-text(tabindex=0)
6435
+ { role: "tablist", selector: "ul.ti3-tabs" },
6436
+ { role: "tab", selector: ".ti3-tabs-text" },
6437
+ { role: "tabpanel", selector: ["ti-tab.ti3-tab-pane", ".ti3-tab-pane"] },
6438
+ // 自定义下拉 / 区域选择触发器
6439
+ {
6440
+ role: "combobox",
6441
+ selector: [
6442
+ ".ti3-select-dominator-container",
6443
+ ".selected-label",
6444
+ ".sort-select",
6445
+ ".service-select",
6446
+ ".region-select",
6447
+ '[cf-uba="searchableRegion..open"]'
6448
+ ]
6449
+ },
6450
+ // 图标型 / 无语义按钮
6451
+ {
6452
+ role: "button",
6453
+ selector: [
6454
+ ".modules-service-list-menu-service-icon-container",
6455
+ ".ti3-btn-only-icon-noborder",
6456
+ ".ti3-select-dominator-dropdown-btn",
6457
+ ".modules-right-sidebar-icon-item-wrapper",
6458
+ ".modules-right-sidebar-hide-state-plugin",
6459
+ ".components-service-list-container-service-list-input-service-close",
6460
+ ".modules-searchable-region-region-panel-close",
6461
+ ".modules-searchable-region-region-panel-search-btn",
6462
+ '[cf-uba="rightSidebar..hideBtn"]',
6463
+ // Tiny3 图标组件:帮助中心固定/全屏/关闭等(ti-icon / tp-icon 无原生 button 语义)
6464
+ ".ti-global-help-panel-header-icon",
6465
+ "ti-icon[name]",
6466
+ "tp-icon[name]",
6467
+ // 无 name 的箭头/操作图标(如 latest news 区 common-icon 展开箭头)
6468
+ "tp-icon.common-icon",
6469
+ "ti-icon.common-icon",
6470
+ "ti-icon.ti3-icon-full-screen",
6471
+ "ti-icon.ti3-icon-close",
6472
+ "tp-icon.ti3-icon-full-screen",
6473
+ "tp-icon.ti3-icon-close"
6474
+ ]
6475
+ },
6476
+ // 服务列表侧栏分类 / 顶栏菜单项
6477
+ {
6478
+ role: "menuitem",
6479
+ selector: [
6480
+ ".components-service-list-left-box-sidebar-visit-panel > li",
6481
+ ".modules-menus-menu-item",
6482
+ ".components-menu-wrapper-menu-text"
6483
+ ]
6484
+ },
6485
+ // 区域筛选项 / 下拉选项
6486
+ {
6487
+ role: "option",
6488
+ selector: [
6489
+ ".region-selector-item",
6490
+ ".modules-searchable-region-project-item-region-item",
6491
+ ".modules-searchable-region-region-panel-recent-region-item",
6492
+ ".ti3-multiselect-box-cell"
6493
+ ]
6494
+ }
6495
+ ],
6496
+ states: {
6497
+ // 选中态:挂在容器 class 上,用 selector + closest 即可命中内部交互节点
6498
+ selected: [
6499
+ { selector: "li.ti3-tab-li.ti3-tab-active" },
6500
+ // Tiny3 按钮组(计费模式等):ti3-active 在 .ti3-btn-item-container 上,不在 button 上
6501
+ { selector: ".ti3-btn-item-container.ti3-active" },
6502
+ { selector: ".components-service-list-left-box-active" },
6503
+ {
6504
+ selector: [
6505
+ ".modules-searchable-region-project-item-region-item-selected",
6506
+ ".components-search-content-search-select-search-select-selected"
6507
+ ]
6508
+ }
6509
+ ],
6510
+ hasPopup: [
6511
+ {
6512
+ selector: [
6513
+ ".ti3-select-dominator-container",
6514
+ ".selected-label",
6515
+ ".sort-select",
6516
+ ".service-select",
6517
+ ".region-select",
6518
+ '[cf-uba="searchableRegion..open"]',
6519
+ '[cf-uba="serviceList..open"]',
6520
+ '[cf-uba="userinfo"]'
6521
+ ]
6522
+ }
6523
+ ],
6524
+ disabled: [{ selector: ".ti3-disabled" }],
6525
+ // 展开态:需结合计算样式,选择器表达不了「可见」
6526
+ expanded: [
6527
+ {
6528
+ match: (t) => {
6529
+ try {
6530
+ if (!t.matches(
6531
+ ".modules-layout-module-sidebar-panel, .modules-searchable-region-region-panel, .ti3-dropdown-container"
6532
+ ))
6533
+ return !1;
6534
+ const e = window.getComputedStyle(t);
6535
+ return e.display !== "none" && e.visibility !== "hidden" && e.opacity !== "0";
6536
+ } catch {
6537
+ return !1;
6538
+ }
6539
+ }
6540
+ }
6541
+ ]
6542
+ },
6543
+ // exposedAttributes 输出属性 token;带 name 的 ti-icon/tp-icon 可交互性由 roles/whitelist 中 ti-icon[name] 等规则判定。
6544
+ exposedAttributes: ["cf-uba", "data-qa-id", "name"],
6545
+ whitelist: [
6546
+ ".modules-service-list-menu-service-icon-container",
6547
+ ".ti3-tabs-text",
6548
+ '[cf-uba="cloudShell"]',
6549
+ '[cf-uba="messageBox"]',
6550
+ '[cf-uba="helpFeedback"]',
6551
+ '[cf-uba="globalMessage"]',
6552
+ '[cf-uba="rightSidebar..hideBtn"]',
6553
+ // 帮助中心等区域的 ti-icon / tp-icon 图标按钮
6554
+ ".ti-global-help-panel-header-icon",
6555
+ "ti-icon[name]",
6556
+ "tp-icon[name]",
6557
+ "tp-icon.common-icon",
6558
+ "ti-icon.common-icon",
6559
+ "ti-icon.ti3-icon-full-screen"
6560
+ ],
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"
6567
+ ]
6568
+ }
6569
+ };
6570
+ function isConsoleCloudHost(t = typeof location < "u" ? location.hostname : "") {
6571
+ return /(^|\.)console\.huaweicloud\.com$/i.test(t);
6063
6572
  }
6064
6573
  export {
6574
+ DEFAULT_PAGE_AGENT_TOOL_CONFIG as D,
6065
6575
  Motion as M,
6576
+ PAGE_AGENT_TOOL_CALL_EVENT as P,
6066
6577
  QrCode as Q,
6067
6578
  getSkillMdContent as a,
6068
6579
  getMainSkillPaths as b,
6069
6580
  getMainSkillPathByName as c,
6070
6581
  createSkillTools as d,
6071
- createRemoter as e,
6582
+ PAGE_AGENT_TOOL_RESULT_EVENT as e,
6072
6583
  formatSkillsForSystemPrompt as f,
6073
6584
  getSkillOverviews as g,
6585
+ getPageAgentToolConfig as h,
6586
+ consoleCloudPageAgentToolOptions as i,
6587
+ isConsoleCloudHost as j,
6588
+ DEFAULT_A11Y_CONFIG as k,
6589
+ defineA11yConfig as l,
6590
+ resolveA11yInfo as m,
6591
+ resolveA11yRole as n,
6592
+ resolveA11yStates as o,
6074
6593
  parseSkillFrontMatter as p,
6075
- registerPageAgentTool as r
6594
+ mergeA11yConfig as q,
6595
+ registerPageAgentTool as r,
6596
+ setPageAgentToolConfig as s,
6597
+ mergeA11yConfigs as t,
6598
+ ensureResolvedA11yConfig as u,
6599
+ isResolvedA11yConfig as v,
6600
+ extractSelectors as w,
6601
+ buildA11yTree as x,
6602
+ searchA11yTree as y,
6603
+ createRemoter as z
6076
6604
  };