@flytedan/flytebot-design-system 0.79.0 → 0.80.0

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/index.cjs CHANGED
@@ -927,11 +927,16 @@ __export(index_exports, {
927
927
  Button: () => Button,
928
928
  CHANNELS: () => CHANNELS,
929
929
  CHANNEL_WEIGHTS: () => CHANNEL_WEIGHTS,
930
+ CHAT_CALL_DEADLINE_MS: () => CHAT_CALL_DEADLINE_MS,
930
931
  CHAT_UNAVAILABLE: () => CHAT_UNAVAILABLE,
932
+ CHAT_UNAVAILABLE_MESSAGE: () => CHAT_UNAVAILABLE_MESSAGE,
931
933
  COPIED_FEEDBACK_MS: () => COPIED_FEEDBACK_MS,
932
934
  CORNER_STACK_INSET_PROPERTY: () => CORNER_STACK_INSET_PROPERTY,
933
935
  CORNER_STACK_OFFSET_PROPERTY: () => CORNER_STACK_OFFSET_PROPERTY,
936
+ CSV_FAILED_FALLBACK: () => CSV_FAILED_FALLBACK,
937
+ CSV_KEPT_NOTE: () => CSV_KEPT_NOTE,
934
938
  Calendar: () => Calendar,
939
+ CallDeadlineError: () => CallDeadlineError,
935
940
  Card: () => Card,
936
941
  CardGrid: () => CardGrid,
937
942
  CardRow: () => CardRow,
@@ -944,6 +949,7 @@ __export(index_exports, {
944
949
  ChatSessionBar: () => ChatSessionBar,
945
950
  ChatTranscript: () => ChatTranscript,
946
951
  ChatTurn: () => ChatTurn,
952
+ ChatUnreachableError: () => ChatUnreachableError,
947
953
  Checkbox: () => Checkbox,
948
954
  Citations: () => Citations,
949
955
  Clamp: () => Clamp,
@@ -956,6 +962,7 @@ __export(index_exports, {
956
962
  CsiBadge: () => CsiBadge,
957
963
  CsiHero: () => CsiHero,
958
964
  CsiMeter: () => CsiMeter,
965
+ CsvCard: () => CsvCard,
959
966
  DEFAULT_PREFS: () => DEFAULT_PREFS,
960
967
  DEFAULT_STORAGE_KEY: () => DEFAULT_STORAGE_KEY,
961
968
  DEFAULT_TOAST_DURATION_MS: () => DEFAULT_TOAST_DURATION_MS,
@@ -968,9 +975,14 @@ __export(index_exports, {
968
975
  Dropzone: () => Dropzone,
969
976
  DropzoneKit: () => DropzoneKit,
970
977
  ENTITY_ROW_METRIC_WIDTH: () => ENTITY_ROW_METRIC_WIDTH,
978
+ EXPORT_FAILED_FALLBACK: () => EXPORT_FAILED_FALLBACK,
979
+ EXPORT_IDLE_POLL_INTERVAL_MS: () => EXPORT_IDLE_POLL_INTERVAL_MS,
980
+ EXPORT_KEPT_NOTE: () => EXPORT_KEPT_NOTE,
981
+ EXPORT_POLL_INTERVAL_MS: () => EXPORT_POLL_INTERVAL_MS,
971
982
  EmptyState: () => EmptyState,
972
983
  EntityRow: () => EntityRow,
973
984
  EntityRowMetrics: () => EntityRowMetrics,
985
+ ExportTray: () => ExportTray,
974
986
  FILE_VIEWER_CSV_ROW_LIMIT: () => FILE_VIEWER_CSV_ROW_LIMIT,
975
987
  FILE_VIEWER_TEXT_LIMIT: () => FILE_VIEWER_TEXT_LIMIT,
976
988
  FactList: () => FactList,
@@ -1013,6 +1025,7 @@ __export(index_exports, {
1013
1025
  Modal: () => Modal,
1014
1026
  ModeSwitch: () => ModeSwitch,
1015
1027
  ModelControls: () => ModelControls,
1028
+ NEW_THREAD_FAILED: () => NEW_THREAD_FAILED,
1016
1029
  NumberInput: () => NumberInput,
1017
1030
  OVERLAY_BREAKPOINT: () => OVERLAY_BREAKPOINT,
1018
1031
  OVERLAY_CEILING: () => OVERLAY_CEILING,
@@ -1026,7 +1039,9 @@ __export(index_exports, {
1026
1039
  PreferenceMeter: () => PreferenceMeter,
1027
1040
  ProfilePage: () => ProfilePage,
1028
1041
  ProgressBar: () => ProgressBar,
1042
+ QUERY_EMPTY_MESSAGE: () => QUERY_EMPTY_MESSAGE,
1029
1043
  QueryKit: () => QueryKit,
1044
+ QueryResultCard: () => QueryResultCard,
1030
1045
  QuotaRow: () => QuotaRow,
1031
1046
  ROOT_STEP: () => ROOT_STEP,
1032
1047
  Radio: () => Radio,
@@ -1060,6 +1075,7 @@ __export(index_exports, {
1060
1075
  StepList: () => StepList,
1061
1076
  SurroundSound: () => SurroundSound,
1062
1077
  Switch: () => Switch,
1078
+ THREADS_LOAD_FAILED: () => THREADS_LOAD_FAILED,
1063
1079
  Tabs: () => Tabs,
1064
1080
  Tag: () => Tag,
1065
1081
  TestModeBar: () => TestModeBar,
@@ -1089,9 +1105,13 @@ __export(index_exports, {
1089
1105
  computeNeedMore: () => computeNeedMore,
1090
1106
  computeVirtualWindow: () => computeVirtualWindow,
1091
1107
  copyToClipboard: () => copyToClipboard,
1108
+ createChatAdapter: () => createChatAdapter,
1109
+ createExportDownloader: () => createExportDownloader,
1092
1110
  createLocalStorageAppearanceStore: () => createLocalStorageAppearanceStore,
1093
1111
  createVersionStore: () => createVersionStore,
1094
1112
  eqFilter: () => eqFilter,
1113
+ exportStateOf: () => exportStateOf,
1114
+ exportToJob: () => exportToJob,
1095
1115
  extensionOf: () => extensionOf,
1096
1116
  extractClipboardFiles: () => extractClipboardFiles,
1097
1117
  filterFiles: () => filterFiles,
@@ -1110,7 +1130,9 @@ __export(index_exports, {
1110
1130
  importanceLevel: () => importanceLevel,
1111
1131
  importanceTokens: () => importanceTokens,
1112
1132
  installFlytedeskFavicon: () => installFlytedeskFavicon,
1133
+ isExpiredExport: () => isExpiredExport,
1113
1134
  isImage: () => isImage,
1135
+ isLiveExport: () => isLiveExport,
1114
1136
  isSystemMessage: () => isSystemMessage,
1115
1137
  isUsStateCode: () => isUsStateCode,
1116
1138
  isWithinLayerTree: () => isWithinLayerTree,
@@ -1135,9 +1157,12 @@ __export(index_exports, {
1135
1157
  useAppearancePrefs: () => useAppearancePrefs,
1136
1158
  useAppearanceStore: () => useAppearanceStore,
1137
1159
  useChatEngine: () => useChatEngine,
1160
+ useChatThreads: () => useChatThreads,
1138
1161
  useCopyToClipboard: () => useCopyToClipboard,
1139
1162
  useCornerStackSlot: () => useCornerStackSlot,
1140
1163
  useDocumentTitle: () => useDocumentTitle,
1164
+ useExpiryClock: () => useExpiryClock,
1165
+ useExportJobs: () => useExportJobs,
1141
1166
  useFeatureStatus: () => useFeatureStatus,
1142
1167
  useLayerZIndex: () => useLayerZIndex,
1143
1168
  useOverlayLayout: () => useOverlayLayout,
@@ -1148,6 +1173,7 @@ __export(index_exports, {
1148
1173
  useServerTable: () => useServerTable,
1149
1174
  useSessionContext: () => useSessionContext,
1150
1175
  useSheetOpenMark: () => useSheetOpenMark,
1176
+ useShownExport: () => useShownExport,
1151
1177
  useStackedLayer: () => useStackedLayer,
1152
1178
  useStagedFiles: () => useStagedFiles,
1153
1179
  useToast: () => useToast,
@@ -1155,6 +1181,7 @@ __export(index_exports, {
1155
1181
  validateFilterValue: () => validateFilterValue,
1156
1182
  visibleMessages: () => visibleMessages,
1157
1183
  watchAppearance: () => watchAppearance,
1184
+ withDeadline: () => withDeadline,
1158
1185
  writeQueryToUrl: () => writeQueryToUrl
1159
1186
  });
1160
1187
  module.exports = __toCommonJS(index_exports);
@@ -15414,9 +15441,155 @@ function AgentChatPanel({
15414
15441
  );
15415
15442
  }
15416
15443
 
15417
- // src/components/files/FileViewer.tsx
15444
+ // src/components/chat/QueryResultCard.tsx
15418
15445
  var React81 = __toESM(require("react"), 1);
15419
15446
  var import_jsx_runtime108 = require("react/jsx-runtime");
15447
+ var STATUS2 = {
15448
+ queued: { label: "Queued", tone: "neutral" },
15449
+ running: { label: "Running", tone: "info" },
15450
+ done: { label: "Done", tone: "success" },
15451
+ failed: { label: "Failed", tone: "danger" },
15452
+ canceled: { label: "Stopped", tone: "neutral" }
15453
+ };
15454
+ var QUERY_EMPTY_MESSAGE = "No rows to show.";
15455
+ function useElapsed(status, startedAt) {
15456
+ const [now, setNow] = React81.useState(() => Date.now());
15457
+ const running = status === "running" && startedAt != null;
15458
+ React81.useEffect(() => {
15459
+ if (!running) return;
15460
+ const tick = setInterval(() => setNow(Date.now()), 1e3);
15461
+ return () => clearInterval(tick);
15462
+ }, [running]);
15463
+ if (!running) return null;
15464
+ return formatDuration(Math.max(0, now - Date.parse(startedAt)));
15465
+ }
15466
+ function QueryResultCard({
15467
+ title,
15468
+ status,
15469
+ startedAt,
15470
+ failureMessage,
15471
+ facts = [],
15472
+ columns,
15473
+ rows = [],
15474
+ rowKey = "id",
15475
+ actions
15476
+ }) {
15477
+ const { label, tone } = STATUS2[status];
15478
+ const elapsed = useElapsed(status, startedAt);
15479
+ const empty = status === "done" && facts.length === 0 && rows.length === 0;
15480
+ return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "fd-stack fd-gap-sm", role: "group", "aria-label": `Query: ${title}`, children: [
15481
+ /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "fd-row fd-wrap fd-justify-between fd-align-center fd-gap-sm", children: [
15482
+ /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "fd-body-sm", style: { overflowWrap: "anywhere", minWidth: 0 }, children: title }),
15483
+ /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Badge, { tone, dot: status === "running", children: elapsed === null ? label : `${label} \xB7 ${elapsed}` })
15484
+ ] }),
15485
+ failureMessage ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("p", { className: "fd-body-sm fd-danger", children: failureMessage }) : null,
15486
+ facts.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(FactList, { facts }),
15487
+ rows.length === 0 || !columns ? null : /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(DataTable, { compact: true, columns, rows, rowKey }),
15488
+ empty ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("p", { className: "fd-body-sm fd-muted", children: QUERY_EMPTY_MESSAGE }) : null,
15489
+ actions ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "fd-row fd-wrap fd-gap-sm", children: actions }) : null
15490
+ ] });
15491
+ }
15492
+
15493
+ // src/components/chat/CsvCard.tsx
15494
+ var React83 = __toESM(require("react"), 1);
15495
+
15496
+ // src/kits/exports/exportState.ts
15497
+ var React82 = __toESM(require("react"), 1);
15498
+
15499
+ // src/kits/exports/exportJob.ts
15500
+ function isLiveExport(job) {
15501
+ return job.status === "PENDING" || job.status === "RUNNING";
15502
+ }
15503
+ function isExpiredExport(job, now) {
15504
+ return job.expiresAt !== null && Date.parse(job.expiresAt) <= now;
15505
+ }
15506
+
15507
+ // src/kits/exports/exportState.ts
15508
+ function exportStateOf(job, now) {
15509
+ switch (job.status) {
15510
+ case "PENDING":
15511
+ return "queued";
15512
+ case "RUNNING":
15513
+ return "preparing";
15514
+ case "FAILED":
15515
+ return "failed";
15516
+ case "SUCCEEDED":
15517
+ return isExpiredExport(job, now) ? "expired" : "ready";
15518
+ }
15519
+ }
15520
+ function useExpiryClock(job) {
15521
+ const [now, setNow] = React82.useState(() => Date.now());
15522
+ const { status, expiresAt } = job;
15523
+ React82.useEffect(() => {
15524
+ if (status !== "SUCCEEDED" || expiresAt === null) return;
15525
+ const wait = Date.parse(expiresAt) - Date.now();
15526
+ if (wait <= 0) return;
15527
+ const timer = setTimeout(() => setNow(Date.now()), wait);
15528
+ return () => clearTimeout(timer);
15529
+ }, [status, expiresAt]);
15530
+ return now;
15531
+ }
15532
+ function useLastListed(listed) {
15533
+ const [last, setLast] = React82.useState(listed);
15534
+ if (listed !== void 0 && listed !== last) setLast(listed);
15535
+ return listed ?? last;
15536
+ }
15537
+ function useShownExport(held, exports2, refresh2) {
15538
+ const lastListed = useLastListed(exports2.find((candidate) => candidate.id === held.id));
15539
+ const unlisted = isLiveExport(held) && lastListed === void 0;
15540
+ React82.useEffect(() => {
15541
+ if (unlisted) refresh2();
15542
+ }, [unlisted, refresh2]);
15543
+ return isLiveExport(held) && lastListed !== void 0 ? lastListed : held;
15544
+ }
15545
+
15546
+ // src/components/chat/CsvCard.tsx
15547
+ var import_jsx_runtime109 = require("react/jsx-runtime");
15548
+ var STATE = {
15549
+ queued: { label: "Queued", tone: "neutral" },
15550
+ preparing: { label: "Preparing", tone: "info" },
15551
+ ready: { label: "Ready", tone: "success" },
15552
+ expired: { label: "Expired", tone: "neutral" },
15553
+ failed: { label: "Failed", tone: "danger" }
15554
+ };
15555
+ var CSV_FAILED_FALLBACK = "The CSV could not be made.";
15556
+ var CSV_KEPT_NOTE = "Kept 24 hours";
15557
+ function CsvCard({ job, onDownload }) {
15558
+ const [downloading, setDownloading] = React83.useState(false);
15559
+ const now = useExpiryClock(job);
15560
+ const state = exportStateOf(job, now);
15561
+ const { label, tone } = STATE[state];
15562
+ const facts = job.rowCount === null ? [] : [{ label: "Rows", value: job.rowCount.toLocaleString("en-US") }];
15563
+ function download() {
15564
+ setDownloading(true);
15565
+ void onDownload(job.id).finally(() => setDownloading(false));
15566
+ }
15567
+ return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-stack fd-gap-sm", role: "group", "aria-label": `CSV: ${job.fileName}`, children: [
15568
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-row fd-wrap fd-justify-between fd-align-center fd-gap-sm", children: [
15569
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-body-sm fd-mono", style: { overflowWrap: "anywhere", minWidth: 0 }, children: job.fileName }),
15570
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Badge, { tone, dot: state === "preparing", children: label })
15571
+ ] }),
15572
+ state === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { className: "fd-body-sm fd-danger", children: job.failureMessage ?? CSV_FAILED_FALLBACK }) : null,
15573
+ facts.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(FactList, { facts }),
15574
+ state === "ready" ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { className: "fd-body-sm fd-muted", children: CSV_KEPT_NOTE }) : null,
15575
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "fd-row fd-wrap fd-gap-sm", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
15576
+ Button,
15577
+ {
15578
+ size: "sm",
15579
+ variant: "secondary",
15580
+ icon: "download-simple",
15581
+ disabled: state !== "ready",
15582
+ loading: downloading,
15583
+ onClick: download,
15584
+ children: "Download"
15585
+ }
15586
+ ) })
15587
+ ] });
15588
+ }
15589
+
15590
+ // src/components/files/FileViewer.tsx
15591
+ var React84 = __toESM(require("react"), 1);
15592
+ var import_jsx_runtime110 = require("react/jsx-runtime");
15420
15593
  function previewKindOf(file) {
15421
15594
  const mime = (file.mime || "").toLowerCase();
15422
15595
  const ext = extensionOf(file.name || "");
@@ -15472,13 +15645,13 @@ function parseDelimited(text, delimiter) {
15472
15645
  return rows;
15473
15646
  }
15474
15647
  function usePreview(file, kind, resolveUrl) {
15475
- const [state, setState] = React81.useState({ status: "loading" });
15476
- const [attempt, setAttempt] = React81.useState(0);
15477
- const resolveRef = React81.useRef(resolveUrl);
15478
- React81.useEffect(() => {
15648
+ const [state, setState] = React84.useState({ status: "loading" });
15649
+ const [attempt, setAttempt] = React84.useState(0);
15650
+ const resolveRef = React84.useRef(resolveUrl);
15651
+ React84.useEffect(() => {
15479
15652
  resolveRef.current = resolveUrl;
15480
15653
  }, [resolveUrl]);
15481
- React81.useEffect(() => {
15654
+ React84.useEffect(() => {
15482
15655
  if (kind === "none") {
15483
15656
  setState({ status: "ready" });
15484
15657
  return;
@@ -15508,19 +15681,19 @@ function usePreview(file, kind, resolveUrl) {
15508
15681
  if (ac) ac.abort();
15509
15682
  };
15510
15683
  }, [file.id, kind, attempt]);
15511
- return { ...state, retry: React81.useCallback(() => setAttempt((a) => a + 1), []) };
15684
+ return { ...state, retry: React84.useCallback(() => setAttempt((a) => a + 1), []) };
15512
15685
  }
15513
15686
  function PreviewBody({ file, kind, state }) {
15514
- if (kind === "image") return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("img", { className: "fd-fv-image", src: state.url, alt: file.name || "Preview" });
15515
- if (kind === "pdf") return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("iframe", { className: "fd-fv-pdf", src: state.url, title: file.name || "PDF preview" });
15516
- if (kind === "markdown") return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Markdown, { className: "fd-fv-markdown", source: state.text || "" });
15687
+ if (kind === "image") return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("img", { className: "fd-fv-image", src: state.url, alt: file.name || "Preview" });
15688
+ if (kind === "pdf") return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("iframe", { className: "fd-fv-pdf", src: state.url, title: file.name || "PDF preview" });
15689
+ if (kind === "markdown") return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(Markdown, { className: "fd-fv-markdown", source: state.text || "" });
15517
15690
  if (kind === "json") {
15518
15691
  let pretty = state.text || "";
15519
15692
  try {
15520
15693
  pretty = JSON.stringify(JSON.parse(pretty), null, 2);
15521
15694
  } catch {
15522
15695
  }
15523
- return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(CodeBlock, { code: pretty, language: "json" });
15696
+ return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(CodeBlock, { code: pretty, language: "json" });
15524
15697
  }
15525
15698
  if (kind === "csv") {
15526
15699
  const tsv = extensionOf(file.name || "") === "tsv" || (file.mime || "").toLowerCase().includes("tab-separated");
@@ -15528,12 +15701,12 @@ function PreviewBody({ file, kind, state }) {
15528
15701
  const head = rows[0] || [];
15529
15702
  const dataRows = rows.slice(1);
15530
15703
  const shown = dataRows.slice(0, FILE_VIEWER_CSV_ROW_LIMIT);
15531
- return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "fd-fv-csv", children: [
15532
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("table", { className: "fd-fv-csv-table", children: [
15533
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("tr", { children: head.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("th", { children: c }, i)) }) }),
15534
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("tbody", { children: shown.map((r, ri) => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("tr", { children: head.map((_, ci) => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("td", { children: r[ci] ?? "" }, ci)) }, ri)) })
15704
+ return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "fd-fv-csv", children: [
15705
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("table", { className: "fd-fv-csv-table", children: [
15706
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tr", { children: head.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("th", { children: c }, i)) }) }),
15707
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tbody", { children: shown.map((r, ri) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tr", { children: head.map((_, ci) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("td", { children: r[ci] ?? "" }, ci)) }, ri)) })
15535
15708
  ] }),
15536
- dataRows.length > FILE_VIEWER_CSV_ROW_LIMIT ? /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("p", { className: "fd-fv-csv-note fd-body-sm fd-muted", children: [
15709
+ dataRows.length > FILE_VIEWER_CSV_ROW_LIMIT ? /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("p", { className: "fd-fv-csv-note fd-body-sm fd-muted", children: [
15537
15710
  "Showing the first ",
15538
15711
  FILE_VIEWER_CSV_ROW_LIMIT.toLocaleString(),
15539
15712
  " of ",
@@ -15542,24 +15715,24 @@ function PreviewBody({ file, kind, state }) {
15542
15715
  ] }) : null
15543
15716
  ] });
15544
15717
  }
15545
- if (kind === "text") return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(CodeBlock, { code: state.text || "", language: extensionOf(file.name || "") || void 0 });
15546
- return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "fd-fv-fallback", children: [
15547
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "fd-fv-fallback-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
15548
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "fd-fv-fallback-title", children: "No preview available" }),
15549
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("span", { className: "fd-fv-fallback-meta", children: [
15718
+ if (kind === "text") return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(CodeBlock, { code: state.text || "", language: extensionOf(file.name || "") || void 0 });
15719
+ return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "fd-fv-fallback", children: [
15720
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { className: "fd-fv-fallback-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
15721
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { className: "fd-fv-fallback-title", children: "No preview available" }),
15722
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "fd-fv-fallback-meta", children: [
15550
15723
  file.mime || "Unknown type",
15551
15724
  file.size ? " \xB7 " + formatBytes(file.size) : ""
15552
15725
  ] })
15553
15726
  ] });
15554
15727
  }
15555
15728
  function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", onClose, actions, className = "" }) {
15556
- const kind = React81.useMemo(() => previewKindOf(file), [file]);
15729
+ const kind = React84.useMemo(() => previewKindOf(file), [file]);
15557
15730
  const preview = usePreview(file, kind, resolveUrl);
15558
- const [tab, setTab] = React81.useState("preview");
15559
- const [downloading, setDownloading] = React81.useState(false);
15560
- const [downloadError, setDownloadError] = React81.useState(null);
15731
+ const [tab, setTab] = React84.useState("preview");
15732
+ const [downloading, setDownloading] = React84.useState(false);
15733
+ const [downloadError, setDownloadError] = React84.useState(null);
15561
15734
  const hasSide = sidePanel != null;
15562
- React81.useEffect(() => {
15735
+ React84.useEffect(() => {
15563
15736
  setTab("preview");
15564
15737
  }, [file.id]);
15565
15738
  const download = () => {
@@ -15575,29 +15748,29 @@ function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", o
15575
15748
  a.remove();
15576
15749
  }).catch((err) => setDownloadError(err && err.message || "Download failed.")).finally(() => setDownloading(false));
15577
15750
  };
15578
- return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)(
15751
+ return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
15579
15752
  "section",
15580
15753
  {
15581
15754
  className: ["fd-fv", hasSide && tab === "side" ? "is-tab-side" : "is-tab-preview", className].filter(Boolean).join(" "),
15582
15755
  "aria-label": file.name || "File",
15583
15756
  children: [
15584
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("header", { className: "fd-fv-head", children: [
15585
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "fd-fv-head-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
15586
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("span", { className: "fd-fv-head-titles", children: [
15587
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "fd-fv-head-title", title: file.name, children: file.name }),
15588
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("span", { className: "fd-fv-head-meta", children: [
15757
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("header", { className: "fd-fv-head", children: [
15758
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { className: "fd-fv-head-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
15759
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "fd-fv-head-titles", children: [
15760
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { className: "fd-fv-head-title", title: file.name, children: file.name }),
15761
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "fd-fv-head-meta", children: [
15589
15762
  file.mime || "Unknown type",
15590
15763
  file.size ? " \xB7 " + formatBytes(file.size) : ""
15591
15764
  ] })
15592
15765
  ] }),
15593
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("span", { className: "fd-fv-head-actions", children: [
15766
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "fd-fv-head-actions", children: [
15594
15767
  actions,
15595
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Button, { variant: "secondary", size: "sm", icon: "download-simple", loading: downloading, onClick: download, children: "Download" }),
15596
- onClose ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(IconButton, { icon: "x", label: "Close", onClick: onClose }) : null
15768
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(Button, { variant: "secondary", size: "sm", icon: "download-simple", loading: downloading, onClick: download, children: "Download" }),
15769
+ onClose ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(IconButton, { icon: "x", label: "Close", onClick: onClose }) : null
15597
15770
  ] })
15598
15771
  ] }),
15599
- downloadError ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "fd-fv-download-error", role: "alert", children: downloadError }) : null,
15600
- hasSide ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
15772
+ downloadError ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "fd-fv-download-error", role: "alert", children: downloadError }) : null,
15773
+ hasSide ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
15601
15774
  Tabs,
15602
15775
  {
15603
15776
  className: "fd-fv-tabs",
@@ -15606,19 +15779,19 @@ function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", o
15606
15779
  onChange: (v) => setTab(v)
15607
15780
  }
15608
15781
  ) : null,
15609
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "fd-fv-body", children: [
15610
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "fd-fv-preview", role: "region", "aria-label": "Preview of " + (file.name || "file"), children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
15782
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "fd-fv-body", children: [
15783
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "fd-fv-preview", role: "region", "aria-label": "Preview of " + (file.name || "file"), children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
15611
15784
  LoadingRegion,
15612
15785
  {
15613
15786
  state: preview.status === "loading" ? "loading" : preview.status === "error" ? "error" : "ready",
15614
15787
  error: preview.error,
15615
15788
  label: "Loading preview of " + (file.name || "file"),
15616
15789
  onRetry: preview.status === "error" ? preview.retry : void 0,
15617
- skeleton: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Skeleton, { shape: "card", h: 220 }),
15618
- children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(PreviewBody, { file, kind, state: preview })
15790
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(Skeleton, { shape: "card", h: 220 }),
15791
+ children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(PreviewBody, { file, kind, state: preview })
15619
15792
  }
15620
15793
  ) }),
15621
- hasSide ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "fd-fv-side", role: "region", "aria-label": sidePanelLabel, children: sidePanel }) : null
15794
+ hasSide ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "fd-fv-side", role: "region", "aria-label": sidePanelLabel, children: sidePanel }) : null
15622
15795
  ] })
