@ai-matrx/design-system 0.21.6 → 0.21.8

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.
@@ -1429,6 +1429,10 @@ function ContentTransferMenuSession({ references = [], referenceActions = [], so
1429
1429
  const [notice, setNotice] = React9.useState(null);
1430
1430
  const [receiptTarget, setReceiptTarget] = React9.useState();
1431
1431
  const [paletteOpen, setPaletteOpen] = React9.useState(false);
1432
+ const [paletteTarget, setPaletteTarget] = React9.useState(null);
1433
+ const externalPaletteClose = React9.useRef(null);
1434
+ const externalPaletteRestoreFocus = React9.useRef(null);
1435
+ const feedbackDocument = React9.useRef(null);
1432
1436
  const [mode, setMode] = React9.useState("copy");
1433
1437
  const scopes = React9.useMemo(() => table?.availableScopes ?? ["target"], [table]);
1434
1438
  const [requestedScope, setRequestedScope] = React9.useState(table?.initialScope ?? "target");
@@ -1525,6 +1529,40 @@ function ContentTransferMenuSession({ references = [], referenceActions = [], so
1525
1529
  fence.finish(controller);
1526
1530
  }
1527
1531
  }, [captureOne, fence, initialScope, primary]);
1532
+ const closePalette = React9.useCallback(() => {
1533
+ const onClose = externalPaletteClose.current;
1534
+ const restoreFocus = externalPaletteRestoreFocus.current;
1535
+ externalPaletteClose.current = null;
1536
+ externalPaletteRestoreFocus.current = null;
1537
+ onClose?.();
1538
+ restoreFocus?.();
1539
+ setPaletteTarget(null);
1540
+ setPaletteOpen(false);
1541
+ }, []);
1542
+ const mountPalette = React9.useCallback((target, onClose, restoreFocus) => {
1543
+ if (!target) {
1544
+ externalPaletteClose.current = null;
1545
+ externalPaletteRestoreFocus.current = null;
1546
+ setPaletteTarget(null);
1547
+ setPaletteOpen(false);
1548
+ return;
1549
+ }
1550
+ if (!enabled) throw new Error("Alchemy is not enabled for this record.");
1551
+ if (disabled) throw new Error("Alchemy is disabled for this record.");
1552
+ externalPaletteClose.current = onClose ?? null;
1553
+ externalPaletteRestoreFocus.current = restoreFocus ?? null;
1554
+ feedbackDocument.current = target.ownerDocument;
1555
+ restoreFocusRef.current = restoreFocus ?? (() => target.focus());
1556
+ setPaletteTarget(target);
1557
+ setPaletteOpen(true);
1558
+ setMode("copy");
1559
+ void preflight();
1560
+ }, [closePalette, disabled, enabled, preflight]);
1561
+ React9.useEffect(() => {
1562
+ if (!paletteTarget || !paletteOpen) return;
1563
+ const firstControl = paletteTarget.querySelector("button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [href]");
1564
+ firstControl?.focus();
1565
+ }, [paletteOpen, paletteTarget]);
1528
1566
  const transfer = React9.useCallback(async (format, download, alternate) => {
1529
1567
  const { controller, id } = fence.begin();
1530
1568
  try {
@@ -1665,6 +1703,7 @@ function ContentTransferMenuSession({ references = [], referenceActions = [], so
1665
1703
  );
1666
1704
  React9.useImperativeHandle(controllerRef, () => ({
1667
1705
  focusTrigger: () => triggerRef.current?.focus(),
1706
+ mountPalette,
1668
1707
  preparePrimary: async (options) => {
1669
1708
  if (!enabled) throw new Error("Alchemy is not enabled for this record.");
1670
1709
  if (disabled) throw new Error("Alchemy is disabled for this record.");
@@ -1679,7 +1718,7 @@ function ContentTransferMenuSession({ references = [], referenceActions = [], so
1679
1718
  externalWorkspaceKeys.current.add(requestedKey);
1680
1719
  await openWorkspace(requestedKey, { source: requestedSource, label: requestedLabel });
1681
1720
  }
1682
- }), [disabled, enabled, hide, openWorkspace, primary, primaryWorkspaceKey, sourceLabel]);
1721
+ }), [disabled, enabled, hide, mountPalette, openWorkspace, primary, primaryWorkspaceKey, sourceLabel]);
1683
1722
  const runAction = React9.useCallback(async (action) => {
1684
1723
  const { controller, id } = fence.begin();
1685
1724
  try {
@@ -1745,7 +1784,6 @@ function ContentTransferMenuSession({ references = [], referenceActions = [], so
1745
1784
  return sealTransferArtifact2({ snapshotId: draft.snapshotId, draftRevision: draft.revision, format: "ai-context", plainText: buildAgentPayload({ kind: "matrx_content", location: sourceLabel, description: "Captured content for an assistant", data: JSON.parse(json.plainText), attributes: { source: draft.sourceId } }), omissions: [...json.omissions] });
1746
1785
  }
1747
1786
  };
1748
- const closePalette = () => setPaletteOpen(false);
1749
1787
  const tile = (id, label2, onClick, options = {}) => {
1750
1788
  const presentation = options.action;
1751
1789
  const Icon2 = presentation?.icon;
@@ -1761,122 +1799,125 @@ function ContentTransferMenuSession({ references = [], referenceActions = [], so
1761
1799
  ] })
1762
1800
  ] }, id);
1763
1801
  };
1802
+ const palette = /* @__PURE__ */ jsxs7(Fragment, { children: [
1803
+ menuStatus === "loading" ? /* @__PURE__ */ jsx13("p", { className: "matrx-alchemy-palette-status", children: "Inspecting content\u2026" }) : menuStatus !== "idle" ? /* @__PURE__ */ jsx13("p", { className: "matrx-alchemy-error", children: menuStatus }) : null,
1804
+ table && scopes.length > 1 ? /* @__PURE__ */ jsxs7("label", { className: "matrx-alchemy-scope", children: [
1805
+ "Content scope",
1806
+ /* @__PURE__ */ jsx13("select", { "aria-label": "Content scope", value: initialScope, onChange: (event) => {
1807
+ const next = scopes.find((scope) => scope === event.target.value);
1808
+ if (next) {
1809
+ setRequestedScope(next);
1810
+ void preflight(next);
1811
+ }
1812
+ }, children: scopes.map((scope) => /* @__PURE__ */ jsx13("option", { value: scope, children: table.scopeLabels?.[scope] ?? SCOPE_LABEL[scope] }, scope)) })
1813
+ ] }) : null,
1814
+ copyAvailable || downloadAvailable ? /* @__PURE__ */ jsxs7("section", { className: "matrx-alchemy-output", children: [
1815
+ /* @__PURE__ */ jsx13("h3", { children: resolvedMode === "copy" ? "Copy as" : "Download as" }),
1816
+ copyAvailable && downloadAvailable ? /* @__PURE__ */ jsxs7("div", { className: "matrx-alchemy-mode", "aria-label": "Output action", children: [
1817
+ /* @__PURE__ */ jsx13("button", { type: "button", "aria-label": "Copy mode", "aria-pressed": resolvedMode === "copy", onClick: () => setMode("copy"), children: "Copy" }),
1818
+ /* @__PURE__ */ jsx13("button", { type: "button", "aria-label": "Download mode", "aria-pressed": resolvedMode === "download", onClick: () => setMode("download"), children: "Download" })
1819
+ ] }) : null,
1820
+ resolvedMode === "copy" && copyAvailable ? /* @__PURE__ */ jsxs7(Fragment, { children: [
1821
+ /* @__PURE__ */ jsxs7("div", { className: "matrx-alchemy-palette-grid", children: [
1822
+ visibleCopies.map((format) => tile(format, { plain: "Text", markdown: "Markdown", html: "Formatted", json: "JSON", "compact-json": "Compact", csv: "CSV", tsv: "Sheets" }[format], () => void transfer(format, false), { ariaLabel: `Copy ${LABEL[format]}` })),
1823
+ visibleAdapters.map((adapter) => tile(adapter.id, adapter.label, () => void transfer(adapter, false), { custom: true }))
1824
+ ] }),
1825
+ quickVariants("copy").length ? /* @__PURE__ */ jsx13(PaletteRows, { title: "Quick copy", items: quickVariants("copy"), onRun: (variant) => {
1826
+ closePalette();
1827
+ void transfer("markdown", false, variant);
1828
+ } }) : null
1829
+ ] }) : null,
1830
+ resolvedMode === "download" && downloadAvailable ? /* @__PURE__ */ jsx13(Fragment, { children: /* @__PURE__ */ jsxs7("div", { className: "matrx-alchemy-palette-grid", children: [
1831
+ visibleDownloads.map((format) => tile(format, { plain: "Text", markdown: "Markdown", html: "Formatted", json: "JSON", "compact-json": "Compact", csv: "CSV", tsv: "Sheets", xlsx: "Excel" }[format], () => void transfer(format, true), { ariaLabel: `Download ${LABEL[format]}` })),
1832
+ visibleAdapters.map((adapter) => tile(adapter.id, adapter.label, () => void transfer(adapter, true), { custom: true })),
1833
+ downloadActions.map((action) => tile(action.id, action.label, () => void runAction(action), { custom: true, action, file: true }))
1834
+ ] }) }) : null
1835
+ ] }) : null,
1836
+ prepareAvailable ? /* @__PURE__ */ jsxs7(Fragment, { children: [
1837
+ /* @__PURE__ */ jsx13(PaletteRows, { title: "Copy for AI", ai: true, glyphKind: "ai-copy", fallbackHint: "Copies immediately", extra: sourceFormats ? /* @__PURE__ */ jsxs7("button", { type: "button", className: "matrx-alchemy-palette-row", onClick: () => {
1838
+ closePalette();
1839
+ void transfer(nativeAiFormat, false);
1840
+ }, children: [
1841
+ /* @__PURE__ */ jsx13(PaletteGlyph, { kind: "ai-copy" }),
1842
+ /* @__PURE__ */ jsxs7("span", { children: [
1843
+ "Copy with AI context",
1844
+ /* @__PURE__ */ jsx13("small", { className: "matrx-alchemy-menu-hint", children: "Include source context" })
1845
+ ] })
1846
+ ] }) : null, items: quickVariants("ai"), onRun: (variant) => {
1847
+ closePalette();
1848
+ void transfer("markdown", false, variant);
1849
+ } }),
1850
+ /* @__PURE__ */ jsx13(PaletteRows, { title: "Edit and prepare", items: [], extra: /* @__PURE__ */ jsxs7("button", { type: "button", className: "matrx-alchemy-palette-row", "aria-label": "Prepare for AI", onClick: () => {
1851
+ closePalette();
1852
+ void openWorkspace();
1853
+ }, children: [
1854
+ /* @__PURE__ */ jsx13(PaletteGlyph, { kind: "sliders" }),
1855
+ /* @__PURE__ */ jsxs7("span", { children: [
1856
+ "Prepare for AI",
1857
+ /* @__PURE__ */ jsx13("small", { className: "matrx-alchemy-menu-hint", children: "Trim, edit or summarize" })
1858
+ ] })
1859
+ ] }) })
1860
+ ] }) : null,
1861
+ prepareAvailable && (nearestWorkspaceKey || variants.length) ? /* @__PURE__ */ jsx13(PaletteRows, { title: "Other sources", items: [], extra: /* @__PURE__ */ jsxs7(Fragment, { children: [
1862
+ nearestWorkspaceKey && nearestSurface ? /* @__PURE__ */ jsxs7("button", { type: "button", className: "matrx-alchemy-palette-row", onClick: () => {
1863
+ closePalette();
1864
+ void openWorkspace(nearestWorkspaceKey, { source: nearestSurface, label: nearestSurface.surfaceName });
1865
+ }, children: [
1866
+ /* @__PURE__ */ jsx13(PaletteGlyph, { kind: "surface" }),
1867
+ /* @__PURE__ */ jsx13("span", { children: "Prepare this page" })
1868
+ ] }) : null,
1869
+ variants.map((variant) => /* @__PURE__ */ jsx13("button", { type: "button", className: "matrx-alchemy-palette-row", "aria-label": variant.ariaLabel, onClick: () => {
1870
+ closePalette();
1871
+ void openWorkspace(variantWorkspaceKeys.get(variant.id), variant);
1872
+ }, children: /* @__PURE__ */ jsx13(MenuPresentation, { ...variant, label: `Prepare ${variant.label}` }) }, variant.id))
1873
+ ] }) }) : null,
1874
+ references.length || referenceActions.length ? /* @__PURE__ */ jsxs7("section", { className: "matrx-alchemy-palette-section", children: [
1875
+ /* @__PURE__ */ jsx13("h3", { children: "References" }),
1876
+ referenceActions.map((action) => /* @__PURE__ */ jsxs7("button", { type: "button", className: "matrx-alchemy-palette-row", onClick: () => void openReference(action), children: [
1877
+ /* @__PURE__ */ jsx13(PaletteGlyph, { kind: "link" }),
1878
+ /* @__PURE__ */ jsx13("span", { children: action.label }),
1879
+ /* @__PURE__ */ jsx13("svg", { className: "matrx-alchemy-disclosure", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx13("path", { d: "m6 4 4 4-4 4" }) })
1880
+ ] }, action.id)),
1881
+ references.map((reference) => /* @__PURE__ */ jsxs7("button", { type: "button", className: "matrx-alchemy-palette-row", title: "Copies a reference to saved data", onClick: () => void copyReference(reference), children: [
1882
+ /* @__PURE__ */ jsx13(PaletteGlyph, { kind: "link" }),
1883
+ /* @__PURE__ */ jsx13("span", { children: reference.label })
1884
+ ] }, reference.id))
1885
+ ] }) : null,
1886
+ ["save", "chat", "email", "other"].map((group) => {
1887
+ const entries = ordinaryActions.filter((action) => (action.group ?? "other") === group);
1888
+ return entries.length ? /* @__PURE__ */ jsxs7("details", { className: "matrx-alchemy-palette-destinations", children: [
1889
+ /* @__PURE__ */ jsxs7("summary", { children: [
1890
+ group === "save" ? "Save to Matrx" : group === "chat" ? "Continue with AI" : group === "email" ? "Email to me" : "Actions",
1891
+ /* @__PURE__ */ jsxs7("span", { className: "matrx-alchemy-disclosure-meta", children: [
1892
+ /* @__PURE__ */ jsx13("span", { children: entries.length }),
1893
+ /* @__PURE__ */ jsx13("svg", { className: "matrx-alchemy-disclosure", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx13("path", { d: "m6 4 4 4-4 4" }) })
1894
+ ] })
1895
+ ] }),
1896
+ /* @__PURE__ */ jsx13("div", { children: entries.map((action) => /* @__PURE__ */ jsx13("button", { type: "button", className: "matrx-alchemy-palette-row", "aria-label": action.ariaLabel, onClick: () => {
1897
+ closePalette();
1898
+ void runAction(action);
1899
+ }, children: /* @__PURE__ */ jsx13(DestinationPresentation, { action }) }, action.id)) })
1900
+ ] }, group) : null;
1901
+ })
1902
+ ] });
1903
+ const feedbackOwner = paletteTarget ?? triggerRef.current ?? feedbackDocument.current?.body ?? null;
1764
1904
  return /* @__PURE__ */ jsxs7("span", { className: cn("matrx-alchemy", className), onClick: stopPropagation ? (event) => event.stopPropagation() : void 0, children: [
1765
- !triggerHidden ? /* @__PURE__ */ jsxs7(Popover, { open: paletteOpen, onOpenChange: (open) => {
1766
- setPaletteOpen(open);
1905
+ !triggerHidden && !paletteTarget ? /* @__PURE__ */ jsxs7(Popover, { open: paletteOpen, onOpenChange: (open) => {
1767
1906
  if (open) {
1907
+ setPaletteOpen(true);
1768
1908
  setMode("copy");
1769
1909
  void preflight();
1770
- }
1910
+ } else closePalette();
1771
1911
  }, children: [
1772
1912
  /* @__PURE__ */ jsx13(PopoverTrigger, { asChild: true, children: triggerVariant === "outline" ? /* @__PURE__ */ jsx13(Button, { ref: triggerRef, variant: "outline", size: "icon-sm", "aria-label": `Copy, transform or export ${sourceLabel}`, "data-alchemy-trigger": "outline", disabled, children: /* @__PURE__ */ jsx13(AlchemyGlyph, { icon }) }) : triggerVariant === "glass" ? /* @__PURE__ */ jsx13(TapTargetButton, { ref: triggerRef, icon: /* @__PURE__ */ jsx13(AlchemyGlyph, { icon }), tooltip: false, ariaLabel: `Copy, transform or export ${sourceLabel}`, "data-alchemy-trigger": "glass", "data-alchemy-size": triggerSize, disabled }) : /* @__PURE__ */ jsx13(TapTargetButtonTransparent, { ref: triggerRef, icon: /* @__PURE__ */ jsx13(AlchemyGlyph, { icon }), tooltip: false, ariaLabel: `Copy, transform or export ${sourceLabel}`, "data-alchemy-trigger": "transparent", "data-alchemy-size": triggerSize, disabled }) }),
1773
- /* @__PURE__ */ jsxs7(PopoverContent, { align: "end", className: "matrx-alchemy-menu matrx-alchemy-palette", "aria-label": "Alchemy output options", onCloseAutoFocus: () => triggerRef.current?.focus(), children: [
1774
- menuStatus === "loading" ? /* @__PURE__ */ jsx13("p", { className: "matrx-alchemy-palette-status", children: "Inspecting content\u2026" }) : menuStatus !== "idle" ? /* @__PURE__ */ jsx13("p", { className: "matrx-alchemy-error", children: menuStatus }) : null,
1775
- table && scopes.length > 1 ? /* @__PURE__ */ jsxs7("label", { className: "matrx-alchemy-scope", children: [
1776
- "Content scope",
1777
- /* @__PURE__ */ jsx13("select", { "aria-label": "Content scope", value: initialScope, onChange: (event) => {
1778
- const next = scopes.find((scope) => scope === event.target.value);
1779
- if (next) {
1780
- setRequestedScope(next);
1781
- void preflight(next);
1782
- }
1783
- }, children: scopes.map((scope) => /* @__PURE__ */ jsx13("option", { value: scope, children: table.scopeLabels?.[scope] ?? SCOPE_LABEL[scope] }, scope)) })
1784
- ] }) : null,
1785
- copyAvailable || downloadAvailable ? /* @__PURE__ */ jsxs7("section", { className: "matrx-alchemy-output", children: [
1786
- /* @__PURE__ */ jsx13("h3", { children: resolvedMode === "copy" ? "Copy as" : "Download as" }),
1787
- copyAvailable && downloadAvailable ? /* @__PURE__ */ jsxs7("div", { className: "matrx-alchemy-mode", "aria-label": "Output action", children: [
1788
- /* @__PURE__ */ jsx13("button", { type: "button", "aria-label": "Copy mode", "aria-pressed": resolvedMode === "copy", onClick: () => setMode("copy"), children: "Copy" }),
1789
- /* @__PURE__ */ jsx13("button", { type: "button", "aria-label": "Download mode", "aria-pressed": resolvedMode === "download", onClick: () => setMode("download"), children: "Download" })
1790
- ] }) : null,
1791
- resolvedMode === "copy" && copyAvailable ? /* @__PURE__ */ jsxs7(Fragment, { children: [
1792
- /* @__PURE__ */ jsxs7("div", { className: "matrx-alchemy-palette-grid", children: [
1793
- visibleCopies.map((format) => tile(format, { plain: "Text", markdown: "Markdown", html: "Formatted", json: "JSON", "compact-json": "Compact", csv: "CSV", tsv: "Sheets" }[format], () => void transfer(format, false), { ariaLabel: `Copy ${LABEL[format]}` })),
1794
- visibleAdapters.map((adapter) => tile(adapter.id, adapter.label, () => void transfer(adapter, false), { custom: true }))
1795
- ] }),
1796
- quickVariants("copy").length ? /* @__PURE__ */ jsx13(PaletteRows, { title: "Quick copy", items: quickVariants("copy"), onRun: (variant) => {
1797
- closePalette();
1798
- void transfer("markdown", false, variant);
1799
- } }) : null
1800
- ] }) : null,
1801
- resolvedMode === "download" && downloadAvailable ? /* @__PURE__ */ jsx13(Fragment, { children: /* @__PURE__ */ jsxs7("div", { className: "matrx-alchemy-palette-grid", children: [
1802
- visibleDownloads.map((format) => tile(format, { plain: "Text", markdown: "Markdown", html: "Formatted", json: "JSON", "compact-json": "Compact", csv: "CSV", tsv: "Sheets", xlsx: "Excel" }[format], () => void transfer(format, true), { ariaLabel: `Download ${LABEL[format]}` })),
1803
- visibleAdapters.map((adapter) => tile(adapter.id, adapter.label, () => void transfer(adapter, true), { custom: true })),
1804
- downloadActions.map((action) => tile(action.id, action.label, () => void runAction(action), { custom: true, action, file: true }))
1805
- ] }) }) : null
1806
- ] }) : null,
1807
- prepareAvailable ? /* @__PURE__ */ jsxs7(Fragment, { children: [
1808
- /* @__PURE__ */ jsx13(PaletteRows, { title: "Copy for AI", ai: true, glyphKind: "ai-copy", fallbackHint: "Copies immediately", extra: sourceFormats ? /* @__PURE__ */ jsxs7("button", { type: "button", className: "matrx-alchemy-palette-row", onClick: () => {
1809
- closePalette();
1810
- void transfer(nativeAiFormat, false);
1811
- }, children: [
1812
- /* @__PURE__ */ jsx13(PaletteGlyph, { kind: "ai-copy" }),
1813
- /* @__PURE__ */ jsxs7("span", { children: [
1814
- "Copy with AI context",
1815
- /* @__PURE__ */ jsx13("small", { className: "matrx-alchemy-menu-hint", children: "Include source context" })
1816
- ] })
1817
- ] }) : null, items: quickVariants("ai"), onRun: (variant) => {
1818
- closePalette();
1819
- void transfer("markdown", false, variant);
1820
- } }),
1821
- /* @__PURE__ */ jsx13(PaletteRows, { title: "Edit and prepare", items: [], extra: /* @__PURE__ */ jsxs7("button", { type: "button", className: "matrx-alchemy-palette-row", "aria-label": "Prepare for AI", onClick: () => {
1822
- closePalette();
1823
- void openWorkspace();
1824
- }, children: [
1825
- /* @__PURE__ */ jsx13(PaletteGlyph, { kind: "sliders" }),
1826
- /* @__PURE__ */ jsxs7("span", { children: [
1827
- "Prepare for AI",
1828
- /* @__PURE__ */ jsx13("small", { className: "matrx-alchemy-menu-hint", children: "Trim, edit or summarize" })
1829
- ] })
1830
- ] }) })
1831
- ] }) : null,
1832
- prepareAvailable && (nearestWorkspaceKey || variants.length) ? /* @__PURE__ */ jsx13(PaletteRows, { title: "Other sources", items: [], extra: /* @__PURE__ */ jsxs7(Fragment, { children: [
1833
- nearestWorkspaceKey && nearestSurface ? /* @__PURE__ */ jsxs7("button", { type: "button", className: "matrx-alchemy-palette-row", onClick: () => {
1834
- closePalette();
1835
- void openWorkspace(nearestWorkspaceKey, { source: nearestSurface, label: nearestSurface.surfaceName });
1836
- }, children: [
1837
- /* @__PURE__ */ jsx13(PaletteGlyph, { kind: "surface" }),
1838
- /* @__PURE__ */ jsx13("span", { children: "Prepare this page" })
1839
- ] }) : null,
1840
- variants.map((variant) => /* @__PURE__ */ jsx13("button", { type: "button", className: "matrx-alchemy-palette-row", "aria-label": variant.ariaLabel, onClick: () => {
1841
- closePalette();
1842
- void openWorkspace(variantWorkspaceKeys.get(variant.id), variant);
1843
- }, children: /* @__PURE__ */ jsx13(MenuPresentation, { ...variant, label: `Prepare ${variant.label}` }) }, variant.id))
1844
- ] }) }) : null,
1845
- references.length || referenceActions.length ? /* @__PURE__ */ jsxs7("section", { className: "matrx-alchemy-palette-section", children: [
1846
- /* @__PURE__ */ jsx13("h3", { children: "References" }),
1847
- referenceActions.map((action) => /* @__PURE__ */ jsxs7("button", { type: "button", className: "matrx-alchemy-palette-row", onClick: () => void openReference(action), children: [
1848
- /* @__PURE__ */ jsx13(PaletteGlyph, { kind: "link" }),
1849
- /* @__PURE__ */ jsx13("span", { children: action.label }),
1850
- /* @__PURE__ */ jsx13("svg", { className: "matrx-alchemy-disclosure", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx13("path", { d: "m6 4 4 4-4 4" }) })
1851
- ] }, action.id)),
1852
- references.map((reference) => /* @__PURE__ */ jsxs7("button", { type: "button", className: "matrx-alchemy-palette-row", title: "Copies a reference to saved data", onClick: () => void copyReference(reference), children: [
1853
- /* @__PURE__ */ jsx13(PaletteGlyph, { kind: "link" }),
1854
- /* @__PURE__ */ jsx13("span", { children: reference.label })
1855
- ] }, reference.id))
1856
- ] }) : null,
1857
- ["save", "chat", "email", "other"].map((group) => {
1858
- const entries = ordinaryActions.filter((action) => (action.group ?? "other") === group);
1859
- return entries.length ? /* @__PURE__ */ jsxs7("details", { className: "matrx-alchemy-palette-destinations", children: [
1860
- /* @__PURE__ */ jsxs7("summary", { children: [
1861
- group === "save" ? "Save to Matrx" : group === "chat" ? "Continue with AI" : group === "email" ? "Email to me" : "Actions",
1862
- /* @__PURE__ */ jsxs7("span", { className: "matrx-alchemy-disclosure-meta", children: [
1863
- /* @__PURE__ */ jsx13("span", { children: entries.length }),
1864
- /* @__PURE__ */ jsx13("svg", { className: "matrx-alchemy-disclosure", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx13("path", { d: "m6 4 4 4-4 4" }) })
1865
- ] })
1866
- ] }),
1867
- /* @__PURE__ */ jsx13("div", { children: entries.map((action) => /* @__PURE__ */ jsx13("button", { type: "button", className: "matrx-alchemy-palette-row", "aria-label": action.ariaLabel, onClick: () => {
1868
- closePalette();
1869
- void runAction(action);
1870
- }, children: /* @__PURE__ */ jsx13(DestinationPresentation, { action }) }, action.id)) })
1871
- ] }, group) : null;
1872
- })
1873
- ] })
1913
+ /* @__PURE__ */ jsx13(PopoverContent, { align: "end", className: "matrx-alchemy-menu matrx-alchemy-palette", "aria-label": "Alchemy output options", onCloseAutoFocus: () => triggerRef.current?.focus(), children: palette })
1874
1914
  ] }) : null,
1875
- notice && triggerRef.current ? createPortal(/* @__PURE__ */ jsxs7("div", { className: "matrx-alchemy-feedback", children: [
1915
+ paletteTarget && paletteOpen ? createPortal(/* @__PURE__ */ jsx13("div", { className: "matrx-alchemy-menu matrx-alchemy-palette", role: "dialog", "aria-label": "Alchemy output options", children: palette }), paletteTarget) : null,
1916
+ notice && feedbackOwner ? createPortal(/* @__PURE__ */ jsxs7("div", { className: "matrx-alchemy-feedback", children: [
1876
1917
  /* @__PURE__ */ jsx13("span", { role: "status", children: notice }),
1877
1918
  /* @__PURE__ */ jsx13(ReceiptLink, { target: receiptTarget }),
1878
1919
  /* @__PURE__ */ jsx13("button", { type: "button", "aria-label": "Dismiss Alchemy feedback", onClick: () => setNotice(null), children: "\xD7" })
1879
- ] }), triggerRef.current.ownerDocument.body) : null,
1920
+ ] }), feedbackOwner.ownerDocument.body) : null,
1880
1921
  Object.values(workspaces).map((saved) => /* @__PURE__ */ jsx13(PreparationWorkspace, { restoreFocus: () => restoreFocusRef.current?.() ?? triggerRef.current?.focus(), open: workspaceOpen && workspaceKey === saved.key, state: saved, scopes, scopeLabels: table?.scopeLabels, onClose: () => setWorkspaceOpen(false), onChange: (next) => setWorkspaces((current) => ({ ...current, [saved.key]: next })), transport, adapters, actions: preparedActions, captureScope: workspaceCaptures.current.get(saved.key) ?? capturePrimary, ...ai ? { ai } : {}, onOutcome: report }, saved.key)),
1881
1922
  emailReview
1882
1923
  ] });