@commentkit/comment-kit 0.6.9 → 0.7.0

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 (62) hide show
  1. package/CHANGELOG.md +36 -4
  2. package/LICENSE +18 -2
  3. package/README.md +133 -88
  4. package/SECURITY.md +48 -0
  5. package/dist/THIRD_PARTY_NOTICES.txt +284 -0
  6. package/dist/angular.es.js +25 -12
  7. package/dist/comment-kit.es.js +23 -11
  8. package/dist/demo.es.js +146 -69
  9. package/dist/headless.es.js +2 -2
  10. package/dist/preact.es.js +3 -3
  11. package/dist/qwik.es.js +1 -110
  12. package/dist/qwik.qwik.mjs +114 -0
  13. package/dist/react.es.js +3 -3
  14. package/dist/shared/annotation-icons-Dh-bmNYK.js +172 -0
  15. package/dist/shared/annotation-toolbar-B9SxYqoF.js +1093 -0
  16. package/dist/shared/{bridge-DRE03N9X.js → bridge-CJoGYngu.js} +6 -3
  17. package/dist/shared/{button-group-CHfMRXyA.js → button-group-Cl9CrvvU.js} +1 -1
  18. package/dist/shared/comment-drawing-canvas-Dzb5YoFw.js +124 -0
  19. package/dist/shared/{comment-image-lightbox-0VdAs2iT.js → comment-image-lightbox-BPYJT1sB.js} +62 -57
  20. package/dist/shared/{comment-kit-core-D0kY00St.js → comment-kit-core-BaSuMzp9.js} +1027 -729
  21. package/dist/shared/comment-kit-ui-CzfdAZs2.js +20181 -0
  22. package/dist/shared/comment-screenshot-annotator-C7X-_bm6.js +151 -0
  23. package/dist/shared/comment-screenshot-overlay-wIrZrcRy.js +206 -0
  24. package/dist/shared/comment-utils-BycYTSxA.js +602 -0
  25. package/dist/shared/{dev-export-panel-BLngcr5q.js → dev-export-panel-FwFVdady.js} +8 -8
  26. package/dist/shared/{dev-grab-pDAfH2lr.js → dev-grab-DDqg0LQf.js} +1 -1
  27. package/dist/shared/dist-De294MVF.js +623 -0
  28. package/dist/shared/{element-selector-CtFzgHvq.js → element-selector-BhJm-NSs.js} +294 -288
  29. package/dist/shared/{icons-BSHCWYO1.js → icons-nzMOLzrm.js} +2 -3
  30. package/dist/shared/{mount-ui-CVivB_eQ.js → mount-ui--ijs8pWT.js} +4 -4
  31. package/dist/shared/{pusher-BEl7Qn-8.js → pusher-ipHMJnO_.js} +1 -1
  32. package/dist/shared/{realtime-BG_t_ze7.js → realtime-Dk41VwKg.js} +71 -50
  33. package/dist/shared/{separator-DusFNTs-.js → separator-XDBsaWyw.js} +891 -785
  34. package/dist/shared/{shadow-root-CmYXiSRR.js → shadow-root-C5v-T8lQ.js} +1 -1
  35. package/dist/shared/styles-D3yMtaec.js +2 -0
  36. package/dist/shared/{useValueChanged-DQXLia-2.js → useValueChanged-CrzfD8l-.js} +15 -15
  37. package/dist/shared/{websocket-manager-BTRqNTB7.js → websocket-manager-DhLWh3Jr.js} +2 -2
  38. package/dist/solid.es.js +3 -3
  39. package/dist/svelte.es.js +3 -3
  40. package/dist/types/adapters/bridge.d.ts +9 -12
  41. package/dist/types/angular/index.d.ts +15 -5
  42. package/dist/types/core/api-client.d.ts +16 -17
  43. package/dist/types/core/comment-kit-core.d.ts +19 -11
  44. package/dist/types/core/local-demo.d.ts +1 -0
  45. package/dist/types/core/types.d.ts +68 -0
  46. package/dist/types/headless.d.ts +1 -1
  47. package/dist/types/index.d.ts +8 -4
  48. package/dist/types/qwik/index.d.ts +4 -1
  49. package/dist/vue.es.js +3 -3
  50. package/docs/api-reference.md +372 -0
  51. package/docs/local-demo.md +60 -0
  52. package/package.json +16 -6
  53. package/dist/shared/annotation-toolbar-pX17NLmJ.js +0 -1104
  54. package/dist/shared/clamp-CcFVX0vC.js +0 -55
  55. package/dist/shared/comment-drawing-canvas-CYu5SwRf.js +0 -126
  56. package/dist/shared/comment-kit-ui-D2j2gvnm.js +0 -16685
  57. package/dist/shared/comment-screenshot-annotator-BuojwviY.js +0 -137
  58. package/dist/shared/comment-screenshot-overlay-BZX0Vcb8.js +0 -144
  59. package/dist/shared/local-demo-context-BohlYbHt.js +0 -6
  60. package/dist/shared/resolveAriaLabelledBy-CIKpnjNJ.js +0 -669
  61. package/dist/shared/styles-D_FEJZ9G.js +0 -2
  62. package/dist/shared/useLabelableId-DGbfdMi_.js +0 -155
@@ -1,24 +1,30 @@
1
- import { a as e, i as t, m as n, n as r } from "./dom-Bhf4WFtY.js";
2
- import { t as i } from "./button-By0hGrJK.js";
3
- import { t as a } from "./createReactComponent-BZHeRbD0.js";
4
- import { n as o } from "./local-demo-context-BohlYbHt.js";
5
- import { _ as s, b as c, i as ee, n as te } from "./comment-kit-ui-D2j2gvnm.js";
1
+ import { a as e, i as t, m as n, n as r, o as i } from "./dom-Bhf4WFtY.js";
2
+ import { n as a } from "./dist-De294MVF.js";
3
+ import { t as o } from "./button-By0hGrJK.js";
4
+ import { t as s } from "./createReactComponent-BZHeRbD0.js";
5
+ import { R as c, n as ee, y as te } from "./comment-kit-ui-CzfdAZs2.js";
6
6
  import * as l from "react";
7
7
  import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
