@commentkit/comment-kit 0.6.9 → 0.7.1

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 (73) hide show
  1. package/CHANGELOG.md +63 -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 +25 -13
  8. package/dist/demo.es.js +148 -70
  9. package/dist/headless.es.js +3 -3
  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-cGC1p-SP.js +1093 -0
  16. package/dist/shared/attachment-refresh-CzQFXHkL.js +94 -0
  17. package/dist/shared/{bridge-DRE03N9X.js → bridge-CJoGYngu.js} +6 -3
  18. package/dist/shared/{button-group-CHfMRXyA.js → button-group-CWdKaOlC.js} +14 -16
  19. package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
  20. package/dist/shared/comment-drawing-canvas-DdXlMgbF.js +124 -0
  21. package/dist/shared/comment-icon-Dg9ZWpz-.js +608 -0
  22. package/dist/shared/comment-image-lightbox-B7iHjnAz.js +190 -0
  23. package/dist/shared/comment-images-content-D7YNUgo5.js +214 -0
  24. package/dist/shared/{comment-kit-core-D0kY00St.js → comment-kit-core-C862uNAm.js} +1371 -853
  25. package/dist/shared/comment-kit-ui-0vd-DY4S.js +19977 -0
  26. package/dist/shared/comment-screenshot-annotator-DcaSSuWB.js +151 -0
  27. package/dist/shared/comment-screenshot-overlay-D_nFoJmM.js +207 -0
  28. package/dist/shared/{dev-export-panel-BLngcr5q.js → dev-export-panel-pWBlhlse.js} +8 -8
  29. package/dist/shared/dev-grab-eQ9EgEGY.js +210 -0
  30. package/dist/shared/dist-De294MVF.js +623 -0
  31. package/dist/shared/{element-selector-CtFzgHvq.js → element-selector-DC-_XJ0k.js} +350 -305
  32. package/dist/shared/{icons-BSHCWYO1.js → icons-nzMOLzrm.js} +2 -3
  33. package/dist/shared/{mount-ui-CVivB_eQ.js → mount-ui-B68j8r6I.js} +4 -4
  34. package/dist/shared/{pusher-BEl7Qn-8.js → pusher-C1FHQGXV.js} +1 -1
  35. package/dist/shared/realtime-Diqz7G_y.js +317 -0
  36. package/dist/shared/realtime-recovery-DJ_adc-H.js +135 -0
  37. package/dist/shared/{separator-DusFNTs-.js → separator-XDBsaWyw.js} +891 -785
  38. package/dist/shared/{shadow-root-CmYXiSRR.js → shadow-root-CrO75sED.js} +1 -1
  39. package/dist/shared/styles-C9Jwvm0Q.js +2 -0
  40. package/dist/shared/useRender-D1z_X_BY.js +5 -0
  41. package/dist/shared/{useValueChanged-DQXLia-2.js → useValueChanged-CrzfD8l-.js} +15 -15
  42. package/dist/shared/{validation-C7QG8j7Z.js → validation-D-8u4M7I.js} +14 -1
  43. package/dist/shared/{websocket-manager-BTRqNTB7.js → websocket-manager-CFak_YHy.js} +148 -89
  44. package/dist/solid.es.js +3 -3
  45. package/dist/svelte.es.js +3 -3
  46. package/dist/types/adapters/bridge.d.ts +9 -12
  47. package/dist/types/angular/index.d.ts +15 -5
  48. package/dist/types/core/api-client.d.ts +24 -18
  49. package/dist/types/core/comment-kit-core.d.ts +28 -11
  50. package/dist/types/core/local-demo.d.ts +1 -0
  51. package/dist/types/core/types.d.ts +103 -0
  52. package/dist/types/core/websocket-manager.d.ts +12 -0
  53. package/dist/types/core/write-access.d.ts +9 -0
  54. package/dist/types/headless.d.ts +1 -1
  55. package/dist/types/index.d.ts +8 -4
  56. package/dist/types/qwik/index.d.ts +4 -1
  57. package/dist/vue.es.js +3 -3
  58. package/docs/api-reference.md +378 -0
  59. package/docs/local-demo.md +60 -0
  60. package/package.json +17 -6
  61. package/dist/shared/annotation-toolbar-pX17NLmJ.js +0 -1104
  62. package/dist/shared/clamp-CcFVX0vC.js +0 -55
  63. package/dist/shared/comment-drawing-canvas-CYu5SwRf.js +0 -126
  64. package/dist/shared/comment-image-lightbox-0VdAs2iT.js +0 -178
  65. package/dist/shared/comment-kit-ui-D2j2gvnm.js +0 -16685
  66. package/dist/shared/comment-screenshot-annotator-BuojwviY.js +0 -137
  67. package/dist/shared/comment-screenshot-overlay-BZX0Vcb8.js +0 -144
  68. package/dist/shared/dev-grab-pDAfH2lr.js +0 -203
  69. package/dist/shared/local-demo-context-BohlYbHt.js +0 -6
  70. package/dist/shared/realtime-BG_t_ze7.js +0 -281
  71. package/dist/shared/resolveAriaLabelledBy-CIKpnjNJ.js +0 -669
  72. package/dist/shared/styles-D_FEJZ9G.js +0 -2
  73. 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";
