@adoptai/genui-components 0.1.67 → 0.1.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/composites/document-preview/PdfViewer.d.ts +2 -1
  2. package/dist/composites/document-preview/PdfViewer.d.ts.map +1 -1
  3. package/dist/composites/document-preview/resolver.cjs +90 -11
  4. package/dist/composites/document-preview/resolver.cjs.map +1 -1
  5. package/dist/composites/document-preview/resolver.d.ts.map +1 -1
  6. package/dist/composites/document-preview/resolver.js +90 -11
  7. package/dist/composites/document-preview/resolver.js.map +1 -1
  8. package/dist/composites/download-card/resolver.cjs +244 -69
  9. package/dist/composites/download-card/resolver.cjs.map +1 -1
  10. package/dist/composites/download-card/resolver.js +189 -14
  11. package/dist/composites/download-card/resolver.js.map +1 -1
  12. package/dist/index.cjs +472 -289
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.js +265 -82
  15. package/dist/index.js.map +1 -1
  16. package/dist/renderer.cjs +404 -221
  17. package/dist/renderer.cjs.map +1 -1
  18. package/dist/renderer.js +259 -76
  19. package/dist/renderer.js.map +1 -1
  20. package/dist/resolver.cjs +403 -220
  21. package/dist/resolver.cjs.map +1 -1
  22. package/dist/resolver.js +259 -76
  23. package/dist/resolver.js.map +1 -1
  24. package/dist/shared/fileType.d.ts +1 -1
  25. package/dist/shared/fileType.d.ts.map +1 -1
  26. package/dist/shared/viewers/HtmlViewer.d.ts +12 -0
  27. package/dist/shared/viewers/HtmlViewer.d.ts.map +1 -0
  28. package/dist/shared/viewers/PreviewHost.d.ts.map +1 -1
  29. package/dist/shared/viewers/pdfWorkerProbe.d.ts +31 -0
  30. package/dist/shared/viewers/pdfWorkerProbe.d.ts.map +1 -0
  31. package/dist/tool-definitions.json +2 -2
  32. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var React45 = require('react');
4
+ var React46 = require('react');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var dagre = require('@dagrejs/dagre');
7
7
  var reactDom = require('react-dom');
@@ -37,7 +37,7 @@ function _interopNamespace(e) {
37
37
  return Object.freeze(n);
38
38
  }
39
39
 
40
- var React45__default = /*#__PURE__*/_interopDefault(React45);
40
+ var React46__default = /*#__PURE__*/_interopDefault(React46);
41
41
  var dagre__default = /*#__PURE__*/_interopDefault(dagre);
42
42
  var XLSX__namespace = /*#__PURE__*/_interopNamespace(XLSX);
43
43
  var Papa__default = /*#__PURE__*/_interopDefault(Papa);
@@ -125,14 +125,14 @@ var init_theme = __esm({
125
125
  }
126
126
  });
