@flamingo-stack/openframe-frontend-core 0.0.646 → 0.0.647
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.
- package/dist/{chunk-XJH5M2B7.js → chunk-5DCRDV7Y.js} +6 -6
- package/dist/{chunk-C6QUB6IS.cjs → chunk-5XBO6URE.cjs} +22 -22
- package/dist/{chunk-C6QUB6IS.cjs.map → chunk-5XBO6URE.cjs.map} +1 -1
- package/dist/{chunk-7UWJMWDH.cjs → chunk-5YW3GAUR.cjs} +660 -494
- package/dist/chunk-5YW3GAUR.cjs.map +1 -0
- package/dist/{chunk-ZDIDA4QG.js → chunk-6Z4GSQPB.js} +2 -2
- package/dist/{chunk-JFBUXYDK.cjs → chunk-ABVOAYYS.cjs} +15 -15
- package/dist/{chunk-JFBUXYDK.cjs.map → chunk-ABVOAYYS.cjs.map} +1 -1
- package/dist/{chunk-NWYSHZG7.cjs → chunk-AKM4AIZY.cjs} +22 -22
- package/dist/{chunk-NWYSHZG7.cjs.map → chunk-AKM4AIZY.cjs.map} +1 -1
- package/dist/{chunk-N2E26OD6.cjs → chunk-ASPNYVGE.cjs} +45 -45
- package/dist/{chunk-N2E26OD6.cjs.map → chunk-ASPNYVGE.cjs.map} +1 -1
- package/dist/{chunk-TZO743LD.cjs → chunk-DBSU5RAE.cjs} +3 -3
- package/dist/{chunk-TZO743LD.cjs.map → chunk-DBSU5RAE.cjs.map} +1 -1
- package/dist/{chunk-PD47DDHS.js → chunk-DIGCERY4.js} +3 -3
- package/dist/{chunk-NKMXFBV5.js → chunk-DLJHXLFG.js} +4 -4
- package/dist/{chunk-NZ66W56D.cjs → chunk-EG3PA7L2.cjs} +10 -10
- package/dist/{chunk-NZ66W56D.cjs.map → chunk-EG3PA7L2.cjs.map} +1 -1
- package/dist/{chunk-5C7GMRJU.js → chunk-ERLGZPCY.js} +5 -5
- package/dist/{chunk-2V7SCIOG.cjs → chunk-EZ6HGRLP.cjs} +33 -33
- package/dist/{chunk-2V7SCIOG.cjs.map → chunk-EZ6HGRLP.cjs.map} +1 -1
- package/dist/{chunk-X2VTQ3TL.cjs → chunk-F4I46MKF.cjs} +10 -10
- package/dist/{chunk-X2VTQ3TL.cjs.map → chunk-F4I46MKF.cjs.map} +1 -1
- package/dist/{chunk-WJ7PDBPK.cjs → chunk-IBTOED4M.cjs} +4 -4
- package/dist/{chunk-WJ7PDBPK.cjs.map → chunk-IBTOED4M.cjs.map} +1 -1
- package/dist/{chunk-XATBOM3X.js → chunk-IKMETQWQ.js} +5 -5
- package/dist/{chunk-QS55P2TA.js → chunk-L6ES7O6B.js} +6 -6
- package/dist/chunk-L6ES7O6B.js.map +1 -0
- package/dist/{chunk-H4FQRA5O.cjs → chunk-MKGAIWQ5.cjs} +3 -3
- package/dist/{chunk-H4FQRA5O.cjs.map → chunk-MKGAIWQ5.cjs.map} +1 -1
- package/dist/{chunk-DULSS7R6.js → chunk-N6ZYJXVJ.js} +709 -543
- package/dist/chunk-N6ZYJXVJ.js.map +1 -0
- package/dist/{chunk-ZW2BEEX2.cjs → chunk-Q2XH3HW6.cjs} +25 -25
- package/dist/{chunk-ZW2BEEX2.cjs.map → chunk-Q2XH3HW6.cjs.map} +1 -1
- package/dist/{chunk-XPPGI7SD.js → chunk-QPAQEPA3.js} +2 -2
- package/dist/{chunk-ZGWXD2S3.js → chunk-RIOWS34T.js} +3 -3
- package/dist/{chunk-AYAZU3BO.cjs → chunk-RSRYEVGZ.cjs} +5 -5
- package/dist/{chunk-AYAZU3BO.cjs.map → chunk-RSRYEVGZ.cjs.map} +1 -1
- package/dist/{chunk-UR7BC74V.js → chunk-RUEVZAPN.js} +3 -3
- package/dist/{chunk-5MZZFTME.js → chunk-RXIFYEL7.js} +5 -5
- package/dist/{chunk-LDJ4TIDC.cjs → chunk-SS2RN4TU.cjs} +9 -9
- package/dist/{chunk-LDJ4TIDC.cjs.map → chunk-SS2RN4TU.cjs.map} +1 -1
- package/dist/{chunk-GBZ3IR3S.js → chunk-T7NBMDDE.js} +2 -2
- package/dist/{chunk-5JVN3EVT.cjs → chunk-TO4UY3P5.cjs} +71 -71
- package/dist/{chunk-5JVN3EVT.cjs.map → chunk-TO4UY3P5.cjs.map} +1 -1
- package/dist/{chunk-4GOJFHJY.js → chunk-V33TSVUR.js} +2 -2
- package/dist/{chunk-LLT5XMP2.js → chunk-VXG43NJD.js} +3 -3
- package/dist/{chunk-RRSR2XHJ.cjs → chunk-YCSYKAT2.cjs} +167 -167
- package/dist/chunk-YCSYKAT2.cjs.map +1 -0
- package/dist/{chunk-ETEM2ZD4.js → chunk-ZNSBWM2D.js} +3 -3
- package/dist/components/case-studies/index.cjs +14 -14
- package/dist/components/case-studies/index.js +3 -3
- package/dist/components/chat/index.cjs +2 -2
- package/dist/components/chat/index.js +1 -1
- package/dist/components/contact/index.cjs +4 -4
- package/dist/components/contact/index.js +3 -3
- package/dist/components/docs/index.cjs +7 -7
- package/dist/components/docs/index.js +6 -6
- package/dist/components/embeds/index.cjs +4 -4
- package/dist/components/embeds/index.js +3 -3
- package/dist/components/faq/index.cjs +4 -4
- package/dist/components/faq/index.js +3 -3
- package/dist/components/features/index.cjs +3 -3
- package/dist/components/features/index.js +2 -2
- package/dist/components/help-center-pages/index.cjs +23 -23
- package/dist/components/help-center-pages/index.js +14 -14
- package/dist/components/index.cjs +39 -39
- package/dist/components/index.js +13 -13
- package/dist/components/meeting-scheduler/index.cjs +24 -24
- package/dist/components/meeting-scheduler/index.js +2 -2
- package/dist/components/navigation/index.cjs +6 -6
- package/dist/components/navigation/index.js +5 -5
- package/dist/components/onboarding-guides/index.cjs +6 -6
- package/dist/components/onboarding-guides/index.js +5 -5
- package/dist/components/tickets/index.cjs +7 -7
- package/dist/components/tickets/index.js +6 -6
- package/dist/components/ui/data-table/data-table-skeleton.d.ts.map +1 -1
- package/dist/components/ui/index.cjs +3 -3
- package/dist/components/ui/index.js +2 -2
- package/dist/components/ui/markdown/mermaid-diagram.d.ts +31 -9
- package/dist/components/ui/markdown/mermaid-diagram.d.ts.map +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.js +6 -6
- package/package.json +1 -1
- package/src/components/ui/data-table/data-table-skeleton.tsx +15 -7
- package/src/components/ui/markdown/__tests__/mermaid-zoom.test.tsx +115 -0
- package/src/components/ui/markdown/mermaid-diagram.tsx +279 -59
- package/dist/chunk-7UWJMWDH.cjs.map +0 -1
- package/dist/chunk-DULSS7R6.js.map +0 -1
- package/dist/chunk-QS55P2TA.js.map +0 -1
- package/dist/chunk-RRSR2XHJ.cjs.map +0 -1
- /package/dist/{chunk-XJH5M2B7.js.map → chunk-5DCRDV7Y.js.map} +0 -0
- /package/dist/{chunk-ZDIDA4QG.js.map → chunk-6Z4GSQPB.js.map} +0 -0
- /package/dist/{chunk-PD47DDHS.js.map → chunk-DIGCERY4.js.map} +0 -0
- /package/dist/{chunk-NKMXFBV5.js.map → chunk-DLJHXLFG.js.map} +0 -0
- /package/dist/{chunk-5C7GMRJU.js.map → chunk-ERLGZPCY.js.map} +0 -0
- /package/dist/{chunk-XATBOM3X.js.map → chunk-IKMETQWQ.js.map} +0 -0
- /package/dist/{chunk-XPPGI7SD.js.map → chunk-QPAQEPA3.js.map} +0 -0
- /package/dist/{chunk-ZGWXD2S3.js.map → chunk-RIOWS34T.js.map} +0 -0
- /package/dist/{chunk-UR7BC74V.js.map → chunk-RUEVZAPN.js.map} +0 -0
- /package/dist/{chunk-5MZZFTME.js.map → chunk-RXIFYEL7.js.map} +0 -0
- /package/dist/{chunk-GBZ3IR3S.js.map → chunk-T7NBMDDE.js.map} +0 -0
- /package/dist/{chunk-4GOJFHJY.js.map → chunk-V33TSVUR.js.map} +0 -0
- /package/dist/{chunk-LLT5XMP2.js.map → chunk-VXG43NJD.js.map} +0 -0
- /package/dist/{chunk-ETEM2ZD4.js.map → chunk-ZNSBWM2D.js.map} +0 -0
|
@@ -1252,7 +1252,7 @@ ContextCompactionDisplay.displayName = "ContextCompactionDisplay";
|
|
|
1252
1252
|
import { forwardRef as forwardRef8, useState as useState7 } from "react";
|
|
1253
1253
|
|
|
1254
1254
|
// src/components/ui/markdown/engine.tsx
|
|
1255
|
-
import { memo, useMemo as
|
|
1255
|
+
import { memo, useMemo as useMemo4 } from "react";
|
|
1256
1256
|
import ReactMarkdown from "react-markdown";
|
|
1257
1257
|
import rehypeHighlight from "rehype-highlight";
|
|
1258
1258
|
import rehypeRaw from "rehype-raw";
|
|
@@ -1376,7 +1376,8 @@ function extractText(node) {
|
|
|
1376
1376
|
}
|
|
1377
1377
|
|
|
1378
1378
|
// src/components/ui/markdown/mermaid-diagram.tsx
|
|
1379
|
-
import {
|
|
1379
|
+
import { Maximize2, ZoomIn, ZoomOut } from "lucide-react";
|
|
1380
|
+
import { useCallback, useEffect, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useRef, useState as useState6 } from "react";
|
|
1380
1381
|
|
|
1381
1382
|
// src/hooks/ui/use-is-hydrated.ts
|
|
1382
1383
|
import { useSyncExternalStore } from "react";
|
|
@@ -1435,38 +1436,17 @@ async function withRenderTimeout(promise, ms) {
|
|
|
1435
1436
|
}
|
|
1436
1437
|
}
|
|
1437
1438
|
var mermaidStyles = `
|
|
1439
|
+
/* The pan surface is a scroll region with NO scrollbars: drag, wheel,
|
|
1440
|
+
arrows and the toolbar move it (a canvas, the way dbdiagram, Figma and
|
|
1441
|
+
Excalidraw draw one). Two mechanisms for one motion read as a bug. */
|
|
1442
|
+
.mermaid-frame-pan { scrollbar-width: none; -ms-overflow-style: none; }
|
|
1443
|
+
.mermaid-frame-pan::-webkit-scrollbar { display: none; }
|
|
1438
1444
|
.mermaid-svg-container svg {
|
|
1439
|
-
max-width: 100
|
|
1440
|
-
height: auto
|
|
1441
|
-
min-height: 200px;
|
|
1445
|
+
max-width: 100%;
|
|
1446
|
+
height: auto;
|
|
1442
1447
|
font-family: 'DM Sans', sans-serif !important;
|
|
1443
1448
|
font-size: 14px !important;
|
|
1444
1449
|
}
|
|
1445
|
-
@media (min-width: 1520px) {
|
|
1446
|
-
.mermaid-svg-container svg {
|
|
1447
|
-
max-width: 900px !important;
|
|
1448
|
-
max-height: 700px !important;
|
|
1449
|
-
min-height: 300px;
|
|
1450
|
-
font-size: 16px !important;
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
@media (min-width: 768px) and (max-width: 1519px) {
|
|
1454
|
-
.mermaid-svg-container svg {
|
|
1455
|
-
max-width: 700px !important;
|
|
1456
|
-
max-height: 600px !important;
|
|
1457
|
-
min-height: 250px;
|
|
1458
|
-
font-size: 15px !important;
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
@media (max-width: 767px) {
|
|
1462
|
-
.mermaid-svg-container svg {
|
|
1463
|
-
max-width: 90vw !important;
|
|
1464
|
-
max-height: 400px !important;
|
|
1465
|
-
min-height: 200px;
|
|
1466
|
-
font-size: 13px !important;
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
.mermaid-svg-container svg[width] { width: 100% !important; }
|
|
1470
1450
|
.mermaid-svg-container .node rect,
|
|
1471
1451
|
.mermaid-svg-container .node circle,
|
|
1472
1452
|
.mermaid-svg-container .node ellipse,
|
|
@@ -1481,15 +1461,122 @@ var mermaidStyles = `
|
|
|
1481
1461
|
.mermaid-svg-container .edgeLabel text { font-size: 16px !important; }
|
|
1482
1462
|
}
|
|
1483
1463
|
`;
|
|
1464
|
+
var MERMAID_ZOOM_MIN = 0.25;
|
|
1465
|
+
var MERMAID_ZOOM_MAX = 4;
|
|
1466
|
+
var MERMAID_ZOOM_STEP = 1.25;
|
|
1467
|
+
var clampZoom = (z) => Math.min(MERMAID_ZOOM_MAX, Math.max(MERMAID_ZOOM_MIN, z));
|
|
1484
1468
|
var mermaidRenderSeq = 0;
|
|
1485
|
-
var
|
|
1469
|
+
var FRAME_CLASS = {
|
|
1470
|
+
content: "min-h-[200px] max-h-[70svh] md:min-h-[250px]",
|
|
1471
|
+
fold: "h-[70svh] min-h-[320px]"
|
|
1472
|
+
};
|
|
1473
|
+
var MermaidDiagram = ({
|
|
1474
|
+
chart,
|
|
1475
|
+
zoomable = true,
|
|
1476
|
+
frame = "content"
|
|
1477
|
+
}) => {
|
|
1486
1478
|
const [svg, setSvg] = useState6("");
|
|
1487
1479
|
const [error, setError] = useState6("");
|
|
1488
1480
|
const [isLoading, setIsLoading] = useState6(true);
|
|
1481
|
+
const [zoom, setZoom] = useState6(1);
|
|
1482
|
+
const [dragging, setDragging] = useState6(false);
|
|
1483
|
+
const empty = !chart.trim();
|
|
1484
|
+
const naturalWidth = useMemo3(() => {
|
|
1485
|
+
const px = Number(svg.match(/max-width:\s*([\d.]+)px/)?.[1]);
|
|
1486
|
+
return Number.isFinite(px) && px > 0 ? Math.ceil(px) : null;
|
|
1487
|
+
}, [svg]);
|
|
1488
|
+
const scrollRef = useRef(null);
|
|
1489
|
+
const pendingAnchor = useRef(null);
|
|
1490
|
+
const applyZoom = useCallback((next, anchor) => {
|
|
1491
|
+
setZoom((current) => {
|
|
1492
|
+
const target = clampZoom(Math.round(next * 100) / 100);
|
|
1493
|
+
if (target === current) return current;
|
|
1494
|
+
const el = scrollRef.current;
|
|
1495
|
+
const ax = anchor?.ax ?? (el ? el.clientWidth / 2 : 0);
|
|
1496
|
+
const ay = anchor?.ay ?? (el ? el.clientHeight / 2 : 0);
|
|
1497
|
+
pendingAnchor.current = { ratio: target / current, ax, ay };
|
|
1498
|
+
return target;
|
|
1499
|
+
});
|
|
1500
|
+
}, []);
|
|
1501
|
+
useLayoutEffect2(() => {
|
|
1502
|
+
const el = scrollRef.current;
|
|
1503
|
+
const pending = pendingAnchor.current;
|
|
1504
|
+
if (!el || !pending) return;
|
|
1505
|
+
pendingAnchor.current = null;
|
|
1506
|
+
el.scrollLeft = (el.scrollLeft + pending.ax) * pending.ratio - pending.ax;
|
|
1507
|
+
el.scrollTop = (el.scrollTop + pending.ay) * pending.ratio - pending.ay;
|
|
1508
|
+
}, [zoom]);
|
|
1509
|
+
const zoomBy = useCallback(
|
|
1510
|
+
(factor, anchor) => applyZoom(zoom * factor, anchor),
|
|
1511
|
+
[applyZoom, zoom]
|
|
1512
|
+
);
|
|
1513
|
+
const fit = useCallback(() => {
|
|
1514
|
+
const el = scrollRef.current;
|
|
1515
|
+
const svgEl = el?.querySelector("svg");
|
|
1516
|
+
if (!el || !svgEl) return;
|
|
1517
|
+
const box = svgEl.getBoundingClientRect();
|
|
1518
|
+
const w = box.width / zoom;
|
|
1519
|
+
const h = box.height / zoom;
|
|
1520
|
+
if (!(w > 0 && h > 0)) return;
|
|
1521
|
+
const next = Math.min(1, el.clientWidth / w, el.clientHeight / h);
|
|
1522
|
+
pendingAnchor.current = null;
|
|
1523
|
+
setZoom(clampZoom(Math.floor(next * 100) / 100));
|
|
1524
|
+
el.scrollTo({ left: 0, top: 0 });
|
|
1525
|
+
}, [zoom]);
|
|
1526
|
+
useEffect(() => {
|
|
1527
|
+
const el = scrollRef.current;
|
|
1528
|
+
if (!el || !zoomable) return void 0;
|
|
1529
|
+
const onWheel = (e) => {
|
|
1530
|
+
if (!(e.ctrlKey || e.metaKey)) return;
|
|
1531
|
+
e.preventDefault();
|
|
1532
|
+
const rect = el.getBoundingClientRect();
|
|
1533
|
+
applyZoom(zoom * Math.exp(-e.deltaY * 25e-4), { ax: e.clientX - rect.left, ay: e.clientY - rect.top });
|
|
1534
|
+
};
|
|
1535
|
+
el.addEventListener("wheel", onWheel, { passive: false });
|
|
1536
|
+
return () => el.removeEventListener("wheel", onWheel);
|
|
1537
|
+
}, [zoomable, svg, zoom, applyZoom]);
|
|
1538
|
+
const drag = useRef(null);
|
|
1539
|
+
const onPointerDown = (e) => {
|
|
1540
|
+
if (!zoomable || e.button !== 0 || e.pointerType === "touch") return;
|
|
1541
|
+
const el = scrollRef.current;
|
|
1542
|
+
if (!el) return;
|
|
1543
|
+
e.preventDefault();
|
|
1544
|
+
drag.current = { x: e.clientX, y: e.clientY, left: el.scrollLeft, top: el.scrollTop };
|
|
1545
|
+
el.setPointerCapture?.(e.pointerId);
|
|
1546
|
+
el.focus({ preventScroll: true });
|
|
1547
|
+
setDragging(true);
|
|
1548
|
+
};
|
|
1549
|
+
const onPointerMove = (e) => {
|
|
1550
|
+
const d = drag.current;
|
|
1551
|
+
const el = scrollRef.current;
|
|
1552
|
+
if (!d || !el) return;
|
|
1553
|
+
el.scrollLeft = d.left - (e.clientX - d.x);
|
|
1554
|
+
el.scrollTop = d.top - (e.clientY - d.y);
|
|
1555
|
+
};
|
|
1556
|
+
const endDrag = (e) => {
|
|
1557
|
+
if (!drag.current) return;
|
|
1558
|
+
drag.current = null;
|
|
1559
|
+
scrollRef.current?.releasePointerCapture?.(e.pointerId);
|
|
1560
|
+
setDragging(false);
|
|
1561
|
+
};
|
|
1562
|
+
const onKeyDown = (e) => {
|
|
1563
|
+
if (!zoomable || !svg) return;
|
|
1564
|
+
if (e.key === "+" || e.key === "=") zoomBy(MERMAID_ZOOM_STEP);
|
|
1565
|
+
else if (e.key === "-") zoomBy(1 / MERMAID_ZOOM_STEP);
|
|
1566
|
+
else if (e.key === "0") applyZoom(1);
|
|
1567
|
+
else if (e.key === "f" || e.key === "F") fit();
|
|
1568
|
+
else return;
|
|
1569
|
+
e.preventDefault();
|
|
1570
|
+
};
|
|
1489
1571
|
const mounted = useIsHydrated();
|
|
1490
1572
|
useEffect(() => {
|
|
1491
1573
|
let cancelled = false;
|
|
1492
1574
|
const renderId = `mermaid-${mermaidRenderSeq += 1}`;
|
|
1575
|
+
if (empty) {
|
|
1576
|
+
return () => {
|
|
1577
|
+
cancelled = true;
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1493
1580
|
const renderMermaid = async () => {
|
|
1494
1581
|
try {
|
|
1495
1582
|
setIsLoading(true);
|
|
@@ -1539,6 +1626,8 @@ var MermaidDiagram = ({ chart }) => {
|
|
|
1539
1626
|
);
|
|
1540
1627
|
if (cancelled) return;
|
|
1541
1628
|
setSvg(renderedSvg);
|
|
1629
|
+
pendingAnchor.current = null;
|
|
1630
|
+
setZoom(1);
|
|
1542
1631
|
setError("");
|
|
1543
1632
|
setIsLoading(false);
|
|
1544
1633
|
} catch (err) {
|
|
@@ -1556,33 +1645,110 @@ var MermaidDiagram = ({ chart }) => {
|
|
|
1556
1645
|
document.getElementById(`d${renderId}`)?.remove();
|
|
1557
1646
|
document.getElementById(renderId)?.remove();
|
|
1558
1647
|
};
|
|
1559
|
-
}, [chart, mounted]);
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1648
|
+
}, [chart, empty, mounted]);
|
|
1649
|
+
const frameClass = `${FRAME_CLASS[frame]} flex w-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-ods-accent ${zoomable && svg ? `mermaid-frame-pan select-none ${dragging ? "cursor-grabbing" : "cursor-grab"}` : ""}`;
|
|
1650
|
+
const frameStyle = { justifyContent: "safe center", alignItems: "safe center" };
|
|
1651
|
+
const body = error && !empty ? /* @__PURE__ */ jsxs8("div", { className: "error-state m-auto rounded-lg border border-ods-border bg-ods-card p-6", children: [
|
|
1652
|
+
/* @__PURE__ */ jsx12("div", { className: "error-icon mb-4 flex justify-center", children: /* @__PURE__ */ jsx12(AlertCircleIcon, { className: "h-12 w-12 text-ods-error" }) }),
|
|
1653
|
+
/* @__PURE__ */ jsx12("div", { className: "error-title mb-2 text-center font-sans text-lg font-semibold text-ods-error", children: "Diagram Error" }),
|
|
1654
|
+
/* @__PURE__ */ jsx12("div", { className: "error-description mb-4 max-w-full overflow-hidden break-words text-center font-sans text-sm text-ods-text-secondary", children: /* @__PURE__ */ jsx12("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsx12("pre", { className: "whitespace-pre-wrap break-words text-xs", children: error }) }) })
|
|
1655
|
+
] }) : empty || isLoading || !svg ? /* @__PURE__ */ jsx12("div", { className: "skeleton-code m-auto animate-pulse font-sans text-ods-text-tertiary", children: isLoading ? "Loading diagram renderer..." : "Rendering diagram..." }) : /* @__PURE__ */ jsx12(
|
|
1656
|
+
"div",
|
|
1657
|
+
{
|
|
1658
|
+
className: "mermaid-svg-container flex shrink-0 justify-center",
|
|
1659
|
+
"data-testid": "mermaid-svg-container",
|
|
1660
|
+
"data-zoom": zoom,
|
|
1661
|
+
style: {
|
|
1662
|
+
fontSize: "14px",
|
|
1663
|
+
zoom,
|
|
1664
|
+
width: naturalWidth ? `min(${naturalWidth}px, calc(100% * ${zoom}))` : "100%"
|
|
1665
|
+
},
|
|
1666
|
+
dangerouslySetInnerHTML: { __html: svg }
|
|
1667
|
+
}
|
|
1668
|
+
);
|
|
1669
|
+
return /* @__PURE__ */ jsxs8("div", { className: "mermaid-container relative my-6 rounded-lg border border-ods-border bg-ods-card p-4 md:p-6 lg:p-8", children: [
|
|
1571
1670
|
/* @__PURE__ */ jsx12("style", { dangerouslySetInnerHTML: { __html: mermaidStyles } }),
|
|
1572
|
-
|
|
1671
|
+
zoomable && /* @__PURE__ */ jsxs8(
|
|
1573
1672
|
"div",
|
|
1574
1673
|
{
|
|
1575
|
-
className: "
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1674
|
+
className: "absolute right-2 top-2 z-10 flex items-center gap-[var(--spacing-system-xxs)] rounded-md bg-ods-card",
|
|
1675
|
+
role: "group",
|
|
1676
|
+
"aria-label": "Diagram zoom",
|
|
1677
|
+
children: [
|
|
1678
|
+
/* @__PURE__ */ jsx12(
|
|
1679
|
+
Button,
|
|
1680
|
+
{
|
|
1681
|
+
variant: "outline",
|
|
1682
|
+
size: "icon-sm",
|
|
1683
|
+
"aria-label": "Zoom out",
|
|
1684
|
+
title: "Zoom out (\u2212, \u2318/Ctrl + wheel)",
|
|
1685
|
+
disabled: !svg || zoom <= MERMAID_ZOOM_MIN,
|
|
1686
|
+
onClick: () => zoomBy(1 / MERMAID_ZOOM_STEP),
|
|
1687
|
+
children: /* @__PURE__ */ jsx12(ZoomOut, {})
|
|
1688
|
+
}
|
|
1689
|
+
),
|
|
1690
|
+
/* @__PURE__ */ jsxs8(
|
|
1691
|
+
Button,
|
|
1692
|
+
{
|
|
1693
|
+
variant: "outline",
|
|
1694
|
+
size: "compact",
|
|
1695
|
+
"aria-label": "Reset zoom",
|
|
1696
|
+
title: "Back to 100% (0)",
|
|
1697
|
+
disabled: !svg || zoom === 1,
|
|
1698
|
+
onClick: () => applyZoom(1),
|
|
1699
|
+
children: [
|
|
1700
|
+
Math.round(zoom * 100),
|
|
1701
|
+
"%"
|
|
1702
|
+
]
|
|
1703
|
+
}
|
|
1704
|
+
),
|
|
1705
|
+
/* @__PURE__ */ jsx12(
|
|
1706
|
+
Button,
|
|
1707
|
+
{
|
|
1708
|
+
variant: "outline",
|
|
1709
|
+
size: "icon-sm",
|
|
1710
|
+
"aria-label": "Zoom in",
|
|
1711
|
+
title: "Zoom in (+, \u2318/Ctrl + wheel)",
|
|
1712
|
+
disabled: !svg || zoom >= MERMAID_ZOOM_MAX,
|
|
1713
|
+
onClick: () => zoomBy(MERMAID_ZOOM_STEP),
|
|
1714
|
+
children: /* @__PURE__ */ jsx12(ZoomIn, {})
|
|
1715
|
+
}
|
|
1716
|
+
),
|
|
1717
|
+
/* @__PURE__ */ jsx12(
|
|
1718
|
+
Button,
|
|
1719
|
+
{
|
|
1720
|
+
variant: "outline",
|
|
1721
|
+
size: "icon-sm",
|
|
1722
|
+
"aria-label": "Fit to frame",
|
|
1723
|
+
title: "Fit the whole diagram in the frame (f)",
|
|
1724
|
+
disabled: !svg,
|
|
1725
|
+
onClick: fit,
|
|
1726
|
+
children: /* @__PURE__ */ jsx12(Maximize2, {})
|
|
1727
|
+
}
|
|
1582
1728
|
)
|
|
1583
|
-
|
|
1729
|
+
]
|
|
1584
1730
|
}
|
|
1585
|
-
)
|
|
1731
|
+
),
|
|
1732
|
+
/* @__PURE__ */ jsx12(
|
|
1733
|
+
"div",
|
|
1734
|
+
{
|
|
1735
|
+
ref: scrollRef,
|
|
1736
|
+
className: frameClass,
|
|
1737
|
+
style: frameStyle,
|
|
1738
|
+
"data-testid": "mermaid-frame",
|
|
1739
|
+
"data-frame": frame,
|
|
1740
|
+
tabIndex: zoomable && svg ? 0 : -1,
|
|
1741
|
+
role: zoomable && svg ? "region" : void 0,
|
|
1742
|
+
"aria-label": zoomable && svg ? "Diagram. Drag to pan; Ctrl or Cmd plus wheel, or + and -, to zoom; 0 resets; f fits." : void 0,
|
|
1743
|
+
title: zoomable && svg ? "Drag to pan \xB7 \u2318/Ctrl + wheel to zoom" : void 0,
|
|
1744
|
+
onPointerDown,
|
|
1745
|
+
onPointerMove,
|
|
1746
|
+
onPointerUp: endDrag,
|
|
1747
|
+
onPointerCancel: endDrag,
|
|
1748
|
+
onKeyDown,
|
|
1749
|
+
children: body
|
|
1750
|
+
}
|
|
1751
|
+
)
|
|
1586
1752
|
] });
|
|
1587
1753
|
};
|
|
1588
1754
|
|
|
@@ -3515,23 +3681,23 @@ var MarkdownEngineImpl = ({
|
|
|
3515
3681
|
extraAllowedHtmlTags,
|
|
3516
3682
|
streaming = false
|
|
3517
3683
|
}) => {
|
|
3518
|
-
const textSizes =
|
|
3684
|
+
const textSizes = useMemo4(() => resolveTextSizeConfig(textSize), [textSize]);
|
|
3519
3685
|
const extraTagsKey = extraAllowedHtmlTags?.join("|") ?? "";
|
|
3520
|
-
const effectiveTags =
|
|
3686
|
+
const effectiveTags = useMemo4(
|
|
3521
3687
|
() => buildEffectiveTagSet(extraTagsKey ? extraTagsKey.split("|") : void 0),
|
|
3522
3688
|
[extraTagsKey]
|
|
3523
3689
|
);
|
|
3524
|
-
const processedContent =
|
|
3690
|
+
const processedContent = useMemo4(() => {
|
|
3525
3691
|
const preprocessed = preprocessContent ? preprocessContent(content) : content;
|
|
3526
3692
|
const completed = streaming ? completeStreamingTail(preprocessed) : preprocessed;
|
|
3527
3693
|
return escapeUnknownHtmlTags(completed, effectiveTags);
|
|
3528
3694
|
}, [preprocessContent, content, effectiveTags, streaming]);
|
|
3529
3695
|
const headingIds = useHeadingIdMap(processedContent, sectionIds);
|
|
3530
|
-
const remarkPlugins =
|
|
3696
|
+
const remarkPlugins = useMemo4(
|
|
3531
3697
|
() => [remarkGfm, remarkBreaks, ...additionalRemarkPlugins ?? []],
|
|
3532
3698
|
[additionalRemarkPlugins]
|
|
3533
3699
|
);
|
|
3534
|
-
const rehypePlugins =
|
|
3700
|
+
const rehypePlugins = useMemo4(() => {
|
|
3535
3701
|
const schema = buildSanitizeSchema({
|
|
3536
3702
|
extraAllowedHtmlTags: extraTagsKey ? extraTagsKey.split("|") : void 0
|
|
3537
3703
|
});
|
|
@@ -3545,7 +3711,7 @@ var MarkdownEngineImpl = ({
|
|
|
3545
3711
|
[rehypeHighlight, { detect: true, ignoreMissing: true }]
|
|
3546
3712
|
];
|
|
3547
3713
|
}, [extraTagsKey]);
|
|
3548
|
-
const components =
|
|
3714
|
+
const components = useMemo4(
|
|
3549
3715
|
() => ({
|
|
3550
3716
|
...buildBaseComponents({
|
|
3551
3717
|
textSizes,
|
|
@@ -3561,7 +3727,7 @@ var MarkdownEngineImpl = ({
|
|
|
3561
3727
|
}),
|
|
3562
3728
|
[textSizes, demoteMarkdownH1ToH2, brokenLinks, currentPath, onInternalLinkClick, onResolveLink, componentOverrides]
|
|
3563
3729
|
);
|
|
3564
|
-
const streamingBlocks =
|
|
3730
|
+
const streamingBlocks = useMemo4(
|
|
3565
3731
|
() => streaming ? splitStreamingBlocks(processedContent) : null,
|
|
3566
3732
|
[streaming, processedContent]
|
|
3567
3733
|
);
|
|
@@ -4210,7 +4376,7 @@ function hslToRgb(h, s, l) {
|
|
|
4210
4376
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
4211
4377
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
4212
4378
|
import { Check } from "lucide-react";
|
|
4213
|
-
import React, { useCallback } from "react";
|
|
4379
|
+
import React, { useCallback as useCallback2 } from "react";
|
|
4214
4380
|
|
|
4215
4381
|
// src/components/ui/actions-menu-header-context.ts
|
|
4216
4382
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
@@ -4220,7 +4386,7 @@ function useIsInActionsMenuHeader() {
|
|
|
4220
4386
|
}
|
|
4221
4387
|
|
|
4222
4388
|
// src/components/ui/overlay-open-registry.tsx
|
|
4223
|
-
import { createContext as createContext3, useContext as useContext3, useEffect as useEffect3, useMemo as
|
|
4389
|
+
import { createContext as createContext3, useContext as useContext3, useEffect as useEffect3, useMemo as useMemo5, useRef as useRef2 } from "react";
|
|
4224
4390
|
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
4225
4391
|
var OverlayOpenRegistryContext = createContext3(null);
|
|
4226
4392
|
function useOverlayOpenRegistry() {
|
|
@@ -4234,12 +4400,12 @@ function useReportOverlayOpen(open) {
|
|
|
4234
4400
|
}, [open, registry]);
|
|
4235
4401
|
}
|
|
4236
4402
|
function OverlayOpenRegistryProvider({ onOpenChange, children }) {
|
|
4237
|
-
const countRef =
|
|
4238
|
-
const onOpenChangeRef =
|
|
4403
|
+
const countRef = useRef2(0);
|
|
4404
|
+
const onOpenChangeRef = useRef2(onOpenChange);
|
|
4239
4405
|
useEffect3(() => {
|
|
4240
4406
|
onOpenChangeRef.current = onOpenChange;
|
|
4241
4407
|
});
|
|
4242
|
-
const registry =
|
|
4408
|
+
const registry = useMemo5(
|
|
4243
4409
|
() => ({
|
|
4244
4410
|
acquire: () => {
|
|
4245
4411
|
countRef.current += 1;
|
|
@@ -4265,7 +4431,7 @@ var ROW_CLASSES = "flex flex-1 min-w-0 items-center gap-[var(--spacing-system-xs
|
|
|
4265
4431
|
var WRAPPER_CLASSES = "relative flex items-stretch border-b border-ods-border last:border-b-0";
|
|
4266
4432
|
var SECONDARY_ACTION_CLASSES = "flex p-[var(--spacing-system-s)] shrink-0 items-center justify-center self-stretch border-l border-ods-border transition-colors hover:bg-ods-bg-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ods-focus [&_svg]:w-4 [&_svg]:h-4 md:[&_svg]:w-6 md:[&_svg]:h-6";
|
|
4267
4433
|
var SecondaryAction = ({ action }) => {
|
|
4268
|
-
const handleClick =
|
|
4434
|
+
const handleClick = useCallback2(
|
|
4269
4435
|
(e) => {
|
|
4270
4436
|
e.stopPropagation();
|
|
4271
4437
|
if (action.disabled) {
|
|
@@ -4313,7 +4479,7 @@ var SecondaryAction = ({ action }) => {
|
|
|
4313
4479
|
var MenuItem = ({ item, onItemClick }) => {
|
|
4314
4480
|
const portalContainer = usePortalContainer();
|
|
4315
4481
|
const collisionBoundary = useCollisionBoundary();
|
|
4316
|
-
const activate =
|
|
4482
|
+
const activate = useCallback2(() => {
|
|
4317
4483
|
if (item.disabled) return;
|
|
4318
4484
|
if (item.type === "checkbox") {
|
|
4319
4485
|
item.onClick?.();
|
|
@@ -4324,7 +4490,7 @@ var MenuItem = ({ item, onItemClick }) => {
|
|
|
4324
4490
|
item.onClick?.();
|
|
4325
4491
|
onItemClick?.(item);
|
|
4326
4492
|
}, [item, onItemClick]);
|
|
4327
|
-
const handleClick =
|
|
4493
|
+
const handleClick = useCallback2(
|
|
4328
4494
|
(e) => {
|
|
4329
4495
|
e.stopPropagation();
|
|
4330
4496
|
e.preventDefault();
|
|
@@ -4332,7 +4498,7 @@ var MenuItem = ({ item, onItemClick }) => {
|
|
|
4332
4498
|
},
|
|
4333
4499
|
[activate]
|
|
4334
4500
|
);
|
|
4335
|
-
const handleKeyDown =
|
|
4501
|
+
const handleKeyDown = useCallback2(
|
|
4336
4502
|
(e) => {
|
|
4337
4503
|
if (e.key !== "Enter" && e.key !== " ") return;
|
|
4338
4504
|
e.preventDefault();
|
|
@@ -4341,7 +4507,7 @@ var MenuItem = ({ item, onItemClick }) => {
|
|
|
4341
4507
|
},
|
|
4342
4508
|
[activate]
|
|
4343
4509
|
);
|
|
4344
|
-
const handleLinkClick =
|
|
4510
|
+
const handleLinkClick = useCallback2(
|
|
4345
4511
|
(e) => {
|
|
4346
4512
|
if (item.disabled) {
|
|
4347
4513
|
e.preventDefault();
|
|
@@ -4512,7 +4678,7 @@ var ActionsMenuDropdown = ({
|
|
|
4512
4678
|
document.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
4513
4679
|
return () => document.removeEventListener("scroll", onScroll, { capture: true });
|
|
4514
4680
|
}, [open, setOpen]);
|
|
4515
|
-
const handleItemClick =
|
|
4681
|
+
const handleItemClick = useCallback2(
|
|
4516
4682
|
(item) => {
|
|
4517
4683
|
onItemClick?.(item);
|
|
4518
4684
|
if (item.type !== "checkbox" && item.type !== "submenu" && item.closeOnSelect !== false) {
|
|
@@ -5043,12 +5209,12 @@ ChatFooter.displayName = "ChatFooter";
|
|
|
5043
5209
|
// src/components/chat/chat-input.tsx
|
|
5044
5210
|
import {
|
|
5045
5211
|
useState as useState10,
|
|
5046
|
-
useRef as
|
|
5212
|
+
useRef as useRef3,
|
|
5047
5213
|
useImperativeHandle,
|
|
5048
5214
|
forwardRef as forwardRef14,
|
|
5049
|
-
useCallback as
|
|
5215
|
+
useCallback as useCallback3,
|
|
5050
5216
|
useEffect as useEffect4,
|
|
5051
|
-
useMemo as
|
|
5217
|
+
useMemo as useMemo6
|
|
5052
5218
|
} from "react";
|
|
5053
5219
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
5054
5220
|
|
|
@@ -5847,15 +6013,15 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
5847
6013
|
const [focused, setFocused] = useState10(false);
|
|
5848
6014
|
const [isStopping, setIsStopping] = useState10(false);
|
|
5849
6015
|
const [previewDismissed, setPreviewDismissed] = useState10(false);
|
|
5850
|
-
const editorRef =
|
|
5851
|
-
const shouldRefocusRef =
|
|
5852
|
-
const prevSendingRef =
|
|
5853
|
-
const prevAwaitingResponseRef =
|
|
5854
|
-
const isComposingRef =
|
|
5855
|
-
const valueRef =
|
|
6016
|
+
const editorRef = useRef3(null);
|
|
6017
|
+
const shouldRefocusRef = useRef3(false);
|
|
6018
|
+
const prevSendingRef = useRef3(sending);
|
|
6019
|
+
const prevAwaitingResponseRef = useRef3(awaitingResponse);
|
|
6020
|
+
const isComposingRef = useRef3(false);
|
|
6021
|
+
const valueRef = useRef3(value);
|
|
5856
6022
|
valueRef.current = value;
|
|
5857
|
-
const metaRef =
|
|
5858
|
-
const focusEditor =
|
|
6023
|
+
const metaRef = useRef3(/* @__PURE__ */ new Map());
|
|
6024
|
+
const focusEditor = useCallback3(() => {
|
|
5859
6025
|
if (disabled) return;
|
|
5860
6026
|
editorRef.current?.focus({ preventScroll: true });
|
|
5861
6027
|
}, [disabled]);
|
|
@@ -5865,7 +6031,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
5865
6031
|
useEffect4(() => {
|
|
5866
6032
|
onValueChange?.(value);
|
|
5867
6033
|
}, [value, onValueChange]);
|
|
5868
|
-
const previewTextRef =
|
|
6034
|
+
const previewTextRef = useRef3(previewText);
|
|
5869
6035
|
useEffect4(() => {
|
|
5870
6036
|
previewTextRef.current = previewText;
|
|
5871
6037
|
});
|
|
@@ -5875,7 +6041,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
5875
6041
|
useEffect4(() => {
|
|
5876
6042
|
if (previewTextRef.current) setPreviewDismissed(true);
|
|
5877
6043
|
}, [value]);
|
|
5878
|
-
const applyValue =
|
|
6044
|
+
const applyValue = useCallback3((next, caret = "end") => {
|
|
5879
6045
|
const el = editorRef.current;
|
|
5880
6046
|
if (el) {
|
|
5881
6047
|
rebuildDom(el, next, metaRef.current);
|
|
@@ -5888,7 +6054,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
5888
6054
|
valueRef.current = next;
|
|
5889
6055
|
setValue(next);
|
|
5890
6056
|
}, []);
|
|
5891
|
-
const fire =
|
|
6057
|
+
const fire = useCallback3(
|
|
5892
6058
|
(message) => {
|
|
5893
6059
|
const can = (message.length > 0 || allowEmptySend) && !sending && !disabled;
|
|
5894
6060
|
if (!can || !onSend) return;
|
|
@@ -5913,7 +6079,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
5913
6079
|
},
|
|
5914
6080
|
[allowEmptySend, sending, disabled, onSend, focusEditor, applyValue]
|
|
5915
6081
|
);
|
|
5916
|
-
const handleSubmit =
|
|
6082
|
+
const handleSubmit = useCallback3(() => {
|
|
5917
6083
|
fire(valueRef.current.trim());
|
|
5918
6084
|
}, [fire]);
|
|
5919
6085
|
useImperativeHandle(
|
|
@@ -5949,7 +6115,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
5949
6115
|
[focusEditor, fire, applyValue]
|
|
5950
6116
|
);
|
|
5951
6117
|
const mentionEnabled = !!onMentionQueryChange;
|
|
5952
|
-
const mentionQuery =
|
|
6118
|
+
const mentionQuery = useMemo6(() => {
|
|
5953
6119
|
if (!mentionEnabled) return null;
|
|
5954
6120
|
const m = value.match(MENTION_TRIGGER_AT_END);
|
|
5955
6121
|
return m ? m[2] ?? "" : null;
|
|
@@ -5957,7 +6123,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
5957
6123
|
useEffect4(() => {
|
|
5958
6124
|
if (mentionEnabled) onMentionQueryChange?.(mentionQuery);
|
|
5959
6125
|
}, [mentionEnabled, mentionQuery, onMentionQueryChange]);
|
|
5960
|
-
const slashMatch =
|
|
6126
|
+
const slashMatch = useMemo6(() => slashCommands ? value.match(SLASH_INPUT_TRIGGER) : null, [value, slashCommands]);
|
|
5961
6127
|
const slashPrefix = slashMatch ? slashMatch[1] ?? "" : null;
|
|
5962
6128
|
const [slashSuggestions, setSlashSuggestions] = useState10([]);
|
|
5963
6129
|
const [highlightedIdx, setHighlightedIdx] = useState10(0);
|
|
@@ -5992,7 +6158,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
5992
6158
|
clearTimeout(handle);
|
|
5993
6159
|
};
|
|
5994
6160
|
}, [slashPrefix, slashCommands]);
|
|
5995
|
-
const acceptSuggestion =
|
|
6161
|
+
const acceptSuggestion = useCallback3(
|
|
5996
6162
|
(cmd) => {
|
|
5997
6163
|
metaRef.current = /* @__PURE__ */ new Map();
|
|
5998
6164
|
const next = `/${cmd.id} `;
|
|
@@ -6002,17 +6168,17 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
6002
6168
|
},
|
|
6003
6169
|
[applyValue, focusEditor]
|
|
6004
6170
|
);
|
|
6005
|
-
const syncFromDom =
|
|
6171
|
+
const syncFromDom = useCallback3(() => {
|
|
6006
6172
|
const el = editorRef.current;
|
|
6007
6173
|
if (!el) return;
|
|
6008
6174
|
setHasChips(el.querySelector("[data-token]") !== null);
|
|
6009
6175
|
setValue(serialize(el));
|
|
6010
6176
|
}, []);
|
|
6011
|
-
const handleInput =
|
|
6177
|
+
const handleInput = useCallback3(() => {
|
|
6012
6178
|
if (isComposingRef.current) return;
|
|
6013
6179
|
syncFromDom();
|
|
6014
6180
|
}, [syncFromDom]);
|
|
6015
|
-
const handlePaste =
|
|
6181
|
+
const handlePaste = useCallback3(
|
|
6016
6182
|
(e) => {
|
|
6017
6183
|
e.preventDefault();
|
|
6018
6184
|
const text2 = e.clipboardData.getData("text/plain");
|
|
@@ -6022,7 +6188,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
6022
6188
|
},
|
|
6023
6189
|
[syncFromDom]
|
|
6024
6190
|
);
|
|
6025
|
-
const handleKeyDown =
|
|
6191
|
+
const handleKeyDown = useCallback3(
|
|
6026
6192
|
(e) => {
|
|
6027
6193
|
if (slashSuggestions.length > 0 && slashPrefix !== null) {
|
|
6028
6194
|
if (e.key === "Escape") {
|
|
@@ -6080,7 +6246,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
6080
6246
|
syncFromDom
|
|
6081
6247
|
]
|
|
6082
6248
|
);
|
|
6083
|
-
const handleEditorMouseDown =
|
|
6249
|
+
const handleEditorMouseDown = useCallback3(
|
|
6084
6250
|
(e) => {
|
|
6085
6251
|
const target = e.target;
|
|
6086
6252
|
const chip = target.closest("[data-token]");
|
|
@@ -6112,7 +6278,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
6112
6278
|
const id = requestAnimationFrame(() => focusEditor());
|
|
6113
6279
|
return () => cancelAnimationFrame(id);
|
|
6114
6280
|
}, [awaitingResponse, disabled, focusEditor]);
|
|
6115
|
-
const handleStop =
|
|
6281
|
+
const handleStop = useCallback3(async () => {
|
|
6116
6282
|
if (!onStop || isStopping) return;
|
|
6117
6283
|
setIsStopping(true);
|
|
6118
6284
|
try {
|
|
@@ -6272,7 +6438,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
6272
6438
|
ChatInput.displayName = "ChatInput";
|
|
6273
6439
|
|
|
6274
6440
|
// src/components/chat/chat-message-enhanced.tsx
|
|
6275
|
-
import React2, { forwardRef as forwardRef16, memo as memo2, useEffect as useEffect6, useMemo as
|
|
6441
|
+
import React2, { forwardRef as forwardRef16, memo as memo2, useEffect as useEffect6, useMemo as useMemo9, useRef as useRef5 } from "react";
|
|
6276
6442
|
|
|
6277
6443
|
// src/chat-protocol/card-marker.ts
|
|
6278
6444
|
var CARD_TYPE = "[a-zA-Z0-9_-]+";
|
|
@@ -6395,10 +6561,10 @@ function createUTCTimestamp() {
|
|
|
6395
6561
|
|
|
6396
6562
|
// src/components/chat/chat-context-picker.tsx
|
|
6397
6563
|
import { QueryErrorResetBoundary } from "@tanstack/react-query";
|
|
6398
|
-
import { Fragment as Fragment7, Suspense, useCallback as
|
|
6564
|
+
import { Fragment as Fragment7, Suspense, useCallback as useCallback5, useEffect as useEffect5, useLayoutEffect as useLayoutEffect3, useMemo as useMemo7, useRef as useRef4, useState as useState11 } from "react";
|
|
6399
6565
|
|
|
6400
6566
|
// src/components/chat/context-items-list.tsx
|
|
6401
|
-
import { Component, useCallback as
|
|
6567
|
+
import { Component, useCallback as useCallback4 } from "react";
|
|
6402
6568
|
import { Fragment as Fragment6, jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
6403
6569
|
var itemKey = (i) => `${i.type}:${i.id}`;
|
|
6404
6570
|
var CONTEXT_ROW_CLASS = "flex w-full items-center gap-2 border-b border-ods-border bg-ods-bg py-3 pl-4 pr-2 text-left outline-none transition-colors last:border-b-0 hover:bg-ods-bg-hover focus-visible:bg-ods-bg-hover [&_svg]:size-4 md:[&_svg]:size-6";
|
|
@@ -6455,7 +6621,7 @@ function ContextItemsList({
|
|
|
6455
6621
|
emptyLabel = "No results",
|
|
6456
6622
|
className
|
|
6457
6623
|
}) {
|
|
6458
|
-
const onScroll =
|
|
6624
|
+
const onScroll = useCallback4(
|
|
6459
6625
|
(e) => {
|
|
6460
6626
|
if (!hasMore || loadingMore || !onLoadMore) return;
|
|
6461
6627
|
const el = e.currentTarget;
|
|
@@ -6568,12 +6734,12 @@ function ChatContextPicker({
|
|
|
6568
6734
|
const [activeType, setActiveType] = useState11(null);
|
|
6569
6735
|
const [query, setQuery] = useState11("");
|
|
6570
6736
|
const [debouncedQuery, setDebouncedQuery] = useState11("");
|
|
6571
|
-
const rootRef =
|
|
6572
|
-
const searchRef =
|
|
6737
|
+
const rootRef = useRef4(null);
|
|
6738
|
+
const searchRef = useRef4(null);
|
|
6573
6739
|
const maxItems = config.maxItems ?? CHAT_CONTEXT_ITEMS_DEFAULT_MAX;
|
|
6574
6740
|
const atLimit = selectedItems.length >= maxItems;
|
|
6575
|
-
const selectedKeys =
|
|
6576
|
-
const mentionQueryRef =
|
|
6741
|
+
const selectedKeys = useMemo7(() => new Set(selectedItems.map(itemKey2)), [selectedItems]);
|
|
6742
|
+
const mentionQueryRef = useRef4(mentionQuery);
|
|
6577
6743
|
useEffect5(() => {
|
|
6578
6744
|
mentionQueryRef.current = mentionQuery;
|
|
6579
6745
|
});
|
|
@@ -6605,7 +6771,7 @@ function ChatContextPicker({
|
|
|
6605
6771
|
}, [query]);
|
|
6606
6772
|
const [measuredMaxH, setAvailMaxH] = useState11(void 0);
|
|
6607
6773
|
const availMaxH = open ? measuredMaxH : void 0;
|
|
6608
|
-
|
|
6774
|
+
useLayoutEffect3(() => {
|
|
6609
6775
|
if (!open) return void 0;
|
|
6610
6776
|
const measure = () => {
|
|
6611
6777
|
const el = rootRef.current;
|
|
@@ -6631,20 +6797,20 @@ function ChatContextPicker({
|
|
|
6631
6797
|
window.removeEventListener("resize", measure);
|
|
6632
6798
|
};
|
|
6633
6799
|
}, [open, view]);
|
|
6634
|
-
const openType =
|
|
6800
|
+
const openType = useCallback5((type) => {
|
|
6635
6801
|
setActiveType(type);
|
|
6636
6802
|
setQuery("");
|
|
6637
6803
|
setDebouncedQuery("");
|
|
6638
6804
|
setView("items");
|
|
6639
6805
|
}, []);
|
|
6640
|
-
const backToTypes =
|
|
6806
|
+
const backToTypes = useCallback5(() => {
|
|
6641
6807
|
setActiveType(null);
|
|
6642
6808
|
setQuery("");
|
|
6643
6809
|
setDebouncedQuery("");
|
|
6644
6810
|
setView("types");
|
|
6645
6811
|
}, []);
|
|
6646
6812
|
const typeFilter = (mentionQuery ?? "").trim().toLowerCase();
|
|
6647
|
-
const visibleTypes =
|
|
6813
|
+
const visibleTypes = useMemo7(
|
|
6648
6814
|
() => typeFilter ? config.entityTypes.filter((t) => t.label.toLowerCase().includes(typeFilter)) : config.entityTypes,
|
|
6649
6815
|
[config.entityTypes, typeFilter]
|
|
6650
6816
|
);
|
|
@@ -6915,7 +7081,7 @@ var remarkStripCitations = () => {
|
|
|
6915
7081
|
};
|
|
6916
7082
|
|
|
6917
7083
|
// src/components/chat/tool-execution-display.tsx
|
|
6918
|
-
import { forwardRef as forwardRef15, useMemo as
|
|
7084
|
+
import { forwardRef as forwardRef15, useMemo as useMemo8, useState as useState12 } from "react";
|
|
6919
7085
|
import { Fragment as Fragment9, jsx as jsx34, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
6920
7086
|
var COMMAND_BODY_KEYS2 = new Set(COMMAND_BODY_ARG_KEYS);
|
|
6921
7087
|
var ToolExecutionDisplay = forwardRef15(
|
|
@@ -6928,7 +7094,7 @@ var ToolExecutionDisplay = forwardRef15(
|
|
|
6928
7094
|
const isExecuted = message.type === "EXECUTED_TOOL";
|
|
6929
7095
|
const integratedToolType = message.integratedToolType || "OPENFRAME";
|
|
6930
7096
|
const previewText = variant === "client" ? message.toolExplanation?.trim() : message.toolTitle?.trim();
|
|
6931
|
-
const argEntries =
|
|
7097
|
+
const argEntries = useMemo8(() => {
|
|
6932
7098
|
if (!message.parameters || typeof message.parameters !== "object") return [];
|
|
6933
7099
|
const entries = Object.entries(message.parameters).filter(([, v]) => v !== null && v !== void 0 && v !== "");
|
|
6934
7100
|
if (variant === "client") {
|
|
@@ -7078,10 +7244,10 @@ var ChatMessageEnhanced = forwardRef16(
|
|
|
7078
7244
|
const isError = role === "error";
|
|
7079
7245
|
const authorType = authorTypeProp ?? (isUser ? "user" : assistantType === "mingo" ? "mingo" : "fae");
|
|
7080
7246
|
const hasMarkerSupport = !!renderEntityCard;
|
|
7081
|
-
const segments =
|
|
7082
|
-
const askRuns =
|
|
7247
|
+
const segments = useMemo9(() => normalizeContent(content), [content]);
|
|
7248
|
+
const askRuns = useMemo9(() => groupAskRuns(segments), [segments]);
|
|
7083
7249
|
const hasMentionSupport = !!renderMention;
|
|
7084
|
-
const inlineMentionIds =
|
|
7250
|
+
const inlineMentionIds = useMemo9(() => {
|
|
7085
7251
|
const ids = /* @__PURE__ */ new Set();
|
|
7086
7252
|
if (!hasMentionSupport) return ids;
|
|
7087
7253
|
for (const seg of segments) {
|
|
@@ -7090,26 +7256,26 @@ var ChatMessageEnhanced = forwardRef16(
|
|
|
7090
7256
|
}
|
|
7091
7257
|
return ids;
|
|
7092
7258
|
}, [hasMentionSupport, segments]);
|
|
7093
|
-
const stripContextItems =
|
|
7259
|
+
const stripContextItems = useMemo9(
|
|
7094
7260
|
() => inlineMentionIds.size > 0 && contextItems ? contextItems.filter((it) => !inlineMentionIds.has(it.id)) : contextItems,
|
|
7095
7261
|
[contextItems, inlineMentionIds]
|
|
7096
7262
|
);
|
|
7097
|
-
const cardRemarkPlugins =
|
|
7263
|
+
const cardRemarkPlugins = useMemo9(
|
|
7098
7264
|
() => [
|
|
7099
7265
|
...hasMarkerSupport ? [remarkCardLinks, remarkStripCitations] : [],
|
|
7100
7266
|
...hasMentionSupport ? [remarkMentionChips] : []
|
|
7101
7267
|
],
|
|
7102
7268
|
[hasMarkerSupport, hasMentionSupport]
|
|
7103
7269
|
);
|
|
7104
|
-
const renderedCardNodeCache =
|
|
7270
|
+
const renderedCardNodeCache = useRef5(
|
|
7105
7271
|
/* @__PURE__ */ new Map()
|
|
7106
7272
|
);
|
|
7107
|
-
const refByKey =
|
|
7273
|
+
const refByKey = useMemo9(() => {
|
|
7108
7274
|
const byKey2 = /* @__PURE__ */ new Map();
|
|
7109
7275
|
for (const described of refs ?? []) byKey2.set(`${described.type}:${described.id}`, described);
|
|
7110
7276
|
return byKey2;
|
|
7111
7277
|
}, [refs]);
|
|
7112
|
-
const renderingPlan =
|
|
7278
|
+
const renderingPlan = useMemo9(() => {
|
|
7113
7279
|
if (!hasMarkerSupport) return null;
|
|
7114
7280
|
const render2 = renderEntityCard;
|
|
7115
7281
|
const inlineByKey = /* @__PURE__ */ new Map();
|
|
@@ -7183,9 +7349,9 @@ var ChatMessageEnhanced = forwardRef16(
|
|
|
7183
7349
|
if (!usedKeys.has(k)) cache.delete(k);
|
|
7184
7350
|
}
|
|
7185
7351
|
}, [renderingPlan]);
|
|
7186
|
-
const renderingPlanRef =
|
|
7352
|
+
const renderingPlanRef = useRef5(renderingPlan);
|
|
7187
7353
|
renderingPlanRef.current = renderingPlan;
|
|
7188
|
-
const cardComponentOverrides =
|
|
7354
|
+
const cardComponentOverrides = useMemo9(() => {
|
|
7189
7355
|
if (!hasMarkerSupport && !hasMentionSupport) return void 0;
|
|
7190
7356
|
return {
|
|
7191
7357
|
// Override `<a>` to detect `card://` URLs emitted by `remarkCardLinks`.
|
|
@@ -7411,13 +7577,13 @@ MemoizedChatMessageEnhanced.displayName = "MemoizedChatMessageEnhanced";
|
|
|
7411
7577
|
|
|
7412
7578
|
// src/components/chat/chat-message-list.tsx
|
|
7413
7579
|
import {
|
|
7414
|
-
useRef as
|
|
7580
|
+
useRef as useRef6,
|
|
7415
7581
|
useState as useState14,
|
|
7416
|
-
useCallback as
|
|
7582
|
+
useCallback as useCallback6,
|
|
7417
7583
|
useEffect as useEffect8,
|
|
7418
|
-
useLayoutEffect as
|
|
7584
|
+
useLayoutEffect as useLayoutEffect4,
|
|
7419
7585
|
useImperativeHandle as useImperativeHandle2,
|
|
7420
|
-
useMemo as
|
|
7586
|
+
useMemo as useMemo11,
|
|
7421
7587
|
forwardRef as forwardRef17
|
|
7422
7588
|
} from "react";
|
|
7423
7589
|
import { useStickToBottom } from "use-stick-to-bottom";
|
|
@@ -7490,7 +7656,7 @@ function ChatMessageListSkeleton({
|
|
|
7490
7656
|
}
|
|
7491
7657
|
|
|
7492
7658
|
// src/components/chat/cycling-phrase.tsx
|
|
7493
|
-
import { useEffect as useEffect7, useMemo as
|
|
7659
|
+
import { useEffect as useEffect7, useMemo as useMemo10, useState as useState13 } from "react";
|
|
7494
7660
|
import { jsx as jsx37, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
7495
7661
|
var BLINK_KEYFRAMES = `
|
|
7496
7662
|
@keyframes cyclingCursorBlink {
|
|
@@ -7504,7 +7670,7 @@ function CyclingPhrase({ words, className, charMs = 60, holdMs = 4500 }) {
|
|
|
7504
7670
|
const target = words[wordIndex] ?? "";
|
|
7505
7671
|
const holding = words.length > 0 && cursor >= Math.max(text2.length, target.length);
|
|
7506
7672
|
const shownText = holding ? target : text2;
|
|
7507
|
-
const placeholder =
|
|
7673
|
+
const placeholder = useMemo10(
|
|
7508
7674
|
() => words.reduce((longest, w) => w.length > longest.length ? w : longest, ""),
|
|
7509
7675
|
[words]
|
|
7510
7676
|
);
|
|
@@ -7622,17 +7788,17 @@ var ChatMessageList = forwardRef17(
|
|
|
7622
7788
|
resize: "smooth",
|
|
7623
7789
|
initial: false
|
|
7624
7790
|
});
|
|
7625
|
-
const lastUserMessageIndex =
|
|
7791
|
+
const lastUserMessageIndex = useMemo11(() => {
|
|
7626
7792
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
7627
7793
|
if (messages[i].role === "user") return i;
|
|
7628
7794
|
}
|
|
7629
7795
|
return -1;
|
|
7630
7796
|
}, [messages]);
|
|
7631
|
-
const overlayOpenRef =
|
|
7632
|
-
const wasAtBottomOnOpenRef =
|
|
7633
|
-
const isAtBottomRef =
|
|
7797
|
+
const overlayOpenRef = useRef6(false);
|
|
7798
|
+
const wasAtBottomOnOpenRef = useRef6(false);
|
|
7799
|
+
const isAtBottomRef = useRef6(isAtBottom);
|
|
7634
7800
|
isAtBottomRef.current = isAtBottom;
|
|
7635
|
-
const handleOverlayOpenChange =
|
|
7801
|
+
const handleOverlayOpenChange = useCallback6(
|
|
7636
7802
|
(hasOpenOverlay) => {
|
|
7637
7803
|
overlayOpenRef.current = hasOpenOverlay;
|
|
7638
7804
|
if (hasOpenOverlay) {
|
|
@@ -7646,17 +7812,17 @@ var ChatMessageList = forwardRef17(
|
|
|
7646
7812
|
},
|
|
7647
7813
|
[scrollToBottom, stopScroll]
|
|
7648
7814
|
);
|
|
7649
|
-
const sentinelRef =
|
|
7650
|
-
const onLoadMoreRef =
|
|
7815
|
+
const sentinelRef = useRef6(null);
|
|
7816
|
+
const onLoadMoreRef = useRef6(onLoadMore);
|
|
7651
7817
|
onLoadMoreRef.current = onLoadMore;
|
|
7652
|
-
const isFetchingRef =
|
|
7818
|
+
const isFetchingRef = useRef6(isFetchingNextPage);
|
|
7653
7819
|
isFetchingRef.current = isFetchingNextPage;
|
|
7654
|
-
const dialogIdRef =
|
|
7820
|
+
const dialogIdRef = useRef6(dialogId);
|
|
7655
7821
|
dialogIdRef.current = dialogId;
|
|
7656
|
-
const followBottomRef =
|
|
7822
|
+
const followBottomRef = useRef6(false);
|
|
7657
7823
|
const [atBottom, setAtBottom] = useState14(true);
|
|
7658
|
-
const prevRenderRef =
|
|
7659
|
-
const loadOlderAnchorRef =
|
|
7824
|
+
const prevRenderRef = useRef6({ dialogId: void 0, messageCount: 0, lastMessageId: void 0 });
|
|
7825
|
+
const loadOlderAnchorRef = useRef6(null);
|
|
7660
7826
|
useEffect8(() => {
|
|
7661
7827
|
if (!autoScroll) return;
|
|
7662
7828
|
const dialogChanged = dialogId !== prevRenderRef.current.dialogId;
|
|
@@ -7786,8 +7952,8 @@ var ChatMessageList = forwardRef17(
|
|
|
7786
7952
|
window.removeEventListener("blur", endPointer);
|
|
7787
7953
|
};
|
|
7788
7954
|
}, [autoScroll, scrollRef, contentRef, scrollToBottom, stopScroll, isLoading]);
|
|
7789
|
-
const pinPrevHeightRef =
|
|
7790
|
-
|
|
7955
|
+
const pinPrevHeightRef = useRef6(0);
|
|
7956
|
+
useLayoutEffect4(() => {
|
|
7791
7957
|
if (!pinBottom) {
|
|
7792
7958
|
pinPrevHeightRef.current = 0;
|
|
7793
7959
|
return;
|
|
@@ -7798,7 +7964,7 @@ var ChatMessageList = forwardRef17(
|
|
|
7798
7964
|
pinPrevHeightRef.current = el.scrollHeight;
|
|
7799
7965
|
el.scrollTop = el.scrollHeight;
|
|
7800
7966
|
}, [pinBottom, messages, isTyping, pendingApprovals, scrollRef]);
|
|
7801
|
-
|
|
7967
|
+
useLayoutEffect4(() => {
|
|
7802
7968
|
const el = scrollRef.current;
|
|
7803
7969
|
const anchor = loadOlderAnchorRef.current;
|
|
7804
7970
|
if (!el || !anchor) return;
|
|
@@ -7811,8 +7977,8 @@ var ChatMessageList = forwardRef17(
|
|
|
7811
7977
|
loadOlderAnchorRef.current = null;
|
|
7812
7978
|
el.scrollTop = anchor.scrollTop + addedHeight;
|
|
7813
7979
|
}, [messages, dialogId, scrollRef]);
|
|
7814
|
-
const messageElsRef =
|
|
7815
|
-
const refCallbacksRef =
|
|
7980
|
+
const messageElsRef = useRef6(/* @__PURE__ */ new Map());
|
|
7981
|
+
const refCallbacksRef = useRef6(/* @__PURE__ */ new Map());
|
|
7816
7982
|
const getRegisterMessageEl = (id) => {
|
|
7817
7983
|
let cb = refCallbacksRef.current.get(id);
|
|
7818
7984
|
if (cb) return cb;
|
|
@@ -7827,12 +7993,12 @@ var ChatMessageList = forwardRef17(
|
|
|
7827
7993
|
refCallbacksRef.current.set(id, cb);
|
|
7828
7994
|
return cb;
|
|
7829
7995
|
};
|
|
7830
|
-
const scrolledIdsRef =
|
|
7996
|
+
const scrolledIdsRef = useRef6(null);
|
|
7831
7997
|
if (scrolledIdsRef.current === null) {
|
|
7832
7998
|
scrolledIdsRef.current = new Set(messages.filter((m) => hasNonEmptyContent(m.content)).map((m) => m.id));
|
|
7833
7999
|
}
|
|
7834
|
-
const anchorWatcherRef =
|
|
7835
|
-
|
|
8000
|
+
const anchorWatcherRef = useRef6(null);
|
|
8001
|
+
useLayoutEffect4(() => {
|
|
7836
8002
|
if (!autoScroll) return;
|
|
7837
8003
|
if (overlayOpenRef.current) return;
|
|
7838
8004
|
const last = messages[messages.length - 1];
|
|
@@ -7902,13 +8068,13 @@ var ChatMessageList = forwardRef17(
|
|
|
7902
8068
|
return () => observer.disconnect();
|
|
7903
8069
|
}, [hasNextPage, isFetchingNextPage, scrollRef, isLoading]);
|
|
7904
8070
|
useImperativeHandle2(ref, () => scrollRef.current, [scrollRef, isLoading]);
|
|
7905
|
-
const setScrollRef =
|
|
8071
|
+
const setScrollRef = useCallback6(
|
|
7906
8072
|
(el) => {
|
|
7907
8073
|
scrollRef(el);
|
|
7908
8074
|
},
|
|
7909
8075
|
[scrollRef]
|
|
7910
8076
|
);
|
|
7911
|
-
const setContentRef =
|
|
8077
|
+
const setContentRef = useCallback6(
|
|
7912
8078
|
(el) => {
|
|
7913
8079
|
contentRef(el);
|
|
7914
8080
|
},
|
|
@@ -8320,18 +8486,18 @@ function QuickActionChipFromData({
|
|
|
8320
8486
|
}
|
|
8321
8487
|
|
|
8322
8488
|
// src/components/chat/quick-action-marquee.tsx
|
|
8323
|
-
import { useMemo as
|
|
8489
|
+
import { useMemo as useMemo14 } from "react";
|
|
8324
8490
|
|
|
8325
8491
|
// src/components/chat/quick-action-wall.tsx
|
|
8326
|
-
import { useRef as
|
|
8492
|
+
import { useRef as useRef8, useState as useState17, useEffect as useEffect10, useMemo as useMemo13 } from "react";
|
|
8327
8493
|
|
|
8328
8494
|
// src/components/ui/marquee-wall.tsx
|
|
8329
8495
|
import {
|
|
8330
|
-
useCallback as
|
|
8496
|
+
useCallback as useCallback7,
|
|
8331
8497
|
useEffect as useEffect9,
|
|
8332
|
-
useLayoutEffect as
|
|
8333
|
-
useMemo as
|
|
8334
|
-
useRef as
|
|
8498
|
+
useLayoutEffect as useLayoutEffect5,
|
|
8499
|
+
useMemo as useMemo12,
|
|
8500
|
+
useRef as useRef7,
|
|
8335
8501
|
useState as useState16,
|
|
8336
8502
|
useSyncExternalStore as useSyncExternalStore2
|
|
8337
8503
|
} from "react";
|
|
@@ -8465,16 +8631,16 @@ function MarqueeWall({
|
|
|
8465
8631
|
sync,
|
|
8466
8632
|
trackId
|
|
8467
8633
|
}) {
|
|
8468
|
-
const fades =
|
|
8634
|
+
const fades = useMemo12(() => normalizeFades(fade), [fade]);
|
|
8469
8635
|
const axis = axisProp ?? (fades.includes("top") || fades.includes("bottom") ? "y" : "x");
|
|
8470
|
-
const containerRef =
|
|
8471
|
-
const trackRef =
|
|
8472
|
-
const copyRef =
|
|
8636
|
+
const containerRef = useRef7(null);
|
|
8637
|
+
const trackRef = useRef7(null);
|
|
8638
|
+
const copyRef = useRef7(null);
|
|
8473
8639
|
const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)") ?? false;
|
|
8474
8640
|
const [overflows, setOverflows] = useState16(false);
|
|
8475
|
-
const copySizeRef =
|
|
8476
|
-
const wrapSizeRef =
|
|
8477
|
-
const measure =
|
|
8641
|
+
const copySizeRef = useRef7(0);
|
|
8642
|
+
const wrapSizeRef = useRef7(0);
|
|
8643
|
+
const measure = useCallback7(() => {
|
|
8478
8644
|
const container = containerRef.current;
|
|
8479
8645
|
const copy = copyRef.current;
|
|
8480
8646
|
if (!container || !copy) return;
|
|
@@ -8507,22 +8673,22 @@ function MarqueeWall({
|
|
|
8507
8673
|
io.observe(el);
|
|
8508
8674
|
return () => io.disconnect();
|
|
8509
8675
|
}, []);
|
|
8510
|
-
const pointerInsideRef =
|
|
8511
|
-
const clearPointerInside =
|
|
8676
|
+
const pointerInsideRef = useRef7(false);
|
|
8677
|
+
const clearPointerInside = useCallback7(() => {
|
|
8512
8678
|
pointerInsideRef.current = false;
|
|
8513
8679
|
}, []);
|
|
8514
|
-
const onPointerEnter =
|
|
8680
|
+
const onPointerEnter = useCallback7((e) => {
|
|
8515
8681
|
if (e.pointerType === "touch") return;
|
|
8516
8682
|
pointerInsideRef.current = true;
|
|
8517
8683
|
}, []);
|
|
8518
|
-
const onPointerLeave =
|
|
8684
|
+
const onPointerLeave = useCallback7((e) => {
|
|
8519
8685
|
if (e.pointerType === "touch") return;
|
|
8520
8686
|
pointerInsideRef.current = false;
|
|
8521
8687
|
}, []);
|
|
8522
8688
|
useResetOnPageHidden(clearPointerInside);
|
|
8523
|
-
const draggingRef =
|
|
8524
|
-
const dragSuppressUntilRef =
|
|
8525
|
-
const applyTransform =
|
|
8689
|
+
const draggingRef = useRef7(false);
|
|
8690
|
+
const dragSuppressUntilRef = useRef7(0);
|
|
8691
|
+
const applyTransform = useCallback7(
|
|
8526
8692
|
(pos) => {
|
|
8527
8693
|
const track = trackRef.current;
|
|
8528
8694
|
if (!track) return;
|
|
@@ -8538,7 +8704,7 @@ function MarqueeWall({
|
|
|
8538
8704
|
},
|
|
8539
8705
|
[axis, reverse, trackId]
|
|
8540
8706
|
);
|
|
8541
|
-
const applyPos =
|
|
8707
|
+
const applyPos = useCallback7(
|
|
8542
8708
|
(pos) => {
|
|
8543
8709
|
if (sync) {
|
|
8544
8710
|
sync.publish(pos);
|
|
@@ -8554,7 +8720,7 @@ function MarqueeWall({
|
|
|
8554
8720
|
if (track) track.style.transform = "";
|
|
8555
8721
|
if (trackId) MARQUEE_TRACK_OFFSETS.set(trackId, ZERO_OFFSET);
|
|
8556
8722
|
}, [marqueeMounted, trackId]);
|
|
8557
|
-
const applyTransformRef =
|
|
8723
|
+
const applyTransformRef = useRef7(applyTransform);
|
|
8558
8724
|
useEffect9(() => {
|
|
8559
8725
|
applyTransformRef.current = applyTransform;
|
|
8560
8726
|
});
|
|
@@ -8582,7 +8748,7 @@ function MarqueeWall({
|
|
|
8582
8748
|
// (engine seeds from readBack on activation) instead of restarting at 0.
|
|
8583
8749
|
readBack: sync ? () => sync.readPosition() : void 0
|
|
8584
8750
|
});
|
|
8585
|
-
|
|
8751
|
+
useLayoutEffect5(() => {
|
|
8586
8752
|
if (!marqueeMounted) {
|
|
8587
8753
|
posRef.current = 0;
|
|
8588
8754
|
return;
|
|
@@ -8592,10 +8758,10 @@ function MarqueeWall({
|
|
|
8592
8758
|
}
|
|
8593
8759
|
}, [marqueeMounted, reverse, posRef]);
|
|
8594
8760
|
const DRAG_RESUME_MS = 1200;
|
|
8595
|
-
const dragStartRef =
|
|
8596
|
-
const dragMovedRef =
|
|
8597
|
-
const suppressClickRef =
|
|
8598
|
-
const onDragPointerDown =
|
|
8761
|
+
const dragStartRef = useRef7({ coord: 0, pos: 0 });
|
|
8762
|
+
const dragMovedRef = useRef7(false);
|
|
8763
|
+
const suppressClickRef = useRef7(false);
|
|
8764
|
+
const onDragPointerDown = useCallback7(
|
|
8599
8765
|
(e) => {
|
|
8600
8766
|
if (!marqueeMounted) return;
|
|
8601
8767
|
draggingRef.current = true;
|
|
@@ -8605,7 +8771,7 @@ function MarqueeWall({
|
|
|
8605
8771
|
},
|
|
8606
8772
|
[marqueeMounted, axis, posRef]
|
|
8607
8773
|
);
|
|
8608
|
-
const onDragPointerMove =
|
|
8774
|
+
const onDragPointerMove = useCallback7(
|
|
8609
8775
|
(e) => {
|
|
8610
8776
|
if (!draggingRef.current) return;
|
|
8611
8777
|
const delta = (axis === "y" ? e.clientY : e.clientX) - dragStartRef.current.coord;
|
|
@@ -8622,7 +8788,7 @@ function MarqueeWall({
|
|
|
8622
8788
|
},
|
|
8623
8789
|
[axis, reverse, wrap, posRef, applyPos]
|
|
8624
8790
|
);
|
|
8625
|
-
const onDragPointerUp =
|
|
8791
|
+
const onDragPointerUp = useCallback7((e) => {
|
|
8626
8792
|
if (!draggingRef.current) return;
|
|
8627
8793
|
draggingRef.current = false;
|
|
8628
8794
|
if (dragMovedRef.current) suppressClickRef.current = true;
|
|
@@ -8634,14 +8800,14 @@ function MarqueeWall({
|
|
|
8634
8800
|
}
|
|
8635
8801
|
}
|
|
8636
8802
|
}, []);
|
|
8637
|
-
const onDragPointerLeave =
|
|
8803
|
+
const onDragPointerLeave = useCallback7(
|
|
8638
8804
|
(e) => {
|
|
8639
8805
|
onPointerLeave(e);
|
|
8640
8806
|
if (draggingRef.current && !dragMovedRef.current) draggingRef.current = false;
|
|
8641
8807
|
},
|
|
8642
8808
|
[onPointerLeave]
|
|
8643
8809
|
);
|
|
8644
|
-
const onDragClickCapture =
|
|
8810
|
+
const onDragClickCapture = useCallback7((e) => {
|
|
8645
8811
|
if (suppressClickRef.current) {
|
|
8646
8812
|
suppressClickRef.current = false;
|
|
8647
8813
|
e.preventDefault();
|
|
@@ -8759,7 +8925,7 @@ function QuickActionWall({
|
|
|
8759
8925
|
contentClassName,
|
|
8760
8926
|
sync
|
|
8761
8927
|
}) {
|
|
8762
|
-
const brickRef =
|
|
8928
|
+
const brickRef = useRef8(null);
|
|
8763
8929
|
const [brickWidth, setBrickWidth] = useState17(0);
|
|
8764
8930
|
const [chipWidth, setChipWidth] = useState17(0);
|
|
8765
8931
|
useEffect10(() => {
|
|
@@ -8781,7 +8947,7 @@ function QuickActionWall({
|
|
|
8781
8947
|
return () => ro.disconnect();
|
|
8782
8948
|
}, [chips]);
|
|
8783
8949
|
const padTarget = rows ? void 0 : minChips;
|
|
8784
|
-
const track =
|
|
8950
|
+
const track = useMemo13(() => {
|
|
8785
8951
|
if (!padTarget || chips.length === 0 || chips.length >= padTarget) return chips;
|
|
8786
8952
|
const repeats = Math.ceil(padTarget / chips.length);
|
|
8787
8953
|
return Array.from(
|
|
@@ -8887,7 +9053,7 @@ function QuickActionMarquee({
|
|
|
8887
9053
|
sync,
|
|
8888
9054
|
className
|
|
8889
9055
|
}) {
|
|
8890
|
-
const chips =
|
|
9056
|
+
const chips = useMemo14(
|
|
8891
9057
|
() => items.map((item) => ({
|
|
8892
9058
|
id: item.id,
|
|
8893
9059
|
label: item.label,
|
|
@@ -8919,12 +9085,12 @@ function QuickActionMarquee({
|
|
|
8919
9085
|
import { forwardRef as forwardRef19 } from "react";
|
|
8920
9086
|
|
|
8921
9087
|
// src/components/ui/scroll-fade.tsx
|
|
8922
|
-
import { useCallback as
|
|
9088
|
+
import { useCallback as useCallback8, useLayoutEffect as useLayoutEffect6, useRef as useRef9, useState as useState18 } from "react";
|
|
8923
9089
|
import { jsx as jsx46, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
8924
9090
|
function useScrollFade(axis = "vertical") {
|
|
8925
|
-
const scrollRef =
|
|
9091
|
+
const scrollRef = useRef9(null);
|
|
8926
9092
|
const [fade, setFade] = useState18({ top: false, bottom: false, left: false, right: false });
|
|
8927
|
-
const update =
|
|
9093
|
+
const update = useCallback8(() => {
|
|
8928
9094
|
const el = scrollRef.current;
|
|
8929
9095
|
if (!el) return;
|
|
8930
9096
|
setFade((prev) => {
|
|
@@ -8937,7 +9103,7 @@ function useScrollFade(axis = "vertical") {
|
|
|
8937
9103
|
return prev.top === top && prev.bottom === bottom && prev.left === left && prev.right === right ? prev : { top, bottom, left, right };
|
|
8938
9104
|
});
|
|
8939
9105
|
}, [axis]);
|
|
8940
|
-
|
|
9106
|
+
useLayoutEffect6(() => {
|
|
8941
9107
|
update();
|
|
8942
9108
|
const el = scrollRef.current;
|
|
8943
9109
|
if (!el) return void 0;
|
|
@@ -9232,10 +9398,10 @@ function MingoOnboardingListSkeleton({ rows = 6, className }) {
|
|
|
9232
9398
|
}
|
|
9233
9399
|
|
|
9234
9400
|
// src/components/chat/mingo-welcome.tsx
|
|
9235
|
-
import { useCallback as
|
|
9401
|
+
import { useCallback as useCallback9, useMemo as useMemo16, useState as useState20 } from "react";
|
|
9236
9402
|
|
|
9237
9403
|
// src/components/chat/mingo-chat-history.tsx
|
|
9238
|
-
import { useState as useState19, useMemo as
|
|
9404
|
+
import { useState as useState19, useMemo as useMemo15, useRef as useRef10, useEffect as useEffect11 } from "react";
|
|
9239
9405
|
|
|
9240
9406
|
// src/components/chat/chat-list-empty-state.tsx
|
|
9241
9407
|
import { jsx as jsx50, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
@@ -9466,12 +9632,12 @@ function MingoChatHistory({
|
|
|
9466
9632
|
onLoadMore,
|
|
9467
9633
|
className
|
|
9468
9634
|
}) {
|
|
9469
|
-
const groups =
|
|
9635
|
+
const groups = useMemo15(() => groupDialogs(dialogs), [dialogs]);
|
|
9470
9636
|
const noSearchResults = groups.length === 0 && !!searchQuery?.trim();
|
|
9471
9637
|
const { scrollRef, fadeTop, fadeBottom, update: updateFade } = useScrollFade();
|
|
9472
|
-
const sentinelRef =
|
|
9473
|
-
const onLoadMoreRef =
|
|
9474
|
-
const isLoadingMoreRef =
|
|
9638
|
+
const sentinelRef = useRef10(null);
|
|
9639
|
+
const onLoadMoreRef = useRef10(onLoadMore);
|
|
9640
|
+
const isLoadingMoreRef = useRef10(isLoadingMore);
|
|
9475
9641
|
useEffect11(() => {
|
|
9476
9642
|
onLoadMoreRef.current = onLoadMore;
|
|
9477
9643
|
isLoadingMoreRef.current = isLoadingMore;
|
|
@@ -9565,7 +9731,7 @@ function MingoWelcome({
|
|
|
9565
9731
|
const resolvedPromo = hasExistingChats ? null : promo === void 0 ? onStartGuideChat ? DEFAULT_PROMO : null : promo;
|
|
9566
9732
|
const hydrated = useIsHydrated();
|
|
9567
9733
|
const [dismissedThisSession, setPromoDismissed] = useState20(false);
|
|
9568
|
-
const storedDismissed =
|
|
9734
|
+
const storedDismissed = useMemo16(() => {
|
|
9569
9735
|
if (!hydrated || !resolvedPromo) return false;
|
|
9570
9736
|
try {
|
|
9571
9737
|
const store = promoStorage === "session" ? window.sessionStorage : window.localStorage;
|
|
@@ -9575,7 +9741,7 @@ function MingoWelcome({
|
|
|
9575
9741
|
}
|
|
9576
9742
|
}, [hydrated, resolvedPromo, promoStorage, promoStorageKey]);
|
|
9577
9743
|
const promoDismissed = dismissedThisSession || storedDismissed;
|
|
9578
|
-
const dismissPromo =
|
|
9744
|
+
const dismissPromo = useCallback9(() => {
|
|
9579
9745
|
setPromoDismissed(true);
|
|
9580
9746
|
try {
|
|
9581
9747
|
const store = promoStorage === "session" ? window.sessionStorage : window.localStorage;
|
|
@@ -9690,7 +9856,7 @@ function MingoWelcome({
|
|
|
9690
9856
|
}
|
|
9691
9857
|
|
|
9692
9858
|
// src/components/chat/guide-welcome.tsx
|
|
9693
|
-
import { useMemo as
|
|
9859
|
+
import { useMemo as useMemo17 } from "react";
|
|
9694
9860
|
import { jsx as jsx53, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
9695
9861
|
var DEFAULT_TITLE = "Guide Mode Chat";
|
|
9696
9862
|
function GuideWelcome({
|
|
@@ -9707,7 +9873,7 @@ function GuideWelcome({
|
|
|
9707
9873
|
className
|
|
9708
9874
|
}) {
|
|
9709
9875
|
const { scrollRef, fadeTop, fadeBottom, update: updateScrollFade } = useScrollFade();
|
|
9710
|
-
const chipItems =
|
|
9876
|
+
const chipItems = useMemo17(
|
|
9711
9877
|
() => quickActions.map((action) => ({
|
|
9712
9878
|
id: action.id,
|
|
9713
9879
|
label: action.label,
|
|
@@ -9974,7 +10140,7 @@ function MingoHistoryRail({
|
|
|
9974
10140
|
import { useState as useState22 } from "react";
|
|
9975
10141
|
|
|
9976
10142
|
// src/components/ui/modal-v2.tsx
|
|
9977
|
-
import { createContext as createContext4, forwardRef as forwardRef20, useContext as useContext4, useRef as
|
|
10143
|
+
import { createContext as createContext4, forwardRef as forwardRef20, useContext as useContext4, useRef as useRef11, useEffect as useEffect12, useState as useState21 } from "react";
|
|
9978
10144
|
import { RemoveScroll } from "react-remove-scroll";
|
|
9979
10145
|
import { jsx as jsx57, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
9980
10146
|
var ANIMATION_DURATION = 200;
|
|
@@ -9989,9 +10155,9 @@ var isInPortaledLayer = (node) => node instanceof Element && node.closest('[data
|
|
|
9989
10155
|
var Modal = forwardRef20(
|
|
9990
10156
|
({ isOpen, onClose, children, className, size: size2 = "default" }, ref) => {
|
|
9991
10157
|
const [isMounted, setIsMounted] = useState21(isOpen);
|
|
9992
|
-
const panelRef =
|
|
9993
|
-
const restoreFocusRef =
|
|
9994
|
-
const stackIdRef =
|
|
10158
|
+
const panelRef = useRef11(null);
|
|
10159
|
+
const restoreFocusRef = useRef11(null);
|
|
10160
|
+
const stackIdRef = useRef11(/* @__PURE__ */ Symbol("modal"));
|
|
9995
10161
|
useEffect12(() => {
|
|
9996
10162
|
if (!isOpen) return void 0;
|
|
9997
10163
|
const stackId = stackIdRef.current;
|
|
@@ -10325,7 +10491,7 @@ var ChatHeaderIconButton = forwardRef21(
|
|
|
10325
10491
|
ChatHeaderIconButton.displayName = "ChatHeaderIconButton";
|
|
10326
10492
|
|
|
10327
10493
|
// src/components/chat/chat-header-search-field.tsx
|
|
10328
|
-
import { useState as useState23, useRef as
|
|
10494
|
+
import { useState as useState23, useRef as useRef12, useEffect as useEffect13, useCallback as useCallback10 } from "react";
|
|
10329
10495
|
import { jsx as jsx60, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
10330
10496
|
function ChatHeaderSearchField({
|
|
10331
10497
|
initialValue,
|
|
@@ -10336,21 +10502,21 @@ function ChatHeaderSearchField({
|
|
|
10336
10502
|
}) {
|
|
10337
10503
|
const [value, setValue] = useState23(initialValue ?? "");
|
|
10338
10504
|
const debounced = useDebounce(value, 300);
|
|
10339
|
-
const lastEmitted =
|
|
10505
|
+
const lastEmitted = useRef12(initialValue ?? "");
|
|
10340
10506
|
const [exiting, setExiting] = useState23(false);
|
|
10341
|
-
const collapsedRef =
|
|
10507
|
+
const collapsedRef = useRef12(false);
|
|
10342
10508
|
useEffect13(() => {
|
|
10343
10509
|
if (exiting) return;
|
|
10344
10510
|
if (debounced === lastEmitted.current) return;
|
|
10345
10511
|
lastEmitted.current = debounced;
|
|
10346
10512
|
onSearchChange(debounced);
|
|
10347
10513
|
}, [debounced, exiting, onSearchChange]);
|
|
10348
|
-
const finishCollapse =
|
|
10514
|
+
const finishCollapse = useCallback10(() => {
|
|
10349
10515
|
if (collapsedRef.current) return;
|
|
10350
10516
|
collapsedRef.current = true;
|
|
10351
10517
|
onCollapse?.();
|
|
10352
10518
|
}, [onCollapse]);
|
|
10353
|
-
const beginCollapse =
|
|
10519
|
+
const beginCollapse = useCallback10(() => {
|
|
10354
10520
|
setExiting(true);
|
|
10355
10521
|
}, []);
|
|
10356
10522
|
useEffect13(() => {
|
|
@@ -10585,10 +10751,10 @@ function ChatPanelHeader({
|
|
|
10585
10751
|
}
|
|
10586
10752
|
|
|
10587
10753
|
// src/components/chat/chat-composer.tsx
|
|
10588
|
-
import { useCallback as
|
|
10754
|
+
import { useCallback as useCallback11, useMemo as useMemo19 } from "react";
|
|
10589
10755
|
|
|
10590
10756
|
// src/components/chat/chat-attachment-bar.tsx
|
|
10591
|
-
import { useEffect as useEffect14, useMemo as
|
|
10757
|
+
import { useEffect as useEffect14, useMemo as useMemo18, useRef as useRef13 } from "react";
|
|
10592
10758
|
|
|
10593
10759
|
// src/components/chat/utils/chat-attachment-markdown.ts
|
|
10594
10760
|
var CHAT_ATTACHMENT_VIEW_URL_PREFIX = "/api/storage/view/chat-attachments/";
|
|
@@ -10660,7 +10826,7 @@ function ChatAttachmentAddButton({
|
|
|
10660
10826
|
disabled = false,
|
|
10661
10827
|
size: size2 = "default"
|
|
10662
10828
|
}) {
|
|
10663
|
-
const fileInputRef =
|
|
10829
|
+
const fileInputRef = useRef13(null);
|
|
10664
10830
|
const compact = size2 === "compact";
|
|
10665
10831
|
const boxClass = compact ? "h-6 w-6" : "h-7 w-7";
|
|
10666
10832
|
if (!attachmentsEnabled) {
|
|
@@ -10797,7 +10963,7 @@ function extLabel(fileName) {
|
|
|
10797
10963
|
}
|
|
10798
10964
|
var objectUrlByFile = /* @__PURE__ */ new WeakMap();
|
|
10799
10965
|
function useObjectUrl(file) {
|
|
10800
|
-
const url =
|
|
10966
|
+
const url = useMemo18(() => {
|
|
10801
10967
|
if (!file || typeof window === "undefined") return null;
|
|
10802
10968
|
let existing = objectUrlByFile.get(file);
|
|
10803
10969
|
if (!existing) {
|
|
@@ -10817,7 +10983,7 @@ function useObjectUrl(file) {
|
|
|
10817
10983
|
}
|
|
10818
10984
|
|
|
10819
10985
|
// src/components/chat/chat-context-memory-bar.tsx
|
|
10820
|
-
import { useEffect as useEffect15, useRef as
|
|
10986
|
+
import { useEffect as useEffect15, useRef as useRef14, useState as useState24 } from "react";
|
|
10821
10987
|
import { jsx as jsx64, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
10822
10988
|
var itemKey3 = (item) => `${item.type}:${item.id}`;
|
|
10823
10989
|
function ChatContextMemoryBar({
|
|
@@ -10828,7 +10994,7 @@ function ChatContextMemoryBar({
|
|
|
10828
10994
|
className
|
|
10829
10995
|
}) {
|
|
10830
10996
|
const [open, setOpen] = useState24(false);
|
|
10831
|
-
const rootRef =
|
|
10997
|
+
const rootRef = useRef14(null);
|
|
10832
10998
|
if (items.length === 0 && open) setOpen(false);
|
|
10833
10999
|
useEffect15(() => {
|
|
10834
11000
|
if (!open) return void 0;
|
|
@@ -11133,12 +11299,12 @@ function ChatComposer({
|
|
|
11133
11299
|
const selected = selectedContextItems ?? [];
|
|
11134
11300
|
const memory = contextMemoryItems ?? [];
|
|
11135
11301
|
const entityTypes = contextPicker?.entityTypes;
|
|
11136
|
-
const iconByType =
|
|
11302
|
+
const iconByType = useMemo19(() => {
|
|
11137
11303
|
const map = /* @__PURE__ */ new Map();
|
|
11138
11304
|
for (const t of entityTypes ?? []) map.set(t.type, t.icon);
|
|
11139
11305
|
return map;
|
|
11140
11306
|
}, [entityTypes]);
|
|
11141
|
-
const resolveContextIcon =
|
|
11307
|
+
const resolveContextIcon = useCallback11((item) => iconByType.get(item.type), [iconByType]);
|
|
11142
11308
|
const inputNode = /* @__PURE__ */ jsx67(
|
|
11143
11309
|
ChatInput,
|
|
11144
11310
|
{
|
|
@@ -11297,7 +11463,7 @@ function ChatArchivePage(props) {
|
|
|
11297
11463
|
}
|
|
11298
11464
|
|
|
11299
11465
|
// src/components/chat/chat-sidebar.tsx
|
|
11300
|
-
import { forwardRef as forwardRef24, useRef as
|
|
11466
|
+
import { forwardRef as forwardRef24, useRef as useRef15, useEffect as useEffect16 } from "react";
|
|
11301
11467
|
|
|
11302
11468
|
// src/components/chat/chat-sidebar-skeleton.tsx
|
|
11303
11469
|
import { forwardRef as forwardRef23 } from "react";
|
|
@@ -11420,11 +11586,11 @@ var ChatSidebar = forwardRef24(
|
|
|
11420
11586
|
...props
|
|
11421
11587
|
}, ref) => {
|
|
11422
11588
|
const showEmptyState = dialogs.length === 0 && !children;
|
|
11423
|
-
const scrollContainerRef =
|
|
11424
|
-
const loadMoreRef =
|
|
11425
|
-
const onLoadMoreRef =
|
|
11589
|
+
const scrollContainerRef = useRef15(null);
|
|
11590
|
+
const loadMoreRef = useRef15(null);
|
|
11591
|
+
const onLoadMoreRef = useRef15(onLoadMore);
|
|
11426
11592
|
onLoadMoreRef.current = onLoadMore;
|
|
11427
|
-
const isFetchingRef =
|
|
11593
|
+
const isFetchingRef = useRef15(isFetchingNextPage);
|
|
11428
11594
|
isFetchingRef.current = isFetchingNextPage;
|
|
11429
11595
|
useEffect16(() => {
|
|
11430
11596
|
const scrollContainer = scrollContainerRef.current;
|
|
@@ -11868,10 +12034,10 @@ var TabsContent = forwardRef25(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
11868
12034
|
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
11869
12035
|
|
|
11870
12036
|
// src/components/features/use-captions.ts
|
|
11871
|
-
import { useMemo as
|
|
12037
|
+
import { useMemo as useMemo20 } from "react";
|
|
11872
12038
|
function useCaptions() {
|
|
11873
12039
|
const endpoints = useChatRuntime()?.endpoints ?? null;
|
|
11874
|
-
return
|
|
12040
|
+
return useMemo20(
|
|
11875
12041
|
() => ({
|
|
11876
12042
|
forEntity: (entityType, entity) => getEntityCaptionUrls(endpoints, entityType, entity),
|
|
11877
12043
|
forEntityId: (entityType, entityId) => getEntityCaptionUrlsById(endpoints, entityType, entityId),
|
|
@@ -11883,7 +12049,7 @@ function useCaptions() {
|
|
|
11883
12049
|
|
|
11884
12050
|
// src/components/features/video.tsx
|
|
11885
12051
|
import MuxPlayer from "@mux/mux-player-react";
|
|
11886
|
-
import { useCallback as
|
|
12052
|
+
import { useCallback as useCallback12, useEffect as useEffect19, useImperativeHandle as useImperativeHandle3, useMemo as useMemo21, useRef as useRef16, useState as useState25 } from "react";
|
|
11887
12053
|
|
|
11888
12054
|
// src/utils/fetch-priority.ts
|
|
11889
12055
|
import React4 from "react";
|
|
@@ -12322,10 +12488,10 @@ function FilePlayer({
|
|
|
12322
12488
|
const effectivePreload = preload ?? (saveDataEnabled() ? "none" : "metadata");
|
|
12323
12489
|
const resolvedCaptionsUrl = useAuthedAssetSrc(captionsUrl, "text/vtt, */*");
|
|
12324
12490
|
const [hoverMutedFallback, setHoverMutedFallback] = useState25(() => Boolean(startMuted));
|
|
12325
|
-
const hoverPlayerRef =
|
|
12491
|
+
const hoverPlayerRef = useRef16(null);
|
|
12326
12492
|
const [mutedFallbackBlocked, setMutedFallbackBlocked] = useState25(false);
|
|
12327
|
-
const perfListenerRef =
|
|
12328
|
-
const clearPerfListener =
|
|
12493
|
+
const perfListenerRef = useRef16(null);
|
|
12494
|
+
const clearPerfListener = useCallback12(() => {
|
|
12329
12495
|
if (perfListenerRef.current) {
|
|
12330
12496
|
try {
|
|
12331
12497
|
hoverPlayerRef.current?.removeEventListener?.("playing", perfListenerRef.current);
|
|
@@ -12335,21 +12501,21 @@ function FilePlayer({
|
|
|
12335
12501
|
}
|
|
12336
12502
|
}, []);
|
|
12337
12503
|
useEffect19(() => clearPerfListener, [clearPerfListener]);
|
|
12338
|
-
const hoverActiveRef =
|
|
12339
|
-
const hoverGenerationRef =
|
|
12340
|
-
const activationWaiterRef =
|
|
12341
|
-
const clearActivationWaiter =
|
|
12504
|
+
const hoverActiveRef = useRef16(false);
|
|
12505
|
+
const hoverGenerationRef = useRef16(0);
|
|
12506
|
+
const activationWaiterRef = useRef16(null);
|
|
12507
|
+
const clearActivationWaiter = useCallback12(() => {
|
|
12342
12508
|
if (activationWaiterRef.current) {
|
|
12343
12509
|
activationWaiters.delete(activationWaiterRef.current);
|
|
12344
12510
|
activationWaiterRef.current = null;
|
|
12345
12511
|
}
|
|
12346
12512
|
}, []);
|
|
12347
12513
|
useEffect19(() => clearActivationWaiter, [clearActivationWaiter]);
|
|
12348
|
-
const mutedIntentRef =
|
|
12514
|
+
const mutedIntentRef = useRef16(mutedIntent);
|
|
12349
12515
|
useEffect19(() => {
|
|
12350
12516
|
mutedIntentRef.current = mutedIntent;
|
|
12351
12517
|
});
|
|
12352
|
-
const startHoverPlayback =
|
|
12518
|
+
const startHoverPlayback = useCallback12(() => {
|
|
12353
12519
|
hoverActiveRef.current = true;
|
|
12354
12520
|
const generation = ++hoverGenerationRef.current;
|
|
12355
12521
|
const el = hoverPlayerRef.current;
|
|
@@ -12412,7 +12578,7 @@ function FilePlayer({
|
|
|
12412
12578
|
} catch {
|
|
12413
12579
|
}
|
|
12414
12580
|
}, [clearActivationWaiter, clearPerfListener]);
|
|
12415
|
-
const stopHoverPlayback =
|
|
12581
|
+
const stopHoverPlayback = useCallback12(() => {
|
|
12416
12582
|
hoverActiveRef.current = false;
|
|
12417
12583
|
setHoverMutedFallback(false);
|
|
12418
12584
|
clearActivationWaiter();
|
|
@@ -12422,7 +12588,7 @@ function FilePlayer({
|
|
|
12422
12588
|
} catch {
|
|
12423
12589
|
}
|
|
12424
12590
|
}, [clearActivationWaiter, clearPerfListener]);
|
|
12425
|
-
const unmuteNow =
|
|
12591
|
+
const unmuteNow = useCallback12((e) => {
|
|
12426
12592
|
e.stopPropagation();
|
|
12427
12593
|
e.preventDefault();
|
|
12428
12594
|
const el = hoverPlayerRef.current;
|
|
@@ -12445,7 +12611,7 @@ function FilePlayer({
|
|
|
12445
12611
|
}, [hoverControlled, playWhenHovered, startHoverPlayback, stopHoverPlayback]);
|
|
12446
12612
|
const handleHoverEnter = playOnHover && !hoverControlled ? startHoverPlayback : void 0;
|
|
12447
12613
|
const handleHoverLeave = playOnHover && !hoverControlled ? stopHoverPlayback : void 0;
|
|
12448
|
-
const onMutedFallbackChangeRef =
|
|
12614
|
+
const onMutedFallbackChangeRef = useRef16(onMutedFallbackChange);
|
|
12449
12615
|
useEffect19(() => {
|
|
12450
12616
|
onMutedFallbackChangeRef.current = onMutedFallbackChange;
|
|
12451
12617
|
});
|
|
@@ -12455,7 +12621,7 @@ function FilePlayer({
|
|
|
12455
12621
|
blocked: hoverMutedFallback && mutedFallbackBlocked
|
|
12456
12622
|
});
|
|
12457
12623
|
}, [hoverMutedFallback, mutedFallbackBlocked]);
|
|
12458
|
-
const autoPlayKickedRef =
|
|
12624
|
+
const autoPlayKickedRef = useRef16(false);
|
|
12459
12625
|
useEffect19(() => {
|
|
12460
12626
|
if (autoPlayKickedRef.current) return;
|
|
12461
12627
|
if (startMuted) {
|
|
@@ -12537,7 +12703,7 @@ function FilePlayer({
|
|
|
12537
12703
|
}
|
|
12538
12704
|
};
|
|
12539
12705
|
}, []);
|
|
12540
|
-
const onEndedRef =
|
|
12706
|
+
const onEndedRef = useRef16(onEnded);
|
|
12541
12707
|
useEffect19(() => {
|
|
12542
12708
|
onEndedRef.current = onEnded;
|
|
12543
12709
|
});
|
|
@@ -12598,15 +12764,15 @@ function FilePlayer({
|
|
|
12598
12764
|
}
|
|
12599
12765
|
const monitorHealth = !chromeless;
|
|
12600
12766
|
const [playbackFailed, setPlaybackFailed] = useState25(false);
|
|
12601
|
-
const stallTimerRef =
|
|
12602
|
-
const clearStallTimer =
|
|
12767
|
+
const stallTimerRef = useRef16(null);
|
|
12768
|
+
const clearStallTimer = useCallback12(() => {
|
|
12603
12769
|
if (stallTimerRef.current !== null) {
|
|
12604
12770
|
clearTimeout(stallTimerRef.current);
|
|
12605
12771
|
stallTimerRef.current = null;
|
|
12606
12772
|
}
|
|
12607
12773
|
}, []);
|
|
12608
12774
|
useEffect19(() => clearStallTimer, [clearStallTimer]);
|
|
12609
|
-
const failPlayback =
|
|
12775
|
+
const failPlayback = useCallback12(
|
|
12610
12776
|
(reason) => {
|
|
12611
12777
|
clearStallTimer();
|
|
12612
12778
|
setPlaybackFailed(true);
|
|
@@ -12614,7 +12780,7 @@ function FilePlayer({
|
|
|
12614
12780
|
},
|
|
12615
12781
|
[clearStallTimer, url]
|
|
12616
12782
|
);
|
|
12617
|
-
const armStallTimer =
|
|
12783
|
+
const armStallTimer = useCallback12(() => {
|
|
12618
12784
|
if (!monitorHealth) return;
|
|
12619
12785
|
const el = hoverPlayerRef.current;
|
|
12620
12786
|
if (!el || el.paused || el.ended) return;
|
|
@@ -12624,15 +12790,15 @@ function FilePlayer({
|
|
|
12624
12790
|
failPlayback("stall");
|
|
12625
12791
|
}, VIDEO_STALL_TIMEOUT_MS);
|
|
12626
12792
|
}, [monitorHealth, failPlayback]);
|
|
12627
|
-
const handlePlaybackProgress =
|
|
12793
|
+
const handlePlaybackProgress = useCallback12(() => {
|
|
12628
12794
|
clearStallTimer();
|
|
12629
12795
|
setPlaybackFailed(false);
|
|
12630
12796
|
}, [clearStallTimer]);
|
|
12631
|
-
const handleMediaError =
|
|
12797
|
+
const handleMediaError = useCallback12(() => {
|
|
12632
12798
|
if (!monitorHealth) return;
|
|
12633
12799
|
failPlayback("error");
|
|
12634
12800
|
}, [monitorHealth, failPlayback]);
|
|
12635
|
-
const retryPlayback =
|
|
12801
|
+
const retryPlayback = useCallback12(() => {
|
|
12636
12802
|
setPlaybackFailed(false);
|
|
12637
12803
|
clearStallTimer();
|
|
12638
12804
|
const el = hoverPlayerRef.current;
|
|
@@ -12769,12 +12935,12 @@ function YouTubeFacadeInner({
|
|
|
12769
12935
|
const [activated, setActivated] = useState25(Boolean(autoActivate));
|
|
12770
12936
|
const [failed, setFailed] = useState25(false);
|
|
12771
12937
|
const [reloadNonce, setReloadNonce] = useState25(0);
|
|
12772
|
-
const iframeRef =
|
|
12773
|
-
const retry =
|
|
12938
|
+
const iframeRef = useRef16(null);
|
|
12939
|
+
const retry = useCallback12(() => {
|
|
12774
12940
|
setFailed(false);
|
|
12775
12941
|
setReloadNonce((n) => n + 1);
|
|
12776
12942
|
}, []);
|
|
12777
|
-
const embedUrl =
|
|
12943
|
+
const embedUrl = useMemo21(() => {
|
|
12778
12944
|
const params = new URLSearchParams({
|
|
12779
12945
|
autoplay: "1",
|
|
12780
12946
|
rel: "0",
|
|
@@ -12851,7 +13017,7 @@ function YouTubeFacadeInner({
|
|
|
12851
13017
|
if (blurTimer !== null) clearTimeout(blurTimer);
|
|
12852
13018
|
};
|
|
12853
13019
|
}, [activated, failed, reloadNonce, videoId]);
|
|
12854
|
-
const prevSuspendedRef =
|
|
13020
|
+
const prevSuspendedRef = useRef16(false);
|
|
12855
13021
|
useEffect19(() => {
|
|
12856
13022
|
const wasSuspended = prevSuspendedRef.current;
|
|
12857
13023
|
prevSuspendedRef.current = Boolean(suspended);
|
|
@@ -12919,7 +13085,7 @@ function YouTubeFacadeInner({
|
|
|
12919
13085
|
}
|
|
12920
13086
|
|
|
12921
13087
|
// src/components/features/video-bites-strip.tsx
|
|
12922
|
-
import { useMemo as
|
|
13088
|
+
import { useMemo as useMemo23, useRef as useRef19, useState as useState28 } from "react";
|
|
12923
13089
|
|
|
12924
13090
|
// src/components/user-display.tsx
|
|
12925
13091
|
import { jsx as jsx78, jsxs as jsxs59 } from "react/jsx-runtime";
|
|
@@ -12987,7 +13153,7 @@ function CardHitLayer({
|
|
|
12987
13153
|
}
|
|
12988
13154
|
|
|
12989
13155
|
// src/components/features/cards-strip.tsx
|
|
12990
|
-
import React5, { useCallback as
|
|
13156
|
+
import React5, { useCallback as useCallback13, useEffect as useEffect20, useMemo as useMemo22, useRef as useRef17, useState as useState26 } from "react";
|
|
12991
13157
|
import { Fragment as Fragment20, jsx as jsx80, jsxs as jsxs60 } from "react/jsx-runtime";
|
|
12992
13158
|
var TRACK_GAP_PX = 16;
|
|
12993
13159
|
var CHEVRON_SUPPRESS_MS = 4e3;
|
|
@@ -13035,7 +13201,7 @@ function CardsStrip(props) {
|
|
|
13035
13201
|
className
|
|
13036
13202
|
} = props;
|
|
13037
13203
|
const childrenMode = props.renderCard === void 0;
|
|
13038
|
-
const childItems =
|
|
13204
|
+
const childItems = useMemo22(
|
|
13039
13205
|
() => childrenMode ? React5.Children.toArray(props.children) : EMPTY_CHILDREN,
|
|
13040
13206
|
[childrenMode, props.children]
|
|
13041
13207
|
);
|
|
@@ -13057,9 +13223,9 @@ function CardsStrip(props) {
|
|
|
13057
13223
|
}
|
|
13058
13224
|
return React5.isValidElement(item) && item.key != null ? String(item.key) : String(index);
|
|
13059
13225
|
};
|
|
13060
|
-
const wrapperRef =
|
|
13061
|
-
const scrollerRef =
|
|
13062
|
-
const trackRef =
|
|
13226
|
+
const wrapperRef = useRef17(null);
|
|
13227
|
+
const scrollerRef = useRef17(null);
|
|
13228
|
+
const trackRef = useRef17(null);
|
|
13063
13229
|
const [reducedMotion, setReducedMotion] = useState26(false);
|
|
13064
13230
|
const [isTouch, setIsTouch] = useState26(false);
|
|
13065
13231
|
const [isMobile, setIsMobile] = useState26(false);
|
|
@@ -13083,9 +13249,9 @@ function CardsStrip(props) {
|
|
|
13083
13249
|
}, []);
|
|
13084
13250
|
const [overflows, setOverflows] = useState26(false);
|
|
13085
13251
|
const [marqueeEligible, setMarqueeEligible] = useState26(false);
|
|
13086
|
-
const singleCopyWidthRef =
|
|
13252
|
+
const singleCopyWidthRef = useRef17(0);
|
|
13087
13253
|
const marqueeActive = autoScroll && !reducedMotion && marqueeEligible && items.length > 0;
|
|
13088
|
-
const measure =
|
|
13254
|
+
const measure = useCallback13(() => {
|
|
13089
13255
|
const scroller = scrollerRef.current;
|
|
13090
13256
|
const track = trackRef.current;
|
|
13091
13257
|
if (!scroller || !track) return;
|
|
@@ -13105,8 +13271,8 @@ function CardsStrip(props) {
|
|
|
13105
13271
|
ro.observe(track);
|
|
13106
13272
|
return () => ro.disconnect();
|
|
13107
13273
|
}, [measure, items.length, marqueeActive, isMobile]);
|
|
13108
|
-
const chevronSuppressUntilRef =
|
|
13109
|
-
const userScrollSuppressUntilRef =
|
|
13274
|
+
const chevronSuppressUntilRef = useRef17(0);
|
|
13275
|
+
const userScrollSuppressUntilRef = useRef17(0);
|
|
13110
13276
|
const [nearViewport, setNearViewport] = useState26(true);
|
|
13111
13277
|
useEffect20(() => {
|
|
13112
13278
|
const el = wrapperRef.current;
|
|
@@ -13118,18 +13284,18 @@ function CardsStrip(props) {
|
|
|
13118
13284
|
return () => io.disconnect();
|
|
13119
13285
|
}, []);
|
|
13120
13286
|
const [activeKey, setActiveKey] = useState26(null);
|
|
13121
|
-
const activeKeyRef =
|
|
13122
|
-
const activate =
|
|
13287
|
+
const activeKeyRef = useRef17(null);
|
|
13288
|
+
const activate = useCallback13((key) => {
|
|
13123
13289
|
activeKeyRef.current = key;
|
|
13124
13290
|
setActiveKey(key);
|
|
13125
13291
|
}, []);
|
|
13126
|
-
const deactivate =
|
|
13292
|
+
const deactivate = useCallback13((key) => {
|
|
13127
13293
|
if (activeKeyRef.current === key) activeKeyRef.current = null;
|
|
13128
13294
|
setActiveKey((current) => current === key ? null : current);
|
|
13129
13295
|
}, []);
|
|
13130
|
-
const hoverPointerRef =
|
|
13131
|
-
const lastHoverSyncScrollRef =
|
|
13132
|
-
const syncHoverToPointer =
|
|
13296
|
+
const hoverPointerRef = useRef17({ x: 0, y: 0, inside: false });
|
|
13297
|
+
const lastHoverSyncScrollRef = useRef17(-1);
|
|
13298
|
+
const syncHoverToPointer = useCallback13(() => {
|
|
13133
13299
|
const p = hoverPointerRef.current;
|
|
13134
13300
|
if (!p.inside) return;
|
|
13135
13301
|
const el = typeof document !== "undefined" ? document.elementFromPoint(p.x, p.y) : null;
|
|
@@ -13141,15 +13307,15 @@ function CardsStrip(props) {
|
|
|
13141
13307
|
if (current !== null) deactivate(current);
|
|
13142
13308
|
if (key !== null) activate(key);
|
|
13143
13309
|
}, [activate, deactivate]);
|
|
13144
|
-
const onHoverPointerEnter =
|
|
13310
|
+
const onHoverPointerEnter = useCallback13((e) => {
|
|
13145
13311
|
if (e.pointerType === "touch") return;
|
|
13146
13312
|
hoverPointerRef.current = { x: e.clientX, y: e.clientY, inside: true };
|
|
13147
13313
|
}, []);
|
|
13148
|
-
const onHoverPointerMove =
|
|
13314
|
+
const onHoverPointerMove = useCallback13((e) => {
|
|
13149
13315
|
if (e.pointerType === "touch") return;
|
|
13150
13316
|
hoverPointerRef.current = { x: e.clientX, y: e.clientY, inside: true };
|
|
13151
13317
|
}, []);
|
|
13152
|
-
const onHoverPointerLeave =
|
|
13318
|
+
const onHoverPointerLeave = useCallback13(
|
|
13153
13319
|
(e) => {
|
|
13154
13320
|
if (e.pointerType === "touch") return;
|
|
13155
13321
|
hoverPointerRef.current.inside = false;
|
|
@@ -13158,20 +13324,20 @@ function CardsStrip(props) {
|
|
|
13158
13324
|
},
|
|
13159
13325
|
[deactivate]
|
|
13160
13326
|
);
|
|
13161
|
-
const clearHover =
|
|
13327
|
+
const clearHover = useCallback13(() => {
|
|
13162
13328
|
hoverPointerRef.current.inside = false;
|
|
13163
13329
|
const current = activeKeyRef.current;
|
|
13164
13330
|
if (current !== null) deactivate(current);
|
|
13165
13331
|
}, [deactivate]);
|
|
13166
13332
|
useResetOnPageHidden(clearHover);
|
|
13167
|
-
const syncHoverIfScrolled =
|
|
13333
|
+
const syncHoverIfScrolled = useCallback13(() => {
|
|
13168
13334
|
const scroller = scrollerRef.current;
|
|
13169
13335
|
if (!scroller) return;
|
|
13170
13336
|
if (scroller.scrollLeft === lastHoverSyncScrollRef.current) return;
|
|
13171
13337
|
lastHoverSyncScrollRef.current = scroller.scrollLeft;
|
|
13172
13338
|
syncHoverToPointer();
|
|
13173
13339
|
}, [syncHoverToPointer]);
|
|
13174
|
-
const seamBuffer =
|
|
13340
|
+
const seamBuffer = useCallback13(() => {
|
|
13175
13341
|
const half = singleCopyWidthRef.current;
|
|
13176
13342
|
const viewport = scrollerRef.current?.clientWidth ?? 0;
|
|
13177
13343
|
return Math.max(0, Math.min(200, half / 4, half - viewport - TRACK_GAP_PX - 1));
|
|
@@ -13193,9 +13359,9 @@ function CardsStrip(props) {
|
|
|
13193
13359
|
onAfterFrame: syncHoverIfScrolled
|
|
13194
13360
|
});
|
|
13195
13361
|
const [mountedIdx, setMountedIdx] = useState26(() => /* @__PURE__ */ new Set());
|
|
13196
|
-
const cardObserverRef =
|
|
13197
|
-
const cardElIdxRef =
|
|
13198
|
-
const cardElNearRef =
|
|
13362
|
+
const cardObserverRef = useRef17(null);
|
|
13363
|
+
const cardElIdxRef = useRef17(/* @__PURE__ */ new Map());
|
|
13364
|
+
const cardElNearRef = useRef17(/* @__PURE__ */ new Map());
|
|
13199
13365
|
useEffect20(() => {
|
|
13200
13366
|
if (typeof IntersectionObserver === "undefined") return void 0;
|
|
13201
13367
|
const io = new IntersectionObserver(
|
|
@@ -13230,7 +13396,7 @@ function CardsStrip(props) {
|
|
|
13230
13396
|
};
|
|
13231
13397
|
}, []);
|
|
13232
13398
|
const [cardRefFns] = useState26(() => /* @__PURE__ */ new Map());
|
|
13233
|
-
const getCardRef =
|
|
13399
|
+
const getCardRef = useCallback13(
|
|
13234
13400
|
(idx) => {
|
|
13235
13401
|
let fn = cardRefFns.get(idx);
|
|
13236
13402
|
if (!fn) {
|
|
@@ -13250,11 +13416,11 @@ function CardsStrip(props) {
|
|
|
13250
13416
|
},
|
|
13251
13417
|
[cardRefFns]
|
|
13252
13418
|
);
|
|
13253
|
-
const marqueeActiveRef =
|
|
13419
|
+
const marqueeActiveRef = useRef17(false);
|
|
13254
13420
|
useEffect20(() => {
|
|
13255
13421
|
marqueeActiveRef.current = marqueeActive;
|
|
13256
13422
|
});
|
|
13257
|
-
const scrollByCard =
|
|
13423
|
+
const scrollByCard = useCallback13(
|
|
13258
13424
|
(dir) => {
|
|
13259
13425
|
const scroller = scrollerRef.current;
|
|
13260
13426
|
const track = trackRef.current;
|
|
@@ -13270,22 +13436,22 @@ function CardsStrip(props) {
|
|
|
13270
13436
|
},
|
|
13271
13437
|
[glideBy]
|
|
13272
13438
|
);
|
|
13273
|
-
const onUserScrollIntent =
|
|
13439
|
+
const onUserScrollIntent = useCallback13(() => {
|
|
13274
13440
|
userScrollSuppressUntilRef.current = performance.now() + USER_SCROLL_SUPPRESS_MS;
|
|
13275
13441
|
}, []);
|
|
13276
|
-
const onWheelIntent =
|
|
13442
|
+
const onWheelIntent = useCallback13(
|
|
13277
13443
|
(e) => {
|
|
13278
13444
|
if (Math.abs(e.deltaX) > Math.abs(e.deltaY)) onUserScrollIntent();
|
|
13279
13445
|
},
|
|
13280
13446
|
[onUserScrollIntent]
|
|
13281
13447
|
);
|
|
13282
|
-
const onPointerDownIntent =
|
|
13448
|
+
const onPointerDownIntent = useCallback13(
|
|
13283
13449
|
(e) => {
|
|
13284
13450
|
if (e.pointerType === "touch") onUserScrollIntent();
|
|
13285
13451
|
},
|
|
13286
13452
|
[onUserScrollIntent]
|
|
13287
13453
|
);
|
|
13288
|
-
const onSeamWarp =
|
|
13454
|
+
const onSeamWarp = useCallback13(() => {
|
|
13289
13455
|
const scroller = scrollerRef.current;
|
|
13290
13456
|
if (!scroller) return;
|
|
13291
13457
|
syncHoverIfScrolled();
|
|
@@ -13398,7 +13564,7 @@ function CardsStrip(props) {
|
|
|
13398
13564
|
}
|
|
13399
13565
|
|
|
13400
13566
|
// src/components/features/video-hover-preview.tsx
|
|
13401
|
-
import { useEffect as useEffect21, useRef as
|
|
13567
|
+
import { useEffect as useEffect21, useRef as useRef18, useState as useState27 } from "react";
|
|
13402
13568
|
import { Fragment as Fragment21, jsx as jsx81, jsxs as jsxs61 } from "react/jsx-runtime";
|
|
13403
13569
|
function VideoHoverPreviewSurface({
|
|
13404
13570
|
url,
|
|
@@ -13423,7 +13589,7 @@ function VideoHoverPreviewSurface({
|
|
|
13423
13589
|
}) {
|
|
13424
13590
|
const previewUrl = toMuxPreviewUrl(url);
|
|
13425
13591
|
const gateControlled = playerMounted !== void 0;
|
|
13426
|
-
const rootElRef =
|
|
13592
|
+
const rootElRef = useRef18(null);
|
|
13427
13593
|
const [isNear, setIsNear] = useState27(false);
|
|
13428
13594
|
useEffect21(() => {
|
|
13429
13595
|
if (gateControlled) return void 0;
|
|
@@ -13570,7 +13736,7 @@ function VideoBitesStrip({
|
|
|
13570
13736
|
sortComparator = sortBitesByCreatedAtDesc,
|
|
13571
13737
|
className
|
|
13572
13738
|
}) {
|
|
13573
|
-
const items =
|
|
13739
|
+
const items = useMemo23(() => {
|
|
13574
13740
|
const filtered = filterPublished ? bites.filter((b) => b.published) : [...bites];
|
|
13575
13741
|
return filtered.sort(sortComparator);
|
|
13576
13742
|
}, [bites, filterPublished, sortComparator]);
|
|
@@ -13643,7 +13809,7 @@ function VideoBiteCard({
|
|
|
13643
13809
|
const isActive = controlled ? !!active : selfActive;
|
|
13644
13810
|
const activate = () => controlled ? onActivate?.(key) : setSelfActive(true);
|
|
13645
13811
|
const deactivate = () => controlled ? onDeactivate?.(key) : setSelfActive(false);
|
|
13646
|
-
const titleInputRef =
|
|
13812
|
+
const titleInputRef = useRef19(null);
|
|
13647
13813
|
useIsomorphicLayoutEffect(() => {
|
|
13648
13814
|
const el = titleInputRef.current;
|
|
13649
13815
|
if (!el) return;
|
|
@@ -16346,7 +16512,7 @@ var NETWORK_CONFIG = {
|
|
|
16346
16512
|
var EMPTY_DIALOG_CAPABILITIES = Object.freeze({});
|
|
16347
16513
|
|
|
16348
16514
|
// src/components/chat/hooks/use-chunk-catchup.ts
|
|
16349
|
-
import { useCallback as
|
|
16515
|
+
import { useCallback as useCallback14, useEffect as useEffect22, useRef as useRef20 } from "react";
|
|
16350
16516
|
function makeSeqKey(messageType, chunkType, sequenceId) {
|
|
16351
16517
|
return `${messageType}:${chunkType}:${sequenceId}`;
|
|
16352
16518
|
}
|
|
@@ -16368,26 +16534,26 @@ function useChunkCatchup({
|
|
|
16368
16534
|
chatTypes = [CHAT_TYPE.CLIENT],
|
|
16369
16535
|
fetchChunks
|
|
16370
16536
|
}) {
|
|
16371
|
-
const processedSequenceKeys =
|
|
16372
|
-
const lastSequenceId =
|
|
16373
|
-
const lastSequenceIdByType =
|
|
16374
|
-
const catchupRun =
|
|
16375
|
-
const lastFetchParams =
|
|
16376
|
-
const pendingCatchupRef =
|
|
16377
|
-
const chunkBuffer =
|
|
16378
|
-
const bufferUntilInitialCatchupComplete =
|
|
16379
|
-
const hasCompletedInitialCatchup =
|
|
16380
|
-
const dialogIdRef =
|
|
16381
|
-
const chatTypesRef =
|
|
16382
|
-
const fetchChunksRef =
|
|
16383
|
-
const onChunkReceivedRef =
|
|
16537
|
+
const processedSequenceKeys = useRef20(/* @__PURE__ */ new Set());
|
|
16538
|
+
const lastSequenceId = useRef20(null);
|
|
16539
|
+
const lastSequenceIdByType = useRef20(/* @__PURE__ */ new Map());
|
|
16540
|
+
const catchupRun = useRef20(null);
|
|
16541
|
+
const lastFetchParams = useRef20(null);
|
|
16542
|
+
const pendingCatchupRef = useRef20(null);
|
|
16543
|
+
const chunkBuffer = useRef20([]);
|
|
16544
|
+
const bufferUntilInitialCatchupComplete = useRef20(false);
|
|
16545
|
+
const hasCompletedInitialCatchup = useRef20(false);
|
|
16546
|
+
const dialogIdRef = useRef20(dialogId);
|
|
16547
|
+
const chatTypesRef = useRef20(chatTypes);
|
|
16548
|
+
const fetchChunksRef = useRef20(fetchChunks);
|
|
16549
|
+
const onChunkReceivedRef = useRef20(onChunkReceived);
|
|
16384
16550
|
useEffect22(() => {
|
|
16385
16551
|
dialogIdRef.current = dialogId;
|
|
16386
16552
|
chatTypesRef.current = chatTypes;
|
|
16387
16553
|
fetchChunksRef.current = fetchChunks;
|
|
16388
16554
|
onChunkReceivedRef.current = onChunkReceived;
|
|
16389
16555
|
});
|
|
16390
|
-
const processChunk =
|
|
16556
|
+
const processChunk = useCallback14(
|
|
16391
16557
|
(chunk, messageType, forceProcess = false) => {
|
|
16392
16558
|
if (bufferUntilInitialCatchupComplete.current && !forceProcess) {
|
|
16393
16559
|
chunkBuffer.current.push({ chunk, messageType });
|
|
@@ -16409,7 +16575,7 @@ function useChunkCatchup({
|
|
|
16409
16575
|
},
|
|
16410
16576
|
[]
|
|
16411
16577
|
);
|
|
16412
|
-
const flushBufferedRealtimeChunks =
|
|
16578
|
+
const flushBufferedRealtimeChunks = useCallback14(() => {
|
|
16413
16579
|
if (chunkBuffer.current.length === 0) return;
|
|
16414
16580
|
const buffered = [...chunkBuffer.current];
|
|
16415
16581
|
chunkBuffer.current = [];
|
|
@@ -16422,17 +16588,17 @@ function useChunkCatchup({
|
|
|
16422
16588
|
processChunk(chunk, messageType, true);
|
|
16423
16589
|
});
|
|
16424
16590
|
}, [processChunk]);
|
|
16425
|
-
const completeCatchupWindow =
|
|
16591
|
+
const completeCatchupWindow = useCallback14(() => {
|
|
16426
16592
|
bufferUntilInitialCatchupComplete.current = false;
|
|
16427
16593
|
hasCompletedInitialCatchup.current = true;
|
|
16428
16594
|
}, []);
|
|
16429
|
-
const rearmForQueuedCatchup =
|
|
16595
|
+
const rearmForQueuedCatchup = useCallback14(() => {
|
|
16430
16596
|
hasCompletedInitialCatchup.current = false;
|
|
16431
16597
|
lastFetchParams.current = null;
|
|
16432
16598
|
bufferUntilInitialCatchupComplete.current = true;
|
|
16433
16599
|
}, []);
|
|
16434
|
-
const catchUpChunksRef =
|
|
16435
|
-
const catchUpChunks =
|
|
16600
|
+
const catchUpChunksRef = useRef20(null);
|
|
16601
|
+
const catchUpChunks = useCallback14(
|
|
16436
16602
|
async (fromSequenceId) => {
|
|
16437
16603
|
const currentDialogId = dialogIdRef.current;
|
|
16438
16604
|
const currentChatTypes = chatTypesRef.current;
|
|
@@ -16611,7 +16777,7 @@ function useChunkCatchup({
|
|
|
16611
16777
|
useEffect22(() => {
|
|
16612
16778
|
catchUpChunksRef.current = catchUpChunks;
|
|
16613
16779
|
});
|
|
16614
|
-
const resetChunkTracking =
|
|
16780
|
+
const resetChunkTracking = useCallback14(() => {
|
|
16615
16781
|
processedSequenceKeys.current.clear();
|
|
16616
16782
|
lastSequenceId.current = null;
|
|
16617
16783
|
lastSequenceIdByType.current.clear();
|
|
@@ -16622,16 +16788,16 @@ function useChunkCatchup({
|
|
|
16622
16788
|
bufferUntilInitialCatchupComplete.current = false;
|
|
16623
16789
|
hasCompletedInitialCatchup.current = false;
|
|
16624
16790
|
}, []);
|
|
16625
|
-
const startInitialBuffering =
|
|
16791
|
+
const startInitialBuffering = useCallback14(() => {
|
|
16626
16792
|
if (!bufferUntilInitialCatchupComplete.current) {
|
|
16627
16793
|
chunkBuffer.current = [];
|
|
16628
16794
|
bufferUntilInitialCatchupComplete.current = true;
|
|
16629
16795
|
}
|
|
16630
16796
|
hasCompletedInitialCatchup.current = false;
|
|
16631
16797
|
}, []);
|
|
16632
|
-
const isBufferingActive =
|
|
16633
|
-
const processedCount =
|
|
16634
|
-
const resetAndCatchUp =
|
|
16798
|
+
const isBufferingActive = useCallback14(() => bufferUntilInitialCatchupComplete.current, []);
|
|
16799
|
+
const processedCount = useCallback14(() => processedSequenceKeys.current.size, []);
|
|
16800
|
+
const resetAndCatchUp = useCallback14(async () => {
|
|
16635
16801
|
if (!dialogIdRef.current) return;
|
|
16636
16802
|
const fromSeq = lastSequenceId.current;
|
|
16637
16803
|
hasCompletedInitialCatchup.current = false;
|
|
@@ -16689,7 +16855,7 @@ function useScriptedStream(frames, resetKey, enabled = true) {
|
|
|
16689
16855
|
}
|
|
16690
16856
|
|
|
16691
16857
|
// src/components/chat/hooks/use-jetstream-dialog-subscription.ts
|
|
16692
|
-
import { useCallback as
|
|
16858
|
+
import { useCallback as useCallback15, useEffect as useEffect24, useRef as useRef21, useState as useState30 } from "react";
|
|
16693
16859
|
var DEFAULT_STREAM_NAME = "CHAT_CHUNKS";
|
|
16694
16860
|
var RESYNC_AFTER_HIDDEN_MS = 1e4;
|
|
16695
16861
|
var RESYNC_COALESCE_MS = 1e3;
|
|
@@ -16718,58 +16884,58 @@ function useJetStreamDialogSubscription({
|
|
|
16718
16884
|
const [seqEntry, setSeqEntry] = useState30(null);
|
|
16719
16885
|
const currentStreamSeq = seqEntry && seqEntry.dialogId === dialogId ? seqEntry.seq : null;
|
|
16720
16886
|
const isSubscribed = subscriptionLive && enabled && Boolean(dialogId) && isConnected;
|
|
16721
|
-
const lastRecoveryReportRef =
|
|
16722
|
-
const resyncTimerRef =
|
|
16723
|
-
const lastResyncSignalRef =
|
|
16724
|
-
const resyncSignalRef =
|
|
16887
|
+
const lastRecoveryReportRef = useRef21(0);
|
|
16888
|
+
const resyncTimerRef = useRef21(null);
|
|
16889
|
+
const lastResyncSignalRef = useRef21(resyncSignal);
|
|
16890
|
+
const resyncSignalRef = useRef21(resyncSignal);
|
|
16725
16891
|
useEffect24(() => {
|
|
16726
16892
|
resyncSignalRef.current = resyncSignal;
|
|
16727
16893
|
});
|
|
16728
|
-
const clientRef =
|
|
16729
|
-
const subscriptionRef =
|
|
16730
|
-
const highestStreamSeqRef =
|
|
16731
|
-
const onEventRef =
|
|
16894
|
+
const clientRef = useRef21(null);
|
|
16895
|
+
const subscriptionRef = useRef21(null);
|
|
16896
|
+
const highestStreamSeqRef = useRef21(null);
|
|
16897
|
+
const onEventRef = useRef21(onEvent);
|
|
16732
16898
|
useEffect24(() => {
|
|
16733
16899
|
onEventRef.current = onEvent;
|
|
16734
16900
|
}, [onEvent]);
|
|
16735
|
-
const onConnectRef =
|
|
16901
|
+
const onConnectRef = useRef21(onConnect);
|
|
16736
16902
|
useEffect24(() => {
|
|
16737
16903
|
onConnectRef.current = onConnect;
|
|
16738
16904
|
}, [onConnect]);
|
|
16739
|
-
const onDisconnectRef =
|
|
16905
|
+
const onDisconnectRef = useRef21(onDisconnect);
|
|
16740
16906
|
useEffect24(() => {
|
|
16741
16907
|
onDisconnectRef.current = onDisconnect;
|
|
16742
16908
|
}, [onDisconnect]);
|
|
16743
|
-
const onSubscribedRef =
|
|
16909
|
+
const onSubscribedRef = useRef21(onSubscribed);
|
|
16744
16910
|
useEffect24(() => {
|
|
16745
16911
|
onSubscribedRef.current = onSubscribed;
|
|
16746
16912
|
}, [onSubscribed]);
|
|
16747
|
-
const onBeforeReconnectRef =
|
|
16913
|
+
const onBeforeReconnectRef = useRef21(onBeforeReconnect);
|
|
16748
16914
|
useEffect24(() => {
|
|
16749
16915
|
onBeforeReconnectRef.current = onBeforeReconnect;
|
|
16750
16916
|
}, [onBeforeReconnect]);
|
|
16751
|
-
const getNatsWsUrlRef =
|
|
16917
|
+
const getNatsWsUrlRef = useRef21(getNatsWsUrl);
|
|
16752
16918
|
useEffect24(() => {
|
|
16753
16919
|
getNatsWsUrlRef.current = getNatsWsUrl;
|
|
16754
16920
|
}, [getNatsWsUrl]);
|
|
16755
|
-
const reconnectionBackoffRef =
|
|
16921
|
+
const reconnectionBackoffRef = useRef21(reconnectionBackoff);
|
|
16756
16922
|
useEffect24(() => {
|
|
16757
16923
|
reconnectionBackoffRef.current = reconnectionBackoff;
|
|
16758
16924
|
}, [reconnectionBackoff]);
|
|
16759
|
-
const optStartSeqRef =
|
|
16925
|
+
const optStartSeqRef = useRef21(optStartSeq);
|
|
16760
16926
|
useEffect24(() => {
|
|
16761
16927
|
optStartSeqRef.current = optStartSeq;
|
|
16762
16928
|
}, [optStartSeq]);
|
|
16763
|
-
const inactiveThresholdRef =
|
|
16929
|
+
const inactiveThresholdRef = useRef21(inactiveThresholdMs);
|
|
16764
16930
|
useEffect24(() => {
|
|
16765
16931
|
inactiveThresholdRef.current = inactiveThresholdMs;
|
|
16766
16932
|
}, [inactiveThresholdMs]);
|
|
16767
|
-
const hadConnectionBeforeRef =
|
|
16768
|
-
const clientConfigRef =
|
|
16933
|
+
const hadConnectionBeforeRef = useRef21(false);
|
|
16934
|
+
const clientConfigRef = useRef21(clientConfig);
|
|
16769
16935
|
useEffect24(() => {
|
|
16770
16936
|
clientConfigRef.current = clientConfig;
|
|
16771
16937
|
}, [clientConfig]);
|
|
16772
|
-
const currentWsUrlRef =
|
|
16938
|
+
const currentWsUrlRef = useRef21("");
|
|
16773
16939
|
const wsUrl = getNatsWsUrl();
|
|
16774
16940
|
useEffect24(() => {
|
|
16775
16941
|
if (!enabled || !wsUrl) {
|
|
@@ -16862,7 +17028,7 @@ function useJetStreamDialogSubscription({
|
|
|
16862
17028
|
}
|
|
16863
17029
|
};
|
|
16864
17030
|
}, [dialogId]);
|
|
16865
|
-
const requestResync =
|
|
17031
|
+
const requestResync = useCallback15(() => {
|
|
16866
17032
|
if (resyncTimerRef.current !== null) clearTimeout(resyncTimerRef.current);
|
|
16867
17033
|
resyncTimerRef.current = setTimeout(() => {
|
|
16868
17034
|
resyncTimerRef.current = null;
|
|
@@ -16991,7 +17157,7 @@ function useJetStreamDialogSubscription({
|
|
|
16991
17157
|
}
|
|
16992
17158
|
|
|
16993
17159
|
// src/components/chat/hooks/use-nats-dialog-subscription.ts
|
|
16994
|
-
import { useEffect as useEffect25, useRef as
|
|
17160
|
+
import { useEffect as useEffect25, useRef as useRef22, useState as useState31 } from "react";
|
|
16995
17161
|
function useNatsDialogSubscription({
|
|
16996
17162
|
enabled,
|
|
16997
17163
|
dialogId,
|
|
@@ -17008,45 +17174,45 @@ function useNatsDialogSubscription({
|
|
|
17008
17174
|
const [isConnected, setIsConnected] = useState31(false);
|
|
17009
17175
|
const [isSubscribed, setIsSubscribed] = useState31(false);
|
|
17010
17176
|
const [reconnectionCount, setReconnectionCount] = useState31(0);
|
|
17011
|
-
const clientRef =
|
|
17012
|
-
const subscriptionRefs =
|
|
17013
|
-
const onEventRef =
|
|
17177
|
+
const clientRef = useRef22(null);
|
|
17178
|
+
const subscriptionRefs = useRef22(/* @__PURE__ */ new Map());
|
|
17179
|
+
const onEventRef = useRef22(onEvent);
|
|
17014
17180
|
useEffect25(() => {
|
|
17015
17181
|
onEventRef.current = onEvent;
|
|
17016
17182
|
}, [onEvent]);
|
|
17017
|
-
const onConnectRef =
|
|
17183
|
+
const onConnectRef = useRef22(onConnect);
|
|
17018
17184
|
useEffect25(() => {
|
|
17019
17185
|
onConnectRef.current = onConnect;
|
|
17020
17186
|
}, [onConnect]);
|
|
17021
|
-
const onDisconnectRef =
|
|
17187
|
+
const onDisconnectRef = useRef22(onDisconnect);
|
|
17022
17188
|
useEffect25(() => {
|
|
17023
17189
|
onDisconnectRef.current = onDisconnect;
|
|
17024
17190
|
}, [onDisconnect]);
|
|
17025
|
-
const onSubscribedRef =
|
|
17191
|
+
const onSubscribedRef = useRef22(onSubscribed);
|
|
17026
17192
|
useEffect25(() => {
|
|
17027
17193
|
onSubscribedRef.current = onSubscribed;
|
|
17028
17194
|
}, [onSubscribed]);
|
|
17029
|
-
const onBeforeReconnectRef =
|
|
17195
|
+
const onBeforeReconnectRef = useRef22(onBeforeReconnect);
|
|
17030
17196
|
useEffect25(() => {
|
|
17031
17197
|
onBeforeReconnectRef.current = onBeforeReconnect;
|
|
17032
17198
|
}, [onBeforeReconnect]);
|
|
17033
|
-
const hadConnectionBeforeRef =
|
|
17034
|
-
const getNatsWsUrlRef =
|
|
17199
|
+
const hadConnectionBeforeRef = useRef22(false);
|
|
17200
|
+
const getNatsWsUrlRef = useRef22(getNatsWsUrl);
|
|
17035
17201
|
useEffect25(() => {
|
|
17036
17202
|
getNatsWsUrlRef.current = getNatsWsUrl;
|
|
17037
17203
|
}, [getNatsWsUrl]);
|
|
17038
|
-
const reconnectionBackoffRef =
|
|
17204
|
+
const reconnectionBackoffRef = useRef22(reconnectionBackoff);
|
|
17039
17205
|
useEffect25(() => {
|
|
17040
17206
|
reconnectionBackoffRef.current = reconnectionBackoff;
|
|
17041
17207
|
}, [reconnectionBackoff]);
|
|
17042
|
-
const clientConfigRef =
|
|
17208
|
+
const clientConfigRef = useRef22(clientConfig);
|
|
17043
17209
|
useEffect25(() => {
|
|
17044
17210
|
clientConfigRef.current = clientConfig;
|
|
17045
17211
|
}, [clientConfig]);
|
|
17046
|
-
const currentWsUrlRef =
|
|
17212
|
+
const currentWsUrlRef = useRef22("");
|
|
17047
17213
|
const wsUrl = getNatsWsUrl();
|
|
17048
|
-
const lastSubscribedDialogIdRef =
|
|
17049
|
-
const abortControllerRef =
|
|
17214
|
+
const lastSubscribedDialogIdRef = useRef22(null);
|
|
17215
|
+
const abortControllerRef = useRef22(null);
|
|
17050
17216
|
useEffect25(() => {
|
|
17051
17217
|
if (!enabled || !wsUrl) {
|
|
17052
17218
|
if (currentWsUrlRef.current && clientRef.current) {
|
|
@@ -17129,13 +17295,13 @@ function useNatsDialogSubscription({
|
|
|
17129
17295
|
};
|
|
17130
17296
|
}, [enabled, wsUrl]);
|
|
17131
17297
|
const topicsKey = topics.join(",");
|
|
17132
|
-
const topicsRef =
|
|
17133
|
-
const isConnectedRef =
|
|
17298
|
+
const topicsRef = useRef22(topics);
|
|
17299
|
+
const isConnectedRef = useRef22(isConnected);
|
|
17134
17300
|
useEffect25(() => {
|
|
17135
17301
|
topicsRef.current = topics;
|
|
17136
17302
|
isConnectedRef.current = isConnected;
|
|
17137
17303
|
});
|
|
17138
|
-
const currentDialogIdRef =
|
|
17304
|
+
const currentDialogIdRef = useRef22(null);
|
|
17139
17305
|
useEffect25(() => {
|
|
17140
17306
|
currentDialogIdRef.current = dialogId;
|
|
17141
17307
|
if (!enabled || !dialogId) {
|
|
@@ -17392,7 +17558,7 @@ function useEmptyStateConfig(emptyStateUrl, options) {
|
|
|
17392
17558
|
|
|
17393
17559
|
// src/components/chat/hooks/use-chat-attachments.ts
|
|
17394
17560
|
import { fileTypeFromBlob } from "file-type";
|
|
17395
|
-
import { useCallback as
|
|
17561
|
+
import { useCallback as useCallback16, useEffect as useEffect27, useMemo as useMemo24, useRef as useRef23, useState as useState33 } from "react";
|
|
17396
17562
|
var CHAT_ATTACHMENTS_BUCKET = "chat-attachments";
|
|
17397
17563
|
var CHAT_ATTACHMENTS_FOLDER = "chat";
|
|
17398
17564
|
var CHAT_ATTACHMENT_MAX_SIZE_BYTES = 25 * 1024 * 1024;
|
|
@@ -17460,11 +17626,11 @@ function useChatAttachments() {
|
|
|
17460
17626
|
const runtime = useRequiredChatRuntime();
|
|
17461
17627
|
const uploadUrlEndpoint = runtime.endpoints.attachmentUploadUrl;
|
|
17462
17628
|
const [attachments, setAttachments] = useState33([]);
|
|
17463
|
-
const controllersRef =
|
|
17464
|
-
const updateOne =
|
|
17629
|
+
const controllersRef = useRef23(/* @__PURE__ */ new Map());
|
|
17630
|
+
const updateOne = useCallback16((id, patch) => {
|
|
17465
17631
|
setAttachments((prev) => prev.map((a) => a.id === id ? { ...a, ...patch } : a));
|
|
17466
17632
|
}, []);
|
|
17467
|
-
const removeAttachment =
|
|
17633
|
+
const removeAttachment = useCallback16((id) => {
|
|
17468
17634
|
const ctrl = controllersRef.current.get(id);
|
|
17469
17635
|
if (ctrl) {
|
|
17470
17636
|
ctrl.abort();
|
|
@@ -17472,12 +17638,12 @@ function useChatAttachments() {
|
|
|
17472
17638
|
}
|
|
17473
17639
|
setAttachments((prev) => prev.filter((a) => a.id !== id));
|
|
17474
17640
|
}, []);
|
|
17475
|
-
const clear =
|
|
17641
|
+
const clear = useCallback16(() => {
|
|
17476
17642
|
for (const ctrl of controllersRef.current.values()) ctrl.abort();
|
|
17477
17643
|
controllersRef.current.clear();
|
|
17478
17644
|
setAttachments([]);
|
|
17479
17645
|
}, []);
|
|
17480
|
-
const uploadOne =
|
|
17646
|
+
const uploadOne = useCallback16(
|
|
17481
17647
|
async (att) => {
|
|
17482
17648
|
const ctrl = controllersRef.current.get(att.id);
|
|
17483
17649
|
try {
|
|
@@ -17550,11 +17716,11 @@ function useChatAttachments() {
|
|
|
17550
17716
|
},
|
|
17551
17717
|
[uploadUrlEndpoint, updateOne]
|
|
17552
17718
|
);
|
|
17553
|
-
const attachmentsRef =
|
|
17719
|
+
const attachmentsRef = useRef23([]);
|
|
17554
17720
|
useEffect27(() => {
|
|
17555
17721
|
attachmentsRef.current = attachments;
|
|
17556
17722
|
});
|
|
17557
|
-
const addFiles =
|
|
17723
|
+
const addFiles = useCallback16(
|
|
17558
17724
|
(files) => {
|
|
17559
17725
|
const arr = Array.from(files);
|
|
17560
17726
|
if (arr.length === 0) return;
|
|
@@ -17601,7 +17767,7 @@ function useChatAttachments() {
|
|
|
17601
17767
|
},
|
|
17602
17768
|
[uploadOne]
|
|
17603
17769
|
);
|
|
17604
|
-
const readyAttachments =
|
|
17770
|
+
const readyAttachments = useMemo24(
|
|
17605
17771
|
() => attachments.filter(
|
|
17606
17772
|
(a) => a.status === "ready" && !!a.storagePath && !!a.viewToken
|
|
17607
17773
|
).map((a) => ({
|
|
@@ -17625,15 +17791,15 @@ function useChatAttachments() {
|
|
|
17625
17791
|
}
|
|
17626
17792
|
|
|
17627
17793
|
// src/components/chat/hooks/use-chat-attachment-image-gallery.tsx
|
|
17628
|
-
import { useCallback as
|
|
17794
|
+
import { useCallback as useCallback17, useEffect as useEffect28, useRef as useRef24, useState as useState34 } from "react";
|
|
17629
17795
|
import { jsx as jsx95 } from "react/jsx-runtime";
|
|
17630
17796
|
var CLOSED = { isOpen: false, images: [], initialIndex: 0 };
|
|
17631
17797
|
function useChatAttachmentImageGallery() {
|
|
17632
17798
|
const runtime = useRequiredChatRuntime();
|
|
17633
17799
|
const viewUrlPrefix = runtime.endpoints.attachmentViewUrlPrefix;
|
|
17634
|
-
const panelRef =
|
|
17800
|
+
const panelRef = useRef24(null);
|
|
17635
17801
|
const [state, setState] = useState34(CLOSED);
|
|
17636
|
-
const handleClose =
|
|
17802
|
+
const handleClose = useCallback17(() => setState(CLOSED), []);
|
|
17637
17803
|
useEffect28(() => {
|
|
17638
17804
|
const root = panelRef.current;
|
|
17639
17805
|
if (!root) return void 0;
|
|
@@ -17735,11 +17901,11 @@ function useChatIdentity(enabled = true) {
|
|
|
17735
17901
|
}
|
|
17736
17902
|
|
|
17737
17903
|
// src/components/chat/hooks/use-close-on-navigation.ts
|
|
17738
|
-
import { useEffect as useEffect30, useRef as
|
|
17904
|
+
import { useEffect as useEffect30, useRef as useRef25 } from "react";
|
|
17739
17905
|
function useCloseOnNavigation(close, pathname) {
|
|
17740
|
-
const prevPathnameRef =
|
|
17741
|
-
const initializedRef =
|
|
17742
|
-
const closeRef =
|
|
17906
|
+
const prevPathnameRef = useRef25(null);
|
|
17907
|
+
const initializedRef = useRef25(false);
|
|
17908
|
+
const closeRef = useRef25(close);
|
|
17743
17909
|
useEffect30(() => {
|
|
17744
17910
|
closeRef.current = close;
|
|
17745
17911
|
});
|
|
@@ -17757,15 +17923,15 @@ function useCloseOnNavigation(close, pathname) {
|
|
|
17757
17923
|
}
|
|
17758
17924
|
|
|
17759
17925
|
// src/components/chat/hooks/use-chat.ts
|
|
17760
|
-
import { useState as useState37, useCallback as
|
|
17926
|
+
import { useState as useState37, useCallback as useCallback19, useEffect as useEffect31, useRef as useRef27 } from "react";
|
|
17761
17927
|
|
|
17762
17928
|
// src/components/chat/hooks/use-sse.ts
|
|
17763
|
-
import { useState as useState36, useCallback as
|
|
17929
|
+
import { useState as useState36, useCallback as useCallback18, useRef as useRef26 } from "react";
|
|
17764
17930
|
function useSSE({ streamFn } = {}) {
|
|
17765
17931
|
const [isStreaming, setIsStreaming] = useState36(false);
|
|
17766
17932
|
const [error, setError] = useState36(null);
|
|
17767
|
-
const abortControllerRef =
|
|
17768
|
-
const streamMessage =
|
|
17933
|
+
const abortControllerRef = useRef26(null);
|
|
17934
|
+
const streamMessage = useCallback18(
|
|
17769
17935
|
async function* (message, extra) {
|
|
17770
17936
|
setIsStreaming(true);
|
|
17771
17937
|
setError(null);
|
|
@@ -17800,13 +17966,13 @@ function useSSE({ streamFn } = {}) {
|
|
|
17800
17966
|
},
|
|
17801
17967
|
[streamFn]
|
|
17802
17968
|
);
|
|
17803
|
-
const abort =
|
|
17969
|
+
const abort = useCallback18(() => {
|
|
17804
17970
|
if (abortControllerRef.current) {
|
|
17805
17971
|
abortControllerRef.current.abort();
|
|
17806
17972
|
}
|
|
17807
17973
|
setIsStreaming(false);
|
|
17808
17974
|
}, []);
|
|
17809
|
-
const reset =
|
|
17975
|
+
const reset = useCallback18(() => {
|
|
17810
17976
|
}, []);
|
|
17811
17977
|
return {
|
|
17812
17978
|
streamMessage,
|
|
@@ -17835,8 +18001,8 @@ function useChat({
|
|
|
17835
18001
|
} = {}) {
|
|
17836
18002
|
const [messages, setMessages] = useState37(() => initialMessages ?? []);
|
|
17837
18003
|
const [isTyping, setIsTyping] = useState37(false);
|
|
17838
|
-
const currentAssistantSegmentsRef =
|
|
17839
|
-
const onMessagesChangeRef =
|
|
18004
|
+
const currentAssistantSegmentsRef = useRef27([]);
|
|
18005
|
+
const onMessagesChangeRef = useRef27(onMessagesChange);
|
|
17840
18006
|
useEffect31(() => {
|
|
17841
18007
|
onMessagesChangeRef.current = onMessagesChange;
|
|
17842
18008
|
});
|
|
@@ -17854,10 +18020,10 @@ function useChat({
|
|
|
17854
18020
|
debugMode,
|
|
17855
18021
|
streamFn
|
|
17856
18022
|
});
|
|
17857
|
-
const addMessage =
|
|
18023
|
+
const addMessage = useCallback19((message) => {
|
|
17858
18024
|
setMessages((prev) => [...prev, message]);
|
|
17859
18025
|
}, []);
|
|
17860
|
-
const updateLastAssistantMessage =
|
|
18026
|
+
const updateLastAssistantMessage = useCallback19((segments) => {
|
|
17861
18027
|
setMessages((prev) => {
|
|
17862
18028
|
const newMessages = [...prev];
|
|
17863
18029
|
const lastMessage = newMessages[newMessages.length - 1];
|
|
@@ -17870,7 +18036,7 @@ function useChat({
|
|
|
17870
18036
|
return newMessages;
|
|
17871
18037
|
});
|
|
17872
18038
|
}, []);
|
|
17873
|
-
const sendMessage =
|
|
18039
|
+
const sendMessage = useCallback19(
|
|
17874
18040
|
async (text2, extra, options) => {
|
|
17875
18041
|
const userMessage = {
|
|
17876
18042
|
id: `user-${Date.now()}`,
|
|
@@ -18046,21 +18212,21 @@ function useChat({
|
|
|
18046
18212
|
},
|
|
18047
18213
|
[streamMessage, addMessage, updateLastAssistantMessage, assistantName, assistantAvatar]
|
|
18048
18214
|
);
|
|
18049
|
-
const handleQuickAction =
|
|
18215
|
+
const handleQuickAction = useCallback19(
|
|
18050
18216
|
(actionText) => {
|
|
18051
18217
|
void sendMessage(actionText);
|
|
18052
18218
|
},
|
|
18053
18219
|
[sendMessage]
|
|
18054
18220
|
);
|
|
18055
|
-
const clearMessages =
|
|
18221
|
+
const clearMessages = useCallback19(() => {
|
|
18056
18222
|
setMessages([]);
|
|
18057
18223
|
setIsTyping(false);
|
|
18058
18224
|
reset();
|
|
18059
18225
|
}, [reset]);
|
|
18060
|
-
const hydrateMessages =
|
|
18226
|
+
const hydrateMessages = useCallback19((history) => {
|
|
18061
18227
|
setMessages((prev) => prev.length === 0 ? history : [...history, ...prev]);
|
|
18062
18228
|
}, []);
|
|
18063
|
-
const stopMessage =
|
|
18229
|
+
const stopMessage = useCallback19(() => {
|
|
18064
18230
|
abort();
|
|
18065
18231
|
setIsTyping(false);
|
|
18066
18232
|
}, [abort]);
|
|
@@ -18079,7 +18245,7 @@ function useChat({
|
|
|
18079
18245
|
}
|
|
18080
18246
|
|
|
18081
18247
|
// src/components/chat/hooks/use-sse-chat-adapter.ts
|
|
18082
|
-
import { useCallback as
|
|
18248
|
+
import { useCallback as useCallback22, useMemo as useMemo27, useRef as useRef30, useState as useState41 } from "react";
|
|
18083
18249
|
|
|
18084
18250
|
// src/chat-protocol/confirm-tool.ts
|
|
18085
18251
|
function buildConfirmToolBody(request) {
|
|
@@ -20628,7 +20794,7 @@ function createChatDialogStore(options = {}) {
|
|
|
20628
20794
|
}
|
|
20629
20795
|
|
|
20630
20796
|
// src/components/chat/stream/use-chat-stream-reducer.ts
|
|
20631
|
-
import { useCallback as
|
|
20797
|
+
import { useCallback as useCallback20, useEffect as useEffect32, useMemo as useMemo25, useState as useState38, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
20632
20798
|
|
|
20633
20799
|
// src/components/chat/stream/delta-batcher.ts
|
|
20634
20800
|
var DELTA_FLUSH_FALLBACK_MS = 50;
|
|
@@ -20718,12 +20884,12 @@ function useChatStreamReducer({
|
|
|
20718
20884
|
createReducerOptions
|
|
20719
20885
|
}) {
|
|
20720
20886
|
const reducer = store.getReducer(dialogId, side, () => createReducerOptions?.() ?? {});
|
|
20721
|
-
const getSnapshot2 =
|
|
20722
|
-
const getServerSnapshot2 =
|
|
20723
|
-
const subscribe2 =
|
|
20887
|
+
const getSnapshot2 = useCallback20(() => store.getSnapshot(dialogId, side), [store, dialogId, side]);
|
|
20888
|
+
const getServerSnapshot2 = useCallback20(() => store.getServerSnapshot(), [store]);
|
|
20889
|
+
const subscribe2 = useCallback20((listener) => store.subscribe(listener), [store]);
|
|
20724
20890
|
const state = useSyncExternalStore3(subscribe2, getSnapshot2, getServerSnapshot2);
|
|
20725
20891
|
useEffect32(() => store.retain(dialogId, side), [store, dialogId, side]);
|
|
20726
|
-
const key =
|
|
20892
|
+
const key = useMemo25(() => ({ store, dialogId, side }), [store, dialogId, side]);
|
|
20727
20893
|
const [batcher] = useState38(
|
|
20728
20894
|
() => createDeltaBatcher({
|
|
20729
20895
|
applyOne: (event, k) => {
|
|
@@ -20731,8 +20897,8 @@ function useChatStreamReducer({
|
|
|
20731
20897
|
}
|
|
20732
20898
|
})
|
|
20733
20899
|
);
|
|
20734
|
-
const flushDeltas =
|
|
20735
|
-
const applyEvent =
|
|
20900
|
+
const flushDeltas = useCallback20(() => batcher.flush(), [batcher]);
|
|
20901
|
+
const applyEvent = useCallback20(
|
|
20736
20902
|
(event) => {
|
|
20737
20903
|
if (batcher.push(event, key)) return;
|
|
20738
20904
|
batcher.flush();
|
|
@@ -20741,11 +20907,11 @@ function useChatStreamReducer({
|
|
|
20741
20907
|
[batcher, key]
|
|
20742
20908
|
);
|
|
20743
20909
|
useEffect32(() => () => batcher.dispose(), [batcher]);
|
|
20744
|
-
const mutate =
|
|
20910
|
+
const mutate = useCallback20(
|
|
20745
20911
|
(fn) => store.mutate(dialogId, side, fn),
|
|
20746
20912
|
[store, dialogId, side]
|
|
20747
20913
|
);
|
|
20748
|
-
return
|
|
20914
|
+
return useMemo25(
|
|
20749
20915
|
() => ({ state, applyEvent, flushDeltas, mutate, reducer }),
|
|
20750
20916
|
[state, applyEvent, flushDeltas, mutate, reducer]
|
|
20751
20917
|
);
|
|
@@ -20900,7 +21066,7 @@ function buildDiscussPrompt(reference, options = {}) {
|
|
|
20900
21066
|
}
|
|
20901
21067
|
|
|
20902
21068
|
// src/components/chat/hooks/use-chat-history-hydration.ts
|
|
20903
|
-
import { useEffect as useEffect33, useRef as
|
|
21069
|
+
import { useEffect as useEffect33, useRef as useRef28, useState as useState39 } from "react";
|
|
20904
21070
|
|
|
20905
21071
|
// src/components/chat/utils/auto-continuation-directive.ts
|
|
20906
21072
|
var AUTO_CONTINUATION_DIRECTIVE_PREFIX = "[internal-auto-continuation]";
|
|
@@ -20929,8 +21095,8 @@ function useChatHistoryHydration({
|
|
|
20929
21095
|
onOrphanedConversation
|
|
20930
21096
|
}) {
|
|
20931
21097
|
const [isHydratingHistory, setIsHydratingHistory] = useState39(false);
|
|
20932
|
-
const hydratedKeyRef =
|
|
20933
|
-
const runIdRef =
|
|
21098
|
+
const hydratedKeyRef = useRef28(null);
|
|
21099
|
+
const runIdRef = useRef28(0);
|
|
20934
21100
|
useEffect33(() => {
|
|
20935
21101
|
if (!active || !conversationId) return () => setIsHydratingHistory(false);
|
|
20936
21102
|
const key = `${source}:${conversationId}`;
|
|
@@ -21003,7 +21169,7 @@ function useChatHistoryHydration({
|
|
|
21003
21169
|
}
|
|
21004
21170
|
|
|
21005
21171
|
// src/components/chat/hooks/use-managed-dialog-list.ts
|
|
21006
|
-
import { useCallback as
|
|
21172
|
+
import { useCallback as useCallback21, useEffect as useEffect34, useMemo as useMemo26, useRef as useRef29, useState as useState40 } from "react";
|
|
21007
21173
|
function useManagedDialogList({
|
|
21008
21174
|
autoLoad,
|
|
21009
21175
|
fetchDialogs,
|
|
@@ -21026,19 +21192,19 @@ function useManagedDialogList({
|
|
|
21026
21192
|
setAutoLoadWas(autoLoad);
|
|
21027
21193
|
if (autoLoad && fetchDialogs) setSettledSearch(void 0);
|
|
21028
21194
|
}
|
|
21029
|
-
const pendingRef =
|
|
21195
|
+
const pendingRef = useRef29(false);
|
|
21030
21196
|
const [dialogsError, setDialogsError] = useState40(false);
|
|
21031
|
-
const dialogsRef =
|
|
21197
|
+
const dialogsRef = useRef29(dialogs);
|
|
21032
21198
|
useEffect34(() => {
|
|
21033
21199
|
dialogsRef.current = dialogs;
|
|
21034
21200
|
});
|
|
21035
|
-
const onDialogRemovedRef =
|
|
21201
|
+
const onDialogRemovedRef = useRef29(onDialogRemoved);
|
|
21036
21202
|
useEffect34(() => {
|
|
21037
21203
|
onDialogRemovedRef.current = onDialogRemoved;
|
|
21038
21204
|
});
|
|
21039
|
-
const initialDialogsLoadedRef =
|
|
21040
|
-
const requestIdRef =
|
|
21041
|
-
const loadDialogsPage =
|
|
21205
|
+
const initialDialogsLoadedRef = useRef29(false);
|
|
21206
|
+
const requestIdRef = useRef29(0);
|
|
21207
|
+
const loadDialogsPage = useCallback21(
|
|
21042
21208
|
async (cursor) => {
|
|
21043
21209
|
if (!fetchDialogs) return;
|
|
21044
21210
|
const requestId = ++requestIdRef.current;
|
|
@@ -21080,10 +21246,10 @@ function useManagedDialogList({
|
|
|
21080
21246
|
},
|
|
21081
21247
|
[fetchDialogs, pageSize, search, logTag]
|
|
21082
21248
|
);
|
|
21083
|
-
const reloadDialogs =
|
|
21249
|
+
const reloadDialogs = useCallback21(() => {
|
|
21084
21250
|
void loadDialogsPage();
|
|
21085
21251
|
}, [loadDialogsPage]);
|
|
21086
|
-
const loadedSearchRef =
|
|
21252
|
+
const loadedSearchRef = useRef29(void 0);
|
|
21087
21253
|
useEffect34(() => {
|
|
21088
21254
|
if (!fetchDialogs) return;
|
|
21089
21255
|
if (!autoLoad) return;
|
|
@@ -21092,10 +21258,10 @@ function useManagedDialogList({
|
|
|
21092
21258
|
loadedSearchRef.current = search;
|
|
21093
21259
|
void loadDialogsPage();
|
|
21094
21260
|
}, [autoLoad, fetchDialogs, search, loadDialogsPage]);
|
|
21095
|
-
const removeLocal =
|
|
21261
|
+
const removeLocal = useCallback21((id) => {
|
|
21096
21262
|
setDialogs((prev) => prev.filter((d) => d.id !== id));
|
|
21097
21263
|
}, []);
|
|
21098
|
-
const deleteDialog =
|
|
21264
|
+
const deleteDialog = useCallback21(
|
|
21099
21265
|
async (id) => {
|
|
21100
21266
|
if (!deleteDialogCallback) return;
|
|
21101
21267
|
try {
|
|
@@ -21109,7 +21275,7 @@ function useManagedDialogList({
|
|
|
21109
21275
|
},
|
|
21110
21276
|
[deleteDialogCallback, removeLocal, logTag]
|
|
21111
21277
|
);
|
|
21112
|
-
const renameDialog =
|
|
21278
|
+
const renameDialog = useCallback21(
|
|
21113
21279
|
async (id, title) => {
|
|
21114
21280
|
if (!renameDialogCallback) return;
|
|
21115
21281
|
const previous = dialogsRef.current.find((d) => d.id === id)?.title;
|
|
@@ -21125,7 +21291,7 @@ function useManagedDialogList({
|
|
|
21125
21291
|
},
|
|
21126
21292
|
[renameDialogCallback, logTag]
|
|
21127
21293
|
);
|
|
21128
|
-
const archiveDialog =
|
|
21294
|
+
const archiveDialog = useCallback21(
|
|
21129
21295
|
async (id) => {
|
|
21130
21296
|
if (!archiveDialogCallback) return;
|
|
21131
21297
|
try {
|
|
@@ -21139,15 +21305,15 @@ function useManagedDialogList({
|
|
|
21139
21305
|
},
|
|
21140
21306
|
[archiveDialogCallback, removeLocal, logTag]
|
|
21141
21307
|
);
|
|
21142
|
-
const loadMoreDialogs =
|
|
21308
|
+
const loadMoreDialogs = useCallback21(async () => {
|
|
21143
21309
|
if (!dialogsNextCursor) return;
|
|
21144
21310
|
if (pendingRef.current) return;
|
|
21145
21311
|
await loadDialogsPage(dialogsNextCursor);
|
|
21146
21312
|
}, [dialogsNextCursor, loadDialogsPage]);
|
|
21147
|
-
const upsertDialogTop =
|
|
21313
|
+
const upsertDialogTop = useCallback21((item) => {
|
|
21148
21314
|
setDialogs((prev) => [item, ...prev.filter((d) => d.id !== item.id)]);
|
|
21149
21315
|
}, []);
|
|
21150
|
-
const bumpDialogToTop =
|
|
21316
|
+
const bumpDialogToTop = useCallback21((id) => {
|
|
21151
21317
|
setDialogs((prev) => {
|
|
21152
21318
|
const row = prev.find((d) => d.id === id);
|
|
21153
21319
|
if (!row) return prev;
|
|
@@ -21157,7 +21323,7 @@ function useManagedDialogList({
|
|
|
21157
21323
|
const hasMoreDialogs = dialogsNextCursor != null;
|
|
21158
21324
|
const awaitingFirstPage = !!fetchDialogs && settledSearch !== (search ?? null);
|
|
21159
21325
|
const dialogsLoading = isDialogsLoading || awaitingFirstPage;
|
|
21160
|
-
return
|
|
21326
|
+
return useMemo26(
|
|
21161
21327
|
() => ({
|
|
21162
21328
|
dialogs,
|
|
21163
21329
|
dialogsNextCursor,
|
|
@@ -21224,10 +21390,10 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21224
21390
|
const runtime = useRequiredChatRuntime();
|
|
21225
21391
|
const source = runtime.source || DEFAULT_CHAT_SOURCE;
|
|
21226
21392
|
const tableIdForDocumentType = options?.tableIdForDocumentType ?? defaultTableIdForDocumentType;
|
|
21227
|
-
const sendMessageRef =
|
|
21393
|
+
const sendMessageRef = useRef30(
|
|
21228
21394
|
() => Promise.resolve(true)
|
|
21229
21395
|
);
|
|
21230
|
-
const cardResolve =
|
|
21396
|
+
const cardResolve = useCallback22(
|
|
21231
21397
|
(action) => (reqId) => {
|
|
21232
21398
|
if (!reqId) return void 0;
|
|
21233
21399
|
return sendMessageRef.current("", {
|
|
@@ -21237,32 +21403,32 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21237
21403
|
},
|
|
21238
21404
|
[]
|
|
21239
21405
|
);
|
|
21240
|
-
const cardApprove =
|
|
21241
|
-
const cardReject =
|
|
21242
|
-
const createReducerOptions =
|
|
21406
|
+
const cardApprove = useMemo27(() => cardResolve("approve"), [cardResolve]);
|
|
21407
|
+
const cardReject = useMemo27(() => cardResolve("reject"), [cardResolve]);
|
|
21408
|
+
const createReducerOptions = useCallback22(
|
|
21243
21409
|
() => ({
|
|
21244
21410
|
transport: "sse",
|
|
21245
21411
|
callbacks: { onApprove: cardApprove, onReject: cardReject }
|
|
21246
21412
|
}),
|
|
21247
21413
|
[cardApprove, cardReject]
|
|
21248
21414
|
);
|
|
21249
|
-
const storeRef =
|
|
21415
|
+
const storeRef = useRef30(null);
|
|
21250
21416
|
if (storeRef.current === null) storeRef.current = createChatDialogStore();
|
|
21251
21417
|
const { state, applyEvent, flushDeltas, mutate } = useChatStreamReducer({
|
|
21252
21418
|
store: storeRef.current,
|
|
21253
21419
|
dialogId: source,
|
|
21254
21420
|
createReducerOptions
|
|
21255
21421
|
});
|
|
21256
|
-
const conversationStorage =
|
|
21257
|
-
const conversationIdRef =
|
|
21258
|
-
const restoredConversationRef =
|
|
21422
|
+
const conversationStorage = useMemo27(() => createChatConversationStorage(source), [source]);
|
|
21423
|
+
const conversationIdRef = useRef30(null);
|
|
21424
|
+
const restoredConversationRef = useRef30(false);
|
|
21259
21425
|
if (!restoredConversationRef.current) {
|
|
21260
21426
|
restoredConversationRef.current = true;
|
|
21261
21427
|
pruneStaleChatConversationStorage(source);
|
|
21262
21428
|
conversationIdRef.current = conversationStorage.load()?.conversationId ?? null;
|
|
21263
21429
|
}
|
|
21264
21430
|
const [conversationId, setConversationId] = useState41(() => conversationIdRef.current);
|
|
21265
|
-
const commitConversationId =
|
|
21431
|
+
const commitConversationId = useCallback22(
|
|
21266
21432
|
(id) => {
|
|
21267
21433
|
conversationIdRef.current = id;
|
|
21268
21434
|
setConversationId(id);
|
|
@@ -21275,7 +21441,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21275
21441
|
const { commands: slashCommands } = useSlashCommandRegistry(commandsUrl, {
|
|
21276
21442
|
enabled: active
|
|
21277
21443
|
});
|
|
21278
|
-
const cmdIdByTableId =
|
|
21444
|
+
const cmdIdByTableId = useMemo27(() => {
|
|
21279
21445
|
const buckets = /* @__PURE__ */ new Map();
|
|
21280
21446
|
for (const cmd of slashCommands) {
|
|
21281
21447
|
if (!cmd.primarySourceId) continue;
|
|
@@ -21296,8 +21462,8 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21296
21462
|
return map;
|
|
21297
21463
|
}, [slashCommands]);
|
|
21298
21464
|
const historyUrl = runtime.endpoints.chatHistoryUrl ?? `${runtime.endpoints.chatStreamUrl.replace(/\/+$/, "")}/history`;
|
|
21299
|
-
const hydrationSendCountRef =
|
|
21300
|
-
const hydrateMessages =
|
|
21465
|
+
const hydrationSendCountRef = useRef30(0);
|
|
21466
|
+
const hydrateMessages = useCallback22(
|
|
21301
21467
|
(history, sourcesSeed) => {
|
|
21302
21468
|
mutate((r) => {
|
|
21303
21469
|
const mapped = history.map(historyMessageToReducerMessage);
|
|
@@ -21318,9 +21484,9 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21318
21484
|
},
|
|
21319
21485
|
[mutate]
|
|
21320
21486
|
);
|
|
21321
|
-
const messagesLenRef =
|
|
21487
|
+
const messagesLenRef = useRef30(0);
|
|
21322
21488
|
messagesLenRef.current = state.messages.length;
|
|
21323
|
-
const onOrphanedConversation =
|
|
21489
|
+
const onOrphanedConversation = useCallback22(
|
|
21324
21490
|
(id) => {
|
|
21325
21491
|
if (conversationIdRef.current === id && messagesLenRef.current === 0) commitConversationId(null);
|
|
21326
21492
|
},
|
|
@@ -21347,8 +21513,8 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21347
21513
|
// the thread they just opened. The live count is read through a ref.
|
|
21348
21514
|
onOrphanedConversation
|
|
21349
21515
|
});
|
|
21350
|
-
const abortControllerRef =
|
|
21351
|
-
const switchConversation =
|
|
21516
|
+
const abortControllerRef = useRef30(null);
|
|
21517
|
+
const switchConversation = useCallback22(
|
|
21352
21518
|
(id) => {
|
|
21353
21519
|
abortControllerRef.current?.abort();
|
|
21354
21520
|
flushDeltas();
|
|
@@ -21360,16 +21526,16 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21360
21526
|
[flushDeltas, mutate, hydratedKeyRef, commitConversationId]
|
|
21361
21527
|
);
|
|
21362
21528
|
const conversationsUrl = runtime.endpoints.chatConversationsUrl;
|
|
21363
|
-
const conversationsApi =
|
|
21529
|
+
const conversationsApi = useMemo27(
|
|
21364
21530
|
() => conversationsUrl ? createChatConversationsApi(conversationsUrl) : null,
|
|
21365
21531
|
[conversationsUrl]
|
|
21366
21532
|
);
|
|
21367
21533
|
const [dialogSearch, setDialogSearch] = useState41("");
|
|
21368
|
-
const fetchActiveDialogs =
|
|
21534
|
+
const fetchActiveDialogs = useMemo27(
|
|
21369
21535
|
() => conversationsApi ? (params) => conversationsApi.fetchDialogs({ ...params, status: "active" }) : void 0,
|
|
21370
21536
|
[conversationsApi]
|
|
21371
21537
|
);
|
|
21372
|
-
const fetchArchivedDialogs =
|
|
21538
|
+
const fetchArchivedDialogs = useMemo27(
|
|
21373
21539
|
() => conversationsApi ? (params) => conversationsApi.fetchDialogs({ ...params, status: "archived" }) : void 0,
|
|
21374
21540
|
[conversationsApi]
|
|
21375
21541
|
);
|
|
@@ -21398,16 +21564,16 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21398
21564
|
if (conversationIdRef.current === id) switchConversation(null);
|
|
21399
21565
|
}
|
|
21400
21566
|
});
|
|
21401
|
-
const unarchiveDialog =
|
|
21567
|
+
const unarchiveDialog = useMemo27(
|
|
21402
21568
|
() => conversationsApi ? async (id) => {
|
|
21403
21569
|
await conversationsApi.unarchiveDialog(id);
|
|
21404
21570
|
reloadDialogs();
|
|
21405
21571
|
} : void 0,
|
|
21406
21572
|
[conversationsApi, reloadDialogs]
|
|
21407
21573
|
);
|
|
21408
|
-
const endpointsRef =
|
|
21574
|
+
const endpointsRef = useRef30(runtime.endpoints);
|
|
21409
21575
|
endpointsRef.current = runtime.endpoints;
|
|
21410
|
-
const captureConversationId =
|
|
21576
|
+
const captureConversationId = useCallback22(
|
|
21411
21577
|
(event) => {
|
|
21412
21578
|
if (event.type !== "metadata") return false;
|
|
21413
21579
|
const id = event.conversationId;
|
|
@@ -21419,7 +21585,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21419
21585
|
},
|
|
21420
21586
|
[commitConversationId, hydratedKeyRef, source]
|
|
21421
21587
|
);
|
|
21422
|
-
const sendMessage =
|
|
21588
|
+
const sendMessage = useCallback22(
|
|
21423
21589
|
// Resolves `true` on a clean turn, `false` when the request failed
|
|
21424
21590
|
// (surfaced to batch approve-all loops via the card callbacks).
|
|
21425
21591
|
async (text2, sendOptions) => {
|
|
@@ -21516,25 +21682,25 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21516
21682
|
]
|
|
21517
21683
|
);
|
|
21518
21684
|
sendMessageRef.current = sendMessage;
|
|
21519
|
-
const stopMessage =
|
|
21685
|
+
const stopMessage = useCallback22(() => {
|
|
21520
21686
|
abortControllerRef.current?.abort();
|
|
21521
21687
|
flushDeltas();
|
|
21522
21688
|
mutate((r) => r.setPhase("idle"));
|
|
21523
21689
|
}, [mutate, flushDeltas]);
|
|
21524
|
-
const clearMessages =
|
|
21690
|
+
const clearMessages = useCallback22(() => {
|
|
21525
21691
|
mutate((r) => r.reset());
|
|
21526
21692
|
commitConversationId(null);
|
|
21527
21693
|
hydrationSendCountRef.current = 0;
|
|
21528
21694
|
hydratedKeyRef.current = null;
|
|
21529
21695
|
}, [mutate, commitConversationId, hydratedKeyRef]);
|
|
21530
|
-
const selectDialog =
|
|
21696
|
+
const selectDialog = useCallback22(
|
|
21531
21697
|
(id) => {
|
|
21532
21698
|
if (id === conversationIdRef.current) return;
|
|
21533
21699
|
switchConversation(id);
|
|
21534
21700
|
},
|
|
21535
21701
|
[switchConversation]
|
|
21536
21702
|
);
|
|
21537
|
-
const dialogCapabilities =
|
|
21703
|
+
const dialogCapabilities = useMemo27(
|
|
21538
21704
|
() => conversationsApi ? {
|
|
21539
21705
|
canRename: true,
|
|
21540
21706
|
canArchive: true,
|
|
@@ -21548,7 +21714,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21548
21714
|
} : void 0,
|
|
21549
21715
|
[conversationsApi, fetchArchivedDialogs, unarchiveDialog, dialogSearch]
|
|
21550
21716
|
);
|
|
21551
|
-
const docMessages =
|
|
21717
|
+
const docMessages = useMemo27(() => {
|
|
21552
21718
|
const { meta, sources: sourcesMap } = state.turnMeta;
|
|
21553
21719
|
let sendIdx = -1;
|
|
21554
21720
|
return state.messages.map((m) => {
|
|
@@ -21575,7 +21741,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21575
21741
|
};
|
|
21576
21742
|
});
|
|
21577
21743
|
}, [state.messages, state.turnMeta]);
|
|
21578
|
-
const displayRef =
|
|
21744
|
+
const displayRef = useCallback22(
|
|
21579
21745
|
(reference) => {
|
|
21580
21746
|
const tableId = tableIdForDocumentType(reference.type);
|
|
21581
21747
|
if (!tableId) {
|
|
@@ -21597,7 +21763,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21597
21763
|
},
|
|
21598
21764
|
[sendMessage, source, cmdIdByTableId, tableIdForDocumentType]
|
|
21599
21765
|
);
|
|
21600
|
-
const discussRef =
|
|
21766
|
+
const discussRef = useCallback22(
|
|
21601
21767
|
(reference) => {
|
|
21602
21768
|
const tableId = tableIdForDocumentType(reference.type);
|
|
21603
21769
|
if (!tableId) {
|
|
@@ -21616,7 +21782,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21616
21782
|
},
|
|
21617
21783
|
[sendMessage, tableIdForDocumentType]
|
|
21618
21784
|
);
|
|
21619
|
-
const latestMeta =
|
|
21785
|
+
const latestMeta = useMemo27(() => {
|
|
21620
21786
|
const { meta, sendCount } = state.turnMeta;
|
|
21621
21787
|
return meta.get(sendCount - 1) ?? meta.get(sendCount - 2) ?? null;
|
|
21622
21788
|
}, [state]);
|
|
@@ -21680,7 +21846,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21680
21846
|
}
|
|
21681
21847
|
|
|
21682
21848
|
// src/components/chat/hooks/use-nats-chat-adapter.ts
|
|
21683
|
-
import { useCallback as
|
|
21849
|
+
import { useCallback as useCallback23, useEffect as useEffect35, useMemo as useMemo28, useRef as useRef31, useState as useState42 } from "react";
|
|
21684
21850
|
|
|
21685
21851
|
// src/chat-protocol/nats-decoder.ts
|
|
21686
21852
|
function str(value) {
|
|
@@ -22693,19 +22859,19 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22693
22859
|
const isManagedMode = fetchDialogs !== void 0;
|
|
22694
22860
|
const [internalDialogId, setInternalDialogId] = useState42(null);
|
|
22695
22861
|
const dialogId = isManagedMode ? internalDialogId : controlledDialogId !== void 0 ? controlledDialogId : null;
|
|
22696
|
-
const currentDialogIdRef =
|
|
22862
|
+
const currentDialogIdRef = useRef31(dialogId);
|
|
22697
22863
|
useEffect35(() => {
|
|
22698
22864
|
currentDialogIdRef.current = dialogId;
|
|
22699
22865
|
});
|
|
22700
|
-
const handleApproveRef =
|
|
22866
|
+
const handleApproveRef = useRef31(async () => {
|
|
22701
22867
|
});
|
|
22702
|
-
const handleRejectRef =
|
|
22868
|
+
const handleRejectRef = useRef31(async () => {
|
|
22703
22869
|
});
|
|
22704
|
-
const accumApprove =
|
|
22870
|
+
const accumApprove = useCallback23((requestId) => {
|
|
22705
22871
|
if (!requestId) return void 0;
|
|
22706
22872
|
return handleApproveRef.current(requestId);
|
|
22707
22873
|
}, []);
|
|
22708
|
-
const accumReject =
|
|
22874
|
+
const accumReject = useCallback23((requestId) => {
|
|
22709
22875
|
if (!requestId) return void 0;
|
|
22710
22876
|
return handleRejectRef.current(requestId);
|
|
22711
22877
|
}, []);
|
|
@@ -22758,7 +22924,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22758
22924
|
}
|
|
22759
22925
|
};
|
|
22760
22926
|
});
|
|
22761
|
-
const processChunk =
|
|
22927
|
+
const processChunk = useCallback23(
|
|
22762
22928
|
(chunk) => {
|
|
22763
22929
|
const event = decodeNatsChunk(chunk);
|
|
22764
22930
|
if (event) applyEvent(event);
|
|
@@ -22795,7 +22961,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22795
22961
|
const [messagesNextCursor, setMessagesNextCursor] = useState42(null);
|
|
22796
22962
|
const [isMessagesLoading, setIsMessagesLoading] = useState42(false);
|
|
22797
22963
|
const [connectedForDialog, setConnectedForDialog] = useState42(null);
|
|
22798
|
-
const hasConnectedOnceRef =
|
|
22964
|
+
const hasConnectedOnceRef = useRef31(false);
|
|
22799
22965
|
const {
|
|
22800
22966
|
processChunk: catchupProcessChunk,
|
|
22801
22967
|
catchUpChunks,
|
|
@@ -22808,8 +22974,8 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22808
22974
|
onChunkReceived: (chunk) => processChunk(chunk),
|
|
22809
22975
|
fetchChunks
|
|
22810
22976
|
});
|
|
22811
|
-
const historyLoadSeqRef =
|
|
22812
|
-
const loadDialogHistory =
|
|
22977
|
+
const historyLoadSeqRef = useRef31(0);
|
|
22978
|
+
const loadDialogHistory = useCallback23(
|
|
22813
22979
|
async (id, cursor) => {
|
|
22814
22980
|
if (!fetchDialogMessages) return;
|
|
22815
22981
|
historyLoadSeqRef.current += 1;
|
|
@@ -22867,7 +23033,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22867
23033
|
isBufferingActive
|
|
22868
23034
|
]
|
|
22869
23035
|
);
|
|
22870
|
-
const prevDialogIdRef =
|
|
23036
|
+
const prevDialogIdRef = useRef31(void 0);
|
|
22871
23037
|
useEffect35(() => {
|
|
22872
23038
|
if (prevDialogIdRef.current === dialogId) return;
|
|
22873
23039
|
prevDialogIdRef.current = dialogId;
|
|
@@ -22941,7 +23107,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22941
23107
|
}
|
|
22942
23108
|
});
|
|
22943
23109
|
const connectionState = !active || !dialogId ? "connected" : connectedForDialog === dialogId ? "connected" : "connecting";
|
|
22944
|
-
const sendMessage =
|
|
23110
|
+
const sendMessage = useCallback23(
|
|
22945
23111
|
async (text2, sendOptions) => {
|
|
22946
23112
|
const hidden = sendOptions?.hidden ?? false;
|
|
22947
23113
|
mutate((r) => r.pushOptimisticSend(text2, hidden));
|
|
@@ -22949,7 +23115,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22949
23115
|
},
|
|
22950
23116
|
[mutate, publishUserMessage, dialogId]
|
|
22951
23117
|
);
|
|
22952
|
-
const stopMessage =
|
|
23118
|
+
const stopMessage = useCallback23(() => {
|
|
22953
23119
|
mutate((r) => r.setPhase("idle"));
|
|
22954
23120
|
if (stopGenerationCallback && dialogId) {
|
|
22955
23121
|
void stopGenerationCallback(dialogId).catch((err) => {
|
|
@@ -22957,10 +23123,10 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22957
23123
|
});
|
|
22958
23124
|
}
|
|
22959
23125
|
}, [mutate, stopGenerationCallback, dialogId]);
|
|
22960
|
-
const clearMessages =
|
|
23126
|
+
const clearMessages = useCallback23(() => {
|
|
22961
23127
|
mutate((r) => r.clearThread());
|
|
22962
23128
|
}, [mutate]);
|
|
22963
|
-
const selectDialog =
|
|
23129
|
+
const selectDialog = useCallback23(
|
|
22964
23130
|
(id) => {
|
|
22965
23131
|
if (!isManagedMode) {
|
|
22966
23132
|
return;
|
|
@@ -22969,7 +23135,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22969
23135
|
},
|
|
22970
23136
|
[isManagedMode]
|
|
22971
23137
|
);
|
|
22972
|
-
const startNewDialog =
|
|
23138
|
+
const startNewDialog = useCallback23(async () => {
|
|
22973
23139
|
if (!createDialogCallback) return null;
|
|
22974
23140
|
if (isCreatingDialog) return null;
|
|
22975
23141
|
try {
|
|
@@ -22991,17 +23157,17 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22991
23157
|
setIsCreatingDialog(false);
|
|
22992
23158
|
}
|
|
22993
23159
|
}, [createDialogCallback, isCreatingDialog, isManagedMode, upsertDialogTop]);
|
|
22994
|
-
const loadMoreMessages =
|
|
23160
|
+
const loadMoreMessages = useCallback23(async () => {
|
|
22995
23161
|
if (!dialogId || !messagesNextCursor) return;
|
|
22996
23162
|
await loadDialogHistory(dialogId, messagesNextCursor);
|
|
22997
23163
|
}, [dialogId, messagesNextCursor, loadDialogHistory]);
|
|
22998
|
-
const approveRequest =
|
|
23164
|
+
const approveRequest = useCallback23(async (requestId) => {
|
|
22999
23165
|
await handleApproveRef.current(requestId);
|
|
23000
23166
|
}, []);
|
|
23001
|
-
const rejectRequest =
|
|
23167
|
+
const rejectRequest = useCallback23(async (requestId, reason) => {
|
|
23002
23168
|
await handleRejectRef.current(requestId, reason);
|
|
23003
23169
|
}, []);
|
|
23004
|
-
const discussRef =
|
|
23170
|
+
const discussRef = useCallback23(
|
|
23005
23171
|
(reference) => {
|
|
23006
23172
|
const prompt = buildDiscussPrompt(reference, { includeReference: true });
|
|
23007
23173
|
void sendMessage(prompt).catch((err) => {
|
|
@@ -23013,7 +23179,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
23013
23179
|
const { messages, streamingPhase, dialogTokenUsage = null, liveModel = null } = state;
|
|
23014
23180
|
const isLoading = streamingPhase !== "idle";
|
|
23015
23181
|
const hasMoreMessages = messagesNextCursor != null;
|
|
23016
|
-
const dialogCapabilities =
|
|
23182
|
+
const dialogCapabilities = useMemo28(
|
|
23017
23183
|
() => ({
|
|
23018
23184
|
canRename: isManagedMode && !!renameDialogCallback,
|
|
23019
23185
|
canArchive: isManagedMode && !!archiveDialogCallback,
|
|
@@ -23022,7 +23188,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
23022
23188
|
}),
|
|
23023
23189
|
[isManagedMode, renameDialogCallback, archiveDialogCallback, fetchArchivedDialogs, unarchiveDialog]
|
|
23024
23190
|
);
|
|
23025
|
-
return
|
|
23191
|
+
return useMemo28(
|
|
23026
23192
|
() => ({
|
|
23027
23193
|
messages,
|
|
23028
23194
|
isLoading,
|
|
@@ -23121,7 +23287,7 @@ function useStableShallow(value) {
|
|
|
23121
23287
|
}
|
|
23122
23288
|
|
|
23123
23289
|
// src/components/chat/hooks/use-unified-chat.ts
|
|
23124
|
-
import { useCallback as
|
|
23290
|
+
import { useCallback as useCallback24, useEffect as useEffect36, useMemo as useMemo29, useRef as useRef32, useState as useState44 } from "react";
|
|
23125
23291
|
var EMPTY_SSE_OPTIONS = {};
|
|
23126
23292
|
function createDisabledNatsConfig() {
|
|
23127
23293
|
return {
|
|
@@ -23147,40 +23313,40 @@ function useUnifiedChat(options) {
|
|
|
23147
23313
|
const activeStateIsInjected = activeState === mingoStateOverride;
|
|
23148
23314
|
const stableInjected = useStableShallow(injectedDialogCapabilities);
|
|
23149
23315
|
const dialogCapabilities = activeStateIsInjected ? activeState.dialogCapabilities ?? stableInjected ?? EMPTY_DIALOG_CAPABILITIES : activeState.dialogCapabilities;
|
|
23150
|
-
const activeStateRef =
|
|
23316
|
+
const activeStateRef = useRef32(activeState);
|
|
23151
23317
|
useEffect36(() => {
|
|
23152
23318
|
activeStateRef.current = activeState;
|
|
23153
23319
|
});
|
|
23154
|
-
const stopMessage =
|
|
23155
|
-
const clearMessages =
|
|
23156
|
-
const sendMessage =
|
|
23320
|
+
const stopMessage = useCallback24(() => activeStateRef.current.stopMessage(), []);
|
|
23321
|
+
const clearMessages = useCallback24(() => activeStateRef.current.clearMessages(), []);
|
|
23322
|
+
const sendMessage = useCallback24(
|
|
23157
23323
|
(text2, opts) => activeStateRef.current.sendMessage(text2, opts),
|
|
23158
23324
|
[]
|
|
23159
23325
|
);
|
|
23160
|
-
const discussRef =
|
|
23326
|
+
const discussRef = useCallback24(
|
|
23161
23327
|
(ref) => activeStateRef.current.discussRef(ref),
|
|
23162
23328
|
[]
|
|
23163
23329
|
);
|
|
23164
|
-
const displayRefForward =
|
|
23330
|
+
const displayRefForward = useCallback24(
|
|
23165
23331
|
(ref) => activeStateRef.current.displayRef?.(ref),
|
|
23166
23332
|
[]
|
|
23167
23333
|
);
|
|
23168
23334
|
const displayRef = activeState.displayRef ? displayRefForward : void 0;
|
|
23169
|
-
const selectDialog =
|
|
23170
|
-
const startNewDialog =
|
|
23171
|
-
const deleteDialog =
|
|
23172
|
-
const renameDialog =
|
|
23173
|
-
const archiveDialog =
|
|
23174
|
-
const loadMoreDialogs =
|
|
23175
|
-
const setDialogScope =
|
|
23176
|
-
const reloadDialogs =
|
|
23177
|
-
const loadMoreMessages =
|
|
23178
|
-
const approveRequest =
|
|
23179
|
-
const rejectRequest =
|
|
23335
|
+
const selectDialog = useCallback24((id) => activeStateRef.current.selectDialog(id), []);
|
|
23336
|
+
const startNewDialog = useCallback24(() => activeStateRef.current.startNewDialog(), []);
|
|
23337
|
+
const deleteDialog = useCallback24((id) => activeStateRef.current.deleteDialog(id), []);
|
|
23338
|
+
const renameDialog = useCallback24((id, title) => activeStateRef.current.renameDialog(id, title), []);
|
|
23339
|
+
const archiveDialog = useCallback24((id) => activeStateRef.current.archiveDialog(id), []);
|
|
23340
|
+
const loadMoreDialogs = useCallback24(() => activeStateRef.current.loadMoreDialogs(), []);
|
|
23341
|
+
const setDialogScope = useCallback24((scope) => activeStateRef.current.setDialogScope?.(scope), []);
|
|
23342
|
+
const reloadDialogs = useCallback24(() => activeStateRef.current.reloadDialogs(), []);
|
|
23343
|
+
const loadMoreMessages = useCallback24(() => activeStateRef.current.loadMoreMessages(), []);
|
|
23344
|
+
const approveRequest = useCallback24((requestId) => activeStateRef.current.approveRequest(requestId), []);
|
|
23345
|
+
const rejectRequest = useCallback24(
|
|
23180
23346
|
(requestId, reason) => activeStateRef.current.rejectRequest(requestId, reason),
|
|
23181
23347
|
[]
|
|
23182
23348
|
);
|
|
23183
|
-
return
|
|
23349
|
+
return useMemo29(
|
|
23184
23350
|
() => ({
|
|
23185
23351
|
messages: activeState.messages,
|
|
23186
23352
|
isLoading: activeState.isLoading,
|
|
@@ -23656,7 +23822,7 @@ import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
|
|
23656
23822
|
import { usePreventScroll } from "@react-aria/overlays";
|
|
23657
23823
|
import { isIOS } from "@react-aria/utils";
|
|
23658
23824
|
import { MessageSquare as MessageSquare3 } from "lucide-react";
|
|
23659
|
-
import React10, { useCallback as
|
|
23825
|
+
import React10, { useCallback as useCallback28, useEffect as useEffect38, useImperativeHandle as useImperativeHandle4, useMemo as useMemo31, useRef as useRef36, useState as useState48 } from "react";
|
|
23660
23826
|
|
|
23661
23827
|
// src/components/ui/drawer.tsx
|
|
23662
23828
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
@@ -23664,9 +23830,9 @@ import { cva as cva2 } from "class-variance-authority";
|
|
|
23664
23830
|
import { X } from "lucide-react";
|
|
23665
23831
|
import {
|
|
23666
23832
|
forwardRef as forwardRef26,
|
|
23667
|
-
useCallback as
|
|
23833
|
+
useCallback as useCallback25,
|
|
23668
23834
|
useEffect as useEffect37,
|
|
23669
|
-
useRef as
|
|
23835
|
+
useRef as useRef33,
|
|
23670
23836
|
useState as useState45
|
|
23671
23837
|
} from "react";
|
|
23672
23838
|
import { jsx as jsx96, jsxs as jsxs74 } from "react/jsx-runtime";
|
|
@@ -23773,7 +23939,7 @@ function viewportSize(isHorizontal) {
|
|
|
23773
23939
|
return isHorizontal ? window.innerWidth : window.innerHeight;
|
|
23774
23940
|
}
|
|
23775
23941
|
function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize, storageKey }) {
|
|
23776
|
-
const clampToViewport =
|
|
23942
|
+
const clampToViewport = useCallback25(
|
|
23777
23943
|
(value) => {
|
|
23778
23944
|
const vp = viewportSize(isHorizontal);
|
|
23779
23945
|
const effectiveMax = vp > 0 ? Math.min(maxSize, vp - 80) : maxSize;
|
|
@@ -23781,7 +23947,7 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
|
|
|
23781
23947
|
},
|
|
23782
23948
|
[isHorizontal, minSize, maxSize]
|
|
23783
23949
|
);
|
|
23784
|
-
const readInitial =
|
|
23950
|
+
const readInitial = useCallback25(() => {
|
|
23785
23951
|
if (!enabled) return defaultSize;
|
|
23786
23952
|
if (typeof window === "undefined") return defaultSize;
|
|
23787
23953
|
if (!storageKey) return clampToViewport(defaultSize);
|
|
@@ -23796,7 +23962,7 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
|
|
|
23796
23962
|
}
|
|
23797
23963
|
}, [enabled, storageKey, defaultSize, clampToViewport]);
|
|
23798
23964
|
const [size2, setSizeRaw] = useState45(readInitial);
|
|
23799
|
-
const setSize =
|
|
23965
|
+
const setSize = useCallback25((next) => setSizeRaw(clampToViewport(next)), [clampToViewport]);
|
|
23800
23966
|
useEffect37(() => {
|
|
23801
23967
|
if (!enabled || !storageKey || typeof window === "undefined") return;
|
|
23802
23968
|
try {
|
|
@@ -23814,7 +23980,7 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
|
|
|
23814
23980
|
}
|
|
23815
23981
|
function DrawerResizeHandle({ side, size: size2, minSize, maxSize, onSize, ariaLabel }) {
|
|
23816
23982
|
const isHorizontal = HORIZONTAL_SIDES.has(side);
|
|
23817
|
-
const startRef =
|
|
23983
|
+
const startRef = useRef33(null);
|
|
23818
23984
|
const direction = side === "right" || side === "bottom" ? -1 : 1;
|
|
23819
23985
|
const handlePointerDown = (e) => {
|
|
23820
23986
|
if (e.button !== 0 && e.pointerType === "mouse") return;
|
|
@@ -24011,7 +24177,7 @@ var DrawerFooter = ({ className, ...props }) => /* @__PURE__ */ jsx96("div", { c
|
|
|
24011
24177
|
DrawerFooter.displayName = "DrawerFooter";
|
|
24012
24178
|
|
|
24013
24179
|
// src/components/ui/hover-dropdown.tsx
|
|
24014
|
-
import { useState as useState46, useRef as
|
|
24180
|
+
import { useState as useState46, useRef as useRef34, useCallback as useCallback26 } from "react";
|
|
24015
24181
|
import { Fragment as Fragment33, jsx as jsx97, jsxs as jsxs75 } from "react/jsx-runtime";
|
|
24016
24182
|
function DefaultAnchor({ href, className, children }) {
|
|
24017
24183
|
return /* @__PURE__ */ jsx97("a", { href, className, children });
|
|
@@ -24025,9 +24191,9 @@ function HoverDropdown({
|
|
|
24025
24191
|
renderAnchor
|
|
24026
24192
|
}) {
|
|
24027
24193
|
const [open, setOpen] = useState46(false);
|
|
24028
|
-
const timeoutRef =
|
|
24029
|
-
const containerRef =
|
|
24030
|
-
const panelRef =
|
|
24194
|
+
const timeoutRef = useRef34(void 0);
|
|
24195
|
+
const containerRef = useRef34(null);
|
|
24196
|
+
const panelRef = useRef34(null);
|
|
24031
24197
|
useIsomorphicLayoutEffect(() => {
|
|
24032
24198
|
const el = panelRef.current;
|
|
24033
24199
|
const container = containerRef.current;
|
|
@@ -24055,14 +24221,14 @@ function HoverDropdown({
|
|
|
24055
24221
|
}
|
|
24056
24222
|
}
|
|
24057
24223
|
});
|
|
24058
|
-
const show =
|
|
24224
|
+
const show = useCallback26(() => {
|
|
24059
24225
|
clearTimeout(timeoutRef.current);
|
|
24060
24226
|
setOpen(true);
|
|
24061
24227
|
}, []);
|
|
24062
|
-
const hide =
|
|
24228
|
+
const hide = useCallback26(() => {
|
|
24063
24229
|
timeoutRef.current = setTimeout(() => setOpen(false), hideDelay);
|
|
24064
24230
|
}, [hideDelay]);
|
|
24065
|
-
const toggle =
|
|
24231
|
+
const toggle = useCallback26((e) => {
|
|
24066
24232
|
e.stopPropagation();
|
|
24067
24233
|
clearTimeout(timeoutRef.current);
|
|
24068
24234
|
setOpen((prev) => !prev);
|
|
@@ -24128,7 +24294,7 @@ function HoverDropdown({
|
|
|
24128
24294
|
}
|
|
24129
24295
|
|
|
24130
24296
|
// src/components/chat/hooks/use-chat-dialog-manager.ts
|
|
24131
|
-
import { useCallback as
|
|
24297
|
+
import { useCallback as useCallback27, useMemo as useMemo30, useRef as useRef35, useState as useState47 } from "react";
|
|
24132
24298
|
function useChatDialogManager({
|
|
24133
24299
|
dialogs,
|
|
24134
24300
|
activeDialogId,
|
|
@@ -24141,7 +24307,7 @@ function useChatDialogManager({
|
|
|
24141
24307
|
}) {
|
|
24142
24308
|
const [renameTarget, setRenameTarget] = useState47(null);
|
|
24143
24309
|
const [archiveTarget, setArchiveTarget] = useState47(null);
|
|
24144
|
-
const handleConfirmRename =
|
|
24310
|
+
const handleConfirmRename = useCallback27(
|
|
24145
24311
|
(name) => {
|
|
24146
24312
|
if (renameTarget) void renameDialog(renameTarget.id, name);
|
|
24147
24313
|
setRenameTarget(null);
|
|
@@ -24149,7 +24315,7 @@ function useChatDialogManager({
|
|
|
24149
24315
|
[renameTarget, renameDialog]
|
|
24150
24316
|
);
|
|
24151
24317
|
const [openingDialogId, setOpeningDialogId] = useState47(null);
|
|
24152
|
-
const handleConfirmArchive =
|
|
24318
|
+
const handleConfirmArchive = useCallback27(async () => {
|
|
24153
24319
|
if (archiveTarget) {
|
|
24154
24320
|
try {
|
|
24155
24321
|
await archiveDialog(archiveTarget.id);
|
|
@@ -24169,8 +24335,8 @@ function useChatDialogManager({
|
|
|
24169
24335
|
const [archivedCursor, setArchivedCursor] = useState47(null);
|
|
24170
24336
|
const [archivedLoading, setArchivedLoading] = useState47(false);
|
|
24171
24337
|
const [archivedPending, setArchivedPending] = useState47(false);
|
|
24172
|
-
const archivedRequestIdRef =
|
|
24173
|
-
const loadArchivedPage =
|
|
24338
|
+
const archivedRequestIdRef = useRef35(0);
|
|
24339
|
+
const loadArchivedPage = useCallback27(
|
|
24174
24340
|
async (cursor) => {
|
|
24175
24341
|
if (!fetchArchivedDialogs) return;
|
|
24176
24342
|
const requestId = ++archivedRequestIdRef.current;
|
|
@@ -24203,13 +24369,13 @@ function useChatDialogManager({
|
|
|
24203
24369
|
},
|
|
24204
24370
|
[fetchArchivedDialogs]
|
|
24205
24371
|
);
|
|
24206
|
-
const openArchive =
|
|
24372
|
+
const openArchive = useCallback27(() => {
|
|
24207
24373
|
setArchiveOpen(true);
|
|
24208
24374
|
void loadArchivedPage();
|
|
24209
24375
|
}, [loadArchivedPage]);
|
|
24210
|
-
const closeArchive =
|
|
24376
|
+
const closeArchive = useCallback27(() => setArchiveOpen(false), []);
|
|
24211
24377
|
const [viewingArchivedId, setViewingArchivedId] = useState47(null);
|
|
24212
|
-
const handleSelectDialog =
|
|
24378
|
+
const handleSelectDialog = useCallback27(
|
|
24213
24379
|
(id) => {
|
|
24214
24380
|
setViewingArchivedId(null);
|
|
24215
24381
|
setOpeningDialogId(id);
|
|
@@ -24218,7 +24384,7 @@ function useChatDialogManager({
|
|
|
24218
24384
|
[selectDialog]
|
|
24219
24385
|
);
|
|
24220
24386
|
const isOpeningDialog = openingDialogId != null && openingDialogId === activeDialogId;
|
|
24221
|
-
const handleArchivedSelect =
|
|
24387
|
+
const handleArchivedSelect = useCallback27(
|
|
24222
24388
|
(id) => {
|
|
24223
24389
|
setArchiveOpen(false);
|
|
24224
24390
|
setOpeningDialogId(null);
|
|
@@ -24228,7 +24394,7 @@ function useChatDialogManager({
|
|
|
24228
24394
|
[selectDialog]
|
|
24229
24395
|
);
|
|
24230
24396
|
const [restoreTarget, setRestoreTarget] = useState47(null);
|
|
24231
|
-
const handleConfirmRestore =
|
|
24397
|
+
const handleConfirmRestore = useCallback27(async () => {
|
|
24232
24398
|
if (restoreTarget) {
|
|
24233
24399
|
try {
|
|
24234
24400
|
await unarchiveDialog?.(restoreTarget.id);
|
|
@@ -24242,7 +24408,7 @@ function useChatDialogManager({
|
|
|
24242
24408
|
setRestoreTarget(null);
|
|
24243
24409
|
}, [restoreTarget, unarchiveDialog]);
|
|
24244
24410
|
const isViewingArchived = viewingArchivedId != null && viewingArchivedId === activeDialogId;
|
|
24245
|
-
const handleBack =
|
|
24411
|
+
const handleBack = useCallback27(() => {
|
|
24246
24412
|
const wasArchived = isViewingArchived;
|
|
24247
24413
|
setViewingArchivedId(null);
|
|
24248
24414
|
setOpeningDialogId(null);
|
|
@@ -24250,14 +24416,14 @@ function useChatDialogManager({
|
|
|
24250
24416
|
clearMessages();
|
|
24251
24417
|
if (wasArchived) setArchiveOpen(true);
|
|
24252
24418
|
}, [isViewingArchived, selectDialog, clearMessages]);
|
|
24253
|
-
const resetToNewChat =
|
|
24419
|
+
const resetToNewChat = useCallback27(() => {
|
|
24254
24420
|
setViewingArchivedId(null);
|
|
24255
24421
|
setOpeningDialogId(null);
|
|
24256
24422
|
selectDialog(null);
|
|
24257
24423
|
clearMessages();
|
|
24258
24424
|
setArchiveOpen(false);
|
|
24259
24425
|
}, [selectDialog, clearMessages]);
|
|
24260
|
-
const activeDialog =
|
|
24426
|
+
const activeDialog = useMemo30(
|
|
24261
24427
|
() => dialogs.find((d) => d.id === activeDialogId) ?? archivedDialogs.find((d) => d.id === activeDialogId),
|
|
24262
24428
|
[dialogs, archivedDialogs, activeDialogId]
|
|
24263
24429
|
);
|
|
@@ -24734,7 +24900,7 @@ function EmbeddableChatInner({
|
|
|
24734
24900
|
return !window.matchMedia("(pointer: coarse)").matches;
|
|
24735
24901
|
});
|
|
24736
24902
|
usePreventScroll({ isDisabled: !isOpen || shellLess });
|
|
24737
|
-
const navigatingAwayRef =
|
|
24903
|
+
const navigatingAwayRef = useRef36(false);
|
|
24738
24904
|
useEffect38(() => {
|
|
24739
24905
|
if (!isOpen) return void 0;
|
|
24740
24906
|
if (shellLess) return void 0;
|
|
@@ -24761,9 +24927,9 @@ function EmbeddableChatInner({
|
|
|
24761
24927
|
window.scrollTo(0, scrollY);
|
|
24762
24928
|
};
|
|
24763
24929
|
}, [isOpen, shellLess]);
|
|
24764
|
-
const chatInputRef =
|
|
24930
|
+
const chatInputRef = useRef36(null);
|
|
24765
24931
|
const [quickActionPreview, setQuickActionPreview] = useState48(null);
|
|
24766
|
-
const slashCommandsProp =
|
|
24932
|
+
const slashCommandsProp = useMemo31(
|
|
24767
24933
|
() => ({
|
|
24768
24934
|
fetchCommands: (prefix, signal) => fetchSlashCommands(prefix, signal, commandsUrl),
|
|
24769
24935
|
resolveSourceIcon: (sourceId) => {
|
|
@@ -24778,7 +24944,7 @@ function EmbeddableChatInner({
|
|
|
24778
24944
|
[commandsUrl]
|
|
24779
24945
|
);
|
|
24780
24946
|
const headerUserName = identityUser?.name?.trim() || [identityUser?.firstName, identityUser?.lastName].filter(Boolean).join(" ").trim() || userDisplayName?.trim() || void 0;
|
|
24781
|
-
const effectiveModes =
|
|
24947
|
+
const effectiveModes = useMemo31(() => {
|
|
24782
24948
|
if (modes) return modes;
|
|
24783
24949
|
const guideOptions = tableIdForDocumentType ? { tableIdForDocumentType } : {};
|
|
24784
24950
|
return { guide: guideOptions };
|
|
@@ -24787,7 +24953,7 @@ function EmbeddableChatInner({
|
|
|
24787
24953
|
const initialActiveMode = controlledActiveMode ?? defaultActiveMode ?? (effectiveModes.guide ? "guide" : "mingo");
|
|
24788
24954
|
const [uncontrolledActiveMode, setUncontrolledActiveMode] = useState48(initialActiveMode);
|
|
24789
24955
|
const activeMode = controlledActiveMode ?? uncontrolledActiveMode;
|
|
24790
|
-
const handleActiveModeChange =
|
|
24956
|
+
const handleActiveModeChange = useCallback28(
|
|
24791
24957
|
(next) => {
|
|
24792
24958
|
if (controlledActiveMode === void 0) {
|
|
24793
24959
|
setUncontrolledActiveMode(next);
|
|
@@ -24799,7 +24965,7 @@ function EmbeddableChatInner({
|
|
|
24799
24965
|
const { commands: commandsList, loaded: commandsLoaded } = useSlashCommandRegistry(commandsUrl, {
|
|
24800
24966
|
enabled: activeMode === "guide"
|
|
24801
24967
|
});
|
|
24802
|
-
const commandsById =
|
|
24968
|
+
const commandsById = useMemo31(() => {
|
|
24803
24969
|
const map = /* @__PURE__ */ new Map();
|
|
24804
24970
|
for (const cmd of commandsList) map.set(cmd.id, cmd);
|
|
24805
24971
|
return map;
|
|
@@ -24813,7 +24979,7 @@ function EmbeddableChatInner({
|
|
|
24813
24979
|
const effectiveGreeting = emptyStateConfig.greeting ?? emptyStateGreeting;
|
|
24814
24980
|
const effectiveEnabledRagTableIds = emptyStateUrl ? emptyStateConfig.enabledRagTableIds : enabledRagTableIds;
|
|
24815
24981
|
const effectiveSuggestedQueries = emptyStateUrl ? emptyStateConfig.suggestedQueries : suggestedQueries;
|
|
24816
|
-
const effectiveQuickActions =
|
|
24982
|
+
const effectiveQuickActions = useMemo31(
|
|
24817
24983
|
() => emptyStateUrl ? emptyStateConfig.quickActions : [],
|
|
24818
24984
|
[emptyStateUrl, emptyStateConfig.quickActions]
|
|
24819
24985
|
);
|
|
@@ -24859,7 +25025,7 @@ function EmbeddableChatInner({
|
|
|
24859
25025
|
injectedDialogCapabilities: mingoDialogCapabilities
|
|
24860
25026
|
});
|
|
24861
25027
|
const historyListMode = dialogCapabilities !== void 0;
|
|
24862
|
-
const mingoCaps =
|
|
25028
|
+
const mingoCaps = useMemo31(
|
|
24863
25029
|
() => ({
|
|
24864
25030
|
...dialogCapabilities,
|
|
24865
25031
|
canRename: dialogCapabilities?.canRename ?? false,
|
|
@@ -24867,7 +25033,7 @@ function EmbeddableChatInner({
|
|
|
24867
25033
|
}),
|
|
24868
25034
|
[dialogCapabilities]
|
|
24869
25035
|
);
|
|
24870
|
-
const guidePromptSentRef =
|
|
25036
|
+
const guidePromptSentRef = useRef36(false);
|
|
24871
25037
|
useEffect38(() => {
|
|
24872
25038
|
if (!guidePendingPrompt) {
|
|
24873
25039
|
guidePromptSentRef.current = false;
|
|
@@ -24894,11 +25060,11 @@ function EmbeddableChatInner({
|
|
|
24894
25060
|
const [contextItems, setContextItems] = useState48(NO_CONTEXT_ITEMS);
|
|
24895
25061
|
const [contextPickerOpen, setContextPickerOpen] = useState48(false);
|
|
24896
25062
|
const [mentionQuery, setMentionQuery] = useState48(null);
|
|
24897
|
-
const mentionActiveRef =
|
|
25063
|
+
const mentionActiveRef = useRef36(false);
|
|
24898
25064
|
useEffect38(() => {
|
|
24899
25065
|
mentionActiveRef.current = mentionQuery !== null;
|
|
24900
25066
|
}, [mentionQuery]);
|
|
24901
|
-
const mentionKeysRef =
|
|
25067
|
+
const mentionKeysRef = useRef36(/* @__PURE__ */ new Set());
|
|
24902
25068
|
const [contextClearedFor, setContextClearedFor] = useState48({ activeDialogId, activeMode });
|
|
24903
25069
|
if (contextClearedFor.activeDialogId !== activeDialogId || contextClearedFor.activeMode !== activeMode) {
|
|
24904
25070
|
setContextClearedFor({ activeDialogId, activeMode });
|
|
@@ -24908,18 +25074,18 @@ function EmbeddableChatInner({
|
|
|
24908
25074
|
useEffect38(() => {
|
|
24909
25075
|
mentionKeysRef.current.clear();
|
|
24910
25076
|
}, [activeDialogId, activeMode]);
|
|
24911
|
-
const mentionMarkerByType =
|
|
25077
|
+
const mentionMarkerByType = useMemo31(() => {
|
|
24912
25078
|
const m = /* @__PURE__ */ new Map();
|
|
24913
25079
|
for (const t of contextPicker?.entityTypes ?? []) if (t.marker) m.set(t.type, t.marker);
|
|
24914
25080
|
return m;
|
|
24915
25081
|
}, [contextPicker?.entityTypes]);
|
|
24916
25082
|
const contextEntityTypes = contextPicker?.entityTypes;
|
|
24917
|
-
const resolveContextIcon =
|
|
25083
|
+
const resolveContextIcon = useMemo31(() => {
|
|
24918
25084
|
const byType = /* @__PURE__ */ new Map();
|
|
24919
25085
|
for (const t of contextEntityTypes ?? []) byType.set(t.type, t.icon);
|
|
24920
25086
|
return (item) => byType.get(item.type);
|
|
24921
25087
|
}, [contextEntityTypes]);
|
|
24922
|
-
const toggleContextItem =
|
|
25088
|
+
const toggleContextItem = useCallback28(
|
|
24923
25089
|
(item) => {
|
|
24924
25090
|
const key = `${item.type}:${item.id}`;
|
|
24925
25091
|
if (mentionActiveRef.current) {
|
|
@@ -24942,7 +25108,7 @@ function EmbeddableChatInner({
|
|
|
24942
25108
|
},
|
|
24943
25109
|
[contextMaxItems, contextItems, mentionMarkerByType, resolveContextIcon]
|
|
24944
25110
|
);
|
|
24945
|
-
const removeContextItem =
|
|
25111
|
+
const removeContextItem = useCallback28(
|
|
24946
25112
|
(item) => {
|
|
24947
25113
|
const key = `${item.type}:${item.id}`;
|
|
24948
25114
|
setContextItems((prev) => prev.filter((p) => `${p.type}:${p.id}` !== key));
|
|
@@ -24955,7 +25121,7 @@ function EmbeddableChatInner({
|
|
|
24955
25121
|
},
|
|
24956
25122
|
[mentionMarkerByType]
|
|
24957
25123
|
);
|
|
24958
|
-
const handleContextValueChange =
|
|
25124
|
+
const handleContextValueChange = useCallback28(
|
|
24959
25125
|
(value) => {
|
|
24960
25126
|
for (const key of Array.from(mentionKeysRef.current)) {
|
|
24961
25127
|
if (!value.includes(`@${mentionTokenOf(key, mentionMarkerByType)}`)) {
|
|
@@ -24966,32 +25132,32 @@ function EmbeddableChatInner({
|
|
|
24966
25132
|
},
|
|
24967
25133
|
[mentionMarkerByType]
|
|
24968
25134
|
);
|
|
24969
|
-
const openContextPicker =
|
|
25135
|
+
const openContextPicker = useCallback28(() => {
|
|
24970
25136
|
setMentionQuery(null);
|
|
24971
25137
|
setContextPickerOpen(true);
|
|
24972
25138
|
}, []);
|
|
24973
|
-
const closeContextPicker =
|
|
25139
|
+
const closeContextPicker = useCallback28(() => {
|
|
24974
25140
|
if (mentionActiveRef.current) {
|
|
24975
25141
|
chatInputRef.current?.removeMentionTrigger();
|
|
24976
25142
|
}
|
|
24977
25143
|
setContextPickerOpen(false);
|
|
24978
25144
|
setMentionQuery(null);
|
|
24979
25145
|
}, []);
|
|
24980
|
-
const handleMentionQueryChange =
|
|
25146
|
+
const handleMentionQueryChange = useCallback28((query) => {
|
|
24981
25147
|
setMentionQuery(query);
|
|
24982
25148
|
setContextPickerOpen(query !== null);
|
|
24983
25149
|
}, []);
|
|
24984
25150
|
const resolvedBaseRoute = baseRoute || (source === "flamingo" ? "/knowledge-base" : "/data-room");
|
|
24985
|
-
const handleClose =
|
|
24986
|
-
const handleNavigationClose =
|
|
25151
|
+
const handleClose = useCallback28(() => setIsOpen(false), [setIsOpen]);
|
|
25152
|
+
const handleNavigationClose = useCallback28(() => {
|
|
24987
25153
|
navigatingAwayRef.current = true;
|
|
24988
25154
|
setIsOpen(false);
|
|
24989
25155
|
}, [setIsOpen]);
|
|
24990
|
-
const chatPanelHandle =
|
|
25156
|
+
const chatPanelHandle = useMemo31(
|
|
24991
25157
|
() => ({ closeChat: handleNavigationClose }),
|
|
24992
25158
|
[handleNavigationClose]
|
|
24993
25159
|
);
|
|
24994
|
-
const renderEntityCard =
|
|
25160
|
+
const renderEntityCard = useCallback28(
|
|
24995
25161
|
(reference) => renderChatInlineEntityCard(reference, {
|
|
24996
25162
|
onDiscuss: discussRef,
|
|
24997
25163
|
onDisplay: displayRef,
|
|
@@ -25001,20 +25167,20 @@ function EmbeddableChatInner({
|
|
|
25001
25167
|
}),
|
|
25002
25168
|
[discussRef, displayRef, resolvedBaseRoute, chipBasePlatform, extras]
|
|
25003
25169
|
);
|
|
25004
|
-
const mingoAssistantIcon =
|
|
25170
|
+
const mingoAssistantIcon = useMemo31(
|
|
25005
25171
|
() => effectiveAssistantIcon ? /* @__PURE__ */ jsx98(EntityIcon, { icon: effectiveAssistantIcon, size: 24 }) : /* @__PURE__ */ jsx98(MingoIcon, { className: "h-6 w-6", cornerColor: "var(--ods-flamingo-cyan-base)" }),
|
|
25006
25172
|
[effectiveAssistantIcon]
|
|
25007
25173
|
);
|
|
25008
25174
|
const [timestampCache] = useState48(() => /* @__PURE__ */ new Map());
|
|
25009
25175
|
const guideUserName = activeMode === "guide" ? [identityUser?.firstName, identityUser?.lastName].filter(Boolean).join(" ").trim() || identityUser?.name?.trim() || void 0 : void 0;
|
|
25010
25176
|
const guideUserAvatar = activeMode === "guide" ? identityUser?.avatarUrl?.trim() || void 0 : void 0;
|
|
25011
|
-
const messages =
|
|
25177
|
+
const messages = useMemo31(() => {
|
|
25012
25178
|
const options = { userName: guideUserName, userAvatar: guideUserAvatar, timestampCache };
|
|
25013
25179
|
const mapped = rawMessages.map((m) => mapHostMessage(m, options));
|
|
25014
25180
|
pruneTimestampCache(timestampCache, new Set(rawMessages.map((m) => m.id)));
|
|
25015
25181
|
return mapped;
|
|
25016
25182
|
}, [rawMessages, guideUserName, guideUserAvatar, timestampCache]);
|
|
25017
|
-
const handleSend =
|
|
25183
|
+
const handleSend = useCallback28(
|
|
25018
25184
|
(text2) => {
|
|
25019
25185
|
let augmentedText = text2;
|
|
25020
25186
|
if (readyAttachments.length > 0) {
|
|
@@ -25036,7 +25202,7 @@ function EmbeddableChatInner({
|
|
|
25036
25202
|
},
|
|
25037
25203
|
[sendMessage, readyAttachments, viewUrlPrefix, clearAttachments, contextItems]
|
|
25038
25204
|
);
|
|
25039
|
-
const handleAskSelect =
|
|
25205
|
+
const handleAskSelect = useCallback28(
|
|
25040
25206
|
(label) => {
|
|
25041
25207
|
void sendMessage(label).catch((err) => {
|
|
25042
25208
|
console.error("[EmbeddableChat] handleAskSelect send failed:", err);
|
|
@@ -25044,7 +25210,7 @@ function EmbeddableChatInner({
|
|
|
25044
25210
|
},
|
|
25045
25211
|
[sendMessage]
|
|
25046
25212
|
);
|
|
25047
|
-
const guideSuggestedActions =
|
|
25213
|
+
const guideSuggestedActions = useMemo31(() => {
|
|
25048
25214
|
if (effectiveQuickActions.length > 0) {
|
|
25049
25215
|
return effectiveQuickActions.map((qa) => ({
|
|
25050
25216
|
id: qa.id,
|
|
@@ -25103,7 +25269,7 @@ function EmbeddableChatInner({
|
|
|
25103
25269
|
fetchArchivedDialogs: mingoCaps.fetchArchivedDialogs,
|
|
25104
25270
|
unarchiveDialog: mingoCaps.unarchiveDialog
|
|
25105
25271
|
});
|
|
25106
|
-
const handleOpen =
|
|
25272
|
+
const handleOpen = useCallback28(() => setIsOpen(true), [setIsOpen]);
|
|
25107
25273
|
useCloseOnNavigation(handleNavigationClose, null);
|
|
25108
25274
|
useEffect38(() => {
|
|
25109
25275
|
const handler = (e) => {
|
|
@@ -25136,11 +25302,11 @@ function EmbeddableChatInner({
|
|
|
25136
25302
|
if (!isQuickActionEmpty && quickActionPreview !== null) setQuickActionPreview(null);
|
|
25137
25303
|
const guideCanReturnToMingo = isGuideEmpty && hasMingoMode;
|
|
25138
25304
|
const sourceLabel = source === "flamingo" ? "Knowledge Base" : "Data Room";
|
|
25139
|
-
const enabledSet =
|
|
25305
|
+
const enabledSet = useMemo31(
|
|
25140
25306
|
() => effectiveEnabledRagTableIds ? new Set(effectiveEnabledRagTableIds) : null,
|
|
25141
25307
|
[effectiveEnabledRagTableIds]
|
|
25142
25308
|
);
|
|
25143
|
-
const chipCommands =
|
|
25309
|
+
const chipCommands = useMemo31(() => {
|
|
25144
25310
|
const out = [];
|
|
25145
25311
|
for (const cmd of commandsById.values()) {
|
|
25146
25312
|
if (cmd.displayOrder === void 0) continue;
|
|
@@ -25155,7 +25321,7 @@ function EmbeddableChatInner({
|
|
|
25155
25321
|
});
|
|
25156
25322
|
return out;
|
|
25157
25323
|
}, [commandsById, enabledSet]);
|
|
25158
|
-
const renderMessageSources =
|
|
25324
|
+
const renderMessageSources = useCallback28(
|
|
25159
25325
|
(message, index) => {
|
|
25160
25326
|
if (message.role !== "assistant") return null;
|
|
25161
25327
|
if (chatLoading && index === messages.length - 1) return null;
|
|
@@ -25187,7 +25353,7 @@ function EmbeddableChatInner({
|
|
|
25187
25353
|
ro.observe(panelBoundary);
|
|
25188
25354
|
return () => ro.disconnect();
|
|
25189
25355
|
}, [panelBoundary]);
|
|
25190
|
-
const setPanelNode =
|
|
25356
|
+
const setPanelNode = useCallback28((node) => {
|
|
25191
25357
|
setPanelBoundary(node);
|
|
25192
25358
|
if (node) setPanelWidth(node.clientWidth);
|
|
25193
25359
|
}, []);
|
|
@@ -25201,7 +25367,7 @@ function EmbeddableChatInner({
|
|
|
25201
25367
|
} catch {
|
|
25202
25368
|
}
|
|
25203
25369
|
}
|
|
25204
|
-
const toggleRailCollapsed =
|
|
25370
|
+
const toggleRailCollapsed = useCallback28(() => {
|
|
25205
25371
|
setRailCollapsed((prev) => {
|
|
25206
25372
|
const next = !prev;
|
|
25207
25373
|
try {
|
|
@@ -25237,7 +25403,7 @@ function EmbeddableChatInner({
|
|
|
25237
25403
|
const headerPersonName = headerOwner?.name?.trim() || headerUserName;
|
|
25238
25404
|
const headerPersonAvatarUrl = headerOwner ? headerOwner.avatarUrl?.trim() || void 0 : identityUser?.avatarUrl?.trim() || userAvatarUrl?.trim() || void 0;
|
|
25239
25405
|
const headerAvatar = headerPersonName || headerPersonAvatarUrl ? { name: headerPersonName, avatarUrl: headerPersonAvatarUrl } : void 0;
|
|
25240
|
-
const handleNewChat =
|
|
25406
|
+
const handleNewChat = useCallback28(() => {
|
|
25241
25407
|
resetToNewChat();
|
|
25242
25408
|
}, [resetToNewChat]);
|
|
25243
25409
|
const [pendingDraft, setPendingDraft] = useState48(null);
|
|
@@ -25246,7 +25412,7 @@ function EmbeddableChatInner({
|
|
|
25246
25412
|
setSeededDraft(pendingDraft);
|
|
25247
25413
|
setContextItems(pendingDraft.mentions);
|
|
25248
25414
|
}
|
|
25249
|
-
const appliedDraftRef =
|
|
25415
|
+
const appliedDraftRef = useRef36(null);
|
|
25250
25416
|
useEffect38(() => {
|
|
25251
25417
|
const draft = pendingDraft;
|
|
25252
25418
|
if (!draft || appliedDraftRef.current === draft) return;
|
|
@@ -26138,4 +26304,4 @@ export {
|
|
|
26138
26304
|
buildStreamFrames,
|
|
26139
26305
|
EmbeddableChat
|
|
26140
26306
|
};
|
|
26141
|
-
//# sourceMappingURL=chunk-
|
|
26307
|
+
//# sourceMappingURL=chunk-N6ZYJXVJ.js.map
|