@githumbi/grabby 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1217,7 +1217,7 @@ function createElementPicker(deps) {
1217
1217
  e.stopPropagation();
1218
1218
  if (heldElement) return;
1219
1219
  if (hoveredElement) {
1220
- deps.onSelect(hoveredElement);
1220
+ deps.onSelect(hoveredElement, { x: e.clientX, y: e.clientY });
1221
1221
  }
1222
1222
  }
1223
1223
  return {
@@ -1475,7 +1475,8 @@ function createWebhookPlugin(url) {
1475
1475
  type: "grabby.comment",
1476
1476
  version: 1,
1477
1477
  origin: typeof location !== "undefined" ? location.origin : null,
1478
- comment
1478
+ // The marker position is browser-only.
1479
+ comment: { ...comment, pin: void 0 }
1479
1480
  })
1480
1481
  }).catch(() => {
1481
1482
  });
@@ -1567,6 +1568,9 @@ ${vars.join("\n")}
1567
1568
 
1568
1569
  // src/core/toolbar/toolbar-renderer.ts
1569
1570
  var TOOLBAR_ID = "__grabby-toolbar__";
1571
+ var COLLAPSED_SIZE = 42;
1572
+ var EASE_OUT_EXPO = "cubic-bezier(0.19, 1, 0.22, 1)";
1573
+ var MORPH_MS = 360;
1570
1574
  var STYLE_ID3 = "__grabby-toolbar-styles__";