8
- var p = a("outline", "paperclip", "Paperclip", [["path", {
8
+ var ne = s("outline", "paperclip", "Paperclip", [["path", {
9
9
  d: "M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",
10
10
  key: "svg-0"
11
- }]]), m = ".ck-element-selector{z-index:calc(var(--z-ck-fab) - 1);pointer-events:none;position:fixed;inset:0}.ck-element-selector-outline,.ck-element-selector-mark{pointer-events:none;border-radius:4px;position:fixed}.ck-element-selector-outline{z-index:calc(var(--z-ck-fab) - 1);border:2px solid var(--primary);background-color:color-mix(in oklch, var(--primary) 8%, transparent);box-shadow:0 0 0 1px color-mix(in oklch, var(--background) 95%, transparent), 0 0 0 4px color-mix(in oklch, var(--primary) 18%, transparent)}.ck-element-selector-outline[data-state=selected]{background-color:color-mix(in oklch, var(--primary) 12%, transparent);border-style:solid}.ck-element-selector-outline[data-state=multi]{border-style:dashed;border-color:color-mix(in oklch, var(--primary) 70%, var(--foreground));background-color:color-mix(in oklch, var(--primary) 6%, transparent)}.ck-element-selector-outline[data-state=multi]:before{content:attr(data-multi-index);top:-10px;background:var(--primary);min-width:20px;height:20px;color:var(--primary-foreground,white);text-align:center;border-radius:999px;padding:0 6px;font:600 11px/20px ui-monospace,SF Mono,Menlo,monospace;position:absolute;inset-inline-start:-10px;box-shadow:0 1px 3px #00000040}.ck-element-selector-multibar{bottom:24px;z-index:calc(var(--z-ck-fab) + 1);border:1px solid var(--border);background-color:var(--popover);color:var(--popover-foreground);box-shadow:0 18px 30px -12px #00000047, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:999px;align-items:center;gap:8px;padding:6px 10px;font:13px/1 system-ui,sans-serif;display:inline-flex;position:fixed;inset-inline-start:50%;transform:translate(-50%)}.ck-element-selector-multibar-count{color:var(--popover-foreground);padding:0 4px}.ck-element-selector-marquee{z-index:calc(var(--z-ck-fab) - 1);border:1px dashed var(--primary);background-color:color-mix(in oklch, var(--primary) 12%, transparent);pointer-events:none;border-radius:4px;position:fixed}.ck-element-selector-context-menu{z-index:calc(var(--z-ck-fab) + 2);border:1px solid var(--border);background-color:var(--popover);min-width:200px;color:var(--popover-foreground);box-shadow:0 18px 30px -12px #0000004d, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:8px;margin:0;padding:4px;font:13px/1 system-ui,sans-serif;list-style:none;position:fixed}.ck-element-selector-context-menu li{list-style:none}.ck-element-selector-context-menu button{width:100%;color:inherit;text-align:left;cursor:pointer;font:inherit;background:0 0;border:0;border-radius:4px;padding:8px 10px}.ck-element-selector-context-menu button:hover,.ck-element-selector-context-menu button:focus-visible{background-color:color-mix(in oklch, var(--primary) 14%, transparent);outline:none}.ck-element-selector-mark{z-index:calc(var(--z-ck-fab) - 2);border:2px solid color-mix(in oklch, var(--primary) 78%, var(--foreground));box-shadow:inset 0 0 0 1px color-mix(in oklch, var(--background) 80%, transparent), 0 0 0 3px color-mix(in oklch, var(--primary) 14%, transparent)}.ck-element-selector-composer{z-index:var(--z-ck-fab);border:1px solid var(--border);background-color:var(--popover);width:min(28rem,100vw - 1rem);color:var(--popover-foreground);box-shadow:0 22px 42px -16px #00000052, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:8px;align-items:stretch;gap:.625rem;padding:.75rem;display:grid;position:fixed}.ck-element-selector-input-row{min-width:0}.ck-element-selector-composer .ck-input{border-radius:7px;width:100%;min-width:0;min-height:3rem;padding-inline:.875rem;font-size:.875rem;line-height:1.25rem}.ck-element-selector-actions{align-items:center;gap:.5rem;width:100%;display:flex}.ck-element-selector-actions .ck-button{min-height:2.375rem}.ck-element-selector-attach-action{gap:.375rem;margin-inline-end:auto}.ck-element-selector-grab-action{min-width:8.75rem}.ck-element-selector-action-icon{flex:none;width:.95rem;height:.95rem}.ck-element-selector-file-input{clip:rect(0 0 0 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.ck-element-selector-attachment{border:1px solid color-mix(in oklch, var(--border) 80%, transparent);background-color:color-mix(in oklch, var(--muted) 55%, transparent);border-radius:7px;align-items:center;gap:.625rem;width:100%;min-width:0;padding:.5rem;display:flex}.ck-element-selector-attachment-image{object-fit:cover;border-radius:6px;flex:none;width:2.5rem;height:2.5rem}.ck-element-selector-attachment-meta{flex:1;gap:.125rem;min-width:0;display:grid}.ck-element-selector-attachment-name,.ck-element-selector-attachment-path,.ck-element-selector-attachment-size{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ck-element-selector-attachment-name{color:var(--foreground);font-size:.75rem;font-weight:600;line-height:1rem}.ck-element-selector-attachment-path,.ck-element-selector-attachment-size{color:var(--muted-foreground);font-size:.6875rem;line-height:.875rem}.ck-element-selector-error{width:100%;color:var(--destructive);font-size:.75rem;line-height:1rem}@media (width<=420px){.ck-element-selector-actions{flex-wrap:wrap}.ck-element-selector-attach-action{margin-inline-end:0}.ck-element-selector-save-action,.ck-element-selector-grab-action{flex:auto}}", h = "data-commentkit-freeze", g = "\n*, *::before, *::after {\n animation-play-state: paused !important;\n transition: none !important;\n}\n", _ = 0, v = null, y = [];
12
- function b() {
13
- if (v || typeof document > "u") return;
11
+ }]]), re = s("outline", "x", "X", [["path", {
12
+ d: "M18 6l-12 12",
13
+ key: "svg-0"
14
+ }], ["path", {
15
+ d: "M6 6l12 12",
16
+ key: "svg-1"
17
+ }]]), p = ".ck-element-selector{z-index:calc(var(--z-ck-fab) - 1);pointer-events:none;position:fixed;inset:0}.ck-element-selector-outline,.ck-element-selector-mark{pointer-events:none;border-radius:4px;position:fixed}.ck-element-selector-outline{z-index:calc(var(--z-ck-fab) - 1);border:2px solid var(--primary);background-color:color-mix(in oklch, var(--primary) 8%, transparent);box-shadow:0 0 0 1px color-mix(in oklch, var(--background) 95%, transparent), 0 0 0 4px color-mix(in oklch, var(--primary) 18%, transparent)}.ck-element-selector-outline[data-state=selected]{background-color:color-mix(in oklch, var(--primary) 12%, transparent);border-style:solid}.ck-element-selector-outline[data-state=multi]{border-style:dashed;border-color:color-mix(in oklch, var(--primary) 70%, var(--foreground));background-color:color-mix(in oklch, var(--primary) 6%, transparent)}.ck-element-selector-outline[data-state=multi]:before{content:attr(data-multi-index);top:-10px;background:var(--primary);min-width:20px;height:20px;color:var(--primary-foreground,white);text-align:center;border-radius:999px;padding:0 6px;font:600 11px/20px ui-monospace,SF Mono,Menlo,monospace;position:absolute;inset-inline-start:-10px;box-shadow:0 1px 3px #00000040}.ck-element-selector-multibar{bottom:24px;z-index:calc(var(--z-ck-fab) + 1);border:1px solid var(--border);background-color:var(--popover);color:var(--popover-foreground);box-shadow:0 18px 30px -12px #00000047, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:999px;align-items:center;gap:8px;padding:6px 10px;font:13px/1 system-ui,sans-serif;display:inline-flex;position:fixed;inset-inline-start:50%;transform:translate(-50%)}.ck-element-selector-multibar-count{color:var(--popover-foreground);padding:0 4px}.ck-element-selector-marquee{z-index:calc(var(--z-ck-fab) - 1);border:1px dashed var(--primary);background-color:color-mix(in oklch, var(--primary) 12%, transparent);pointer-events:none;border-radius:4px;position:fixed}.ck-element-selector-context-menu{z-index:calc(var(--z-ck-fab) + 2);border:1px solid var(--border);background-color:var(--popover);min-width:200px;color:var(--popover-foreground);box-shadow:0 18px 30px -12px #0000004d, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:8px;margin:0;padding:4px;font:13px/1 system-ui,sans-serif;list-style:none;position:fixed}.ck-element-selector-context-menu li{list-style:none}.ck-element-selector-context-menu button{width:100%;color:inherit;text-align:left;cursor:pointer;font:inherit;background:0 0;border:0;border-radius:4px;padding:8px 10px}.ck-element-selector-context-menu button:hover,.ck-element-selector-context-menu button:focus-visible{background-color:color-mix(in oklch, var(--primary) 14%, transparent);outline:none}.ck-element-selector-mark{z-index:calc(var(--z-ck-fab) - 2);border:2px solid color-mix(in oklch, var(--primary) 78%, var(--foreground));box-shadow:inset 0 0 0 1px color-mix(in oklch, var(--background) 80%, transparent), 0 0 0 3px color-mix(in oklch, var(--primary) 14%, transparent)}.ck-element-selector-composer{z-index:var(--z-ck-fab);border:1px solid var(--border);background-color:var(--popover);width:min(28rem,100vw - 1rem);color:var(--popover-foreground);box-shadow:0 22px 42px -16px #00000052, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:8px;align-items:stretch;gap:.625rem;padding:.75rem;display:grid;position:fixed}.ck-element-selector-input-row{min-width:0}.ck-element-selector-composer .ck-input{border-radius:7px;width:100%;min-width:0;min-height:3rem;padding-inline:.875rem;font-size:.875rem;line-height:1.25rem}.ck-element-selector-actions{align-items:center;gap:.5rem;width:100%;display:flex}.ck-element-selector-actions .ck-button{min-height:2.375rem}.ck-element-selector-attach-action{gap:.375rem;margin-inline-end:auto}.ck-element-selector-grab-action{min-width:8.75rem}.ck-element-selector-action-icon{flex:none;width:.95rem;height:.95rem}.ck-element-selector-file-input{clip:rect(0 0 0 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.ck-element-selector-attachment{border:1px solid color-mix(in oklch, var(--border) 80%, transparent);background-color:color-mix(in oklch, var(--muted) 55%, transparent);border-radius:7px;align-items:center;gap:.625rem;width:100%;min-width:0;padding:.5rem;display:flex}.ck-element-selector-attachment-image{object-fit:cover;border-radius:6px;flex:none;width:2.5rem;height:2.5rem}.ck-element-selector-attachment-meta{flex:1;gap:.125rem;min-width:0;display:grid}.ck-element-selector-attachment-name,.ck-element-selector-attachment-path,.ck-element-selector-attachment-size{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ck-element-selector-attachment-name{color:var(--foreground);font-size:.75rem;font-weight:600;line-height:1rem}.ck-element-selector-attachment-path,.ck-element-selector-attachment-size{color:var(--muted-foreground);font-size:.6875rem;line-height:.875rem}.ck-element-selector-error{width:100%;color:var(--destructive);font-size:.75rem;line-height:1rem}@media (width<=420px){.ck-element-selector-actions{flex-wrap:wrap}.ck-element-selector-attach-action{margin-inline-end:0}.ck-element-selector-save-action,.ck-element-selector-grab-action{flex:auto}}", m = "data-commentkit-freeze", h = "\n*, *::before, *::after {\n animation-play-state: paused !important;\n transition: none !important;\n}\n", g = 0, _ = null, v = [];
18
+ function y() {
19
+ if (_ || typeof document > "u") return;
14
20
  let e = document.createElement("style");
15
- e.setAttribute(h, ""), e.textContent = g, document.head.appendChild(e), v = e;
21
+ e.setAttribute(m, ""), e.textContent = h, document.head.appendChild(e), _ = e;
16
22
  }
17
- function x() {
18
- v &&= (v.remove(), null);
23
+ function b() {
24
+ _ &&= (_.remove(), null);
19
25
  }
20
- function S() {
21
- typeof document < "u" && typeof document.getAnimations == "function" && (y = document.getAnimations().filter((e) => {
26
+ function x() {
27
+ typeof document < "u" && typeof document.getAnimations == "function" && (v = document.getAnimations().filter((e) => {
22
28
  if (e.playState !== "running") return !1;
23
29
  try {
24
30
  return e.pause(), !0;
@@ -27,63 +33,63 @@ function S() {
27
33
  }
28
34
  }));
29
35
  }
30
- function C() {
31
- for (let e of y) try {
36
+ function S() {
37
+ for (let e of v) try {
32
38
  e.play();
33
39
  } catch {}
34
- y = [];
40
+ v = [];
35
41
  }
36
- function ne() {
37
- _++, _ === 1 && (b(), S());
42
+ function ie() {
43
+ g++, g === 1 && (y(), x());
38
44
  let e = !1;
39
45
  return () => {
40
- e || (e = !0, _ = Math.max(0, _ - 1), _ === 0 && (x(), C()));
46
+ e || (e = !0, g = Math.max(0, g - 1), g === 0 && (b(), S()));
41
47
  };
42
48
  }
43
- var w = 448, re = 236, T = 8, E = .9, D = 1e3, O = 2147483600;
44
- function k(e) {
49
+ var C = 448, ae = 236, w = 8, T = .9, E = 1e3, D = 2147483600;
50
+ function O(e) {
45
51
  return typeof Element < "u" && e instanceof Element;
46
52
  }
47
- function A() {
53
+ function k() {
48
54
  let e = document.activeElement;
49
55
  for (; e?.shadowRoot?.activeElement;) e = e.shadowRoot.activeElement;
50
56
  return e;
51
57
  }
52
- function ie(e) {
58
+ function oe(e) {
53
59
  let t = typeof e.composedPath == "function" ? e.composedPath()[0] ?? e.target : e.target;
54
- if (!k(t)) return !1;
60
+ if (!O(t)) return !1;
55
61
  let n = t.tagName.toLowerCase();
56
62
  return n === "input" || n === "textarea" || n === "select" || t instanceof HTMLElement && t.isContentEditable;
57
63
  }
58
- function j(e) {
64
+ function A(e) {
59
65
  let t = e.getRootNode();
60
66
  return !!(e.closest("[data-commentkit], [data-commentkit-host], [data-commentkit-ui], .ck-root") || typeof ShadowRoot < "u" && t instanceof ShadowRoot && t.host.matches("[data-commentkit], [data-commentkit-host], [data-commentkit-ui]"));
61
67
  }
62
- function M(e, t = V(e)) {
68
+ function j(e, t = B(e)) {
63
69
  let n = e.tagName.toLowerCase();
64
- if (n === "html" || n === "body" || j(e) || e.closest("[data-commentkit-ignore], [data-react-grab-ignore]") || !se(t)) return !1;
70
+ if (n === "html" || n === "body" || A(e) || e.closest("[data-commentkit-ignore], [data-react-grab-ignore]") || !le(t)) return !1;
65
71
  let r = window.getComputedStyle(e);
66
72
  if (r.display === "none" || r.visibility === "hidden") return !1;
67
73
  let i = Number.parseFloat(r.opacity || "1");
68
74
  if (Number.isFinite(i) && i <= .01) return !1;
69
- let a = Number.parseInt(r.zIndex || "", 10), o = r.position === "fixed" || r.position === "absolute", s = t.width / Math.max(window.innerWidth, 1) >= E && t.height / Math.max(window.innerHeight, 1) >= E;
70
- return !(r.pointerEvents === "none" && r.position === "fixed" && Number.isFinite(a) && a >= O || s && o && (r.backgroundColor === "transparent" || r.backgroundColor === "rgba(0, 0, 0, 0)" || Number.isFinite(i) && i < .1 || Number.isFinite(a) && a > D));
75
+ let a = Number.parseInt(r.zIndex || "", 10), o = r.position === "fixed" || r.position === "absolute", s = t.width / Math.max(window.innerWidth, 1) >= T && t.height / Math.max(window.innerHeight, 1) >= T;
76
+ return !(r.pointerEvents === "none" && r.position === "fixed" && Number.isFinite(a) && a >= D || s && o && (r.backgroundColor === "transparent" || r.backgroundColor === "rgba(0, 0, 0, 0)" || Number.isFinite(i) && i < .1 || Number.isFinite(a) && a > E));
71
77
  }
72
- function N(e) {
78
+ function M(e) {
73
79
  return typeof e.composedPath == "function" ? e.composedPath() : e.target ? [e.target] : [];
74
80
  }
75
- function P(e) {
76
- return N(e).some((e) => k(e) && j(e));
81
+ function N(e) {
82
+ return M(e).some((e) => O(e) && A(e));
77
83
  }
78
- function F(e, t) {
84
+ function P(e, t) {
79
85
  if (typeof document.elementsFromPoint == "function") return document.elementsFromPoint(e, t);
80
86
  let n = document.elementFromPoint?.(e, t);
81
87
  return n ? [n] : [];
82
88
  }
83
- function I(e, t) {
84
- return F(e, t).find((e) => M(e)) ?? null;
89
+ function F(e, t) {
90
+ return P(e, t).find((e) => j(e)) ?? null;
85
91
  }
86
- function ae(e) {
92
+ function se(e) {
87
93
  let t = Math.min(e.startX, e.x), n = Math.min(e.startY, e.y), r = Math.abs(e.x - e.startX), i = Math.abs(e.y - e.startY);
88
94
  return {
89
95
  left: t,
@@ -94,27 +100,27 @@ function ae(e) {
94
100
  bottom: n + i
95
101
  };
96
102
  }
97
- function L(e, t) {
103
+ function I(e, t) {
98
104
  return !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom);
99
105
  }
100
- var R = 200, z = 5e3;
101
- function B(e) {
106
+ var L = 200, R = 5e3;
107
+ function z(e) {
102
108
  let t = window.getComputedStyle(e), n = (e) => e === "hidden" || e === "clip";
103
109
  return n(t.overflowX) || n(t.overflowY) || n(t.overflow);
104
110
  }
105
- function oe(e) {
111
+ function ce(e) {
106
112
  let t = [];
107
113
  if (typeof document > "u") return t;
108
114
  let n = 0, r = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, { acceptNode(r) {
109
- if (n >= z || t.length >= R) return NodeFilter.FILTER_REJECT;
115
+ if (n >= R || t.length >= L) return NodeFilter.FILTER_REJECT;
110
116
  n += 1;
111
- let i = r, a = V(i), o = se(a) && L(a, e);
112
- return !o && B(i) ? NodeFilter.FILTER_REJECT : o && M(i, a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
117
+ let i = r, a = B(i), o = le(a) && I(a, e);
118
+ return !o && z(i) ? NodeFilter.FILTER_REJECT : o && j(i, a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
113
119
  } }), i = r.nextNode();
114
- for (; i && (t.push(i), !(t.length >= R || n >= z));) i = r.nextNode();
120
+ for (; i && (t.push(i), !(t.length >= L || n >= R));) i = r.nextNode();
115
121
  return t;
116
122
  }
117
- function V(e) {
123
+ function B(e) {
118
124
  let t = e.getBoundingClientRect();
119
125
  return {
120
126
  top: t.top,
@@ -125,38 +131,38 @@ function V(e) {
125
131
  right: t.right
126
132
  };
127
133
  }
128
- function se(e) {
134
+ function le(e) {
129
135
  return e.width > 0 && e.height > 0;
130
136
  }
131
- function H(n) {
137
+ function V(n) {
132
138
  return {
133
139
  element: n,
134
140
  selector: t(n),
135
141
  xpath: e(n),
136
- rect: V(n)
142
+ rect: B(n)
137
143
  };
138
144
  }
139
- function U(e, t, n) {
145
+ function H(e, t, n) {
140
146
  return Math.min(n, Math.max(t, e));
141
147
  }
142
- function W() {
148
+ function U() {
143
149
  return {
144
150
  width: Math.max(window.innerWidth || 0, 16),
145
151
  height: Math.max(window.innerHeight || 0, 16)
146
152
  };
147
153
  }
148
- function ce(e) {
149
- let t = W(), r = U(e.rect.left + e.rect.width / 2, 0, t.width), i = U(e.rect.top + e.rect.height / 2, 0, t.height);
154
+ function ue(e) {
155
+ let t = U(), r = H(e.rect.left + e.rect.width / 2, 0, t.width), i = H(e.rect.top + e.rect.height / 2, 0, t.height);
150
156
  return {
151
157
  ...n(r, i, t),
152
158
  element: e.selector,
153
159
  xpath: e.xpath
154
160
  };
155
161
  }
156
- function le(e) {
162
+ function de(e) {
157
163
  return typeof e != "number" || !Number.isFinite(e) ? "" : e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
158
164
  }
159
- function ue(e, t) {
165
+ function W(e, t) {
160
166
  let n = e.path;
161
167
  if (typeof n == "string" && n.trim()) return {
162
168
  path: n.trim(),
@@ -175,8 +181,8 @@ function ue(e, t) {
175
181
  pathSource: "browser-fallback"
176
182
  };
177
183
  }
178
- function de(e, t) {
179
- let { path: n, pathSource: r } = ue(e, t);
184
+ function fe(e, t) {
185
+ let { path: n, pathSource: r } = W(e, t);
180
186
  return {
181
187
  name: e.name,
182
188
  path: n,
@@ -190,16 +196,16 @@ function de(e, t) {
190
196
  function G(e) {
191
197
  e && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
192
198
  }
193
- async function fe(e, t) {
199
+ async function pe(e, t) {
194
200
  try {
195
201
  if (!navigator.clipboard?.writeText) throw Error("clipboard unavailable");
196
202
  await navigator.clipboard.writeText(e);
197
203
  try {
198
- c.success(`${t} copied`);
204
+ a.success(`${t} copied`);
199
205
  } catch {}
200
206
  } catch {
201
207
  try {
202
- c.error(`Could not copy ${t.toLowerCase()}`);
208
+ a.error(`Could not copy ${t.toLowerCase()}`);
203
209
  } catch {}
204
210
  }
205
211
  }
@@ -211,37 +217,37 @@ function K(e) {
211
217
  height: e.height
212
218
  };
213
219
  }
214
- function pe(e, t = re) {
215
- let n = W(), r = Math.max(T, n.width - w - T), i = U(e.left, T, r), a = e.bottom + T, o = e.top - t - T;
220
+ function me(e, t = ae) {
221
+ let n = U(), r = Math.max(w, n.width - C - w), i = H(e.left, w, r), a = e.bottom + w, o = e.top - t - w;
216
222
  return {
217
223
  left: i,
218
- top: a + t <= n.height - T ? a : U(o, T, n.height - t - T)
224
+ top: a + t <= n.height - w ? a : H(o, w, n.height - t - w)
219
225
  };
220
226
  }
221
- var me = 220, q = 200;
222
- function he(e) {
223
- let t = W();
227
+ var he = 220, ge = 200;
228
+ function _e(e) {
229
+ let t = U();
224
230
  return {
225
- left: U(e.x, T, Math.max(T, t.width - me - T)),
226
- top: U(e.y, T, Math.max(T, t.height - q - T))
231
+ left: H(e.x, w, Math.max(w, t.width - he - w)),
232
+ top: H(e.y, w, Math.max(w, t.height - ge - w))
227
233
  };
228
234
  }
229
- function ge(e) {
235
+ function ve(e) {
230
236
  return e.status === "open" && !!(e.position.element || e.position.xpath);
231
237
  }
232
- function _e(e) {
238
+ function ye(e) {
233
239
  return e.flatMap((e) => {
234
- if (!ge(e)) return [];
240
+ if (!ve(e)) return [];
235
241
  let t = r(e.position.element ?? "", e.position.xpath);
236
242
  if (!t) return [];
237
- let n = V(t);
238
- return M(t, n) ? [{
243
+ let n = B(t);
244
+ return j(t, n) ? [{
239
245
  id: e.id,
240
246
  rect: n
241
247
  }] : [];
242
248
  });
243
249
  }
244
- function ve(e) {
250
+ function be(e) {
245
251
  let [t, n] = l.useState(0);
246
252
  return l.useEffect(() => {
247
253
  if (!e) return;
@@ -267,59 +273,59 @@ function ve(e) {
267
273
  };
268
274
  }, [e]), t;
269
275
  }
270
- var ye = l.memo(function({ core: n, state: r, active: a }) {
271
- let c = o(), [m, h] = l.useState(null), [g, _] = l.useState(null), [v, y] = l.useState([]), [b, x] = l.useState(null), [S, C] = l.useState(null), [w, T] = l.useState(""), [E, D] = l.useState(null), [O, k] = l.useState(!1), [j, M] = l.useState(!1), [N, F] = l.useState(null), L = l.useRef(null), R = l.useRef(null), z = l.useRef(null), B = l.useRef(null), [se, U] = l.useState(re), W = r.comments.some(ge), ue = ve(a || W || !!g || v.length > 0), me = l.useRef(null), q = l.useRef([]), ye = l.useRef(""), J = l.useRef(null);
276
+ var xe = l.memo(function({ core: n, state: r, active: a }) {
277
+ let s = c(), [p, m] = l.useState(null), [h, g] = l.useState(null), [_, v] = l.useState([]), [y, b] = l.useState(null), [x, S] = l.useState(null), [C, w] = l.useState(""), [T, E] = l.useState(null), [D, O] = l.useState(!1), [A, j] = l.useState(!1), [M, P] = l.useState(null), I = l.useRef(null), L = l.useRef(null), R = l.useRef(null), z = l.useRef(null), [le, H] = l.useState(ae), U = i().path, W = l.useMemo(() => r.comments.filter((e) => e.page?.path === U), [r.comments, U]), he = W.some(ve), ge = be(a || he || !!h || _.length > 0), xe = l.useRef(null), q = l.useRef([]), Se = l.useRef(""), Ce = l.useRef(null);
272
278
  l.useEffect(() => {
273
- me.current = g?.element ?? m?.element ?? null;
274
- }, [m, g]), l.useEffect(() => {
275
- q.current = v;
276
- }, [v]), l.useEffect(() => {
277
- ye.current = w;
278
- }, [w]), l.useEffect(() => {
279
- J.current = E;
280
- }, [E]);
281
- let be = l.useMemo(() => _e(r.comments), [r.comments, ue]);
279
+ xe.current = h?.element ?? p?.element ?? null;
280
+ }, [p, h]), l.useEffect(() => {
281
+ q.current = _;
282
+ }, [_]), l.useEffect(() => {
283
+ Se.current = C;
284
+ }, [C]), l.useEffect(() => {
285
+ Ce.current = T;
286
+ }, [T]);
287
+ let we = l.useMemo(() => ye(W), [W, ge]);
282
288
  l.useEffect(() => {
283
- a || (h(null), _(null), y([]), C(null), T(""), D((e) => (G(e?.previewUrl), null)), k(!1), F(null), x(null), Q.current = null, $.current = !1);
289
+ a || (m(null), g(null), v([]), S(null), w(""), E((e) => (G(e?.previewUrl), null)), O(!1), P(null), b(null), Z.current = null, Q.current = !1);
284
290
  }, [a]), l.useEffect(() => () => {
285
- G(J.current?.previewUrl);
291
+ G(Ce.current?.previewUrl);
286
292
  }, []), l.useEffect(() => {
287
293
  if (!a) return;
288
294
  let e = document.body.style.cursor;
289
295
  document.body.style.cursor = "crosshair";
290
- let t = ne();
296
+ let t = ie();
291
297
  return () => {
292
298
  document.body.style.cursor = e, t();
293
299
  };
294
300
  }, [a]);
295
- let Y = a && !!g;
301
+ let J = a && !!h;
296
302
  l.useEffect(() => {
297
- if (!Y) return;
298
- let e = A();
299
- return e instanceof HTMLElement && !L.current?.contains(e) && (B.current = e), L.current?.querySelector("[data-ck-composer-input]")?.focus({ preventScroll: !0 }), () => {
300
- let e = B.current;
301
- B.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
303
+ if (!J) return;
304
+ let e = k();
305
+ return e instanceof HTMLElement && !I.current?.contains(e) && (z.current = e), I.current?.querySelector("[data-ck-composer-input]")?.focus({ preventScroll: !0 }), () => {
306
+ let e = z.current;
307
+ z.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
302
308
  };
303
- }, [Y]);
304
- let xe = l.useRef(r.isAuthenticated);
309
+ }, [J]);
310
+ let Te = l.useRef(r.isAuthenticated);
305
311
  l.useEffect(() => {
306
- let e = !xe.current && r.isAuthenticated;
307
- if (xe.current = r.isAuthenticated, !e || !Y || !w.trim()) return;
308
- let t = L.current?.querySelector("[data-ck-composer-input]");
312
+ let e = !Te.current && r.isAuthenticated;
313
+ if (Te.current = r.isAuthenticated, !e || !J || !C.trim()) return;
314
+ let t = I.current?.querySelector("[data-ck-composer-input]");
309
315
  t?.focus({ preventScroll: !0 });
310
316
  let n = t?.value.length ?? 0;
311
- t?.setSelectionRange?.(n, n), F((e) => e && e.startsWith("Sign in to save comments") ? null : e);
317
+ t?.setSelectionRange?.(n, n), P((e) => e && e.startsWith("Sign in to save comments") ? null : e);
312
318
  }, [
313
319
  r.isAuthenticated,
314
- Y,
315
- w
320
+ J,
321
+ C
316
322
  ]), l.useLayoutEffect(() => {
317
- if (!Y) return;
318
- let e = L.current;
323
+ if (!J) return;
324
+ let e = I.current;
319
325
  if (!e) return;
320
326
  let t = () => {
321
327
  let t = e.getBoundingClientRect().height;
322
- t > 0 && U((e) => Math.abs(e - t) > 1 ? t : e);
328
+ t > 0 && H((e) => Math.abs(e - t) > 1 ? t : e);
323
329
  };
324
330
  t();
325
331
  let n = null;
@@ -330,30 +336,30 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
330
336
  }
331
337
  return () => n?.disconnect();
332
338
  }, [
333
- Y,
334
- E,
335
- N
339
+ J,
340
+ T,
341
+ M
336
342
  ]), l.useEffect(() => {
337
343
  if (!a) return;
338
344
  let e = () => {
339
- _((e) => e && {
345
+ g((e) => e && {
340
346
  ...e,
341
- rect: V(e.element)
342
- }), h((e) => e && {
347
+ rect: B(e.element)
348
+ }), m((e) => e && {
343
349
  ...e,
344
- rect: V(e.element)
345
- }), y((e) => e.map((e) => ({
350
+ rect: B(e.element)
351
+ }), v((e) => e.map((e) => ({
346
352
  ...e,
347
- rect: V(e.element)
353
+ rect: B(e.element)
348
354
  })));
349
355
  };
350
356
  return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
351
357
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
352
358
  };
353
359
  }, [a]);
354
- let X = l.useCallback(async (e, t, r) => {
355
- if (!e || j) return !1;
356
- M(!0), F(null);
360
+ let Y = l.useCallback(async (e, t, r) => {
361
+ if (!e || A) return !1;
362
+ j(!0), P(null);
357
363
  try {
358
364
  let i = t?.trim(), a = r ? [{
359
365
  name: r.name,
@@ -366,45 +372,45 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
366
372
  ...i ? { comment: i } : {},
367
373
  ...a.length > 0 ? { attachments: a } : {}
368
374
  } : void 0, s = o ? await n.grabElement(e, o) : await n.grabElement(e);
369
- return M(!1), s ? (_(null), h(null), T(""), D((e) => (G(e?.previewUrl), null)), n.setTool(null), !0) : (F("Could not grab this element."), !1);
375
+ return j(!1), s ? (g(null), m(null), w(""), E((e) => (G(e?.previewUrl), null)), n.setTool(null), !0) : (P("Could not grab this element."), !1);
370
376
  } catch {
371
- return M(!1), F("Could not copy this element for the agent."), !1;
377
+ return j(!1), P("Could not copy this element for the agent."), !1;
372
378
  }
373
- }, [n, j]), Z = l.useCallback(async (e) => {
374
- if (e.length === 0 || j) return !1;
375
- M(!0), F(null);
379
+ }, [n, A]), X = l.useCallback(async (e) => {
380
+ if (e.length === 0 || A) return !1;
381
+ j(!0), P(null);
376
382
  try {
377
383
  let t = await n.grabElements(e);
378
- return M(!1), t ? (y([]), _(null), h(null), T(""), D((e) => (G(e?.previewUrl), null)), n.setTool(null), !0) : (F("Could not grab these elements."), !1);
384
+ return j(!1), t ? (v([]), g(null), m(null), w(""), E((e) => (G(e?.previewUrl), null)), n.setTool(null), !0) : (P("Could not grab these elements."), !1);
379
385
  } catch {
380
- return M(!1), F("Could not copy these elements for the agent."), !1;
386
+ return j(!1), P("Could not copy these elements for the agent."), !1;
381
387
  }
382
- }, [n, j]), Se = l.useCallback(() => {
388
+ }, [n, A]), Ee = l.useCallback(() => {
383
389
  let e = q.current.map((e) => e.element);
384
- Z(e);
385
- }, [Z]), Ce = l.useCallback(() => {
386
- y([]);
387
- }, []), Q = l.useRef(null), $ = l.useRef(!1), we = l.useRef(null);
388
- we.current = b;
389
- let Te = l.useRef(null);
390
- Te.current = S, l.useEffect(() => {
391
- if (!S) return;
390
+ X(e);
391
+ }, [X]), De = l.useCallback(() => {
392
+ v([]);
393
+ }, []), Z = l.useRef(null), Q = l.useRef(!1), $ = l.useRef(null);
394
+ $.current = y;
395
+ let Oe = l.useRef(null);
396
+ Oe.current = x, l.useEffect(() => {
397
+ if (!x) return;
392
398
  let e = n.blockEscape();
393
399
  return () => e();
394
- }, [S, n]), l.useEffect(() => {
395
- if (!S) return;
396
- let e = A();
397
- return e instanceof HTMLElement && !z.current?.contains(e) && (B.current = e), z.current?.querySelector("[role=\"menuitem\"]")?.focus({ preventScroll: !0 }), () => {
398
- let e = B.current;
399
- B.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
400
+ }, [x, n]), l.useEffect(() => {
401
+ if (!x) return;
402
+ let e = k();
403
+ return e instanceof HTMLElement && !R.current?.contains(e) && (z.current = e), R.current?.querySelector("[role=\"menuitem\"]")?.focus({ preventScroll: !0 }), () => {
404
+ let e = z.current;
405
+ z.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
400
406
  };
401
- }, [S]);
402
- let Ee = l.useCallback((e) => {
403
- let t = z.current;
407
+ }, [x]);
408
+ let ke = l.useCallback((e) => {
409
+ let t = R.current;
404
410
  if (!t) return;
405
411
  let n = Array.from(t.querySelectorAll("[role=\"menuitem\"]"));
406
412
  if (n.length === 0) return;
407
- let r = A(), i = n.findIndex((e) => e === r), a = (e) => {
413
+ let r = k(), i = n.findIndex((e) => e === r), a = (e) => {
408
414
  n[(e + n.length) % n.length]?.focus({ preventScroll: !0 });
409
415
  };
410
416
  switch (e.key) {
@@ -421,20 +427,20 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
421
427
  e.preventDefault(), e.stopPropagation(), a(n.length - 1);
422
428
  break;
423
429
  case "Enter":
424
- case " ": e.preventDefault(), e.stopPropagation(), A()?.click();
430
+ case " ": e.preventDefault(), e.stopPropagation(), k()?.click();
425
431
  }
426
432
  }, []);
427
433
  l.useEffect(() => {
428
434
  if (!a) return;
429
435
  let r = (e) => {
430
- e.button !== 0 || P(e) || g || (C(null), Q.current = {
436
+ e.button !== 0 || N(e) || h || (S(null), Z.current = {
431
437
  x: e.clientX,
432
438
  y: e.clientY
433
- }, $.current = !1);
439
+ }, Q.current = !1);
434
440
  }, i = (n) => {
435
- if (P(n)) return;
436
- let r = I(n.clientX, n.clientY);
437
- r && (n.preventDefault(), n.stopPropagation(), C({
441
+ if (N(n)) return;
442
+ let r = F(n.clientX, n.clientY);
443
+ r && (n.preventDefault(), n.stopPropagation(), S({
438
444
  element: r,
439
445
  selector: t(r),
440
446
  xpath: e(r),
@@ -444,16 +450,16 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
444
450
  }, o = null, s = null, c = () => {
445
451
  o &&= (clearTimeout(o), null), s = null;
446
452
  }, ee = (n) => {
447
- if (P(n) || n.touches.length !== 1) return;
453
+ if (N(n) || n.touches.length !== 1) return;
448
454
  let r = n.touches[0];
449
455
  if (!r) return;
450
- let i = I(r.clientX, r.clientY);
456
+ let i = F(r.clientX, r.clientY);
451
457
  i && (s = {
452
458
  x: r.clientX,
453
459
  y: r.clientY,
454
460
  element: i
455
461
  }, o = setTimeout(() => {
456
- s && (C({
462
+ s && (S({
457
463
  element: s.element,
458
464
  selector: t(s.element),
459
465
  xpath: e(s.element),
@@ -470,86 +476,86 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
470
476
  }, l = () => {
471
477
  c();
472
478
  }, u = (e) => {
473
- if (P(e)) return;
474
- let t = Q.current;
479
+ if (N(e)) return;
480
+ let t = Z.current;
475
481
  if (t) {
476
- if (e.pointerType === "mouse" && !(e.buttons & 1)) Q.current = null, $.current = !1, x(null);
482
+ if (e.pointerType === "mouse" && !(e.buttons & 1)) Z.current = null, Q.current = !1, b(null);
477
483
  else {
478
484
  let n = e.clientX - t.x, r = e.clientY - t.y;
479
- if (we.current || Math.abs(n) > 6 || Math.abs(r) > 6) {
480
- $.current = !0, x({
485
+ if ($.current || Math.abs(n) > 6 || Math.abs(r) > 6) {
486
+ Q.current = !0, b({
481
487
  startX: t.x,
482
488
  startY: t.y,
483
489
  x: e.clientX,
484
490
  y: e.clientY
485
- }), h(null);
491
+ }), m(null);
486
492
  return;
487
493
  }
488
494
  }
489
495
  }
490
- if (g) return;
491
- let n = I(e.clientX, e.clientY);
492
- h(n ? H(n) : null);
496
+ if (h) return;
497
+ let n = F(e.clientX, e.clientY);
498
+ m(n ? V(n) : null);
493
499
  }, d = () => {
494
- Q.current = null, $.current = !1, x(null);
500
+ Z.current = null, Q.current = !1, b(null);
495
501
  }, f = (e) => {
496
- let t = Q.current;
497
- Q.current = null;
498
- let n = we.current;
502
+ let t = Z.current;
503
+ Z.current = null;
504
+ let n = $.current;
499
505
  if (!t || !n) return;
500
- let r = ae({
506
+ let r = se({
501
507
  ...n,
502
508
  x: e.clientX,
503
509
  y: e.clientY
504
510
  });
505
511
  if (r.width < 6 || r.height < 6) {
506
- x(null);
512
+ b(null);
507
513
  return;
508
514
  }
509
- let i = oe(r);
515
+ let i = ce(r);
510
516
  if (i.length > 0) {
511
- let e = i.map(H);
512
- y((t) => {
517
+ let e = i.map(V);
518
+ v((t) => {
513
519
  let n = new Set(t.map((e) => e.element)), r = [...t];
514
520
  for (let t of e) n.has(t.element) || r.push(t);
515
521
  return r;
516
522
  });
517
523
  }
518
- x(null);
519
- }, p = (e) => {
520
- if (P(e)) return;
521
- if ($.current) {
522
- $.current = !1, e.preventDefault(), e.stopPropagation();
524
+ b(null);
525
+ }, ne = (e) => {
526
+ if (N(e)) return;
527
+ if (Q.current) {
528
+ Q.current = !1, e.preventDefault(), e.stopPropagation();
523
529
  return;
524
530
  }
525
531
  e.preventDefault(), e.stopPropagation();
526
- let t = I(e.clientX, e.clientY);
527
- g && !e.shiftKey ? (_(null), h(null), T(""), D((e) => (G(e?.previewUrl), null)), F(null)) : t && (e.shiftKey ? (y((e) => e.some((e) => e.element === t) ? e.filter((e) => e.element !== t) : [...g && !e.some((e) => e.element === g.element) ? [...e, g] : e, H(t)]), h(null), _(null), T(""), D((e) => (G(e?.previewUrl), null)), F(null)) : (_(H(t)), h(null), T(""), D((e) => (G(e?.previewUrl), null)), F(null)));
528
- }, m = (e) => {
532
+ let t = F(e.clientX, e.clientY);
533
+ h && !e.shiftKey ? (g(null), m(null), w(""), E((e) => (G(e?.previewUrl), null)), P(null)) : t && (e.shiftKey ? (v((e) => e.some((e) => e.element === t) ? e.filter((e) => e.element !== t) : [...h && !e.some((e) => e.element === h.element) ? [...e, h] : e, V(t)]), m(null), g(null), w(""), E((e) => (G(e?.previewUrl), null)), P(null)) : (g(V(t)), m(null), w(""), E((e) => (G(e?.previewUrl), null)), P(null)));
534
+ }, re = (e) => {
529
535
  if (e.key === "Escape") {
530
536
  if (e.isComposing) return;
531
- if (Te.current) {
532
- e.preventDefault(), e.stopPropagation(), C(null);
537
+ if (Oe.current) {
538
+ e.preventDefault(), e.stopPropagation(), S(null);
533
539
  return;
534
540
  }
535
- e.preventDefault(), e.stopPropagation(), _(null), h(null), T(""), D((e) => (G(e?.previewUrl), null)), F(null), n.setTool(null);
541
+ e.preventDefault(), e.stopPropagation(), g(null), m(null), w(""), E((e) => (G(e?.previewUrl), null)), P(null), n.setTool(null);
536
542
  return;
537
543
  }
538
- if (!e.metaKey && !e.ctrlKey || e.shiftKey || e.altKey || e.key !== "c" && e.key !== "C" && e.code !== "KeyC" || ie(e)) return;
544
+ if (!e.metaKey && !e.ctrlKey || e.shiftKey || e.altKey || e.key !== "c" && e.key !== "C" && e.code !== "KeyC" || oe(e)) return;
539
545
  let t = typeof window < "u" ? window.getSelection() : null;
540
546
  if (t && !t.isCollapsed && t.toString().length > 0) return;
541
547
  let r = q.current;
542
548
  if (r.length > 0) {
543
- e.preventDefault(), e.stopPropagation(), Z(r.map((e) => e.element));
549
+ e.preventDefault(), e.stopPropagation(), X(r.map((e) => e.element));
544
550
  return;
545
551
  }
546
- let i = me.current;
552
+ let i = xe.current;
547
553
  if (!i) return;
548
554
  e.preventDefault(), e.stopPropagation();
549
- let a = g?.element === i;
550
- X(i, a ? ye.current : void 0, a ? J.current : null);
555
+ let a = h?.element === i;
556
+ Y(i, a ? Se.current : void 0, a ? Ce.current : null);
551
557
  };
552
- return document.addEventListener("pointerdown", r, !0), document.addEventListener("pointermove", u, !0), document.addEventListener("pointerup", f, !0), document.addEventListener("pointercancel", d, !0), document.addEventListener("click", p, !0), document.addEventListener("contextmenu", i, !0), document.addEventListener("touchstart", ee, {
558
+ return document.addEventListener("pointerdown", r, !0), document.addEventListener("pointermove", u, !0), document.addEventListener("pointerup", f, !0), document.addEventListener("pointercancel", d, !0), document.addEventListener("click", ne, !0), document.addEventListener("contextmenu", i, !0), document.addEventListener("touchstart", ee, {
553
559
  capture: !0,
554
560
  passive: !0
555
561
  }), document.addEventListener("touchmove", te, {
@@ -561,101 +567,101 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
561
567
  }), document.addEventListener("touchcancel", l, {
562
568
  capture: !0,
563
569
  passive: !0
564
- }), window.addEventListener("keydown", m, !0), () => {
565
- document.removeEventListener("pointerdown", r, !0), document.removeEventListener("pointermove", u, !0), document.removeEventListener("pointerup", f, !0), document.removeEventListener("pointercancel", d, !0), document.removeEventListener("click", p, !0), document.removeEventListener("contextmenu", i, !0), document.removeEventListener("touchstart", ee, !0), document.removeEventListener("touchmove", te, !0), document.removeEventListener("touchend", l, !0), document.removeEventListener("touchcancel", l, !0), window.removeEventListener("keydown", m, !0), c();
570
+ }), window.addEventListener("keydown", re, !0), () => {
571
+ document.removeEventListener("pointerdown", r, !0), document.removeEventListener("pointermove", u, !0), document.removeEventListener("pointerup", f, !0), document.removeEventListener("pointercancel", d, !0), document.removeEventListener("click", ne, !0), document.removeEventListener("contextmenu", i, !0), document.removeEventListener("touchstart", ee, !0), document.removeEventListener("touchmove", te, !0), document.removeEventListener("touchend", l, !0), document.removeEventListener("touchcancel", l, !0), window.removeEventListener("keydown", re, !0), c();
566
572
  };
567
573
  }, [
568
574
  a,
569
575
  n,
576
+ Y,
570
577
  X,
571
- Z,
572
- g
578
+ h
573
579
  ]);
574
- let De = l.useCallback(async (e) => {
580
+ let Ae = l.useCallback(async (e) => {
575
581
  e.preventDefault();
576
- let t = w.trim();
577
- if (g && t && !O) {
578
- if (!r.currentUser) F("Sign in to save comments. You can still use Grab for agent without signing in."), n.toggleLoginModal();
582
+ let t = C.trim();
583
+ if (h && t && !D) {
584
+ if (!r.currentUser) P("Sign in to save comments. You can still use Grab for agent without signing in."), n.toggleLoginModal();
579
585
  else {
580
- k(!0), F(null);
586
+ O(!0), P(null);
581
587
  try {
582
- await n.createComment("pin", t, ce(g)), k(!1), _(null), T(""), D((e) => (G(e?.previewUrl), null)), n.setTool(null);
588
+ await n.createComment("pin", t, ue(h)), O(!1), g(null), w(""), E((e) => (G(e?.previewUrl), null)), n.setTool(null);
583
589
  } catch {
584
- k(!1), F("Could not save this comment. Try again.");
590
+ O(!1), P("Could not save this comment. Try again.");
585
591
  }
586
592
  }
587
593
  }
588
594
  }, [
589
- w,
595
+ C,
590
596
  n,
591
- O,
592
- g,
597
+ D,
598
+ h,
593
599
  r.currentUser
594
- ]), Oe = l.useCallback(() => {
595
- X(g?.element ?? null, w, E);
600
+ ]), je = l.useCallback(() => {
601
+ Y(h?.element ?? null, C, T);
596
602
  }, [
597
- E,
598
- w,
599
- X,
600
- g
601
- ]), ke = l.useCallback(() => {
602
- R.current?.click();
603
- }, []), Ae = l.useCallback((e) => {
603
+ T,
604
+ C,
605
+ Y,
606
+ h
607
+ ]), Me = l.useCallback(() => {
608
+ L.current?.click();
609
+ }, []), Ne = l.useCallback((e) => {
604
610
  let t = e.currentTarget, n = t.files?.[0] ?? null;
605
- D((e) => (G(e?.previewUrl), n ? de(n, t) : null)), t.value = "";
606
- }, []), je = l.useCallback(() => {
607
- D((e) => (G(e?.previewUrl), null));
608
- }, []), Me = l.useMemo(() => te(), []);
609
- return !a && be.length === 0 ? null : /* @__PURE__ */ f("div", {
611
+ E((e) => (G(e?.previewUrl), n ? fe(n, t) : null)), t.value = "";
612
+ }, []), Pe = l.useCallback(() => {
613
+ E((e) => (G(e?.previewUrl), null));
614
+ }, []), Fe = l.useMemo(() => ee(), []);
615
+ return !a && we.length === 0 ? null : /* @__PURE__ */ f("div", {
610
616
  className: "ck-element-selector",
611
617
  "data-testid": "ck-element-selector",
612
618
  children: [
613
- be.map((e) => /* @__PURE__ */ d("div", {
619
+ we.map((e) => /* @__PURE__ */ d("div", {
614
620
  "aria-hidden": "true",
615
621
  className: "ck-element-selector-mark",
616
622
  "data-comment-id": e.id,
617
623
  style: K(e.rect)
618
624
  }, e.id)),
619
- a && m && !b && /* @__PURE__ */ d("div", {
625
+ a && p && !y && /* @__PURE__ */ d("div", {
620
626
  "aria-hidden": "true",
621
627
  className: "ck-element-selector-outline",
622
628
  "data-state": "hover",
623
- style: K(m.rect)
629
+ style: K(p.rect)
624
630
  }),
625
- a && b && /* @__PURE__ */ d("div", {
631
+ a && y && /* @__PURE__ */ d("div", {
626
632
  "aria-hidden": "true",
627
633
  className: "ck-element-selector-marquee",
628
634
  "data-testid": "ck-element-selector-marquee",
629
635
  style: {
630
- left: Math.min(b.startX, b.x),
631
- top: Math.min(b.startY, b.y),
632
- width: Math.abs(b.x - b.startX),
633
- height: Math.abs(b.y - b.startY)
636
+ left: Math.min(y.startX, y.x),
637
+ top: Math.min(y.startY, y.y),
638
+ width: Math.abs(y.x - y.startX),
639
+ height: Math.abs(y.y - y.startY)
634
640
  }
635
641
  }),
636
- a && v.map((e, t) => /* @__PURE__ */ d("div", {
642
+ a && _.map((e, t) => /* @__PURE__ */ d("div", {
637
643
  "aria-hidden": "true",
638
644
  className: "ck-element-selector-outline",
639
645
  "data-state": "multi",
640
646
  "data-multi-index": t + 1,
641
647
  style: K(e.rect)
642
648
  }, `multi-${t}-${e.selector}-${e.xpath}`)),
643
- a && S && /* @__PURE__ */ f("ul", {
644
- ref: z,
649
+ a && x && /* @__PURE__ */ f("ul", {
650
+ ref: R,
645
651
  className: "ck-element-selector-context-menu",
646
652
  "data-testid": "ck-element-selector-context-menu",
647
653
  role: "menu",
648
654
  "aria-label": "Element actions",
649
- onKeyDown: Ee,
650
- style: he(S),
655
+ onKeyDown: ke,
656
+ style: _e(x),
651
657
  children: [
652
658
  /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
653
659
  type: "button",
654
660
  role: "menuitem",
655
661
  "data-testid": "ck-context-menu-grab",
656
662
  onClick: () => {
657
- let e = S.element;
658
- C(null), X(e);
663
+ let e = x.element;
664
+ S(null), Y(e);
659
665
  },
660
666
  children: "Grab for agent"
661
667
  }) }),
@@ -664,8 +670,8 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
664
670
  role: "menuitem",
665
671
  "data-testid": "ck-context-menu-comment",
666
672
  onClick: () => {
667
- let e = H(S.element);
668
- C(null), _(e);
673
+ let e = V(x.element);
674
+ S(null), g(e);
669
675
  },
670
676
  children: "Add comment"
671
677
  }) }),
@@ -674,8 +680,8 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
674
680
  role: "menuitem",
675
681
  "data-testid": "ck-context-menu-copy-selector",
676
682
  onClick: () => {
677
- let e = S.selector;
678
- C(null), fe(e, "CSS selector");
683
+ let e = x.selector;
684
+ S(null), pe(e, "CSS selector");
679
685
  },
680
686
  children: "Copy CSS selector"
681
687
  }) }),
@@ -684,8 +690,8 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
684
690
  role: "menuitem",
685
691
  "data-testid": "ck-context-menu-copy-xpath",
686
692
  onClick: () => {
687
- let e = S.xpath;
688
- C(null), fe(e, "XPath");
693
+ let e = x.xpath;
694
+ S(null), pe(e, "XPath");
689
695
  },
690
696
  children: "Copy XPath"
691
697
  }) }),
@@ -694,106 +700,106 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
694
700
  role: "menuitem",
695
701
  "data-testid": "ck-context-menu-inspect",
696
702
  onClick: () => {
697
- console.log("[CommentKit] inspect", S.element), C(null);
703
+ console.log("[CommentKit] inspect", x.element), S(null);
698
704
  },
699
705
  children: "Inspect (log to console)"
700
706
  }) })
701
707
  ]
702
708
  }),
703
- a && v.length > 0 && /* @__PURE__ */ f("div", {
709
+ a && _.length > 0 && /* @__PURE__ */ f("div", {
704
710
  className: "ck-element-selector-multibar",
705
711
  "data-testid": "ck-element-selector-multibar",
706
712
  children: [
707
713
  /* @__PURE__ */ f("span", {
708
714
  className: "ck-element-selector-multibar-count",
709
- children: [v.length, " selected"]
715
+ children: [_.length, " selected"]
710
716
  }),
711
- /* @__PURE__ */ d(i, {
717
+ /* @__PURE__ */ d(o, {
712
718
  type: "button",
713
719
  size: "sm",
714
- onClick: Se,
715
- disabled: j,
720
+ onClick: Ee,
721
+ disabled: A,
716
722
  "data-testid": "ck-element-grab-many-button",
717
- children: j ? "Grabbing…" : `Grab ${v.length} for agent`
723
+ children: A ? "Grabbing…" : `Grab ${_.length} for agent`
718
724
  }),
719
- /* @__PURE__ */ d(i, {
725
+ /* @__PURE__ */ d(o, {
720
726
  type: "button",
721
727
  size: "sm",
722
728
  variant: "ghost",
723
- onClick: Ce,
724
- disabled: j,
729
+ onClick: De,
730
+ disabled: A,
725
731
  "data-testid": "ck-element-grab-clear-button",
726
732
  children: "Clear"
727
733
  })
728
734
  ]
729
735
  }),
730
- a && g && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("div", {
736
+ a && h && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("div", {
731
737
  "aria-hidden": "true",
732
738
  className: "ck-element-selector-outline",
733
739
  "data-state": "selected",
734
- style: K(g.rect)
740
+ style: K(h.rect)
735
741
  }), /* @__PURE__ */ f("form", {
736
- ref: L,
742
+ ref: I,
737
743
  className: "ck-element-selector-composer",
738
- style: pe(g.rect, se),
739
- onSubmit: De,
744
+ style: me(h.rect, le),
745
+ onSubmit: Ae,
740
746
  children: [
741
747
  /* @__PURE__ */ d("div", {
742
748
  className: "ck-element-selector-input-row",
743
- children: /* @__PURE__ */ d(ee, {
749
+ children: /* @__PURE__ */ d(te, {
744
750
  "data-ck-composer-input": "",
745
751
  "aria-label": "Element comment",
746
- value: w,
752
+ value: C,
747
753
  placeholder: "Add comment",
748
- disabled: O || j,
754
+ disabled: D || A,
749
755
  onChange: (e) => {
750
- T(e.currentTarget.value), N && F(null);
756
+ w(e.currentTarget.value), M && P(null);
751
757
  }
752
758
  })
753
759
  }),
754
- !c && /* @__PURE__ */ d("input", {
755
- ref: R,
760
+ !s && /* @__PURE__ */ d("input", {
761
+ ref: L,
756
762
  "aria-label": "Attach file",
757
763
  className: "ck-element-selector-file-input",
758
764
  type: "file",
759
- onChange: Ae
765
+ onChange: Ne
760
766
  }),
761
- E && /* @__PURE__ */ f("div", {
767
+ T && /* @__PURE__ */ f("div", {
762
768
  className: "ck-element-selector-attachment",
763
769
  "data-testid": "ck-element-attachment-preview",
764
770
  children: [
765
- E.previewUrl && /* @__PURE__ */ d("img", {
771
+ T.previewUrl && /* @__PURE__ */ d("img", {
766
772
  alt: "",
767
773
  "aria-hidden": "true",
768
774
  className: "ck-element-selector-attachment-image",
769
- src: E.previewUrl
775
+ src: T.previewUrl
770
776
  }),
771
777
  /* @__PURE__ */ f("div", {
772
778
  className: "ck-element-selector-attachment-meta",
773
779
  children: [
774
780
  /* @__PURE__ */ d("span", {
775
781
  className: "ck-element-selector-attachment-name",
776
- children: E.name
782
+ children: T.name
777
783
  }),
778
784
  /* @__PURE__ */ d("span", {
779
785
  className: "ck-element-selector-attachment-path",
780
- title: E.path,
781
- children: E.path
786
+ title: T.path,
787
+ children: T.path
782
788
  }),
783
789
  /* @__PURE__ */ d("span", {
784
790
  className: "ck-element-selector-attachment-size",
785
- children: le(E.size)
791
+ children: de(T.size)
786
792
  })
787
793
  ]
788
794
  }),
789
- /* @__PURE__ */ d(i, {
795
+ /* @__PURE__ */ d(o, {
790
796
  type: "button",
791
797
  size: "icon-xs",
792
798
  variant: "ghost",
793
799
  "aria-label": "Remove attachment",
794
- disabled: O || j,
795
- onClick: je,
796
- children: /* @__PURE__ */ d(s, {
800
+ disabled: D || A,
801
+ onClick: Pe,
802
+ children: /* @__PURE__ */ d(re, {
797
803
  className: "ck-element-selector-action-icon",
798
804
  "aria-hidden": "true"
799
805
  })
@@ -803,50 +809,50 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
803
809
  /* @__PURE__ */ f("div", {
804
810
  className: "ck-element-selector-actions",
805
811
  children: [
806
- !c && /* @__PURE__ */ f(i, {
812
+ !s && /* @__PURE__ */ f(o, {
807
813
  type: "button",
808
814
  variant: "outline",
809
815
  className: "ck-element-selector-attach-action",
810
- disabled: O || j,
811
- onClick: ke,
816
+ disabled: D || A,
817
+ onClick: Me,
812
818
  "data-testid": "ck-element-attach-button",
813
- children: [/* @__PURE__ */ d(p, {
819
+ children: [/* @__PURE__ */ d(ne, {
814
820
  className: "ck-element-selector-action-icon",
815
821
  "aria-hidden": "true"
816
822
  }), /* @__PURE__ */ d("span", { children: "Attach" })]
817
823
  }),
818
- /* @__PURE__ */ d(i, {
824
+ /* @__PURE__ */ d(o, {
819
825
  type: "submit",
820
826
  className: "ck-element-selector-save-action",
821
- disabled: !w.trim() || O || j,
822
- children: O ? "Saving" : "Save"
827
+ disabled: !C.trim() || D || A,
828
+ children: D ? "Saving" : "Save"
823
829
  }),
824
- /* @__PURE__ */ d(i, {
830
+ /* @__PURE__ */ d(o, {
825
831
  type: "button",
826
832
  className: "ck-element-selector-grab-action",
827
- variant: Me ? "default" : "outline",
828
- disabled: O || j,
829
- onClick: Oe,
830
- title: c ? "Copy element context to clipboard for your agent" : "Copy element source + screenshot to clipboard for your agent",
833
+ variant: Fe ? "default" : "outline",
834
+ disabled: D || A,
835
+ onClick: je,
836
+ title: s ? "Copy element context to clipboard for your agent" : "Copy element source + screenshot to clipboard for your agent",
831
837
  "data-testid": "ck-element-grab-button",
832
- children: j ? "Grabbing…" : "Grab for agent"
838
+ children: A ? "Grabbing…" : "Grab for agent"
833
839
  })
834
840
  ]
835
841
  }),
836
- N && /* @__PURE__ */ d("p", {
842
+ M && /* @__PURE__ */ d("p", {
837
843
  className: "ck-element-selector-error",
838
844
  role: "alert",
839
- children: N
845
+ children: M
840
846
  })
841
847
  ]
842
848
  })] })
843
849
  ]
844
850
  });
845
851
  });
846
- function J(e) {
852
+ function q(e) {
847
853
  return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("style", {
848
854
  "data-ck-tool-styles": "element-selector",
849
- children: m
850
- }), /* @__PURE__ */ d(ye, { ...e })] });
855
+ children: p
856
+ }), /* @__PURE__ */ d(xe, { ...e })] });
851
857
  }
852
- export { J as ElementSelector };
858
+ export { q as ElementSelector };