15623
15796
  ]
15624
15797
  }
@@ -15626,8 +15799,8 @@ function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", o
15626
15799
  }
15627
15800
 
15628
15801
  // src/components/files/FileBrowser.tsx
15629
- var React82 = __toESM(require("react"), 1);
15630
- var import_jsx_runtime109 = require("react/jsx-runtime");
15802
+ var React85 = __toESM(require("react"), 1);
15803
+ var import_jsx_runtime111 = require("react/jsx-runtime");
15631
15804
  function childrenOf(folders, parentId) {
15632
15805
  return folders.filter((f) => f.parentId === parentId).sort((a, b) => a.name.localeCompare(b.name));
15633
15806
  }
@@ -15699,8 +15872,8 @@ function FolderPickerMenu({
15699
15872
  }) {
15700
15873
  const panel = useInlinePanel();
15701
15874
  const { open: open2, setOpen, ref } = panel;
15702
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("span", { className: "fd-fb-menu-anchor", ref, children: [
15703
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
15875
+ return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("span", { className: "fd-fb-menu-anchor", ref, children: [
15876
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15704
15877
  IconButton,
15705
15878
  {
15706
15879
  icon: "arrows-out-cardinal",
@@ -15712,9 +15885,9 @@ function FolderPickerMenu({
15712
15885
  onClick: () => setOpen((v) => !v)
15713
15886
  }
15714
15887
  ),
15715
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(InlinePanelSurface, { panel, align: "right", offset: 4, width: 220, maxHeight: 280, role: "menu", label, children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-menu", children: [
15716
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-overline fd-muted fd-fb-menu-title", children: "Move to\u2026" }),
15717
- destinations.map((d) => /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
15888
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(InlinePanelSurface, { panel, align: "right", offset: 4, width: 220, maxHeight: 280, role: "menu", label, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-menu", children: [
15889
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-overline fd-muted fd-fb-menu-title", children: "Move to\u2026" }),
15890
+ destinations.map((d) => /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
15718
15891
  "button",
15719
15892
  {
15720
15893
  type: "button",
@@ -15726,7 +15899,7 @@ function FolderPickerMenu({
15726
15899
  setOpen(false);
15727
15900
  },
15728
15901
  children: [
15729
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("i", { className: "ph ph-" + (d.id == null ? "house-simple" : "folder-simple"), "aria-hidden": "true" }),
15902
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("i", { className: "ph ph-" + (d.id == null ? "house-simple" : "folder-simple"), "aria-hidden": "true" }),
15730
15903
  d.name
15731
15904
  ]
15732
15905
  },
@@ -15736,8 +15909,8 @@ function FolderPickerMenu({
15736
15909
  ] });
15737
15910
  }
15738
15911
  function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropPayload, actions, className = "" }) {
15739
- const [over, setOver] = React82.useState(false);
15740
- const dragCounter = React82.useRef(0);
15912
+ const [over, setOver] = React85.useState(false);
15913
+ const dragCounter = React85.useRef(0);
15741
15914
  const dropHandlers = isDropTarget ? {
15742
15915
  onDragEnter: (e) => {
15743
15916
  if (!hasInternalPayload(e)) return;
@@ -15762,8 +15935,8 @@ function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropP
15762
15935
  if (payload && onDropPayload) onDropPayload(payload);
15763
15936
  }
15764
15937
  } : {};
15765
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: ["fd-fb-row", over ? "is-drop-target" : "", className].filter(Boolean).join(" "), ...dropHandlers, children: [
15766
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
15938
+ return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: ["fd-fb-row", over ? "is-drop-target" : "", className].filter(Boolean).join(" "), ...dropHandlers, children: [
15939
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
15767
15940
  "button",
15768
15941
  {
15769
15942
  type: "button",
@@ -15772,26 +15945,26 @@ function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropP
15772
15945
  draggable: !!draggableId,
15773
15946
  onDragStart: draggableId ? (e) => writeDragPayload(e, draggableId) : void 0,
15774
15947
  children: [
15775
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-fb-row-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("i", { className: "ph ph-" + icon }) }),
15776
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("span", { className: "fd-fb-row-text", children: [
15777
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-fb-row-name", title: name, children: name }),
15778
- meta ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-fb-row-meta", children: meta }) : null
15948
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-fb-row-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("i", { className: "ph ph-" + icon }) }),
15949
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("span", { className: "fd-fb-row-text", children: [
15950
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-fb-row-name", title: name, children: name }),
15951
+ meta ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-fb-row-meta", children: meta }) : null
15779
15952
  ] })
15780
15953
  ]
15781
15954
  }
15782
15955
  ),
15783
- actions ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-fb-row-actions", children: actions }) : null
15956
+ actions ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-fb-row-actions", children: actions }) : null
15784
15957
  ] });
15785
15958
  }
15786
15959
  function TreeNode({ folder, depth, folders, currentFolderId, onNavigate, onMoveInto, canMove }) {
15787
15960
  const kids = childrenOf(folders, folder.id);
15788
- const [expanded, setExpanded] = React82.useState(() => currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId));
15789
- React82.useEffect(() => {
15961
+ const [expanded, setExpanded] = React85.useState(() => currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId));
15962
+ React85.useEffect(() => {
15790
15963
  if (currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId)) setExpanded(true);
15791
15964
  }, [currentFolderId, folder.id, folders]);
15792
15965
  const isCurrent = folder.id === currentFolderId;
15793
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-tree-node", children: [
15794
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
15966
+ return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-tree-node", children: [
15967
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15795
15968
  RowShell,
15796
15969
  {
15797
15970
  icon: folder.id === currentFolderId ? "folder-open" : "folder-simple",
@@ -15801,7 +15974,7 @@ function TreeNode({ folder, depth, folders, currentFolderId, onNavigate, onMoveI
15801
15974
  isDropTarget: canMove,
15802
15975
  onDropPayload: (payload) => onMoveInto(payload, folder.id),
15803
15976
  className: ["fd-fb-tree-row", isCurrent ? "is-current" : ""].filter(Boolean).join(" "),
15804
- actions: kids.length ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
15977
+ actions: kids.length ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15805
15978
  IconButton,
15806
15979
  {
15807
15980
  icon: expanded ? "caret-down" : "caret-right",
@@ -15813,7 +15986,7 @@ function TreeNode({ folder, depth, folders, currentFolderId, onNavigate, onMoveI
15813
15986
  ) : void 0
15814
15987
  }
15815
15988
  ),
15816
- expanded && kids.length ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "fd-fb-tree-children", style: { paddingLeft: 14 }, children: kids.map((k) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
15989
+ expanded && kids.length ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "fd-fb-tree-children", style: { paddingLeft: 14 }, children: kids.map((k) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15817
15990
  TreeNode,
15818
15991
  {
15819
15992
  folder: k,
@@ -15852,15 +16025,15 @@ function FileBrowser({
15852
16025
  const canUpload = perm.canUpload !== false && !!onUpload;
15853
16026
  const canRemoveFile = perm.canRemoveFile !== false && !!onRemoveFile;
15854
16027
  const canDeleteFolder = perm.canDeleteFolder !== false && !!onDeleteFolder;
15855
- const [createOpen, setCreateOpen] = React82.useState(false);
15856
- const [createName, setCreateName] = React82.useState("");
15857
- const [renameTarget, setRenameTarget] = React82.useState(null);
15858
- const [renameValue, setRenameValue] = React82.useState("");
15859
- const [deleteTarget, setDeleteTarget] = React82.useState(null);
15860
- const uploadInputRef = React82.useRef(null);
15861
- const crumbFolders = React82.useMemo(() => ancestorsOf(folders, currentFolderId), [folders, currentFolderId]);
15862
- const subfolders = React82.useMemo(() => childrenOf(folders, currentFolderId), [folders, currentFolderId]);
15863
- const currentFiles = React82.useMemo(
16028
+ const [createOpen, setCreateOpen] = React85.useState(false);
16029
+ const [createName, setCreateName] = React85.useState("");
16030
+ const [renameTarget, setRenameTarget] = React85.useState(null);
16031
+ const [renameValue, setRenameValue] = React85.useState("");
16032
+ const [deleteTarget, setDeleteTarget] = React85.useState(null);
16033
+ const uploadInputRef = React85.useRef(null);
16034
+ const crumbFolders = React85.useMemo(() => ancestorsOf(folders, currentFolderId), [folders, currentFolderId]);
16035
+ const subfolders = React85.useMemo(() => childrenOf(folders, currentFolderId), [folders, currentFolderId]);
16036
+ const currentFiles = React85.useMemo(
15864
16037
  () => files.filter((f) => f.folderId === currentFolderId).sort((a, b) => a.name.localeCompare(b.name)),
15865
16038
  [files, currentFolderId]
15866
16039
  );
@@ -15899,10 +16072,10 @@ function FileBrowser({
15899
16072
  if (deleteTarget && onDeleteFolder) onDeleteFolder(deleteTarget);
15900
16073
  setDeleteTarget(null);
15901
16074
  };
15902
- const content = /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: ["fd-fb", className].filter(Boolean).join(" "), children: [
15903
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-head", children: [
15904
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("nav", { className: "fd-fb-crumbs", "aria-label": "Folder path", children: [
15905
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16075
+ const content = /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: ["fd-fb", className].filter(Boolean).join(" "), children: [
16076
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-head", children: [
16077
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("nav", { className: "fd-fb-crumbs", "aria-label": "Folder path", children: [
16078
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15906
16079
  BreadcrumbCrumb,
15907
16080
  {
15908
16081
  label: "Home",
@@ -15912,7 +16085,7 @@ function FileBrowser({
15912
16085
  onDropPayload: (p) => moveIntoFolder(p, null)
15913
16086
  }
15914
16087
  ),
15915
- crumbFolders.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16088
+ crumbFolders.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15916
16089
  BreadcrumbCrumb,
15917
16090
  {
15918
16091
  label: f.name,
@@ -15924,11 +16097,11 @@ function FileBrowser({
15924
16097
  f.id
15925
16098
  ))
15926
16099
  ] }),
15927
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("span", { className: "fd-fb-actions", children: [
15928
- canCreateFolder ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "secondary", size: "sm", icon: "folder-simple-plus", onClick: openCreate, children: "New folder" }) : null,
15929
- canUpload ? /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
15930
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "secondary", size: "sm", icon: "upload-simple", onClick: () => uploadInputRef.current && uploadInputRef.current.click(), children: "Upload" }),
15931
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16100
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("span", { className: "fd-fb-actions", children: [
16101
+ canCreateFolder ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "secondary", size: "sm", icon: "folder-simple-plus", onClick: openCreate, children: "New folder" }) : null,
16102
+ canUpload ? /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16103
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "secondary", size: "sm", icon: "upload-simple", onClick: () => uploadInputRef.current && uploadInputRef.current.click(), children: "Upload" }),
16104
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15932
16105
  "input",
15933
16106
  {
15934
16107
  ref: uploadInputRef,
@@ -15946,9 +16119,9 @@ function FileBrowser({
15946
16119
  ] }) : null
15947
16120
  ] })
15948
16121
  ] }),
15949
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-body", children: [
15950
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-tree", role: "region", "aria-label": "Folder tree", children: [
15951
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16122
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-body", children: [
16123
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-tree", role: "region", "aria-label": "Folder tree", children: [
16124
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15952
16125
  RowShell,
15953
16126
  {
15954
16127
  icon: "house-simple",
@@ -15959,7 +16132,7 @@ function FileBrowser({
15959
16132
  className: ["fd-fb-tree-row", currentFolderId == null ? "is-current" : ""].filter(Boolean).join(" ")
15960
16133
  }
15961
16134
  ),
15962
- childrenOf(folders, null).map((f) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16135
+ childrenOf(folders, null).map((f) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15963
16136
  TreeNode,
15964
16137
  {
15965
16138
  folder: f,
@@ -15973,18 +16146,18 @@ function FileBrowser({
15973
16146
  f.id
15974
16147
  ))
15975
16148
  ] }),
15976
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "fd-fb-main", role: "region", "aria-label": "Folder contents", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16149
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "fd-fb-main", role: "region", "aria-label": "Folder contents", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15977
16150
  LoadingRegion,
15978
16151
  {
15979
16152
  state: loading ? "loading" : "ready",
15980
16153
  label: "Loading folder contents",
15981
- skeleton: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-stack", style: { gap: 8, padding: 12 }, children: [
15982
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Skeleton, { h: 44, radius: "10px" }),
15983
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Skeleton, { h: 44, radius: "10px" }),
15984
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Skeleton, { h: 44, radius: "10px" })
16154
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-stack", style: { gap: 8, padding: 12 }, children: [
16155
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Skeleton, { h: 44, radius: "10px" }),
16156
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Skeleton, { h: 44, radius: "10px" }),
16157
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Skeleton, { h: 44, radius: "10px" })
15985
16158
  ] }),
15986
- children: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(EmptyState, { icon: "folder-open", title: "This folder is empty", children: canUpload ? "Drop files here, or use Upload above." : "Nothing has been filed here yet." }) : /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-list", children: [
15987
- subfolders.map((f) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16159
+ children: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(EmptyState, { icon: "folder-open", title: "This folder is empty", children: canUpload ? "Drop files here, or use Upload above." : "Nothing has been filed here yet." }) : /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-list", children: [
16160
+ subfolders.map((f) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15988
16161
  RowShell,
15989
16162
  {
15990
16163
  icon: "folder-simple",
@@ -15993,9 +16166,9 @@ function FileBrowser({
15993
16166
  draggableId: canMove ? { kind: "folder", id: f.id } : void 0,
15994
16167
  isDropTarget: canMove,
15995
16168
  onDropPayload: (p) => moveIntoFolder(p, f.id),
15996
- actions: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
15997
- canRenameFolder ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(IconButton, { icon: "pencil-simple", label: "Rename " + f.name, size: "sm", variant: "ghost", onClick: () => openRename(f) }) : null,
15998
- canMove ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16169
+ actions: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16170
+ canRenameFolder ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(IconButton, { icon: "pencil-simple", label: "Rename " + f.name, size: "sm", variant: "ghost", onClick: () => openRename(f) }) : null,
16171
+ canMove ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15999
16172
  FolderPickerMenu,
16000
16173
  {
16001
16174
  label: "Move " + f.name,
@@ -16003,12 +16176,12 @@ function FileBrowser({
16003
16176
  onPick: (target) => moveIntoFolder({ kind: "folder", id: f.id }, target)
16004
16177
  }
16005
16178
  ) : null,
16006
- canDeleteFolder ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(IconButton, { icon: "trash-simple", label: "Delete " + f.name, size: "sm", variant: "ghost", onClick: () => openDelete(f) }) : null
16179
+ canDeleteFolder ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(IconButton, { icon: "trash-simple", label: "Delete " + f.name, size: "sm", variant: "ghost", onClick: () => openDelete(f) }) : null
16007
16180
  ] })
16008
16181
  },
16009
16182
  f.id
16010
16183
  )),
16011
- currentFiles.map((file) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16184
+ currentFiles.map((file) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
16012
16185
  RowShell,
16013
16186
  {
16014
16187
  icon: iconForMime(file.mime, file.name),
@@ -16016,8 +16189,8 @@ function FileBrowser({
16016
16189
  meta: file.size ? formatBytes(file.size) : void 0,
16017
16190
  onOpen: onOpenFile ? () => onOpenFile(file) : void 0,
16018
16191
  draggableId: canMove ? { kind: "file", id: file.id } : void 0,
16019
- actions: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
16020
- canMove ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16192
+ actions: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16193
+ canMove ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
16021
16194
  FolderPickerMenu,
16022
16195
  {
16023
16196
  label: "Move " + file.name,
@@ -16025,7 +16198,7 @@ function FileBrowser({
16025
16198
  onPick: (target) => onMoveFile && onMoveFile(file.id, target)
16026
16199
  }
16027
16200
  ) : null,
16028
- canRemoveFile ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(IconButton, { icon: "trash-simple", label: "Remove " + file.name, size: "sm", variant: "ghost", onClick: () => onRemoveFile && onRemoveFile(file) }) : null
16201
+ canRemoveFile ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(IconButton, { icon: "trash-simple", label: "Remove " + file.name, size: "sm", variant: "ghost", onClick: () => onRemoveFile && onRemoveFile(file) }) : null
16029
16202
  ] })
16030
16203
  },
16031
16204
  file.id
@@ -16034,10 +16207,10 @@ function FileBrowser({
16034
16207
  }
16035
16208
  ) })
16036
16209
  ] }),
16037
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Modal, { open: createOpen, title: "New folder", onClose: () => setCreateOpen(false), footer: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
16038
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "secondary", onClick: () => setCreateOpen(false), children: "Cancel" }),
16039
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { onClick: submitCreate, disabled: !createName.trim(), children: "Create" })
16040
- ] }), children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16210
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Modal, { open: createOpen, title: "New folder", onClose: () => setCreateOpen(false), footer: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16211
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "secondary", onClick: () => setCreateOpen(false), children: "Cancel" }),
16212
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { onClick: submitCreate, disabled: !createName.trim(), children: "Create" })
16213
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
16041
16214
  "input",