1571
1575
  function syncSummary(comments) {
1572
1576
  if (comments.length === 0) return null;
@@ -1588,7 +1592,13 @@ function createToolbarRenderer(callbacks, options = {}) {
1588
1592
  let badge = null;
1589
1593
  let status = null;
1590
1594
  let expandBadge = null;
1595
+ let content = null;
1591
1596
  let collapsed = false;
1597
+ let morphTimer = null;
1598
+ function clearMorph() {
1599
+ if (morphTimer) clearTimeout(morphTimer);
1600
+ morphTimer = null;
1601
+ }
1592
1602
  function injectStyles2() {
1593
1603
  if (hasStyles(STYLE_ID3)) return;
1594
1604
  addStyles(STYLE_ID3, `
@@ -1608,7 +1618,21 @@ function createToolbarRenderer(callbacks, options = {}) {
1608
1618
  box-shadow: 0 4px 16px var(--grabby-toolbar-shadow, rgba(0, 0, 0, 0.12));
1609
1619
  pointer-events: auto;
1610
1620
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
1611
- transition: opacity 0.2s ease, transform 0.2s ease;
1621
+ box-sizing: border-box;
1622
+ height: ${COLLAPSED_SIZE}px;
1623
+ overflow: hidden;
1624
+ justify-content: flex-end;
1625
+ transition: opacity 0.2s ease, transform 0.2s ease,
1626
+ left ${MORPH_MS}ms ${EASE_OUT_EXPO}, width ${MORPH_MS}ms ${EASE_OUT_EXPO};
1627
+ }
1628
+ #${TOOLBAR_ID} .grabby-toolbar-content {
1629
+ display: flex;
1630
+ align-items: center;
1631
+ gap: 2px;
1632
+ flex-shrink: 0;
1633
+ transform-origin: right center;
1634
+ transition: opacity 0.24s ease-out, filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
1635
+ transform 0.42s ${EASE_OUT_EXPO}, visibility 0s;
1612
1636
  }
1613
1637
  #${TOOLBAR_ID}.grabby-toolbar-hidden {
1614
1638
  opacity: 0;
@@ -1704,23 +1728,44 @@ function createToolbarRenderer(callbacks, options = {}) {
1704
1728
  background: var(--grabby-accent-hover, #1d4ed8);
1705
1729
  color: #fff;
1706
1730
  }
1707
- #${TOOLBAR_ID} button.grabby-btn-expand { display: none; }
1731
+ #${TOOLBAR_ID} button.grabby-btn-expand {
1732
+ position: absolute;
1733
+ left: 50%;
1734
+ top: 50%;
1735
+ translate: -50% -50%;
1736
+ color: var(--grabby-accent, #2563eb);
1737
+ opacity: 0;
1738
+ scale: 0.6;
1739
+ visibility: hidden;
1740
+ pointer-events: none;
1741
+ transition: opacity 0.2s ease-out, scale 0.3s ${EASE_OUT_EXPO}, visibility 0s 0.2s;
1742
+ }
1743
+ #${TOOLBAR_ID} button.grabby-btn-expand .grabby-badge { top: -3px; right: -5px; }
1708
1744
  #${TOOLBAR_ID}.grabby-toolbar-collapsed {
1709
- left: auto;
1710
- right: 20px;
1711
- transform: none;
1745
+ left: calc(100% - 20px - ${COLLAPSED_SIZE / 2}px);
1712
1746
  padding: 4px;
1713
1747
  }
1714
- #${TOOLBAR_ID}.grabby-toolbar-collapsed.grabby-toolbar-hidden {
1715
- transform: translateY(20px);
1748
+ #${TOOLBAR_ID}.grabby-toolbar-collapsed .grabby-toolbar-content {
1749
+ opacity: 0;
1750
+ filter: blur(6px);
1751
+ transform: scale(0.4);
1752
+ pointer-events: none;
1753
+ visibility: hidden;
1754
+ transition: opacity 0.24s ease-out, filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
1755
+ transform 0.42s ${EASE_OUT_EXPO}, visibility 0s 0.3s;
1716
1756
  }
1717
- #${TOOLBAR_ID}.grabby-toolbar-collapsed > * { display: none !important; }
1718
- #${TOOLBAR_ID}.grabby-toolbar-collapsed > button.grabby-btn-expand {
1719
- display: flex !important;
1720
- width: 40px;
1721
- height: 40px;
1722
- border-radius: 50%;
1723
- color: var(--grabby-accent, #2563eb);
1757
+ #${TOOLBAR_ID}.grabby-toolbar-collapsed button.grabby-btn-expand {
1758
+ opacity: 1;
1759
+ scale: 1;
1760
+ visibility: visible;
1761
+ pointer-events: auto;
1762
+ transition: opacity 0.24s ease-out 0.08s, scale 0.36s ${EASE_OUT_EXPO} 0.08s, visibility 0s;
1763
+ }
1764
+ @media (prefers-reduced-motion: reduce) {
1765
+ #${TOOLBAR_ID}, #${TOOLBAR_ID} .grabby-toolbar-content, #${TOOLBAR_ID} button.grabby-btn-expand {
1766
+ transition-duration: 0s !important;
1767
+ transition-delay: 0s !important;
1768
+ }
1724
1769
  }
1725
1770
  #${TOOLBAR_ID} .grabby-toolbar-left.grabby-toolbar-left-hidden {
1726
1771
  max-width: 0;
@@ -1775,7 +1820,9 @@ function createToolbarRenderer(callbacks, options = {}) {
1775
1820
  leftGroup.appendChild(buttons.selection);
1776
1821
  leftGroup.appendChild(buttons.history);
1777
1822
  leftGroup.appendChild(divider);
1778
- container.appendChild(leftGroup);
1823
+ content = document.createElement("div");
1824
+ content.className = "grabby-toolbar-content";
1825
+ content.appendChild(leftGroup);
1779
1826
  if (options.review) {
1780
1827
  status = document.createElement("span");
1781
1828
  status.className = "grabby-toolbar-status";
@@ -1792,18 +1839,22 @@ function createToolbarRenderer(callbacks, options = {}) {
1792
1839
  e.stopPropagation();
1793
1840
  _optionalChain([callbacks, 'access', _47 => _47.onFinish, 'optionalCall', _48 => _48()]);
1794
1841
  });
1795
- container.appendChild(status);
1796
- container.appendChild(buttons.finish);
1842
+ content.appendChild(status);
1843
+ content.appendChild(buttons.finish);
1797
1844
  allElements.add(status);
1798
1845
  }
1799
- if (!options.hideEnable) container.appendChild(buttons.enable);
1800
- container.appendChild(buttons.dismiss);
1801
- container.appendChild(buttons.expand);
1802
- container.classList.toggle("grabby-toolbar-collapsed", collapsed);
1846
+ if (!options.hideEnable) content.appendChild(buttons.enable);
1847
+ content.appendChild(buttons.dismiss);
1848
+ container.append(content, buttons.expand);
1849
+ if (collapsed) {
1850
+ container.classList.add("grabby-toolbar-collapsed");
1851
+ container.style.width = `${COLLAPSED_SIZE}px`;
1852
+ }
1803
1853
  getUiRoot().appendChild(container);
1804
1854
  allElements.clear();
1805
1855
  allElements.add(container);
1806
1856
  allElements.add(leftGroup);
1857
+ allElements.add(content);
1807
1858
  allElements.add(divider);
1808
1859
  for (const btn of Object.values(buttons)) {
1809
1860
  allElements.add(btn);
@@ -1849,12 +1900,28 @@ function createToolbarRenderer(callbacks, options = {}) {
1849
1900
  }
1850
1901
  },
1851
1902
  collapse() {
1903
+ if (collapsed) return;
1852
1904
  collapsed = true;
1853
- _optionalChain([container, 'optionalAccess', _57 => _57.classList, 'access', _58 => _58.add, 'call', _59 => _59("grabby-toolbar-collapsed")]);
1905
+ if (!container) return;
1906
+ clearMorph();
1907
+ container.style.width = `${container.offsetWidth}px`;
1908
+ void container.offsetWidth;
1909
+ container.classList.add("grabby-toolbar-collapsed");
1910
+ container.style.width = `${COLLAPSED_SIZE}px`;
1854
1911
  },
1855
1912
  expand() {
1913
+ if (!collapsed) return;
1856
1914
  collapsed = false;
1857
- _optionalChain([container, 'optionalAccess', _60 => _60.classList, 'access', _61 => _61.remove, 'call', _62 => _62("grabby-toolbar-collapsed")]);
1915
+ if (!container) return;
1916
+ clearMorph();
1917
+ container.classList.remove("grabby-toolbar-collapsed");
1918
+ const cs = getComputedStyle(container);
1919
+ const chrome = ["paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"].reduce((sum, k) => sum + (parseFloat(cs[k]) || 0), 0);
1920
+ container.style.width = `${(_nullishCoalesce(_optionalChain([content, 'optionalAccess', _57 => _57.offsetWidth]), () => ( 0))) + chrome}px`;
1921
+ morphTimer = setTimeout(() => {
1922
+ morphTimer = null;
1923
+ if (!collapsed && container) container.style.width = "";
1924
+ }, MORPH_MS + 40);
1858
1925
  },
1859
1926
  isCollapsed() {
1860
1927
  return collapsed;
@@ -1870,10 +1937,12 @@ function createToolbarRenderer(callbacks, options = {}) {
1870
1937
  return false;
1871
1938
  },
1872
1939
  dispose() {
1873
- _optionalChain([container, 'optionalAccess', _63 => _63.remove, 'call', _64 => _64()]);
1940
+ clearMorph();
1941
+ _optionalChain([container, 'optionalAccess', _58 => _58.remove, 'call', _59 => _59()]);
1874
1942
  removeStyles(STYLE_ID3);
1875
1943
  container = null;
1876
1944
  leftGroup = null;
1945
+ content = null;
1877
1946
  buttons = {};
1878
1947
  badge = null;
1879
1948
  expandBadge = null;
@@ -1921,7 +1990,7 @@ function header(comments, env, ctx) {
1921
1990
  if (frameworks.length) meta.push(frameworks.join(", "));
1922
1991
  const routes = uniq(comments.map((c) => c.page.route));
1923
1992
  if (!ctx.showRoutes && routes.length === 1) meta.push(`page ${routes[0]}`);
1924
- const vp = _optionalChain([comments, 'access', _65 => _65[0], 'optionalAccess', _66 => _66.page, 'access', _67 => _67.viewport]);
1993
+ const vp = _optionalChain([comments, 'access', _60 => _60[0], 'optionalAccess', _61 => _61.page, 'access', _62 => _62.viewport]);
1925
1994
  if (vp) meta.push(`${vp[0]}\xD7${vp[1]}`);
1926
1995
  meta.push((_nullishCoalesce(env.now, () => ( /* @__PURE__ */ new Date()))).toISOString().slice(0, 10));
1927
1996
  lines.push(meta.join(" \xB7 "));
@@ -1947,8 +2016,8 @@ function detailBlock(c, i, ctx, groupHasSource, headedComponent) {
1947
2016
  const b = (text) => lines.push(` - ${text}`);
1948
2017
  const where = [`\`${t.preview}\``, `(${t.kind})`];
1949
2018
  if (t.component && t.component !== headedComponent) {
1950
- where.push(_optionalChain([t, 'access', _68 => _68.source, 'optionalAccess', _69 => _69.line]) != null && groupHasSource ? `${t.component} line ${t.source.line}` : t.component);
1951
- } else if (_optionalChain([t, 'access', _70 => _70.source, 'optionalAccess', _71 => _71.line]) != null && groupHasSource) {
2019
+ where.push(_optionalChain([t, 'access', _63 => _63.source, 'optionalAccess', _64 => _64.line]) != null && groupHasSource ? `${t.component} line ${t.source.line}` : t.component);
2020
+ } else if (_optionalChain([t, 'access', _65 => _65.source, 'optionalAccess', _66 => _66.line]) != null && groupHasSource) {
1952
2021
  where.push(`line ${t.source.line}`);
1953
2022
  }
1954
2023
  b(where.join(" "));
@@ -1964,7 +2033,7 @@ function detailBlock(c, i, ctx, groupHasSource, headedComponent) {
1964
2033
  for (const [k, v] of Object.entries(t.extra)) b(`${k}: ${v}`);
1965
2034
  b(`viewport: ${c.page.viewport[0]}\xD7${c.page.viewport[1]}`);
1966
2035
  }
1967
- if (_optionalChain([c, 'access', _72 => _72.screenshot, 'optionalAccess', _73 => _73.url])) b(`screenshot: ${c.screenshot.url}`);
2036
+ if (_optionalChain([c, 'access', _67 => _67.screenshot, 'optionalAccess', _68 => _68.url])) b(`screenshot: ${c.screenshot.url}`);
1968
2037
  const meta = [];
1969
2038
  if (ctx.showAuthors) meta.push(`by ${authorLabel(c.author)}`);
1970
2039
  if (ctx.showRoutes) meta.push(`on ${c.page.route}`);
@@ -1990,7 +2059,7 @@ function formatExport(comments, level = "standard", env = {}) {
1990
2059
  }
1991
2060
  const groups = /* @__PURE__ */ new Map();
1992
2061
  for (const c of ordered) {
1993
- const key = _nullishCoalesce(_optionalChain([c, 'access', _74 => _74.target, 'access', _75 => _75.source, 'optionalAccess', _76 => _76.file]), () => ( ""));
2062
+ const key = _nullishCoalesce(_optionalChain([c, 'access', _69 => _69.target, 'access', _70 => _70.source, 'optionalAccess', _71 => _71.file]), () => ( ""));
1994
2063
  const list = groups.get(key);
1995
2064
  if (list) list.push(c);
1996
2065
  else groups.set(key, [c]);
@@ -2000,7 +2069,7 @@ function formatExport(comments, level = "standard", env = {}) {
2000
2069
  out.push("");
2001
2070
  const components = uniq(list.map((c) => c.target.component));
2002
2071
  const headed = file && components.length === 1 ? components[0] : null;
2003
- const lines = uniq(list.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _77 => _77.target, 'access', _78 => _78.source, 'optionalAccess', _79 => _79.line]), () => ( null))));
2072
+ const lines = uniq(list.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _72 => _72.target, 'access', _73 => _73.source, 'optionalAccess', _74 => _74.line]), () => ( null))));
2004
2073
  if (file) {
2005
2074
  const loc = lines.length === 1 ? location2(file, lines[0], true) : file;
2006
2075
  out.push(`## ${loc}${headed ? ` \xB7 ${headed}` : ""}`);
@@ -2185,7 +2254,7 @@ function createCommentsPanel(callbacks, options = {}) {
2185
2254
  let visible = false;
2186
2255
  let objectUrls = [];
2187
2256
  function ensurePanel() {
2188
- if (_optionalChain([panel, 'optionalAccess', _80 => _80.isConnected])) return panel;
2257
+ if (_optionalChain([panel, 'optionalAccess', _75 => _75.isConnected])) return panel;
2189
2258
  addStyles(STYLE_ID4, CSS2);
2190
2259
  panel = h("div", { id: PANEL_ID, role: "dialog", "aria-label": "Comments" });
2191
2260
  getUiRoot().appendChild(panel);
@@ -2196,7 +2265,7 @@ function createCommentsPanel(callbacks, options = {}) {
2196
2265
  objectUrls = [];
2197
2266
  }
2198
2267
  function thumbnail(comment) {
2199
- const localId = _optionalChain([comment, 'access', _81 => _81.screenshot, 'optionalAccess', _82 => _82.localId]);
2268
+ const localId = _optionalChain([comment, 'access', _76 => _76.screenshot, 'optionalAccess', _77 => _77.localId]);
2200
2269
  if (!localId) return null;
2201
2270
  const img = h("img", { class: "grabby-thumb", alt: "", loading: "lazy" });
2202
2271
  img.addEventListener("error", () => img.remove(), { once: true });
@@ -2305,7 +2374,7 @@ function createCommentsPanel(callbacks, options = {}) {
2305
2374
  h("strong", null, live ? "Nothing sent yet" : "No comments yet"),
2306
2375
  live ? "Click Comment, then click the part of the page you want to talk about." : "Click the hand icon (or press Alt+G), then click anything on the page to comment on it."
2307
2376
  ) : h("div", { class: "grabby-panel-list" }, ...comments.map((c) => row2(c, showAuthors)));
2308
- const who = _nullishCoalesce(_optionalChain([options, 'access', _83 => _83.identityLabel, 'optionalCall', _84 => _84()]), () => ( null));
2377
+ const who = _nullishCoalesce(_optionalChain([options, 'access', _78 => _78.identityLabel, 'optionalCall', _79 => _79()]), () => ( null));
2309
2378
  let footer = null;
2310
2379
  if (live && who) {
2311
2380
  footer = h(
@@ -2318,7 +2387,7 @@ function createCommentsPanel(callbacks, options = {}) {
2318
2387
  "data-grabby-change-identity": "",
2319
2388
  onclick: (e) => {
2320
2389
  e.stopPropagation();
2321
- _optionalChain([callbacks, 'access', _85 => _85.onChangeIdentity, 'optionalCall', _86 => _86()]);
2390
+ _optionalChain([callbacks, 'access', _80 => _80.onChangeIdentity, 'optionalCall', _81 => _81()]);
2322
2391
  }
2323
2392
  }, "Change")
2324
2393
  );
@@ -2352,7 +2421,7 @@ function createCommentsPanel(callbacks, options = {}) {
2352
2421
  },
2353
2422
  hide() {
2354
2423
  visible = false;
2355
- _optionalChain([panel, 'optionalAccess', _87 => _87.classList, 'access', _88 => _88.remove, 'call', _89 => _89("grabby-popover-visible")]);
2424
+ _optionalChain([panel, 'optionalAccess', _82 => _82.classList, 'access', _83 => _83.remove, 'call', _84 => _84("grabby-popover-visible")]);
2356
2425
  },
2357
2426
  isVisible() {
2358
2427
  return visible;
@@ -2362,7 +2431,7 @@ function createCommentsPanel(callbacks, options = {}) {
2362
2431
  },
2363
2432
  dispose() {
2364
2433
  revokeThumbs();
2365
- _optionalChain([panel, 'optionalAccess', _90 => _90.remove, 'call', _91 => _91()]);
2434
+ _optionalChain([panel, 'optionalAccess', _85 => _85.remove, 'call', _86 => _86()]);
2366
2435
  removeStyles(STYLE_ID4);
2367
2436
  panel = null;
2368
2437
  visible = false;
@@ -2443,6 +2512,18 @@ function createCommentPopover(callbacks) {
2443
2512
  font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 4px; border: none;
2444
2513
  background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer; text-decoration: underline;
2445
2514
  }
2515
+ #${POPOVER_ID} .grabby-cp-edit-actions { display: flex; align-items: center; gap: 6px; }
2516
+ #${POPOVER_ID} .grabby-cp-edit-actions .grabby-cp-spacer { flex: 1; }
2517
+ #${POPOVER_ID} .grabby-cp-delete {
2518
+ font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 6px; border: none;
2519
+ border-radius: 8px; background: transparent; color: #b91c1c; cursor: pointer;
2520
+ }
2521
+ #${POPOVER_ID} .grabby-cp-delete:hover { background: rgba(185, 28, 28, 0.08); }
2522
+ #${POPOVER_ID} .grabby-cp-cancel {
2523
+ font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 10px; border: none;
2524
+ border-radius: 8px; background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer;
2525
+ }
2526
+ #${POPOVER_ID} .grabby-cp-cancel:hover { background: var(--grabby-surface, #f1f5f9); }
2446
2527
  #${POPOVER_ID} .grabby-cp-hint {
2447
2528
  font-size: 11px;
2448
2529
  color: var(--grabby-text-muted, #94a3b8);
@@ -2504,6 +2585,37 @@ function createCommentPopover(callbacks) {
2504
2585
  function isEditable(el) {
2505
2586
  return !!el && el !== textarea && el !== nameInput && isEditableElement(el);
2506
2587
  }
2588
+ function save() {
2589
+ const v = _optionalChain([textarea, 'optionalAccess', _87 => _87.value, 'access', _88 => _88.trim, 'call', _89 => _89()]);
2590
+ if (!v) return;
2591
+ pendingValue = v;
2592
+ if (askIdentity) showIdentityStep();
2593
+ else finish();
2594
+ }
2595
+ function editActions() {
2596
+ const act = (fn) => (e) => {
2597
+ e.stopPropagation();
2598
+ fn();
2599
+ };
2600
+ const cancel = () => {
2601
+ const ctx = currentCtx;
2602
+ doHide();
2603
+ callbacks.onCancel(ctx);
2604
+ };
2605
+ const del = () => {
2606
+ const ctx = currentCtx;
2607
+ doHide();
2608
+ _optionalChain([callbacks, 'access', _90 => _90.onDelete, 'optionalCall', _91 => _91(ctx)]);
2609
+ };
2610
+ return h(
2611
+ "div",
2612
+ { class: "grabby-cp-edit-actions" },
2613
+ callbacks.onDelete ? h("button", { type: "button", class: "grabby-cp-delete", "data-grabby-delete": "", onclick: act(del) }, "Delete") : null,
2614
+ h("span", { class: "grabby-cp-spacer" }),
2615
+ h("button", { type: "button", class: "grabby-cp-cancel", "data-grabby-cancel": "", onclick: act(cancel) }, "Cancel"),
2616
+ h("button", { type: "button", class: "grabby-cp-post", "data-grabby-save": "", onclick: act(save) }, "Save")
2617
+ );
2618
+ }
2507
2619
  function finish(identity) {
2508
2620
  const ctx = currentCtx;
2509
2621
  const value = pendingValue;
@@ -2569,11 +2681,7 @@ function createCommentPopover(callbacks) {
2569
2681
  e.stopImmediatePropagation();
2570
2682
  if (e.key === "Enter" && !e.shiftKey) {
2571
2683
  e.preventDefault();
2572
- const v = textarea.value.trim();
2573
- if (!v) return;
2574
- pendingValue = v;
2575
- if (askIdentity) showIdentityStep();
2576
- else finish();
2684
+ save();
2577
2685
  } else if (e.key === "Escape") {
2578
2686
  e.preventDefault();
2579
2687
  const ctx = currentCtx;
@@ -2607,6 +2715,7 @@ function createCommentPopover(callbacks) {
2607
2715
  currentCtx = { mode: opts.mode, entryId: opts.entryId };
2608
2716
  askIdentity = opts.askIdentity === true && opts.mode === "new";
2609
2717
  visible = true;
2718
+ if (opts.mode === "edit") el.appendChild(editActions());
2610
2719
  position(el, opts.anchor);
2611
2720
  attachKey();
2612
2721
  _optionalChain([textarea, 'optionalAccess', _100 => _100.focus, 'call', _101 => _101()]);
@@ -3138,9 +3247,10 @@ function createOutbox(deps) {
3138
3247
  }, delay);
3139
3248
  }
3140
3249
  function wireShape(c) {
3141
- const { screenshot: _shot, sync: _sync, ...rest } = c;
3250
+ const { screenshot: _shot, sync: _sync, pin: _pin, ...rest } = c;
3142
3251
  void _shot;
3143
3252
  void _sync;
3253
+ void _pin;
3144
3254
  return rest;
3145
3255
  }
3146
3256
  function postComment(comment) {
@@ -3450,11 +3560,363 @@ function createFreezeOverlay() {
3450
3560
  };
3451
3561
  }
3452
3562
 
3563
+ // src/core/overlay/markers.ts
3564
+ var LAYER_ID = "__grabby-markers__";
3565
+ var DOC_LAYER_ID = "__grabby-markers-doc__";
3566
+ var CONTEXT_CHECK_MS = 1e3;
3567
+ var TIP_ID = "__grabby-marker-tip__";
3568
+ var STYLE_ID9 = "__grabby-marker-styles__";
3569
+ var SIZE = 22;
3570
+ var ROUTE_CHECK_MS = 250;
3571
+ var LOOKUP_RETRY_MS = 500;
3572
+ var STAGGER_MS = 30;
3573
+ var TIP_MAX = 140;
3574
+ var ICON_EDIT = {
3575
+ size: 12,
3576
+ shapes: paths("M10.5 2.5l3 3L6 13H3v-3z", "M9 4l3 3")
3577
+ };
3578
+ function scrollContextOf(el) {
3579
+ for (let cur = el.parentElement; cur && cur !== document.body && cur !== document.documentElement; cur = cur.parentElement) {
3580
+ const style = getComputedStyle(cur);
3581
+ if (style.position === "fixed" || style.position === "sticky") return "screen";
3582
+ if (/(auto|scroll|overlay)/.test(style.overflowY + style.overflowX)) return "screen";
3583
+ }
3584
+ const own = getComputedStyle(el).position;
3585
+ return own === "fixed" || own === "sticky" ? "screen" : "page";
3586
+ }
3587
+ function createMarkers(deps) {
3588
+ let layer = null;
3589
+ let docLayer = null;
3590
+ let tip = null;
3591
+ let visible = false;
3592
+ let route = "";
3593
+ let rafId = null;
3594
+ let lastRouteCheck = 0;
3595
+ let hovered = null;
3596
+ const entries = /* @__PURE__ */ new Map();
3597
+ function injectStyles2() {
3598
+ if (hasStyles(STYLE_ID9)) return;
3599
+ addStyles(STYLE_ID9, `
3600
+ /*
3601
+ * Page coordinates: the browser moves these with the page as it
3602
+ * scrolls, so they never trail behind their element. (A fixed layer
3603
+ * repositioned from script lags a frame behind fast scrolling.)
3604
+ */
3605
+ #${DOC_LAYER_ID} {
3606
+ position: absolute;
3607
+ left: 0;
3608
+ top: 0;
3609
+ width: 0;
3610
+ height: 0;
3611
+ pointer-events: none;
3612
+ z-index: ${Z_INDEX_CROSSHAIR};
3613
+ }
3614
+ #${LAYER_ID} {
3615
+ position: fixed;
3616
+ inset: 0;
3617
+ pointer-events: none;
3618
+ z-index: ${Z_INDEX_CROSSHAIR};
3619
+ }
3620
+ .grabby-markers-layer .grabby-marker {
3621
+ position: absolute;
3622
+ left: 0;
3623
+ top: 0;
3624
+ width: ${SIZE}px;
3625
+ height: ${SIZE}px;
3626
+ margin: 0;
3627
+ padding: 0;
3628
+ border: none;
3629
+ border-radius: 50%;
3630
+ background: var(--grabby-accent, #2563eb);
3631
+ color: #fff;
3632
+ box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, 0.25);
3633
+ font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
3634
+ display: flex;
3635
+ align-items: center;
3636
+ justify-content: center;
3637
+ cursor: pointer;
3638
+ pointer-events: auto;
3639
+ transition: transform 0.12s ease, box-shadow 0.15s ease;
3640
+ }
3641
+ .grabby-markers-layer .grabby-marker[hidden] { display: none; }
3642
+ .grabby-markers-layer .grabby-marker:hover,
3643
+ .grabby-markers-layer .grabby-marker:focus-visible {
3644
+ z-index: 1;
3645
+ outline: none;
3646
+ box-shadow: 0 0 0 2px #fff, 0 0 0 5px color-mix(in srgb, var(--grabby-accent, #2563eb) 35%, transparent), 0 2px 6px rgba(0, 0, 0, 0.25);
3647
+ }
3648
+ .grabby-markers-layer .grabby-marker-edit { display: none; }
3649
+ .grabby-markers-layer .grabby-marker:hover .grabby-marker-num,
3650
+ .grabby-markers-layer .grabby-marker:focus-visible .grabby-marker-num { display: none; }
3651
+ .grabby-markers-layer .grabby-marker:hover .grabby-marker-edit,
3652
+ .grabby-markers-layer .grabby-marker:focus-visible .grabby-marker-edit { display: block; }
3653
+ .grabby-markers-layer .grabby-marker-in {
3654
+ animation: grabby-marker-in 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
3655
+ }
3656
+ .grabby-markers-layer .grabby-marker-out {
3657
+ animation: grabby-marker-out 0.2s ease-out both;
3658
+ pointer-events: none;
3659
+ }
3660
+ @keyframes grabby-marker-in {
3661
+ from { opacity: 0; scale: 0.3; }
3662
+ to { opacity: 1; scale: 1; }
3663
+ }
3664
+ @keyframes grabby-marker-out {
3665
+ from { opacity: 1; scale: 1; }
3666
+ to { opacity: 0; scale: 0.3; }
3667
+ }
3668
+ #${TIP_ID} {
3669
+ position: fixed;
3670
+ z-index: ${Z_INDEX_CROSSHAIR};
3671
+ max-width: 260px;
3672
+ padding: 8px 10px;
3673
+ border-radius: 10px;
3674
+ background: var(--grabby-label-bg, #1e293b);
3675
+ color: #fff;
3676
+ font: 12px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
3677
+ box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
3678
+ pointer-events: none;
3679
+ white-space: pre-wrap;
3680
+ overflow-wrap: anywhere;
3681
+ animation: grabby-marker-tip-in 0.12s ease both;
3682
+ }
3683
+ #${TIP_ID}[hidden] { display: none; }
3684
+ #${TIP_ID} .grabby-marker-tip-hint { display: block; margin-top: 4px; opacity: 0.6; font-size: 11px; }
3685
+ @keyframes grabby-marker-tip-in {
3686
+ from { opacity: 0; transform: translateY(-2px); }
3687
+ to { opacity: 1; transform: none; }
3688
+ }
3689
+ @media (prefers-reduced-motion: reduce) {
3690
+ .grabby-markers-layer .grabby-marker-in, .grabby-markers-layer .grabby-marker-out, #${TIP_ID} { animation: none; }
3691
+ }
3692
+ `);
3693
+ }
3694
+ function ensureLayer() {
3695
+ if (layer) return layer;
3696
+ injectStyles2();
3697
+ layer = document.createElement("div");
3698
+ layer.id = LAYER_ID;
3699
+ layer.className = "grabby-markers-layer";
3700
+ docLayer = document.createElement("div");
3701
+ docLayer.id = DOC_LAYER_ID;
3702
+ docLayer.className = "grabby-markers-layer";
3703
+ tip = document.createElement("div");
3704
+ tip.id = TIP_ID;
3705
+ tip.hidden = true;
3706
+ tip.setAttribute("role", "tooltip");
3707
+ getUiRoot().append(docLayer, layer, tip);
3708
+ return layer;
3709
+ }
3710
+ function pageComments() {
3711
+ return deps.getComments().filter((c) => c.page.route === route).reverse();
3712
+ }
3713
+ function preview(text) {
3714
+ const flat = text.trim();
3715
+ return flat.length > TIP_MAX ? `${flat.slice(0, TIP_MAX - 1)}\u2026` : flat;
3716
+ }
3717
+ function createEntry(comment) {
3718
+ const number = document.createElement("span");
3719
+ number.className = "grabby-marker-num";
3720
+ const button = document.createElement("button");
3721
+ button.type = "button";
3722
+ button.className = "grabby-marker";
3723
+ button.dataset.grabbyMarker = comment.id;
3724
+ button.append(number, svgIcon(ICON_EDIT, "grabby-marker-edit"));
3725
+ const entry = { comment, button, number, element: null, lastLookup: 0, context: "page", contextCheckedAt: -Infinity };
3726
+ button.addEventListener("click", (e) => {
3727
+ e.preventDefault();
3728
+ e.stopPropagation();
3729
+ hideTip();
3730
+ deps.onOpen(entry.comment, entry.element, button);
3731
+ });
3732
+ button.addEventListener("mouseenter", () => startHover(entry));
3733
+ button.addEventListener("focus", () => startHover(entry));
3734
+ button.addEventListener("mouseleave", () => endHover(entry));
3735
+ button.addEventListener("blur", () => endHover(entry));
3736
+ return entry;
3737
+ }
3738
+ function startHover(entry) {
3739
+ hovered = entry;
3740
+ showTip(entry);
3741
+ deps.onHover(entry.comment, entry.element);
3742
+ }
3743
+ function endHover(entry) {
3744
+ if (hovered !== entry) return;
3745
+ hovered = null;
3746
+ hideTip();
3747
+ deps.onHover(null, null);
3748
+ }
3749
+ function showTip(entry) {
3750
+ if (!tip) return;
3751
+ const hint = document.createElement("span");
3752
+ hint.className = "grabby-marker-tip-hint";
3753
+ hint.textContent = "Click to edit";
3754
+ tip.replaceChildren(document.createTextNode(preview(entry.comment.comment)), hint);
3755
+ tip.hidden = false;
3756
+ placeTip(entry);
3757
+ }
3758
+ function placeTip(entry) {
3759
+ if (!tip || tip.hidden) return;
3760
+ const m = entry.button.getBoundingClientRect();
3761
+ const t = tip.getBoundingClientRect();
3762
+ const left = Math.max(8, Math.min(m.left + m.width / 2 - t.width / 2, window.innerWidth - t.width - 8));
3763
+ const below = m.bottom + 8;
3764
+ const top = below + t.height > window.innerHeight - 8 ? m.top - 8 - t.height : below;
3765
+ tip.style.left = `${left}px`;
3766
+ tip.style.top = `${Math.max(8, top)}px`;
3767
+ }
3768
+ function hideTip() {
3769
+ if (tip) tip.hidden = true;
3770
+ }
3771
+ function animateIn(button, delay) {
3772
+ button.classList.remove("grabby-marker-out", "grabby-marker-in");
3773
+ button.style.animationDelay = `${delay}ms`;
3774
+ void button.offsetWidth;
3775
+ button.classList.add("grabby-marker-in");
3776
+ }
3777
+ function removeEntry(id, animate) {
3778
+ const entry = entries.get(id);
3779
+ if (!entry) return;
3780
+ entries.delete(id);
3781
+ if (hovered === entry) endHover(entry);
3782
+ if (!animate) {
3783
+ entry.button.remove();
3784
+ return;
3785
+ }
3786
+ entry.button.style.animationDelay = "0ms";
3787
+ entry.button.classList.remove("grabby-marker-in");
3788
+ entry.button.classList.add("grabby-marker-out");
3789
+ setTimeout(() => entry.button.remove(), 220);
3790
+ }
3791
+ function sync(fresh) {
3792
+ if (!visible) return;
3793
+ const host2 = ensureLayer();
3794
+ const list = pageComments();
3795
+ const ids = new Set(list.map((c) => c.id));
3796
+ for (const id of [...entries.keys()]) if (!ids.has(id)) removeEntry(id, !fresh);
3797
+ list.forEach((comment, i) => {
3798
+ let entry = entries.get(comment.id);
3799
+ const isNew = !entry;
3800
+ if (!entry) {
3801
+ entry = createEntry(comment);
3802
+ entries.set(comment.id, entry);
3803
+ host2.appendChild(entry.button);
3804
+ }
3805
+ entry.comment = comment;
3806
+ const n = String(i + 1);
3807
+ entry.number.textContent = n;
3808
+ entry.button.setAttribute("aria-label", `Comment ${n}: ${preview(comment.comment)}. Click to edit.`);
3809
+ if (fresh || isNew) animateIn(entry.button, fresh ? i * STAGGER_MS : 0);
3810
+ });
3811
+ if (hovered && entries.get(hovered.comment.id) === hovered) showTip(hovered);
3812
+ position(performance.now());
3813
+ schedule();
3814
+ }
3815
+ function position(now) {
3816
+ for (const entry of entries.values()) {
3817
+ if (!_optionalChain([entry, 'access', _134 => _134.element, 'optionalAccess', _135 => _135.isConnected])) {
3818
+ entry.element = null;
3819
+ if (now - entry.lastLookup >= LOOKUP_RETRY_MS) {
3820
+ entry.lastLookup = now;
3821
+ entry.element = deps.findElement(entry.comment);
3822
+ }
3823
+ }
3824
+ const rect = _optionalChain([entry, 'access', _136 => _136.element, 'optionalAccess', _137 => _137.getBoundingClientRect, 'call', _138 => _138()]);
3825
+ if (!rect || rect.width === 0 && rect.height === 0) {
3826
+ entry.button.hidden = true;
3827
+ continue;
3828
+ }
3829
+ if (now - entry.contextCheckedAt >= CONTEXT_CHECK_MS) {
3830
+ entry.contextCheckedAt = now;
3831
+ entry.context = scrollContextOf(entry.element);
3832
+ const home = entry.context === "page" ? docLayer : layer;
3833
+ if (home && entry.button.parentElement !== home) home.appendChild(entry.button);
3834
+ }
3835
+ const pin = _nullishCoalesce(entry.comment.pin, () => ( { x: 1, y: 0 }));
3836
+ const maxX = (document.documentElement.clientWidth || window.innerWidth) - SIZE;
3837
+ let x = Math.max(0, Math.min(rect.left + pin.x * rect.width - SIZE / 2, maxX));
3838
+ let y = rect.top + pin.y * rect.height - SIZE / 2;
3839
+ if (entry.context === "page") {
3840
+ x += window.scrollX;
3841
+ y = Math.max(0, y + window.scrollY);
3842
+ }
3843
+ entry.button.hidden = false;
3844
+ entry.button.style.transform = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;
3845
+ }
3846
+ if (hovered) placeTip(hovered);
3847
+ }
3848
+ function frame() {
3849
+ rafId = null;
3850
+ const now = performance.now();
3851
+ if (!visible) return;
3852
+ if (now - lastRouteCheck >= ROUTE_CHECK_MS) {
3853
+ lastRouteCheck = now;
3854
+ const next = deps.currentRoute();
3855
+ if (next !== route) {
3856
+ route = next;
3857
+ for (const id of [...entries.keys()]) removeEntry(id, false);
3858
+ sync(true);
3859
+ return;
3860
+ }
3861
+ }
3862
+ position(now);
3863
+ schedule();
3864
+ }
3865
+ function schedule() {
3866
+ if (rafId === null && visible) rafId = requestAnimationFrame(frame);
3867
+ }
3868
+ function stop() {
3869
+ if (rafId !== null) cancelAnimationFrame(rafId);
3870
+ rafId = null;
3871
+ }
3872
+ function handleScroll() {
3873
+ if (visible && entries.size) position(performance.now());
3874
+ }
3875
+ return {
3876
+ setVisible(next) {
3877
+ if (next === visible) return;
3878
+ visible = next;
3879
+ if (next) {
3880
+ route = deps.currentRoute();
3881
+ lastRouteCheck = performance.now();
3882
+ document.addEventListener("scroll", handleScroll, { capture: true, passive: true });
3883
+ sync(true);
3884
+ } else {
3885
+ document.removeEventListener("scroll", handleScroll, true);
3886
+ stop();
3887
+ hideTip();
3888
+ if (hovered) endHover(hovered);
3889
+ for (const id of [...entries.keys()]) removeEntry(id, true);
3890
+ }
3891
+ },
3892
+ refresh() {
3893
+ sync(false);
3894
+ },
3895
+ isMarkerElement(el) {
3896
+ return [layer, docLayer].some((l) => !!l && (l === el || l.contains(el)));
3897
+ },
3898
+ dispose() {
3899
+ stop();
3900
+ document.removeEventListener("scroll", handleScroll, true);
3901
+ entries.clear();
3902
+ _optionalChain([layer, 'optionalAccess', _139 => _139.remove, 'call', _140 => _140()]);
3903
+ _optionalChain([docLayer, 'optionalAccess', _141 => _141.remove, 'call', _142 => _142()]);
3904
+ docLayer = null;
3905
+ _optionalChain([tip, 'optionalAccess', _143 => _143.remove, 'call', _144 => _144()]);
3906
+ layer = null;
3907
+ tip = null;
3908
+ hovered = null;
3909
+ visible = false;
3910
+ removeStyles(STYLE_ID9);
3911
+ }
3912
+ };
3913
+ }
3914
+
3453
3915
  // src/core/overlay/select-feedback.ts
3454
- var STYLE_ID9 = "__grabby-feedback-styles__";
3916
+ var STYLE_ID10 = "__grabby-feedback-styles__";
3455
3917
  function injectStyles() {
3456
- if (hasStyles(STYLE_ID9)) return;
3457
- addStyles(STYLE_ID9, `
3918
+ if (hasStyles(STYLE_ID10)) return;
3919
+ addStyles(STYLE_ID10, `
3458
3920
  @keyframes grabby-flash {
3459
3921
  0% { opacity: 1; }
3460
3922
  100% { opacity: 0; transform: scale(1.02); }
@@ -3533,7 +3995,7 @@ function showSelectFeedback(element, label = "Selected") {
3533
3995
  setTimeout(cleanup, 1200);
3534
3996
  }
3535
3997
  function disposeFeedbackStyles() {
3536
- removeStyles(STYLE_ID9);
3998
+ removeStyles(STYLE_ID10);
3537
3999
  }
3538
4000
 
3539
4001
  // src/core/storage/history-persistence.ts
@@ -3624,7 +4086,7 @@ function clearPersistedHistory() {
3624
4086
  var baselineFrame = null;
3625
4087
  var baselineCache = /* @__PURE__ */ new Map();
3626
4088
  function baselineDoc() {
3627
- if (_optionalChain([baselineFrame, 'optionalAccess', _134 => _134.isConnected]) && baselineFrame.contentDocument) return baselineFrame.contentDocument;
4089
+ if (_optionalChain([baselineFrame, 'optionalAccess', _145 => _145.isConnected]) && baselineFrame.contentDocument) return baselineFrame.contentDocument;
3628
4090
  try {
3629
4091
  baselineFrame = document.createElement("iframe");
3630
4092
  baselineFrame.setAttribute("aria-hidden", "true");
@@ -3654,8 +4116,8 @@ function baselineFor(tag, type, props) {
3654
4116
  const missing = props.filter((p) => !cached.has(p));
3655
4117
  if (missing.length > 0) {
3656
4118
  const doc = baselineDoc();
3657
- const view = _optionalChain([doc, 'optionalAccess', _135 => _135.defaultView]);
3658
- if (_optionalChain([doc, 'optionalAccess', _136 => _136.body]) && view) {
4119
+ const view = _optionalChain([doc, 'optionalAccess', _146 => _146.defaultView]);
4120
+ if (_optionalChain([doc, 'optionalAccess', _147 => _147.body]) && view) {
3659
4121
  const probe = doc.createElement(tag);
3660
4122
  if (type) probe.setAttribute("type", type);
3661
4123
  doc.body.appendChild(probe);
@@ -3669,7 +4131,7 @@ function baselineFor(tag, type, props) {
3669
4131
  return cached;
3670
4132
  }
3671
4133
  function disposeStyleBaseline() {
3672
- _optionalChain([baselineFrame, 'optionalAccess', _137 => _137.remove, 'call', _138 => _138()]);
4134
+ _optionalChain([baselineFrame, 'optionalAccess', _148 => _148.remove, 'call', _149 => _149()]);
3673
4135
  baselineFrame = null;
3674
4136
  baselineCache.clear();
3675
4137
  }
@@ -3771,7 +4233,7 @@ function states(el) {
3771
4233
  }
3772
4234
  function actionFacts(el) {
3773
4235
  const f = {};
3774
- const imgAlt = _nullishCoalesce(_optionalChain([el, 'access', _139 => _139.querySelector, 'call', _140 => _140("img[alt]"), 'optionalAccess', _141 => _141.getAttribute, 'call', _142 => _142("alt")]), () => ( ""));
4236
+ const imgAlt = _nullishCoalesce(_optionalChain([el, 'access', _150 => _150.querySelector, 'call', _151 => _151("img[alt]"), 'optionalAccess', _152 => _152.getAttribute, 'call', _153 => _153("alt")]), () => ( ""));
3775
4237
  put(f, "label", accessibleLabel(el) || textOf(el, 80) || redact(_nullishCoalesce(el.getAttribute("title"), () => ( ""))) || redact(imgAlt));
3776
4238
  if (el.tagName === "A") put(f, "href", sanitizeUrl(_nullishCoalesce(el.getAttribute("href"), () => ( ""))));
3777
4239
  else if (el.tagName === "BUTTON" || el.tagName === "INPUT") put(f, "type", _nullishCoalesce(el.getAttribute("type"), () => ( (el.tagName === "BUTTON" ? "submit" : ""))));
@@ -3820,7 +4282,7 @@ function mediaFacts(el) {
3820
4282
  put(f, "label", accessibleLabel(el) || textOf(_nullishCoalesce(el.querySelector("title"), () => ( el)), 40));
3821
4283
  put(f, "viewBox", _nullishCoalesce(el.getAttribute("viewBox"), () => ( "")));
3822
4284
  } else if (el.tagName === "VIDEO" || el.tagName === "AUDIO" || el.tagName === "IFRAME") {
3823
- put(f, "src", basename3(_nullishCoalesce(_nullishCoalesce(el.getAttribute("src"), () => ( _optionalChain([el, 'access', _143 => _143.querySelector, 'call', _144 => _144("source"), 'optionalAccess', _145 => _145.getAttribute, 'call', _146 => _146("src")]))), () => ( ""))));
4285
+ put(f, "src", basename3(_nullishCoalesce(_nullishCoalesce(el.getAttribute("src"), () => ( _optionalChain([el, 'access', _154 => _154.querySelector, 'call', _155 => _155("source"), 'optionalAccess', _156 => _156.getAttribute, 'call', _157 => _157("src")]))), () => ( ""))));
3824
4286
  put(f, "title", redact(_nullishCoalesce(el.getAttribute("title"), () => ( ""))));
3825
4287
  }
3826
4288
  put(f, "size", size(el));
@@ -3828,8 +4290,8 @@ function mediaFacts(el) {
3828
4290
  return f;
3829
4291
  }
3830
4292
  function childLabel(child, resolver) {
3831
- const resolved = _optionalChain([resolver, 'optionalCall', _147 => _147(child)]);
3832
- if (_optionalChain([resolved, 'optionalAccess', _148 => _148.name]) && resolved.hostElement === child) return resolved.name;
4293
+ const resolved = _optionalChain([resolver, 'optionalCall', _158 => _158(child)]);
4294
+ if (_optionalChain([resolved, 'optionalAccess', _159 => _159.name]) && resolved.hostElement === child) return resolved.name;
3833
4295
  const tag = child.tagName.toLowerCase();
3834
4296
  if (/^h[1-6]$/.test(tag)) return "heading";
3835
4297
  if (tag === "a") return "link";
@@ -3864,7 +4326,7 @@ function sectionFacts(el, resolver) {
3864
4326
  const f = {};
3865
4327
  put(f, "title", redact(el.ownerDocument.title));
3866
4328
  put(f, "viewport", `${window.innerWidth}\xD7${window.innerHeight}`);
3867
- const regions = Array.from(el.querySelectorAll('header, nav, main, aside, footer, section, [role="region"]')).filter((r) => !_optionalChain([r, 'access', _149 => _149.parentElement, 'optionalAccess', _150 => _150.closest, 'call', _151 => _151('header, nav, main, aside, footer, section, [role="region"]')]) || r.parentElement === el).slice(0, 8).map((r) => {
4329
+ const regions = Array.from(el.querySelectorAll('header, nav, main, aside, footer, section, [role="region"]')).filter((r) => !_optionalChain([r, 'access', _160 => _160.parentElement, 'optionalAccess', _161 => _161.closest, 'call', _162 => _162('header, nav, main, aside, footer, section, [role="region"]')]) || r.parentElement === el).slice(0, 8).map((r) => {
3868
4330
  const heading = firstHeading2(r);
3869
4331
  return heading ? `${r.tagName.toLowerCase()} "${truncate(heading, 30)}"` : r.tagName.toLowerCase();
3870
4332
  });
@@ -3921,22 +4383,22 @@ function isAppFile(file) {
3921
4383
  return !!file && !/(^|[\\/])node_modules[\\/]/.test(file);
3922
4384
  }
3923
4385
  function resolveStack(el, deps) {
3924
- const comp = _nullishCoalesce(_optionalChain([deps, 'access', _152 => _152.componentResolver, 'optionalCall', _153 => _153(el)]), () => ( null));
4386
+ const comp = _nullishCoalesce(_optionalChain([deps, 'access', _163 => _163.componentResolver, 'optionalCall', _164 => _164(el)]), () => ( null));
3925
4387
  const frames = [];
3926
4388
  const named = [];
3927
- for (const entry of _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _154 => _154.stack]), () => ( []))) {
4389
+ for (const entry of _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _165 => _165.stack]), () => ( []))) {
3928
4390
  const src = entry.filePath !== void 0 ? { filePath: entry.filePath, line: _nullishCoalesce(entry.line, () => ( null)) } : entry.hostElement && deps.sourceResolver ? deps.sourceResolver(entry.hostElement) : null;
3929
- const frame = { name: entry.name, file: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _155 => _155.filePath]), () => ( null)), line: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _156 => _156.line]), () => ( null)) };
4391
+ const frame = { name: entry.name, file: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _166 => _166.filePath]), () => ( null)), line: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _167 => _167.line]), () => ( null)) };
3930
4392
  named.push(frame);
3931
4393
  if (isAppFile(frame.file) && frames.length < MAX_STACK) frames.push(frame);
3932
4394
  }
3933
- return { component: _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _157 => _157.name]), () => ( null)), frames: frames.length > 0 ? frames : named.slice(0, 2) };
4395
+ return { component: _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _168 => _168.name]), () => ( null)), frames: frames.length > 0 ? frames : named.slice(0, 2) };
3934
4396
  }
