agent-ui-annotation 0.1.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.
@@ -0,0 +1,3263 @@
1
+ var St = Object.defineProperty;
2
+ var wt = (t, n, e) => n in t ? St(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
+ var w = (t, n, e) => wt(t, typeof n != "symbol" ? n + "" : n, e);
4
+ function $t(t) {
5
+ let n = { ...t };
6
+ const e = /* @__PURE__ */ new Set();
7
+ let o = !1, a = !1, r = !1;
8
+ const s = () => {
9
+ r || e.forEach((d) => {
10
+ try {
11
+ if (d.selector) {
12
+ const h = d.selector(n);
13
+ Object.is(h, d.prevSelected) || (d.prevSelected = h, d.listener(n));
14
+ } else
15
+ d.listener(n);
16
+ } catch (h) {
17
+ console.error("[Annotation Store] Listener error:", h);
18
+ }
19
+ });
20
+ };
21
+ return {
22
+ getState: () => n,
23
+ setState: (d) => {
24
+ if (r) return;
25
+ const h = typeof d == "function" ? d(n) : d, v = { ...n, ...h };
26
+ Object.keys(h).some(
27
+ (b) => !Object.is(n[b], v[b])
28
+ ) && (n = v, o ? a = !0 : s());
29
+ },
30
+ subscribe: (d, h) => {
31
+ if (r) return () => {
32
+ };
33
+ const v = {
34
+ listener: d,
35
+ selector: h,
36
+ prevSelected: h ? h(n) : void 0
37
+ };
38
+ return e.add(v), () => {
39
+ e.delete(v);
40
+ };
41
+ },
42
+ batch: (d) => {
43
+ if (!r) {
44
+ o = !0, a = !1;
45
+ try {
46
+ d();
47
+ } finally {
48
+ o = !1, a && s();
49
+ }
50
+ }
51
+ },
52
+ reset: (d) => {
53
+ r || (n = { ...d }, s());
54
+ },
55
+ destroy: () => {
56
+ r = !0, e.clear();
57
+ }
58
+ };
59
+ }
60
+ function At() {
61
+ const t = /* @__PURE__ */ new Map();
62
+ let n = !1;
63
+ const e = (i, p) => {
64
+ if (n) return;
65
+ const f = t.get(i);
66
+ if (!f) return;
67
+ Array.from(f).forEach((c) => {
68
+ try {
69
+ c(p);
70
+ } catch (l) {
71
+ console.error(`[Annotation EventBus] Error in handler for "${String(i)}":`, l);
72
+ }
73
+ });
74
+ }, o = (i, p) => {
75
+ if (n) return () => {
76
+ };
77
+ t.has(i) || t.set(i, /* @__PURE__ */ new Set());
78
+ const f = t.get(i);
79
+ return f.add(p), () => {
80
+ f.delete(p), f.size === 0 && t.delete(i);
81
+ };
82
+ };
83
+ return {
84
+ emit: e,
85
+ on: o,
86
+ once: (i, p) => {
87
+ const f = o(i, (u) => {
88
+ f(), p(u);
89
+ });
90
+ return f;
91
+ },
92
+ off: (i) => {
93
+ n || (i !== void 0 ? t.delete(i) : t.clear());
94
+ },
95
+ destroy: () => {
96
+ n = !0, t.clear();
97
+ }
98
+ };
99
+ }
100
+ const st = {
101
+ theme: "auto",
102
+ outputLevel: "standard",
103
+ toolbarPosition: "bottom-right",
104
+ showTooltips: !0,
105
+ showMarkerNumbers: !0,
106
+ freezeOnScope: !1,
107
+ persistScopes: !0,
108
+ scopeColor: "#AF52DE",
109
+ // purple
110
+ blockInteractions: !0,
111
+ autoClearAfterCopy: !1
112
+ }, Et = {
113
+ x: 20,
114
+ y: 20
115
+ };
116
+ function Ct(t) {
117
+ return {
118
+ scopes: /* @__PURE__ */ new Map(),
119
+ selectedAnnotationId: null,
120
+ hoveredElement: null,
121
+ hoveredElementInfo: null,
122
+ mode: "disabled",
123
+ toolbarExpanded: !1,
124
+ toolbarPosition: { ...Et },
125
+ settings: { ...st },
126
+ isSelecting: !1,
127
+ selectionRect: null,
128
+ selectionPreviewElements: [],
129
+ isFrozen: !1,
130
+ popupVisible: !1,
131
+ popupAnnotationId: null,
132
+ popupElementInfo: null,
133
+ popupClickX: 0,
134
+ popupClickY: 0,
135
+ pendingMarkerX: 0,
136
+ pendingMarkerY: 0,
137
+ pendingMarkerIsFixed: !1,
138
+ multiSelectElements: [],
139
+ multiSelectInfos: [],
140
+ markersVisible: !0,
141
+ animatingMarkers: /* @__PURE__ */ new Set(),
142
+ exitingMarkers: /* @__PURE__ */ new Set(),
143
+ deletingMarkerId: null,
144
+ renumberFrom: null,
145
+ showCopiedFeedback: !1,
146
+ showClearedFeedback: !1,
147
+ scrollY: 0,
148
+ showEntranceAnimation: !0,
149
+ isDraggingToolbar: !1,
150
+ settingsPanelVisible: !1,
151
+ ...t
152
+ };
153
+ }
154
+ const Mt = 40;
155
+ function x(t, n = Mt) {
156
+ const e = t.trim().replace(/\s+/g, " ");
157
+ return e.length <= n ? e : e.slice(0, n - 3) + "...";
158
+ }
159
+ function E(t) {
160
+ var e;
161
+ if (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement)
162
+ return t.value || t.placeholder || "";
163
+ if (t instanceof HTMLSelectElement)
164
+ return ((e = t.options[t.selectedIndex]) == null ? void 0 : e.text) || "";
165
+ const n = t.cloneNode(!0);
166
+ return n.querySelectorAll('script, style, [aria-hidden="true"]').forEach((o) => o.remove()), n.textContent || "";
167
+ }
168
+ function F(t) {
169
+ const n = t.getAttribute("aria-label");
170
+ if (n) return n;
171
+ const e = t.getAttribute("aria-labelledby");
172
+ if (e) {
173
+ const o = document.getElementById(e);
174
+ if (o)
175
+ return E(o);
176
+ }
177
+ return null;
178
+ }
179
+ function K(t) {
180
+ var o;
181
+ const n = t.id;
182
+ if (n) {
183
+ const a = document.querySelector(`label[for="${n}"]`);
184
+ if (a)
185
+ return E(a);
186
+ }
187
+ const e = t.closest("label");
188
+ if (e) {
189
+ const a = e.cloneNode(!0);
190
+ a.querySelectorAll("input, select, textarea").forEach((s) => s.remove());
191
+ const r = (o = a.textContent) == null ? void 0 : o.trim();
192
+ if (r) return r;
193
+ }
194
+ return null;
195
+ }
196
+ function it(t) {
197
+ const n = Array.from(t.children);
198
+ if (n.length === 0) return !1;
199
+ const e = n.every(
200
+ (a) => a.tagName === "SVG" || a.tagName === "svg" || a.classList.contains("icon") || a.tagName === "I"
201
+ ), o = E(t).trim();
202
+ return e && !o;
203
+ }
204
+ function It(t) {
205
+ const n = x(E(t));
206
+ if (n)
207
+ return `button "${n}"`;
208
+ const e = F(t);
209
+ if (e)
210
+ return `button [${x(e)}]`;
211
+ const o = t.getAttribute("title");
212
+ if (o)
213
+ return `button [${x(o)}]`;
214
+ if (it(t))
215
+ return "icon button";
216
+ const a = t.getAttribute("type");
217
+ return a && a !== "button" ? `${a} button` : "button";
218
+ }
219
+ function Tt(t) {
220
+ const n = x(E(t));
221
+ if (n)
222
+ return `link "${n}"`;
223
+ const e = F(t);
224
+ if (e)
225
+ return `link [${x(e)}]`;
226
+ const o = t.getAttribute("href");
227
+ if (o && o !== "#")
228
+ try {
229
+ const a = new URL(o, window.location.origin);
230
+ return a.origin === window.location.origin ? `link to ${a.pathname}` : `link to ${a.hostname}`;
231
+ } catch {
232
+ return `link to ${x(o, 30)}`;
233
+ }
234
+ return it(t) ? "icon link" : "link";
235
+ }
236
+ function Lt(t) {
237
+ const n = t.type || "text", e = K(t), o = t.placeholder, a = t.name, r = F(t);
238
+ let s = "";
239
+ switch (e ? s = `"${x(e)}"` : r ? s = `[${x(r)}]` : o ? s = `"${x(o)}"` : a && (s = `[${a}]`), n) {
240
+ case "submit":
241
+ return `submit button${s ? " " + s : ""}`;
242
+ case "checkbox":
243
+ return `checkbox${s ? " " + s : ""}`;
244
+ case "radio":
245
+ return `radio${s ? " " + s : ""}`;
246
+ case "file":
247
+ return `file input${s ? " " + s : ""}`;
248
+ case "search":
249
+ return `search input${s ? " " + s : ""}`;
250
+ case "email":
251
+ return `email input${s ? " " + s : ""}`;
252
+ case "password":
253
+ return `password input${s ? " " + s : ""}`;
254
+ case "number":
255
+ return `number input${s ? " " + s : ""}`;
256
+ case "tel":
257
+ return `phone input${s ? " " + s : ""}`;
258
+ case "url":
259
+ return `URL input${s ? " " + s : ""}`;
260
+ case "date":
261
+ case "datetime-local":
262
+ case "time":
263
+ return `${n} input${s ? " " + s : ""}`;
264
+ case "range":
265
+ return `slider${s ? " " + s : ""}`;
266
+ case "color":
267
+ return `color picker${s ? " " + s : ""}`;
268
+ default:
269
+ return `text input${s ? " " + s : ""}`;
270
+ }
271
+ }
272
+ function Ft(t) {
273
+ const n = K(t), e = F(t), o = t.name;
274
+ let a = "";
275
+ return n ? a = ` "${x(n)}"` : e ? a = ` [${x(e)}]` : o && (a = ` [${o}]`), `dropdown${a}`;
276
+ }
277
+ function zt(t) {
278
+ const n = K(t), e = F(t), o = t.placeholder, a = t.name;
279
+ let r = "";
280
+ return n ? r = ` "${x(n)}"` : e ? r = ` [${x(e)}]` : o ? r = ` "${x(o)}"` : a && (r = ` [${a}]`), `text area${r}`;
281
+ }
282
+ function Pt(t) {
283
+ const n = t.tagName.toLowerCase(), e = x(E(t));
284
+ return e ? `${n} "${e}"` : n;
285
+ }
286
+ function Yt(t, n) {
287
+ const e = x(E(t), 50);
288
+ return e ? `${n}: "${e}"` : n;
289
+ }
290
+ function Rt(t) {
291
+ const n = t.alt;
292
+ if (n)
293
+ return `image "${x(n)}"`;
294
+ const e = F(t);
295
+ if (e)
296
+ return `image [${x(e)}]`;
297
+ const o = t.src;
298
+ if (o)
299
+ try {
300
+ const r = new URL(o).pathname.split("/").pop();
301
+ if (r && !r.includes("?"))
302
+ return `image "${x(r, 30)}"`;
303
+ } catch {
304
+ }
305
+ return "image";
306
+ }
307
+ function Ht(t) {
308
+ if (t.closest('button, a, [role="button"]'))
309
+ return "icon";
310
+ const e = F(t);
311
+ if (e)
312
+ return `graphic [${x(e)}]`;
313
+ const o = t.querySelector("title");
314
+ return o != null && o.textContent ? `graphic "${x(o.textContent)}"` : "icon";
315
+ }
316
+ function Xt(t) {
317
+ const n = F(t);
318
+ return n ? `video [${x(n)}]` : "video";
319
+ }
320
+ function Dt(t) {
321
+ const n = t.tagName === "TH", e = x(E(t), 30), o = n ? "table header" : "table cell";
322
+ return e ? `${o}: "${e}"` : o;
323
+ }
324
+ function Ot(t) {
325
+ const n = x(E(t), 50);
326
+ return n ? `list item: "${n}"` : "list item";
327
+ }
328
+ function Nt(t) {
329
+ const n = x(E(t));
330
+ return n ? `label "${n}"` : "label";
331
+ }
332
+ function jt(t) {
333
+ const n = t.getAttribute("role");
334
+ if (n)
335
+ return n;
336
+ const e = Array.from(t.classList), o = ["header", "footer", "nav", "sidebar", "main", "content", "article", "section", "card", "modal", "dialog", "menu", "dropdown", "panel", "container", "wrapper"];
337
+ for (const r of e) {
338
+ const s = r.toLowerCase();
339
+ for (const i of o)
340
+ if (s.includes(i))
341
+ return i;
342
+ }
343
+ const a = t.getAttribute("data-testid") || t.getAttribute("data-test-id");
344
+ return a ? a.replace(/[-_]/g, " ") : t.tagName.toLowerCase();
345
+ }
346
+ function X(t) {
347
+ const n = t.tagName.toLowerCase();
348
+ if (n === "button" || t.getAttribute("role") === "button" || t instanceof HTMLInputElement && (t.type === "button" || t.type === "submit" || t.type === "reset"))
349
+ return It(t);
350
+ if (n === "a")
351
+ return Tt(t);
352
+ if (n === "input")
353
+ return Lt(t);
354
+ if (n === "select")
355
+ return Ft(t);
356
+ if (n === "textarea")
357
+ return zt(t);
358
+ if (/^h[1-6]$/.test(n))
359
+ return Pt(t);
360
+ if (n === "p")
361
+ return Yt(t, "paragraph");
362
+ if (n === "span") {
363
+ const e = x(E(t));
364
+ return e ? `text: "${e}"` : "text";
365
+ }
366
+ if (n === "code") {
367
+ const e = x(E(t), 30);
368
+ return e ? `code: \`${e}\`` : "code";
369
+ }
370
+ return n === "pre" ? "code block" : n === "blockquote" ? "blockquote" : n === "img" ? Rt(t) : n === "svg" ? Ht(t) : n === "video" ? Xt(t) : n === "audio" ? "audio" : n === "canvas" ? "canvas" : n === "iframe" ? "iframe" : n === "th" || n === "td" ? Dt(t) : n === "tr" ? "table row" : n === "table" ? "table" : n === "li" ? Ot(t) : n === "ul" ? "unordered list" : n === "ol" ? "ordered list" : n === "label" ? Nt(t) : n === "nav" ? "navigation" : n === "header" ? "header" : n === "footer" ? "footer" : n === "main" ? "main content" : n === "aside" ? "sidebar" : n === "article" ? "article" : n === "section" ? "section" : n === "form" ? "form" : n === "figure" ? "figure" : n === "figcaption" ? "caption" : jt(t);
371
+ }
372
+ const G = /[-_][a-zA-Z0-9]{5,}$/, Z = [
373
+ // Webpack/CSS Modules: component_abc123 or component-abc123
374
+ /^(.+?)[-_][a-zA-Z0-9]{5,}$/,
375
+ // Styled-components: sc-abc123
376
+ /^sc-[a-zA-Z0-9]+$/,
377
+ // Emotion: css-abc123
378
+ /^css-[a-zA-Z0-9]+$/,
379
+ // Tailwind JIT: arbitrary values like [color:red]
380
+ /^\[.+\]$/
381
+ ], lt = [
382
+ "text-",
383
+ "bg-",
384
+ "flex",
385
+ "grid",
386
+ "p-",
387
+ "px-",
388
+ "py-",
389
+ "m-",
390
+ "mx-",
391
+ "my-",
392
+ "w-",
393
+ "h-",
394
+ "min-",
395
+ "max-",
396
+ "border",
397
+ "rounded",
398
+ "shadow",
399
+ "opacity",
400
+ "font-",
401
+ "leading-",
402
+ "tracking-",
403
+ "space-",
404
+ "gap-",
405
+ "items-",
406
+ "justify-",
407
+ "self-",
408
+ "overflow-",
409
+ "z-",
410
+ "cursor-",
411
+ "transition",
412
+ "transform",
413
+ "scale-",
414
+ "rotate-",
415
+ "translate-",
416
+ "animate-",
417
+ "duration-",
418
+ "ease-",
419
+ "delay-",
420
+ "hidden",
421
+ "block",
422
+ "inline",
423
+ "relative",
424
+ "absolute",
425
+ "fixed",
426
+ "sticky",
427
+ "static",
428
+ "top-",
429
+ "right-",
430
+ "bottom-",
431
+ "left-",
432
+ "inset-"
433
+ ];
434
+ function ct(t) {
435
+ const n = t.trim();
436
+ if (!n) return null;
437
+ if (lt.some((o) => n.startsWith(o)))
438
+ return n;
439
+ for (const o of Z.slice(1))
440
+ if (o.test(n))
441
+ return null;
442
+ const e = n.match(Z[0]);
443
+ return e ? e[1] : G.test(n) ? n.replace(G, "") : n;
444
+ }
445
+ function Vt(t) {
446
+ const n = Array.isArray(t) ? t : Array.from(t), e = /* @__PURE__ */ new Set();
447
+ for (const o of n) {
448
+ const a = ct(o);
449
+ a && e.add(a);
450
+ }
451
+ return Array.from(e);
452
+ }
453
+ function dt(t) {
454
+ return Vt(t.classList).filter((e) => e.length > 2);
455
+ }
456
+ function _t(t) {
457
+ const n = dt(t);
458
+ return n.find(
459
+ (o) => !lt.some((a) => o.startsWith(a))
460
+ ) || n[0] || null;
461
+ }
462
+ const Bt = 4, ut = /* @__PURE__ */ new Set(["html", "body", "main", "div", "span"]), pt = /* @__PURE__ */ new Set([
463
+ "header",
464
+ "footer",
465
+ "nav",
466
+ "aside",
467
+ "article",
468
+ "section",
469
+ "form",
470
+ "table",
471
+ "ul",
472
+ "ol",
473
+ "dialog"
474
+ ]);
475
+ function ft(t) {
476
+ const n = t.tagName.toLowerCase();
477
+ if (t.id) {
478
+ const r = ct(t.id);
479
+ if (r && r === t.id)
480
+ return `#${t.id}`;
481
+ }
482
+ const e = _t(t);
483
+ if (pt.has(n))
484
+ return e ? `${n}.${e}` : n;
485
+ if (e)
486
+ return ut.has(n) ? `.${e}` : `${n}.${e}`;
487
+ const o = t.getAttribute("role");
488
+ if (o)
489
+ return `[role="${o}"]`;
490
+ const a = t.getAttribute("data-testid") || t.getAttribute("data-test-id");
491
+ if (a)
492
+ return `[data-testid="${a}"]`;
493
+ if ((t instanceof HTMLInputElement || t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement) && t.name)
494
+ return `${n}[name="${t.name}"]`;
495
+ if (t instanceof HTMLInputElement || t instanceof HTMLButtonElement) {
496
+ const r = t.type;
497
+ if (r && r !== "text" && r !== "submit")
498
+ return `${n}[type="${r}"]`;
499
+ }
500
+ if (t instanceof HTMLAnchorElement && t.href)
501
+ try {
502
+ const r = new URL(t.href);
503
+ if (r.origin === window.location.origin && r.pathname !== "/")
504
+ return `a[href="${r.pathname}"]`;
505
+ } catch {
506
+ }
507
+ return n;
508
+ }
509
+ function O(t, n) {
510
+ try {
511
+ const e = document.querySelectorAll(t);
512
+ return e.length === 1 && e[0] === n;
513
+ } catch {
514
+ return !1;
515
+ }
516
+ }
517
+ function Wt(t) {
518
+ const n = t.parentElement;
519
+ if (!n) return "";
520
+ const e = Array.from(n.children).filter(
521
+ (a) => a.tagName === t.tagName
522
+ );
523
+ return e.length <= 1 ? "" : `:nth-of-type(${e.indexOf(t) + 1})`;
524
+ }
525
+ function Ut(t) {
526
+ const n = [];
527
+ let e = t, o = 0;
528
+ for (; e && o < Bt; ) {
529
+ const a = e.tagName.toLowerCase();
530
+ if (a === "body" || a === "html")
531
+ break;
532
+ const r = ft(e);
533
+ if (r.startsWith("#")) {
534
+ n.unshift(r);
535
+ break;
536
+ }
537
+ if (ut.has(a) && r === a) {
538
+ e = e.parentElement;
539
+ continue;
540
+ }
541
+ if (n.unshift(r), o++, pt.has(a) && o >= 2)
542
+ break;
543
+ e = e.parentElement;
544
+ }
545
+ return n;
546
+ }
547
+ function qt(t) {
548
+ const n = ft(t);
549
+ if (n.startsWith("#") || O(n, t))
550
+ return n;
551
+ const e = Ut(t);
552
+ if (e.length === 0)
553
+ return t.tagName.toLowerCase();
554
+ let o = e.join(" > ");
555
+ if (O(o, t))
556
+ return o;
557
+ const a = e[e.length - 1], r = Wt(t);
558
+ return r && (e[e.length - 1] = a + r, o = e.join(" > "), O(o, t)), o;
559
+ }
560
+ function Kt(t) {
561
+ const n = [];
562
+ let e = t;
563
+ for (; e; ) {
564
+ const o = e.tagName.toLowerCase();
565
+ if (o === "html") {
566
+ n.unshift("html");
567
+ break;
568
+ }
569
+ let a = o;
570
+ e.id && (a += `#${e.id}`);
571
+ const r = Array.from(e.classList).slice(0, 3);
572
+ r.length > 0 && (a += "." + r.join("."));
573
+ const s = e.parentElement;
574
+ if (s) {
575
+ const i = Array.from(s.children);
576
+ if (i.length > 1) {
577
+ const p = i.indexOf(e) + 1;
578
+ a += `:nth-child(${p})`;
579
+ }
580
+ }
581
+ n.unshift(a), e = e.parentElement;
582
+ }
583
+ return n.join(" > ");
584
+ }
585
+ const Gt = [
586
+ "a[href]",
587
+ "button",
588
+ 'input:not([type="hidden"])',
589
+ "select",
590
+ "textarea",
591
+ '[tabindex]:not([tabindex="-1"])',
592
+ '[role="button"]',
593
+ '[role="link"]',
594
+ '[role="checkbox"]',
595
+ '[role="radio"]',
596
+ '[role="menuitem"]',
597
+ '[role="tab"]',
598
+ '[role="option"]',
599
+ '[role="switch"]',
600
+ '[role="slider"]',
601
+ '[role="textbox"]',
602
+ '[role="combobox"]',
603
+ '[contenteditable="true"]'
604
+ ];
605
+ function Zt(t) {
606
+ for (const e of Gt)
607
+ try {
608
+ if (t.matches(e))
609
+ return !0;
610
+ } catch {
611
+ }
612
+ return !!(t.hasAttribute("onclick") || t.hasAttribute("data-onclick") || window.getComputedStyle(t).cursor === "pointer");
613
+ }
614
+ function Jt(t) {
615
+ const n = t.getAttribute("role");
616
+ if (n)
617
+ return n;
618
+ const e = t.tagName.toLowerCase();
619
+ return {
620
+ a: t.hasAttribute("href") ? "link" : null,
621
+ article: "article",
622
+ aside: "complementary",
623
+ button: "button",
624
+ dialog: "dialog",
625
+ footer: "contentinfo",
626
+ form: "form",
627
+ h1: "heading",
628
+ h2: "heading",
629
+ h3: "heading",
630
+ h4: "heading",
631
+ h5: "heading",
632
+ h6: "heading",
633
+ header: "banner",
634
+ img: "img",
635
+ input: Qt(t),
636
+ li: "listitem",
637
+ main: "main",
638
+ nav: "navigation",
639
+ ol: "list",
640
+ option: "option",
641
+ progress: "progressbar",
642
+ section: t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby") ? "region" : null,
643
+ select: "combobox",
644
+ table: "table",
645
+ tbody: "rowgroup",
646
+ td: "cell",
647
+ textarea: "textbox",
648
+ th: "columnheader",
649
+ thead: "rowgroup",
650
+ tr: "row",
651
+ ul: "list"
652
+ }[e] || null;
653
+ }
654
+ function Qt(t) {
655
+ const n = t.type;
656
+ return {
657
+ button: "button",
658
+ checkbox: "checkbox",
659
+ email: "textbox",
660
+ image: "button",
661
+ number: "spinbutton",
662
+ radio: "radio",
663
+ range: "slider",
664
+ reset: "button",
665
+ search: "searchbox",
666
+ submit: "button",
667
+ tel: "textbox",
668
+ text: "textbox",
669
+ url: "textbox"
670
+ }[n] || "textbox";
671
+ }
672
+ function te(t) {
673
+ return t.hasAttribute("tabindex") ? t.tabIndex : t.matches('a[href], button, input, select, textarea, [contenteditable="true"]') ? 0 : null;
674
+ }
675
+ function _(t) {
676
+ var o;
677
+ if (!t) return null;
678
+ const n = t.split(/\s+/), e = [];
679
+ for (const a of n) {
680
+ const r = document.getElementById(a);
681
+ if (r) {
682
+ const s = (o = r.textContent) == null ? void 0 : o.trim();
683
+ s && e.push(s);
684
+ }
685
+ }
686
+ return e.length > 0 ? e.join(" ") : null;
687
+ }
688
+ function ee(t) {
689
+ return {
690
+ role: Jt(t),
691
+ ariaLabel: t.getAttribute("aria-label"),
692
+ ariaDescribedBy: _(t.getAttribute("aria-describedby")),
693
+ ariaLabelledBy: _(t.getAttribute("aria-labelledby")),
694
+ tabIndex: te(t),
695
+ isInteractive: Zt(t)
696
+ };
697
+ }
698
+ function ne(t) {
699
+ const n = ["banner", "complementary", "contentinfo", "form", "main", "navigation", "region", "search"], e = ["header", "footer", "nav", "main", "aside", "form", "section"];
700
+ let o = t.parentElement;
701
+ for (; o && o !== document.body; ) {
702
+ const a = o.getAttribute("role");
703
+ if (a && n.includes(a))
704
+ return o;
705
+ const r = o.tagName.toLowerCase();
706
+ if (e.includes(r))
707
+ if (r === "section") {
708
+ if (o.hasAttribute("aria-label") || o.hasAttribute("aria-labelledby"))
709
+ return o;
710
+ } else
711
+ return o;
712
+ o = o.parentElement;
713
+ }
714
+ return null;
715
+ }
716
+ function oe(t) {
717
+ if (!t) return null;
718
+ const n = t.getAttribute("role") || t.tagName.toLowerCase(), e = t.getAttribute("aria-label");
719
+ if (e)
720
+ return `${n} "${e}"`;
721
+ const o = t.getAttribute("aria-labelledby");
722
+ if (o) {
723
+ const a = _(o);
724
+ if (a)
725
+ return `${n} "${a}"`;
726
+ }
727
+ return n;
728
+ }
729
+ function ae(t) {
730
+ return t.replace(/([A-Z])/g, "-$1").toLowerCase();
731
+ }
732
+ function re(t) {
733
+ const n = window.getComputedStyle(t);
734
+ return {
735
+ display: n.display,
736
+ position: n.position,
737
+ visibility: n.visibility,
738
+ opacity: n.opacity,
739
+ zIndex: n.zIndex,
740
+ overflow: n.overflow,
741
+ pointerEvents: n.pointerEvents,
742
+ cursor: n.cursor,
743
+ backgroundColor: n.backgroundColor,
744
+ color: n.color,
745
+ fontSize: n.fontSize,
746
+ fontFamily: n.fontFamily,
747
+ fontWeight: n.fontWeight,
748
+ lineHeight: n.lineHeight,
749
+ padding: n.padding,
750
+ margin: n.margin,
751
+ border: n.border,
752
+ borderRadius: n.borderRadius,
753
+ boxShadow: n.boxShadow,
754
+ transform: n.transform,
755
+ transition: n.transition
756
+ };
757
+ }
758
+ function se(t) {
759
+ return Object.entries(t).map(([n, e]) => `${ae(n)}: ${e}`).join(`
760
+ `);
761
+ }
762
+ function ie(t) {
763
+ let n = t;
764
+ for (; n && n !== document.body && n !== document.documentElement; ) {
765
+ const o = window.getComputedStyle(n).position;
766
+ if (o === "fixed" || o === "sticky")
767
+ return !0;
768
+ n = n.parentElement;
769
+ }
770
+ return !1;
771
+ }
772
+ const J = 200;
773
+ function le(t) {
774
+ const n = t.getBoundingClientRect();
775
+ return {
776
+ top: n.top,
777
+ left: n.left,
778
+ width: n.width,
779
+ height: n.height,
780
+ bottom: n.bottom,
781
+ right: n.right
782
+ };
783
+ }
784
+ function ce(t) {
785
+ const n = t.parentElement, e = t.previousElementSibling, o = t.nextElementSibling, a = ne(t);
786
+ return {
787
+ parent: n ? X(n) : null,
788
+ previousSibling: e ? X(e) : null,
789
+ nextSibling: o ? X(o) : null,
790
+ containingLandmark: oe(a)
791
+ };
792
+ }
793
+ function de(t) {
794
+ const n = {}, e = /* @__PURE__ */ new Set(["class", "style", "id"]);
795
+ for (const o of Array.from(t.attributes))
796
+ e.has(o.name) || (n[o.name] = o.value);
797
+ return n;
798
+ }
799
+ function ue(t) {
800
+ const e = (t.textContent || "").trim().replace(/\s+/g, " ");
801
+ return e.length <= J ? e : e.slice(0, J - 3) + "...";
802
+ }
803
+ function D(t, n = !1) {
804
+ return {
805
+ humanReadable: X(t),
806
+ selectorPath: qt(t),
807
+ fullDomPath: Kt(t),
808
+ tagName: t.tagName.toLowerCase(),
809
+ id: t.id || null,
810
+ classes: dt(t),
811
+ rect: le(t),
812
+ accessibility: ee(t),
813
+ computedStyles: n ? re(t) : null,
814
+ nearbyContext: ce(t),
815
+ innerText: ue(t),
816
+ attributes: de(t),
817
+ isFixed: ie(t)
818
+ };
819
+ }
820
+ function pe() {
821
+ return `scope-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
822
+ }
823
+ function fe(t) {
824
+ return t.size === 0 ? 1 : Math.max(...Array.from(t.values()).map((e) => e.number)) + 1;
825
+ }
826
+ function he(t, n, e, o = {}) {
827
+ const {
828
+ selectedText: a = null,
829
+ isMultiSelect: r = !1,
830
+ includeForensic: s = !1,
831
+ clickX: i = 0,
832
+ clickY: p = 0
833
+ } = o, f = Date.now(), u = D(t, s);
834
+ return {
835
+ id: pe(),
836
+ number: fe(e),
837
+ comment: n,
838
+ elementInfo: u,
839
+ element: t,
840
+ createdAt: f,
841
+ updatedAt: f,
842
+ selectedText: a,
843
+ isMultiSelect: r,
844
+ clickX: i,
845
+ clickY: p
846
+ };
847
+ }
848
+ function me(t, n) {
849
+ return {
850
+ ...t,
851
+ comment: n,
852
+ updatedAt: Date.now()
853
+ };
854
+ }
855
+ function ge(t, n) {
856
+ const e = /* @__PURE__ */ new Map();
857
+ for (const [o, a] of t)
858
+ a.number > n ? e.set(o, {
859
+ ...a,
860
+ number: a.number - 1
861
+ }) : e.set(o, a);
862
+ return e;
863
+ }
864
+ function be(t, n) {
865
+ return {
866
+ addScope: (u, c, l) => {
867
+ const d = t.getState(), h = d.settings.outputLevel === "forensic", v = he(u, c, d.scopes, {
868
+ ...l,
869
+ includeForensic: h
870
+ }), g = new Map(d.scopes);
871
+ return g.set(v.id, v), t.setState({ scopes: g }), n.emit("scope:create", { scope: v }), v;
872
+ },
873
+ updateScope: (u, c) => {
874
+ const l = t.getState(), d = l.scopes.get(u);
875
+ if (!d) return null;
876
+ const h = c.comment !== void 0 ? me(d, c.comment) : d, v = new Map(l.scopes);
877
+ return v.set(u, h), t.setState({ scopes: v }), n.emit("scope:update", { scope: h }), h;
878
+ },
879
+ deleteScope: (u) => {
880
+ const c = t.getState(), l = c.scopes.get(u);
881
+ if (!l) return !1;
882
+ const d = l.number, h = new Map(c.scopes);
883
+ h.delete(u);
884
+ const v = ge(h, d);
885
+ return t.batch(() => {
886
+ t.setState({
887
+ scopes: v,
888
+ deletingMarkerId: u,
889
+ renumberFrom: d
890
+ }), setTimeout(() => {
891
+ t.setState({
892
+ deletingMarkerId: null,
893
+ renumberFrom: null
894
+ });
895
+ }, 300);
896
+ }), n.emit("scope:delete", { id: u }), !0;
897
+ },
898
+ clearAllScopes: () => {
899
+ const u = t.getState(), c = Array.from(u.scopes.values());
900
+ return t.batch(() => {
901
+ t.setState({
902
+ scopes: /* @__PURE__ */ new Map(),
903
+ selectedAnnotationId: null,
904
+ showClearedFeedback: !0
905
+ }), setTimeout(() => {
906
+ t.setState({ showClearedFeedback: !1 });
907
+ }, 2e3);
908
+ }), n.emit("scopes:clear", { scopes: c }), c;
909
+ },
910
+ selectScope: (u) => {
911
+ t.setState({ selectedAnnotationId: u }), n.emit("scope:select", { id: u });
912
+ },
913
+ getScope: (u) => t.getState().scopes.get(u),
914
+ getAllScopes: () => Array.from(t.getState().scopes.values()).sort((u, c) => u.number - c.number),
915
+ getScopeCount: () => t.getState().scopes.size
916
+ };
917
+ }
918
+ const ve = "annotation-scopes-", ht = "annotation-settings", xe = 7 * 24 * 60 * 60 * 1e3;
919
+ function mt() {
920
+ return ve + window.location.pathname;
921
+ }
922
+ function ye(t) {
923
+ return {
924
+ id: t.id,
925
+ number: t.number,
926
+ comment: t.comment,
927
+ elementInfo: t.elementInfo,
928
+ createdAt: t.createdAt,
929
+ updatedAt: t.updatedAt,
930
+ selectedText: t.selectedText,
931
+ isMultiSelect: t.isMultiSelect,
932
+ clickX: t.clickX,
933
+ clickY: t.clickY
934
+ };
935
+ }
936
+ function ke(t) {
937
+ return {
938
+ ...t,
939
+ element: null
940
+ // DOM reference can't be restored
941
+ };
942
+ }
943
+ function Se(t) {
944
+ const n = Date.now() - xe;
945
+ return t.filter((e) => e.createdAt > n);
946
+ }
947
+ function we(t) {
948
+ try {
949
+ const n = mt(), e = Array.from(t.values()).map(ye);
950
+ return localStorage.setItem(n, JSON.stringify(e)), !0;
951
+ } catch (n) {
952
+ return console.error("[Annotation] Failed to save scopes:", n), !1;
953
+ }
954
+ }
955
+ function $e() {
956
+ try {
957
+ const t = mt(), n = localStorage.getItem(t);
958
+ if (!n)
959
+ return /* @__PURE__ */ new Map();
960
+ const e = JSON.parse(n), o = Se(e);
961
+ o.length !== e.length && localStorage.setItem(t, JSON.stringify(o));
962
+ const a = /* @__PURE__ */ new Map();
963
+ for (const r of o)
964
+ a.set(r.id, ke(r));
965
+ return a;
966
+ } catch (t) {
967
+ return console.error("[Annotation] Failed to load scopes:", t), /* @__PURE__ */ new Map();
968
+ }
969
+ }
970
+ function Ae(t) {
971
+ try {
972
+ return localStorage.setItem(ht, JSON.stringify(t)), !0;
973
+ } catch (n) {
974
+ return console.error("[Annotation] Failed to save settings:", n), !1;
975
+ }
976
+ }
977
+ function Ee() {
978
+ try {
979
+ const t = localStorage.getItem(ht);
980
+ return t ? JSON.parse(t) : null;
981
+ } catch (t) {
982
+ return console.error("[Annotation] Failed to load settings:", t), null;
983
+ }
984
+ }
985
+ function Ce(t, n = 1e3) {
986
+ let e = null;
987
+ const o = () => {
988
+ e !== null && (clearTimeout(e), e = null), we(t());
989
+ };
990
+ return { save: () => {
991
+ e !== null && clearTimeout(e), e = setTimeout(o, n);
992
+ }, flush: o, destroy: () => {
993
+ e !== null && (clearTimeout(e), e = null);
994
+ } };
995
+ }
996
+ function Me() {
997
+ return {
998
+ userAgent: navigator.userAgent,
999
+ viewport: {
1000
+ width: window.innerWidth,
1001
+ height: window.innerHeight
1002
+ },
1003
+ devicePixelRatio: window.devicePixelRatio,
1004
+ url: window.location.href,
1005
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1006
+ scrollPosition: {
1007
+ x: window.scrollX,
1008
+ y: window.scrollY
1009
+ }
1010
+ };
1011
+ }
1012
+ function Ie(t) {
1013
+ const n = t.elementInfo.humanReadable, e = t.comment || "(no comment)";
1014
+ return `${t.number}. **${n}**: ${e}`;
1015
+ }
1016
+ function Te(t) {
1017
+ const n = [];
1018
+ return n.push(`### ${t.number}. ${t.elementInfo.humanReadable}`), n.push(`**Location:** ${t.elementInfo.selectorPath}`), t.selectedText && n.push(`**Selected text:** "${t.selectedText}"`), n.push(`**Feedback:** ${t.comment || "(no comment)"}`), n.join(`
1019
+ `);
1020
+ }
1021
+ function Le(t) {
1022
+ const n = [], e = t.elementInfo;
1023
+ n.push(`### ${t.number}. ${e.humanReadable}`), n.push(""), n.push(`**Location:** \`${e.selectorPath}\``), e.id && n.push(`**ID:** ${e.id}`), e.classes.length > 0 && n.push(`**Classes:** ${e.classes.join(", ")}`);
1024
+ const o = e.rect;
1025
+ n.push(`**Position:** ${Math.round(o.left)}x${Math.round(o.top)}, ${Math.round(o.width)}×${Math.round(o.height)}px`), e.isFixed && n.push("**Positioning:** Fixed/Sticky"), t.selectedText && n.push(`**Selected text:** "${t.selectedText}"`);
1026
+ const a = e.nearbyContext;
1027
+ return (a.parent || a.containingLandmark) && (n.push(""), n.push("**Context:**"), a.containingLandmark && n.push(`- Landmark: ${a.containingLandmark}`), a.parent && n.push(`- Parent: ${a.parent}`), a.previousSibling && n.push(`- Previous: ${a.previousSibling}`), a.nextSibling && n.push(`- Next: ${a.nextSibling}`)), n.push(""), n.push(`**Feedback:** ${t.comment || "(no comment)"}`), n.join(`
1028
+ `);
1029
+ }
1030
+ function Fe(t, n) {
1031
+ const e = [], o = t.elementInfo;
1032
+ e.push(`### ${t.number}. ${o.humanReadable}`), e.push(""), e.push("#### DOM Path"), e.push("```"), e.push(o.fullDomPath), e.push("```"), e.push(""), e.push(`**Selector:** \`${o.selectorPath}\``), e.push(""), e.push("#### Element Details"), e.push(`- **Tag:** ${o.tagName}`), o.id && e.push(`- **ID:** ${o.id}`), o.classes.length > 0 && e.push(`- **Classes:** ${o.classes.join(", ")}`);
1033
+ const a = Object.entries(o.attributes);
1034
+ if (a.length > 0) {
1035
+ e.push("- **Attributes:**");
1036
+ for (const [p, f] of a.slice(0, 10))
1037
+ e.push(` - ${p}: "${f}"`);
1038
+ }
1039
+ o.innerText && e.push(`- **Text content:** "${o.innerText}"`), e.push(""), e.push("#### Position & Dimensions");
1040
+ const r = o.rect;
1041
+ e.push(`- **Bounding box:** (${Math.round(r.left)}, ${Math.round(r.top)}) to (${Math.round(r.right)}, ${Math.round(r.bottom)})`), e.push(`- **Size:** ${Math.round(r.width)}×${Math.round(r.height)}px`), e.push(`- **Fixed positioning:** ${o.isFixed ? "Yes" : "No"}`), e.push(""), e.push("#### Accessibility");
1042
+ const s = o.accessibility;
1043
+ e.push(`- **Role:** ${s.role || "none"}`), e.push(`- **Interactive:** ${s.isInteractive ? "Yes" : "No"}`), s.ariaLabel && e.push(`- **ARIA Label:** "${s.ariaLabel}"`), s.ariaDescribedBy && e.push(`- **Described by:** "${s.ariaDescribedBy}"`), s.tabIndex !== null && e.push(`- **Tab index:** ${s.tabIndex}`), e.push(""), o.computedStyles && (e.push("#### Computed Styles"), e.push("```css"), e.push(se(o.computedStyles)), e.push("```"), e.push(""));
1044
+ const i = o.nearbyContext;
1045
+ return e.push("#### Context"), i.containingLandmark && e.push(`- **Landmark:** ${i.containingLandmark}`), i.parent && e.push(`- **Parent:** ${i.parent}`), i.previousSibling && e.push(`- **Previous sibling:** ${i.previousSibling}`), i.nextSibling && e.push(`- **Next sibling:** ${i.nextSibling}`), e.push(""), t.selectedText && (e.push(`**Selected text:** "${t.selectedText}"`), e.push("")), t.isMultiSelect && (e.push("*Created via multi-select*"), e.push("")), e.push("#### Metadata"), e.push(`- **Created:** ${new Date(t.createdAt).toISOString()}`), e.push(`- **Updated:** ${new Date(t.updatedAt).toISOString()}`), e.push(""), e.push("#### Feedback"), e.push(t.comment || "(no comment)"), e.join(`
1046
+ `);
1047
+ }
1048
+ function ze(t, n) {
1049
+ const e = [], o = window.location.pathname;
1050
+ return e.push(`## Page Feedback: ${o}`), t === "compact" ? (e.push(""), e.join(`
1051
+ `)) : (e.push(`**Viewport:** ${window.innerWidth}×${window.innerHeight}`), e.push(`**Scopes:** ${n}`), e.push(""), e.join(`
1052
+ `));
1053
+ }
1054
+ function Pe(t, n) {
1055
+ const e = [];
1056
+ return e.push(`## Page Feedback: ${t.url}`), e.push(""), e.push("### Environment"), e.push(`- **URL:** ${t.url}`), e.push(`- **Viewport:** ${t.viewport.width}×${t.viewport.height}`), e.push(`- **Device pixel ratio:** ${t.devicePixelRatio}`), e.push(`- **Scroll position:** (${t.scrollPosition.x}, ${t.scrollPosition.y})`), e.push(`- **Timestamp:** ${t.timestamp}`), e.push(`- **User agent:** ${t.userAgent}`), e.push(`- **Total scopes:** ${n}`), e.push(""), e.push("---"), e.push(""), e.join(`
1057
+ `);
1058
+ }
1059
+ function Q(t, n) {
1060
+ if (t.length === 0)
1061
+ return `## Page Feedback
1062
+
1063
+ No scopes created.`;
1064
+ const e = [...t].sort((r, s) => r.number - s.number), o = n === "forensic" ? Me() : null, a = [];
1065
+ n === "forensic" && o ? a.push(Pe(o, t.length)) : a.push(ze(n, t.length));
1066
+ for (const r of e) {
1067
+ switch (n) {
1068
+ case "compact":
1069
+ a.push(Ie(r));
1070
+ break;
1071
+ case "standard":
1072
+ a.push(Te(r));
1073
+ break;
1074
+ case "detailed":
1075
+ a.push(Le(r));
1076
+ break;
1077
+ case "forensic":
1078
+ a.push(Fe(r));
1079
+ break;
1080
+ }
1081
+ n !== "compact" && (a.push(""), a.push("---"), a.push(""));
1082
+ }
1083
+ return n === "compact" ? a.join(`
1084
+ `) : a.join(`
1085
+ `).trim();
1086
+ }
1087
+ async function Ye(t) {
1088
+ try {
1089
+ return await navigator.clipboard.writeText(t), !0;
1090
+ } catch (n) {
1091
+ try {
1092
+ const e = document.createElement("textarea");
1093
+ e.value = t, e.style.position = "fixed", e.style.left = "-9999px", document.body.appendChild(e), e.select();
1094
+ const o = document.execCommand("copy");
1095
+ return document.body.removeChild(e), o;
1096
+ } catch {
1097
+ return console.error("[Annotation] Failed to copy to clipboard:", n), !1;
1098
+ }
1099
+ }
1100
+ }
1101
+ const B = "data-annotation-toolbar", W = "data-annotation-marker", U = "data-annotation-popup", q = "data-annotation-settings";
1102
+ function P(t) {
1103
+ return t ? t.tagName.toLowerCase() === "agent-ui-annotation" || t.closest("agent-ui-annotation") ? !0 : t.hasAttribute(B) || t.hasAttribute(W) || t.hasAttribute(U) || t.hasAttribute(q) || t.closest(`[${B}], [${W}], [${U}], [${q}]`) !== null : !1;
1104
+ }
1105
+ function Re(t) {
1106
+ const n = t.composedPath();
1107
+ for (const e of n)
1108
+ if (e instanceof Element && (e.tagName.toLowerCase() === "agent-ui-annotation" || e.hasAttribute && (e.hasAttribute(B) || e.hasAttribute(W) || e.hasAttribute(U) || e.hasAttribute(q))))
1109
+ return !0;
1110
+ return !1;
1111
+ }
1112
+ function He(t) {
1113
+ const n = t.target;
1114
+ return P(n) ? null : n;
1115
+ }
1116
+ function Xe(t, n) {
1117
+ let e = !1;
1118
+ const o = (c) => {
1119
+ const l = t.getState();
1120
+ if (l.mode === "disabled" || Re(c) || l.settingsPanelVisible) return;
1121
+ const d = He(c);
1122
+ if (!d) return;
1123
+ l.settings.blockInteractions && d.matches('a, button, input, select, textarea, [role="button"], [onclick]') && (c.preventDefault(), c.stopPropagation());
1124
+ const h = l.settings.outputLevel === "forensic", v = D(d, h), g = c.clientX, b = v.isFixed ? c.clientY : c.clientY + window.scrollY;
1125
+ n.emit("element:click", {
1126
+ element: d,
1127
+ elementInfo: v,
1128
+ clickX: g,
1129
+ clickY: b
1130
+ });
1131
+ }, a = (c) => {
1132
+ if (t.getState().mode !== "multi-select") return;
1133
+ const d = c.target;
1134
+ if (P(d)) return;
1135
+ const h = {
1136
+ x: c.clientX,
1137
+ y: c.clientY
1138
+ };
1139
+ n.emit("multiselect:start", { position: h });
1140
+ }, r = (c) => {
1141
+ const l = t.getState();
1142
+ if (!(!l.isSelecting && l.selectionRect === null) && l.isSelecting && l.selectionRect) {
1143
+ const d = {
1144
+ startX: l.selectionRect.startX,
1145
+ startY: l.selectionRect.startY,
1146
+ endX: c.clientX,
1147
+ endY: c.clientY
1148
+ };
1149
+ n.emit("multiselect:update", { rect: d });
1150
+ }
1151
+ }, s = (c) => {
1152
+ const l = t.getState();
1153
+ if (!l.isSelecting) return;
1154
+ const d = l.selectionRect;
1155
+ if (!d) return;
1156
+ const h = De(d);
1157
+ n.emit("multiselect:end", { elements: h });
1158
+ }, i = () => {
1159
+ t.setState({ scrollY: window.scrollY });
1160
+ }, p = (c) => {
1161
+ const l = t.getState();
1162
+ c.key === "Escape" && (l.popupVisible ? (t.setState({ popupVisible: !1, popupAnnotationId: null }), c.preventDefault()) : l.isSelecting ? (t.setState({ isSelecting: !1, selectionRect: null }), c.preventDefault()) : l.mode !== "disabled" && (n.emit("deactivate", void 0), c.preventDefault()));
1163
+ };
1164
+ return {
1165
+ attach: () => {
1166
+ e || (document.addEventListener("click", o, !0), document.addEventListener("mousedown", a, !0), document.addEventListener("mousemove", r, !0), document.addEventListener("mouseup", s, !0), document.addEventListener("scroll", i, { passive: !0 }), document.addEventListener("keydown", p, !0), e = !0);
1167
+ },
1168
+ detach: () => {
1169
+ e && (document.removeEventListener("click", o, !0), document.removeEventListener("mousedown", a, !0), document.removeEventListener("mousemove", r, !0), document.removeEventListener("mouseup", s, !0), document.removeEventListener("scroll", i), document.removeEventListener("keydown", p, !0), e = !1);
1170
+ },
1171
+ isActive: () => e
1172
+ };
1173
+ }
1174
+ function De(t) {
1175
+ const n = Math.min(t.startX, t.endX), e = Math.max(t.startX, t.endX), o = Math.min(t.startY, t.endY), a = Math.max(t.startY, t.endY), s = document.querySelectorAll("button, a, input, img, p, h1, h2, h3, h4, h5, h6, li, label, td, th"), i = {
1176
+ width: window.innerWidth,
1177
+ height: window.innerHeight
1178
+ }, p = [];
1179
+ for (const f of s) {
1180
+ if (P(f)) continue;
1181
+ const u = f.getBoundingClientRect();
1182
+ u.right < n || u.left > e || u.bottom < o || u.top > a || u.width > i.width * 0.8 && u.height > i.height * 0.5 || u.width < 10 || u.height < 10 || p.push(f);
1183
+ }
1184
+ return p.filter((f) => !p.some(
1185
+ (u) => u !== f && f.contains(u)
1186
+ ));
1187
+ }
1188
+ function Oe(t, n, e = {}) {
1189
+ const { leading: o = !0, trailing: a = !0 } = e;
1190
+ let r = null, s = null, i = null, p = 0;
1191
+ const f = (b) => {
1192
+ p = b;
1193
+ const y = s;
1194
+ s = null, t(...y);
1195
+ }, u = (b) => {
1196
+ const y = i !== null ? b - i : 0, S = b - p;
1197
+ return i === null || y >= n || y < 0 || S >= n;
1198
+ }, c = (b) => {
1199
+ const y = i !== null ? b - i : 0, S = n - y;
1200
+ return Math.max(0, S);
1201
+ }, l = () => {
1202
+ const b = Date.now();
1203
+ if (u(b))
1204
+ return d(b);
1205
+ r = setTimeout(l, c(b));
1206
+ }, d = (b) => {
1207
+ r = null, a && s && f(b), s = null;
1208
+ }, h = () => {
1209
+ r !== null && clearTimeout(r), p = 0, s = null, i = null, r = null;
1210
+ }, v = () => {
1211
+ r !== null && d(Date.now());
1212
+ }, g = (...b) => {
1213
+ const y = Date.now(), S = u(y);
1214
+ s = b, i = y, S && r === null && (o && f(y), r = setTimeout(l, n));
1215
+ };
1216
+ return g.cancel = h, g.flush = v, g;
1217
+ }
1218
+ const Ne = 50;
1219
+ function je(t, n) {
1220
+ let e = !1, o = null;
1221
+ const r = Oe((u) => {
1222
+ const c = t.getState();
1223
+ if (c.mode === "disabled" || c.isSelecting) {
1224
+ c.hoveredElement !== null && (t.setState({
1225
+ hoveredElement: null,
1226
+ hoveredElementInfo: null
1227
+ }), n.emit("element:hover", { element: null, elementInfo: null }));
1228
+ return;
1229
+ }
1230
+ if (c.popupVisible || c.settingsPanelVisible)
1231
+ return;
1232
+ const l = u.target;
1233
+ if (P(l)) {
1234
+ o !== null && (o = null, t.setState({
1235
+ hoveredElement: null,
1236
+ hoveredElementInfo: null
1237
+ }), n.emit("element:hover", { element: null, elementInfo: null }));
1238
+ return;
1239
+ }
1240
+ if (l === o)
1241
+ return;
1242
+ o = l;
1243
+ const d = c.settings.outputLevel === "forensic", h = D(l, d);
1244
+ t.setState({
1245
+ hoveredElement: l,
1246
+ hoveredElementInfo: h
1247
+ }), n.emit("element:hover", { element: l, elementInfo: h });
1248
+ }, Ne, {
1249
+ leading: !0,
1250
+ trailing: !0
1251
+ }), s = (u) => {
1252
+ const c = u.relatedTarget;
1253
+ c && document.documentElement.contains(c) || (o = null, t.setState({
1254
+ hoveredElement: null,
1255
+ hoveredElementInfo: null
1256
+ }), n.emit("element:hover", { element: null, elementInfo: null }));
1257
+ };
1258
+ return {
1259
+ attach: () => {
1260
+ e || (document.addEventListener("mousemove", r, { passive: !0 }), document.addEventListener("mouseleave", s), e = !0);
1261
+ },
1262
+ detach: () => {
1263
+ e && (document.removeEventListener("mousemove", r), document.removeEventListener("mouseleave", s), r.cancel(), o = null, t.setState({
1264
+ hoveredElement: null,
1265
+ hoveredElementInfo: null
1266
+ }), e = !1);
1267
+ },
1268
+ clearHover: () => {
1269
+ o = null, t.setState({
1270
+ hoveredElement: null,
1271
+ hoveredElementInfo: null
1272
+ }), n.emit("element:hover", { element: null, elementInfo: null });
1273
+ },
1274
+ isActive: () => e
1275
+ };
1276
+ }
1277
+ const Ve = 8, tt = 20;
1278
+ function _e(t, n) {
1279
+ let e = null, o = !1, a = !1;
1280
+ const r = () => {
1281
+ document.body.style.userSelect = "none", document.body.style.webkitUserSelect = "none";
1282
+ }, s = () => {
1283
+ document.body.style.userSelect = "", document.body.style.webkitUserSelect = "";
1284
+ }, i = (g) => {
1285
+ e = g, o = !1;
1286
+ }, p = (g) => {
1287
+ if (!e) return;
1288
+ const b = g.clientX - e.x, y = g.clientY - e.y, S = Math.sqrt(b * b + y * y);
1289
+ if (!o && S > Ve) {
1290
+ o = !0, r();
1291
+ const C = {
1292
+ startX: e.x,
1293
+ startY: e.y,
1294
+ endX: g.clientX,
1295
+ endY: g.clientY
1296
+ };
1297
+ t.setState({
1298
+ isSelecting: !0,
1299
+ selectionRect: C,
1300
+ selectionPreviewElements: N(C)
1301
+ });
1302
+ }
1303
+ if (o) {
1304
+ const C = {
1305
+ startX: e.x,
1306
+ startY: e.y,
1307
+ endX: g.clientX,
1308
+ endY: g.clientY
1309
+ };
1310
+ t.setState({
1311
+ selectionRect: C,
1312
+ selectionPreviewElements: N(C)
1313
+ });
1314
+ }
1315
+ }, f = () => {
1316
+ const g = t.getState(), b = g.selectionRect, y = g.selectionPreviewElements;
1317
+ if (e = null, o = !1, s(), t.setState({
1318
+ isSelecting: !1,
1319
+ selectionRect: null,
1320
+ selectionPreviewElements: []
1321
+ }), !b) return [];
1322
+ const S = Math.abs(b.endX - b.startX), C = Math.abs(b.endY - b.startY);
1323
+ return S < tt && C < tt ? [] : y.length > 0 ? y : N(b);
1324
+ }, u = () => {
1325
+ e = null, o = !1, s(), t.setState({
1326
+ isSelecting: !1,
1327
+ selectionRect: null,
1328
+ selectionPreviewElements: []
1329
+ });
1330
+ }, c = (g) => {
1331
+ const b = t.getState();
1332
+ if (b.mode !== "select" && b.mode !== "multi-select" || b.popupVisible) return;
1333
+ const y = g.target;
1334
+ P(y) || g.button === 0 && i({ x: g.clientX, y: g.clientY });
1335
+ }, l = (g) => {
1336
+ e && p(g);
1337
+ }, d = () => {
1338
+ if (!e) return;
1339
+ const g = f();
1340
+ g.length > 0 && n.emit("multiselect:end", { elements: g });
1341
+ };
1342
+ return {
1343
+ attach: () => {
1344
+ a || (document.addEventListener("mousedown", c, !0), document.addEventListener("mousemove", l, !0), document.addEventListener("mouseup", d, !0), a = !0);
1345
+ },
1346
+ detach: () => {
1347
+ a && (document.removeEventListener("mousedown", c, !0), document.removeEventListener("mousemove", l, !0), document.removeEventListener("mouseup", d, !0), u(), a = !1);
1348
+ },
1349
+ cancel: u,
1350
+ isActive: () => a,
1351
+ isDragging: () => o
1352
+ };
1353
+ }
1354
+ function N(t) {
1355
+ const n = Math.min(t.startX, t.endX), e = Math.max(t.startX, t.endX), o = Math.min(t.startY, t.endY), a = Math.max(t.startY, t.endY), s = document.querySelectorAll("button, a, input, img, p, h1, h2, h3, h4, h5, h6, li, label, td, th"), i = {
1356
+ width: window.innerWidth,
1357
+ height: window.innerHeight
1358
+ }, p = [];
1359
+ for (const f of s) {
1360
+ if (P(f)) continue;
1361
+ const u = f.getBoundingClientRect();
1362
+ !(u.right >= n && u.left <= e && u.bottom >= o && u.top <= a) || u.width > i.width * 0.8 && u.height > i.height * 0.5 || u.width < 10 || u.height < 10 || p.push(f);
1363
+ }
1364
+ return p.filter((f) => !p.some(
1365
+ (u) => u !== f && f.contains(u)
1366
+ ));
1367
+ }
1368
+ function Be(t) {
1369
+ const n = Math.min(t.startX, t.endX), e = Math.min(t.startY, t.endY), o = Math.abs(t.endX - t.startX), a = Math.abs(t.endY - t.startY);
1370
+ return { x: n, y: e, width: o, height: a };
1371
+ }
1372
+ const We = "annotation-freeze-styles", Ue = `
1373
+ *:not([data-annotation-toolbar] *):not([data-annotation-marker] *):not([data-annotation-popup] *) {
1374
+ animation-play-state: paused !important;
1375
+ transition: none !important;
1376
+ }
1377
+ `;
1378
+ function qe(t, n) {
1379
+ let e = !1, o = null, a = /* @__PURE__ */ new WeakSet();
1380
+ const r = () => {
1381
+ o || (o = document.createElement("style"), o.id = We, o.textContent = Ue, document.head.appendChild(o));
1382
+ }, s = () => {
1383
+ o && (o.remove(), o = null);
1384
+ }, i = () => {
1385
+ const d = document.querySelectorAll("video");
1386
+ for (const h of d)
1387
+ h.paused || (a.add(h), h.pause());
1388
+ }, p = () => {
1389
+ const d = document.querySelectorAll("video");
1390
+ for (const h of d)
1391
+ a.has(h) && h.play().catch(() => {
1392
+ });
1393
+ a = /* @__PURE__ */ new WeakSet();
1394
+ }, f = () => {
1395
+ e || (r(), i(), e = !0, t.setState({ isFrozen: !0 }), n.emit("freeze:toggle", { frozen: !0 }));
1396
+ }, u = () => {
1397
+ e && (s(), p(), e = !1, t.setState({ isFrozen: !1 }), n.emit("freeze:toggle", { frozen: !1 }));
1398
+ };
1399
+ return {
1400
+ freeze: f,
1401
+ unfreeze: u,
1402
+ toggle: () => {
1403
+ e ? u() : f();
1404
+ },
1405
+ destroy: () => {
1406
+ e && u();
1407
+ },
1408
+ isFrozen: () => e
1409
+ };
1410
+ }
1411
+ const Ke = "annotation-cursor-styles", Ge = `
1412
+ /* Crosshair for most elements */
1413
+ body:not([data-annotation-disabled]) *:not([data-annotation-toolbar] *):not([data-annotation-marker] *):not([data-annotation-popup] *) {
1414
+ cursor: crosshair !important;
1415
+ }
1416
+
1417
+ /* Text cursor for text selection */
1418
+ body:not([data-annotation-disabled]) p:not([data-annotation-toolbar] *),
1419
+ body:not([data-annotation-disabled]) span:not([data-annotation-toolbar] *),
1420
+ body:not([data-annotation-disabled]) h1:not([data-annotation-toolbar] *),
1421
+ body:not([data-annotation-disabled]) h2:not([data-annotation-toolbar] *),
1422
+ body:not([data-annotation-disabled]) h3:not([data-annotation-toolbar] *),
1423
+ body:not([data-annotation-disabled]) h4:not([data-annotation-toolbar] *),
1424
+ body:not([data-annotation-disabled]) h5:not([data-annotation-toolbar] *),
1425
+ body:not([data-annotation-disabled]) h6:not([data-annotation-toolbar] *),
1426
+ body:not([data-annotation-disabled]) li:not([data-annotation-toolbar] *),
1427
+ body:not([data-annotation-disabled]) td:not([data-annotation-toolbar] *),
1428
+ body:not([data-annotation-disabled]) th:not([data-annotation-toolbar] *),
1429
+ body:not([data-annotation-disabled]) code:not([data-annotation-toolbar] *),
1430
+ body:not([data-annotation-disabled]) pre:not([data-annotation-toolbar] *) {
1431
+ cursor: text !important;
1432
+ }
1433
+
1434
+ /* Pointer for Annotation UI elements */
1435
+ [data-annotation-marker],
1436
+ [data-annotation-marker] *,
1437
+ [data-annotation-toolbar] button,
1438
+ [data-annotation-popup] button {
1439
+ cursor: pointer !important;
1440
+ }
1441
+
1442
+ /* Default for toolbar */
1443
+ [data-annotation-toolbar],
1444
+ [data-annotation-toolbar] *,
1445
+ [data-annotation-popup],
1446
+ [data-annotation-popup] * {
1447
+ cursor: default !important;
1448
+ }
1449
+
1450
+ /* Crosshair for multi-select mode */
1451
+ body[data-annotation-multiselect] *:not([data-annotation-toolbar] *):not([data-annotation-marker] *):not([data-annotation-popup] *) {
1452
+ cursor: crosshair !important;
1453
+ }
1454
+
1455
+ /* Move cursor when dragging toolbar */
1456
+ body[data-annotation-dragging] * {
1457
+ cursor: move !important;
1458
+ }
1459
+ `;
1460
+ let L = null;
1461
+ function Ze() {
1462
+ L || (L = document.createElement("style"), L.id = Ke, L.textContent = Ge, document.head.appendChild(L));
1463
+ }
1464
+ function Je() {
1465
+ L && (L.remove(), L = null);
1466
+ }
1467
+ function j(t) {
1468
+ t ? document.body.setAttribute("data-annotation-multiselect", "") : document.body.removeAttribute("data-annotation-multiselect");
1469
+ }
1470
+ function Qe(t) {
1471
+ document.body.removeAttribute("data-annotation-disabled");
1472
+ }
1473
+ function tn() {
1474
+ Je(), document.body.removeAttribute("data-annotation-multiselect"), document.body.removeAttribute("data-annotation-dragging"), document.body.removeAttribute("data-annotation-disabled");
1475
+ }
1476
+ function en(t = {}) {
1477
+ const {
1478
+ settings: n,
1479
+ loadPersisted: e = !0,
1480
+ onScopeCreate: o,
1481
+ onScopeUpdate: a,
1482
+ onScopeDelete: r,
1483
+ onScopesClear: s,
1484
+ onCopy: i,
1485
+ copyToClipboard: p = !0
1486
+ } = t, f = e ? Ee() : null, u = e ? $e() : /* @__PURE__ */ new Map(), c = {
1487
+ ...st,
1488
+ ...f,
1489
+ ...n
1490
+ }, l = $t(
1491
+ Ct({
1492
+ settings: c,
1493
+ scopes: u
1494
+ })
1495
+ ), d = At(), h = be(l, d), v = qe(l, d), g = Xe(l, d), b = je(l, d), y = _e(l, d), S = Ce(() => l.getState().scopes, 1e3);
1496
+ o && d.on("scope:create", ({ scope: m }) => o(m)), a && d.on("scope:update", ({ scope: m }) => a(m)), r && d.on("scope:delete", ({ id: m }) => r(m)), s && d.on("scopes:clear", ({ scopes: m }) => s(m)), d.on("scope:create", () => S.save()), d.on("scope:update", () => S.save()), d.on("scope:delete", () => S.save()), d.on("scopes:clear", () => S.save()), d.on("settings:change", ({ settings: m }) => {
1497
+ const k = l.getState().settings;
1498
+ Ae({ ...k, ...m });
1499
+ }), d.on("element:click", ({ element: m, elementInfo: k, clickX: A, clickY: M }) => {
1500
+ if (l.getState().mode === "disabled") return;
1501
+ const z = k.isFixed ? M : M - window.scrollY;
1502
+ l.setState({
1503
+ popupVisible: !0,
1504
+ popupAnnotationId: null,
1505
+ popupElementInfo: k,
1506
+ popupClickX: A,
1507
+ // X is always viewport-relative
1508
+ popupClickY: z,
1509
+ // Convert to viewport for popup positioning
1510
+ pendingMarkerX: A,
1511
+ // Document coords for marker
1512
+ pendingMarkerY: M,
1513
+ pendingMarkerIsFixed: k.isFixed,
1514
+ hoveredElement: m,
1515
+ hoveredElementInfo: k
1516
+ });
1517
+ }), d.on("multiselect:end", ({ elements: m }) => {
1518
+ if (m.length === 0) return;
1519
+ const A = l.getState().settings.outputLevel === "forensic", M = m.map((I) => D(I, A)), T = m.map((I) => I.getBoundingClientRect()), z = Math.min(...T.map((I) => I.left)), bt = Math.max(...T.map((I) => I.right)), vt = Math.min(...T.map((I) => I.top)), xt = Math.max(...T.map((I) => I.bottom)), yt = (z + bt) / 2, kt = (vt + xt) / 2;
1520
+ l.setState({
1521
+ popupVisible: !0,
1522
+ popupAnnotationId: null,
1523
+ popupElementInfo: M[0],
1524
+ // Primary element for display
1525
+ popupClickX: yt,
1526
+ popupClickY: kt,
1527
+ pendingMarkerX: 0,
1528
+ // No single pending marker for multi-select
1529
+ pendingMarkerY: 0,
1530
+ pendingMarkerIsFixed: !1,
1531
+ multiSelectElements: m,
1532
+ multiSelectInfos: M,
1533
+ hoveredElement: m[0],
1534
+ hoveredElementInfo: M[0]
1535
+ });
1536
+ });
1537
+ const C = (m = "select") => {
1538
+ l.getState().mode === "disabled" && (l.batch(() => {
1539
+ l.setState({
1540
+ mode: m,
1541
+ toolbarExpanded: !0,
1542
+ markersVisible: !0,
1543
+ scrollY: window.scrollY
1544
+ // Initialize scroll position
1545
+ });
1546
+ }), g.attach(), b.attach(), y.attach(), Ze(), Qe(), m === "multi-select" && j(!0), d.emit("activate", void 0), d.emit("mode:change", { mode: m }));
1547
+ }, Y = () => {
1548
+ const m = l.getState();
1549
+ m.mode !== "disabled" && (l.batch(() => {
1550
+ l.setState({
1551
+ mode: "disabled",
1552
+ toolbarExpanded: !1,
1553
+ popupVisible: !1,
1554
+ popupAnnotationId: null,
1555
+ isSelecting: !1,
1556
+ selectionRect: null
1557
+ });
1558
+ }), g.detach(), b.detach(), y.detach(), tn(), m.isFrozen && v.unfreeze(), d.emit("deactivate", void 0), d.emit("mode:change", { mode: "disabled" }));
1559
+ };
1560
+ return {
1561
+ store: l,
1562
+ eventBus: d,
1563
+ scopes: h,
1564
+ freeze: v,
1565
+ activate: C,
1566
+ deactivate: Y,
1567
+ toggle: () => {
1568
+ l.getState().mode === "disabled" ? C() : Y();
1569
+ },
1570
+ isActive: () => l.getState().mode !== "disabled",
1571
+ setMode: (m) => {
1572
+ const k = l.getState();
1573
+ if (m === "disabled") {
1574
+ Y();
1575
+ return;
1576
+ }
1577
+ if (k.mode === "disabled") {
1578
+ C(m);
1579
+ return;
1580
+ }
1581
+ m === "multi-select" && k.mode !== "multi-select" ? (y.attach(), j(!0)) : m === "select" && k.mode === "multi-select" && (y.detach(), j(!1)), l.setState({ mode: m }), d.emit("mode:change", { mode: m });
1582
+ },
1583
+ getMode: () => l.getState().mode,
1584
+ updateSettings: (m) => {
1585
+ const A = { ...l.getState().settings, ...m };
1586
+ l.setState({ settings: A }), d.emit("settings:change", { settings: m });
1587
+ },
1588
+ getSettings: () => l.getState().settings,
1589
+ copyOutput: async (m) => {
1590
+ const k = l.getState(), A = m || k.settings.outputLevel, M = h.getAllScopes(), T = Q(M, A);
1591
+ let z = !0;
1592
+ return p && (z = await Ye(T)), z && (l.setState({ showCopiedFeedback: !0 }), setTimeout(() => {
1593
+ l.setState({ showCopiedFeedback: !1 });
1594
+ }, 2e3), i && i(T, A), d.emit("output:copy", { content: T, level: A }), k.settings.autoClearAfterCopy && h.clearAllScopes()), z;
1595
+ },
1596
+ getOutput: (m) => {
1597
+ const k = l.getState(), A = m || k.settings.outputLevel, M = h.getAllScopes();
1598
+ return Q(M, A);
1599
+ },
1600
+ showPopup: (m) => {
1601
+ if (m) {
1602
+ const k = l.getState().scopes.get(m);
1603
+ if (k) {
1604
+ l.setState({
1605
+ popupVisible: !0,
1606
+ popupAnnotationId: m,
1607
+ popupElementInfo: k.elementInfo,
1608
+ popupClickX: k.clickX,
1609
+ popupClickY: k.clickY
1610
+ });
1611
+ return;
1612
+ }
1613
+ }
1614
+ l.setState({
1615
+ popupVisible: !0,
1616
+ popupAnnotationId: m || null
1617
+ });
1618
+ },
1619
+ hidePopup: () => {
1620
+ l.setState({
1621
+ popupVisible: !1,
1622
+ popupAnnotationId: null,
1623
+ popupElementInfo: null,
1624
+ popupClickX: 0,
1625
+ popupClickY: 0,
1626
+ pendingMarkerX: 0,
1627
+ pendingMarkerY: 0,
1628
+ pendingMarkerIsFixed: !1,
1629
+ multiSelectElements: [],
1630
+ multiSelectInfos: []
1631
+ });
1632
+ },
1633
+ subscribe: (m) => l.subscribe(m),
1634
+ destroy: () => {
1635
+ Y(), S.flush(), S.destroy(), v.destroy(), d.destroy(), l.destroy();
1636
+ }
1637
+ };
1638
+ }
1639
+ const nn = {
1640
+ // Background
1641
+ "--as-bg-primary": "rgba(255, 255, 255, 0.95)",
1642
+ "--as-bg-secondary": "rgba(245, 245, 245, 0.95)",
1643
+ "--as-bg-hover": "rgba(0, 0, 0, 0.05)",
1644
+ "--as-bg-active": "rgba(0, 0, 0, 0.1)",
1645
+ "--as-bg-overlay": "rgba(255, 255, 255, 0.8)",
1646
+ // Text
1647
+ "--as-text-primary": "#1a1a1a",
1648
+ "--as-text-secondary": "#666666",
1649
+ "--as-text-muted": "#999999",
1650
+ "--as-text-inverse": "#ffffff",
1651
+ // Border
1652
+ "--as-border-primary": "rgba(0, 0, 0, 0.1)",
1653
+ "--as-border-secondary": "rgba(0, 0, 0, 0.05)",
1654
+ // Accent (scope color)
1655
+ "--as-accent": "#AF52DE",
1656
+ "--as-accent-hover": "#9B47C7",
1657
+ "--as-accent-light": "rgba(175, 82, 222, 0.1)",
1658
+ // Status
1659
+ "--as-success": "#34C759",
1660
+ "--as-warning": "#FF9500",
1661
+ "--as-error": "#FF3B30",
1662
+ // Shadow
1663
+ "--as-shadow-sm": "0 1px 2px rgba(0, 0, 0, 0.05)",
1664
+ "--as-shadow-md": "0 4px 12px rgba(0, 0, 0, 0.1)",
1665
+ "--as-shadow-lg": "0 8px 24px rgba(0, 0, 0, 0.15)",
1666
+ // Blur
1667
+ "--as-backdrop-blur": "blur(12px)"
1668
+ }, et = {
1669
+ // Background
1670
+ "--as-bg-primary": "rgba(24, 24, 27, 0.95)",
1671
+ "--as-bg-secondary": "rgba(39, 39, 42, 0.95)",
1672
+ "--as-bg-hover": "rgba(255, 255, 255, 0.1)",
1673
+ "--as-bg-active": "rgba(255, 255, 255, 0.15)",
1674
+ "--as-bg-overlay": "rgba(24, 24, 27, 0.8)",
1675
+ // Text
1676
+ "--as-text-primary": "#ffffff",
1677
+ "--as-text-secondary": "#a1a1aa",
1678
+ "--as-text-muted": "#71717a",
1679
+ "--as-text-inverse": "#1a1a1a",
1680
+ // Border
1681
+ "--as-border-primary": "rgba(255, 255, 255, 0.1)",
1682
+ "--as-border-secondary": "rgba(255, 255, 255, 0.05)",
1683
+ // Accent (scope color)
1684
+ "--as-accent": "#AF52DE",
1685
+ "--as-accent-hover": "#C77DFF",
1686
+ "--as-accent-light": "rgba(175, 82, 222, 0.2)",
1687
+ // Status
1688
+ "--as-success": "#34C759",
1689
+ "--as-warning": "#FF9500",
1690
+ "--as-error": "#FF3B30",
1691
+ // Shadow
1692
+ "--as-shadow-sm": "0 1px 2px rgba(0, 0, 0, 0.2)",
1693
+ "--as-shadow-md": "0 4px 12px rgba(0, 0, 0, 0.3)",
1694
+ "--as-shadow-lg": "0 8px 24px rgba(0, 0, 0, 0.4)",
1695
+ // Blur
1696
+ "--as-backdrop-blur": "blur(12px)"
1697
+ }, on = {
1698
+ // Spacing
1699
+ "--as-space-xs": "4px",
1700
+ "--as-space-sm": "8px",
1701
+ "--as-space-md": "12px",
1702
+ "--as-space-lg": "16px",
1703
+ "--as-space-xl": "24px",
1704
+ // Border radius
1705
+ "--as-radius-sm": "4px",
1706
+ "--as-radius-md": "8px",
1707
+ "--as-radius-lg": "12px",
1708
+ "--as-radius-full": "9999px",
1709
+ // Typography
1710
+ "--as-font-family": '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
1711
+ "--as-font-mono": 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',
1712
+ "--as-font-size-xs": "10px",
1713
+ "--as-font-size-sm": "12px",
1714
+ "--as-font-size-md": "14px",
1715
+ "--as-font-size-lg": "16px",
1716
+ // Transitions
1717
+ "--as-transition-fast": "100ms ease",
1718
+ "--as-transition-normal": "200ms ease",
1719
+ "--as-transition-slow": "300ms ease",
1720
+ // Z-index
1721
+ "--as-z-toolbar": "999999",
1722
+ "--as-z-markers": "999998",
1723
+ "--as-z-popup": "1000000",
1724
+ "--as-z-tooltip": "1000001",
1725
+ "--as-z-overlay": "999997"
1726
+ };
1727
+ function V(t) {
1728
+ return t === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : t;
1729
+ }
1730
+ function Pn(t) {
1731
+ const n = {
1732
+ purple: "#AF52DE",
1733
+ blue: "#3c82f7",
1734
+ cyan: "#5AC8FA",
1735
+ green: "#34C759",
1736
+ yellow: "#FFD60A",
1737
+ orange: "#FF9500",
1738
+ red: "#FF3B30"
1739
+ };
1740
+ return n[t] || n.purple;
1741
+ }
1742
+ function R(t) {
1743
+ return Object.entries(t).map(([n, e]) => `${n}: ${e};`).join(`
1744
+ `);
1745
+ }
1746
+ const an = `
1747
+ /* CSS Variables */
1748
+ :host {
1749
+ ${R(on)}
1750
+ ${R(nn)}
1751
+ }
1752
+
1753
+ :host([data-theme="dark"]) {
1754
+ ${R(et)}
1755
+ }
1756
+
1757
+ @media (prefers-color-scheme: dark) {
1758
+ :host([data-theme="auto"]) {
1759
+ ${R(et)}
1760
+ }
1761
+ }
1762
+
1763
+ /* Reset */
1764
+ *,
1765
+ *::before,
1766
+ *::after {
1767
+ box-sizing: border-box;
1768
+ margin: 0;
1769
+ padding: 0;
1770
+ }
1771
+
1772
+ /* Base styles */
1773
+ :host {
1774
+ all: initial;
1775
+ font-family: var(--as-font-family);
1776
+ font-size: var(--as-font-size-md);
1777
+ color: var(--as-text-primary);
1778
+ line-height: 1.5;
1779
+ -webkit-font-smoothing: antialiased;
1780
+ -moz-osx-font-smoothing: grayscale;
1781
+ }
1782
+
1783
+ /* Toolbar container */
1784
+ .toolbar {
1785
+ position: fixed;
1786
+ z-index: var(--as-z-toolbar);
1787
+ display: flex;
1788
+ align-items: center;
1789
+ gap: var(--as-space-sm);
1790
+ padding: var(--as-space-sm) var(--as-space-md);
1791
+ background: var(--as-bg-primary);
1792
+ border: 1px solid var(--as-border-primary);
1793
+ border-radius: var(--as-radius-full);
1794
+ box-shadow: var(--as-shadow-lg);
1795
+ backdrop-filter: var(--as-backdrop-blur);
1796
+ user-select: none;
1797
+ transition: transform var(--as-transition-normal), opacity var(--as-transition-normal);
1798
+ }
1799
+
1800
+ .toolbar.collapsed {
1801
+ padding: var(--as-space-sm);
1802
+ }
1803
+
1804
+ .toolbar.dragging {
1805
+ cursor: move;
1806
+ opacity: 0.9;
1807
+ }
1808
+
1809
+ /* Toolbar entrance animation */
1810
+ .toolbar.entering {
1811
+ animation: toolbar-enter 0.3s ease-out;
1812
+ }
1813
+
1814
+ @keyframes toolbar-enter {
1815
+ from {
1816
+ opacity: 0;
1817
+ transform: scale(0.9) translateY(10px);
1818
+ }
1819
+ to {
1820
+ opacity: 1;
1821
+ transform: scale(1) translateY(0);
1822
+ }
1823
+ }
1824
+
1825
+ /* Toolbar buttons */
1826
+ .toolbar-btn {
1827
+ display: flex;
1828
+ align-items: center;
1829
+ justify-content: center;
1830
+ width: 32px;
1831
+ height: 32px;
1832
+ padding: 0;
1833
+ background: transparent;
1834
+ border: none;
1835
+ border-radius: var(--as-radius-md);
1836
+ color: var(--as-text-primary);
1837
+ cursor: pointer;
1838
+ transition: background var(--as-transition-fast), color var(--as-transition-fast);
1839
+ }
1840
+
1841
+ .toolbar-btn:hover {
1842
+ background: var(--as-bg-hover);
1843
+ }
1844
+
1845
+ .toolbar-btn:active {
1846
+ background: var(--as-bg-active);
1847
+ }
1848
+
1849
+ .toolbar-btn.active {
1850
+ background: var(--as-accent-light);
1851
+ color: var(--as-accent);
1852
+ }
1853
+
1854
+ .toolbar-btn svg {
1855
+ width: 18px;
1856
+ height: 18px;
1857
+ }
1858
+
1859
+ /* Toggle button (collapsed state) */
1860
+ .toggle-btn {
1861
+ position: relative;
1862
+ width: 36px;
1863
+ height: 36px;
1864
+ }
1865
+
1866
+ .toggle-btn .badge {
1867
+ position: absolute;
1868
+ top: -4px;
1869
+ right: -4px;
1870
+ min-width: 16px;
1871
+ height: 16px;
1872
+ padding: 0 4px;
1873
+ background: var(--as-accent);
1874
+ border-radius: var(--as-radius-full);
1875
+ color: var(--as-text-inverse);
1876
+ font-size: var(--as-font-size-xs);
1877
+ font-weight: 600;
1878
+ display: flex;
1879
+ align-items: center;
1880
+ justify-content: center;
1881
+ }
1882
+
1883
+ /* Separator */
1884
+ .separator {
1885
+ width: 1px;
1886
+ height: 20px;
1887
+ background: var(--as-border-primary);
1888
+ margin: 0 var(--as-space-xs);
1889
+ }
1890
+
1891
+ /* Scope count */
1892
+ .scope-count {
1893
+ display: flex;
1894
+ align-items: center;
1895
+ gap: var(--as-space-xs);
1896
+ padding: 0 var(--as-space-sm);
1897
+ font-size: var(--as-font-size-sm);
1898
+ font-weight: 500;
1899
+ color: var(--as-text-secondary);
1900
+ }
1901
+
1902
+ .scope-count .count {
1903
+ color: var(--as-text-primary);
1904
+ font-weight: 600;
1905
+ }
1906
+
1907
+ /* Feedback toast */
1908
+ .feedback {
1909
+ position: absolute;
1910
+ top: -40px;
1911
+ left: 50%;
1912
+ transform: translateX(-50%);
1913
+ padding: var(--as-space-sm) var(--as-space-md);
1914
+ background: var(--as-bg-primary);
1915
+ border: 1px solid var(--as-border-primary);
1916
+ border-radius: var(--as-radius-md);
1917
+ box-shadow: var(--as-shadow-md);
1918
+ font-size: var(--as-font-size-sm);
1919
+ white-space: nowrap;
1920
+ animation: feedback-enter 0.2s ease-out;
1921
+ }
1922
+
1923
+ @keyframes feedback-enter {
1924
+ from {
1925
+ opacity: 0;
1926
+ transform: translateX(-50%) translateY(10px);
1927
+ }
1928
+ to {
1929
+ opacity: 1;
1930
+ transform: translateX(-50%) translateY(0);
1931
+ }
1932
+ }
1933
+
1934
+ .feedback.success {
1935
+ border-color: var(--as-success);
1936
+ color: var(--as-success);
1937
+ }
1938
+
1939
+ /* Markers container */
1940
+ .markers {
1941
+ position: fixed;
1942
+ top: 0;
1943
+ left: 0;
1944
+ width: 0;
1945
+ height: 0;
1946
+ z-index: var(--as-z-markers);
1947
+ pointer-events: none;
1948
+ }
1949
+
1950
+ /* Individual marker */
1951
+ .marker {
1952
+ position: absolute;
1953
+ display: flex;
1954
+ align-items: center;
1955
+ justify-content: center;
1956
+ width: 24px;
1957
+ height: 24px;
1958
+ background: var(--as-accent);
1959
+ border: 2px solid white;
1960
+ border-radius: 50%;
1961
+ color: white;
1962
+ font-size: var(--as-font-size-xs);
1963
+ font-weight: 700;
1964
+ box-shadow: var(--as-shadow-md);
1965
+ pointer-events: auto;
1966
+ cursor: pointer;
1967
+ transform: translate(-50%, -50%);
1968
+ transition: transform var(--as-transition-fast), box-shadow var(--as-transition-fast);
1969
+ }
1970
+
1971
+ .marker:hover {
1972
+ transform: translate(-50%, -50%) scale(1.15);
1973
+ box-shadow: var(--as-shadow-lg);
1974
+ }
1975
+
1976
+ .marker.fixed {
1977
+ position: fixed;
1978
+ }
1979
+
1980
+ .marker.pending {
1981
+ opacity: 0.7;
1982
+ animation: marker-pulse 1s ease-in-out infinite;
1983
+ }
1984
+
1985
+ @keyframes marker-pulse {
1986
+ 0%, 100% { transform: translate(-50%, -50%) scale(1); }
1987
+ 50% { transform: translate(-50%, -50%) scale(1.1); }
1988
+ }
1989
+
1990
+ /* Marker animations */
1991
+ .marker.entering {
1992
+ animation: marker-enter 0.25s ease-out;
1993
+ }
1994
+
1995
+ .marker.exiting {
1996
+ animation: marker-exit 0.2s ease-in forwards;
1997
+ }
1998
+
1999
+ @keyframes marker-enter {
2000
+ from {
2001
+ opacity: 0;
2002
+ transform: translate(-50%, -50%) scale(0);
2003
+ }
2004
+ to {
2005
+ opacity: 1;
2006
+ transform: translate(-50%, -50%) scale(1);
2007
+ }
2008
+ }
2009
+
2010
+ @keyframes marker-exit {
2011
+ from {
2012
+ opacity: 1;
2013
+ transform: translate(-50%, -50%) scale(1);
2014
+ }
2015
+ to {
2016
+ opacity: 0;
2017
+ transform: translate(-50%, -50%) scale(0);
2018
+ }
2019
+ }
2020
+
2021
+ /* Marker tooltip */
2022
+ .marker-tooltip {
2023
+ position: absolute;
2024
+ bottom: calc(100% + 8px);
2025
+ left: 50%;
2026
+ transform: translateX(-50%);
2027
+ padding: var(--as-space-sm) var(--as-space-md);
2028
+ background: var(--as-bg-primary);
2029
+ border: 1px solid var(--as-border-primary);
2030
+ border-radius: var(--as-radius-md);
2031
+ box-shadow: var(--as-shadow-md);
2032
+ font-size: var(--as-font-size-sm);
2033
+ white-space: nowrap;
2034
+ max-width: 300px;
2035
+ pointer-events: none;
2036
+ z-index: var(--as-z-tooltip);
2037
+ animation: tooltip-enter 0.15s ease-out;
2038
+ }
2039
+
2040
+ .marker-tooltip::after {
2041
+ content: '';
2042
+ position: absolute;
2043
+ top: 100%;
2044
+ left: 50%;
2045
+ transform: translateX(-50%);
2046
+ border: 6px solid transparent;
2047
+ border-top-color: var(--as-bg-primary);
2048
+ }
2049
+
2050
+ @keyframes tooltip-enter {
2051
+ from {
2052
+ opacity: 0;
2053
+ transform: translateX(-50%) translateY(4px);
2054
+ }
2055
+ to {
2056
+ opacity: 1;
2057
+ transform: translateX(-50%) translateY(0);
2058
+ }
2059
+ }
2060
+
2061
+ .tooltip-element {
2062
+ font-weight: 500;
2063
+ color: var(--as-text-primary);
2064
+ margin-bottom: 2px;
2065
+ }
2066
+
2067
+ .tooltip-comment {
2068
+ color: var(--as-text-secondary);
2069
+ overflow: hidden;
2070
+ text-overflow: ellipsis;
2071
+ }
2072
+
2073
+ /* Popup - Popover style (positioned near click point) */
2074
+ .popup-popover {
2075
+ position: fixed;
2076
+ z-index: var(--as-z-popup);
2077
+ width: 340px;
2078
+ padding: var(--as-space-lg);
2079
+ background: var(--as-bg-primary);
2080
+ border: 1px solid var(--as-border-primary);
2081
+ border-radius: var(--as-radius-lg);
2082
+ box-shadow: var(--as-shadow-lg);
2083
+ animation: popover-enter 0.15s ease-out;
2084
+ }
2085
+
2086
+ @keyframes popover-enter {
2087
+ from {
2088
+ opacity: 0;
2089
+ transform: scale(0.95) translateY(-4px);
2090
+ }
2091
+ to {
2092
+ opacity: 1;
2093
+ transform: scale(1) translateY(0);
2094
+ }
2095
+ }
2096
+
2097
+ .popup-popover.shake {
2098
+ animation: popup-shake 0.3s ease-out;
2099
+ }
2100
+
2101
+ @keyframes popup-shake {
2102
+ 0%, 100% { transform: translateX(0); }
2103
+ 25% { transform: translateX(-8px); }
2104
+ 75% { transform: translateX(8px); }
2105
+ }
2106
+
2107
+ .popup-header {
2108
+ display: flex;
2109
+ align-items: center;
2110
+ justify-content: space-between;
2111
+ margin-bottom: var(--as-space-md);
2112
+ }
2113
+
2114
+ .popup-element {
2115
+ font-weight: 500;
2116
+ color: var(--as-text-primary);
2117
+ font-size: var(--as-font-size-md);
2118
+ }
2119
+
2120
+ .popup-path {
2121
+ font-family: var(--as-font-mono);
2122
+ font-size: var(--as-font-size-xs);
2123
+ color: var(--as-text-muted);
2124
+ margin-top: 2px;
2125
+ overflow: hidden;
2126
+ text-overflow: ellipsis;
2127
+ white-space: nowrap;
2128
+ }
2129
+
2130
+ .popup-multiselect-header {
2131
+ flex: 1;
2132
+ min-width: 0;
2133
+ }
2134
+
2135
+ .popup-element-list {
2136
+ list-style: none;
2137
+ margin: var(--as-space-xs) 0 0 0;
2138
+ padding: 0;
2139
+ font-size: var(--as-font-size-xs);
2140
+ color: var(--as-text-secondary);
2141
+ max-height: 80px;
2142
+ overflow-y: auto;
2143
+ }
2144
+
2145
+ .popup-element-list li {
2146
+ padding: 2px 0;
2147
+ overflow: hidden;
2148
+ text-overflow: ellipsis;
2149
+ white-space: nowrap;
2150
+ }
2151
+
2152
+ .popup-close {
2153
+ padding: var(--as-space-xs);
2154
+ background: transparent;
2155
+ border: none;
2156
+ border-radius: var(--as-radius-sm);
2157
+ color: var(--as-text-muted);
2158
+ cursor: pointer;
2159
+ transition: background var(--as-transition-fast), color var(--as-transition-fast);
2160
+ }
2161
+
2162
+ .popup-close:hover {
2163
+ background: var(--as-bg-hover);
2164
+ color: var(--as-text-primary);
2165
+ }
2166
+
2167
+ .popup-body {
2168
+ margin-bottom: var(--as-space-lg);
2169
+ }
2170
+
2171
+ .popup-textarea {
2172
+ width: 100%;
2173
+ min-height: 100px;
2174
+ padding: var(--as-space-md);
2175
+ background: var(--as-bg-secondary);
2176
+ border: 1px solid var(--as-border-primary);
2177
+ border-radius: var(--as-radius-md);
2178
+ color: var(--as-text-primary);
2179
+ font-family: inherit;
2180
+ font-size: var(--as-font-size-md);
2181
+ line-height: 1.5;
2182
+ resize: vertical;
2183
+ transition: border-color var(--as-transition-fast);
2184
+ }
2185
+
2186
+ .popup-textarea:focus {
2187
+ outline: none;
2188
+ border-color: var(--as-accent);
2189
+ }
2190
+
2191
+ .popup-textarea::placeholder {
2192
+ color: var(--as-text-muted);
2193
+ }
2194
+
2195
+ .popup-footer {
2196
+ display: flex;
2197
+ justify-content: flex-end;
2198
+ gap: var(--as-space-sm);
2199
+ }
2200
+
2201
+ .popup-btn {
2202
+ padding: var(--as-space-sm) var(--as-space-lg);
2203
+ background: transparent;
2204
+ border: 1px solid var(--as-border-primary);
2205
+ border-radius: var(--as-radius-md);
2206
+ color: var(--as-text-primary);
2207
+ font-size: var(--as-font-size-sm);
2208
+ font-weight: 500;
2209
+ cursor: pointer;
2210
+ transition: background var(--as-transition-fast), border-color var(--as-transition-fast);
2211
+ }
2212
+
2213
+ .popup-btn:hover {
2214
+ background: var(--as-bg-hover);
2215
+ }
2216
+
2217
+ .popup-btn.primary {
2218
+ background: var(--as-accent);
2219
+ border-color: var(--as-accent);
2220
+ color: white;
2221
+ }
2222
+
2223
+ .popup-btn.primary:hover {
2224
+ background: var(--as-accent-hover);
2225
+ border-color: var(--as-accent-hover);
2226
+ }
2227
+
2228
+ .popup-btn.danger {
2229
+ color: var(--as-error);
2230
+ }
2231
+
2232
+ .popup-btn.danger:hover {
2233
+ background: rgba(255, 59, 48, 0.1);
2234
+ }
2235
+
2236
+ /* Hover tooltip (follows cursor) */
2237
+ .hover-tooltip {
2238
+ position: fixed;
2239
+ z-index: var(--as-z-tooltip);
2240
+ padding: var(--as-space-sm) var(--as-space-md);
2241
+ background: var(--as-bg-primary);
2242
+ border: 1px solid var(--as-border-primary);
2243
+ border-radius: var(--as-radius-md);
2244
+ box-shadow: var(--as-shadow-md);
2245
+ font-size: var(--as-font-size-sm);
2246
+ max-width: 350px;
2247
+ pointer-events: none;
2248
+ }
2249
+
2250
+ .hover-element {
2251
+ font-weight: 500;
2252
+ color: var(--as-text-primary);
2253
+ margin-bottom: 2px;
2254
+ }
2255
+
2256
+ .hover-path {
2257
+ font-family: var(--as-font-mono);
2258
+ font-size: var(--as-font-size-xs);
2259
+ color: var(--as-text-muted);
2260
+ overflow: hidden;
2261
+ text-overflow: ellipsis;
2262
+ white-space: nowrap;
2263
+ }
2264
+
2265
+ /* Selection rectangle */
2266
+ .selection-rect {
2267
+ position: fixed;
2268
+ z-index: var(--as-z-overlay);
2269
+ border: 2px dashed var(--as-accent);
2270
+ background: var(--as-accent-light);
2271
+ pointer-events: none;
2272
+ }
2273
+
2274
+ /* Highlight overlay */
2275
+ .highlight {
2276
+ position: fixed;
2277
+ z-index: var(--as-z-overlay);
2278
+ border: 2px solid var(--as-accent);
2279
+ background: var(--as-accent-light);
2280
+ pointer-events: none;
2281
+ transition: all 0.1s ease-out;
2282
+ }
2283
+
2284
+ /* Settings panel */
2285
+ .settings-panel {
2286
+ position: absolute;
2287
+ bottom: calc(100% + var(--as-space-md));
2288
+ right: 0;
2289
+ width: 280px;
2290
+ padding: var(--as-space-md);
2291
+ background: var(--as-bg-primary);
2292
+ border: 1px solid var(--as-border-primary);
2293
+ border-radius: var(--as-radius-lg);
2294
+ box-shadow: var(--as-shadow-lg);
2295
+ animation: settings-enter 0.2s ease-out;
2296
+ }
2297
+
2298
+ @keyframes settings-enter {
2299
+ from {
2300
+ opacity: 0;
2301
+ transform: translateY(10px);
2302
+ }
2303
+ to {
2304
+ opacity: 1;
2305
+ transform: translateY(0);
2306
+ }
2307
+ }
2308
+
2309
+ .settings-title {
2310
+ font-weight: 600;
2311
+ margin-bottom: var(--as-space-md);
2312
+ padding-bottom: var(--as-space-sm);
2313
+ border-bottom: 1px solid var(--as-border-primary);
2314
+ }
2315
+
2316
+ .settings-group {
2317
+ margin-bottom: var(--as-space-md);
2318
+ }
2319
+
2320
+ .settings-label {
2321
+ display: block;
2322
+ font-size: var(--as-font-size-sm);
2323
+ color: var(--as-text-secondary);
2324
+ margin-bottom: var(--as-space-xs);
2325
+ }
2326
+
2327
+ .settings-select {
2328
+ width: 100%;
2329
+ padding: var(--as-space-sm);
2330
+ background: var(--as-bg-secondary);
2331
+ border: 1px solid var(--as-border-primary);
2332
+ border-radius: var(--as-radius-md);
2333
+ color: var(--as-text-primary);
2334
+ font-size: var(--as-font-size-sm);
2335
+ cursor: pointer;
2336
+ }
2337
+
2338
+ .settings-select:focus {
2339
+ outline: none;
2340
+ border-color: var(--as-accent);
2341
+ }
2342
+
2343
+ .settings-toggle {
2344
+ display: flex;
2345
+ align-items: center;
2346
+ justify-content: space-between;
2347
+ padding: var(--as-space-sm) 0;
2348
+ }
2349
+
2350
+ .settings-toggle-label {
2351
+ font-size: var(--as-font-size-sm);
2352
+ }
2353
+
2354
+ .settings-switch {
2355
+ position: relative;
2356
+ width: 40px;
2357
+ height: 22px;
2358
+ background: var(--as-bg-secondary);
2359
+ border: 1px solid var(--as-border-primary);
2360
+ border-radius: var(--as-radius-full);
2361
+ cursor: pointer;
2362
+ transition: background var(--as-transition-fast);
2363
+ }
2364
+
2365
+ .settings-switch.active {
2366
+ background: var(--as-accent);
2367
+ border-color: var(--as-accent);
2368
+ }
2369
+
2370
+ .settings-switch::after {
2371
+ content: '';
2372
+ position: absolute;
2373
+ top: 2px;
2374
+ left: 2px;
2375
+ width: 16px;
2376
+ height: 16px;
2377
+ background: white;
2378
+ border-radius: 50%;
2379
+ transition: transform var(--as-transition-fast);
2380
+ }
2381
+
2382
+ .settings-switch.active::after {
2383
+ transform: translateX(18px);
2384
+ }
2385
+
2386
+ /* Color picker */
2387
+ .color-picker {
2388
+ display: flex;
2389
+ gap: var(--as-space-xs);
2390
+ flex-wrap: wrap;
2391
+ }
2392
+
2393
+ .color-option {
2394
+ width: 24px;
2395
+ height: 24px;
2396
+ border: 2px solid transparent;
2397
+ border-radius: 50%;
2398
+ cursor: pointer;
2399
+ transition: transform var(--as-transition-fast), border-color var(--as-transition-fast);
2400
+ }
2401
+
2402
+ .color-option:hover {
2403
+ transform: scale(1.15);
2404
+ }
2405
+
2406
+ .color-option.active {
2407
+ border-color: var(--as-text-primary);
2408
+ }
2409
+
2410
+ /* Utility classes */
2411
+ .hidden {
2412
+ display: none !important;
2413
+ }
2414
+
2415
+ .sr-only {
2416
+ position: absolute;
2417
+ width: 1px;
2418
+ height: 1px;
2419
+ padding: 0;
2420
+ margin: -1px;
2421
+ overflow: hidden;
2422
+ clip: rect(0, 0, 0, 0);
2423
+ white-space: nowrap;
2424
+ border: 0;
2425
+ }
2426
+
2427
+ /* Skip animation for elements that have already animated */
2428
+ .no-animate {
2429
+ animation: none !important;
2430
+ }
2431
+ `, $ = {
2432
+ scope: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2433
+ <circle cx="12" cy="12" r="10"/>
2434
+ <circle cx="12" cy="12" r="6"/>
2435
+ <circle cx="12" cy="12" r="2"/>
2436
+ </svg>`,
2437
+ freeze: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2438
+ <path d="M12 2v20M2 12h20M4.93 4.93l14.14 14.14M19.07 4.93L4.93 19.07"/>
2439
+ </svg>`,
2440
+ unfreeze: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2441
+ <polygon points="5 3 19 12 5 21 5 3"/>
2442
+ </svg>`,
2443
+ eye: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2444
+ <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
2445
+ <circle cx="12" cy="12" r="3"/>
2446
+ </svg>`,
2447
+ eyeOff: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2448
+ <path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/>
2449
+ <line x1="1" y1="1" x2="23" y2="23"/>
2450
+ </svg>`,
2451
+ copy: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2452
+ <rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
2453
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
2454
+ </svg>`,
2455
+ trash: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2456
+ <polyline points="3 6 5 6 21 6"/>
2457
+ <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
2458
+ <line x1="10" y1="11" x2="10" y2="17"/>
2459
+ <line x1="14" y1="11" x2="14" y2="17"/>
2460
+ </svg>`,
2461
+ sun: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2462
+ <circle cx="12" cy="12" r="5"/>
2463
+ <line x1="12" y1="1" x2="12" y2="3"/>
2464
+ <line x1="12" y1="21" x2="12" y2="23"/>
2465
+ <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/>
2466
+ <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
2467
+ <line x1="1" y1="12" x2="3" y2="12"/>
2468
+ <line x1="21" y1="12" x2="23" y2="12"/>
2469
+ <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
2470
+ <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
2471
+ </svg>`,
2472
+ moon: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2473
+ <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
2474
+ </svg>`,
2475
+ x: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2476
+ <line x1="18" y1="6" x2="6" y2="18"/>
2477
+ <line x1="6" y1="6" x2="18" y2="18"/>
2478
+ </svg>`,
2479
+ settings: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2480
+ <circle cx="12" cy="12" r="3"/>
2481
+ <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>
2482
+ </svg>`
2483
+ };
2484
+ function rn(t) {
2485
+ return `
2486
+ <div class="toolbar collapsed" data-annotation-toolbar>
2487
+ <button class="toolbar-btn toggle-btn" title="Activate agent-ui-annotation" data-action="toggle">
2488
+ ${$.scope}
2489
+ ${t > 0 ? `<span class="badge">${t}</span>` : ""}
2490
+ </button>
2491
+ </div>
2492
+ `;
2493
+ }
2494
+ function sn(t) {
2495
+ const {
2496
+ scopeCount: n,
2497
+ isFrozen: e,
2498
+ markersVisible: o,
2499
+ isDarkMode: a,
2500
+ showCopiedFeedback: r,
2501
+ showClearedFeedback: s,
2502
+ showEntranceAnimation: i = !1,
2503
+ settingsPanelHtml: p = ""
2504
+ } = t;
2505
+ return `
2506
+ <div class="toolbar${i ? " entering" : ""}" data-annotation-toolbar>
2507
+ ${r ? '<div class="feedback success">Copied to clipboard!</div>' : ""}
2508
+ ${s ? '<div class="feedback">Cleared all scopes</div>' : ""}
2509
+ ${p}
2510
+
2511
+ <button class="toolbar-btn ${e ? "active" : ""}" title="${e ? "Unfreeze" : "Freeze"} animations" data-action="freeze">
2512
+ ${e ? $.unfreeze : $.freeze}
2513
+ </button>
2514
+
2515
+ <button class="toolbar-btn ${o ? "active" : ""}" title="${o ? "Hide" : "Show"} markers" data-action="toggle-markers">
2516
+ ${o ? $.eye : $.eyeOff}
2517
+ </button>
2518
+
2519
+ <div class="separator"></div>
2520
+
2521
+ <div class="scope-count">
2522
+ ${$.scope}
2523
+ <span class="count">${n}</span>
2524
+ </div>
2525
+
2526
+ <div class="separator"></div>
2527
+
2528
+ <button class="toolbar-btn" title="Copy to clipboard" data-action="copy" ${n === 0 ? "disabled" : ""}>
2529
+ ${$.copy}
2530
+ </button>
2531
+
2532
+ <button class="toolbar-btn" title="Clear all" data-action="clear" ${n === 0 ? "disabled" : ""}>
2533
+ ${$.trash}
2534
+ </button>
2535
+
2536
+ <div class="separator"></div>
2537
+
2538
+ <button class="toolbar-btn" title="Toggle theme" data-action="theme">
2539
+ ${a ? $.sun : $.moon}
2540
+ </button>
2541
+
2542
+ <button class="toolbar-btn" title="Settings" data-action="settings">
2543
+ ${$.settings}
2544
+ </button>
2545
+
2546
+ <button class="toolbar-btn" title="Close" data-action="close">
2547
+ ${$.x}
2548
+ </button>
2549
+ </div>
2550
+ `;
2551
+ }
2552
+ function ln(t, n) {
2553
+ const e = t.elementInfo.isFixed, o = t.clickX, a = t.clickY;
2554
+ return e ? { x: o, y: a, isFixed: !0 } : { x: o, y: a - n, isFixed: !1 };
2555
+ }
2556
+ function cn(t) {
2557
+ const { scope: n, isHovered: e, isExiting: o, isAnimating: a, scrollY: r, accentColor: s, skipTooltipAnimation: i = !1 } = t, p = ln(n, r), f = [
2558
+ "marker",
2559
+ p.isFixed ? "fixed" : "",
2560
+ o ? "exiting" : "",
2561
+ a ? "entering" : ""
2562
+ ].filter(Boolean).join(" "), u = `
2563
+ left: ${p.x}px;
2564
+ top: ${p.y}px;
2565
+ background-color: ${s};
2566
+ `;
2567
+ return `
2568
+ <div
2569
+ class="${f}"
2570
+ style="${u}"
2571
+ data-annotation-marker
2572
+ data-scope-id="${n.id}"
2573
+ title="${n.elementInfo.humanReadable}"
2574
+ >
2575
+ ${n.number}
2576
+ ${e ? dn(n, i) : ""}
2577
+ </div>
2578
+ `;
2579
+ }
2580
+ function dn(t, n) {
2581
+ const e = t.elementInfo.humanReadable, o = t.comment ? t.comment.length > 100 ? t.comment.slice(0, 100) + "..." : t.comment : "(no comment)";
2582
+ return `
2583
+ <div class="marker-tooltip${n ? " no-animate" : ""}">
2584
+ <div class="tooltip-element">${ot(e)}</div>
2585
+ <div class="tooltip-comment">${ot(o)}</div>
2586
+ </div>
2587
+ `;
2588
+ }
2589
+ function nt(t, n, e, o) {
2590
+ const a = t.x, r = t.isFixed ? t.y : t.y - n, s = `
2591
+ left: ${a}px;
2592
+ top: ${r}px;
2593
+ background-color: ${e};
2594
+ opacity: 0.7;
2595
+ `;
2596
+ return `
2597
+ <div
2598
+ class="marker pending${t.isFixed ? " fixed" : ""}"
2599
+ style="${s}"
2600
+ data-annotation-marker
2601
+ data-pending="true"
2602
+ >
2603
+ ${o}
2604
+ </div>
2605
+ `;
2606
+ }
2607
+ function un(t) {
2608
+ const { scopes: n, hoveredMarkerId: e, exitingMarkers: o, animatingMarkers: a, scrollY: r, accentColor: s, pendingMarker: i, pendingMarkers: p = [], skipTooltipAnimation: f = !1 } = t, u = n.map(
2609
+ (l) => cn({
2610
+ scope: l,
2611
+ isHovered: l.id === e,
2612
+ isExiting: o.has(l.id),
2613
+ isAnimating: a.has(l.id),
2614
+ scrollY: r,
2615
+ accentColor: s,
2616
+ skipTooltipAnimation: f
2617
+ })
2618
+ ).join("");
2619
+ let c = "";
2620
+ return p.length > 0 ? c = p.map((l, d) => nt(l, r, s, n.length + 1 + d)).join("") : i && (c = nt(i, r, s, n.length + 1)), `<div class="markers">${u}${c}</div>`;
2621
+ }
2622
+ function ot(t) {
2623
+ const n = document.createElement("div");
2624
+ return n.textContent = t, n.innerHTML;
2625
+ }
2626
+ function pn(t, n) {
2627
+ const r = window.innerWidth, s = window.innerHeight;
2628
+ let i = t + 12, p = n - 220 / 2;
2629
+ return i + 340 > r - 12 && (i = t - 340 - 12), i < 12 && (i = Math.max(12, t - 340 / 2)), i = Math.max(12, Math.min(i, r - 340 - 12)), p < 12 && (p = 12), p + 220 > s - 12 && (p = s - 220 - 12), {
2630
+ left: `${i}px`,
2631
+ top: `${p}px`
2632
+ };
2633
+ }
2634
+ function fn(t) {
2635
+ const { elementInfo: n, existingScope: e, isShaking: o, clickX: a, clickY: r, multiSelectInfos: s = [] } = t;
2636
+ if (!n && !e)
2637
+ return "";
2638
+ const i = s.length > 1, p = (e == null ? void 0 : e.elementInfo) || n, f = (e == null ? void 0 : e.comment) || "", u = !!e, c = pn(a, r);
2639
+ let l;
2640
+ if (i) {
2641
+ const d = s.slice(0, 5).map((v) => `<li>${H(v.humanReadable)}</li>`).join(""), h = s.length > 5 ? `<li>...and ${s.length - 5} more</li>` : "";
2642
+ l = `
2643
+ <div class="popup-multiselect-header">
2644
+ <div class="popup-element">${s.length} elements selected</div>
2645
+ <ul class="popup-element-list">${d}${h}</ul>
2646
+ </div>
2647
+ `;
2648
+ } else
2649
+ l = `
2650
+ <div>
2651
+ <div class="popup-element">${H(p.humanReadable)}</div>
2652
+ <div class="popup-path">${H(p.selectorPath)}</div>
2653
+ </div>
2654
+ `;
2655
+ return `
2656
+ <div class="popup-popover ${o ? "shake" : ""}" style="left: ${c.left}; top: ${c.top};" data-annotation-popup>
2657
+ <div class="popup-header">
2658
+ ${l}
2659
+ <button class="popup-close" data-action="popup-close" title="Close">
2660
+ ${$.x}
2661
+ </button>
2662
+ </div>
2663
+
2664
+ <div class="popup-body">
2665
+ <textarea
2666
+ class="popup-textarea"
2667
+ placeholder="${i ? "Add feedback for all selected elements..." : "Add your feedback..."}"
2668
+ data-popup-input
2669
+ autofocus
2670
+ >${H(f)}</textarea>
2671
+ </div>
2672
+
2673
+ <div class="popup-footer">
2674
+ ${u ? `
2675
+ <button class="popup-btn danger" data-action="popup-delete">
2676
+ Delete
2677
+ </button>
2678
+ ` : ""}
2679
+ <button class="popup-btn" data-action="popup-cancel">
2680
+ Cancel
2681
+ </button>
2682
+ <button class="popup-btn primary" data-action="popup-submit">
2683
+ ${u ? "Save" : i ? `Add ${s.length} Scopes` : "Add Scope"}
2684
+ </button>
2685
+ </div>
2686
+ </div>
2687
+ `;
2688
+ }
2689
+ function H(t) {
2690
+ const n = document.createElement("div");
2691
+ return n.textContent = t, n.innerHTML;
2692
+ }
2693
+ function hn(t, n) {
2694
+ let r = t + 16, s = n + 16;
2695
+ return r + 350 > window.innerWidth && (r = t - 350 - 16), s + 60 > window.innerHeight && (s = n - 60 - 16), r = Math.max(16, r), s = Math.max(16, s), {
2696
+ left: `${r}px`,
2697
+ top: `${s}px`
2698
+ };
2699
+ }
2700
+ function mn(t) {
2701
+ const { elementInfo: n, x: e, y: o } = t, a = hn(e, o);
2702
+ return `
2703
+ <div class="hover-tooltip" style="left: ${a.left}; top: ${a.top};">
2704
+ <div class="hover-element">${rt(n.humanReadable)}</div>
2705
+ <div class="hover-path">${rt(n.selectorPath)}</div>
2706
+ </div>
2707
+ `;
2708
+ }
2709
+ function at(t, n) {
2710
+ return t ? `
2711
+ <div
2712
+ class="highlight"
2713
+ style="
2714
+ left: ${t.left}px;
2715
+ top: ${t.top}px;
2716
+ width: ${t.width}px;
2717
+ height: ${t.height}px;
2718
+ border-color: ${n};
2719
+ background-color: ${n}20;
2720
+ "
2721
+ ></div>
2722
+ ` : "";
2723
+ }
2724
+ function gn(t, n) {
2725
+ return t ? `
2726
+ <div
2727
+ class="selection-rect"
2728
+ style="
2729
+ left: ${t.x}px;
2730
+ top: ${t.y}px;
2731
+ width: ${t.width}px;
2732
+ height: ${t.height}px;
2733
+ border-color: ${n};
2734
+ background-color: ${n}20;
2735
+ "
2736
+ ></div>
2737
+ ` : "";
2738
+ }
2739
+ function rt(t) {
2740
+ const n = document.createElement("div");
2741
+ return n.textContent = t, n.innerHTML;
2742
+ }
2743
+ const bn = {
2744
+ purple: "#AF52DE",
2745
+ blue: "#3c82f7",
2746
+ cyan: "#5AC8FA",
2747
+ green: "#34C759",
2748
+ yellow: "#FFD60A",
2749
+ orange: "#FF9500",
2750
+ red: "#FF3B30"
2751
+ };
2752
+ function vn(t) {
2753
+ const { settings: n, skipAnimation: e = !1 } = t, o = [
2754
+ { value: "compact", label: "Compact" },
2755
+ { value: "standard", label: "Standard" },
2756
+ { value: "detailed", label: "Detailed" },
2757
+ { value: "forensic", label: "Forensic" }
2758
+ ], a = Object.entries(bn).map(([r, s]) => ({
2759
+ name: r,
2760
+ hex: s,
2761
+ active: n.scopeColor === s
2762
+ }));
2763
+ return `
2764
+ <div class="settings-panel${e ? " no-animate" : ""}" data-annotation-settings>
2765
+ <div class="settings-title">Settings</div>
2766
+
2767
+ <div class="settings-group">
2768
+ <label class="settings-label">Output Level</label>
2769
+ <select class="settings-select" data-setting="outputLevel">
2770
+ ${o.map(
2771
+ (r) => `<option value="${r.value}" ${n.outputLevel === r.value ? "selected" : ""}>${r.label}</option>`
2772
+ ).join("")}
2773
+ </select>
2774
+ </div>
2775
+
2776
+ <div class="settings-group">
2777
+ <label class="settings-label">Marker Color</label>
2778
+ <div class="color-picker">
2779
+ ${a.map(
2780
+ (r) => `<button
2781
+ class="color-option ${r.active ? "active" : ""}"
2782
+ style="background: ${r.hex};"
2783
+ data-setting="scopeColor"
2784
+ data-value="${r.hex}"
2785
+ title="${r.name}"
2786
+ ></button>`
2787
+ ).join("")}
2788
+ </div>
2789
+ </div>
2790
+
2791
+ <div class="settings-group">
2792
+ <div class="settings-toggle">
2793
+ <span class="settings-toggle-label">Block page interactions</span>
2794
+ <button
2795
+ class="settings-switch ${n.blockInteractions ? "active" : ""}"
2796
+ data-setting="blockInteractions"
2797
+ data-value="${!n.blockInteractions}"
2798
+ title="Prevent clicks from activating buttons/links while annotating"
2799
+ ></button>
2800
+ </div>
2801
+ </div>
2802
+
2803
+ <div class="settings-group">
2804
+ <div class="settings-toggle">
2805
+ <span class="settings-toggle-label">Show tooltips</span>
2806
+ <button
2807
+ class="settings-switch ${n.showTooltips ? "active" : ""}"
2808
+ data-setting="showTooltips"
2809
+ data-value="${!n.showTooltips}"
2810
+ ></button>
2811
+ </div>
2812
+ </div>
2813
+
2814
+ <div class="settings-group">
2815
+ <div class="settings-toggle">
2816
+ <span class="settings-toggle-label">Auto-clear after copy</span>
2817
+ <button
2818
+ class="settings-switch ${n.autoClearAfterCopy ? "active" : ""}"
2819
+ data-setting="autoClearAfterCopy"
2820
+ data-value="${!n.autoClearAfterCopy}"
2821
+ ></button>
2822
+ </div>
2823
+ </div>
2824
+ </div>
2825
+ `;
2826
+ }
2827
+ class xn extends HTMLElement {
2828
+ constructor() {
2829
+ super();
2830
+ w(this, "core", null);
2831
+ w(this, "shadow");
2832
+ w(this, "unsubscribe", null);
2833
+ w(this, "styleElement");
2834
+ w(this, "contentElement");
2835
+ // Popup state
2836
+ w(this, "isComposing", !1);
2837
+ w(this, "popupShaking", !1);
2838
+ // Hover tracking
2839
+ w(this, "mouseX", 0);
2840
+ w(this, "mouseY", 0);
2841
+ w(this, "hoveredMarkerId", null);
2842
+ // Track if toolbar has been shown before (to prevent re-animation)
2843
+ w(this, "toolbarShownOnce", !1);
2844
+ // Track if settings panel has animated (to prevent re-animation on state changes)
2845
+ w(this, "settingsPanelAnimated", !1);
2846
+ // Track which marker tooltip has animated (to prevent re-animation)
2847
+ w(this, "animatedMarkerTooltipId", null);
2848
+ // Track last rendered settings to avoid unnecessary re-renders when settings panel is open
2849
+ w(this, "lastRenderedSettings", null);
2850
+ this.shadow = this.attachShadow({ mode: "open" }), this.styleElement = document.createElement("style"), this.styleElement.textContent = an, this.contentElement = document.createElement("div"), this.contentElement.className = "annotation-root", this.shadow.appendChild(this.styleElement), this.shadow.appendChild(this.contentElement);
2851
+ }
2852
+ static get observedAttributes() {
2853
+ return ["theme", "output-level", "scope-color", "disabled"];
2854
+ }
2855
+ connectedCallback() {
2856
+ this.core = en({
2857
+ settings: this.getSettingsFromAttributes(),
2858
+ loadPersisted: !0,
2859
+ onScopeCreate: (e) => this.dispatchScopeEvent("annotation:scope", { scope: e }),
2860
+ onScopeUpdate: (e) => this.dispatchScopeEvent("annotation:update", { scope: e }),
2861
+ onScopeDelete: (e) => this.dispatchScopeEvent("annotation:delete", { id: e }),
2862
+ onScopesClear: (e) => this.dispatchScopeEvent("annotation:clear", { scopes: e }),
2863
+ onCopy: (e, o) => this.dispatchScopeEvent("annotation:copy", { content: e, level: o })
2864
+ }), this.unsubscribe = this.core.subscribe((e) => this.render(e)), this.setupEventListeners(), this.render(this.core.store.getState()), this.updateThemeAttribute();
2865
+ }
2866
+ disconnectedCallback() {
2867
+ this.unsubscribe && (this.unsubscribe(), this.unsubscribe = null), this.core && (this.core.destroy(), this.core = null);
2868
+ }
2869
+ attributeChangedCallback(e, o, a) {
2870
+ if (!(o === a || !this.core))
2871
+ switch (e) {
2872
+ case "theme":
2873
+ this.core.updateSettings({ theme: a || "auto" }), this.updateThemeAttribute();
2874
+ break;
2875
+ case "output-level":
2876
+ this.core.updateSettings({ outputLevel: a || "standard" });
2877
+ break;
2878
+ case "scope-color":
2879
+ this.core.updateSettings({ scopeColor: a || "#AF52DE" });
2880
+ break;
2881
+ case "disabled":
2882
+ a !== null && this.core.deactivate();
2883
+ break;
2884
+ }
2885
+ }
2886
+ /**
2887
+ * Public API
2888
+ */
2889
+ activate() {
2890
+ var e;
2891
+ (e = this.core) == null || e.activate();
2892
+ }
2893
+ deactivate() {
2894
+ var e;
2895
+ (e = this.core) == null || e.deactivate();
2896
+ }
2897
+ toggle() {
2898
+ var e;
2899
+ (e = this.core) == null || e.toggle();
2900
+ }
2901
+ async copyOutput(e) {
2902
+ var o;
2903
+ return ((o = this.core) == null ? void 0 : o.copyOutput(e)) ?? !1;
2904
+ }
2905
+ getOutput(e) {
2906
+ var o;
2907
+ return ((o = this.core) == null ? void 0 : o.getOutput(e)) ?? "";
2908
+ }
2909
+ clearAll() {
2910
+ var e;
2911
+ (e = this.core) == null || e.scopes.clearAllScopes();
2912
+ }
2913
+ /**
2914
+ * Private methods
2915
+ */
2916
+ getSettingsFromAttributes() {
2917
+ const e = {}, o = this.getAttribute("theme");
2918
+ (o === "light" || o === "dark" || o === "auto") && (e.theme = o);
2919
+ const a = this.getAttribute("output-level");
2920
+ (a === "compact" || a === "standard" || a === "detailed" || a === "forensic") && (e.outputLevel = a);
2921
+ const r = this.getAttribute("scope-color");
2922
+ return r && (e.scopeColor = r), e;
2923
+ }
2924
+ updateThemeAttribute() {
2925
+ if (!this.core) return;
2926
+ const e = this.core.getSettings().theme, o = V(e);
2927
+ this.setAttribute("data-theme", e), e === "auto" && this.setAttribute("data-resolved-theme", o);
2928
+ }
2929
+ setupEventListeners() {
2930
+ this.shadow.addEventListener("click", this.handleClick.bind(this)), this.shadow.addEventListener("mouseover", this.handleMouseOver.bind(this)), this.shadow.addEventListener("mouseout", this.handleMouseOut.bind(this)), document.addEventListener("mousemove", this.handleMouseMove.bind(this)), this.shadow.addEventListener("keydown", this.handleKeyDown.bind(this)), this.shadow.addEventListener("compositionstart", () => {
2931
+ this.isComposing = !0;
2932
+ }), this.shadow.addEventListener("compositionend", () => {
2933
+ this.isComposing = !1;
2934
+ }), this.shadow.addEventListener("change", this.handleChange.bind(this)), document.addEventListener("click", this.handleDocumentClick.bind(this));
2935
+ }
2936
+ handleDocumentClick(e) {
2937
+ if (!this.core || !this.core.store.getState().settingsPanelVisible) return;
2938
+ e.composedPath().some((s) => s === this) || this.core.store.setState({ settingsPanelVisible: !1 });
2939
+ }
2940
+ handleChange(e) {
2941
+ const o = e.target;
2942
+ this.handleSettingChange(o);
2943
+ }
2944
+ handleClick(e) {
2945
+ var i, p, f;
2946
+ const o = e.target, a = (i = o.closest("[data-action]")) == null ? void 0 : i.getAttribute("data-action"), r = (p = o.closest("[data-scope-id]")) == null ? void 0 : p.getAttribute("data-scope-id");
2947
+ if (!this.core) return;
2948
+ switch (a) {
2949
+ case "toggle":
2950
+ this.core.toggle();
2951
+ break;
2952
+ case "close":
2953
+ this.core.deactivate();
2954
+ break;
2955
+ case "freeze":
2956
+ this.core.freeze.toggle();
2957
+ break;
2958
+ case "toggle-markers": {
2959
+ const u = this.core.store.getState();
2960
+ this.core.store.setState({ markersVisible: !u.markersVisible });
2961
+ break;
2962
+ }
2963
+ case "copy":
2964
+ this.core.copyOutput();
2965
+ break;
2966
+ case "clear":
2967
+ this.core.scopes.clearAllScopes();
2968
+ break;
2969
+ case "theme": {
2970
+ const u = this.core.getSettings().theme, l = V(u) === "dark" ? "light" : "dark";
2971
+ this.core.updateSettings({ theme: l }), this.updateThemeAttribute();
2972
+ break;
2973
+ }
2974
+ case "settings": {
2975
+ const u = this.core.store.getState();
2976
+ this.core.store.setState({ settingsPanelVisible: !u.settingsPanelVisible });
2977
+ break;
2978
+ }
2979
+ case "popup-close":
2980
+ case "popup-cancel":
2981
+ this.core.hidePopup();
2982
+ break;
2983
+ case "popup-submit":
2984
+ this.handlePopupSubmit();
2985
+ break;
2986
+ case "popup-delete":
2987
+ this.handlePopupDelete();
2988
+ break;
2989
+ }
2990
+ r && !a && this.core.showPopup(r), ((f = o.closest("[data-setting]")) == null ? void 0 : f.getAttribute("data-setting")) && this.handleSettingChange(o);
2991
+ }
2992
+ handleSettingChange(e) {
2993
+ if (!this.core) return;
2994
+ const o = e.closest("[data-setting]");
2995
+ if (!o) return;
2996
+ const a = o.getAttribute("data-setting"), r = o.getAttribute("data-value");
2997
+ switch (a) {
2998
+ case "outputLevel": {
2999
+ const s = o;
3000
+ this.core.updateSettings({ outputLevel: s.value });
3001
+ break;
3002
+ }
3003
+ case "scopeColor":
3004
+ r && this.core.updateSettings({ scopeColor: r });
3005
+ break;
3006
+ case "blockInteractions":
3007
+ this.core.updateSettings({ blockInteractions: r === "true" });
3008
+ break;
3009
+ case "showTooltips":
3010
+ this.core.updateSettings({ showTooltips: r === "true" });
3011
+ break;
3012
+ case "autoClearAfterCopy":
3013
+ this.core.updateSettings({ autoClearAfterCopy: r === "true" });
3014
+ break;
3015
+ }
3016
+ }
3017
+ handleMouseOver(e) {
3018
+ const a = e.target.closest("[data-scope-id]");
3019
+ a && (this.hoveredMarkerId = a.getAttribute("data-scope-id"), this.render(this.core.store.getState()));
3020
+ }
3021
+ handleMouseOut(e) {
3022
+ e.target.closest("[data-scope-id]") && (this.hoveredMarkerId = null, this.render(this.core.store.getState()));
3023
+ }
3024
+ handleMouseMove(e) {
3025
+ this.mouseX = e.clientX, this.mouseY = e.clientY;
3026
+ }
3027
+ handleKeyDown(e) {
3028
+ var a;
3029
+ e.target.matches("[data-popup-input]") && (e.key === "Enter" && !e.shiftKey && !this.isComposing && (e.preventDefault(), this.handlePopupSubmit()), e.key === "Escape" && (e.preventDefault(), (a = this.core) == null || a.hidePopup()));
3030
+ }
3031
+ handlePopupSubmit() {
3032
+ var r;
3033
+ if (!this.core) return;
3034
+ const e = this.core.store.getState(), o = this.shadow.querySelector("[data-popup-input]"), a = ((r = o == null ? void 0 : o.value) == null ? void 0 : r.trim()) || "";
3035
+ if (e.popupAnnotationId)
3036
+ this.core.scopes.updateScope(e.popupAnnotationId, { comment: a });
3037
+ else if (e.multiSelectElements.length > 1)
3038
+ for (let s = 0; s < e.multiSelectElements.length; s++) {
3039
+ const i = e.multiSelectElements[s], p = e.multiSelectInfos[s], f = i.getBoundingClientRect(), u = f.left + f.width / 2, c = f.top + f.height / 2, l = p.isFixed, d = u, h = l ? c : c + window.scrollY;
3040
+ this.core.scopes.addScope(i, a, {
3041
+ clickX: d,
3042
+ clickY: h,
3043
+ isMultiSelect: !0
3044
+ });
3045
+ }
3046
+ else if (e.hoveredElement && e.popupElementInfo) {
3047
+ const s = e.popupElementInfo.isFixed, i = e.popupClickX, p = s ? e.popupClickY : e.popupClickY + window.scrollY;
3048
+ this.core.scopes.addScope(e.hoveredElement, a, {
3049
+ clickX: i,
3050
+ clickY: p
3051
+ });
3052
+ }
3053
+ this.core.hidePopup();
3054
+ }
3055
+ handlePopupDelete() {
3056
+ if (!this.core) return;
3057
+ const e = this.core.store.getState();
3058
+ e.popupAnnotationId && (this.core.scopes.deleteScope(e.popupAnnotationId), this.core.hidePopup());
3059
+ }
3060
+ dispatchScopeEvent(e, o) {
3061
+ this.dispatchEvent(
3062
+ new CustomEvent(e, {
3063
+ detail: o,
3064
+ bubbles: !0,
3065
+ composed: !0
3066
+ })
3067
+ );
3068
+ }
3069
+ render(e) {
3070
+ const o = e.settings, a = Array.from(e.scopes.values()).sort((i, p) => i.number - p.number), r = V(o.theme);
3071
+ if (e.settingsPanelVisible) {
3072
+ const i = JSON.stringify({
3073
+ settings: o,
3074
+ settingsPanelVisible: e.settingsPanelVisible,
3075
+ scopeCount: a.length,
3076
+ isFrozen: e.isFrozen,
3077
+ markersVisible: e.markersVisible,
3078
+ theme: r
3079
+ });
3080
+ if (this.lastRenderedSettings === i)
3081
+ return;
3082
+ this.lastRenderedSettings = i;
3083
+ } else
3084
+ this.lastRenderedSettings = null;
3085
+ let s = "";
3086
+ if (e.toolbarExpanded) {
3087
+ const i = !this.toolbarShownOnce;
3088
+ i && (this.toolbarShownOnce = !0);
3089
+ let p = "";
3090
+ if (e.settingsPanelVisible) {
3091
+ const f = this.settingsPanelAnimated;
3092
+ p = vn({ settings: o, skipAnimation: f }), this.settingsPanelAnimated = !0;
3093
+ } else
3094
+ this.settingsPanelAnimated = !1;
3095
+ s += sn({
3096
+ scopeCount: a.length,
3097
+ isFrozen: e.isFrozen,
3098
+ markersVisible: e.markersVisible,
3099
+ isDarkMode: r === "dark",
3100
+ showCopiedFeedback: e.showCopiedFeedback,
3101
+ showClearedFeedback: e.showClearedFeedback,
3102
+ showEntranceAnimation: i,
3103
+ settingsPanelHtml: p
3104
+ });
3105
+ } else
3106
+ this.toolbarShownOnce = !1, this.settingsPanelAnimated = !1, s += rn(a.length);
3107
+ if (e.toolbarExpanded && e.markersVisible) {
3108
+ let i = null, p = [];
3109
+ e.popupVisible && !e.popupAnnotationId && (e.multiSelectElements.length > 1 ? p = e.multiSelectElements.map((u, c) => {
3110
+ var g;
3111
+ const l = u.getBoundingClientRect(), d = l.left + l.width / 2, h = l.top + l.height / 2, v = ((g = e.multiSelectInfos[c]) == null ? void 0 : g.isFixed) || !1;
3112
+ return {
3113
+ x: d,
3114
+ y: v ? h : h + window.scrollY,
3115
+ isFixed: v
3116
+ };
3117
+ }) : e.pendingMarkerX !== 0 && (i = {
3118
+ x: e.pendingMarkerX,
3119
+ y: e.pendingMarkerY,
3120
+ isFixed: e.pendingMarkerIsFixed
3121
+ }));
3122
+ const f = this.hoveredMarkerId !== null && this.hoveredMarkerId === this.animatedMarkerTooltipId;
3123
+ this.hoveredMarkerId !== null ? this.animatedMarkerTooltipId = this.hoveredMarkerId : this.animatedMarkerTooltipId = null, s += un({
3124
+ scopes: a,
3125
+ hoveredMarkerId: this.hoveredMarkerId,
3126
+ exitingMarkers: e.exitingMarkers,
3127
+ animatingMarkers: e.animatingMarkers,
3128
+ scrollY: e.scrollY,
3129
+ accentColor: o.scopeColor,
3130
+ pendingMarker: i,
3131
+ pendingMarkers: p,
3132
+ skipTooltipAnimation: f
3133
+ });
3134
+ }
3135
+ if (e.popupVisible) {
3136
+ const i = e.popupAnnotationId ? e.scopes.get(e.popupAnnotationId) : null;
3137
+ s += fn({
3138
+ elementInfo: (i == null ? void 0 : i.elementInfo) || e.popupElementInfo,
3139
+ existingScope: i || null,
3140
+ isShaking: this.popupShaking,
3141
+ clickX: i ? i.clickX : e.popupClickX,
3142
+ clickY: i ? i.clickY : e.popupClickY,
3143
+ multiSelectInfos: e.multiSelectInfos
3144
+ });
3145
+ }
3146
+ if (e.toolbarExpanded && !e.popupVisible && e.hoveredElementInfo && o.showTooltips && (s += mn({
3147
+ elementInfo: e.hoveredElementInfo,
3148
+ x: this.mouseX,
3149
+ y: this.mouseY
3150
+ }), e.hoveredElement)) {
3151
+ const i = e.hoveredElement.getBoundingClientRect();
3152
+ s += at(i, o.scopeColor);
3153
+ }
3154
+ if (e.isSelecting && e.selectionRect) {
3155
+ const i = Be(e.selectionRect);
3156
+ s += gn(i, o.scopeColor);
3157
+ for (const p of e.selectionPreviewElements) {
3158
+ const f = p.getBoundingClientRect();
3159
+ s += at(f, o.scopeColor);
3160
+ }
3161
+ }
3162
+ if (this.contentElement.innerHTML = s, this.positionToolbar(e), e.popupVisible) {
3163
+ const i = this.shadow.querySelector("[data-popup-input]");
3164
+ i == null || i.focus();
3165
+ }
3166
+ }
3167
+ positionToolbar(e) {
3168
+ const o = this.shadow.querySelector(".toolbar");
3169
+ if (!o) return;
3170
+ const a = 20, { toolbarPosition: r } = e.settings;
3171
+ let s, i;
3172
+ switch (r) {
3173
+ case "top-left":
3174
+ s = a, i = a;
3175
+ break;
3176
+ case "top-right":
3177
+ s = window.innerWidth - o.offsetWidth - a, i = a;
3178
+ break;
3179
+ case "bottom-left":
3180
+ s = a, i = window.innerHeight - o.offsetHeight - a;
3181
+ break;
3182
+ case "bottom-right":
3183
+ default:
3184
+ s = window.innerWidth - o.offsetWidth - a, i = window.innerHeight - o.offsetHeight - a;
3185
+ break;
3186
+ }
3187
+ (e.toolbarPosition.x !== 20 || e.toolbarPosition.y !== 20) && (s = e.toolbarPosition.x, i = e.toolbarPosition.y), o.style.left = `${s}px`, o.style.top = `${i}px`;
3188
+ }
3189
+ }
3190
+ function gt(t = "agent-ui-annotation") {
3191
+ customElements.get(t) || customElements.define(t, xn);
3192
+ }
3193
+ gt();
3194
+ function yn(t = {}) {
3195
+ const {
3196
+ container: n = document.body,
3197
+ theme: e = "auto",
3198
+ outputLevel: o = "standard",
3199
+ scopeColor: a,
3200
+ autoActivate: r = !1,
3201
+ onScopeCreate: s,
3202
+ onScopeUpdate: i,
3203
+ onScopeDelete: p,
3204
+ onScopesClear: f,
3205
+ onCopy: u
3206
+ } = t, c = document.createElement("agent-ui-annotation");
3207
+ return c.setAttribute("theme", e), c.setAttribute("output-level", o), a && c.setAttribute("scope-color", a), s && c.addEventListener("annotation:scope", (l) => {
3208
+ s(l.detail.scope);
3209
+ }), i && c.addEventListener("annotation:update", (l) => {
3210
+ i(l.detail.scope);
3211
+ }), p && c.addEventListener("annotation:delete", (l) => {
3212
+ p(l.detail.id);
3213
+ }), f && c.addEventListener("annotation:clear", (l) => {
3214
+ f(l.detail.scopes);
3215
+ }), u && c.addEventListener("annotation:copy", (l) => {
3216
+ u(l.detail.content, l.detail.level);
3217
+ }), n.appendChild(c), r && requestAnimationFrame(() => {
3218
+ c.activate();
3219
+ }), {
3220
+ element: c,
3221
+ activate() {
3222
+ c.activate();
3223
+ },
3224
+ deactivate() {
3225
+ c.deactivate();
3226
+ },
3227
+ toggle() {
3228
+ c.toggle();
3229
+ },
3230
+ async copyOutput(l) {
3231
+ return c.copyOutput(l);
3232
+ },
3233
+ getOutput(l) {
3234
+ return c.getOutput(l);
3235
+ },
3236
+ clearAll() {
3237
+ c.clearAll();
3238
+ },
3239
+ destroy() {
3240
+ c.remove();
3241
+ }
3242
+ };
3243
+ }
3244
+ function Yn(t = {}) {
3245
+ return yn({ ...t, autoActivate: !0 });
3246
+ }
3247
+ gt();
3248
+ export {
3249
+ xn as AnnotationElement,
3250
+ bn as SCOPE_COLORS,
3251
+ D as collectElementInfo,
3252
+ yn as createAnnotation,
3253
+ en as createAnnotationCore,
3254
+ At as createEventBus,
3255
+ $t as createStore,
3256
+ qt as generateSelectorPath,
3257
+ Pn as getAccentColor,
3258
+ X as identifyElement,
3259
+ Yn as init,
3260
+ gt as registerAnnotationElement,
3261
+ V as resolveTheme
3262
+ };
3263
+ //# sourceMappingURL=agent-ui-annotation.js.map