16042
16215
  {
16043
16216
  className: "fd-fb-input",
@@ -16051,10 +16224,10 @@ function FileBrowser({
16051
16224
  autoFocus: true
16052
16225
  }
16053
16226
  ) }),
16054
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Modal, { open: renameTarget != null, title: "Rename folder", onClose: () => setRenameTarget(null), footer: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
16055
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "secondary", onClick: () => setRenameTarget(null), children: "Cancel" }),
16056
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { onClick: submitRename, disabled: !renameValue.trim(), children: "Save" })
16057
- ] }), children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16227
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Modal, { open: renameTarget != null, title: "Rename folder", onClose: () => setRenameTarget(null), footer: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16228
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "secondary", onClick: () => setRenameTarget(null), children: "Cancel" }),
16229
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { onClick: submitRename, disabled: !renameValue.trim(), children: "Save" })
16230
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
16058
16231
  "input",
16059
16232
  {
16060
16233
  className: "fd-fb-input",
@@ -16068,22 +16241,22 @@ function FileBrowser({
16068
16241
  autoFocus: true
16069
16242
  }
16070
16243
  ) }),
16071
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16244
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
16072
16245
  Modal,
16073
16246
  {
16074
16247
  open: deleteTarget != null,
16075
16248
  title: deleteTarget ? "Delete \u201C" + deleteTarget.name + "\u201D?" : "Delete folder?",
16076
16249
  description: "This can't be undone. The folder must be empty.",
16077
16250
  onClose: () => setDeleteTarget(null),
16078
- footer: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
16079
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "secondary", onClick: () => setDeleteTarget(null), children: "Cancel" }),
16080
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "danger", onClick: confirmDelete, children: "Delete" })
16251
+ footer: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16252
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "secondary", onClick: () => setDeleteTarget(null), children: "Cancel" }),
16253
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "danger", onClick: confirmDelete, children: "Delete" })
16081
16254
  ] })