3935
4397
  function resolveSource(el, deps, frames) {
3936
- const own = _optionalChain([deps, 'access', _158 => _158.sourceResolver, 'optionalCall', _159 => _159(el)]);
4398
+ const own = _optionalChain([deps, 'access', _169 => _169.sourceResolver, 'optionalCall', _170 => _170(el)]);
3937
4399
  if (own && isAppFile(own.filePath)) return { file: own.filePath, line: own.line, column: own.column };
3938
4400
  const first = frames.find((f) => isAppFile(f.file));
3939
- return _optionalChain([first, 'optionalAccess', _160 => _160.file]) ? { file: first.file, line: first.line, column: null } : null;
4401
+ return _optionalChain([first, 'optionalAccess', _171 => _171.file]) ? { file: first.file, line: first.line, column: null } : null;
3940
4402
  }
3941
4403
  function captureTarget(el, deps) {
3942
4404
  const cleanClasses = _nullishCoalesce(deps.cleanClasses, () => ( ((list) => list.filter((c) => !isNoiseClass(c)))));
@@ -3987,7 +4449,7 @@ function sandboxHtml() {
3987
4449
  return policy ? policy.createHTML(SANDBOX_HTML) : null;
3988
4450
  }
3989
4451
  async function getSandbox() {
3990
- if (_optionalChain([sandbox, 'optionalAccess', _161 => _161.isConnected])) return sandbox;
4452
+ if (_optionalChain([sandbox, 'optionalAccess', _172 => _172.isConnected])) return sandbox;
3991
4453
  const frame = document.createElement("iframe");
3992
4454
  frame.setAttribute("aria-hidden", "true");
3993
4455
  frame.setAttribute("tabindex", "-1");
@@ -4011,7 +4473,7 @@ async function getSandbox() {
4011
4473
  return frame;
4012
4474
  }
4013
4475
  function disposeScreenshotSandbox() {
4014
- _optionalChain([sandbox, 'optionalAccess', _162 => _162.remove, 'call', _163 => _163()]);
4476
+ _optionalChain([sandbox, 'optionalAccess', _173 => _173.remove, 'call', _174 => _174()]);
4015
4477
  sandbox = null;
4016
4478
  }
4017
4479
  function withTimeout(promise, ms) {
@@ -4171,7 +4633,7 @@ function resolveComponent(element) {
4171
4633
  name: cleanComponentName(owning.constructor.name),
4172
4634
  hostElement: _nullishCoalesce(host2, () => ( walk.parentElement))
4173
4635
  });
4174
- current = _nullishCoalesce(_nullishCoalesce(_optionalChain([host2, 'optionalAccess', _164 => _164.parentElement]), () => ( _optionalChain([walk, 'access', _165 => _165.parentElement, 'optionalAccess', _166 => _166.parentElement]))), () => ( null));
4636
+ current = _nullishCoalesce(_nullishCoalesce(_optionalChain([host2, 'optionalAccess', _175 => _175.parentElement]), () => ( _optionalChain([walk, 'access', _176 => _176.parentElement, 'optionalAccess', _177 => _177.parentElement]))), () => ( null));
4175
4637
  while (current) {
4176
4638
  const comp = ng.getComponent(current);
4177
4639
  if (comp && !seen2.has(comp)) {
@@ -4305,14 +4767,14 @@ function resolveComponent2(element) {
4305
4767
  let current = fiber;
4306
4768
  while (current && stack.length < MAX_STACK2) {
4307
4769
  const name = getComponentName(current.type);
4308
- if (name && !isNoise(name) && _optionalChain([stack, 'access', _167 => _167[stack.length - 1], 'optionalAccess', _168 => _168.name]) !== name) {
4770
+ if (name && !isNoise(name) && _optionalChain([stack, 'access', _178 => _178[stack.length - 1], 'optionalAccess', _179 => _179.name]) !== name) {
4309
4771
  stack.push({ name, hostElement: findHostElement(current) });
4310
4772
  }
4311
4773
  current = current.return;
4312
4774
  }
4313
4775
  return {
4314
- name: _nullishCoalesce(_optionalChain([stack, 'access', _169 => _169[0], 'optionalAccess', _170 => _170.name]), () => ( null)),
4315
- hostElement: _nullishCoalesce(_optionalChain([stack, 'access', _171 => _171[0], 'optionalAccess', _172 => _172.hostElement]), () => ( null)),
4776
+ name: _nullishCoalesce(_optionalChain([stack, 'access', _180 => _180[0], 'optionalAccess', _181 => _181.name]), () => ( null)),
4777
+ hostElement: _nullishCoalesce(_optionalChain([stack, 'access', _182 => _182[0], 'optionalAccess', _183 => _183.hostElement]), () => ( null)),
4316
4778
  stack
4317
4779
  };
4318
4780
  }
@@ -4323,7 +4785,7 @@ var LOCATION = /^(.*?):(\d+):(\d+)(?::([A-Za-z_$][\w$.]*))?$/;
4323
4785
  function resolveSource3(element) {
4324
4786
  let current = element;
4325
4787
  while (current) {
4326
- const raw = _optionalChain([current, 'access', _173 => _173.getAttribute, 'optionalCall', _174 => _174(SOURCE_ATTRIBUTE)]);
4788
+ const raw = _optionalChain([current, 'access', _184 => _184.getAttribute, 'optionalCall', _185 => _185(SOURCE_ATTRIBUTE)]);
4327
4789
  if (raw) return parseLocation(raw);
4328
4790
  current = current.parentElement;
4329
4791
  }
@@ -4335,7 +4797,7 @@ function parseLocation(raw) {
4335
4797
  return { filePath: match[1], line: Number(match[2]), column: Number(match[3]) };
4336
4798
  }
4337
4799
  function ownStamp(element) {
4338
- const raw = _optionalChain([element, 'optionalAccess', _175 => _175.getAttribute, 'optionalCall', _176 => _176(SOURCE_ATTRIBUTE)]);
4800
+ const raw = _optionalChain([element, 'optionalAccess', _186 => _186.getAttribute, 'optionalCall', _187 => _187(SOURCE_ATTRIBUTE)]);
4339
4801
  if (!raw) return null;
4340
4802
  const match = LOCATION.exec(raw);
4341
4803
  if (!match) return { file: raw, line: null, column: null, name: null };
@@ -4350,8 +4812,8 @@ function nameFromStamps(result) {
4350
4812
  const stack = [];
4351
4813
  for (const entry of result.stack) {
4352
4814
  const stamp = ownStamp(entry.hostElement);
4353
- const name = _nullishCoalesce(_optionalChain([stamp, 'optionalAccess', _177 => _177.name]), () => ( (stamp ? baseName(stamp.file) : null)));
4354
- if (name && _optionalChain([stack, 'access', _178 => _178[stack.length - 1], 'optionalAccess', _179 => _179.name]) !== name) stack.push({ name, hostElement: entry.hostElement });
4815
+ const name = _nullishCoalesce(_optionalChain([stamp, 'optionalAccess', _188 => _188.name]), () => ( (stamp ? baseName(stamp.file) : null)));
4816
+ if (name && _optionalChain([stack, 'access', _189 => _189[stack.length - 1], 'optionalAccess', _190 => _190.name]) !== name) stack.push({ name, hostElement: entry.hostElement });
4355
4817
  }
4356
4818
  return stack[0] ? { name: stack[0].name, hostElement: stack[0].hostElement, stack } : null;
4357
4819
  }
@@ -4387,7 +4849,7 @@ function vue3Name(inst) {
4387
4849
  return t.__name || t.name || t.displayName || (t.__file ? baseName(t.__file) : null);
4388
4850
  }
4389
4851
  function vue3Host(inst) {
4390
- return firstElement(_nullishCoalesce(_optionalChain([inst, 'access', _180 => _180.subTree, 'optionalAccess', _181 => _181.el]), () => ( _optionalChain([inst, 'access', _182 => _182.vnode, 'optionalAccess', _183 => _183.el]))));
4852
+ return firstElement(_nullishCoalesce(_optionalChain([inst, 'access', _191 => _191.subTree, 'optionalAccess', _192 => _192.el]), () => ( _optionalChain([inst, 'access', _193 => _193.vnode, 'optionalAccess', _194 => _194.el]))));
4391
4853
  }
4392
4854
  function vue2Owner(el) {
4393
4855
  let current = el;
@@ -4427,7 +4889,7 @@ function resolveVueComponent(el) {
4427
4889
  }
4428
4890
  function resolveVueSource(el) {
4429
4891
  const inst3 = vue3Owner(el);
4430
- const file = _nullishCoalesce(_optionalChain([inst3, 'optionalAccess', _184 => _184.type, 'optionalAccess', _185 => _185.__file]), () => ( _optionalChain([vue2Owner, 'call', _186 => _186(el), 'optionalAccess', _187 => _187.$options, 'optionalAccess', _188 => _188.__file])));
4892
+ const file = _nullishCoalesce(_optionalChain([inst3, 'optionalAccess', _195 => _195.type, 'optionalAccess', _196 => _196.__file]), () => ( _optionalChain([vue2Owner, 'call', _197 => _197(el), 'optionalAccess', _198 => _198.$options, 'optionalAccess', _199 => _199.__file])));
4431
4893
  return file ? { filePath: relativizePath(file), line: null, column: null } : NO_SOURCE;
4432
4894
  }
4433
4895
  var vueAdapter = {
@@ -4443,19 +4905,19 @@ function metaOf(el) {
4443
4905
  let current = el;
4444
4906
  while (current) {
4445
4907
  const meta = current.__svelte_meta;
4446
- if (_optionalChain([meta, 'optionalAccess', _189 => _189.loc])) return { meta, el: current };
4908
+ if (_optionalChain([meta, 'optionalAccess', _200 => _200.loc])) return { meta, el: current };
4447
4909
  current = current.parentElement;
4448
4910
  }
4449
4911
  return null;
4450
4912
  }
4451
4913
  function lineOf(meta) {
4452
- const line = _optionalChain([meta, 'access', _190 => _190.loc, 'optionalAccess', _191 => _191.line]);
4914
+ const line = _optionalChain([meta, 'access', _201 => _201.loc, 'optionalAccess', _202 => _202.line]);
4453
4915
  if (typeof line !== "number") return null;
4454
4916
  return "parent" in meta ? line : line + 1;
4455
4917
  }
4456
4918
  function resolveSvelteComponent(el) {
4457
4919
  const found = metaOf(el);
4458
- if (!_optionalChain([found, 'optionalAccess', _192 => _192.meta, 'access', _193 => _193.loc, 'optionalAccess', _194 => _194.file])) return null;
4920
+ if (!_optionalChain([found, 'optionalAccess', _203 => _203.meta, 'access', _204 => _204.loc, 'optionalAccess', _205 => _205.file])) return null;
4459
4921
  const { meta } = found;
4460
4922
  const own = baseName(meta.loc.file);
4461
4923
  const stack = [{ name: own, hostElement: found.el }];
@@ -4469,9 +4931,9 @@ function resolveSvelteComponent(el) {
4469
4931
  }
4470
4932
  function resolveSvelteSource(el) {
4471
4933
  const found = metaOf(el);
4472
- const file = _optionalChain([found, 'optionalAccess', _195 => _195.meta, 'access', _196 => _196.loc, 'optionalAccess', _197 => _197.file]);
4934
+ const file = _optionalChain([found, 'optionalAccess', _206 => _206.meta, 'access', _207 => _207.loc, 'optionalAccess', _208 => _208.file]);
4473
4935
  if (!found || !file) return NO_SOURCE;
4474
- const column = _optionalChain([found, 'access', _198 => _198.meta, 'access', _199 => _199.loc, 'optionalAccess', _200 => _200.column]);
4936
+ const column = _optionalChain([found, 'access', _209 => _209.meta, 'access', _210 => _210.loc, 'optionalAccess', _211 => _211.column]);
4475
4937
  return {
4476
4938
  filePath: relativizePath(file),
4477
4939
  line: lineOf(found.meta),
@@ -4491,10 +4953,10 @@ var domAdapter = {
4491
4953
  name: "HTML",
4492
4954
  resolveComponent: (el) => {
4493
4955
  const host2 = el.closest("[data-component]");
4494
- const name = _optionalChain([host2, 'optionalAccess', _201 => _201.getAttribute, 'call', _202 => _202("data-component")]);
4956
+ const name = _optionalChain([host2, 'optionalAccess', _212 => _212.getAttribute, 'call', _213 => _213("data-component")]);
4495
4957
  if (!host2 || !name) return null;
4496
4958
  const stack = [];
4497
- for (let h2 = host2; h2; h2 = _nullishCoalesce(_optionalChain([h2, 'access', _203 => _203.parentElement, 'optionalAccess', _204 => _204.closest, 'call', _205 => _205("[data-component]")]), () => ( null))) {
4959
+ for (let h2 = host2; h2; h2 = _nullishCoalesce(_optionalChain([h2, 'access', _214 => _214.parentElement, 'optionalAccess', _215 => _215.closest, 'call', _216 => _216("[data-component]")]), () => ( null))) {
4498
4960
  const n = h2.getAttribute("data-component");
4499
4961
  if (n) stack.push({ name: n, hostElement: h2 });
4500
4962
  if (stack.length >= 12) break;
@@ -4516,7 +4978,7 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
4516
4978
  for (const adapter of adapters) {
4517
4979
  try {
4518
4980
  const result = adapter.resolveComponent(el);
4519
- if (_optionalChain([result, 'optionalAccess', _206 => _206.name])) return { adapter, result };
4981
+ if (_optionalChain([result, 'optionalAccess', _217 => _217.name])) return { adapter, result };
4520
4982
  } catch (e30) {
4521
4983
  }
4522
4984
  }
@@ -4524,7 +4986,7 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
4524
4986
  }
4525
4987
  return {
4526
4988
  resolveComponent(el) {
4527
- return _nullishCoalesce(_optionalChain([owner, 'call', _207 => _207(el), 'optionalAccess', _208 => _208.result]), () => ( null));
4989
+ return _nullishCoalesce(_optionalChain([owner, 'call', _218 => _218(el), 'optionalAccess', _219 => _219.result]), () => ( null));
4528
4990
  },
4529
4991
  resolveSource(el) {
4530
4992
  const stamped = resolveSource3(el);
@@ -4533,15 +4995,15 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
4533
4995
  const ordered = found ? [found.adapter, ...adapters.filter((a) => a !== found.adapter)] : adapters;
4534
4996
  for (const adapter of ordered) {
4535
4997
  try {
4536
- const src = _optionalChain([adapter, 'access', _209 => _209.resolveSource, 'optionalCall', _210 => _210(el)]);
4537
- if (_optionalChain([src, 'optionalAccess', _211 => _211.filePath])) return src;
4998
+ const src = _optionalChain([adapter, 'access', _220 => _220.resolveSource, 'optionalCall', _221 => _221(el)]);
4999
+ if (_optionalChain([src, 'optionalAccess', _222 => _222.filePath])) return src;
4538
5000
  } catch (e31) {
4539
5001
  }
4540
5002
  }
4541
5003
  return null;
4542
5004
  },
4543
5005
  frameworkFor(el) {
4544
- return _nullishCoalesce(_optionalChain([owner, 'call', _212 => _212(el), 'optionalAccess', _213 => _213.adapter, 'access', _214 => _214.name]), () => ( "HTML"));
5006
+ return _nullishCoalesce(_optionalChain([owner, 'call', _223 => _223(el), 'optionalAccess', _224 => _224.adapter, 'access', _225 => _225.name]), () => ( "HTML"));
4545
5007
  },
4546
5008
  cleanClasses(classes) {
4547
5009
  return adapters.reduce((list, a) => a.cleanClasses ? a.cleanClasses(list) : list, classes);
@@ -4573,7 +5035,7 @@ function getDefaultOptions() {
4573
5035
  };
4574
5036
  }
4575
5037
  function init(options) {
4576
- if (_optionalChain([options, 'optionalAccess', _215 => _215.mode]) === "live" && !_chunk6CBIOKZVcjs.consumeFeedbackLink.call(void 0, options.projectKey)) {
5038
+ if (_optionalChain([options, 'optionalAccess', _226 => _226.mode]) === "live" && !_chunk6CBIOKZVcjs.consumeFeedbackLink.call(void 0, options.projectKey)) {
4577
5039
  return createDormantApi(options);
4578
5040
  }
4579
5041
  return createGrabInstance(options);
@@ -4599,7 +5061,7 @@ function createDormantApi(options) {
4599
5061
  real.show();
4600
5062
  return;
4601
5063
  }
4602
- _optionalChain([flusher, 'optionalAccess', _216 => _216.dispose, 'call', _217 => _217()]);
5064
+ _optionalChain([flusher, 'optionalAccess', _227 => _227.dispose, 'call', _228 => _228()]);
4603
5065
  _chunk6CBIOKZVcjs.startFeedbackSession.call(void 0, );
4604
5066
  real = createGrabInstance(options);
4605
5067
  for (const fn of queued.splice(0)) fn(real);
@@ -4721,7 +5183,10 @@ function createGrabInstance(options) {
4721
5183
  let sourceResolver = adapters.resolveSource;
4722
5184
  const cleanClasses = (list) => adapters.cleanClasses(list.filter((c) => !isNoiseClass(c)));
4723
5185
  let selectedElement = null;
5186
+ let selectedPin;
4724
5187
  let pendingShot = null;
5188
+ const commentedElements = /* @__PURE__ */ new Map();
5189
+ let editingFromMarker = false;
4725
5190
  let level = loadLevel(merged.detailLevel);
4726
5191
  let collapsed = loadCollapsed();
4727
5192
  const pendingShotDeletes = /* @__PURE__ */ new Map();
@@ -4775,12 +5240,12 @@ function createGrabInstance(options) {
4775
5240
  function toastDetail(c) {
4776
5241
  return {
4777
5242
  componentName: c.target.component,
4778
- filePath: _nullishCoalesce(_optionalChain([c, 'access', _218 => _218.target, 'access', _219 => _219.source, 'optionalAccess', _220 => _220.file]), () => ( null)),
4779
- line: _nullishCoalesce(_optionalChain([c, 'access', _221 => _221.target, 'access', _222 => _222.source, 'optionalAccess', _223 => _223.line]), () => ( null)),
4780
- column: _nullishCoalesce(_optionalChain([c, 'access', _224 => _224.target, 'access', _225 => _225.source, 'optionalAccess', _226 => _226.column]), () => ( null))
5243
+ filePath: _nullishCoalesce(_optionalChain([c, 'access', _229 => _229.target, 'access', _230 => _230.source, 'optionalAccess', _231 => _231.file]), () => ( null)),
5244
+ line: _nullishCoalesce(_optionalChain([c, 'access', _232 => _232.target, 'access', _233 => _233.source, 'optionalAccess', _234 => _234.line]), () => ( null)),
5245
+ column: _nullishCoalesce(_optionalChain([c, 'access', _235 => _235.target, 'access', _236 => _236.source, 'optionalAccess', _237 => _237.column]), () => ( null))
4781
5246
  };
4782
5247
  }
4783
- function saveComment(element, text, shot) {
5248
+ function saveComment(element, text, shot, pin) {
4784
5249
  const now = Date.now();
4785
5250
  const comment = {
4786
5251
  id: randomId(),
@@ -4797,11 +5262,13 @@ function createGrabInstance(options) {
4797
5262
  target: captureTarget(element, { componentResolver, sourceResolver, cleanClasses }),
4798
5263
  screenshot: null,
4799
5264
  framework: adapters.frameworkFor(element),
4800
- ...outbox ? { sync: "pending" } : {}
5265
+ ...outbox ? { sync: "pending" } : {},
5266
+ ...pin ? { pin } : {}
4801
5267
  };
5268
+ commentedElements.set(comment.id, element);
4802
5269
  setComments([comment, ...comments()].slice(0, MAX_COMMENTS));
4803
5270
  pluginRegistry.callHook("onComment", comment, element);
4804
- _optionalChain([outbox, 'optionalAccess', _227 => _227.send, 'call', _228 => _228(comment.id)]);
5271
+ _optionalChain([outbox, 'optionalAccess', _238 => _238.send, 'call', _239 => _239(comment.id)]);
4805
5272
  if (shot) void attachScreenshot(comment.id, shot);
4806
5273
  const count = comments().length;
4807
5274
  if (live) {
@@ -4836,18 +5303,19 @@ function createGrabInstance(options) {
4836
5303
  const updated = { ...current, screenshot: { localId: id, width: result.width, height: result.height } };
4837
5304
  setComments(comments().map((c) => c.id === id ? updated : c));
4838
5305
  pluginRegistry.callHook("onScreenshot", updated, result.blob);
4839
- _optionalChain([outbox, 'optionalAccess', _229 => _229.sendScreenshot, 'call', _230 => _230(id)]);
5306
+ _optionalChain([outbox, 'optionalAccess', _240 => _240.sendScreenshot, 'call', _241 => _241(id)]);
4840
5307
  }
4841
5308
  function removeComments(ids, message, withdraw = false) {
4842
5309
  if (ids.length === 0) return;
4843
5310
  const idSet = new Set(ids);
4844
5311
  const before = comments();
4845
5312
  const removed = before.filter((c) => idSet.has(c.id));
5313
+ for (const id of ids) commentedElements.delete(id);
4846
5314
  setComments(before.filter((c) => !idSet.has(c.id)));
4847
5315
  const withdrawn = withdraw && outbox ? removed.filter((c) => c.sync !== void 0) : [];
4848
5316
  const hadQueued = new Set(withdrawn.filter((c) => outbox.isQueued(c.id)).map((c) => c.id));
4849
5317
  for (const c of withdrawn) outbox.remove(c.id, c.author.sessionId, message ? UNDO_MS + 500 : 0);
4850
- const shotIds = removed.flatMap((c) => _optionalChain([c, 'access', _231 => _231.screenshot, 'optionalAccess', _232 => _232.localId]) ? [c.screenshot.localId] : []);
5318
+ const shotIds = removed.flatMap((c) => _optionalChain([c, 'access', _242 => _242.screenshot, 'optionalAccess', _243 => _243.localId]) ? [c.screenshot.localId] : []);
4851
5319
  const key = randomId();
4852
5320
  pendingShotDeletes.set(key, setTimeout(() => {
4853
5321
  pendingShotDeletes.delete(key);
@@ -4866,7 +5334,7 @@ function createGrabInstance(options) {
4866
5334
  const back = removed.filter((c) => !present.has(c.id)).map((c) => resend.has(c.id) ? { ...c, sync: "pending" } : c);
4867
5335
  const restored = [...back, ...comments()].sort((a, b) => b.createdAt - a.createdAt);
4868
5336
  setComments(restored);
4869
- for (const id of resend) _optionalChain([outbox, 'optionalAccess', _233 => _233.send, 'call', _234 => _234(id)]);
5337
+ for (const id of resend) _optionalChain([outbox, 'optionalAccess', _244 => _244.send, 'call', _245 => _245(id)]);
4870
5338
  showToast(`Restored ${removed.length} comment${removed.length === 1 ? "" : "s"}`);
4871
5339
  }
4872
5340
  }]
@@ -4899,12 +5367,19 @@ function createGrabInstance(options) {
4899
5367
  }
4900
5368
  function hideCommentPopover() {
4901
5369
  commentPopover.hide();
5370
+ endMarkerEdit();
4902
5371
  if (picker.isHolding()) {
4903
5372
  selectedElement = null;
5373
+ selectedPin = void 0;
4904
5374
  pendingShot = null;
4905
5375
  picker.release();
4906
5376
  }
4907
5377
  }
5378
+ function endMarkerEdit() {
5379
+ if (!editingFromMarker) return;
5380
+ editingFromMarker = false;
5381
+ overlay.hide();
5382
+ }
4908
5383
  function closeAllPopovers() {
4909
5384
  commentsPanel.hide();
4910
5385
  hideCommentPopover();
@@ -4941,8 +5416,14 @@ function createGrabInstance(options) {
4941
5416
  pluginRegistry.callHook("onElementHover", element);
4942
5417
  }
4943
5418
  },
4944
- onSelect(element) {
5419
+ onSelect(element, point) {
4945
5420
  selectedElement = element;
5421
+ const rect = element.getBoundingClientRect();
5422
+ const frac = (v, start, size2) => size2 > 0 ? Math.min(1, Math.max(0, (v - start) / size2)) : 0.5;
5423
+ selectedPin = {
5424
+ x: Math.round(frac(point.x, rect.left, rect.width) * 1e3) / 1e3,
5425
+ y: Math.round(frac(point.y, rect.top, rect.height) * 1e3) / 1e3
5426
+ };
4946
5427
  pendingShot = store.state.options.screenshots ? captureScreenshot(element) : null;
4947
5428
  pluginRegistry.callHook("onElementSelect", element);
4948
5429
  coachMark.dismiss();
@@ -4951,6 +5432,36 @@ function createGrabInstance(options) {
4951
5432
  commentPopover.show({ anchor: element, mode: "new", askIdentity: shouldAskIdentity() });
4952
5433
  }
4953
5434
  });
5435
+ const markers = createMarkers({
5436
+ getComments: comments,
5437
+ currentRoute: () => sanitizeRoute(location, store.state.options.captureQueryParams),
5438
+ findElement(comment) {
5439
+ const known = commentedElements.get(comment.id);
5440
+ if (_optionalChain([known, 'optionalAccess', _246 => _246.isConnected])) return known;
5441
+ return safeQuery(comment.target.selector);
5442
+ },
5443
+ onHover(comment, element) {
5444
+ if (picker.isHolding() || editingFromMarker || commentPopover.isVisible()) return;
5445
+ if (comment && element) overlay.show(element, comment.target.component, null, []);
5446
+ else overlay.hide();
5447
+ },
5448
+ onOpen(comment, element, marker) {
5449
+ if (picker.isHolding()) return;
5450
+ closeAllPopovers();
5451
+ doDeactivate(true);
5452
+ editingFromMarker = true;
5453
+ if (element) overlay.show(element, comment.target.component, null, []);
5454
+ commentPopover.show({
5455
+ anchor: _nullishCoalesce(element, () => ( marker)),
5456
+ initialValue: comment.comment,
5457
+ mode: "edit",
5458
+ entryId: comment.id
5459
+ });
5460
+ }
5461
+ });
5462
+ function updateMarkers() {
5463
+ markers.setVisible(store.state.toolbar.visible && !collapsed && store.state.options.enabled);
5464
+ }
4954
5465
  function doActivate() {
4955
5466
  if (!store.state.options.enabled) return;
4956
5467
  if (store.state.active) return;
@@ -5025,12 +5536,14 @@ function createGrabInstance(options) {
5025
5536
  toolbar.collapse();
5026
5537
  saveCollapsed(true);
5027
5538
  updateToastOffset();
5539
+ updateMarkers();
5028
5540
  }
5029
5541
  function expandToolbar() {
5030
5542
  collapsed = false;
5031
5543
  toolbar.expand();
5032
5544
  saveCollapsed(false);
5033
5545
  updateToastOffset();
5546
+ updateMarkers();
5034
5547
  }
5035
5548
  const commentsPanel = createCommentsPanel({
5036
5549
  onHover(comment) {
@@ -5093,7 +5606,7 @@ function createGrabInstance(options) {
5093
5606
  });
5094
5607
  const finishSheet = createFinishSheet({
5095
5608
  onDone() {
5096
- const done = comments().filter((c) => c.sync === "sent" && !_optionalChain([outbox, 'optionalAccess', _235 => _235.isQueued, 'call', _236 => _236(c.id)])).map((c) => c.id);
5609
+ const done = comments().filter((c) => c.sync === "sent" && !_optionalChain([outbox, 'optionalAccess', _247 => _247.isQueued, 'call', _248 => _248(c.id)])).map((c) => c.id);
5097
5610
  if (!comments().length) {
5098
5611
  exitFeedbackMode();
5099
5612
  return;
@@ -5107,9 +5620,9 @@ function createGrabInstance(options) {
5107
5620
  if (failed.length) {
5108
5621
  const ids = new Set(failed.map((c) => c.id));
5109
5622
  setComments(comments().map((c) => ids.has(c.id) ? { ...c, sync: "pending" } : c));
5110
- for (const id of ids) _optionalChain([outbox, 'optionalAccess', _237 => _237.send, 'call', _238 => _238(id)]);
5623
+ for (const id of ids) _optionalChain([outbox, 'optionalAccess', _249 => _249.send, 'call', _250 => _250(id)]);
5111
5624
  }
5112
- _optionalChain([outbox, 'optionalAccess', _239 => _239.flush, 'call', _240 => _240()]);
5625
+ _optionalChain([outbox, 'optionalAccess', _251 => _251.flush, 'call', _252 => _252()]);
5113
5626
  }
5114
5627
  });
5115
5628
  const commentPopover = createCommentPopover({
@@ -5118,9 +5631,11 @@ function createGrabInstance(options) {
5118
5631
  if (ctx.mode === "new") {
5119
5632
  const element = selectedElement;
5120
5633
  const shot = pendingShot;
5634
+ const pin = selectedPin;
5121
5635
  selectedElement = null;
5636
+ selectedPin = void 0;
5122
5637
  pendingShot = null;
5123
- if (element) saveComment(element, value, shot);
5638
+ if (element) saveComment(element, value, shot, pin);
5124
5639
  doDeactivate(true);
5125
5640
  return;
5126
5641
  }
@@ -5129,18 +5644,25 @@ function createGrabInstance(options) {
5129
5644
  (c) => c.id === ctx.entryId ? { ...c, comment: value, updatedAt: Date.now(), ...outbox ? { sync: "pending" } : {} } : c
5130
5645
  );
5131
5646
  setComments(updated);
5132
- _optionalChain([outbox, 'optionalAccess', _241 => _241.send, 'call', _242 => _242(ctx.entryId)]);
5647
+ _optionalChain([outbox, 'optionalAccess', _253 => _253.send, 'call', _254 => _254(ctx.entryId)]);
5133
5648
  showToast("Comment updated");
5134
- commentsPanel.show([...updated]);
5649
+ if (editingFromMarker) endMarkerEdit();
5650
+ else commentsPanel.show([...updated]);
5135
5651
  },
5136
5652
  onCancel(ctx) {
5137
5653
  if (ctx.mode === "new") {
5138
5654
  selectedElement = null;
5655
+ selectedPin = void 0;
5139
5656
  pendingShot = null;
5140
5657
  doDeactivate(true);
5141
5658
  return;
5142
5659
  }
5143
- commentsPanel.show([...comments()]);
5660
+ if (editingFromMarker) endMarkerEdit();
5661
+ else commentsPanel.show([...comments()]);
5662
+ },
5663
+ onDelete(ctx) {
5664
+ endMarkerEdit();
5665
+ if (ctx.entryId) removeComments([ctx.entryId], "Comment deleted", true);
5144
5666
  }
5145
5667
  });
5146
5668
  function handleDocumentClick(e) {
@@ -5154,7 +5676,7 @@ function createGrabInstance(options) {
5154
5676
  document.addEventListener("click", handleDocumentClick);
5155
5677
  function handlePageHide() {
5156
5678
  flushPendingWrite();
5157
- _optionalChain([outbox, 'optionalAccess', _243 => _243.flushOnExit, 'call', _244 => _244()]);
5679
+ _optionalChain([outbox, 'optionalAccess', _255 => _255.flushOnExit, 'call', _256 => _256()]);
5158
5680
  }
5159
5681
  function handleVisibilityChange() {
5160
5682
  if (document.visibilityState === "hidden") flushPendingWrite();
@@ -5296,6 +5818,7 @@ function createGrabInstance(options) {
5296
5818
  overlay.dispose();
5297
5819
  crosshair.dispose();
5298
5820
  freezeOverlay.dispose();
5821
+ markers.dispose();
5299
5822
  disposeToast();
5300
5823
  disposeFeedbackStyles();
5301
5824
  pluginRegistry.dispose();
@@ -5306,7 +5829,7 @@ function createGrabInstance(options) {
5306
5829
  copySheet.dispose();
5307
5830
  finishSheet.dispose();
5308
5831
  coachMark.dispose();
5309
- _optionalChain([outbox, 'optionalAccess', _245 => _245.dispose, 'call', _246 => _246()]);
5832
+ _optionalChain([outbox, 'optionalAccess', _257 => _257.dispose, 'call', _258 => _258()]);
5310
5833
  themeManager.dispose();
5311
5834
  disposeStyleBaseline();
5312
5835
  disposeScreenshotSandbox();
@@ -5332,8 +5855,11 @@ function createGrabInstance(options) {
5332
5855
  doDeactivate(true);
5333
5856
  }
5334
5857
  }
5858
+ if (key === "options") updateMarkers();
5335
5859
  if (key === "toolbar") {
5336
5860
  updateToastOffset();
5861
+ updateMarkers();
5862
+ markers.refresh();
5337
5863
  if (state.options.persistHistory) {
5338
5864
  if (state.toolbar.comments.length > 0) {
5339
5865
  saveHistory(state.toolbar.comments);
@@ -5355,6 +5881,7 @@ function createGrabInstance(options) {
5355
5881
  if (merged.webhookUrl) {
5356
5882
  api.registerPlugin(createWebhookPlugin(merged.webhookUrl));
5357
5883
  }
5884
+ updateMarkers();
5358
5885
  return api;
5359
5886
  }
5360
5887