6
- import * as l from "react";
7
- import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
8
- var p = a("outline", "paperclip", "Paperclip", [["path", {
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 { G as c, K as ee, S as te, V as l, n as ne } from "./comment-kit-ui-0vd-DY4S.js";
6
+ import * as u from "react";
7
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
8
+ var re = 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
+ }]]), ie = 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
+ }]]), 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}}", ae = "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(ae, ""), 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 oe() {
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, se = 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 ce(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]") || !V(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 le(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 ue(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 = V(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,7 +131,7 @@ function V(e) {
125
131
  right: t.right
126
132
  };
127
133
  }
128
- function se(e) {
134
+ function V(e) {
129
135
  return e.width > 0 && e.height > 0;
130
136
  }
131
137
  function H(n) {
@@ -133,7 +139,7 @@ function H(n) {
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
145
  function U(e, t, n) {
@@ -145,7 +151,7 @@ function W() {
145
151
  height: Math.max(window.innerHeight || 0, 16)
146
152
  };
147
153
  }
148
- function ce(e) {
154
+ function de(e) {
149
155
  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);
150
156
  return {
151
157
  ...n(r, i, t),
@@ -153,10 +159,10 @@ function ce(e) {
153
159
  xpath: e.xpath
154
160
  };
155
161
  }
156
- function le(e) {
162
+ function fe(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 pe(e, t) {
160
166
  let n = e.path;
161
167
  if (typeof n == "string" && n.trim()) return {
162
168
  path: n.trim(),
@@ -175,9 +181,10 @@ 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 me(e, t) {
185
+ let { path: n, pathSource: r } = pe(e, t);
180
186
  return {
187
+ file: e,
181
188
  name: e.name,
182
189
  path: n,
183
190
  pathSource: r,
@@ -190,16 +197,16 @@ function de(e, t) {
190
197
  function G(e) {
191
198
  e && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
192
199
  }
193
- async function fe(e, t) {
200
+ async function he(e, t) {
194
201
  try {
195
202
  if (!navigator.clipboard?.writeText) throw Error("clipboard unavailable");
196
203
  await navigator.clipboard.writeText(e);
197
204
  try {
198
- c.success(`${t} copied`);
205
+ a.success(`${t} copied`);
199
206
  } catch {}
200
207
  } catch {
201
208
  try {
202
- c.error(`Could not copy ${t.toLowerCase()}`);
209
+ a.error(`Could not copy ${t.toLowerCase()}`);
203
210
  } catch {}
204
211
  }
205
212
  }
@@ -211,39 +218,39 @@ function K(e) {
211
218
  height: e.height
212
219
  };
213
220
  }
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;
221
+ function ge(e, t = se) {
222
+ let n = W(), r = Math.max(w, n.width - C - w), i = U(e.left, w, r), a = e.bottom + w, o = e.top - t - w;
216
223
  return {
217
224
  left: i,
218
- top: a + t <= n.height - T ? a : U(o, T, n.height - t - T)
225
+ top: a + t <= n.height - w ? a : U(o, w, n.height - t - w)
219
226
  };
220
227
  }
221
- var me = 220, q = 200;
222
- function he(e) {
228
+ var _e = 220, q = 200;
229
+ function ve(e) {
223
230
  let t = W();
224
231
  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))
232
+ left: U(e.x, w, Math.max(w, t.width - _e - w)),
233
+ top: U(e.y, w, Math.max(w, t.height - q - w))
227
234
  };
228
235
  }
229
- function ge(e) {
236
+ function ye(e) {
230
237
  return e.status === "open" && !!(e.position.element || e.position.xpath);
231
238
  }
232
- function _e(e) {
239
+ function be(e) {
233
240
  return e.flatMap((e) => {
234
- if (!ge(e)) return [];
241
+ if (!ye(e)) return [];
235
242
  let t = r(e.position.element ?? "", e.position.xpath);
236
243
  if (!t) return [];
237
- let n = V(t);
238
- return M(t, n) ? [{
244
+ let n = B(t);
245
+ return j(t, n) ? [{
239
246
  id: e.id,
240
247
  rect: n
241
248
  }] : [];
242
249
  });
243
250
  }
244
- function ve(e) {
245
- let [t, n] = l.useState(0);
246
- return l.useEffect(() => {
251
+ function xe(e) {
252
+ let [t, n] = u.useState(0);
253
+ return u.useEffect(() => {
247
254
  if (!e) return;
248
255
  let t = 0, r = () => {
249
256
  t ||= window.requestAnimationFrame(() => {
@@ -267,59 +274,67 @@ function ve(e) {
267
274
  };
268
275
  }, [e]), t;
269
276
  }
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);
272
- 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]);
282
- 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);
284
- }, [a]), l.useEffect(() => () => {
285
- G(J.current?.previewUrl);
286
- }, []), l.useEffect(() => {
277
+ var J = u.memo(function({ core: n, state: r, active: a }) {
278
+ let s = l(), { canWrite: m, message: ae } = ee(), [h, g] = u.useState(null), [_, v] = u.useState(null), [y, b] = u.useState([]), [x, S] = u.useState(null), [C, w] = u.useState(null), [T, E] = u.useState(""), [D, O] = u.useState(null), [A, j] = u.useState(!1), M = u.useRef(null), [P, I] = u.useState(!1), [L, R] = u.useState(null), z = u.useRef(null), V = u.useRef(null), U = u.useRef(null), W = u.useRef(null), [pe, _e] = u.useState(se), q = i().path, J = u.useMemo(() => r.comments.filter((e) => e.page?.path === q), [r.comments, q]), Se = J.some(ye), Ce = xe(a || Se || !!_ || y.length > 0), we = u.useRef(null), Te = u.useRef([]), Ee = u.useRef(""), De = u.useRef(null);
279
+ u.useEffect(() => {
280
+ we.current = _?.element ?? h?.element ?? null;
281
+ }, [h, _]), u.useEffect(() => {
282
+ Te.current = y;
283
+ }, [y]), u.useEffect(() => {
284
+ Ee.current = T;
285
+ }, [T]), u.useEffect(() => {
286
+ De.current = D;
287
+ }, [D]);
288
+ let Oe = u.useMemo(() => be(J), [J, Ce]);
289
+ u.useEffect(() => {
290
+ let e = M.current;
291
+ (e && (r.currentUser?.id !== e.userId || (r.activeBranch ?? null) !== e.branch || q !== e.page || !e.submitting && r.activeTool === null || r.activeTool !== null && r.activeTool !== "select") || !a && !A) && (M.current = null, g(null), v(null), b([]), w(null), E(""), O((e) => (G(e?.previewUrl), null)), j(!1), R(null), S(null), Q.current = null, $.current = !1);
292
+ }, [
293
+ a,
294
+ A,
295
+ r.activeTool,
296
+ r.activeBranch,
297
+ r.currentUser?.id,
298
+ q
299
+ ]), u.useEffect(() => () => {
300
+ M.current = null, G(De.current?.previewUrl);
301
+ }, []), u.useEffect(() => {
287
302
  if (!a) return;
288
303
  let e = document.body.style.cursor;
289
304
  document.body.style.cursor = "crosshair";
290
- let t = ne();
305
+ let t = oe();
291
306
  return () => {
292
307
  document.body.style.cursor = e, t();
293
308
  };
294
309
  }, [a]);
295
- let Y = a && !!g;
296
- l.useEffect(() => {
310
+ let Y = a && !!_;
311
+ u.useEffect(() => {
297
312
  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 });
313
+ let e = k();
314
+ return e instanceof HTMLElement && !z.current?.contains(e) && (W.current = e), z.current?.querySelector("[data-ck-composer-input]")?.focus({ preventScroll: !0 }), () => {
315
+ let e = W.current;
316
+ W.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
302
317
  };
303
318
  }, [Y]);
304
- let xe = l.useRef(r.isAuthenticated);
305
- 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]");
319
+ let ke = u.useRef(r.isAuthenticated);
320
+ u.useEffect(() => {
321
+ let e = !ke.current && r.isAuthenticated;
322
+ if (ke.current = r.isAuthenticated, !e || !Y || !T.trim()) return;
323
+ let t = z.current?.querySelector("[data-ck-composer-input]");
309
324
  t?.focus({ preventScroll: !0 });
310
325
  let n = t?.value.length ?? 0;
311
- t?.setSelectionRange?.(n, n), F((e) => e && e.startsWith("Sign in to save comments") ? null : e);
326
+ t?.setSelectionRange?.(n, n), R((e) => e && e.startsWith("Sign in to save comments") ? null : e);
312
327
  }, [
313
328
  r.isAuthenticated,
314
329
  Y,
315
- w
316
- ]), l.useLayoutEffect(() => {
330
+ T
331
+ ]), u.useLayoutEffect(() => {
317
332
  if (!Y) return;
318
- let e = L.current;
333
+ let e = z.current;
319
334
  if (!e) return;
320
335
  let t = () => {
321
336
  let t = e.getBoundingClientRect().height;
322
- t > 0 && U((e) => Math.abs(e - t) > 1 ? t : e);
337
+ t > 0 && _e((e) => Math.abs(e - t) > 1 ? t : e);
323
338
  };
324
339
  t();
325
340
  let n = null;
@@ -331,29 +346,29 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
331
346
  return () => n?.disconnect();
332
347
  }, [
333
348
  Y,
334
- E,
335
- N
336
- ]), l.useEffect(() => {
349
+ D,
350
+ L
351
+ ]), u.useEffect(() => {
337
352
  if (!a) return;
338
353
  let e = () => {
339
- _((e) => e && {
354
+ v((e) => e && {
340
355
  ...e,
341
- rect: V(e.element)
342
- }), h((e) => e && {
356
+ rect: B(e.element)
357
+ }), g((e) => e && {
343
358
  ...e,
344
- rect: V(e.element)
345
- }), y((e) => e.map((e) => ({
359
+ rect: B(e.element)
360
+ }), b((e) => e.map((e) => ({
346
361
  ...e,
347
- rect: V(e.element)
362
+ rect: B(e.element)
348
363
  })));
349
364
  };
350
365
  return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
351
366
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
352
367
  };
353
368
  }, [a]);
354
- let X = l.useCallback(async (e, t, r) => {
355
- if (!e || j) return !1;
356
- M(!0), F(null);
369
+ let X = u.useCallback(async (e, t, r) => {
370
+ if (!e || P) return !1;
371
+ I(!0), R(null);
357
372
  try {
358
373
  let i = t?.trim(), a = r ? [{
359
374
  name: r.name,
@@ -366,45 +381,45 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
366
381
  ...i ? { comment: i } : {},
367
382
  ...a.length > 0 ? { attachments: a } : {}
368
383
  } : 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);
384
+ return I(!1), s ? (v(null), g(null), E(""), O((e) => (G(e?.previewUrl), null)), n.setTool(null), !0) : (R("Could not grab this element."), !1);
370
385
  } catch {
371
- return M(!1), F("Could not copy this element for the agent."), !1;
386
+ return I(!1), R("Could not copy this element for the agent."), !1;
372
387
  }
373
- }, [n, j]), Z = l.useCallback(async (e) => {
374
- if (e.length === 0 || j) return !1;
375
- M(!0), F(null);
388
+ }, [n, P]), Z = u.useCallback(async (e) => {
389
+ if (e.length === 0 || P) return !1;
390
+ I(!0), R(null);
376
391
  try {
377
392
  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);
393
+ return I(!1), t ? (b([]), v(null), g(null), E(""), O((e) => (G(e?.previewUrl), null)), n.setTool(null), !0) : (R("Could not grab these elements."), !1);
379
394
  } catch {
380
- return M(!1), F("Could not copy these elements for the agent."), !1;
395
+ return I(!1), R("Could not copy these elements for the agent."), !1;
381
396
  }
382
- }, [n, j]), Se = l.useCallback(() => {
383
- let e = q.current.map((e) => e.element);
397
+ }, [n, P]), Ae = u.useCallback(() => {
398
+ let e = Te.current.map((e) => e.element);
384
399
  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;
400
+ }, [Z]), je = u.useCallback(() => {
401
+ b([]);
402
+ }, []), Q = u.useRef(null), $ = u.useRef(!1), Me = u.useRef(null);
403
+ Me.current = x;
404
+ let Ne = u.useRef(null);
405
+ Ne.current = C, u.useEffect(() => {
406
+ if (!C) return;
392
407
  let e = n.blockEscape();
393
408
  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 });
409
+ }, [C, n]), u.useEffect(() => {
410
+ if (!C) return;
411
+ let e = k();
412
+ return e instanceof HTMLElement && !U.current?.contains(e) && (W.current = e), U.current?.querySelector("[role=\"menuitem\"]")?.focus({ preventScroll: !0 }), () => {
413
+ let e = W.current;
414
+ W.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
400
415
  };
401
- }, [S]);
402
- let Ee = l.useCallback((e) => {
403
- let t = z.current;
416
+ }, [C]);
417
+ let Pe = u.useCallback((e) => {
418
+ let t = U.current;
404
419
  if (!t) return;
405
420
  let n = Array.from(t.querySelectorAll("[role=\"menuitem\"]"));
406
421
  if (n.length === 0) return;
407
- let r = A(), i = n.findIndex((e) => e === r), a = (e) => {
422
+ let r = k(), i = n.findIndex((e) => e === r), a = (e) => {
408
423
  n[(e + n.length) % n.length]?.focus({ preventScroll: !0 });
409
424
  };
410
425
  switch (e.key) {
@@ -421,20 +436,20 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
421
436
  e.preventDefault(), e.stopPropagation(), a(n.length - 1);
422
437
  break;
423
438
  case "Enter":
424
- case " ": e.preventDefault(), e.stopPropagation(), A()?.click();
439
+ case " ": e.preventDefault(), e.stopPropagation(), k()?.click();
425
440
  }
426
441
  }, []);
427
- l.useEffect(() => {
428
- if (!a) return;
442
+ u.useEffect(() => {
443
+ if (!a && !A) return;
429
444
  let r = (e) => {
430
- e.button !== 0 || P(e) || g || (C(null), Q.current = {
445
+ e.button !== 0 || N(e) || _ || (w(null), Q.current = {
431
446
  x: e.clientX,
432
447
  y: e.clientY
433
448
  }, $.current = !1);
434
449
  }, i = (n) => {
435
- if (P(n)) return;
436
- let r = I(n.clientX, n.clientY);
437
- r && (n.preventDefault(), n.stopPropagation(), C({
450
+ if (N(n)) return;
451
+ let r = F(n.clientX, n.clientY);
452
+ r && (n.preventDefault(), n.stopPropagation(), w({
438
453
  element: r,
439
454
  selector: t(r),
440
455
  xpath: e(r),
@@ -444,16 +459,16 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
444
459
  }, o = null, s = null, c = () => {
445
460
  o &&= (clearTimeout(o), null), s = null;
446
461
  }, ee = (n) => {
447
- if (P(n) || n.touches.length !== 1) return;
462
+ if (N(n) || n.touches.length !== 1) return;
448
463
  let r = n.touches[0];
449
464
  if (!r) return;
450
- let i = I(r.clientX, r.clientY);
465
+ let i = F(r.clientX, r.clientY);
451
466
  i && (s = {
452
467
  x: r.clientX,
453
468
  y: r.clientY,
454
469
  element: i
455
470
  }, o = setTimeout(() => {
456
- s && (C({
471
+ s && (w({
457
472
  element: s.element,
458
473
  selector: t(s.element),
459
474
  xpath: e(s.element),
@@ -469,87 +484,87 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
469
484
  (Math.abs(n) > 10 || Math.abs(r) > 10) && c();
470
485
  }, l = () => {
471
486
  c();
472
- }, u = (e) => {
473
- if (P(e)) return;
487
+ }, ne = (e) => {
488
+ if (N(e)) return;
474
489
  let t = Q.current;
475
490
  if (t) {
476
- if (e.pointerType === "mouse" && !(e.buttons & 1)) Q.current = null, $.current = !1, x(null);
491
+ if (e.pointerType === "mouse" && !(e.buttons & 1)) Q.current = null, $.current = !1, S(null);
477
492
  else {
478
493
  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({
494
+ if (Me.current || Math.abs(n) > 6 || Math.abs(r) > 6) {
495
+ $.current = !0, S({
481
496
  startX: t.x,
482
497
  startY: t.y,
483
498
  x: e.clientX,
484
499
  y: e.clientY
485
- }), h(null);
500
+ }), g(null);
486
501
  return;
487
502
  }
488
503
  }
489
504
  }
490
- if (g) return;
491
- let n = I(e.clientX, e.clientY);
492
- h(n ? H(n) : null);
493
- }, d = () => {
494
- Q.current = null, $.current = !1, x(null);
495
- }, f = (e) => {
505
+ if (_) return;
506
+ let n = F(e.clientX, e.clientY);
507
+ g(n ? H(n) : null);
508
+ }, u = () => {
509
+ Q.current = null, $.current = !1, S(null);
510
+ }, d = (e) => {
496
511
  let t = Q.current;
497
512
  Q.current = null;
498
- let n = we.current;
513
+ let n = Me.current;
499
514
  if (!t || !n) return;
500
- let r = ae({
515
+ let r = le({
501
516
  ...n,
502
517
  x: e.clientX,
503
518
  y: e.clientY
504
519
  });
505
520
  if (r.width < 6 || r.height < 6) {
506
- x(null);
521
+ S(null);
507
522
  return;
508
523
  }
509
- let i = oe(r);
524
+ let i = ue(r);
510
525
  if (i.length > 0) {
511
526
  let e = i.map(H);
512
- y((t) => {
527
+ b((t) => {
513
528
  let n = new Set(t.map((e) => e.element)), r = [...t];
514
529
  for (let t of e) n.has(t.element) || r.push(t);
515
530
  return r;
516
531
  });
517
532
  }
518
- x(null);
519
- }, p = (e) => {
520
- if (P(e)) return;
533
+ S(null);
534
+ }, f = (e) => {
535
+ if (N(e) || A) return;
521
536
  if ($.current) {
522
537
  $.current = !1, e.preventDefault(), e.stopPropagation();
523
538
  return;
524
539
  }
525
540
  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) => {
541
+ let t = F(e.clientX, e.clientY);
542
+ _ && !e.shiftKey ? (v(null), g(null), E(""), O((e) => (G(e?.previewUrl), null)), R(null)) : t && (e.shiftKey ? (b((e) => e.some((e) => e.element === t) ? e.filter((e) => e.element !== t) : [..._ && !e.some((e) => e.element === _.element) ? [...e, _] : e, H(t)]), g(null), v(null), E(""), O((e) => (G(e?.previewUrl), null)), R(null)) : (v(H(t)), g(null), E(""), O((e) => (G(e?.previewUrl), null)), R(null)));
543
+ }, p = (e) => {
529
544
  if (e.key === "Escape") {
530
545
  if (e.isComposing) return;
531
- if (Te.current) {
532
- e.preventDefault(), e.stopPropagation(), C(null);
546
+ if (Ne.current) {
547
+ e.preventDefault(), e.stopPropagation(), w(null);
533
548
  return;
534
549
  }
535
- e.preventDefault(), e.stopPropagation(), _(null), h(null), T(""), D((e) => (G(e?.previewUrl), null)), F(null), n.setTool(null);
550
+ e.preventDefault(), e.stopPropagation(), M.current = null, j(!1), v(null), g(null), E(""), O((e) => (G(e?.previewUrl), null)), R(null), n.setTool(null);
536
551
  return;
537
552
  }
538
- if (!e.metaKey && !e.ctrlKey || e.shiftKey || e.altKey || e.key !== "c" && e.key !== "C" && e.code !== "KeyC" || ie(e)) return;
553
+ if (A || !e.metaKey && !e.ctrlKey || e.shiftKey || e.altKey || e.key !== "c" && e.key !== "C" && e.code !== "KeyC" || ce(e)) return;
539
554
  let t = typeof window < "u" ? window.getSelection() : null;
540
555
  if (t && !t.isCollapsed && t.toString().length > 0) return;
541
- let r = q.current;
556
+ let r = Te.current;
542
557
  if (r.length > 0) {
543
558
  e.preventDefault(), e.stopPropagation(), Z(r.map((e) => e.element));
544
559
  return;
545
560
  }
546
- let i = me.current;
561
+ let i = we.current;
547
562
  if (!i) return;
548
563
  e.preventDefault(), e.stopPropagation();
549
- let a = g?.element === i;
550
- X(i, a ? ye.current : void 0, a ? J.current : null);
564
+ let a = _?.element === i;
565
+ X(i, a ? Ee.current : void 0, a ? De.current : null);
551
566
  };
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, {
567
+ return document.addEventListener("pointerdown", r, !0), document.addEventListener("pointermove", ne, !0), document.addEventListener("pointerup", d, !0), document.addEventListener("pointercancel", u, !0), document.addEventListener("click", f, !0), document.addEventListener("contextmenu", i, !0), document.addEventListener("touchstart", ee, {
553
568
  capture: !0,
554
569
  passive: !0
555
570
  }), document.addEventListener("touchmove", te, {
@@ -561,292 +576,322 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
561
576
  }), document.addEventListener("touchcancel", l, {
562
577
  capture: !0,
563
578
  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();
579
+ }), window.addEventListener("keydown", p, !0), () => {
580
+ document.removeEventListener("pointerdown", r, !0), document.removeEventListener("pointermove", ne, !0), document.removeEventListener("pointerup", d, !0), document.removeEventListener("pointercancel", u, !0), document.removeEventListener("click", f, !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", p, !0), c();
566
581
  };
567
582
  }, [
568
583
  a,
584
+ A,
569
585
  n,
570
586
  X,
571
587
  Z,
572
- g
588
+ _
573
589
  ]);
574
- let De = l.useCallback(async (e) => {
590
+ let Fe = u.useCallback(async (e) => {
575
591
  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();
579
- else {
580
- k(!0), F(null);
581
- try {
582
- await n.createComment("pin", t, ce(g)), k(!1), _(null), T(""), D((e) => (G(e?.previewUrl), null)), n.setTool(null);
583
- } catch {
584
- k(!1), F("Could not save this comment. Try again.");
585
- }
586
- }
592
+ let t = T.trim();
593
+ if (!_ || !t || A) return;
594
+ if (!r.currentUser) {
595
+ R("Sign in to save comments. You can still use Grab for agent without signing in."), n.toggleLoginModal();
596
+ return;
597
+ }
598
+ let a = {
599
+ userId: r.currentUser.id,
600
+ branch: r.activeBranch ?? null,
601
+ page: q,
602
+ submitting: !1
603
+ };
604
+ M.current = a;
605
+ let o = () => {
606
+ let e = n.getState();
607
+ return M.current === a && e.isAuthenticated && e.currentUser?.id === a.userId && (e.activeBranch ?? null) === a.branch && (e.activeTool === null || e.activeTool === "select") && i().path === a.page;
608
+ }, s = n.on("auth:logout", () => {
609
+ M.current === a && (M.current = null, j(!1));
610
+ });
611
+ j(!0), R(null);
612
+ try {
613
+ let e = await c(n, t, de(_), { files: D ? [D.file] : [] }, () => !o() || n.getState().activeTool !== "select" ? !1 : (a.submitting = !0, !0));
614
+ if (!o()) return;
615
+ if (e.status === "failed") throw Error(e.message);
616
+ v(null), E(""), O((e) => (G(e?.previewUrl), null)), n.setTool(null);
617
+ } catch {
618
+ if (!o()) return;
619
+ n.getState().activeTool === null && n.setTool("select"), R("Could not save this comment. Try again.");
620
+ } finally {
621
+ s(), M.current === a && (M.current = null, j(!1));
587
622
  }
588
623
  }, [
589
- w,
624
+ D,
625
+ T,
590
626
  n,
591
- O,
592
- g,
627
+ q,
628
+ A,
629
+ _,
630
+ r.activeBranch,
593
631
  r.currentUser
594
- ]), Oe = l.useCallback(() => {
595
- X(g?.element ?? null, w, E);
632
+ ]), Ie = u.useCallback(() => {
633
+ X(_?.element ?? null, T, D);
596
634
  }, [
597
- E,
598
- w,
635
+ D,
636
+ T,
599
637
  X,
600
- g
601
- ]), ke = l.useCallback(() => {
602
- R.current?.click();
603
- }, []), Ae = l.useCallback((e) => {
638
+ _
639
+ ]), Le = u.useCallback(() => {
640
+ V.current?.click();
641
+ }, []), Re = u.useCallback((e) => {
604
642
  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", {
643
+ O((e) => (G(e?.previewUrl), n ? me(n, t) : null)), t.value = "";
644
+ }, []), ze = u.useCallback(() => {
645
+ O((e) => (G(e?.previewUrl), null));
646
+ }, []), Be = u.useMemo(() => ne(), []);
647
+ return !a && !A && Oe.length === 0 ? null : /* @__PURE__ */ p("div", {
610
648
  className: "ck-element-selector",
611
649
  "data-testid": "ck-element-selector",
612
650
  children: [
613
- be.map((e) => /* @__PURE__ */ d("div", {
651
+ Oe.map((e) => /* @__PURE__ */ f("div", {
614
652
  "aria-hidden": "true",
615
653
  className: "ck-element-selector-mark",
616
654
  "data-comment-id": e.id,
617
655
  style: K(e.rect)
618
656
  }, e.id)),
619
- a && m && !b && /* @__PURE__ */ d("div", {
657
+ a && h && !x && /* @__PURE__ */ f("div", {
620
658
  "aria-hidden": "true",
621
659
  className: "ck-element-selector-outline",
622
660
  "data-state": "hover",
623
- style: K(m.rect)
661
+ style: K(h.rect)
624
662
  }),
625
- a && b && /* @__PURE__ */ d("div", {
663
+ a && x && /* @__PURE__ */ f("div", {
626
664
  "aria-hidden": "true",
627
665
  className: "ck-element-selector-marquee",
628
666
  "data-testid": "ck-element-selector-marquee",
629
667
  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)
668
+ left: Math.min(x.startX, x.x),
669
+ top: Math.min(x.startY, x.y),
670
+ width: Math.abs(x.x - x.startX),
671
+ height: Math.abs(x.y - x.startY)
634
672
  }
635
673
  }),
636
- a && v.map((e, t) => /* @__PURE__ */ d("div", {
674
+ a && y.map((e, t) => /* @__PURE__ */ f("div", {
637
675
  "aria-hidden": "true",
638
676
  className: "ck-element-selector-outline",
639
677
  "data-state": "multi",
640
678
  "data-multi-index": t + 1,
641
679
  style: K(e.rect)
642
680
  }, `multi-${t}-${e.selector}-${e.xpath}`)),
643
- a && S && /* @__PURE__ */ f("ul", {
644
- ref: z,
681
+ a && C && /* @__PURE__ */ p("ul", {
682
+ ref: U,
645
683
  className: "ck-element-selector-context-menu",
646
684
  "data-testid": "ck-element-selector-context-menu",
647
685
  role: "menu",
648
686
  "aria-label": "Element actions",
649
- onKeyDown: Ee,
650
- style: he(S),
687
+ onKeyDown: Pe,
688
+ style: ve(C),
651
689
  children: [
652
- /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
690
+ /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
653
691
  type: "button",
654
692
  role: "menuitem",
655
693
  "data-testid": "ck-context-menu-grab",
656
694
  onClick: () => {
657
- let e = S.element;
658
- C(null), X(e);
695
+ let e = C.element;
696
+ w(null), X(e);
659
697
  },
660
698
  children: "Grab for agent"
661
699
  }) }),
662
- /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
700
+ /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
663
701
  type: "button",
664
702
  role: "menuitem",
665
703
  "data-testid": "ck-context-menu-comment",
704
+ disabled: !m,
666
705
  onClick: () => {
667
- let e = H(S.element);
668
- C(null), _(e);
706
+ let e = H(C.element);
707
+ w(null), v(e);
669
708
  },
670
709
  children: "Add comment"
671
710
  }) }),
672
- /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
711
+ /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
673
712
  type: "button",
674
713
  role: "menuitem",
675
714
  "data-testid": "ck-context-menu-copy-selector",
676
715
  onClick: () => {
677
- let e = S.selector;
678
- C(null), fe(e, "CSS selector");
716
+ let e = C.selector;
717
+ w(null), he(e, "CSS selector");
679
718
  },
680
719
  children: "Copy CSS selector"
681
720
  }) }),
682
- /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
721
+ /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
683
722
  type: "button",
684
723
  role: "menuitem",
685
724
  "data-testid": "ck-context-menu-copy-xpath",
686
725
  onClick: () => {
687
- let e = S.xpath;
688
- C(null), fe(e, "XPath");
726
+ let e = C.xpath;
727
+ w(null), he(e, "XPath");
689
728
  },
690
729
  children: "Copy XPath"
691
730
  }) }),
692
- /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d("button", {
731
+ /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
693
732
  type: "button",
694
733
  role: "menuitem",
695
734
  "data-testid": "ck-context-menu-inspect",
696
735
  onClick: () => {
697
- console.log("[CommentKit] inspect", S.element), C(null);
736
+ console.log("[CommentKit] inspect", C.element), w(null);
698
737
  },
699
738
  children: "Inspect (log to console)"
700
739
  }) })
701
740
  ]
702
741
  }),
703
- a && v.length > 0 && /* @__PURE__ */ f("div", {
742
+ a && y.length > 0 && /* @__PURE__ */ p("div", {
704
743
  className: "ck-element-selector-multibar",
705
744
  "data-testid": "ck-element-selector-multibar",
706
745
  children: [
707
- /* @__PURE__ */ f("span", {
746
+ /* @__PURE__ */ p("span", {
708
747
  className: "ck-element-selector-multibar-count",
709
- children: [v.length, " selected"]
748
+ children: [y.length, " selected"]
710
749
  }),
711
- /* @__PURE__ */ d(i, {
750
+ /* @__PURE__ */ f(o, {
712
751
  type: "button",
713
752
  size: "sm",
714
- onClick: Se,
715
- disabled: j,
753
+ onClick: Ae,
754
+ disabled: P,
716
755
  "data-testid": "ck-element-grab-many-button",
717
- children: j ? "Grabbing…" : `Grab ${v.length} for agent`
756
+ children: P ? "Grabbing…" : `Grab ${y.length} for agent`
718
757
  }),
719
- /* @__PURE__ */ d(i, {
758
+ /* @__PURE__ */ f(o, {
720
759
  type: "button",
721
760
  size: "sm",
722
761
  variant: "ghost",
723
- onClick: Ce,
724
- disabled: j,
762
+ onClick: je,
763
+ disabled: P,
725
764
  "data-testid": "ck-element-grab-clear-button",
726
765
  children: "Clear"
727
766
  })
728
767
  ]
729
768
  }),
730
- a && g && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("div", {
769
+ (a || A) && _ && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", {
731
770
  "aria-hidden": "true",
732
771
  className: "ck-element-selector-outline",
733
772
  "data-state": "selected",
734
- style: K(g.rect)
735
- }), /* @__PURE__ */ f("form", {
736
- ref: L,
773
+ style: K(_.rect)
774
+ }), /* @__PURE__ */ p("form", {
775
+ ref: z,
737
776
  className: "ck-element-selector-composer",
738
- style: pe(g.rect, se),
739
- onSubmit: De,
777
+ style: ge(_.rect, pe),
778
+ onSubmit: Fe,
740
779
  children: [
741
- /* @__PURE__ */ d("div", {
780
+ /* @__PURE__ */ f("div", {
742
781
  className: "ck-element-selector-input-row",
743
- children: /* @__PURE__ */ d(ee, {
782
+ children: /* @__PURE__ */ f(te, {
744
783
  "data-ck-composer-input": "",
745
784
  "aria-label": "Element comment",
746
- value: w,
785
+ value: T,
747
786
  placeholder: "Add comment",
748
- disabled: O || j,
787
+ disabled: A || P,
749
788
  onChange: (e) => {
750
- T(e.currentTarget.value), N && F(null);
789
+ E(e.currentTarget.value), L && R(null);
751
790
  }
752
791
  })
753
792
  }),
754
- !c && /* @__PURE__ */ d("input", {
755
- ref: R,
793
+ !s && /* @__PURE__ */ f("input", {
794
+ ref: V,
756
795
  "aria-label": "Attach file",
757
796
  className: "ck-element-selector-file-input",
758
797
  type: "file",
759
- onChange: Ae
798
+ disabled: A || P,
799
+ onChange: Re
760
800
  }),
761
- E && /* @__PURE__ */ f("div", {
801
+ D && /* @__PURE__ */ p("div", {
762
802
  className: "ck-element-selector-attachment",
763
803
  "data-testid": "ck-element-attachment-preview",
764
804
  children: [
765
- E.previewUrl && /* @__PURE__ */ d("img", {
805
+ D.previewUrl && /* @__PURE__ */ f("img", {
766
806
  alt: "",
767
807
  "aria-hidden": "true",
768
808
  className: "ck-element-selector-attachment-image",
769
- src: E.previewUrl
809
+ src: D.previewUrl
770
810
  }),
771
- /* @__PURE__ */ f("div", {
811
+ /* @__PURE__ */ p("div", {
772
812
  className: "ck-element-selector-attachment-meta",
773
813
  children: [
774
- /* @__PURE__ */ d("span", {
814
+ /* @__PURE__ */ f("span", {
775
815
  className: "ck-element-selector-attachment-name",
776
- children: E.name
816
+ children: D.name
777
817
  }),
778
- /* @__PURE__ */ d("span", {
818
+ /* @__PURE__ */ f("span", {
779
819
  className: "ck-element-selector-attachment-path",
780
- title: E.path,
781
- children: E.path
820
+ title: D.path,
821
+ children: D.path
782
822
  }),
783
- /* @__PURE__ */ d("span", {
823
+ /* @__PURE__ */ f("span", {
784
824
  className: "ck-element-selector-attachment-size",
785
- children: le(E.size)
825
+ children: fe(D.size)
786
826
  })
787
827
  ]
788
828
  }),
789
- /* @__PURE__ */ d(i, {
829
+ /* @__PURE__ */ f(o, {
790
830
  type: "button",
791
831
  size: "icon-xs",
792
832
  variant: "ghost",
793
833
  "aria-label": "Remove attachment",
794
- disabled: O || j,
795
- onClick: je,
796
- children: /* @__PURE__ */ d(s, {
834
+ disabled: A || P,
835
+ onClick: ze,
836
+ children: /* @__PURE__ */ f(ie, {
797
837
  className: "ck-element-selector-action-icon",
798
838
  "aria-hidden": "true"
799
839
  })
800
840
  })
801
841
  ]
802
842
  }),
803
- /* @__PURE__ */ f("div", {
843
+ /* @__PURE__ */ p("div", {
804
844
  className: "ck-element-selector-actions",
805
845
  children: [
806
- !c && /* @__PURE__ */ f(i, {
846
+ !s && /* @__PURE__ */ p(o, {
807
847
  type: "button",
808
848
  variant: "outline",
809
849
  className: "ck-element-selector-attach-action",
810
- disabled: O || j,
811
- onClick: ke,
850
+ disabled: A || P,
851
+ onClick: Le,
812
852
  "data-testid": "ck-element-attach-button",
813
- children: [/* @__PURE__ */ d(p, {
853
+ children: [/* @__PURE__ */ f(re, {
814
854
  className: "ck-element-selector-action-icon",
815
855
  "aria-hidden": "true"
816
- }), /* @__PURE__ */ d("span", { children: "Attach" })]
856
+ }), /* @__PURE__ */ f("span", { children: "Attach" })]
817
857
  }),
818
- /* @__PURE__ */ d(i, {
858
+ /* @__PURE__ */ f(o, {
819
859
  type: "submit",
820
860
  className: "ck-element-selector-save-action",
821
- disabled: !w.trim() || O || j,
822
- children: O ? "Saving" : "Save"
861
+ disabled: !m || !T.trim() || A || P,
862
+ children: A ? "Saving" : "Save"
823
863
  }),
824
- /* @__PURE__ */ d(i, {
864
+ /* @__PURE__ */ f(o, {
825
865
  type: "button",
826
866
  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",
867
+ variant: Be ? "default" : "outline",
868
+ disabled: A || P,
869
+ onClick: Ie,
870
+ title: s ? "Copy element context to clipboard for your agent" : "Copy element source + screenshot to clipboard for your agent",
831
871
  "data-testid": "ck-element-grab-button",
832
- children: j ? "Grabbing…" : "Grab for agent"
872
+ children: P ? "Grabbing…" : "Grab for agent"
833
873
  })
834
874
  ]
835
875
  }),
836
- N && /* @__PURE__ */ d("p", {
876
+ !m && /* @__PURE__ */ f("p", {
877
+ role: "status",
878
+ className: "ck-element-selector-error",
879
+ children: ae
880
+ }),
881
+ L && /* @__PURE__ */ f("p", {
837
882
  className: "ck-element-selector-error",
838
883
  role: "alert",
839
- children: N
884
+ children: L
840
885
  })
841
886
  ]
842
887
  })] })
843
888
  ]
844
889
  });
845
890
  });
846
- function J(e) {
847
- return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("style", {
891
+ function Se(e) {
892
+ return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("style", {
848
893
  "data-ck-tool-styles": "element-selector",
849
894
  children: m
850
- }), /* @__PURE__ */ d(ye, { ...e })] });
895
+ }), /* @__PURE__ */ f(J, { ...e })] });
851
896
  }
852
- export { J as ElementSelector };
897
+ export { Se as ElementSelector };