16082
16255
  }
16083
16256
  )
16084
16257
  ] });
16085
16258
  if (!canUpload) return content;
16086
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Dropzone, { className: "fd-fb-dropzone", onFiles: (picked) => onUpload && onUpload(picked, currentFolderId), label: "Drop files to upload", children: content });
16259
+ return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Dropzone, { className: "fd-fb-dropzone", onFiles: (picked) => onUpload && onUpload(picked, currentFolderId), label: "Drop files to upload", children: content });
16087
16260
  }
16088
16261
  function BreadcrumbCrumb({
16089
16262
  label,
@@ -16092,8 +16265,8 @@ function BreadcrumbCrumb({
16092
16265
  isDropTarget,
16093
16266
  onDropPayload
16094
16267
  }) {
16095
- const [over, setOver] = React82.useState(false);
16096
- const dragCounter = React82.useRef(0);
16268
+ const [over, setOver] = React85.useState(false);
16269
+ const dragCounter = React85.useRef(0);
16097
16270
  const dropHandlers = isDropTarget ? {
16098
16271
  onDragEnter: (e) => {
16099
16272
  if (!hasInternalPayload(e)) return;
@@ -16118,11 +16291,11 @@ function BreadcrumbCrumb({
16118
16291
  if (payload && onDropPayload) onDropPayload(payload);
16119
16292
  }
16120
16293
  } : {};
16121
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: ["fd-fb-crumb", over ? "is-drop-target" : ""].filter(Boolean).join(" "), ...dropHandlers, children: isCurrent ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-fb-crumb-current", "aria-current": "page", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("button", { type: "button", className: "fd-fb-crumb-link", onClick, children: label }) });
16294
+ return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: ["fd-fb-crumb", over ? "is-drop-target" : ""].filter(Boolean).join(" "), ...dropHandlers, children: isCurrent ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-fb-crumb-current", "aria-current": "page", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("button", { type: "button", className: "fd-fb-crumb-link", onClick, children: label }) });
16122
16295
  }
16123
16296
 
16124
16297
  // src/kits/query.ts
16125
- var React83 = __toESM(require("react"), 1);
16298
+ var React86 = __toESM(require("react"), 1);
16126
16299
 
16127
16300
  // src/kits/queryUrl.ts
16128
16301
  var historyUrlAdapter = {
@@ -16260,38 +16433,38 @@ function requestFor(params, query, paging, after) {
16260
16433
  }
16261
16434
  var toError = (e) => e instanceof Error ? e : new Error(String(e));
16262
16435
  function useServerTable({ endpoint, params, defaults, deps, prefsKey, paging = "page", url }) {
16263
- const [base] = React83.useState(() => {
16436
+ const [base] = React86.useState(() => {
16264
16437
  const store = PREFS || window.PlannerPrefs;
16265
16438
  const saved = prefsKey && store ? store.getTable(prefsKey) : {};
16266
16439
  return { ...DEFAULTS, ...defaults || {}, ...saved.pageSize ? { pageSize: saved.pageSize } : {}, ...saved.sort ? { sort: saved.sort, dir: saved.dir || "desc" } : {} };
16267
16440
  });
16268
- const [mountParams] = React83.useState(() => url ? (url.adapter ?? historyUrlAdapter).read() : null);
16269
- const address = React83.useRef(mountParams);
16270
- const [query, setQuery] = React83.useState(() => url && mountParams ? readQueryFromUrl(mountParams, url.scope, base, paging) : base);
16271
- const savePref = React83.useCallback((patch2) => {
16441
+ const [mountParams] = React86.useState(() => url ? (url.adapter ?? historyUrlAdapter).read() : null);
16442
+ const address = React86.useRef(mountParams);
16443
+ const [query, setQuery] = React86.useState(() => url && mountParams ? readQueryFromUrl(mountParams, url.scope, base, paging) : base);
16444
+ const savePref = React86.useCallback((patch2) => {
16272
16445
  const store = PREFS || window.PlannerPrefs;
16273
16446
  if (prefsKey && store) store.setTable(prefsKey, patch2);
16274
16447
  }, [prefsKey]);
16275
- const [res, setRes] = React83.useState(null);
16276
- const [loading, setLoading] = React83.useState(true);
16277
- const [loadingMore, setLoadingMore] = React83.useState(false);
16278
- const [failure, setFailure] = React83.useState(null);
16279
- const [reloadToken, setReloadToken] = React83.useState(0);
16280
- const moreController = React83.useRef(null);
16448
+ const [res, setRes] = React86.useState(null);
16449
+ const [loading, setLoading] = React86.useState(true);
16450
+ const [loadingMore, setLoadingMore] = React86.useState(false);
16451
+ const [failure, setFailure] = React86.useState(null);
16452
+ const [reloadToken, setReloadToken] = React86.useState(0);
16453
+ const moreController = React86.useRef(null);
16281
16454
  const depKey = (deps || []).join("|");
16282
16455
  const paramKey = JSON.stringify(params || {});
16283
16456
  const queryKey = JSON.stringify(query);
16284
- const lifetime = React83.useRef(null);
16285
- React83.useEffect(() => {
16457
+ const lifetime = React86.useRef(null);
16458
+ React86.useEffect(() => {
16286
16459
  const controller = new AbortController();
16287
16460
  lifetime.current = controller;
16288
16461
  return () => controller.abort();
16289
16462
  }, []);
16290
- const latest = React83.useRef({ res, loading, query, params, endpoint, url, base });
16291
- React83.useLayoutEffect(() => {
16463
+ const latest = React86.useRef({ res, loading, query, params, endpoint, url, base });
16464
+ React86.useLayoutEffect(() => {
16292
16465
  latest.current = { res, loading, query, params, endpoint, url, base };
16293
16466
  });
16294
- React83.useEffect(() => {
16467
+ React86.useEffect(() => {
16295
16468
  const controller = new AbortController();
16296
16469
  const { signal } = controller;
16297
16470
  setLoading(true);
@@ -16327,7 +16500,7 @@ function useServerTable({ endpoint, params, defaults, deps, prefsKey, paging = "
16327
16500
  };
16328
16501
  }, [endpoint, queryKey, paramKey, depKey, paging, reloadToken]);
16329
16502
  const adapter = url ? url.adapter ?? historyUrlAdapter : null;
16330
- React83.useEffect(() => {
16503
+ React86.useEffect(() => {
16331
16504
  if (!adapter) return;
16332
16505
  return adapter.subscribe((params2) => {
16333
16506
  const { url: u, base: b } = latest.current;
@@ -16677,16 +16850,219 @@ function createVersionStore(initialState, options) {
16677
16850
  }
16678
16851
 
16679
16852
  // src/kits/documentTitle.ts
16680
- var React84 = __toESM(require("react"), 1);
16853
+ var React87 = __toESM(require("react"), 1);
16681
16854
  function formatDocumentTitle(routeTitle, appName) {
16682
16855
  return [routeTitle, appName, "Flytedesk"].filter((part2) => !!part2 && part2.length > 0).join(" \xB7 ");
16683
16856
  }
16684
16857
  function useDocumentTitle(routeTitle, appName) {
16685
- React84.useEffect(() => {
16858
+ React87.useEffect(() => {
16686
16859
  if (typeof document === "undefined") return;
16687
16860
  document.title = formatDocumentTitle(routeTitle, appName);
16688
16861
  }, [routeTitle, appName]);
16689
16862
  }
16863
+
16864
+ // src/kits/chatTransport/deadline.ts
16865
+ var CHAT_CALL_DEADLINE_MS = 3e4;
16866
+ var CallDeadlineError = class extends Error {
16867
+ constructor(call, deadlineMs) {
16868
+ super(`${call} did not answer within ${deadlineMs}ms`);
16869
+ this.call = call;
16870
+ this.deadlineMs = deadlineMs;
16871
+ this.name = "CallDeadlineError";
16872
+ }
16873
+ call;
16874
+ deadlineMs;
16875
+ };
16876
+ function withDeadline(call, deadlineMs, work) {
16877
+ let timer;
16878
+ const deadline = new Promise((_resolve, reject) => {
16879
+ timer = setTimeout(() => reject(new CallDeadlineError(call, deadlineMs)), deadlineMs);
16880
+ });
16881
+ return Promise.race([work, deadline]).finally(() => clearTimeout(timer));
16882
+ }
16883
+
16884
+ // src/kits/chatTransport/chatAdapter.ts
16885
+ var CHAT_UNAVAILABLE_MESSAGE = "chat_unavailable";
16886
+ var ChatUnreachableError = class extends Error {
16887
+ constructor(message = CHAT_UNAVAILABLE_MESSAGE) {
16888
+ super(message);
16889
+ this.name = "ChatUnreachableError";
16890
+ }
16891
+ };
16892
+ function createChatAdapter(transport, { onTurnStarted, deadlineMs = CHAT_CALL_DEADLINE_MS } = {}) {
16893
+ const within = (call, work) => withDeadline(call, deadlineMs, work);
16894
+ const common = {
16895
+ async resolveThread(context) {
16896
+ try {
16897
+ const { thread_id } = await within("resolveThread", transport.resolveThread(context));
16898
+ return { thread_id };
16899
+ } catch {
16900
+ throw new Error(CHAT_UNAVAILABLE_MESSAGE);
16901
+ }
16902
+ },
16903
+ async getThread(threadId) {
16904
+ return { messages: await within("getThread", transport.getMessages(threadId)) };
16905
+ },
16906
+ cancelJob: transport.cancelTurn ? (jobId) => within("cancelJob", transport.cancelTurn(jobId)) : void 0
16907
+ };
16908
+ if (transport.streamTurn) {
16909
+ const { streamTurn } = transport;
16910
+ return {
16911
+ ...common,
16912
+ // The engine streams whenever `streamMessage` is present and calls neither of these for a turn that settles.
16913
+ // A streamed turn that answered a job id would have the engine poll one that does not exist: fail loudly.
16914
+ sendMessage: () => Promise.reject(new Error("A streaming chat starts its turns with streamMessage.")),
16915
+ getJob: () => Promise.reject(new Error("A streaming chat has no turn status to poll.")),
16916
+ async streamMessage(threadId, text, handlers, signal, attachments) {
16917
+ let started = false;
16918
+ const markStarted = () => {
16919
+ if (started) return;
16920
+ started = true;
16921
+ onTurnStarted?.();
16922
+ };
16923
+ const accepting = {
16924
+ onToken: (chunk) => (markStarted(), handlers.onToken(chunk)),
16925
+ onStep: handlers.onStep && ((step) => (markStarted(), handlers.onStep(step))),
16926
+ onThinking: handlers.onThinking && ((chunk) => (markStarted(), handlers.onThinking(chunk)))
16927
+ };
16928
+ let result;
16929
+ try {
16930
+ result = await streamTurn(threadId, text, accepting, signal, attachments);
16931
+ } catch (err) {
16932
+ if (err instanceof ChatUnreachableError) throw new Error(CHAT_UNAVAILABLE_MESSAGE);
16933
+ throw err;
16934
+ }
16935
+ if (result.job_id) throw new Error("A streamed turn must end with its final result, not a job to poll.");
16936
+ markStarted();
16937
+ return result;
16938
+ }
16939
+ };
16940
+ }
16941
+ const { startTurn, getTurn } = transport;
16942
+ return {
16943
+ ...common,
16944
+ // `signal` (the engine's Stop-button plumbing) is deliberately not wired to this call: it only starts a dispatch and
16945
+ // never streams, and aborting it could leave a dispatch started server-side with no job id for the engine to track.
16946
+ // Stop is `cancelJob`.
16947
+ async sendMessage(threadId, text, _signal, attachments) {
16948
+ const { jobId } = await within("sendMessage", startTurn(threadId, text, attachments));
16949
+ onTurnStarted?.();
16950
+ return { dispatched: true, job_id: jobId };
16951
+ },
16952
+ async getJob(jobId) {
16953
+ const status = await within("getJob", getTurn(jobId));
16954
+ return status ?? { status: "failed", error: "turn_not_found" };
16955
+ }
16956
+ };
16957
+ }
16958
+
16959
+ // src/kits/chatTransport/useChatThreads.ts
16960
+ var React88 = __toESM(require("react"), 1);
16961
+ var THREADS_LOAD_FAILED = "Your earlier conversations could not be loaded.";
16962
+ var NEW_THREAD_FAILED = "A new conversation could not be started.";
16963
+ function useChatThreads(transport, { deadlineMs = CHAT_CALL_DEADLINE_MS } = {}) {
16964
+ const toast = useToast();
16965
+ const [threads, setThreads] = React88.useState([]);
16966
+ const [reads, setReads] = React88.useState(0);
16967
+ const transportRef = useLatest(transport);
16968
+ const deadlineRef = useLatest(deadlineMs);
16969
+ const refresh2 = React88.useCallback(() => setReads((n) => n + 1), []);
16970
+ React88.useEffect(() => {
16971
+ const controller = new AbortController();
16972
+ const { signal } = controller;
16973
+ withDeadline("listThreads", deadlineRef.current, transportRef.current.listThreads(signal)).then(
16974
+ (listed) => {
16975
+ if (!signal.aborted) setThreads(listed);
16976
+ },
16977
+ () => {
16978
+ if (!signal.aborted) toast.show(THREADS_LOAD_FAILED, { tone: "error" });
16979
+ }
16980
+ );
16981
+ return () => controller.abort();
16982
+ }, [reads, toast, transportRef, deadlineRef]);
16983
+ const startNewThread = React88.useCallback(
16984
+ (onCreated) => withDeadline("createThread", deadlineRef.current, transportRef.current.createThread()).then(
16985
+ ({ thread_id }) => {
16986
+ onCreated(thread_id);
16987
+ refresh2();
16988
+ },
16989
+ () => toast.show(NEW_THREAD_FAILED, { tone: "error" })
16990
+ ),
16991
+ [deadlineRef, transportRef, refresh2, toast]
16992
+ );
16993
+ return { threads, refresh: refresh2, startNewThread };
16994
+ }
16995
+
16996
+ // src/kits/exports/downloadExport.ts
16997
+ function createExportDownloader({
16998
+ mintUrl,
16999
+ navigate = (url) => window.location.assign(url)
17000
+ }) {
17001
+ return (id) => mintUrl(id).then(
17002
+ (url) => {
17003
+ if (url) navigate(url);
17004
+ },
17005
+ () => {
17006
+ }
17007
+ );
17008
+ }
17009
+
17010
+ // src/kits/exports/useExportJobs.ts
17011
+ var React89 = __toESM(require("react"), 1);
17012
+ var EXPORT_POLL_INTERVAL_MS = 3e3;
17013
+ var EXPORT_IDLE_POLL_INTERVAL_MS = 3e4;
17014
+ function useExportJobs({ list, acknowledge }) {
17015
+ const [rows, setRows] = React89.useState([]);
17016
+ const listRef = useLatest(list);
17017
+ const acknowledgeRef = useLatest(acknowledge);
17018
+ const reload = React89.useCallback(
17019
+ () => listRef.current().then(
17020
+ (fresh) => setRows(fresh),
17021
+ () => {
17022
+ }
17023
+ ),
17024
+ [listRef]
17025
+ );
17026
+ React89.useEffect(() => {
17027
+ void reload();
17028
+ }, [reload]);
17029
+ const anyLive = rows.some(isLiveExport);
17030
+ React89.useEffect(() => {
17031
+ const timer = setInterval(() => void reload(), anyLive ? EXPORT_POLL_INTERVAL_MS : EXPORT_IDLE_POLL_INTERVAL_MS);
17032
+ return () => clearInterval(timer);
17033
+ }, [anyLive, reload]);
17034
+ const refresh2 = React89.useCallback(() => void reload(), [reload]);
17035
+ const ackExport = React89.useCallback(
17036
+ (id) => void acknowledgeRef.current(id).then(reload),
17037
+ [acknowledgeRef, reload]
17038
+ );
17039
+ return { exports: rows, ackExport, refresh: refresh2 };
17040
+ }
17041
+
17042
+ // src/kits/exports/ExportTray.tsx
17043
+ var React90 = __toESM(require("react"), 1);
17044
+ var import_jsx_runtime112 = require("react/jsx-runtime");
17045
+ var EXPORT_KEPT_NOTE = "Kept for 24 hours";
17046
+ var EXPORT_FAILED_FALLBACK = "Unknown error.";
17047
+ function exportToJob(job, onDownload) {
17048
+ const base = { id: job.id, title: job.title, note: job.note };
17049
+ if (job.status === "SUCCEEDED") {
17050
+ return {
17051
+ ...base,
17052
+ status: "done",
17053
+ action: { label: "Download", icon: "download-simple", onClick: () => onDownload(job.id) },
17054
+ doneNote: EXPORT_KEPT_NOTE
17055
+ };
17056
+ }
17057
+ if (job.status === "FAILED") {
17058
+ return { ...base, status: "failed", failureReason: job.failureMessage ?? EXPORT_FAILED_FALLBACK };
17059
+ }
17060
+ return { ...base, status: "active" };
17061
+ }
17062
+ function ExportTray({ exports: exports2, onDownload, onDismiss }) {
17063
+ const jobs2 = React90.useMemo(() => exports2.map((job) => exportToJob(job, onDownload)), [exports2, onDownload]);
17064
+ return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(JobTray, { jobs: jobs2, onDismiss });
17065
+ }
16690
17066
  // Annotate the CommonJS export names for ESM import in node:
16691
17067
  0 && (module.exports = {
16692
17068
  AccountMenu,
@@ -16707,11 +17083,16 @@ function useDocumentTitle(routeTitle, appName) {
16707
17083
  Button,
16708
17084
  CHANNELS,
16709
17085
  CHANNEL_WEIGHTS,
17086
+ CHAT_CALL_DEADLINE_MS,
16710
17087
  CHAT_UNAVAILABLE,
17088
+ CHAT_UNAVAILABLE_MESSAGE,
16711
17089
  COPIED_FEEDBACK_MS,
16712
17090
  CORNER_STACK_INSET_PROPERTY,
16713
17091
  CORNER_STACK_OFFSET_PROPERTY,
17092
+ CSV_FAILED_FALLBACK,
17093
+ CSV_KEPT_NOTE,
16714
17094
  Calendar,
17095
+ CallDeadlineError,
16715
17096
  Card,
16716
17097
  CardGrid,
16717
17098
  CardRow,
@@ -16724,6 +17105,7 @@ function useDocumentTitle(routeTitle, appName) {
16724
17105
  ChatSessionBar,
16725
17106
  ChatTranscript,
16726
17107
  ChatTurn,
17108
+ ChatUnreachableError,
16727
17109
  Checkbox,
16728
17110
  Citations,
16729
17111
  Clamp,
@@ -16736,6 +17118,7 @@ function useDocumentTitle(routeTitle, appName) {
16736
17118
  CsiBadge,
16737
17119
  CsiHero,
16738
17120
  CsiMeter,
17121
+ CsvCard,
16739
17122
  DEFAULT_PREFS,
16740
17123
  DEFAULT_STORAGE_KEY,
16741
17124
  DEFAULT_TOAST_DURATION_MS,
@@ -16748,9 +17131,14 @@ function useDocumentTitle(routeTitle, appName) {
16748
17131
  Dropzone,
16749
17132
  DropzoneKit,
16750
17133
  ENTITY_ROW_METRIC_WIDTH,
17134
+ EXPORT_FAILED_FALLBACK,
17135
+ EXPORT_IDLE_POLL_INTERVAL_MS,
17136
+ EXPORT_KEPT_NOTE,
17137
+ EXPORT_POLL_INTERVAL_MS,
16751
17138
  EmptyState,
16752
17139
  EntityRow,
16753
17140
  EntityRowMetrics,
17141
+ ExportTray,
16754
17142
  FILE_VIEWER_CSV_ROW_LIMIT,
16755
17143
  FILE_VIEWER_TEXT_LIMIT,
16756
17144
  FactList,
@@ -16793,6 +17181,7 @@ function useDocumentTitle(routeTitle, appName) {
16793
17181
  Modal,
16794
17182
  ModeSwitch,
16795
17183
  ModelControls,
17184
+ NEW_THREAD_FAILED,
16796
17185
  NumberInput,
16797
17186
  OVERLAY_BREAKPOINT,
16798
17187
  OVERLAY_CEILING,
@@ -16806,7 +17195,9 @@ function useDocumentTitle(routeTitle, appName) {
16806
17195
  PreferenceMeter,
16807
17196
  ProfilePage,
16808
17197
  ProgressBar,
17198
+ QUERY_EMPTY_MESSAGE,
16809
17199
  QueryKit,
17200
+ QueryResultCard,
16810
17201
  QuotaRow,
16811
17202
  ROOT_STEP,
16812
17203
  Radio,
@@ -16840,6 +17231,7 @@ function useDocumentTitle(routeTitle, appName) {
16840
17231
  StepList,
16841
17232
  SurroundSound,
16842
17233
  Switch,
17234
+ THREADS_LOAD_FAILED,
16843
17235
  Tabs,
16844
17236
  Tag,
16845
17237
  TestModeBar,
@@ -16869,9 +17261,13 @@ function useDocumentTitle(routeTitle, appName) {
16869
17261
  computeNeedMore,
16870
17262
  computeVirtualWindow,
16871
17263
  copyToClipboard,
17264
+ createChatAdapter,
17265
+ createExportDownloader,
16872
17266
  createLocalStorageAppearanceStore,
16873
17267
  createVersionStore,
16874
17268
  eqFilter,
17269
+ exportStateOf,
17270
+ exportToJob,
16875
17271
  extensionOf,
16876
17272
  extractClipboardFiles,
16877
17273
  filterFiles,
@@ -16890,7 +17286,9 @@ function useDocumentTitle(routeTitle, appName) {
16890
17286
  importanceLevel,
16891
17287
  importanceTokens,
16892
17288
  installFlytedeskFavicon,
17289
+ isExpiredExport,
16893
17290
  isImage,
17291
+ isLiveExport,
16894
17292
  isSystemMessage,
16895
17293
  isUsStateCode,
16896
17294
  isWithinLayerTree,
@@ -16915,9 +17313,12 @@ function useDocumentTitle(routeTitle, appName) {
16915
17313
  useAppearancePrefs,
16916
17314
  useAppearanceStore,
16917
17315
  useChatEngine,
17316
+ useChatThreads,
16918
17317
  useCopyToClipboard,
16919
17318
  useCornerStackSlot,
16920
17319
  useDocumentTitle,
17320
+ useExpiryClock,
17321
+ useExportJobs,
16921
17322
  useFeatureStatus,
16922
17323
  useLayerZIndex,
16923
17324
  useOverlayLayout,
@@ -16928,6 +17329,7 @@ function useDocumentTitle(routeTitle, appName) {
16928
17329
  useServerTable,
16929
17330
  useSessionContext,
16930
17331
  useSheetOpenMark,
17332
+ useShownExport,
16931
17333
  useStackedLayer,
16932
17334
  useStagedFiles,
16933
17335
  useToast,
@@ -16935,6 +17337,7 @@ function useDocumentTitle(routeTitle, appName) {
16935
17337
  validateFilterValue,
16936
17338
  visibleMessages,
16937
17339
  watchAppearance,
17340
+ withDeadline,
16938
17341
  writeQueryToUrl
16939
17342
  });
16940
17343
  //# sourceMappingURL=index.cjs.map