127
127
  function GenUIThemeProvider({ colors, children }) {
128
- const merged = React45.useMemo(
128
+ const merged = React46.useMemo(
129
129
  () => colors ? __spreadValues(__spreadValues({}, exports.DEFAULT_TOKENS), colors) : exports.DEFAULT_TOKENS,
130
130
  [colors]
131
131
  );
132
132
  return /* @__PURE__ */ jsxRuntime.jsx(GenUIThemeContext.Provider, { value: merged, children });
133
133
  }
134
134
  function useTheme() {
135
- return React45.useContext(GenUIThemeContext);
135
+ return React46.useContext(GenUIThemeContext);
136
136
  }
137
137
  exports.DEFAULT_TOKENS = void 0; var GenUIThemeContext;
138
138
  var init_ThemeContext = __esm({
@@ -154,7 +154,7 @@ var init_ThemeContext = __esm({
154
154
  SECONDARY: exports.SECONDARY,
155
155
  CHART_PALETTE: [...exports.CHART_PALETTE]
156
156
  };
157
- GenUIThemeContext = React45.createContext(exports.DEFAULT_TOKENS);
157
+ GenUIThemeContext = React46.createContext(exports.DEFAULT_TOKENS);
158
158
  }
159
159
  });
160
160
  function renderInline(text) {
@@ -890,11 +890,11 @@ async function getMermaid(t) {
890
890
  }
891
891
  function MermaidFallback({ diagram, title }) {
892
892
  const tokens = useTheme();
893
- const [svg, setSvg] = React45.useState("");
894
- const [err, setErr] = React45.useState(false);
895
- const [full, setFull] = React45.useState(false);
896
- const idRef = React45.useRef(0);
897
- React45.useEffect(() => {
893
+ const [svg, setSvg] = React46.useState("");
894
+ const [err, setErr] = React46.useState(false);
895
+ const [full, setFull] = React46.useState(false);
896
+ const idRef = React46.useRef(0);
897
+ React46.useEffect(() => {
898
898
  const id = ++renderSeq;
899
899
  idRef.current = id;
900
900
  setErr(false);
@@ -963,7 +963,7 @@ function FullscreenModalInner({ nodes, edges, title, onClose }) {
963
963
  ] }) });
964
964
  }
965
965
  function FullscreenModal({ nodes, edges, title, onClose }) {
966
- React45.useEffect(() => {
966
+ React46.useEffect(() => {
967
967
  const h = (e) => {
968
968
  if (e.key === "Escape") onClose();
969
969
  };
@@ -976,8 +976,8 @@ function FullscreenModal({ nodes, edges, title, onClose }) {
976
976
  );
977
977
  }
978
978
  function usePrefersReducedMotion() {
979
- const [reduced, setReduced] = React45.useState(false);
980
- React45.useEffect(() => {
979
+ const [reduced, setReduced] = React46.useState(false);
980
+ React46.useEffect(() => {
981
981
  var _a2;
982
982
  if (typeof matchMedia === "undefined") return;
983
983
  const mq = matchMedia("(prefers-reduced-motion: reduce)");
@@ -1021,9 +1021,9 @@ function topoOrder(nodeIds, edges) {
1021
1021
  }
1022
1022
  function useAutoplay(order, enabled) {
1023
1023
  const reduced = usePrefersReducedMotion();
1024
- const [step, setStep] = React45.useState(0);
1024
+ const [step, setStep] = React46.useState(0);
1025
1025
  const key = order.join("|");
1026
- React45.useEffect(() => {
1026
+ React46.useEffect(() => {
1027
1027
  if (!enabled || reduced || order.length === 0) {
1028
1028
  setStep(0);
1029
1029
  return;
@@ -1045,7 +1045,7 @@ function useAutoplay(order, enabled) {
1045
1045
  timer = setTimeout(tick, 850);
1046
1046
  return () => clearTimeout(timer);
1047
1047
  }, [enabled, reduced, key]);
1048
- return React45.useMemo(() => {
1048
+ return React46.useMemo(() => {
1049
1049
  const m = {};
1050
1050
  order.forEach((id, i) => {
1051
1051
  m[id] = i < step ? "done" : i === step ? "active" : "pending";
@@ -1067,13 +1067,13 @@ function resolveStates(nodes, nodeStates) {
1067
1067
  }
1068
1068
  function Inner({ diagram, title, autoplay, nodeStates }) {
1069
1069
  const tokens = useTheme();
1070
- const [full, setFull] = React45.useState(false);
1071
- const [focused, setFocused] = React45.useState(false);
1072
- const [boxW, setBoxW] = React45.useState(640);
1073
- const containerRef = React45.useRef(null);
1074
- const parsed = React45.useMemo(() => parseMermaidFlow(diagram), [diagram]);
1075
- const layout = React45.useMemo(() => parsed ? computeLayout(parsed) : null, [parsed]);
1076
- const themedEdges = React45.useMemo(
1070
+ const [full, setFull] = React46.useState(false);
1071
+ const [focused, setFocused] = React46.useState(false);
1072
+ const [boxW, setBoxW] = React46.useState(640);
1073
+ const containerRef = React46.useRef(null);
1074
+ const parsed = React46.useMemo(() => parseMermaidFlow(diagram), [diagram]);
1075
+ const layout = React46.useMemo(() => parsed ? computeLayout(parsed) : null, [parsed]);
1076
+ const themedEdges = React46.useMemo(
1077
1077
  () => {
1078
1078
  var _a2;
1079
1079
  return ((_a2 = layout == null ? void 0 : layout.edges) != null ? _a2 : []).map((e) => __spreadProps(__spreadValues({}, e), {
@@ -1085,7 +1085,7 @@ function Inner({ diagram, title, autoplay, nodeStates }) {
1085
1085
  },
1086
1086
  [layout, tokens.ACCENT, tokens.MUTED]
1087
1087
  );
1088
- const order = React45.useMemo(
1088
+ const order = React46.useMemo(
1089
1089
  () => {
1090
1090
  var _a2, _b;
1091
1091
  return topoOrder(((_a2 = layout == null ? void 0 : layout.nodes) != null ? _a2 : []).map((n) => n.id), (_b = layout == null ? void 0 : layout.edges) != null ? _b : []);
@@ -1093,19 +1093,19 @@ function Inner({ diagram, title, autoplay, nodeStates }) {
1093
1093
  [layout]
1094
1094
  );
1095
1095
  const autoStatus = useAutoplay(order, !!autoplay);
1096
- const staticStatus = React45.useMemo(() => {
1096
+ const staticStatus = React46.useMemo(() => {
1097
1097
  var _a2;
1098
1098
  return resolveStates((_a2 = layout == null ? void 0 : layout.nodes) != null ? _a2 : [], nodeStates);
1099
1099
  }, [layout, nodeStates]);
1100
1100
  const statusMap = autoplay ? autoStatus : staticStatus;
1101
- const displayNodes = React45.useMemo(
1101
+ const displayNodes = React46.useMemo(
1102
1102
  () => {
1103
1103
  var _a2;
1104
1104
  return ((_a2 = layout == null ? void 0 : layout.nodes) != null ? _a2 : []).map((n) => __spreadProps(__spreadValues({}, n), { data: __spreadProps(__spreadValues({}, n.data), { status: statusMap[n.id] }) }));
1105
1105
  },
1106
1106
  [layout, statusMap]
1107
1107
  );
1108
- const displayEdges = React45.useMemo(
1108
+ const displayEdges = React46.useMemo(
1109
1109
  () => themedEdges.map((e) => {
1110
1110
  const ss = statusMap[e.source];
1111
1111
  const ts = statusMap[e.target];
@@ -1125,13 +1125,13 @@ function Inner({ diagram, title, autoplay, nodeStates }) {
1125
1125
  const [nodes, setNodes, onNC] = react.useNodesState(displayNodes);
1126
1126
  const [edges, setEdges, onEC] = react.useEdgesState(displayEdges);
1127
1127
  const rf = react.useReactFlow();
1128
- React45.useEffect(() => {
1128
+ React46.useEffect(() => {
1129
1129
  setNodes(displayNodes);
1130
1130
  }, [displayNodes, setNodes]);
1131
- React45.useEffect(() => {
1131
+ React46.useEffect(() => {
1132
1132
  setEdges(displayEdges);
1133
1133
  }, [displayEdges, setEdges]);
1134
- React45.useEffect(() => {
1134
+ React46.useEffect(() => {
1135
1135
  const id = requestAnimationFrame(() => {
1136
1136
  try {
1137
1137
  rf.fitView({ padding: 0.1 });
@@ -1140,14 +1140,14 @@ function Inner({ diagram, title, autoplay, nodeStates }) {
1140
1140
  });
1141
1141
  return () => cancelAnimationFrame(id);
1142
1142
  }, [layout, rf]);
1143
- const handleClickOutside = React45.useCallback((e) => {
1143
+ const handleClickOutside = React46.useCallback((e) => {
1144
1144
  if (containerRef.current && !containerRef.current.contains(e.target)) setFocused(false);
1145
1145
  }, []);
1146
- React45.useEffect(() => {
1146
+ React46.useEffect(() => {
1147
1147
  document.addEventListener("mousedown", handleClickOutside);
1148
1148
  return () => document.removeEventListener("mousedown", handleClickOutside);
1149
1149
  }, [handleClickOutside]);
1150
- React45.useEffect(() => {
1150
+ React46.useEffect(() => {
1151
1151
  const el = containerRef.current;
1152
1152
  if (!el) return;
1153
1153
  let raf = 0;
@@ -1299,23 +1299,84 @@ var init_FlowGraph = __esm({
1299
1299
  renderSeq = 0;
1300
1300
  }
1301
1301
  });
1302
+ function resolvePdfWorkerSrc(pdfjs2) {
1303
+ const override = typeof window !== "undefined" ? window.__GENUI_PDF_WORKER_SRC__ : void 0;
1304
+ const current = pdfjs2.GlobalWorkerOptions.workerSrc;
1305
+ const isConfigured = !!current && current !== "pdf.worker.mjs";
1306
+ if (override) {
1307
+ pdfjs2.GlobalWorkerOptions.workerSrc = override;
1308
+ } else if (!isConfigured) {
1309
+ pdfjs2.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${pdfjs2.version}/build/pdf.worker.min.mjs`;
1310
+ }
1311
+ return pdfjs2.GlobalWorkerOptions.workerSrc;
1312
+ }
1313
+ function probePdfWorker() {
1314
+ if (probe) return probe;
1315
+ probe = (async () => {
1316
+ if (typeof window === "undefined") return false;
1317
+ try {
1318
+ const { pdfjs: pdfjs2 } = await import('react-pdf');
1319
+ resolvePdfWorkerSrc(pdfjs2);
1320
+ const task = pdfjs2.getDocument({ data: new TextEncoder().encode(TINY_PDF) });
1321
+ const doc = await Promise.race([
1322
+ task.promise,
1323
+ new Promise(
1324
+ (_, reject) => setTimeout(() => reject(new Error("pdf worker probe timed out")), PROBE_TIMEOUT_MS)
1325
+ )
1326
+ ]);
1327
+ await doc.destroy();
1328
+ return true;
1329
+ } catch (e) {
1330
+ probe = null;
1331
+ return false;
1332
+ }
1333
+ })();
1334
+ return probe;
1335
+ }
1336
+ function usePdfWorkerReady(enabled) {
1337
+ const [ready, setReady] = React46.useState(null);
1338
+ React46.useEffect(() => {
1339
+ if (!enabled) return;
1340
+ let cancelled = false;
1341
+ probePdfWorker().then((ok) => {
1342
+ if (!cancelled) setReady(ok);
1343
+ });
1344
+ return () => {
1345
+ cancelled = true;
1346
+ };
1347
+ }, [enabled]);
1348
+ return enabled ? ready : null;
1349
+ }
1350
+ var TINY_PDF, PROBE_TIMEOUT_MS, probe;
1351
+ var init_pdfWorkerProbe = __esm({
1352
+ "src/shared/viewers/pdfWorkerProbe.ts"() {
1353
+ "use client";
1354
+ TINY_PDF = `%PDF-1.1
1355
+ 1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj
1356
+ 2 0 obj<</Type/Pages/Kids[3 0 R]/Count 1>>endobj
1357
+ 3 0 obj<</Type/Page/Parent 2 0 R/MediaBox[0 0 3 3]>>endobj
1358
+ trailer<</Root 1 0 R>>`;
1359
+ PROBE_TIMEOUT_MS = 5e3;
1360
+ probe = null;
1361
+ }
1362
+ });
1302
1363
 
1303
1364
  // src/composites/document-preview/PdfViewer.tsx
1304
1365
  var PdfViewer_exports = {};
1305
1366
  __export(PdfViewer_exports, {
1306
1367
  PdfViewer: () => PdfViewer
1307
1368
  });
1308
- function PdfViewer({ url, base64, onLoadSuccess }) {
1369
+ function PdfViewer({ url, base64, onLoadSuccess, onLoadError }) {
1309
1370
  const { BORDER: BORDER3, MUTED: MUTED2, SURFACE: SURFACE2 } = useTheme();
1310
- const [numPages, setNumPages] = React45.useState(0);
1311
- const [currentPage, setCurrentPage] = React45.useState(1);
1312
- const [loading, setLoading] = React45.useState(true);
1313
- const handleLoad = React45.useCallback(({ numPages: n }) => {
1371
+ const [numPages, setNumPages] = React46.useState(0);
1372
+ const [currentPage, setCurrentPage] = React46.useState(1);
1373
+ const [loading, setLoading] = React46.useState(true);
1374
+ const handleLoad = React46.useCallback(({ numPages: n }) => {
1314
1375
  setNumPages(n);
1315
1376
  setLoading(false);
1316
1377
  onLoadSuccess == null ? void 0 : onLoadSuccess(n);
1317
1378
  }, [onLoadSuccess]);
1318
- React45.useEffect(() => {
1379
+ React46.useEffect(() => {
1319
1380
  if (numPages <= 1) return;
1320
1381
  const handler = (e) => {
1321
1382
  var _a2;
@@ -1385,23 +1446,34 @@ function PdfViewer({ url, base64, onLoadSuccess }) {
1385
1446
  ] }),
1386
1447
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { overflow: "auto", width: "100%", display: "flex", justifyContent: "center", padding: "16px" }, children: [
1387
1448
  loading && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "200px", color: MUTED2, fontSize: "13px" }, children: "Loading PDF..." }),
1388
- /* @__PURE__ */ jsxRuntime.jsx(reactPdf.Document, { file: base64 ? `data:application/pdf;base64,${base64}` : url, onLoadSuccess: handleLoad, loading: "", children: /* @__PURE__ */ jsxRuntime.jsx(
1389
- reactPdf.Page,
1449
+ /* @__PURE__ */ jsxRuntime.jsx(
1450
+ reactPdf.Document,
1390
1451
  {
1391
- pageNumber: currentPage,
1392
- width: 540,
1393
- renderTextLayer: true,
1394
- renderAnnotationLayer: true
1452
+ file: base64 ? `data:application/pdf;base64,${base64}` : url,
1453
+ onLoadSuccess: handleLoad,
1454
+ onLoadError,
1455
+ loading: "",
1456
+ error: "",
1457
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1458
+ reactPdf.Page,
1459
+ {
1460
+ pageNumber: currentPage,
1461
+ width: 540,
1462
+ renderTextLayer: true,
1463
+ renderAnnotationLayer: true
1464
+ }
1465
+ )
1395
1466
  }
1396
- ) })
1467
+ )
1397
1468
  ] })
1398
1469
  ] });
1399
1470
  }
1400
1471
  var init_PdfViewer = __esm({
1401
1472
  "src/composites/document-preview/PdfViewer.tsx"() {
1402
1473
  "use client";
1474
+ init_pdfWorkerProbe();
1403
1475
  init_ThemeContext();
1404
- reactPdf.pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${reactPdf.pdfjs.version}/build/pdf.worker.min.mjs`;
1476
+ resolvePdfWorkerSrc(reactPdf.pdfjs);
1405
1477
  }
1406
1478
  });
1407
1479
 
@@ -1412,13 +1484,13 @@ __export(ExcelViewer_exports, {
1412
1484
  });
1413
1485
  function ExcelViewer({ url, base64, onLoadSuccess }) {
1414
1486
  const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SURFACE: SURFACE2 } = useTheme();
1415
- const [sheetNames, setSheetNames] = React45.useState([]);
1416
- const [activeSheet, setActiveSheet] = React45.useState(0);
1417
- const [data, setData] = React45.useState([]);
1418
- const [loading, setLoading] = React45.useState(true);
1419
- const [error, setError] = React45.useState(null);
1420
- const wbRef = React45.useRef(null);
1421
- React45.useEffect(() => {
1487
+ const [sheetNames, setSheetNames] = React46.useState([]);
1488
+ const [activeSheet, setActiveSheet] = React46.useState(0);
1489
+ const [data, setData] = React46.useState([]);
1490
+ const [loading, setLoading] = React46.useState(true);
1491
+ const [error, setError] = React46.useState(null);
1492
+ const wbRef = React46.useRef(null);
1493
+ React46.useEffect(() => {
1422
1494
  let cancelled = false;
1423
1495
  setLoading(true);
1424
1496
  setError(null);
@@ -1476,7 +1548,7 @@ function ExcelViewer({ url, base64, onLoadSuccess }) {
1476
1548
  const rows = XLSX__namespace.utils.sheet_to_json(wbRef.current.Sheets[wbRef.current.SheetNames[idx]], { header: 1 });
1477
1549
  setData(rows);
1478
1550
  };
1479
- React45.useEffect(() => {
1551
+ React46.useEffect(() => {
1480
1552
  if (sheetNames.length <= 1) return;
1481
1553
  const handler = (e) => {
1482
1554
  var _a2;
@@ -1602,10 +1674,10 @@ __export(CsvViewer_exports, {
1602
1674
  });
1603
1675
  function CsvViewer({ url, base64, delimiter, maxRows }) {
1604
1676
  const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2 } = useTheme();
1605
- const [rows, setRows] = React45.useState([]);
1606
- const [loading, setLoading] = React45.useState(true);
1607
- const [error, setError] = React45.useState(null);
1608
- React45.useEffect(() => {
1677
+ const [rows, setRows] = React46.useState([]);
1678
+ const [loading, setLoading] = React46.useState(true);
1679
+ const [error, setError] = React46.useState(null);
1680
+ React46.useEffect(() => {
1609
1681
  let cancelled = false;
1610
1682
  setLoading(true);
1611
1683
  setError(null);
@@ -1724,10 +1796,10 @@ __export(TextViewer_exports, {
1724
1796
  });
1725
1797
  function TextViewer({ url, base64, markdown = false, maxLines }) {
1726
1798
  const { MUTED: MUTED2 } = useTheme();
1727
- const [text, setText] = React45.useState("");
1728
- const [loading, setLoading] = React45.useState(true);
1729
- const [error, setError] = React45.useState(null);
1730
- React45.useEffect(() => {
1799
+ const [text, setText] = React46.useState("");
1800
+ const [loading, setLoading] = React46.useState(true);
1801
+ const [error, setError] = React46.useState(null);
1802
+ React46.useEffect(() => {
1731
1803
  let cancelled = false;
1732
1804
  setLoading(true);
1733
1805
  setError(null);
@@ -1825,10 +1897,10 @@ function sanitize(html) {
1825
1897
  }
1826
1898
  function DocxViewer({ url, base64 }) {
1827
1899
  const { MUTED: MUTED2, BORDER: BORDER3, SURFACE: SURFACE2 } = useTheme();
1828
- const [html, setHtml] = React45.useState("");
1829
- const [loading, setLoading] = React45.useState(true);
1830
- const [error, setError] = React45.useState(null);
1831
- React45.useEffect(() => {
1900
+ const [html, setHtml] = React46.useState("");
1901
+ const [loading, setLoading] = React46.useState(true);
1902
+ const [error, setError] = React46.useState(null);
1903
+ React46.useEffect(() => {
1832
1904
  let cancelled = false;
1833
1905
  setLoading(true);
1834
1906
  setError(null);
@@ -1908,6 +1980,89 @@ var init_DocxViewer = __esm({
1908
1980
  }
1909
1981
  });
1910
1982
 
1983
+ // src/shared/viewers/HtmlViewer.tsx
1984
+ var HtmlViewer_exports = {};
1985
+ __export(HtmlViewer_exports, {
1986
+ HtmlViewer: () => HtmlViewer
1987
+ });
1988
+ function HtmlViewer({ url, base64, height = 480 }) {
1989
+ const { MUTED: MUTED2 } = useTheme();
1990
+ const [html, setHtml] = React46.useState("");
1991
+ const [loading, setLoading] = React46.useState(true);
1992
+ const [error, setError] = React46.useState(null);
1993
+ React46.useEffect(() => {
1994
+ let cancelled = false;
1995
+ setLoading(true);
1996
+ setError(null);
1997
+ if (base64) {
1998
+ try {
1999
+ if (!cancelled) {
2000
+ setHtml(base64ToText(base64));
2001
+ setLoading(false);
2002
+ }
2003
+ } catch (e) {
2004
+ if (!cancelled) {
2005
+ setError(e instanceof Error ? e.message : "Failed to decode HTML");
2006
+ setLoading(false);
2007
+ }
2008
+ }
2009
+ return () => {
2010
+ cancelled = true;
2011
+ };
2012
+ }
2013
+ if (!url) {
2014
+ setError("No file source provided");
2015
+ setLoading(false);
2016
+ return () => {
2017
+ cancelled = true;
2018
+ };
2019
+ }
2020
+ fetch(url).then((r) => {
2021
+ if (!r.ok) throw new Error(`Failed to fetch: ${r.status}`);
2022
+ return r.text();
2023
+ }).then((t) => {
2024
+ if (cancelled) return;
2025
+ setHtml(t);
2026
+ setLoading(false);
2027
+ }).catch((e) => {
2028
+ if (cancelled) return;
2029
+ setError(e.message);
2030
+ setLoading(false);
2031
+ });
2032
+ return () => {
2033
+ cancelled = true;
2034
+ };
2035
+ }, [url, base64]);
2036
+ if (loading) {
2037
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "24px", color: MUTED2, fontSize: "13px", textAlign: "center" }, children: "Loading\u2026" });
2038
+ }
2039
+ if (error) {
2040
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "24px", color: "#dc2626", fontSize: "13px", textAlign: "center" }, children: error });
2041
+ }
2042
+ return /* @__PURE__ */ jsxRuntime.jsx(
2043
+ "iframe",
2044
+ {
2045
+ title: "HTML preview",
2046
+ sandbox: "",
2047
+ srcDoc: html,
2048
+ style: {
2049
+ width: "100%",
2050
+ height: `${height}px`,
2051
+ border: "none",
2052
+ background: "white",
2053
+ display: "block"
2054
+ }
2055
+ }
2056
+ );
2057
+ }
2058
+ var init_HtmlViewer = __esm({
2059
+ "src/shared/viewers/HtmlViewer.tsx"() {
2060
+ "use client";
2061
+ init_ThemeContext();
2062
+ init_decode();
2063
+ }
2064
+ });
2065
+
1911
2066
  // src/index.ts
1912
2067
  init_ThemeContext();
1913
2068
  var dataTableSchema = zod.z.object({
@@ -6089,16 +6244,16 @@ var DOT_COLOR = "#aaaaaa";
6089
6244
  var DOT_HOVER = "#555555";
6090
6245
  function ComponentActions({ children, onDownloadCSV, columnConfig, filename = "component" }) {
6091
6246
  const { BORDER: BORDER3, MUTED: MUTED2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2 } = useTheme();
6092
- const [open, setOpen] = React45.useState(false);
6093
- const [view, setView] = React45.useState("main");
6094
- const contentRef = React45.useRef(null);
6095
- const menuRef = React45.useRef(null);
6096
- const btnRef = React45.useRef(null);
6097
- const close = React45.useCallback(() => {
6247
+ const [open, setOpen] = React46.useState(false);
6248
+ const [view, setView] = React46.useState("main");
6249
+ const contentRef = React46.useRef(null);
6250
+ const menuRef = React46.useRef(null);
6251
+ const btnRef = React46.useRef(null);
6252
+ const close = React46.useCallback(() => {
6098
6253
  setOpen(false);
6099
6254
  setView("main");
6100
6255
  }, []);
6101
- React45.useEffect(() => {
6256
+ React46.useEffect(() => {
6102
6257
  if (!open) return;
6103
6258
  const handler = (e) => {
6104
6259
  var _a2, _b;
@@ -6109,7 +6264,7 @@ function ComponentActions({ children, onDownloadCSV, columnConfig, filename = "c
6109
6264
  document.addEventListener("mousedown", handler);
6110
6265
  return () => document.removeEventListener("mousedown", handler);
6111
6266
  }, [open, close]);
6112
- const handleDownloadPNG = React45.useCallback(async () => {
6267
+ const handleDownloadPNG = React46.useCallback(async () => {
6113
6268
  if (!contentRef.current) return;
6114
6269
  try {
6115
6270
  const url = await htmlToImage.toPng(contentRef.current, { backgroundColor: "white", pixelRatio: 2 });
@@ -6121,7 +6276,7 @@ function ComponentActions({ children, onDownloadCSV, columnConfig, filename = "c
6121
6276
  }
6122
6277
  close();
6123
6278
  }, [filename, close]);
6124
- const handleCSV = React45.useCallback(() => {
6279
+ const handleCSV = React46.useCallback(() => {
6125
6280
  onDownloadCSV == null ? void 0 : onDownloadCSV();
6126
6281
  close();
6127
6282
  }, [onDownloadCSV, close]);
@@ -6234,12 +6389,12 @@ function MenuButton({ label, onClick }) {
6234
6389
  );
6235
6390
  }
6236
6391
  function useColumnVisibility(columns) {
6237
- const [hidden, setHidden] = React45.useState(/* @__PURE__ */ new Set());
6238
- const visibleColumns = React45.useMemo(
6392
+ const [hidden, setHidden] = React46.useState(/* @__PURE__ */ new Set());
6393
+ const visibleColumns = React46.useMemo(
6239
6394
  () => columns.filter((c) => !hidden.has(c.key)),
6240
6395
  [columns, hidden]
6241
6396
  );
6242
- const toggle = React45.useCallback((key) => {
6397
+ const toggle = React46.useCallback((key) => {
6243
6398
  setHidden((prev) => {
6244
6399
  const next = new Set(prev);
6245
6400
  if (next.has(key)) next.delete(key);
@@ -6247,8 +6402,8 @@ function useColumnVisibility(columns) {
6247
6402
  return next;
6248
6403
  });
6249
6404
  }, []);
6250
- const showAll = React45.useCallback(() => setHidden(/* @__PURE__ */ new Set()), []);
6251
- const hideAll = React45.useCallback(
6405
+ const showAll = React46.useCallback(() => setHidden(/* @__PURE__ */ new Set()), []);
6406
+ const hideAll = React46.useCallback(
6252
6407
  () => setHidden(new Set(columns.map((c) => c.key))),
6253
6408
  [columns]
6254
6409
  );
@@ -6505,9 +6660,9 @@ function AlertResolver(p) {
6505
6660
  // src/composites/stat-grid/resolver.tsx
6506
6661
  init_Markdown();
6507
6662
  function FitText({ children, max = 22, min = 13, title, className, style }) {
6508
- const ref = React45.useRef(null);
6509
- const [size, setSize] = React45.useState(max);
6510
- React45.useLayoutEffect(() => {
6663
+ const ref = React46.useRef(null);
6664
+ const [size, setSize] = React46.useState(max);
6665
+ React46.useLayoutEffect(() => {
6511
6666
  const el = ref.current;
6512
6667
  if (!el) return void 0;
6513
6668
  const fit = () => {
@@ -6601,7 +6756,7 @@ init_ThemeContext();
6601
6756
  function TabsPanelResolver(p) {
6602
6757
  var _a2;
6603
6758
  const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SURFACE: SURFACE2, ACCENT: ACCENT2 } = useTheme();
6604
- const [activeIdx, setActiveIdx] = React45.useState(0);
6759
+ const [activeIdx, setActiveIdx] = React46.useState(0);
6605
6760
  const activeTab = p.tabs[activeIdx];
6606
6761
  return /* @__PURE__ */ jsxRuntime.jsx(ComponentActions, { filename: "tabs-panel", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "0" }, children: [
6607
6762
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -6865,7 +7020,7 @@ var thStyle = (MUTED2, BORDER3, PAPER2) => ({
6865
7020
  function ScreenerTableResolver(p) {
6866
7021
  var _a2, _b, _c, _d, _e, _f;
6867
7022
  const { ACCENT: ACCENT2, BORDER: BORDER3, BORDER_SOFT: BORDER_SOFT2, MUTED: MUTED2, PAPER: PAPER2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2 } = useTheme();
6868
- const [activeFilters, setActiveFilters] = React45.useState(new Set((_a2 = p.activeFilters) != null ? _a2 : []));
7023
+ const [activeFilters, setActiveFilters] = React46.useState(new Set((_a2 = p.activeFilters) != null ? _a2 : []));
6869
7024
  const { visibleColumns, hidden, toggle, showAll, hideAll, allColumns } = useColumnVisibility((_b = p.columns) != null ? _b : []);
6870
7025
  const toggleFilter = (f) => setActiveFilters((prev) => {
6871
7026
  const next = new Set(prev);
@@ -6935,7 +7090,7 @@ var th2 = (MUTED2, BORDER3, PAPER2) => ({
6935
7090
  function GroupRows({ group, columns, depth }) {
6936
7091
  var _a2, _b;
6937
7092
  const { MUTED: MUTED2, PAPER: PAPER2, BORDER_SOFT: BORDER_SOFT2 } = useTheme();
6938
- const [open, setOpen] = React45.useState(true);
7093
+ const [open, setOpen] = React46.useState(true);
6939
7094
  const indent = depth * 14;
6940
7095
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6941
7096
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -7040,7 +7195,7 @@ var dotColor = {
7040
7195
  function NewsFeedResolver(p) {
7041
7196
  var _a2, _b;
7042
7197
  const { ACCENT: ACCENT2, MUTED: MUTED2, SURFACE: SURFACE2, SHADOW: SHADOW2 } = useTheme();
7043
- const [filter, setFilter] = React45.useState(null);
7198
+ const [filter, setFilter] = React46.useState(null);
7044
7199
  const sentiments = ["positive", "neutral", "negative"].filter(
7045
7200
  (s) => {
7046
7201
  var _a3;
@@ -7082,9 +7237,9 @@ function NewsFeedResolver(p) {
7082
7237
  ] }) });
7083
7238
  }
7084
7239
  function useSeriesToggle(seriesKeys) {
7085
- const [hidden, setHidden] = React45.useState(/* @__PURE__ */ new Set());
7086
- const isVisible = React45.useCallback((key) => !hidden.has(key), [hidden]);
7087
- const toggle = React45.useCallback((key) => {
7240
+ const [hidden, setHidden] = React46.useState(/* @__PURE__ */ new Set());
7241
+ const isVisible = React46.useCallback((key) => !hidden.has(key), [hidden]);
7242
+ const toggle = React46.useCallback((key) => {
7088
7243
  setHidden((prev) => {
7089
7244
  const next = new Set(prev);
7090
7245
  if (next.has(key)) next.delete(key);
@@ -7092,7 +7247,7 @@ function useSeriesToggle(seriesKeys) {
7092
7247
  return next;
7093
7248
  });
7094
7249
  }, []);
7095
- const showAll = React45.useCallback(() => setHidden(/* @__PURE__ */ new Set()), []);
7250
+ const showAll = React46.useCallback(() => setHidden(/* @__PURE__ */ new Set()), []);
7096
7251
  return { hidden, isVisible, toggle, showAll, allKeys: seriesKeys };
7097
7252
  }
7098
7253
 
@@ -7397,7 +7552,7 @@ function WaterfallChartResolver(p) {
7397
7552
  }
7398
7553
  init_ThemeContext();
7399
7554
  init_theme();
7400
- var FlowGraph2 = React45__default.default.lazy(
7555
+ var FlowGraph2 = React46__default.default.lazy(
7401
7556
  () => Promise.resolve().then(() => (init_FlowGraph(), FlowGraph_exports)).then((m) => ({ default: m.FlowGraph }))
7402
7557
  );
7403
7558
  function FlowCanvasRenderer({
@@ -7438,7 +7593,7 @@ function FlowCanvasRenderer({
7438
7593
  overflow: "hidden",
7439
7594
  background: SURFACE2,
7440
7595
  position: "relative"
7441
- }, diagram ? {} : { height: "320px" }), children: diagram ? /* @__PURE__ */ jsxRuntime.jsx(React45.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(FlowGraph2, { diagram, title, autoplay, nodeStates }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
7596
+ }, diagram ? {} : { height: "320px" }), children: diagram ? /* @__PURE__ */ jsxRuntime.jsx(React46.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(FlowGraph2, { diagram, title, autoplay, nodeStates }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
7442
7597
  position: "absolute",
7443
7598
  inset: 0,
7444
7599
  display: "flex",
@@ -7673,7 +7828,7 @@ function TrialBalanceResolver(p) {
7673
7828
  gDebit += a.debit;
7674
7829
  gCredit += a.credit;
7675
7830
  });
7676
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
7831
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
7677
7832
  /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: 4, style: {
7678
7833
  padding: "8px 12px",
7679
7834
  fontSize: "12px",
@@ -8211,7 +8366,7 @@ function ItemRow({ item }) {
8211
8366
  }
8212
8367
  function Section({ section }) {
8213
8368
  const { BORDER: BORDER3, MUTED: MUTED2, SURFACE: SURFACE2 } = useTheme();
8214
- const [open, setOpen] = React45.useState(true);
8369
+ const [open, setOpen] = React46.useState(true);
8215
8370
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
8216
8371
  /* @__PURE__ */ jsxRuntime.jsxs(
8217
8372
  "button",
@@ -8334,7 +8489,7 @@ function ReconciliationViewResolver(p) {
8334
8489
  const { BORDER: BORDER3, BORDER_SOFT: BORDER_SOFT2, MUTED: MUTED2, PAPER: PAPER2, ACCENT: ACCENT2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2 } = useTheme();
8335
8490
  const sourceA = (_a2 = p.sourceA) != null ? _a2 : { label: "Source A" };
8336
8491
  const sourceB = (_b = p.sourceB) != null ? _b : { label: "Source B" };
8337
- const [activeTab, setActiveTab] = React45.useState("matched");
8492
+ const [activeTab, setActiveTab] = React46.useState("matched");
8338
8493
  const balanceA = (_d = (_c = p.summary) == null ? void 0 : _c.balanceA) != null ? _d : 0;
8339
8494
  const balanceB = (_f = (_e = p.summary) == null ? void 0 : _e.balanceB) != null ? _f : 0;
8340
8495
  const difference = (_h = (_g = p.summary) == null ? void 0 : _g.difference) != null ? _h : balanceA - balanceB;
@@ -8980,7 +9135,7 @@ function ChangesView({ changes }) {
8980
9135
  function EventCard({ event }) {
8981
9136
  var _a2;
8982
9137
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, SURFACE: SURFACE2 } = useTheme();
8983
- const [showChanges, setShowChanges] = React45.useState(false);
9138
+ const [showChanges, setShowChanges] = React46.useState(false);
8984
9139
  const ac = (_a2 = actionConfig[event.action]) != null ? _a2 : actionConfig.commented;
8985
9140
  const hasChanges = event.changes && event.changes.length > 0;
8986
9141
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "12px", position: "relative" }, children: [
@@ -9038,23 +9193,23 @@ function AuditTrailResolver(p) {
9038
9193
  }
9039
9194
  init_Markdown();
9040
9195
  function useFullscreen(ref) {
9041
- const [isFullscreen, setIsFullscreen] = React45.useState(false);
9042
- React45.useEffect(() => {
9196
+ const [isFullscreen, setIsFullscreen] = React46.useState(false);
9197
+ React46.useEffect(() => {
9043
9198
  const handler = () => {
9044
9199
  setIsFullscreen(!!document.fullscreenElement);
9045
9200
  };
9046
9201
  document.addEventListener("fullscreenchange", handler);
9047
9202
  return () => document.removeEventListener("fullscreenchange", handler);
9048
9203
  }, []);
9049
- const enter = React45.useCallback(() => {
9204
+ const enter = React46.useCallback(() => {
9050
9205
  var _a2, _b;
9051
9206
  (_b = (_a2 = ref.current) == null ? void 0 : _a2.requestFullscreen) == null ? void 0 : _b.call(_a2);
9052
9207
  }, [ref]);
9053
- const exit = React45.useCallback(() => {
9208
+ const exit = React46.useCallback(() => {
9054
9209
  var _a2;
9055
9210
  if (document.fullscreenElement) (_a2 = document.exitFullscreen) == null ? void 0 : _a2.call(document);
9056
9211
  }, []);
9057
- const toggle = React45.useCallback(() => {
9212
+ const toggle = React46.useCallback(() => {
9058
9213
  if (isFullscreen) exit();
9059
9214
  else enter();
9060
9215
  }, [isFullscreen, enter, exit]);
@@ -9064,10 +9219,11 @@ function useFullscreen(ref) {
9064
9219
  // src/composites/document-preview/resolver.tsx
9065
9220
  init_theme();
9066
9221
  init_ThemeContext();
9067
- var PdfViewer2 = React45__default.default.lazy(
9222
+ init_pdfWorkerProbe();
9223
+ var PdfViewer2 = React46__default.default.lazy(
9068
9224
  () => Promise.resolve().then(() => (init_PdfViewer(), PdfViewer_exports)).then((m) => ({ default: m.PdfViewer }))
9069
9225
  );
9070
- var ExcelViewer2 = React45__default.default.lazy(
9226
+ var ExcelViewer2 = React46__default.default.lazy(
9071
9227
  () => Promise.resolve().then(() => (init_ExcelViewer(), ExcelViewer_exports)).then((m) => ({ default: m.ExcelViewer }))
9072
9228
  );
9073
9229
  var highlightColors = {
@@ -9118,8 +9274,8 @@ function DownloadIcon() {
9118
9274
  function DocumentPreviewResolver(p) {
9119
9275
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
9120
9276
  const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, ACCENT: ACCENT2, SURFACE: SURFACE2, SHADOW: SHADOW2 } = useTheme();
9121
- const [currentPage, setCurrentPage] = React45.useState(0);
9122
- const containerRef = React45.useRef(null);
9277
+ const [currentPage, setCurrentPage] = React46.useState(0);
9278
+ const containerRef = React46.useRef(null);
9123
9279
  const { isFullscreen, toggle } = useFullscreen(containerRef);
9124
9280
  const hasRealFile = !!(((_a2 = p.source) == null ? void 0 : _a2.url) || ((_b = p.source) == null ? void 0 : _b.base64));
9125
9281
  const isPdf = p.documentType === "pdf";
@@ -9127,9 +9283,15 @@ function DocumentPreviewResolver(p) {
9127
9283
  const totalPages = ((_c = p.pages) != null ? _c : []).length;
9128
9284
  const page = p.pages[currentPage];
9129
9285
  const pageHighlights = ((_d = p.highlights) != null ? _d : []).filter((h) => h.pageIndex === currentPage);
9130
- const handlePdfLoad = React45.useCallback(() => {
9286
+ const [pdfFailed, setPdfFailed] = React46.useState(false);
9287
+ const pdfWorkerReady = usePdfWorkerReady(hasRealFile && isPdf);
9288
+ const pdfReady = pdfFailed ? false : pdfWorkerReady;
9289
+ const showPdfViewer = hasRealFile && isPdf && pdfReady === true;
9290
+ const pdfPending = hasRealFile && isPdf && pdfReady === null;
9291
+ const handlePdfLoad = React46.useCallback(() => {
9131
9292
  }, []);
9132
- const handleExcelLoad = React45.useCallback(() => {
9293
+ const handlePdfError = React46.useCallback(() => setPdfFailed(true), []);
9294
+ const handleExcelLoad = React46.useCallback(() => {
9133
9295
  }, []);
9134
9296
  return /* @__PURE__ */ jsxRuntime.jsx(ComponentActions, { filename: (_e = p.title) != null ? _e : "document-preview", children: /* @__PURE__ */ jsxRuntime.jsxs(
9135
9297
  "div",
@@ -9222,7 +9384,7 @@ function DocumentPreviewResolver(p) {
9222
9384
  children: pg.label
9223
9385
  },
9224
9386
  i
9225
- )) }) : !hasRealFile && totalPages > 1 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "6px 14px", borderLeft: `1px solid ${BORDER3}`, borderRight: `1px solid ${BORDER3}`, background: SURFACE2 }, children: [
9387
+ )) }) : (!hasRealFile || pdfReady === false) && totalPages > 1 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "6px 14px", borderLeft: `1px solid ${BORDER3}`, borderRight: `1px solid ${BORDER3}`, background: SURFACE2 }, children: [
9226
9388
  /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => setCurrentPage(Math.max(0, currentPage - 1)), disabled: currentPage === 0, style: { border: `1px solid ${BORDER3}`, borderRadius: "4px", padding: "2px 8px", background: SURFACE2, cursor: "pointer", fontSize: "12px", color: currentPage === 0 ? BORDER3 : MUTED2 }, children: "\u2190" }),
9227
9389
  /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: "12px", color: MUTED2 }, children: [
9228
9390
  currentPage + 1,
@@ -9242,7 +9404,7 @@ function DocumentPreviewResolver(p) {
9242
9404
  display: "flex",
9243
9405
  flexDirection: "column"
9244
9406
  }, children: [
9245
- hasRealFile && isPdf ? /* @__PURE__ */ jsxRuntime.jsx(React45.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(PdfViewer2, { url: (_q = p.source) == null ? void 0 : _q.url, base64: (_r = p.source) == null ? void 0 : _r.base64, onLoadSuccess: handlePdfLoad }) }) : hasRealFile && isExcel ? /* @__PURE__ */ jsxRuntime.jsx(React45.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(ExcelViewer2, { url: (_s = p.source) == null ? void 0 : _s.url, base64: (_t = p.source) == null ? void 0 : _t.base64, onLoadSuccess: handleExcelLoad }) }) : (page == null ? void 0 : page.imageUrl) ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "20px" }, children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: page.imageUrl, alt: page.label, style: { maxWidth: "100%", borderRadius: "4px" } }) }) : (page == null ? void 0 : page.content) ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontFamily: "var(--font-sans, system-ui)", fontSize: "13px", color: "var(--foreground)", lineHeight: 1.6, margin: 0, padding: "20px" }, children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { content: page.content }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "120px", color: MUTED2, fontSize: "13px" }, children: [
9407
+ showPdfViewer ? /* @__PURE__ */ jsxRuntime.jsx(React46.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(PdfViewer2, { url: (_q = p.source) == null ? void 0 : _q.url, base64: (_r = p.source) == null ? void 0 : _r.base64, onLoadSuccess: handlePdfLoad, onLoadError: handlePdfError }) }) : pdfPending ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "200px", color: MUTED2, fontSize: "13px" }, children: "Loading preview\u2026" }) : hasRealFile && isExcel ? /* @__PURE__ */ jsxRuntime.jsx(React46.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(ExcelViewer2, { url: (_s = p.source) == null ? void 0 : _s.url, base64: (_t = p.source) == null ? void 0 : _t.base64, onLoadSuccess: handleExcelLoad }) }) : (page == null ? void 0 : page.imageUrl) ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "20px" }, children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: page.imageUrl, alt: page.label, style: { maxWidth: "100%", borderRadius: "4px" } }) }) : (page == null ? void 0 : page.content) ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontFamily: "var(--font-sans, system-ui)", fontSize: "13px", color: "var(--foreground)", lineHeight: 1.6, margin: 0, padding: "20px" }, children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { content: page.content }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "120px", color: MUTED2, fontSize: "13px" }, children: [
9246
9408
  "No content available for ",
9247
9409
  (_u = page == null ? void 0 : page.label) != null ? _u : "this page"
9248
9410
  ] }),
@@ -9307,7 +9469,7 @@ function ConfidenceBar({ confidence, height = 6 }) {
9307
9469
  function StepCard({ step, isLast }) {
9308
9470
  var _a2;
9309
9471
  const { ACCENT: ACCENT2, MUTED: MUTED2, BORDER: BORDER3, SURFACE_MUTED: SURFACE_MUTED2 } = useTheme();
9310
- const [expanded, setExpanded] = React45.useState(false);
9472
+ const [expanded, setExpanded] = React46.useState(false);
9311
9473
  const cfg = stepTypeConfig[step.stepType];
9312
9474
  const detail = (_a2 = step.detail) != null ? _a2 : "";
9313
9475
  const isLong = detail.length > 100;
@@ -9816,7 +9978,7 @@ function ExampleRow({ example }) {
9816
9978
  }
9817
9979
  function PartSection({ part, defaultOpen }) {
9818
9980
  const { BORDER: BORDER3, MUTED: MUTED2, SURFACE: SURFACE2 } = useTheme();
9819
- const [open, setOpen] = React45.useState(defaultOpen);
9981
+ const [open, setOpen] = React46.useState(defaultOpen);
9820
9982
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
9821
9983
  /* @__PURE__ */ jsxRuntime.jsxs(
9822
9984
  "button",
@@ -9946,7 +10108,7 @@ function EngagementPipelineResolver(p) {
9946
10108
  const defaultActive = phases.findIndex(
9947
10109
  (ph) => ph.status === "in-progress" || ph.status === "blocked"
9948
10110
  );
9949
- const [activeIdx, setActiveIdx] = React45.useState(defaultActive >= 0 ? defaultActive : 0);
10111
+ const [activeIdx, setActiveIdx] = React46.useState(defaultActive >= 0 ? defaultActive : 0);
9950
10112
  const activePhase = phases[activeIdx];
9951
10113
  return /* @__PURE__ */ jsxRuntime.jsx(ComponentActions, { filename: (_b = p.title) != null ? _b : "engagement-pipeline", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
9952
10114
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
@@ -10030,7 +10192,7 @@ function EngagementPipelineResolver(p) {
10030
10192
  const color = (_a3 = statusColor2[phase.status]) != null ? _a3 : "#d6d3d1";
10031
10193
  const isCurrent = i === activeIdx;
10032
10194
  const size = isCurrent ? 28 : 20;
10033
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
10195
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
10034
10196
  i > 0 && /* @__PURE__ */ jsxRuntime.jsx(
10035
10197
  "div",
10036
10198
  {
@@ -10338,7 +10500,7 @@ function Avatar({ name, avatar, hovered }) {
10338
10500
  function EntityCardGridResolver(p) {
10339
10501
  var _a2, _b;
10340
10502
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, SHADOW: SHADOW2 } = useTheme();
10341
- const [hoveredId, setHoveredId] = React45.useState(null);
10503
+ const [hoveredId, setHoveredId] = React46.useState(null);
10342
10504
  return /* @__PURE__ */ jsxRuntime.jsx(ComponentActions, { filename: (_a2 = p.title) != null ? _a2 : "entity-card-grid", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "10px" }, children: [
10343
10505
  p.title && /* @__PURE__ */ jsxRuntime.jsx(
10344
10506
  "p",
@@ -10595,7 +10757,7 @@ function StepRow({ step }) {
10595
10757
  function JobTrackerResolver(p) {
10596
10758
  var _a2, _b, _c, _d, _e, _f, _g;
10597
10759
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, PAPER: PAPER2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2, SHADOW: SHADOW2 } = useTheme();
10598
- const [stepsOpen, setStepsOpen] = React45.useState(true);
10760
+ const [stepsOpen, setStepsOpen] = React46.useState(true);
10599
10761
  const barColor = (_a2 = statusColors[p.status]) != null ? _a2 : MUTED2;
10600
10762
  const badge = (_b = statusBadgeConfig[p.status]) != null ? _b : statusBadgeConfig.queued;
10601
10763
  const progress = (_c = p.progress) != null ? _c : p.status === "completed" ? 100 : 0;
@@ -11038,7 +11200,7 @@ function CitationCard({
11038
11200
  }
11039
11201
  function FollowUpItem({ text }) {
11040
11202
  const { SECONDARY: SECONDARY2 } = useTheme();
11041
- const [hovered, setHovered] = React45.useState(false);
11203
+ const [hovered, setHovered] = React46.useState(false);
11042
11204
  return /* @__PURE__ */ jsxRuntime.jsxs(
11043
11205
  "span",
11044
11206
  {
@@ -11064,7 +11226,7 @@ function CitationMarker({
11064
11226
  onClick
11065
11227
  }) {
11066
11228
  const { SECONDARY: SECONDARY2 } = useTheme();
11067
- const [hovered, setHovered] = React45.useState(false);
11229
+ const [hovered, setHovered] = React46.useState(false);
11068
11230
  return /* @__PURE__ */ jsxRuntime.jsx(
11069
11231
  "sup",
11070
11232
  {
@@ -11093,7 +11255,7 @@ function CitationMarker({
11093
11255
  function CitedAnswerResolver(p) {
11094
11256
  var _a2, _b, _c, _d, _e;
11095
11257
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, SECONDARY: SECONDARY2, SURFACE: SURFACE2, SHADOW: SHADOW2 } = useTheme();
11096
- const [expandedIds, setExpandedIds] = React45.useState(/* @__PURE__ */ new Set());
11258
+ const [expandedIds, setExpandedIds] = React46.useState(/* @__PURE__ */ new Set());
11097
11259
  const toggleCitation = (id) => {
11098
11260
  setExpandedIds((prev) => {
11099
11261
  const next = new Set(prev);
@@ -11398,7 +11560,7 @@ function TransactionFeedResolver(p) {
11398
11560
  var _a2, _b, _c, _d, _e;
11399
11561
  const { BORDER: BORDER3, MUTED: MUTED2 } = useTheme();
11400
11562
  const currency = (_a2 = p.currency) != null ? _a2 : "USD";
11401
- const [hoveredIndex, setHoveredIndex] = React45.useState(null);
11563
+ const [hoveredIndex, setHoveredIndex] = React46.useState(null);
11402
11564
  const hasBalance = ((_b = p.transactions) != null ? _b : []).some((tx) => tx.balance != null);
11403
11565
  const totalInflows = p.transactions.filter((tx) => tx.amount > 0 && tx.status !== "reversed").reduce((sum, tx) => sum + tx.amount, 0);
11404
11566
  const totalOutflows = p.transactions.filter((tx) => tx.amount < 0 && tx.status !== "reversed").reduce((sum, tx) => sum + tx.amount, 0);
@@ -11556,7 +11718,7 @@ function formatDate2(dateStr) {
11556
11718
  function FileRow({ item }) {
11557
11719
  var _a2;
11558
11720
  const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SURFACE: SURFACE2, SECONDARY: SECONDARY2 } = useTheme();
11559
- const [hovered, setHovered] = React45.useState(false);
11721
+ const [hovered, setHovered] = React46.useState(false);
11560
11722
  const cfg = getDocConfig(item.docType);
11561
11723
  return /* @__PURE__ */ jsxRuntime.jsxs(
11562
11724
  "div",
@@ -11633,8 +11795,8 @@ function FileRow({ item }) {
11633
11795
  }
11634
11796
  function GroupSection({ groupName, items }) {
11635
11797
  const { BORDER: BORDER3, MUTED: MUTED2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2 } = useTheme();
11636
- const [open, setOpen] = React45.useState(true);
11637
- const [headerHovered, setHeaderHovered] = React45.useState(false);
11798
+ const [open, setOpen] = React46.useState(true);
11799
+ const [headerHovered, setHeaderHovered] = React46.useState(false);
11638
11800
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11639
11801
  /* @__PURE__ */ jsxRuntime.jsxs(
11640
11802
  "button",
@@ -11750,7 +11912,7 @@ init_theme();
11750
11912
  var FAMILIES = [
11751
11913
  { exts: ["csv", "tsv", "xls", "xlsx", "numbers"], fg: exports.SEMANTIC.success.color, bg: exports.SEMANTIC.success.bg },
11752
11914
  { exts: ["pdf"], fg: exports.SEMANTIC.error.color, bg: exports.SEMANTIC.error.bg },
11753
- { exts: ["doc", "docx", "txt", "md", "rtf", "pages"], fg: exports.SEMANTIC.info.color, bg: exports.SEMANTIC.info.bg },
11915
+ { exts: ["doc", "docx", "txt", "md", "rtf", "pages", "html", "htm"], fg: exports.SEMANTIC.info.color, bg: exports.SEMANTIC.info.bg },
11754
11916
  { exts: ["json", "yaml", "yml", "xml", "toml"], fg: exports.SEMANTIC.purple.color, bg: exports.SEMANTIC.purple.bg },
11755
11917
  { exts: ["zip", "tar", "gz", "rar", "7z"], fg: exports.SEMANTIC.warning.color, bg: exports.SEMANTIC.warning.bg },
11756
11918
  { exts: ["png", "jpg", "jpeg", "gif", "svg", "webp", "bmp"], fg: exports.SEMANTIC.info.color, bg: exports.SEMANTIC.info.bg }
@@ -11777,7 +11939,9 @@ var PREVIEW_EXTS = {
11777
11939
  txt: "text",
11778
11940
  log: "text",
11779
11941
  text: "text",
11780
- docx: "docx"
11942
+ docx: "docx",
11943
+ html: "html",
11944
+ htm: "html"
11781
11945
  };
11782
11946
  function extOf(fileType, filename) {
11783
11947
  var _a2;
@@ -11788,6 +11952,7 @@ function extOf(fileType, filename) {
11788
11952
  if (mime.includes("csv")) return "csv";
11789
11953
  if (mime.includes("markdown")) return "md";
11790
11954
  if (mime.includes("wordprocessing") || mime.includes("msword")) return "docx";
11955
+ if (mime.includes("html")) return "html";
11791
11956
  if (mime.startsWith("text/")) return "txt";
11792
11957
  } else if (fileType) {
11793
11958
  const t = fileType.toLowerCase().replace(/[^a-z0-9]/g, "");
@@ -11824,17 +11989,32 @@ function isExpirySoon(expiresAt) {
11824
11989
 
11825
11990
  // src/shared/viewers/PreviewHost.tsx
11826
11991
  init_ThemeContext();
11827
- var PdfViewer3 = React45.lazy(
11992
+ init_pdfWorkerProbe();
11993
+ var PdfViewer3 = React46.lazy(
11828
11994
  () => Promise.resolve().then(() => (init_PdfViewer(), PdfViewer_exports)).then((m) => ({ default: m.PdfViewer }))
11829
11995
  );
11830
- var ExcelViewer3 = React45.lazy(
11996
+ var ExcelViewer3 = React46.lazy(
11831
11997
  () => Promise.resolve().then(() => (init_ExcelViewer(), ExcelViewer_exports)).then((m) => ({ default: m.ExcelViewer }))
11832
11998
  );
11833
- var CsvViewer2 = React45.lazy(() => Promise.resolve().then(() => (init_CsvViewer(), CsvViewer_exports)).then((m) => ({ default: m.CsvViewer })));
11834
- var TextViewer2 = React45.lazy(() => Promise.resolve().then(() => (init_TextViewer(), TextViewer_exports)).then((m) => ({ default: m.TextViewer })));
11835
- var DocxViewer2 = React45.lazy(() => Promise.resolve().then(() => (init_DocxViewer(), DocxViewer_exports)).then((m) => ({ default: m.DocxViewer })));
11999
+ var CsvViewer2 = React46.lazy(() => Promise.resolve().then(() => (init_CsvViewer(), CsvViewer_exports)).then((m) => ({ default: m.CsvViewer })));
12000
+ var TextViewer2 = React46.lazy(() => Promise.resolve().then(() => (init_TextViewer(), TextViewer_exports)).then((m) => ({ default: m.TextViewer })));
12001
+ var DocxViewer2 = React46.lazy(() => Promise.resolve().then(() => (init_DocxViewer(), DocxViewer_exports)).then((m) => ({ default: m.DocxViewer })));
12002
+ var HtmlViewer2 = React46.lazy(() => Promise.resolve().then(() => (init_HtmlViewer(), HtmlViewer_exports)).then((m) => ({ default: m.HtmlViewer })));
11836
12003
  var PEEK_ROWS = 20;
11837
12004
  var PEEK_LINES = 40;
12005
+ function GatedPdfViewer({ source }) {
12006
+ const { MUTED: MUTED2 } = useTheme();
12007
+ const [failed, setFailed] = React46.useState(false);
12008
+ const workerReady = usePdfWorkerReady(true);
12009
+ const ready = failed ? false : workerReady;
12010
+ if (ready === null) {
12011
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "24px", color: MUTED2, fontSize: "13px", textAlign: "center" }, children: "Loading preview\u2026" });
12012
+ }
12013
+ if (ready === false) {
12014
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "24px", color: MUTED2, fontSize: "13px", textAlign: "center" }, children: "Preview unavailable \u2014 download the file to view it." });
12015
+ }
12016
+ return /* @__PURE__ */ jsxRuntime.jsx(PdfViewer3, { url: source.url, base64: source.base64, onLoadError: () => setFailed(true) });
12017
+ }
11838
12018
  function PreviewHost({ kind, source, mode = "full" }) {
11839
12019
  const { MUTED: MUTED2 } = useTheme();
11840
12020
  const peek = mode === "peek";
@@ -11842,7 +12022,7 @@ function PreviewHost({ kind, source, mode = "full" }) {
11842
12022
  let viewer = null;
11843
12023
  switch (kind) {
11844
12024
  case "pdf":
11845
- viewer = /* @__PURE__ */ jsxRuntime.jsx(PdfViewer3, { url: source.url, base64: source.base64 });
12025
+ viewer = /* @__PURE__ */ jsxRuntime.jsx(GatedPdfViewer, { source });
11846
12026
  break;
11847
12027
  case "excel":
11848
12028
  viewer = /* @__PURE__ */ jsxRuntime.jsx(ExcelViewer3, { url: source.url, base64: source.base64 });
@@ -11859,10 +12039,13 @@ function PreviewHost({ kind, source, mode = "full" }) {
11859
12039
  case "docx":
11860
12040
  viewer = /* @__PURE__ */ jsxRuntime.jsx(DocxViewer2, { url: source.url, base64: source.base64 });
11861
12041
  break;
12042
+ case "html":
12043
+ viewer = /* @__PURE__ */ jsxRuntime.jsx(HtmlViewer2, { url: source.url, base64: source.base64, height: peek ? 240 : 480 });
12044
+ break;
11862
12045
  default:
11863
12046
  return null;
11864
12047
  }
11865
- return /* @__PURE__ */ jsxRuntime.jsx(React45.Suspense, { fallback, children: viewer });
12048
+ return /* @__PURE__ */ jsxRuntime.jsx(React46.Suspense, { fallback, children: viewer });
11866
12049
  }
11867
12050
 
11868
12051
  // src/shared/PreviewModal.tsx
@@ -11878,7 +12061,7 @@ function PreviewModal({
11878
12061
  onDownload
11879
12062
  }) {
11880
12063
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, SURFACE: SURFACE2, FOREGROUND: FOREGROUND2, SCRIM: SCRIM2 } = useTheme();
11881
- React45.useEffect(() => {
12064
+ React46.useEffect(() => {
11882
12065
  if (!open) return;
11883
12066
  const onKey = (e) => {
11884
12067
  if (e.key === "Escape") onClose();
@@ -12055,17 +12238,17 @@ function FileCard({
12055
12238
  previewDisabled = false
12056
12239
  }) {
12057
12240
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2, SHADOW: SHADOW2 } = useTheme();
12058
- const [cardHover, setCardHover] = React45.useState(false);
12059
- const [btnHover, setBtnHover] = React45.useState(false);
12060
- const [pvHover, setPvHover] = React45.useState(false);
12241
+ const [cardHover, setCardHover] = React46.useState(false);
12242
+ const [btnHover, setBtnHover] = React46.useState(false);
12243
+ const [pvHover, setPvHover] = React46.useState(false);
12061
12244
  const previewKind = previewKindFor(fileType, filename);
12062
12245
  const canPreview = !previewDisabled && previewKind !== null && (!!previewUrl || !!fetchPreviewBlob);
12063
- const [peekOpen, setPeekOpen] = React45.useState(false);
12064
- const [modalOpen, setModalOpen] = React45.useState(false);
12065
- const [source, setSource] = React45.useState(previewUrl ? { url: previewUrl } : null);
12066
- const [pvLoading, setPvLoading] = React45.useState(false);
12067
- const [pvError, setPvError] = React45.useState(null);
12068
- const ensureSource = React45.useCallback(async () => {
12246
+ const [peekOpen, setPeekOpen] = React46.useState(false);
12247
+ const [modalOpen, setModalOpen] = React46.useState(false);
12248
+ const [source, setSource] = React46.useState(previewUrl ? { url: previewUrl } : null);
12249
+ const [pvLoading, setPvLoading] = React46.useState(false);
12250
+ const [pvError, setPvError] = React46.useState(null);
12251
+ const ensureSource = React46.useCallback(async () => {
12069
12252
  if (source) return source;
12070
12253
  if (previewUrl) {
12071
12254
  const s = { url: previewUrl };
@@ -12087,7 +12270,7 @@ function FileCard({
12087
12270
  setPvLoading(false);
12088
12271
  }
12089
12272
  }, [source, previewUrl, fetchPreviewBlob]);
12090
- const togglePeek = React45.useCallback(async () => {
12273
+ const togglePeek = React46.useCallback(async () => {
12091
12274
  if (peekOpen) {
12092
12275
  setPeekOpen(false);
12093
12276
  return;
@@ -12095,7 +12278,7 @@ function FileCard({
12095
12278
  setPeekOpen(true);
12096
12279
  await ensureSource();
12097
12280
  }, [peekOpen, ensureSource]);
12098
- const openModal = React45.useCallback(async () => {
12281
+ const openModal = React46.useCallback(async () => {
12099
12282
  const s = await ensureSource();
12100
12283
  if (s) setModalOpen(true);
12101
12284
  }, [ensureSource]);
@@ -12210,7 +12393,7 @@ function FileCard({
12210
12393
  whiteSpace: "nowrap"
12211
12394
  },
12212
12395
  children: [
12213
- metaTokens.map((t, i) => /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
12396
+ metaTokens.map((t, i) => /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
12214
12397
  i > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: MUTED2 }, children: "\xB7" }),
12215
12398
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: t })
12216
12399
  ] }, i)),
@@ -12555,7 +12738,7 @@ function ServiceCard({ item, isHovered, onHover, onLeave: onLeave2 }) {
12555
12738
  function OpsDashboardResolver(p) {
12556
12739
  var _a2, _b, _c;
12557
12740
  const { BORDER: BORDER3, MUTED: MUTED2 } = useTheme();
12558
- const [hoveredId, setHoveredId] = React45.useState(null);
12741
+ const [hoveredId, setHoveredId] = React46.useState(null);
12559
12742
  const hasRunning = ((_a2 = p.items) != null ? _a2 : []).some((item) => item.state === "running");
12560
12743
  return /* @__PURE__ */ jsxRuntime.jsxs(ComponentActions, { filename: (_b = p.title) != null ? _b : "ops-dashboard", children: [
12561
12744
  hasRunning && /* @__PURE__ */ jsxRuntime.jsx("style", { children: PULSE_KEYFRAMES }),
@@ -12609,8 +12792,8 @@ function formatDate3(value) {
12609
12792
  }
12610
12793
  function CopyButton({ value, rowHovered }) {
12611
12794
  const { MUTED: MUTED2 } = useTheme();
12612
- const [copied, setCopied] = React45.useState(false);
12613
- const [btnHovered, setBtnHovered] = React45.useState(false);
12795
+ const [copied, setCopied] = React46.useState(false);
12796
+ const [btnHovered, setBtnHovered] = React46.useState(false);
12614
12797
  const handleCopy = () => {
12615
12798
  navigator.clipboard.writeText(value).then(() => {
12616
12799
  setCopied(true);
@@ -12704,7 +12887,7 @@ function ValueCell({ item }) {
12704
12887
  }
12705
12888
  function KVRow({ item, isLast, index }) {
12706
12889
  const { MUTED: MUTED2, BORDER: BORDER3, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2 } = useTheme();
12707
- const [hovered, setHovered] = React45.useState(false);
12890
+ const [hovered, setHovered] = React46.useState(false);
12708
12891
  const altBg = index % 2 === 1 ? SURFACE_MUTED2 : SURFACE2;
12709
12892
  return /* @__PURE__ */ jsxRuntime.jsxs(
12710
12893
  "div",
@@ -12789,7 +12972,7 @@ function KeyValueListResolver(p) {
12789
12972
  var _a4;
12790
12973
  return sum + ((_a4 = g.items) != null ? _a4 : []).length;
12791
12974
  }, 0);
12792
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
12975
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
12793
12976
  /* @__PURE__ */ jsxRuntime.jsxs(
12794
12977
  "div",
12795
12978
  {
@@ -12967,7 +13150,7 @@ function BalanceSheetResolver(p) {
12967
13150
  /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
12968
13151
  ((_p = p.sections) != null ? _p : []).map((section) => {
12969
13152
  var _a3;
12970
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
13153
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
12971
13154
  /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan, style: {
12972
13155
  padding: "8px 12px",
12973
13156
  fontSize: "12px",
@@ -12980,7 +13163,7 @@ function BalanceSheetResolver(p) {
12980
13163
  }, children: (_a3 = categoryLabels2[section.category]) != null ? _a3 : section.category }) }),
12981
13164
  section.subsections.map((sub, si) => {
12982
13165
  var _a4;
12983
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
13166
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
12984
13167
  /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan, style: {
12985
13168
  padding: "6px 10px 6px 24px",
12986
13169
  fontSize: "12px",
@@ -13156,7 +13339,7 @@ function IncomeStatementResolver(p) {
13156
13339
  textAlign: "left",
13157
13340
  whiteSpace: "nowrap"
13158
13341
  }, children: "\xA0" }),
13159
- periods.map((period) => /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
13342
+ periods.map((period) => /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
13160
13343
  /* @__PURE__ */ jsxRuntime.jsx("th", { style: {
13161
13344
  fontSize: "11px",
13162
13345
  fontWeight: 500,
@@ -13187,7 +13370,7 @@ function IncomeStatementResolver(p) {
13187
13370
  sections.map((section, si) => {
13188
13371
  var _a3;
13189
13372
  const isSubtotal = section.sectionType === "subtotal";
13190
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
13373
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
13191
13374
  /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: colCount, style: {
13192
13375
  padding: "8px 12px",
13193
13376
  fontSize: "12px",
@@ -13218,7 +13401,7 @@ function IncomeStatementResolver(p) {
13218
13401
  var _a5;
13219
13402
  const val = (_a5 = amounts[pi]) != null ? _a5 : 0;
13220
13403
  const isNeg = val < 0;
13221
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
13404
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
13222
13405
  /* @__PURE__ */ jsxRuntime.jsx("td", { style: {
13223
13406
  padding: "6px 10px",
13224
13407
  fontSize: "13px",
@@ -13253,7 +13436,7 @@ function IncomeStatementResolver(p) {
13253
13436
  var _a3;
13254
13437
  const val = (_a3 = grossProfit[pi]) != null ? _a3 : 0;
13255
13438
  const isNeg = val < 0;
13256
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
13439
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
13257
13440
  /* @__PURE__ */ jsxRuntime.jsx("td", { style: {
13258
13441
  padding: "8px 10px",
13259
13442
  fontSize: "12px",
@@ -13288,7 +13471,7 @@ function IncomeStatementResolver(p) {
13288
13471
  var _a3;
13289
13472
  const val = (_a3 = operatingIncome[pi]) != null ? _a3 : 0;
13290
13473
  const isNeg = val < 0;
13291
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
13474
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
13292
13475
  /* @__PURE__ */ jsxRuntime.jsx("td", { style: {
13293
13476
  padding: "8px 10px",
13294
13477
  fontSize: "12px",
@@ -13322,7 +13505,7 @@ function IncomeStatementResolver(p) {
13322
13505
  var _a3;
13323
13506
  const val = (_a3 = netIncome[pi]) != null ? _a3 : 0;
13324
13507
  const isNeg = val < 0;
13325
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
13508
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
13326
13509
  /* @__PURE__ */ jsxRuntime.jsx("td", { style: {
13327
13510
  padding: "10px 10px",
13328
13511
  fontSize: "13px",
@@ -13542,7 +13725,7 @@ function CashFlowStatementResolver(p) {
13542
13725
  /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
13543
13726
  activities.map((activity, ai) => {
13544
13727
  var _a3, _b2, _c2;
13545
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
13728
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
13546
13729
  ai > 0 && /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx(
13547
13730
  "td",
13548
13731
  {
@@ -15956,8 +16139,8 @@ var PRIORITY_STYLES = {
15956
16139
  function EscalationCardResolver(p) {
15957
16140
  var _a2, _b, _c, _d, _e;
15958
16141
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2, SHADOW: SHADOW2 } = useTheme();
15959
- const [cardHovered, setCardHovered] = React45.useState(false);
15960
- const [btnHovered, setBtnHovered] = React45.useState(false);
16142
+ const [cardHovered, setCardHovered] = React46.useState(false);
16143
+ const [btnHovered, setBtnHovered] = React46.useState(false);
15961
16144
  const priorityStyle = p.priority ? PRIORITY_STYLES[p.priority] : null;
15962
16145
  const railColor = (_a2 = priorityStyle == null ? void 0 : priorityStyle.color) != null ? _a2 : ACCENT2;
15963
16146
  const iconBg = (_b = priorityStyle == null ? void 0 : priorityStyle.bg) != null ? _b : "#fff2ec";
@@ -16829,9 +17012,9 @@ var CONNECTED_GREEN = "#15803d";
16829
17012
  function ConnectIntegrationResolver(p) {
16830
17013
  var _a2;
16831
17014
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2, PAPER: PAPER2, SURFACE: SURFACE2, SHADOW: SHADOW2 } = useTheme();
16832
- const [cardHovered, setCardHovered] = React45.useState(false);
16833
- const [btnHovered, setBtnHovered] = React45.useState(false);
16834
- const [imgFailed, setImgFailed] = React45.useState(false);
17015
+ const [cardHovered, setCardHovered] = React46.useState(false);
17016
+ const [btnHovered, setBtnHovered] = React46.useState(false);
17017
+ const [imgFailed, setImgFailed] = React46.useState(false);
16835
17018
  const name = (p.integrationName || "Integration").trim();
16836
17019
  const initial = name.charAt(0).toUpperCase();
16837
17020
  const iconSrc = p.iconUrl || brandIconUrl(name);
@@ -16993,9 +17176,9 @@ function IntegrationsListResolver(p) {
16993
17176
  var _a2, _b;
16994
17177
  const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2, SURFACE: SURFACE2, SHADOW: SHADOW2 } = useTheme();
16995
17178
  const integrations = Array.isArray(p.integrations) ? p.integrations : [];
16996
- const [rowHover, setRowHover] = React45.useState(null);
16997
- const [btnHover, setBtnHover] = React45.useState(null);
16998
- const [failed, setFailed] = React45.useState({});
17179
+ const [rowHover, setRowHover] = React46.useState(null);
17180
+ const [btnHover, setBtnHover] = React46.useState(null);
17181
+ const [failed, setFailed] = React46.useState({});
16999
17182
  const connectedCount = integrations.filter((i) => i.status === "connected").length;
17000
17183
  return /* @__PURE__ */ jsxRuntime.jsx(ComponentActions, { filename: (_a2 = p.title) != null ? _a2 : "integrations", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "11px" }, children: [
17001
17184
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "2px" }, children: [
@@ -17487,13 +17670,13 @@ var ellipsis = {
17487
17670
  function PipelinePreviewResolver(p) {
17488
17671
  var _a2, _b, _c, _d, _e, _f, _g;
17489
17672
  const { MUTED: MUTED2, PAPER: PAPER2, BORDER: BORDER3, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2, SURFACE: SURFACE2 } = useTheme();
17490
- const [btnHovered, setBtnHovered] = React45.useState(false);
17673
+ const [btnHovered, setBtnHovered] = React46.useState(false);
17491
17674
  const stateCfg = STATE_CONFIG[(_a2 = p.state) != null ? _a2 : "draft"];
17492
17675
  const destinations = (_b = p.destinations) != null ? _b : [];
17493
17676
  const steps = (_c = p.steps) != null ? _c : [];
17494
17677
  const workstreams = (_d = p.workstreams) != null ? _d : [];
17495
17678
  const scheduleLabel = p.schedule ? p.schedule.type === "manual" ? "Manual" : (_f = (_e = p.schedule.label) != null ? _e : p.schedule.cron) != null ? _f : "Scheduled" : null;
17496
- const { nodes, edges, viewBox, vbW, vbH } = React45.useMemo(() => {
17679
+ const { nodes, edges, viewBox, vbW, vbH } = React46.useMemo(() => {
17497
17680
  const res = layoutGraph(steps);
17498
17681
  const b = layoutBounds(res.nodes);
17499
17682
  const pad = 24;
@@ -17507,7 +17690,7 @@ function PipelinePreviewResolver(p) {
17507
17690
  vbH: h
17508
17691
  };
17509
17692
  }, [steps]);
17510
- const nodeMap = React45.useMemo(() => {
17693
+ const nodeMap = React46.useMemo(() => {
17511
17694
  const m = {};
17512
17695
  nodes.forEach((n) => m[n.id] = n);
17513
17696
  return m;
@@ -17885,12 +18068,12 @@ var DEFAULT_INTERACTION = {
17885
18068
  onDecisionSource: void 0,
17886
18069
  onDecisionQueueSubmit: void 0
17887
18070
  };
17888
- var GenUIInteractionContext = React45.createContext(DEFAULT_INTERACTION);
18071
+ var GenUIInteractionContext = React46.createContext(DEFAULT_INTERACTION);
17889
18072
  function GenUIInteractionProvider({ value, children }) {
17890
18073
  return /* @__PURE__ */ jsxRuntime.jsx(GenUIInteractionContext.Provider, { value, children });
17891
18074
  }
17892
18075
  function useGenUIInteraction() {
17893
- return React45.useContext(GenUIInteractionContext);
18076
+ return React46.useContext(GenUIInteractionContext);
17894
18077
  }
17895
18078
  var STATUS_COLORS3 = {
17896
18079
  done: "#15803d",
@@ -18082,8 +18265,8 @@ var CARD_MIN = 132;
18082
18265
  var CARD_GAP = 16;
18083
18266
  var AUTO_COMPACT_BELOW = 360;
18084
18267
  function useContainerWidth(ref) {
18085
- const [w, setW] = React45__default.default.useState(0);
18086
- React45__default.default.useLayoutEffect(() => {
18268
+ const [w, setW] = React46__default.default.useState(0);
18269
+ React46__default.default.useLayoutEffect(() => {
18087
18270
  const el = ref.current;
18088
18271
  if (!el || typeof ResizeObserver === "undefined") return;
18089
18272
  const ro = new ResizeObserver((entries) => {
@@ -18186,15 +18369,15 @@ function WorkflowStepperRenderer({
18186
18369
  const interactive = typeof onSelectStep === "function";
18187
18370
  const statusColor3 = (s) => s === "active" || s === "running" ? ACCENT2 : STATUS_COLORS3[s];
18188
18371
  const doneCount = steps.filter((s) => s.status === "done").length;
18189
- const rootRef = React45__default.default.useRef(null);
18372
+ const rootRef = React46__default.default.useRef(null);
18190
18373
  const containerW = useContainerWidth(rootRef);
18191
18374
  let resolved = density === "auto" ? "full" : density;
18192
18375
  if (density === "auto" && containerW > 0) {
18193
18376
  const needed = steps.length * CARD_MIN + Math.max(0, steps.length - 1) * CARD_GAP;
18194
18377
  resolved = containerW < AUTO_COMPACT_BELOW || needed > containerW * 1.6 ? "compact" : "full";
18195
18378
  }
18196
- const scrollerRef = React45__default.default.useRef(null);
18197
- React45__default.default.useEffect(() => {
18379
+ const scrollerRef = React46__default.default.useRef(null);
18380
+ React46__default.default.useEffect(() => {
18198
18381
  if (resolved !== "full" || loading) return;
18199
18382
  const sc = scrollerRef.current;
18200
18383
  if (!sc) return;
@@ -18205,11 +18388,11 @@ function WorkflowStepperRenderer({
18205
18388
  el.scrollIntoView({ inline: "center", block: "nearest", behavior: "smooth" });
18206
18389
  }
18207
18390
  }, [resolved, loading, selectedStep, activeStepId]);
18208
- const [edges, setEdges] = React45__default.default.useState({
18391
+ const [edges, setEdges] = React46__default.default.useState({
18209
18392
  left: false,
18210
18393
  right: false
18211
18394
  });
18212
- const updateEdges = React45__default.default.useCallback(() => {
18395
+ const updateEdges = React46__default.default.useCallback(() => {
18213
18396
  const sc = scrollerRef.current;
18214
18397
  if (!sc) return;
18215
18398
  const max = sc.scrollWidth - sc.clientWidth;
@@ -18218,7 +18401,7 @@ function WorkflowStepperRenderer({
18218
18401
  const right = sl < max - 1;
18219
18402
  setEdges((prev) => prev.left === left && prev.right === right ? prev : { left, right });
18220
18403
  }, []);
18221
- React45__default.default.useLayoutEffect(() => {
18404
+ React46__default.default.useLayoutEffect(() => {
18222
18405
  if (resolved !== "full" || loading) return;
18223
18406
  updateEdges();
18224
18407
  const sc = scrollerRef.current;
@@ -18274,7 +18457,7 @@ function WorkflowStepperRenderer({
18274
18457
  const reached = s.status !== "pending";
18275
18458
  const clickable = interactive && reached;
18276
18459
  const size = act ? 11 : done ? 9 : 8;
18277
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
18460
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
18278
18461
  i > 0 && /* @__PURE__ */ jsxRuntime.jsx(
18279
18462
  "span",
18280
18463
  {
@@ -18418,7 +18601,7 @@ function WorkflowStepperRenderer({
18418
18601
  const color = statusColor3(step.status);
18419
18602
  const humans = ((_a3 = step.assignees) != null ? _a3 : []).filter((a) => a.kind === "human");
18420
18603
  const roleCaption = humans.map((h) => h.role).filter(Boolean).slice(0, 2).join(" \xB7 ");
18421
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
18604
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
18422
18605
  i > 0 && /* @__PURE__ */ jsxRuntime.jsx(
18423
18606
  "div",
18424
18607
  {
@@ -18784,11 +18967,11 @@ function FieldDetail({
18784
18967
  }) {
18785
18968
  var _a2, _b, _c, _d;
18786
18969
  const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SECONDARY: SECONDARY2, SURFACE: SURFACE2, ACCENT: ACCENT2 } = useTheme();
18787
- const [editing, setEditing] = React45__default.default.useState(false);
18788
- const [draft, setDraft] = React45__default.default.useState("");
18789
- const [saving, setSaving] = React45__default.default.useState(false);
18790
- const [saveError, setSaveError] = React45__default.default.useState(null);
18791
- const textareaRef = React45__default.default.useRef(null);
18970
+ const [editing, setEditing] = React46__default.default.useState(false);
18971
+ const [draft, setDraft] = React46__default.default.useState("");
18972
+ const [saving, setSaving] = React46__default.default.useState(false);
18973
+ const [saveError, setSaveError] = React46__default.default.useState(null);
18974
+ const textareaRef = React46__default.default.useRef(null);
18792
18975
  const color = fieldColor(field, SECONDARY2);
18793
18976
  const corrected = field.state === "corrected";
18794
18977
  const startEdit = (e) => {
@@ -19298,7 +19481,7 @@ function FieldDetails({
19298
19481
  },
19299
19482
  children: facts.map((f) => {
19300
19483
  var _a3;
19301
- return /* @__PURE__ */ jsxRuntime.jsxs(React45__default.default.Fragment, { children: [
19484
+ return /* @__PURE__ */ jsxRuntime.jsxs(React46__default.default.Fragment, { children: [
19302
19485
  /* @__PURE__ */ jsxRuntime.jsx("dt", { style: { fontSize: "12px", color: MUTED2 }, children: f.label }),
19303
19486
  /* @__PURE__ */ jsxRuntime.jsxs(
19304
19487
  "dd",
@@ -19397,7 +19580,7 @@ function FieldAuditLog({
19397
19580
  fields = []
19398
19581
  }) {
19399
19582
  const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SECONDARY: SECONDARY2 } = useTheme();
19400
- const fieldLabelMap = React45__default.default.useMemo(() => {
19583
+ const fieldLabelMap = React46__default.default.useMemo(() => {
19401
19584
  var _a2;
19402
19585
  const map = {};
19403
19586
  for (const f of fields) map[f.field_key] = (_a2 = f.label) != null ? _a2 : f.field_key;
@@ -19596,10 +19779,10 @@ function PageOverlay({
19596
19779
  secondary
19597
19780
  }) {
19598
19781
  const { PAPER: PAPER2, MUTED: MUTED2 } = useTheme();
19599
- const imgRef = React45__default.default.useRef(null);
19600
- const selectedBoxRef = React45__default.default.useRef(null);
19601
- const [px, setPx] = React45__default.default.useState(null);
19602
- React45__default.default.useEffect(() => {
19782
+ const imgRef = React46__default.default.useRef(null);
19783
+ const selectedBoxRef = React46__default.default.useRef(null);
19784
+ const [px, setPx] = React46__default.default.useState(null);
19785
+ React46__default.default.useEffect(() => {
19603
19786
  const el = imgRef.current;
19604
19787
  if (!el) return;
19605
19788
  const measure = () => {
@@ -19613,7 +19796,7 @@ function PageOverlay({
19613
19796
  ro.observe(el);
19614
19797
  return () => ro.disconnect();
19615
19798
  }, [page.imageUrl]);
19616
- React45__default.default.useEffect(() => {
19799
+ React46__default.default.useEffect(() => {
19617
19800
  if (!selectedKey) return;
19618
19801
  if (!fields.some((f) => f.field_key === selectedKey && f.bbox)) return;
19619
19802
  const el = selectedBoxRef.current;
@@ -19715,8 +19898,8 @@ function ExtractionDetail({
19715
19898
  auditLoading
19716
19899
  }) {
19717
19900
  const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SECONDARY: SECONDARY2 } = useTheme();
19718
- const selectedCardRef = React45__default.default.useRef(null);
19719
- React45__default.default.useEffect(() => {
19901
+ const selectedCardRef = React46__default.default.useRef(null);
19902
+ React46__default.default.useEffect(() => {
19720
19903
  if (!selectedKey || tab !== "fields") return;
19721
19904
  const el = selectedCardRef.current;
19722
19905
  if (el && typeof el.scrollIntoView === "function") {
@@ -19887,7 +20070,7 @@ function ExtractionModal({
19887
20070
  children
19888
20071
  }) {
19889
20072
  const { BORDER: BORDER3, MUTED: MUTED2, SURFACE: SURFACE2, FOREGROUND: FOREGROUND2, SCRIM: SCRIM2 } = useTheme();
19890
- React45__default.default.useEffect(() => {
20073
+ React46__default.default.useEffect(() => {
19891
20074
  if (!open) return;
19892
20075
  const onKey = (e) => {
19893
20076
  if (e.key === "Escape") onClose();
@@ -20016,19 +20199,19 @@ function ExtractionModal({
20016
20199
  function DocumentFieldExtractionResolver(p) {
20017
20200
  var _a2, _b;
20018
20201
  const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SURFACE: SURFACE2, SHADOW: SHADOW2, ACCENT: ACCENT2 } = useTheme();
20019
- const [selectedKey, setSelectedKey] = React45__default.default.useState(null);
20020
- const [open, setOpen] = React45__default.default.useState(false);
20021
- const [tab, setTab] = React45__default.default.useState("fields");
20202
+ const [selectedKey, setSelectedKey] = React46__default.default.useState(null);
20203
+ const [open, setOpen] = React46__default.default.useState(false);
20204
+ const [tab, setTab] = React46__default.default.useState("fields");
20022
20205
  const pages = (_a2 = p.pages) != null ? _a2 : [];
20023
20206
  const fields = (_b = p.fields) != null ? _b : [];
20024
20207
  const editable = typeof p.onFieldSave === "function";
20025
20208
  const onLoadAudit = p.onLoadAudit;
20026
- React45__default.default.useEffect(() => {
20209
+ React46__default.default.useEffect(() => {
20027
20210
  if (tab === "audit" && onLoadAudit) {
20028
20211
  onLoadAudit();
20029
20212
  }
20030
20213
  }, [tab, onLoadAudit]);
20031
- const correctionCounts = React45__default.default.useMemo(() => {
20214
+ const correctionCounts = React46__default.default.useMemo(() => {
20032
20215
  var _a3, _b2;
20033
20216
  const counts = {};
20034
20217
  for (const ev of (_a3 = p.auditEvents) != null ? _a3 : []) {
@@ -20385,8 +20568,8 @@ function formatAmount2(amount, currency = "USD") {
20385
20568
  return `${sign}${symbol}${body}`;
20386
20569
  }
20387
20570
  function useContainerWidth2(ref) {
20388
- const [w, setW] = React45__default.default.useState(0);
20389
- React45__default.default.useLayoutEffect(() => {
20571
+ const [w, setW] = React46__default.default.useState(0);
20572
+ React46__default.default.useLayoutEffect(() => {
20390
20573
  const el = ref.current;
20391
20574
  if (!el || typeof ResizeObserver === "undefined") return;
20392
20575
  const ro = new ResizeObserver((entries) => {
@@ -20481,8 +20664,8 @@ function ValueAdjuster({
20481
20664
  const { SURFACE_MUTED: SURFACE_MUTED2 } = useTheme();
20482
20665
  const adjust = option.adjust;
20483
20666
  const suggested = clampToRange((_a2 = option.value) != null ? _a2 : adjust.min, adjust);
20484
- const [value, setValue] = React45__default.default.useState(suggested);
20485
- const [text, setText] = React45__default.default.useState(String(suggested));
20667
+ const [value, setValue] = React46__default.default.useState(suggested);
20668
+ const [text, setText] = React46__default.default.useState(String(suggested));
20486
20669
  const step = (_b = adjust.step) != null ? _b : Number.isInteger(adjust.min) && Number.isInteger(adjust.max) ? 1 : (adjust.max - adjust.min) / 100;
20487
20670
  const pct = adjust.max > adjust.min ? (value - adjust.min) / (adjust.max - adjust.min) * 100 : 0;
20488
20671
  const suggestedPct = adjust.max > adjust.min ? (suggested - adjust.min) / (adjust.max - adjust.min) * 100 : 0;
@@ -20688,10 +20871,10 @@ function DecisionCardRenderer({
20688
20871
  }) {
20689
20872
  var _a2, _b, _c;
20690
20873
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2, SHADOW: SHADOW2 } = useTheme();
20691
- const rootRef = React45__default.default.useRef(null);
20874
+ const rootRef = React46__default.default.useRef(null);
20692
20875
  const width = useContainerWidth2(rootRef);
20693
20876
  const stacked = width > 0 && width < STACK_BELOW;
20694
- const [adjustingIdx, setAdjustingIdx] = React45__default.default.useState(null);
20877
+ const [adjustingIdx, setAdjustingIdx] = React46__default.default.useState(null);
20695
20878
  const options = (_a2 = data.options) != null ? _a2 : [];
20696
20879
  const recommendedIdx = Math.max(
20697
20880
  0,
@@ -20992,8 +21175,8 @@ function DecisionCardResolver(p) {
20992
21175
  const decisionId = (_a2 = p.id) != null ? _a2 : p.title;
20993
21176
  const hostResolved = resolvedDecisions == null ? void 0 : resolvedDecisions[decisionId];
20994
21177
  const initial = hostResolved != null ? hostResolved : p.resolved ? composeResolution(p, p.resolved.option, p.resolved.value) : null;
20995
- const [localResolved, setLocalResolved] = React45__default.default.useState(initial);
20996
- React45__default.default.useEffect(() => {
21178
+ const [localResolved, setLocalResolved] = React46__default.default.useState(initial);
21179
+ React46__default.default.useEffect(() => {
20997
21180
  if (hostResolved !== void 0) setLocalResolved(hostResolved);
20998
21181
  }, [hostResolved]);
20999
21182
  const resolved = hostResolved != null ? hostResolved : localResolved;
@@ -21067,11 +21250,11 @@ function DecisionQueueRenderer({
21067
21250
  var _a2;
21068
21251
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2, BORDER_SOFT: BORDER_SOFT2, PAPER: PAPER2, SHADOW: SHADOW2 } = useTheme();
21069
21252
  const items = (_a2 = data.items) != null ? _a2 : [];
21070
- const [decisions, setDecisions] = React45__default.default.useState(
21253
+ const [decisions, setDecisions] = React46__default.default.useState(
21071
21254
  () => items.map(() => void 0)
21072
21255
  );
21073
21256
  const firstUndecided = decisions.findIndex((d) => !d);
21074
- const [focusIdx, setFocusIdx] = React45__default.default.useState(firstUndecided >= 0 ? firstUndecided : null);
21257
+ const [focusIdx, setFocusIdx] = React46__default.default.useState(firstUndecided >= 0 ? firstUndecided : null);
21075
21258
  const isSubmitted = submitted != null;
21076
21259
  const shown = isSubmitted ? items.map(
21077
21260
  (item, i) => {
@@ -21096,16 +21279,16 @@ function DecisionQueueRenderer({
21096
21279
  const final = decisions;
21097
21280
  onSubmit == null ? void 0 : onSubmit(final, composeQueueMessage(items, final));
21098
21281
  };
21099
- const onReadyRef = React45__default.default.useRef(onReady);
21100
- React45__default.default.useEffect(() => {
21282
+ const onReadyRef = React46__default.default.useRef(onReady);
21283
+ React46__default.default.useEffect(() => {
21101
21284
  onReadyRef.current = onReady;
21102
21285
  });
21103
- React45__default.default.useEffect(() => {
21286
+ React46__default.default.useEffect(() => {
21104
21287
  if (!onReadyRef.current) return;
21105
21288
  const msg = allDecided ? composeQueueMessage(items, decisions) : null;
21106
21289
  onReadyRef.current(allDecided && !isSubmitted, msg, decisions.filter(Boolean));
21107
21290
  }, [decisions, allDecided, isSubmitted]);
21108
- React45__default.default.useEffect(() => {
21291
+ React46__default.default.useEffect(() => {
21109
21292
  if (!submitRef) return;
21110
21293
  submitRef.current = handleSubmit;
21111
21294
  return () => {
@@ -21330,7 +21513,7 @@ function DecisionQueueResolver(p) {
21330
21513
  const { resolvedDecisions, onDecisionQueueSubmit } = useGenUIInteraction();
21331
21514
  const queueId = (_b = (_a2 = p.id) != null ? _a2 : p.title) != null ? _b : "decision-queue";
21332
21515
  const replayed = (_d = (_c = p.resolved) == null ? void 0 : _c.decisions) != null ? _d : null;
21333
- const [localSubmitted, setLocalSubmitted] = React45__default.default.useState(null);
21516
+ const [localSubmitted, setLocalSubmitted] = React46__default.default.useState(null);
21334
21517
  const hostLocked = (resolvedDecisions == null ? void 0 : resolvedDecisions[queueId]) != null;
21335
21518
  const submitted = (_e = replayed != null ? replayed : localSubmitted) != null ? _e : hostLocked ? [] : null;
21336
21519
  const handleSubmit = (decisions, message) => {
@@ -21408,9 +21591,9 @@ function ExternalIcon() {
21408
21591
  function TabbyAuthResolver(p) {
21409
21592
  var _a2, _b, _c;
21410
21593
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2, SHADOW: SHADOW2 } = useTheme();
21411
- const [cardHovered, setCardHovered] = React45.useState(false);
21412
- const [btnHovered, setBtnHovered] = React45.useState(false);
21413
- const [imgFailed, setImgFailed] = React45.useState(false);
21594
+ const [cardHovered, setCardHovered] = React46.useState(false);
21595
+ const [btnHovered, setBtnHovered] = React46.useState(false);
21596
+ const [imgFailed, setImgFailed] = React46.useState(false);
21414
21597
  const app = humanizeApp(p.app || "the app");
21415
21598
  const connected = p.state === "connected";
21416
21599
  const accent = connected ? CONNECTED_GREEN3 : ACCENT2;
@@ -21816,7 +21999,7 @@ function InlineSpinner() {
21816
21999
  }
21817
22000
  function GenUIRenderer({ payload }) {
21818
22001
  return /* @__PURE__ */ jsxRuntime.jsx(
21819
- React45.Suspense,
22002
+ React46.Suspense,
21820
22003
  {
21821
22004
  fallback: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "8px 0" }, children: [
21822
22005
  /* @__PURE__ */ jsxRuntime.jsx(InlineSpinner, {}),
@@ -21968,7 +22151,7 @@ var INPUT_ERROR = { borderColor: "#dc2626" };
21968
22151
  var SELECT_EXTRA = { cursor: "pointer" };
21969
22152
  function useInputBase() {
21970
22153
  const { BORDER: BORDER3, SURFACE: SURFACE2 } = useTheme();
21971
- return React45.useMemo(() => ({
22154
+ return React46.useMemo(() => ({
21972
22155
  font: "inherit",
21973
22156
  fontSize: "13px",
21974
22157
  padding: "7px 10px",
@@ -22049,7 +22232,7 @@ function SelectField({ field, value, onChange, disabled, error }) {
22049
22232
  }
22050
22233
  function MultiSelectField({ field, value, onChange, disabled }) {
22051
22234
  const { MUTED: MUTED2, ACCENT: ACCENT2, BORDER: BORDER3, SURFACE: SURFACE2 } = useTheme();
22052
- const [hovered, setHovered] = React45.useState(null);
22235
+ const [hovered, setHovered] = React46.useState(null);
22053
22236
  const options = field.options || [];
22054
22237
  const selected = Array.isArray(value) ? value : [];
22055
22238
  const toggle = (optValue) => {
@@ -22166,8 +22349,8 @@ function DocGlyph({ color }) {
22166
22349
  }
22167
22350
  function FileUploadField({ field, value, onChange, disabled, onFileUpload, error, dense }) {
22168
22351
  const { MUTED: MUTED2, ACCENT: ACCENT2, BORDER: BORDER3, PAPER: PAPER2, SURFACE: SURFACE2 } = useTheme();
22169
- const keyRef = React45__default.default.useRef(0);
22170
- const [entries, setEntries] = React45.useState(() => {
22352
+ const keyRef = React46__default.default.useRef(0);
22353
+ const [entries, setEntries] = React46.useState(() => {
22171
22354
  const arr = Array.isArray(value) ? value : value && typeof value === "object" ? [value] : [];
22172
22355
  return arr.map((item) => {
22173
22356
  var _a2, _b;
@@ -22175,11 +22358,11 @@ function FileUploadField({ field, value, onChange, disabled, onFileUpload, error
22175
22358
  return { key: keyRef.current += 1, name: (_b = (_a2 = r.filename) != null ? _a2 : r.name) != null ? _b : "file", size: r.size, status: "done", result: r };
22176
22359
  });
22177
22360
  });
22178
- const entriesRef = React45__default.default.useRef(entries);
22361
+ const entriesRef = React46__default.default.useRef(entries);
22179
22362
  entriesRef.current = entries;
22180
- const [dragOver, setDragOver] = React45.useState(false);
22181
- const inputRef = React45__default.default.useRef(null);
22182
- React45__default.default.useEffect(() => {
22363
+ const [dragOver, setDragOver] = React46.useState(false);
22364
+ const inputRef = React46__default.default.useRef(null);
22365
+ React46__default.default.useEffect(() => {
22183
22366
  ensureFileUploadKeyframes();
22184
22367
  }, []);
22185
22368
  const interactive = !disabled;
@@ -22310,24 +22493,24 @@ function EntityPickerField({ field, value, onChange, disabled, error, onEntitySe
22310
22493
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, PAPER: PAPER2, SURFACE: SURFACE2 } = useTheme();
22311
22494
  const base = useInputBase();
22312
22495
  const source = field.source || "";
22313
- const [open, setOpen] = React45.useState(false);
22314
- const [query, setQuery] = React45.useState("");
22315
- const [results, setResults] = React45.useState([]);
22316
- const [loading, setLoading] = React45.useState(false);
22317
- const [err, setErr] = React45.useState(null);
22318
- const [hi, setHi] = React45.useState(0);
22319
- const [selectedLabel, setSelectedLabel] = React45.useState(null);
22320
- const [creating, setCreating] = React45.useState(false);
22321
- const [createVals, setCreateVals] = React45.useState({});
22322
- const [createBusy, setCreateBusy] = React45.useState(false);
22323
- const boxRef = React45.useRef(null);
22324
- const seq = React45.useRef(0);
22496
+ const [open, setOpen] = React46.useState(false);
22497
+ const [query, setQuery] = React46.useState("");
22498
+ const [results, setResults] = React46.useState([]);
22499
+ const [loading, setLoading] = React46.useState(false);
22500
+ const [err, setErr] = React46.useState(null);
22501
+ const [hi, setHi] = React46.useState(0);
22502
+ const [selectedLabel, setSelectedLabel] = React46.useState(null);
22503
+ const [creating, setCreating] = React46.useState(false);
22504
+ const [createVals, setCreateVals] = React46.useState({});
22505
+ const [createBusy, setCreateBusy] = React46.useState(false);
22506
+ const boxRef = React46.useRef(null);
22507
+ const seq = React46.useRef(0);
22325
22508
  const allowCreate = !!field.allow_create && !!onEntityCreate;
22326
- const createFields = React45.useMemo(
22509
+ const createFields = React46.useMemo(
22327
22510
  () => field.create_fields && field.create_fields.length ? field.create_fields : [{ name: "name", label: "Name", field_type: "text", required: true, placeholder: "" }],
22328
22511
  [field.create_fields]
22329
22512
  );
22330
- const runSearch = React45.useCallback(
22513
+ const runSearch = React46.useCallback(
22331
22514
  (q) => {
22332
22515
  if (!onEntitySearch || !source) return;
22333
22516
  const my = ++seq.current;
@@ -22349,12 +22532,12 @@ function EntityPickerField({ field, value, onChange, disabled, error, onEntitySe
22349
22532
  },
22350
22533
  [onEntitySearch, source]
22351
22534
  );
22352
- React45.useEffect(() => {
22535
+ React46.useEffect(() => {
22353
22536
  if (!open || creating) return;
22354
22537
  const id = setTimeout(() => runSearch(query), 200);
22355
22538
  return () => clearTimeout(id);
22356
22539
  }, [open, creating, query, runSearch]);
22357
- React45.useEffect(() => {
22540
+ React46.useEffect(() => {
22358
22541
  if (!open) return;
22359
22542
  const onDoc = (e) => {
22360
22543
  if (boxRef.current && !boxRef.current.contains(e.target)) {
@@ -22369,7 +22552,7 @@ function EntityPickerField({ field, value, onChange, disabled, error, onEntitySe
22369
22552
  if (disabled) return;
22370
22553
  setOpen(true);
22371
22554
  };
22372
- const select = React45.useCallback((opt) => {
22555
+ const select = React46.useCallback((opt) => {
22373
22556
  onChange({ value: opt.value, label: opt.label });
22374
22557
  setSelectedLabel(opt.label);
22375
22558
  setQuery("");
@@ -22383,14 +22566,14 @@ function EntityPickerField({ field, value, onChange, disabled, error, onEntitySe
22383
22566
  const otherRequired = createFields.filter((f) => f !== nameField && f.required);
22384
22567
  const showCreateRow = allowCreate && !creating && query.trim().length > 0;
22385
22568
  const totalRows = results.length + (showCreateRow ? 1 : 0);
22386
- const beginCreate = React45.useCallback(() => {
22569
+ const beginCreate = React46.useCallback(() => {
22387
22570
  const init = {};
22388
22571
  if (nameField && query.trim()) init[nameField.name] = query.trim();
22389
22572
  setCreateVals(init);
22390
22573
  setErr(null);
22391
22574
  setCreating(true);
22392
22575
  }, [nameField, query]);
22393
- const submitCreate = React45.useCallback((vals) => {
22576
+ const submitCreate = React46.useCallback((vals) => {
22394
22577
  if (!onEntityCreate || !source) return;
22395
22578
  const payload = vals || createVals;
22396
22579
  for (const f of createFields) {
@@ -22403,7 +22586,7 @@ function EntityPickerField({ field, value, onChange, disabled, error, onEntitySe
22403
22586
  setErr(null);
22404
22587
  onEntityCreate(source, payload).then((opt) => select(opt)).catch(() => setErr("Couldn't create \u2014 you may not have permission")).finally(() => setCreateBusy(false));
22405
22588
  }, [onEntityCreate, source, createFields, createVals, select]);
22406
- const handleCreateRow = React45.useCallback(() => {
22589
+ const handleCreateRow = React46.useCallback(() => {
22407
22590
  const q = query.trim();
22408
22591
  if (!q || !nameField) return;
22409
22592
  if (otherRequired.length === 0) {
@@ -22585,11 +22768,11 @@ function _fileExt(path, type) {
22585
22768
  function FileMapField({ field, value, onChange, disabled }) {
22586
22769
  const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, PAPER: PAPER2, SURFACE: SURFACE2 } = useTheme();
22587
22770
  const cfg = field.file_map || null;
22588
- const categories = React45.useMemo(() => (cfg == null ? void 0 : cfg.categories) || [], [cfg]);
22589
- const fileList = React45.useMemo(() => (cfg == null ? void 0 : cfg.files) || [], [cfg]);
22771
+ const categories = React46.useMemo(() => (cfg == null ? void 0 : cfg.categories) || [], [cfg]);
22772
+ const fileList = React46.useMemo(() => (cfg == null ? void 0 : cfg.files) || [], [cfg]);
22590
22773
  const suggestions = (cfg == null ? void 0 : cfg.suggestions) || {};
22591
22774
  const confidence = (cfg == null ? void 0 : cfg.confidence) || {};
22592
- const initial = React45.useMemo(() => {
22775
+ const initial = React46.useMemo(() => {
22593
22776
  const a = {};
22594
22777
  if (value && typeof value === "object" && !Array.isArray(value)) {
22595
22778
  for (const [grp, paths] of Object.entries(value))
@@ -22601,15 +22784,15 @@ function FileMapField({ field, value, onChange, disabled }) {
22601
22784
  for (const f of fileList) if (!(f.path in a)) a[f.path] = _FILEMAP_UNASSIGNED;
22602
22785
  return a;
22603
22786
  }, []);
22604
- const [assignment, setAssignment] = React45.useState(initial);
22605
- const [collapsed, setCollapsed] = React45.useState({});
22606
- const [menuFor, setMenuFor] = React45.useState(null);
22607
- const boardRef = React45.useRef(null);
22608
- const fileByPath = React45.useMemo(
22787
+ const [assignment, setAssignment] = React46.useState(initial);
22788
+ const [collapsed, setCollapsed] = React46.useState({});
22789
+ const [menuFor, setMenuFor] = React46.useState(null);
22790
+ const boardRef = React46.useRef(null);
22791
+ const fileByPath = React46.useMemo(
22609
22792
  () => Object.fromEntries(fileList.map((f) => [f.path, f])),
22610
22793
  [fileList]
22611
22794
  );
22612
- const groupFrom = React45.useCallback((a) => {
22795
+ const groupFrom = React46.useCallback((a) => {
22613
22796
  const g = { [_FILEMAP_UNASSIGNED]: [] };
22614
22797
  for (const c of categories) g[c.id] = [];
22615
22798
  for (const f of fileList) {
@@ -22619,16 +22802,16 @@ function FileMapField({ field, value, onChange, disabled }) {
22619
22802
  }
22620
22803
  return g;
22621
22804
  }, [categories, fileList]);
22622
- const grouped = React45.useMemo(() => groupFrom(assignment), [assignment, groupFrom]);
22623
- const emit = React45.useCallback((g) => onChange(g), [onChange]);
22624
- const emittedRef = React45.useRef(false);
22625
- React45.useEffect(() => {
22805
+ const grouped = React46.useMemo(() => groupFrom(assignment), [assignment, groupFrom]);
22806
+ const emit = React46.useCallback((g) => onChange(g), [onChange]);
22807
+ const emittedRef = React46.useRef(false);
22808
+ React46.useEffect(() => {
22626
22809
  if (!emittedRef.current) {
22627
22810
  emittedRef.current = true;
22628
22811
  emit(grouped);
22629
22812
  }
22630
22813
  }, [grouped, emit]);
22631
- React45.useEffect(() => {
22814
+ React46.useEffect(() => {
22632
22815
  if (!menuFor) return;
22633
22816
  const onDoc = (e) => {
22634
22817
  if (boardRef.current && !boardRef.current.contains(e.target)) setMenuFor(null);
@@ -22636,7 +22819,7 @@ function FileMapField({ field, value, onChange, disabled }) {
22636
22819
  document.addEventListener("mousedown", onDoc);
22637
22820
  return () => document.removeEventListener("mousedown", onDoc);
22638
22821
  }, [menuFor]);
22639
- const move = React45.useCallback((path, grp) => {
22822
+ const move = React46.useCallback((path, grp) => {
22640
22823
  setMenuFor(null);
22641
22824
  setAssignment((prev) => {
22642
22825
  const next = __spreadProps(__spreadValues({}, prev), { [path]: grp });
@@ -22786,7 +22969,7 @@ function FieldRenderer({ field, value, onChange, disabled, error, onFileUpload,
22786
22969
  ] });
22787
22970
  }
22788
22971
  init_ThemeContext();
22789
- var SlotErrorBoundary = class extends React45__default.default.Component {
22972
+ var SlotErrorBoundary = class extends React46__default.default.Component {
22790
22973
  constructor(props) {
22791
22974
  super(props);
22792
22975
  this.state = { hasError: false };
@@ -22872,7 +23055,7 @@ function BuilderRecap({ builder, state }) {
22872
23055
  return String(value);
22873
23056
  };
22874
23057
  const decisionField = (b) => (b.fields || []).find((f) => f.field_type === "select") || (b.fields || [])[0];
22875
- const rows = React45.useMemo(
23058
+ const rows = React46.useMemo(
22876
23059
  () => blocks.map((b) => {
22877
23060
  const df = decisionField(b);
22878
23061
  const decision = df ? display(df, state.getValue(b.id, df.name)) : "";
@@ -22882,7 +23065,7 @@ function BuilderRecap({ builder, state }) {
22882
23065
  // eslint-disable-next-line react-hooks/exhaustive-deps
22883
23066
  [blocks, state.values]
22884
23067
  );
22885
- const counts = React45.useMemo(() => {
23068
+ const counts = React46.useMemo(() => {
22886
23069
  const m = /* @__PURE__ */ new Map();
22887
23070
  for (const r of rows) {
22888
23071
  const k = r.decision || "\u2014";
@@ -23017,7 +23200,7 @@ function isRequiredMissing(fieldType, v) {
23017
23200
  }
23018
23201
  function useBuilderState(blocks) {
23019
23202
  const isMultiBlock = blocks.length > 1;
23020
- const [values, setValues] = React45.useState(() => {
23203
+ const [values, setValues] = React46.useState(() => {
23021
23204
  const init = {};
23022
23205
  for (const block of blocks) {
23023
23206
  for (const field of block.fields || []) {
@@ -23026,17 +23209,17 @@ function useBuilderState(blocks) {
23026
23209
  }
23027
23210
  return init;
23028
23211
  });
23029
- const [errors, setErrors] = React45.useState({});
23030
- const [currentBlock, setCurrentBlock] = React45.useState(0);
23031
- const getValue = React45.useCallback(
23212
+ const [errors, setErrors] = React46.useState({});
23213
+ const [currentBlock, setCurrentBlock] = React46.useState(0);
23214
+ const getValue = React46.useCallback(
23032
23215
  (blockId, name) => values[fieldKey(blockId, name)],
23033
23216
  [values]
23034
23217
  );
23035
- const getError = React45.useCallback(
23218
+ const getError = React46.useCallback(
23036
23219
  (blockId, name) => errors[fieldKey(blockId, name)],
23037
23220
  [errors]
23038
23221
  );
23039
- const setFieldValue = React45.useCallback((blockId, name, value) => {
23222
+ const setFieldValue = React46.useCallback((blockId, name, value) => {
23040
23223
  const k = fieldKey(blockId, name);
23041
23224
  setValues((prev) => __spreadProps(__spreadValues({}, prev), { [k]: value }));
23042
23225
  setErrors((prev) => {
@@ -23046,7 +23229,7 @@ function useBuilderState(blocks) {
23046
23229
  return next;
23047
23230
  });
23048
23231
  }, []);
23049
- const validateBlock = React45.useCallback(
23232
+ const validateBlock = React46.useCallback(
23050
23233
  (blockIdx) => {
23051
23234
  const block = blocks[blockIdx];
23052
23235
  if (!block) return true;
@@ -23080,7 +23263,7 @@ function useBuilderState(blocks) {
23080
23263
  },
23081
23264
  [blocks, values]
23082
23265
  );
23083
- const validateAllDetailed = React45.useCallback(() => {
23266
+ const validateAllDetailed = React46.useCallback(() => {
23084
23267
  let firstBlockIndex = -1;
23085
23268
  let firstKey = null;
23086
23269
  let firstBlockId = null;
@@ -23108,7 +23291,7 @@ function useBuilderState(blocks) {
23108
23291
  if (firstBlockIndex >= 0) setCurrentBlock(firstBlockIndex);
23109
23292
  return { firstKey, firstBlockId, firstName, firstBlockIndex, failingKeys };
23110
23293
  }, [blocks, values]);
23111
- const validateAll = React45.useCallback(
23294
+ const validateAll = React46.useCallback(
23112
23295
  () => validateAllDetailed().failingKeys.length === 0,
23113
23296
  [validateAllDetailed]
23114
23297
  );
@@ -23143,7 +23326,7 @@ function BlockForm({
23143
23326
  }) {
23144
23327
  var _a2;
23145
23328
  const t = useTheme();
23146
- const S3 = React45.useMemo(() => makeStyles(t), [t]);
23329
+ const S3 = React46.useMemo(() => makeStyles(t), [t]);
23147
23330
  const block = builder.blocks[0];
23148
23331
  const isEscalation = variant === "escalation";
23149
23332
  const errorCount = ((block == null ? void 0 : block.fields) || []).reduce(
@@ -23349,7 +23532,7 @@ init_ThemeContext();
23349
23532
  function StepperBuilder({ builder, state, onSubmit, onCancel, disabled, onFileUpload, onEntitySearch, onEntityCreate, dense }) {
23350
23533
  var _a2;
23351
23534
  const t = useTheme();
23352
- const S3 = React45.useMemo(() => makeStyles2(t), [t]);
23535
+ const S3 = React46.useMemo(() => makeStyles2(t), [t]);
23353
23536
  const { blocks } = builder;
23354
23537
  const total = blocks.length;
23355
23538
  const idx = Math.min(Math.max(state.currentBlock, 0), Math.max(total - 1, 0));
@@ -23551,7 +23734,7 @@ function BuilderFormResolver({
23551
23734
  `[BuilderForm] builder "${builder.builder_id}" declared builder_kind="${declaredKind}" with ${blockCount} blocks; rendering as stepper to avoid dropping blocks.`
23552
23735
  );
23553
23736
  }
23554
- const buildSubmission = React45.useCallback(() => {
23737
+ const buildSubmission = React46.useCallback(() => {
23555
23738
  const blocks = (builder.blocks || []).map((b) => ({
23556
23739
  id: b.id,
23557
23740
  title: b.title,
@@ -23563,7 +23746,7 @@ function BuilderFormResolver({
23563
23746
  blocks
23564
23747
  }, blocks.length === 1 ? { values: blocks[0].values } : {});
23565
23748
  }, [builder, kind, state.getValue]);
23566
- const handleSubmit = React45.useCallback(() => {
23749
+ const handleSubmit = React46.useCallback(() => {
23567
23750
  if (disabled) return;
23568
23751
  const failure = state.validateAllDetailed();
23569
23752
  if (failure.failingKeys.length > 0) {
@@ -23572,25 +23755,25 @@ function BuilderFormResolver({
23572
23755
  }
23573
23756
  onSubmit(buildSubmission());
23574
23757
  }, [disabled, state.validateAllDetailed, onSubmit, buildSubmission, onValidationError]);
23575
- const onChangeRef = React45.useRef(onChange);
23576
- React45.useEffect(() => {
23758
+ const onChangeRef = React46.useRef(onChange);
23759
+ React46.useEffect(() => {
23577
23760
  onChangeRef.current = onChange;
23578
23761
  });
23579
- React45.useEffect(() => {
23762
+ React46.useEffect(() => {
23580
23763
  var _a3;
23581
23764
  (_a3 = onChangeRef.current) == null ? void 0 : _a3.call(onChangeRef, buildSubmission());
23582
23765
  }, [state.values]);
23583
- const onBlockChangeRef = React45.useRef(onBlockChange);
23584
- React45.useEffect(() => {
23766
+ const onBlockChangeRef = React46.useRef(onBlockChange);
23767
+ React46.useEffect(() => {
23585
23768
  onBlockChangeRef.current = onBlockChange;
23586
23769
  });
23587
23770
  const activeIdx = kind === "stepper" ? state.currentBlock : 0;
23588
- React45.useEffect(() => {
23771
+ React46.useEffect(() => {
23589
23772
  var _a3;
23590
23773
  const block = (builder.blocks || [])[activeIdx];
23591
23774
  if (block) (_a3 = onBlockChangeRef.current) == null ? void 0 : _a3.call(onBlockChangeRef, block, activeIdx);
23592
23775
  }, [activeIdx]);
23593
- React45.useEffect(() => {
23776
+ React46.useEffect(() => {
23594
23777
  if (!submitRef) return;
23595
23778
  submitRef.current = handleSubmit;
23596
23779
  return () => {
@@ -23653,7 +23836,7 @@ function BuilderFormResolver({
23653
23836
  }
23654
23837
  }
23655
23838
  function resolveBuilder(payload, callbacks) {
23656
- return React45__default.default.createElement(BuilderFormResolver, __spreadValues({
23839
+ return React46__default.default.createElement(BuilderFormResolver, __spreadValues({
23657
23840
  builder: payload
23658
23841
  }, callbacks));
23659
23842
  }