@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.
- package/dist/composites/document-preview/PdfViewer.d.ts +2 -1
- package/dist/composites/document-preview/PdfViewer.d.ts.map +1 -1
- package/dist/composites/document-preview/resolver.cjs +90 -11
- package/dist/composites/document-preview/resolver.cjs.map +1 -1
- package/dist/composites/document-preview/resolver.d.ts.map +1 -1
- package/dist/composites/document-preview/resolver.js +90 -11
- package/dist/composites/document-preview/resolver.js.map +1 -1
- package/dist/composites/download-card/resolver.cjs +244 -69
- package/dist/composites/download-card/resolver.cjs.map +1 -1
- package/dist/composites/download-card/resolver.js +189 -14
- package/dist/composites/download-card/resolver.js.map +1 -1
- package/dist/index.cjs +472 -289
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +265 -82
- package/dist/index.js.map +1 -1
- package/dist/renderer.cjs +404 -221
- package/dist/renderer.cjs.map +1 -1
- package/dist/renderer.js +259 -76
- package/dist/renderer.js.map +1 -1
- package/dist/resolver.cjs +403 -220
- package/dist/resolver.cjs.map +1 -1
- package/dist/resolver.js +259 -76
- package/dist/resolver.js.map +1 -1
- package/dist/shared/fileType.d.ts +1 -1
- package/dist/shared/fileType.d.ts.map +1 -1
- package/dist/shared/viewers/HtmlViewer.d.ts +12 -0
- package/dist/shared/viewers/HtmlViewer.d.ts.map +1 -0
- package/dist/shared/viewers/PreviewHost.d.ts.map +1 -1
- package/dist/shared/viewers/pdfWorkerProbe.d.ts +31 -0
- package/dist/shared/viewers/pdfWorkerProbe.d.ts.map +1 -0
- package/dist/tool-definitions.json +2 -2
- package/package.json +1 -1
package/dist/renderer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import React46, { lazy, createContext, useState, useCallback, useEffect, useRef, Suspense, useMemo, useContext, useLayoutEffect } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import dagre from '@dagrejs/dagre';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
@@ -1264,13 +1264,74 @@ var init_FlowGraph = __esm({
|
|
|
1264
1264
|
renderSeq = 0;
|
|
1265
1265
|
}
|
|
1266
1266
|
});
|
|
1267
|
+
function resolvePdfWorkerSrc(pdfjs2) {
|
|
1268
|
+
const override = typeof window !== "undefined" ? window.__GENUI_PDF_WORKER_SRC__ : void 0;
|
|
1269
|
+
const current = pdfjs2.GlobalWorkerOptions.workerSrc;
|
|
1270
|
+
const isConfigured = !!current && current !== "pdf.worker.mjs";
|
|
1271
|
+
if (override) {
|
|
1272
|
+
pdfjs2.GlobalWorkerOptions.workerSrc = override;
|
|
1273
|
+
} else if (!isConfigured) {
|
|
1274
|
+
pdfjs2.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${pdfjs2.version}/build/pdf.worker.min.mjs`;
|
|
1275
|
+
}
|
|
1276
|
+
return pdfjs2.GlobalWorkerOptions.workerSrc;
|
|
1277
|
+
}
|
|
1278
|
+
function probePdfWorker() {
|
|
1279
|
+
if (probe) return probe;
|
|
1280
|
+
probe = (async () => {
|
|
1281
|
+
if (typeof window === "undefined") return false;
|
|
1282
|
+
try {
|
|
1283
|
+
const { pdfjs: pdfjs2 } = await import('react-pdf');
|
|
1284
|
+
resolvePdfWorkerSrc(pdfjs2);
|
|
1285
|
+
const task = pdfjs2.getDocument({ data: new TextEncoder().encode(TINY_PDF) });
|
|
1286
|
+
const doc = await Promise.race([
|
|
1287
|
+
task.promise,
|
|
1288
|
+
new Promise(
|
|
1289
|
+
(_, reject) => setTimeout(() => reject(new Error("pdf worker probe timed out")), PROBE_TIMEOUT_MS)
|
|
1290
|
+
)
|
|
1291
|
+
]);
|
|
1292
|
+
await doc.destroy();
|
|
1293
|
+
return true;
|
|
1294
|
+
} catch (e) {
|
|
1295
|
+
probe = null;
|
|
1296
|
+
return false;
|
|
1297
|
+
}
|
|
1298
|
+
})();
|
|
1299
|
+
return probe;
|
|
1300
|
+
}
|
|
1301
|
+
function usePdfWorkerReady(enabled) {
|
|
1302
|
+
const [ready, setReady] = useState(null);
|
|
1303
|
+
useEffect(() => {
|
|
1304
|
+
if (!enabled) return;
|
|
1305
|
+
let cancelled = false;
|
|
1306
|
+
probePdfWorker().then((ok) => {
|
|
1307
|
+
if (!cancelled) setReady(ok);
|
|
1308
|
+
});
|
|
1309
|
+
return () => {
|
|
1310
|
+
cancelled = true;
|
|
1311
|
+
};
|
|
1312
|
+
}, [enabled]);
|
|
1313
|
+
return enabled ? ready : null;
|
|
1314
|
+
}
|
|
1315
|
+
var TINY_PDF, PROBE_TIMEOUT_MS, probe;
|
|
1316
|
+
var init_pdfWorkerProbe = __esm({
|
|
1317
|
+
"src/shared/viewers/pdfWorkerProbe.ts"() {
|
|
1318
|
+
"use client";
|
|
1319
|
+
TINY_PDF = `%PDF-1.1
|
|
1320
|
+
1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj
|
|
1321
|
+
2 0 obj<</Type/Pages/Kids[3 0 R]/Count 1>>endobj
|
|
1322
|
+
3 0 obj<</Type/Page/Parent 2 0 R/MediaBox[0 0 3 3]>>endobj
|
|
1323
|
+
trailer<</Root 1 0 R>>`;
|
|
1324
|
+
PROBE_TIMEOUT_MS = 5e3;
|
|
1325
|
+
probe = null;
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1267
1328
|
|
|
1268
1329
|
// src/composites/document-preview/PdfViewer.tsx
|
|
1269
1330
|
var PdfViewer_exports = {};
|
|
1270
1331
|
__export(PdfViewer_exports, {
|
|
1271
1332
|
PdfViewer: () => PdfViewer
|
|
1272
1333
|
});
|
|
1273
|
-
function PdfViewer({ url, base64, onLoadSuccess }) {
|
|
1334
|
+
function PdfViewer({ url, base64, onLoadSuccess, onLoadError }) {
|
|
1274
1335
|
const { BORDER: BORDER3, MUTED: MUTED2, SURFACE: SURFACE2 } = useTheme();
|
|
1275
1336
|
const [numPages, setNumPages] = useState(0);
|
|
1276
1337
|
const [currentPage, setCurrentPage] = useState(1);
|
|
@@ -1350,23 +1411,34 @@ function PdfViewer({ url, base64, onLoadSuccess }) {
|
|
|
1350
1411
|
] }),
|
|
1351
1412
|
/* @__PURE__ */ jsxs("div", { style: { overflow: "auto", width: "100%", display: "flex", justifyContent: "center", padding: "16px" }, children: [
|
|
1352
1413
|
loading && /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "200px", color: MUTED2, fontSize: "13px" }, children: "Loading PDF..." }),
|
|
1353
|
-
/* @__PURE__ */ jsx(
|
|
1354
|
-
|
|
1414
|
+
/* @__PURE__ */ jsx(
|
|
1415
|
+
Document,
|
|
1355
1416
|
{
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1417
|
+
file: base64 ? `data:application/pdf;base64,${base64}` : url,
|
|
1418
|
+
onLoadSuccess: handleLoad,
|
|
1419
|
+
onLoadError,
|
|
1420
|
+
loading: "",
|
|
1421
|
+
error: "",
|
|
1422
|
+
children: /* @__PURE__ */ jsx(
|
|
1423
|
+
Page,
|
|
1424
|
+
{
|
|
1425
|
+
pageNumber: currentPage,
|
|
1426
|
+
width: 540,
|
|
1427
|
+
renderTextLayer: true,
|
|
1428
|
+
renderAnnotationLayer: true
|
|
1429
|
+
}
|
|
1430
|
+
)
|
|
1360
1431
|
}
|
|
1361
|
-
)
|
|
1432
|
+
)
|
|
1362
1433
|
] })
|
|
1363
1434
|
] });
|
|
1364
1435
|
}
|
|
1365
1436
|
var init_PdfViewer = __esm({
|
|
1366
1437
|
"src/composites/document-preview/PdfViewer.tsx"() {
|
|
1367
1438
|
"use client";
|
|
1439
|
+
init_pdfWorkerProbe();
|
|
1368
1440
|
init_ThemeContext();
|
|
1369
|
-
pdfjs
|
|
1441
|
+
resolvePdfWorkerSrc(pdfjs);
|
|
1370
1442
|
}
|
|
1371
1443
|
});
|
|
1372
1444
|
|
|
@@ -1872,6 +1944,89 @@ var init_DocxViewer = __esm({
|
|
|
1872
1944
|
init_decode();
|
|
1873
1945
|
}
|
|
1874
1946
|
});
|
|
1947
|
+
|
|
1948
|
+
// src/shared/viewers/HtmlViewer.tsx
|
|
1949
|
+
var HtmlViewer_exports = {};
|
|
1950
|
+
__export(HtmlViewer_exports, {
|
|
1951
|
+
HtmlViewer: () => HtmlViewer
|
|
1952
|
+
});
|
|
1953
|
+
function HtmlViewer({ url, base64, height = 480 }) {
|
|
1954
|
+
const { MUTED: MUTED2 } = useTheme();
|
|
1955
|
+
const [html, setHtml] = useState("");
|
|
1956
|
+
const [loading, setLoading] = useState(true);
|
|
1957
|
+
const [error, setError] = useState(null);
|
|
1958
|
+
useEffect(() => {
|
|
1959
|
+
let cancelled = false;
|
|
1960
|
+
setLoading(true);
|
|
1961
|
+
setError(null);
|
|
1962
|
+
if (base64) {
|
|
1963
|
+
try {
|
|
1964
|
+
if (!cancelled) {
|
|
1965
|
+
setHtml(base64ToText(base64));
|
|
1966
|
+
setLoading(false);
|
|
1967
|
+
}
|
|
1968
|
+
} catch (e) {
|
|
1969
|
+
if (!cancelled) {
|
|
1970
|
+
setError(e instanceof Error ? e.message : "Failed to decode HTML");
|
|
1971
|
+
setLoading(false);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
return () => {
|
|
1975
|
+
cancelled = true;
|
|
1976
|
+
};
|
|
1977
|
+
}
|
|
1978
|
+
if (!url) {
|
|
1979
|
+
setError("No file source provided");
|
|
1980
|
+
setLoading(false);
|
|
1981
|
+
return () => {
|
|
1982
|
+
cancelled = true;
|
|
1983
|
+
};
|
|
1984
|
+
}
|
|
1985
|
+
fetch(url).then((r) => {
|
|
1986
|
+
if (!r.ok) throw new Error(`Failed to fetch: ${r.status}`);
|
|
1987
|
+
return r.text();
|
|
1988
|
+
}).then((t) => {
|
|
1989
|
+
if (cancelled) return;
|
|
1990
|
+
setHtml(t);
|
|
1991
|
+
setLoading(false);
|
|
1992
|
+
}).catch((e) => {
|
|
1993
|
+
if (cancelled) return;
|
|
1994
|
+
setError(e.message);
|
|
1995
|
+
setLoading(false);
|
|
1996
|
+
});
|
|
1997
|
+
return () => {
|
|
1998
|
+
cancelled = true;
|
|
1999
|
+
};
|
|
2000
|
+
}, [url, base64]);
|
|
2001
|
+
if (loading) {
|
|
2002
|
+
return /* @__PURE__ */ jsx("div", { style: { padding: "24px", color: MUTED2, fontSize: "13px", textAlign: "center" }, children: "Loading\u2026" });
|
|
2003
|
+
}
|
|
2004
|
+
if (error) {
|
|
2005
|
+
return /* @__PURE__ */ jsx("div", { style: { padding: "24px", color: "#dc2626", fontSize: "13px", textAlign: "center" }, children: error });
|
|
2006
|
+
}
|
|
2007
|
+
return /* @__PURE__ */ jsx(
|
|
2008
|
+
"iframe",
|
|
2009
|
+
{
|
|
2010
|
+
title: "HTML preview",
|
|
2011
|
+
sandbox: "",
|
|
2012
|
+
srcDoc: html,
|
|
2013
|
+
style: {
|
|
2014
|
+
width: "100%",
|
|
2015
|
+
height: `${height}px`,
|
|
2016
|
+
border: "none",
|
|
2017
|
+
background: "white",
|
|
2018
|
+
display: "block"
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
);
|
|
2022
|
+
}
|
|
2023
|
+
var init_HtmlViewer = __esm({
|
|
2024
|
+
"src/shared/viewers/HtmlViewer.tsx"() {
|
|
2025
|
+
"use client";
|
|
2026
|
+
init_ThemeContext();
|
|
2027
|
+
init_decode();
|
|
2028
|
+
}
|
|
2029
|
+
});
|
|
1875
2030
|
var dataTableSchema = z.object({
|
|
1876
2031
|
type: z.literal("data-table"),
|
|
1877
2032
|
title: z.string().optional(),
|
|
@@ -7325,7 +7480,7 @@ function WaterfallChartResolver(p) {
|
|
|
7325
7480
|
}
|
|
7326
7481
|
init_ThemeContext();
|
|
7327
7482
|
init_theme();
|
|
7328
|
-
var FlowGraph2 =
|
|
7483
|
+
var FlowGraph2 = React46.lazy(
|
|
7329
7484
|
() => Promise.resolve().then(() => (init_FlowGraph(), FlowGraph_exports)).then((m) => ({ default: m.FlowGraph }))
|
|
7330
7485
|
);
|
|
7331
7486
|
function FlowCanvasRenderer({
|
|
@@ -7601,7 +7756,7 @@ function TrialBalanceResolver(p) {
|
|
|
7601
7756
|
gDebit += a.debit;
|
|
7602
7757
|
gCredit += a.credit;
|
|
7603
7758
|
});
|
|
7604
|
-
return /* @__PURE__ */ jsxs(
|
|
7759
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
7605
7760
|
/* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: 4, style: {
|
|
7606
7761
|
padding: "8px 12px",
|
|
7607
7762
|
fontSize: "12px",
|
|
@@ -8992,10 +9147,11 @@ function useFullscreen(ref) {
|
|
|
8992
9147
|
// src/composites/document-preview/resolver.tsx
|
|
8993
9148
|
init_theme();
|
|
8994
9149
|
init_ThemeContext();
|
|
8995
|
-
|
|
9150
|
+
init_pdfWorkerProbe();
|
|
9151
|
+
var PdfViewer2 = React46.lazy(
|
|
8996
9152
|
() => Promise.resolve().then(() => (init_PdfViewer(), PdfViewer_exports)).then((m) => ({ default: m.PdfViewer }))
|
|
8997
9153
|
);
|
|
8998
|
-
var ExcelViewer2 =
|
|
9154
|
+
var ExcelViewer2 = React46.lazy(
|
|
8999
9155
|
() => Promise.resolve().then(() => (init_ExcelViewer(), ExcelViewer_exports)).then((m) => ({ default: m.ExcelViewer }))
|
|
9000
9156
|
);
|
|
9001
9157
|
var highlightColors = {
|
|
@@ -9055,8 +9211,14 @@ function DocumentPreviewResolver(p) {
|
|
|
9055
9211
|
const totalPages = ((_c = p.pages) != null ? _c : []).length;
|
|
9056
9212
|
const page = p.pages[currentPage];
|
|
9057
9213
|
const pageHighlights = ((_d = p.highlights) != null ? _d : []).filter((h) => h.pageIndex === currentPage);
|
|
9214
|
+
const [pdfFailed, setPdfFailed] = useState(false);
|
|
9215
|
+
const pdfWorkerReady = usePdfWorkerReady(hasRealFile && isPdf);
|
|
9216
|
+
const pdfReady = pdfFailed ? false : pdfWorkerReady;
|
|
9217
|
+
const showPdfViewer = hasRealFile && isPdf && pdfReady === true;
|
|
9218
|
+
const pdfPending = hasRealFile && isPdf && pdfReady === null;
|
|
9058
9219
|
const handlePdfLoad = useCallback(() => {
|
|
9059
9220
|
}, []);
|
|
9221
|
+
const handlePdfError = useCallback(() => setPdfFailed(true), []);
|
|
9060
9222
|
const handleExcelLoad = useCallback(() => {
|
|
9061
9223
|
}, []);
|
|
9062
9224
|
return /* @__PURE__ */ jsx(ComponentActions, { filename: (_e = p.title) != null ? _e : "document-preview", children: /* @__PURE__ */ jsxs(
|
|
@@ -9150,7 +9312,7 @@ function DocumentPreviewResolver(p) {
|
|
|
9150
9312
|
children: pg.label
|
|
9151
9313
|
},
|
|
9152
9314
|
i
|
|
9153
|
-
)) }) : !hasRealFile && totalPages > 1 && /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "6px 14px", borderLeft: `1px solid ${BORDER3}`, borderRight: `1px solid ${BORDER3}`, background: SURFACE2 }, children: [
|
|
9315
|
+
)) }) : (!hasRealFile || pdfReady === false) && totalPages > 1 && /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "6px 14px", borderLeft: `1px solid ${BORDER3}`, borderRight: `1px solid ${BORDER3}`, background: SURFACE2 }, children: [
|
|
9154
9316
|
/* @__PURE__ */ 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" }),
|
|
9155
9317
|
/* @__PURE__ */ jsxs("span", { style: { fontSize: "12px", color: MUTED2 }, children: [
|
|
9156
9318
|
currentPage + 1,
|
|
@@ -9170,7 +9332,7 @@ function DocumentPreviewResolver(p) {
|
|
|
9170
9332
|
display: "flex",
|
|
9171
9333
|
flexDirection: "column"
|
|
9172
9334
|
}, children: [
|
|
9173
|
-
|
|
9335
|
+
showPdfViewer ? /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ 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__ */ jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "200px", color: MUTED2, fontSize: "13px" }, children: "Loading preview\u2026" }) : hasRealFile && isExcel ? /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ 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__ */ jsx("div", { style: { padding: "20px" }, children: /* @__PURE__ */ jsx("img", { src: page.imageUrl, alt: page.label, style: { maxWidth: "100%", borderRadius: "4px" } }) }) : (page == null ? void 0 : page.content) ? /* @__PURE__ */ jsx("div", { style: { fontFamily: "var(--font-sans, system-ui)", fontSize: "13px", color: "var(--foreground)", lineHeight: 1.6, margin: 0, padding: "20px" }, children: /* @__PURE__ */ jsx(Markdown, { content: page.content }) }) : /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "120px", color: MUTED2, fontSize: "13px" }, children: [
|
|
9174
9336
|
"No content available for ",
|
|
9175
9337
|
(_u = page == null ? void 0 : page.label) != null ? _u : "this page"
|
|
9176
9338
|
] }),
|
|
@@ -9958,7 +10120,7 @@ function EngagementPipelineResolver(p) {
|
|
|
9958
10120
|
const color = (_a2 = statusColor2[phase.status]) != null ? _a2 : "#d6d3d1";
|
|
9959
10121
|
const isCurrent = i === activeIdx;
|
|
9960
10122
|
const size = isCurrent ? 28 : 20;
|
|
9961
|
-
return /* @__PURE__ */ jsxs(
|
|
10123
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
9962
10124
|
i > 0 && /* @__PURE__ */ jsx(
|
|
9963
10125
|
"div",
|
|
9964
10126
|
{
|
|
@@ -11678,7 +11840,7 @@ init_theme();
|
|
|
11678
11840
|
var FAMILIES = [
|
|
11679
11841
|
{ exts: ["csv", "tsv", "xls", "xlsx", "numbers"], fg: SEMANTIC.success.color, bg: SEMANTIC.success.bg },
|
|
11680
11842
|
{ exts: ["pdf"], fg: SEMANTIC.error.color, bg: SEMANTIC.error.bg },
|
|
11681
|
-
{ exts: ["doc", "docx", "txt", "md", "rtf", "pages"], fg: SEMANTIC.info.color, bg: SEMANTIC.info.bg },
|
|
11843
|
+
{ exts: ["doc", "docx", "txt", "md", "rtf", "pages", "html", "htm"], fg: SEMANTIC.info.color, bg: SEMANTIC.info.bg },
|
|
11682
11844
|
{ exts: ["json", "yaml", "yml", "xml", "toml"], fg: SEMANTIC.purple.color, bg: SEMANTIC.purple.bg },
|
|
11683
11845
|
{ exts: ["zip", "tar", "gz", "rar", "7z"], fg: SEMANTIC.warning.color, bg: SEMANTIC.warning.bg },
|
|
11684
11846
|
{ exts: ["png", "jpg", "jpeg", "gif", "svg", "webp", "bmp"], fg: SEMANTIC.info.color, bg: SEMANTIC.info.bg }
|
|
@@ -11705,7 +11867,9 @@ var PREVIEW_EXTS = {
|
|
|
11705
11867
|
txt: "text",
|
|
11706
11868
|
log: "text",
|
|
11707
11869
|
text: "text",
|
|
11708
|
-
docx: "docx"
|
|
11870
|
+
docx: "docx",
|
|
11871
|
+
html: "html",
|
|
11872
|
+
htm: "html"
|
|
11709
11873
|
};
|
|
11710
11874
|
function extOf(fileType, filename) {
|
|
11711
11875
|
var _a;
|
|
@@ -11716,6 +11880,7 @@ function extOf(fileType, filename) {
|
|
|
11716
11880
|
if (mime.includes("csv")) return "csv";
|
|
11717
11881
|
if (mime.includes("markdown")) return "md";
|
|
11718
11882
|
if (mime.includes("wordprocessing") || mime.includes("msword")) return "docx";
|
|
11883
|
+
if (mime.includes("html")) return "html";
|
|
11719
11884
|
if (mime.startsWith("text/")) return "txt";
|
|
11720
11885
|
} else if (fileType) {
|
|
11721
11886
|
const t = fileType.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
@@ -11749,6 +11914,7 @@ function isExpirySoon(expiresAt) {
|
|
|
11749
11914
|
|
|
11750
11915
|
// src/shared/viewers/PreviewHost.tsx
|
|
11751
11916
|
init_ThemeContext();
|
|
11917
|
+
init_pdfWorkerProbe();
|
|
11752
11918
|
var PdfViewer3 = lazy(
|
|
11753
11919
|
() => Promise.resolve().then(() => (init_PdfViewer(), PdfViewer_exports)).then((m) => ({ default: m.PdfViewer }))
|
|
11754
11920
|
);
|
|
@@ -11758,8 +11924,22 @@ var ExcelViewer3 = lazy(
|
|
|
11758
11924
|
var CsvViewer2 = lazy(() => Promise.resolve().then(() => (init_CsvViewer(), CsvViewer_exports)).then((m) => ({ default: m.CsvViewer })));
|
|
11759
11925
|
var TextViewer2 = lazy(() => Promise.resolve().then(() => (init_TextViewer(), TextViewer_exports)).then((m) => ({ default: m.TextViewer })));
|
|
11760
11926
|
var DocxViewer2 = lazy(() => Promise.resolve().then(() => (init_DocxViewer(), DocxViewer_exports)).then((m) => ({ default: m.DocxViewer })));
|
|
11927
|
+
var HtmlViewer2 = lazy(() => Promise.resolve().then(() => (init_HtmlViewer(), HtmlViewer_exports)).then((m) => ({ default: m.HtmlViewer })));
|
|
11761
11928
|
var PEEK_ROWS = 20;
|
|
11762
11929
|
var PEEK_LINES = 40;
|
|
11930
|
+
function GatedPdfViewer({ source }) {
|
|
11931
|
+
const { MUTED: MUTED2 } = useTheme();
|
|
11932
|
+
const [failed, setFailed] = useState(false);
|
|
11933
|
+
const workerReady = usePdfWorkerReady(true);
|
|
11934
|
+
const ready = failed ? false : workerReady;
|
|
11935
|
+
if (ready === null) {
|
|
11936
|
+
return /* @__PURE__ */ jsx("div", { style: { padding: "24px", color: MUTED2, fontSize: "13px", textAlign: "center" }, children: "Loading preview\u2026" });
|
|
11937
|
+
}
|
|
11938
|
+
if (ready === false) {
|
|
11939
|
+
return /* @__PURE__ */ jsx("div", { style: { padding: "24px", color: MUTED2, fontSize: "13px", textAlign: "center" }, children: "Preview unavailable \u2014 download the file to view it." });
|
|
11940
|
+
}
|
|
11941
|
+
return /* @__PURE__ */ jsx(PdfViewer3, { url: source.url, base64: source.base64, onLoadError: () => setFailed(true) });
|
|
11942
|
+
}
|
|
11763
11943
|
function PreviewHost({ kind, source, mode = "full" }) {
|
|
11764
11944
|
const { MUTED: MUTED2 } = useTheme();
|
|
11765
11945
|
const peek = mode === "peek";
|
|
@@ -11767,7 +11947,7 @@ function PreviewHost({ kind, source, mode = "full" }) {
|
|
|
11767
11947
|
let viewer = null;
|
|
11768
11948
|
switch (kind) {
|
|
11769
11949
|
case "pdf":
|
|
11770
|
-
viewer = /* @__PURE__ */ jsx(
|
|
11950
|
+
viewer = /* @__PURE__ */ jsx(GatedPdfViewer, { source });
|
|
11771
11951
|
break;
|
|
11772
11952
|
case "excel":
|
|
11773
11953
|
viewer = /* @__PURE__ */ jsx(ExcelViewer3, { url: source.url, base64: source.base64 });
|
|
@@ -11784,6 +11964,9 @@ function PreviewHost({ kind, source, mode = "full" }) {
|
|
|
11784
11964
|
case "docx":
|
|
11785
11965
|
viewer = /* @__PURE__ */ jsx(DocxViewer2, { url: source.url, base64: source.base64 });
|
|
11786
11966
|
break;
|
|
11967
|
+
case "html":
|
|
11968
|
+
viewer = /* @__PURE__ */ jsx(HtmlViewer2, { url: source.url, base64: source.base64, height: peek ? 240 : 480 });
|
|
11969
|
+
break;
|
|
11787
11970
|
default:
|
|
11788
11971
|
return null;
|
|
11789
11972
|
}
|
|
@@ -12135,7 +12318,7 @@ function FileCard({
|
|
|
12135
12318
|
whiteSpace: "nowrap"
|
|
12136
12319
|
},
|
|
12137
12320
|
children: [
|
|
12138
|
-
metaTokens.map((t, i) => /* @__PURE__ */ jsxs(
|
|
12321
|
+
metaTokens.map((t, i) => /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
12139
12322
|
i > 0 && /* @__PURE__ */ jsx("span", { style: { color: MUTED2 }, children: "\xB7" }),
|
|
12140
12323
|
/* @__PURE__ */ jsx("span", { children: t })
|
|
12141
12324
|
] }, i)),
|
|
@@ -12714,7 +12897,7 @@ function KeyValueListResolver(p) {
|
|
|
12714
12897
|
var _a3;
|
|
12715
12898
|
return sum + ((_a3 = g.items) != null ? _a3 : []).length;
|
|
12716
12899
|
}, 0);
|
|
12717
|
-
return /* @__PURE__ */ jsxs(
|
|
12900
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
12718
12901
|
/* @__PURE__ */ jsxs(
|
|
12719
12902
|
"div",
|
|
12720
12903
|
{
|
|
@@ -12892,7 +13075,7 @@ function BalanceSheetResolver(p) {
|
|
|
12892
13075
|
/* @__PURE__ */ jsxs("tbody", { children: [
|
|
12893
13076
|
((_p = p.sections) != null ? _p : []).map((section) => {
|
|
12894
13077
|
var _a2;
|
|
12895
|
-
return /* @__PURE__ */ jsxs(
|
|
13078
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
12896
13079
|
/* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, style: {
|
|
12897
13080
|
padding: "8px 12px",
|
|
12898
13081
|
fontSize: "12px",
|
|
@@ -12905,7 +13088,7 @@ function BalanceSheetResolver(p) {
|
|
|
12905
13088
|
}, children: (_a2 = categoryLabels2[section.category]) != null ? _a2 : section.category }) }),
|
|
12906
13089
|
section.subsections.map((sub, si) => {
|
|
12907
13090
|
var _a3;
|
|
12908
|
-
return /* @__PURE__ */ jsxs(
|
|
13091
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
12909
13092
|
/* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, style: {
|
|
12910
13093
|
padding: "6px 10px 6px 24px",
|
|
12911
13094
|
fontSize: "12px",
|
|
@@ -13081,7 +13264,7 @@ function IncomeStatementResolver(p) {
|
|
|
13081
13264
|
textAlign: "left",
|
|
13082
13265
|
whiteSpace: "nowrap"
|
|
13083
13266
|
}, children: "\xA0" }),
|
|
13084
|
-
periods.map((period) => /* @__PURE__ */ jsxs(
|
|
13267
|
+
periods.map((period) => /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
13085
13268
|
/* @__PURE__ */ jsx("th", { style: {
|
|
13086
13269
|
fontSize: "11px",
|
|
13087
13270
|
fontWeight: 500,
|
|
@@ -13112,7 +13295,7 @@ function IncomeStatementResolver(p) {
|
|
|
13112
13295
|
sections.map((section, si) => {
|
|
13113
13296
|
var _a2;
|
|
13114
13297
|
const isSubtotal = section.sectionType === "subtotal";
|
|
13115
|
-
return /* @__PURE__ */ jsxs(
|
|
13298
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
13116
13299
|
/* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: colCount, style: {
|
|
13117
13300
|
padding: "8px 12px",
|
|
13118
13301
|
fontSize: "12px",
|
|
@@ -13143,7 +13326,7 @@ function IncomeStatementResolver(p) {
|
|
|
13143
13326
|
var _a4;
|
|
13144
13327
|
const val = (_a4 = amounts[pi]) != null ? _a4 : 0;
|
|
13145
13328
|
const isNeg = val < 0;
|
|
13146
|
-
return /* @__PURE__ */ jsxs(
|
|
13329
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
13147
13330
|
/* @__PURE__ */ jsx("td", { style: {
|
|
13148
13331
|
padding: "6px 10px",
|
|
13149
13332
|
fontSize: "13px",
|
|
@@ -13178,7 +13361,7 @@ function IncomeStatementResolver(p) {
|
|
|
13178
13361
|
var _a2;
|
|
13179
13362
|
const val = (_a2 = grossProfit[pi]) != null ? _a2 : 0;
|
|
13180
13363
|
const isNeg = val < 0;
|
|
13181
|
-
return /* @__PURE__ */ jsxs(
|
|
13364
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
13182
13365
|
/* @__PURE__ */ jsx("td", { style: {
|
|
13183
13366
|
padding: "8px 10px",
|
|
13184
13367
|
fontSize: "12px",
|
|
@@ -13213,7 +13396,7 @@ function IncomeStatementResolver(p) {
|
|
|
13213
13396
|
var _a2;
|
|
13214
13397
|
const val = (_a2 = operatingIncome[pi]) != null ? _a2 : 0;
|
|
13215
13398
|
const isNeg = val < 0;
|
|
13216
|
-
return /* @__PURE__ */ jsxs(
|
|
13399
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
13217
13400
|
/* @__PURE__ */ jsx("td", { style: {
|
|
13218
13401
|
padding: "8px 10px",
|
|
13219
13402
|
fontSize: "12px",
|
|
@@ -13247,7 +13430,7 @@ function IncomeStatementResolver(p) {
|
|
|
13247
13430
|
var _a2;
|
|
13248
13431
|
const val = (_a2 = netIncome[pi]) != null ? _a2 : 0;
|
|
13249
13432
|
const isNeg = val < 0;
|
|
13250
|
-
return /* @__PURE__ */ jsxs(
|
|
13433
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
13251
13434
|
/* @__PURE__ */ jsx("td", { style: {
|
|
13252
13435
|
padding: "10px 10px",
|
|
13253
13436
|
fontSize: "13px",
|
|
@@ -13467,7 +13650,7 @@ function CashFlowStatementResolver(p) {
|
|
|
13467
13650
|
/* @__PURE__ */ jsxs("tbody", { children: [
|
|
13468
13651
|
activities.map((activity, ai) => {
|
|
13469
13652
|
var _a2, _b2, _c2;
|
|
13470
|
-
return /* @__PURE__ */ jsxs(
|
|
13653
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
13471
13654
|
ai > 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
|
|
13472
13655
|
"td",
|
|
13473
13656
|
{
|
|
@@ -18004,8 +18187,8 @@ var CARD_MIN = 132;
|
|
|
18004
18187
|
var CARD_GAP = 16;
|
|
18005
18188
|
var AUTO_COMPACT_BELOW = 360;
|
|
18006
18189
|
function useContainerWidth(ref) {
|
|
18007
|
-
const [w, setW] =
|
|
18008
|
-
|
|
18190
|
+
const [w, setW] = React46.useState(0);
|
|
18191
|
+
React46.useLayoutEffect(() => {
|
|
18009
18192
|
const el = ref.current;
|
|
18010
18193
|
if (!el || typeof ResizeObserver === "undefined") return;
|
|
18011
18194
|
const ro = new ResizeObserver((entries) => {
|
|
@@ -18108,15 +18291,15 @@ function WorkflowStepperRenderer({
|
|
|
18108
18291
|
const interactive = typeof onSelectStep === "function";
|
|
18109
18292
|
const statusColor3 = (s) => s === "active" || s === "running" ? ACCENT2 : STATUS_COLORS3[s];
|
|
18110
18293
|
const doneCount = steps.filter((s) => s.status === "done").length;
|
|
18111
|
-
const rootRef =
|
|
18294
|
+
const rootRef = React46.useRef(null);
|
|
18112
18295
|
const containerW = useContainerWidth(rootRef);
|
|
18113
18296
|
let resolved = density === "auto" ? "full" : density;
|
|
18114
18297
|
if (density === "auto" && containerW > 0) {
|
|
18115
18298
|
const needed = steps.length * CARD_MIN + Math.max(0, steps.length - 1) * CARD_GAP;
|
|
18116
18299
|
resolved = containerW < AUTO_COMPACT_BELOW || needed > containerW * 1.6 ? "compact" : "full";
|
|
18117
18300
|
}
|
|
18118
|
-
const scrollerRef =
|
|
18119
|
-
|
|
18301
|
+
const scrollerRef = React46.useRef(null);
|
|
18302
|
+
React46.useEffect(() => {
|
|
18120
18303
|
if (resolved !== "full" || loading) return;
|
|
18121
18304
|
const sc = scrollerRef.current;
|
|
18122
18305
|
if (!sc) return;
|
|
@@ -18127,11 +18310,11 @@ function WorkflowStepperRenderer({
|
|
|
18127
18310
|
el.scrollIntoView({ inline: "center", block: "nearest", behavior: "smooth" });
|
|
18128
18311
|
}
|
|
18129
18312
|
}, [resolved, loading, selectedStep, activeStepId]);
|
|
18130
|
-
const [edges, setEdges] =
|
|
18313
|
+
const [edges, setEdges] = React46.useState({
|
|
18131
18314
|
left: false,
|
|
18132
18315
|
right: false
|
|
18133
18316
|
});
|
|
18134
|
-
const updateEdges =
|
|
18317
|
+
const updateEdges = React46.useCallback(() => {
|
|
18135
18318
|
const sc = scrollerRef.current;
|
|
18136
18319
|
if (!sc) return;
|
|
18137
18320
|
const max = sc.scrollWidth - sc.clientWidth;
|
|
@@ -18140,7 +18323,7 @@ function WorkflowStepperRenderer({
|
|
|
18140
18323
|
const right = sl < max - 1;
|
|
18141
18324
|
setEdges((prev) => prev.left === left && prev.right === right ? prev : { left, right });
|
|
18142
18325
|
}, []);
|
|
18143
|
-
|
|
18326
|
+
React46.useLayoutEffect(() => {
|
|
18144
18327
|
if (resolved !== "full" || loading) return;
|
|
18145
18328
|
updateEdges();
|
|
18146
18329
|
const sc = scrollerRef.current;
|
|
@@ -18196,7 +18379,7 @@ function WorkflowStepperRenderer({
|
|
|
18196
18379
|
const reached = s.status !== "pending";
|
|
18197
18380
|
const clickable = interactive && reached;
|
|
18198
18381
|
const size = act ? 11 : done ? 9 : 8;
|
|
18199
|
-
return /* @__PURE__ */ jsxs(
|
|
18382
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
18200
18383
|
i > 0 && /* @__PURE__ */ jsx(
|
|
18201
18384
|
"span",
|
|
18202
18385
|
{
|
|
@@ -18340,7 +18523,7 @@ function WorkflowStepperRenderer({
|
|
|
18340
18523
|
const color = statusColor3(step.status);
|
|
18341
18524
|
const humans = ((_a2 = step.assignees) != null ? _a2 : []).filter((a) => a.kind === "human");
|
|
18342
18525
|
const roleCaption = humans.map((h) => h.role).filter(Boolean).slice(0, 2).join(" \xB7 ");
|
|
18343
|
-
return /* @__PURE__ */ jsxs(
|
|
18526
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
18344
18527
|
i > 0 && /* @__PURE__ */ jsx(
|
|
18345
18528
|
"div",
|
|
18346
18529
|
{
|
|
@@ -18706,11 +18889,11 @@ function FieldDetail({
|
|
|
18706
18889
|
}) {
|
|
18707
18890
|
var _a, _b, _c, _d;
|
|
18708
18891
|
const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SECONDARY: SECONDARY2, SURFACE: SURFACE2, ACCENT: ACCENT2 } = useTheme();
|
|
18709
|
-
const [editing, setEditing] =
|
|
18710
|
-
const [draft, setDraft] =
|
|
18711
|
-
const [saving, setSaving] =
|
|
18712
|
-
const [saveError, setSaveError] =
|
|
18713
|
-
const textareaRef =
|
|
18892
|
+
const [editing, setEditing] = React46.useState(false);
|
|
18893
|
+
const [draft, setDraft] = React46.useState("");
|
|
18894
|
+
const [saving, setSaving] = React46.useState(false);
|
|
18895
|
+
const [saveError, setSaveError] = React46.useState(null);
|
|
18896
|
+
const textareaRef = React46.useRef(null);
|
|
18714
18897
|
const color = fieldColor(field, SECONDARY2);
|
|
18715
18898
|
const corrected = field.state === "corrected";
|
|
18716
18899
|
const startEdit = (e) => {
|
|
@@ -19220,7 +19403,7 @@ function FieldDetails({
|
|
|
19220
19403
|
},
|
|
19221
19404
|
children: facts.map((f) => {
|
|
19222
19405
|
var _a2;
|
|
19223
|
-
return /* @__PURE__ */ jsxs(
|
|
19406
|
+
return /* @__PURE__ */ jsxs(React46.Fragment, { children: [
|
|
19224
19407
|
/* @__PURE__ */ jsx("dt", { style: { fontSize: "12px", color: MUTED2 }, children: f.label }),
|
|
19225
19408
|
/* @__PURE__ */ jsxs(
|
|
19226
19409
|
"dd",
|
|
@@ -19319,7 +19502,7 @@ function FieldAuditLog({
|
|
|
19319
19502
|
fields = []
|
|
19320
19503
|
}) {
|
|
19321
19504
|
const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SECONDARY: SECONDARY2 } = useTheme();
|
|
19322
|
-
const fieldLabelMap =
|
|
19505
|
+
const fieldLabelMap = React46.useMemo(() => {
|
|
19323
19506
|
var _a;
|
|
19324
19507
|
const map = {};
|
|
19325
19508
|
for (const f of fields) map[f.field_key] = (_a = f.label) != null ? _a : f.field_key;
|
|
@@ -19518,10 +19701,10 @@ function PageOverlay({
|
|
|
19518
19701
|
secondary
|
|
19519
19702
|
}) {
|
|
19520
19703
|
const { PAPER: PAPER2, MUTED: MUTED2 } = useTheme();
|
|
19521
|
-
const imgRef =
|
|
19522
|
-
const selectedBoxRef =
|
|
19523
|
-
const [px, setPx] =
|
|
19524
|
-
|
|
19704
|
+
const imgRef = React46.useRef(null);
|
|
19705
|
+
const selectedBoxRef = React46.useRef(null);
|
|
19706
|
+
const [px, setPx] = React46.useState(null);
|
|
19707
|
+
React46.useEffect(() => {
|
|
19525
19708
|
const el = imgRef.current;
|
|
19526
19709
|
if (!el) return;
|
|
19527
19710
|
const measure = () => {
|
|
@@ -19535,7 +19718,7 @@ function PageOverlay({
|
|
|
19535
19718
|
ro.observe(el);
|
|
19536
19719
|
return () => ro.disconnect();
|
|
19537
19720
|
}, [page.imageUrl]);
|
|
19538
|
-
|
|
19721
|
+
React46.useEffect(() => {
|
|
19539
19722
|
if (!selectedKey) return;
|
|
19540
19723
|
if (!fields.some((f) => f.field_key === selectedKey && f.bbox)) return;
|
|
19541
19724
|
const el = selectedBoxRef.current;
|
|
@@ -19637,8 +19820,8 @@ function ExtractionDetail({
|
|
|
19637
19820
|
auditLoading
|
|
19638
19821
|
}) {
|
|
19639
19822
|
const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SECONDARY: SECONDARY2 } = useTheme();
|
|
19640
|
-
const selectedCardRef =
|
|
19641
|
-
|
|
19823
|
+
const selectedCardRef = React46.useRef(null);
|
|
19824
|
+
React46.useEffect(() => {
|
|
19642
19825
|
if (!selectedKey || tab !== "fields") return;
|
|
19643
19826
|
const el = selectedCardRef.current;
|
|
19644
19827
|
if (el && typeof el.scrollIntoView === "function") {
|
|
@@ -19809,7 +19992,7 @@ function ExtractionModal({
|
|
|
19809
19992
|
children
|
|
19810
19993
|
}) {
|
|
19811
19994
|
const { BORDER: BORDER3, MUTED: MUTED2, SURFACE: SURFACE2, FOREGROUND: FOREGROUND2, SCRIM: SCRIM2 } = useTheme();
|
|
19812
|
-
|
|
19995
|
+
React46.useEffect(() => {
|
|
19813
19996
|
if (!open) return;
|
|
19814
19997
|
const onKey = (e) => {
|
|
19815
19998
|
if (e.key === "Escape") onClose();
|
|
@@ -19938,19 +20121,19 @@ function ExtractionModal({
|
|
|
19938
20121
|
function DocumentFieldExtractionResolver(p) {
|
|
19939
20122
|
var _a, _b;
|
|
19940
20123
|
const { BORDER: BORDER3, MUTED: MUTED2, PAPER: PAPER2, SURFACE: SURFACE2, SHADOW: SHADOW2, ACCENT: ACCENT2 } = useTheme();
|
|
19941
|
-
const [selectedKey, setSelectedKey] =
|
|
19942
|
-
const [open, setOpen] =
|
|
19943
|
-
const [tab, setTab] =
|
|
20124
|
+
const [selectedKey, setSelectedKey] = React46.useState(null);
|
|
20125
|
+
const [open, setOpen] = React46.useState(false);
|
|
20126
|
+
const [tab, setTab] = React46.useState("fields");
|
|
19944
20127
|
const pages = (_a = p.pages) != null ? _a : [];
|
|
19945
20128
|
const fields = (_b = p.fields) != null ? _b : [];
|
|
19946
20129
|
const editable = typeof p.onFieldSave === "function";
|
|
19947
20130
|
const onLoadAudit = p.onLoadAudit;
|
|
19948
|
-
|
|
20131
|
+
React46.useEffect(() => {
|
|
19949
20132
|
if (tab === "audit" && onLoadAudit) {
|
|
19950
20133
|
onLoadAudit();
|
|
19951
20134
|
}
|
|
19952
20135
|
}, [tab, onLoadAudit]);
|
|
19953
|
-
const correctionCounts =
|
|
20136
|
+
const correctionCounts = React46.useMemo(() => {
|
|
19954
20137
|
var _a2, _b2;
|
|
19955
20138
|
const counts = {};
|
|
19956
20139
|
for (const ev of (_a2 = p.auditEvents) != null ? _a2 : []) {
|
|
@@ -20196,8 +20379,8 @@ function formatAmount2(amount, currency = "USD") {
|
|
|
20196
20379
|
return `${sign}${symbol}${body}`;
|
|
20197
20380
|
}
|
|
20198
20381
|
function useContainerWidth2(ref) {
|
|
20199
|
-
const [w, setW] =
|
|
20200
|
-
|
|
20382
|
+
const [w, setW] = React46.useState(0);
|
|
20383
|
+
React46.useLayoutEffect(() => {
|
|
20201
20384
|
const el = ref.current;
|
|
20202
20385
|
if (!el || typeof ResizeObserver === "undefined") return;
|
|
20203
20386
|
const ro = new ResizeObserver((entries) => {
|
|
@@ -20292,8 +20475,8 @@ function ValueAdjuster({
|
|
|
20292
20475
|
const { SURFACE_MUTED: SURFACE_MUTED2 } = useTheme();
|
|
20293
20476
|
const adjust = option.adjust;
|
|
20294
20477
|
const suggested = clampToRange((_a = option.value) != null ? _a : adjust.min, adjust);
|
|
20295
|
-
const [value, setValue] =
|
|
20296
|
-
const [text, setText] =
|
|
20478
|
+
const [value, setValue] = React46.useState(suggested);
|
|
20479
|
+
const [text, setText] = React46.useState(String(suggested));
|
|
20297
20480
|
const step = (_b = adjust.step) != null ? _b : Number.isInteger(adjust.min) && Number.isInteger(adjust.max) ? 1 : (adjust.max - adjust.min) / 100;
|
|
20298
20481
|
const pct = adjust.max > adjust.min ? (value - adjust.min) / (adjust.max - adjust.min) * 100 : 0;
|
|
20299
20482
|
const suggestedPct = adjust.max > adjust.min ? (suggested - adjust.min) / (adjust.max - adjust.min) * 100 : 0;
|
|
@@ -20499,10 +20682,10 @@ function DecisionCardRenderer({
|
|
|
20499
20682
|
}) {
|
|
20500
20683
|
var _a, _b, _c;
|
|
20501
20684
|
const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2, SHADOW: SHADOW2 } = useTheme();
|
|
20502
|
-
const rootRef =
|
|
20685
|
+
const rootRef = React46.useRef(null);
|
|
20503
20686
|
const width = useContainerWidth2(rootRef);
|
|
20504
20687
|
const stacked = width > 0 && width < STACK_BELOW;
|
|
20505
|
-
const [adjustingIdx, setAdjustingIdx] =
|
|
20688
|
+
const [adjustingIdx, setAdjustingIdx] = React46.useState(null);
|
|
20506
20689
|
const options = (_a = data.options) != null ? _a : [];
|
|
20507
20690
|
const recommendedIdx = Math.max(
|
|
20508
20691
|
0,
|
|
@@ -20803,8 +20986,8 @@ function DecisionCardResolver(p) {
|
|
|
20803
20986
|
const decisionId = (_a = p.id) != null ? _a : p.title;
|
|
20804
20987
|
const hostResolved = resolvedDecisions == null ? void 0 : resolvedDecisions[decisionId];
|
|
20805
20988
|
const initial = hostResolved != null ? hostResolved : p.resolved ? composeResolution(p, p.resolved.option, p.resolved.value) : null;
|
|
20806
|
-
const [localResolved, setLocalResolved] =
|
|
20807
|
-
|
|
20989
|
+
const [localResolved, setLocalResolved] = React46.useState(initial);
|
|
20990
|
+
React46.useEffect(() => {
|
|
20808
20991
|
if (hostResolved !== void 0) setLocalResolved(hostResolved);
|
|
20809
20992
|
}, [hostResolved]);
|
|
20810
20993
|
const resolved = hostResolved != null ? hostResolved : localResolved;
|
|
@@ -20878,11 +21061,11 @@ function DecisionQueueRenderer({
|
|
|
20878
21061
|
var _a;
|
|
20879
21062
|
const { BORDER: BORDER3, MUTED: MUTED2, ACCENT: ACCENT2, SURFACE: SURFACE2, SURFACE_MUTED: SURFACE_MUTED2, BORDER_SOFT: BORDER_SOFT2, PAPER: PAPER2, SHADOW: SHADOW2 } = useTheme();
|
|
20880
21063
|
const items = (_a = data.items) != null ? _a : [];
|
|
20881
|
-
const [decisions, setDecisions] =
|
|
21064
|
+
const [decisions, setDecisions] = React46.useState(
|
|
20882
21065
|
() => items.map(() => void 0)
|
|
20883
21066
|
);
|
|
20884
21067
|
const firstUndecided = decisions.findIndex((d) => !d);
|
|
20885
|
-
const [focusIdx, setFocusIdx] =
|
|
21068
|
+
const [focusIdx, setFocusIdx] = React46.useState(firstUndecided >= 0 ? firstUndecided : null);
|
|
20886
21069
|
const isSubmitted = submitted != null;
|
|
20887
21070
|
const shown = isSubmitted ? items.map(
|
|
20888
21071
|
(item, i) => {
|
|
@@ -20907,16 +21090,16 @@ function DecisionQueueRenderer({
|
|
|
20907
21090
|
const final = decisions;
|
|
20908
21091
|
onSubmit == null ? void 0 : onSubmit(final, composeQueueMessage(items, final));
|
|
20909
21092
|
};
|
|
20910
|
-
const onReadyRef =
|
|
20911
|
-
|
|
21093
|
+
const onReadyRef = React46.useRef(onReady);
|
|
21094
|
+
React46.useEffect(() => {
|
|
20912
21095
|
onReadyRef.current = onReady;
|
|
20913
21096
|
});
|
|
20914
|
-
|
|
21097
|
+
React46.useEffect(() => {
|
|
20915
21098
|
if (!onReadyRef.current) return;
|
|
20916
21099
|
const msg = allDecided ? composeQueueMessage(items, decisions) : null;
|
|
20917
21100
|
onReadyRef.current(allDecided && !isSubmitted, msg, decisions.filter(Boolean));
|
|
20918
21101
|
}, [decisions, allDecided, isSubmitted]);
|
|
20919
|
-
|
|
21102
|
+
React46.useEffect(() => {
|
|
20920
21103
|
if (!submitRef) return;
|
|
20921
21104
|
submitRef.current = handleSubmit;
|
|
20922
21105
|
return () => {
|
|
@@ -21141,7 +21324,7 @@ function DecisionQueueResolver(p) {
|
|
|
21141
21324
|
const { resolvedDecisions, onDecisionQueueSubmit } = useGenUIInteraction();
|
|
21142
21325
|
const queueId = (_b = (_a = p.id) != null ? _a : p.title) != null ? _b : "decision-queue";
|
|
21143
21326
|
const replayed = (_d = (_c = p.resolved) == null ? void 0 : _c.decisions) != null ? _d : null;
|
|
21144
|
-
const [localSubmitted, setLocalSubmitted] =
|
|
21327
|
+
const [localSubmitted, setLocalSubmitted] = React46.useState(null);
|
|
21145
21328
|
const hostLocked = (resolvedDecisions == null ? void 0 : resolvedDecisions[queueId]) != null;
|
|
21146
21329
|
const submitted = (_e = replayed != null ? replayed : localSubmitted) != null ? _e : hostLocked ? [] : null;
|
|
21147
21330
|
const handleSubmit = (decisions, message) => {
|