@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.js CHANGED
@@ -14230,9 +14230,155 @@ function AgentChatPanel({
14230
14230
  );
14231
14231
  }
14232
14232
 
14233
- // src/components/files/FileViewer.tsx
14233
+ // src/components/chat/QueryResultCard.tsx
14234
14234
  import * as React81 from "react";
14235
14235
  import { jsx as jsx107, jsxs as jsxs94 } from "react/jsx-runtime";
14236
+ var STATUS2 = {
14237
+ queued: { label: "Queued", tone: "neutral" },
14238
+ running: { label: "Running", tone: "info" },
14239
+ done: { label: "Done", tone: "success" },
14240
+ failed: { label: "Failed", tone: "danger" },
14241
+ canceled: { label: "Stopped", tone: "neutral" }
14242
+ };
14243
+ var QUERY_EMPTY_MESSAGE = "No rows to show.";
14244
+ function useElapsed(status, startedAt) {
14245
+ const [now, setNow] = React81.useState(() => Date.now());
14246
+ const running = status === "running" && startedAt != null;
14247
+ React81.useEffect(() => {
14248
+ if (!running) return;
14249
+ const tick = setInterval(() => setNow(Date.now()), 1e3);
14250
+ return () => clearInterval(tick);
14251
+ }, [running]);
14252
+ if (!running) return null;
14253
+ return formatDuration(Math.max(0, now - Date.parse(startedAt)));
14254
+ }
14255
+ function QueryResultCard({
14256
+ title,
14257
+ status,
14258
+ startedAt,
14259
+ failureMessage,
14260
+ facts = [],
14261
+ columns,
14262
+ rows = [],
14263
+ rowKey = "id",
14264
+ actions
14265
+ }) {
14266
+ const { label, tone } = STATUS2[status];
14267
+ const elapsed = useElapsed(status, startedAt);
14268
+ const empty = status === "done" && facts.length === 0 && rows.length === 0;
14269
+ return /* @__PURE__ */ jsxs94("div", { className: "fd-stack fd-gap-sm", role: "group", "aria-label": `Query: ${title}`, children: [
14270
+ /* @__PURE__ */ jsxs94("div", { className: "fd-row fd-wrap fd-justify-between fd-align-center fd-gap-sm", children: [
14271
+ /* @__PURE__ */ jsx107("span", { className: "fd-body-sm", style: { overflowWrap: "anywhere", minWidth: 0 }, children: title }),
14272
+ /* @__PURE__ */ jsx107(Badge, { tone, dot: status === "running", children: elapsed === null ? label : `${label} \xB7 ${elapsed}` })
14273
+ ] }),
14274
+ failureMessage ? /* @__PURE__ */ jsx107("p", { className: "fd-body-sm fd-danger", children: failureMessage }) : null,
14275
+ facts.length === 0 ? null : /* @__PURE__ */ jsx107(FactList, { facts }),
14276
+ rows.length === 0 || !columns ? null : /* @__PURE__ */ jsx107(DataTable, { compact: true, columns, rows, rowKey }),
14277
+ empty ? /* @__PURE__ */ jsx107("p", { className: "fd-body-sm fd-muted", children: QUERY_EMPTY_MESSAGE }) : null,
14278
+ actions ? /* @__PURE__ */ jsx107("div", { className: "fd-row fd-wrap fd-gap-sm", children: actions }) : null
14279
+ ] });
14280
+ }
14281
+
14282
+ // src/components/chat/CsvCard.tsx
14283
+ import * as React83 from "react";
14284
+
14285
+ // src/kits/exports/exportState.ts
14286
+ import * as React82 from "react";
14287
+
14288
+ // src/kits/exports/exportJob.ts
14289
+ function isLiveExport(job) {
14290
+ return job.status === "PENDING" || job.status === "RUNNING";
14291
+ }
14292
+ function isExpiredExport(job, now) {
14293
+ return job.expiresAt !== null && Date.parse(job.expiresAt) <= now;
14294
+ }
14295
+
14296
+ // src/kits/exports/exportState.ts
14297
+ function exportStateOf(job, now) {
14298
+ switch (job.status) {
14299
+ case "PENDING":
14300
+ return "queued";
14301
+ case "RUNNING":
14302
+ return "preparing";
14303
+ case "FAILED":
14304
+ return "failed";
14305
+ case "SUCCEEDED":
14306
+ return isExpiredExport(job, now) ? "expired" : "ready";
14307
+ }
14308
+ }
14309
+ function useExpiryClock(job) {
14310
+ const [now, setNow] = React82.useState(() => Date.now());
14311
+ const { status, expiresAt } = job;
14312
+ React82.useEffect(() => {
14313
+ if (status !== "SUCCEEDED" || expiresAt === null) return;
14314
+ const wait = Date.parse(expiresAt) - Date.now();
14315
+ if (wait <= 0) return;
14316
+ const timer = setTimeout(() => setNow(Date.now()), wait);
14317
+ return () => clearTimeout(timer);
14318
+ }, [status, expiresAt]);
14319
+ return now;
14320
+ }
14321
+ function useLastListed(listed) {
14322
+ const [last, setLast] = React82.useState(listed);
14323
+ if (listed !== void 0 && listed !== last) setLast(listed);
14324
+ return listed ?? last;
14325
+ }
14326
+ function useShownExport(held, exports, refresh2) {
14327
+ const lastListed = useLastListed(exports.find((candidate) => candidate.id === held.id));
14328
+ const unlisted = isLiveExport(held) && lastListed === void 0;
14329
+ React82.useEffect(() => {
14330
+ if (unlisted) refresh2();
14331
+ }, [unlisted, refresh2]);
14332
+ return isLiveExport(held) && lastListed !== void 0 ? lastListed : held;
14333
+ }
14334
+
14335
+ // src/components/chat/CsvCard.tsx
14336
+ import { jsx as jsx108, jsxs as jsxs95 } from "react/jsx-runtime";
14337
+ var STATE = {
14338
+ queued: { label: "Queued", tone: "neutral" },
14339
+ preparing: { label: "Preparing", tone: "info" },
14340
+ ready: { label: "Ready", tone: "success" },
14341
+ expired: { label: "Expired", tone: "neutral" },
14342
+ failed: { label: "Failed", tone: "danger" }
14343
+ };
14344
+ var CSV_FAILED_FALLBACK = "The CSV could not be made.";
14345
+ var CSV_KEPT_NOTE = "Kept 24 hours";
14346
+ function CsvCard({ job, onDownload }) {
14347
+ const [downloading, setDownloading] = React83.useState(false);
14348
+ const now = useExpiryClock(job);
14349
+ const state = exportStateOf(job, now);
14350
+ const { label, tone } = STATE[state];
14351
+ const facts = job.rowCount === null ? [] : [{ label: "Rows", value: job.rowCount.toLocaleString("en-US") }];
14352
+ function download() {
14353
+ setDownloading(true);
14354
+ void onDownload(job.id).finally(() => setDownloading(false));
14355
+ }
14356
+ return /* @__PURE__ */ jsxs95("div", { className: "fd-stack fd-gap-sm", role: "group", "aria-label": `CSV: ${job.fileName}`, children: [
14357
+ /* @__PURE__ */ jsxs95("div", { className: "fd-row fd-wrap fd-justify-between fd-align-center fd-gap-sm", children: [
14358
+ /* @__PURE__ */ jsx108("span", { className: "fd-body-sm fd-mono", style: { overflowWrap: "anywhere", minWidth: 0 }, children: job.fileName }),
14359
+ /* @__PURE__ */ jsx108(Badge, { tone, dot: state === "preparing", children: label })
14360
+ ] }),
14361
+ state === "failed" ? /* @__PURE__ */ jsx108("p", { className: "fd-body-sm fd-danger", children: job.failureMessage ?? CSV_FAILED_FALLBACK }) : null,
14362
+ facts.length === 0 ? null : /* @__PURE__ */ jsx108(FactList, { facts }),
14363
+ state === "ready" ? /* @__PURE__ */ jsx108("p", { className: "fd-body-sm fd-muted", children: CSV_KEPT_NOTE }) : null,
14364
+ /* @__PURE__ */ jsx108("div", { className: "fd-row fd-wrap fd-gap-sm", children: /* @__PURE__ */ jsx108(
14365
+ Button,
14366
+ {
14367
+ size: "sm",
14368
+ variant: "secondary",
14369
+ icon: "download-simple",
14370
+ disabled: state !== "ready",
14371
+ loading: downloading,
14372
+ onClick: download,
14373
+ children: "Download"
14374
+ }
14375
+ ) })
14376
+ ] });
14377
+ }
14378
+
14379
+ // src/components/files/FileViewer.tsx
14380
+ import * as React84 from "react";
14381
+ import { jsx as jsx109, jsxs as jsxs96 } from "react/jsx-runtime";
14236
14382
  function previewKindOf(file) {
14237
14383
  const mime = (file.mime || "").toLowerCase();
14238
14384
  const ext = extensionOf(file.name || "");
@@ -14288,13 +14434,13 @@ function parseDelimited(text, delimiter) {
14288
14434
  return rows;
14289
14435
  }
14290
14436
  function usePreview(file, kind, resolveUrl) {
14291
- const [state, setState] = React81.useState({ status: "loading" });
14292
- const [attempt, setAttempt] = React81.useState(0);
14293
- const resolveRef = React81.useRef(resolveUrl);
14294
- React81.useEffect(() => {
14437
+ const [state, setState] = React84.useState({ status: "loading" });
14438
+ const [attempt, setAttempt] = React84.useState(0);
14439
+ const resolveRef = React84.useRef(resolveUrl);
14440
+ React84.useEffect(() => {
14295
14441
  resolveRef.current = resolveUrl;
14296
14442
  }, [resolveUrl]);
14297
- React81.useEffect(() => {
14443
+ React84.useEffect(() => {
14298
14444
  if (kind === "none") {
14299
14445
  setState({ status: "ready" });
14300
14446
  return;
@@ -14324,19 +14470,19 @@ function usePreview(file, kind, resolveUrl) {
14324
14470
  if (ac) ac.abort();
14325
14471
  };
14326
14472
  }, [file.id, kind, attempt]);
14327
- return { ...state, retry: React81.useCallback(() => setAttempt((a) => a + 1), []) };
14473
+ return { ...state, retry: React84.useCallback(() => setAttempt((a) => a + 1), []) };
14328
14474
  }
14329
14475
  function PreviewBody({ file, kind, state }) {
14330
- if (kind === "image") return /* @__PURE__ */ jsx107("img", { className: "fd-fv-image", src: state.url, alt: file.name || "Preview" });
14331
- if (kind === "pdf") return /* @__PURE__ */ jsx107("iframe", { className: "fd-fv-pdf", src: state.url, title: file.name || "PDF preview" });
14332
- if (kind === "markdown") return /* @__PURE__ */ jsx107(Markdown, { className: "fd-fv-markdown", source: state.text || "" });
14476
+ if (kind === "image") return /* @__PURE__ */ jsx109("img", { className: "fd-fv-image", src: state.url, alt: file.name || "Preview" });
14477
+ if (kind === "pdf") return /* @__PURE__ */ jsx109("iframe", { className: "fd-fv-pdf", src: state.url, title: file.name || "PDF preview" });
14478
+ if (kind === "markdown") return /* @__PURE__ */ jsx109(Markdown, { className: "fd-fv-markdown", source: state.text || "" });
14333
14479
  if (kind === "json") {
14334
14480
  let pretty = state.text || "";
14335
14481
  try {
14336
14482
  pretty = JSON.stringify(JSON.parse(pretty), null, 2);
14337
14483
  } catch {
14338
14484
  }
14339
- return /* @__PURE__ */ jsx107(CodeBlock, { code: pretty, language: "json" });
14485
+ return /* @__PURE__ */ jsx109(CodeBlock, { code: pretty, language: "json" });
14340
14486
  }
14341
14487
  if (kind === "csv") {
14342
14488
  const tsv = extensionOf(file.name || "") === "tsv" || (file.mime || "").toLowerCase().includes("tab-separated");
@@ -14344,12 +14490,12 @@ function PreviewBody({ file, kind, state }) {
14344
14490
  const head = rows[0] || [];
14345
14491
  const dataRows = rows.slice(1);
14346
14492
  const shown = dataRows.slice(0, FILE_VIEWER_CSV_ROW_LIMIT);
14347
- return /* @__PURE__ */ jsxs94("div", { className: "fd-fv-csv", children: [
14348
- /* @__PURE__ */ jsxs94("table", { className: "fd-fv-csv-table", children: [
14349
- /* @__PURE__ */ jsx107("thead", { children: /* @__PURE__ */ jsx107("tr", { children: head.map((c, i) => /* @__PURE__ */ jsx107("th", { children: c }, i)) }) }),
14350
- /* @__PURE__ */ jsx107("tbody", { children: shown.map((r, ri) => /* @__PURE__ */ jsx107("tr", { children: head.map((_, ci) => /* @__PURE__ */ jsx107("td", { children: r[ci] ?? "" }, ci)) }, ri)) })
14493
+ return /* @__PURE__ */ jsxs96("div", { className: "fd-fv-csv", children: [
14494
+ /* @__PURE__ */ jsxs96("table", { className: "fd-fv-csv-table", children: [
14495
+ /* @__PURE__ */ jsx109("thead", { children: /* @__PURE__ */ jsx109("tr", { children: head.map((c, i) => /* @__PURE__ */ jsx109("th", { children: c }, i)) }) }),
14496
+ /* @__PURE__ */ jsx109("tbody", { children: shown.map((r, ri) => /* @__PURE__ */ jsx109("tr", { children: head.map((_, ci) => /* @__PURE__ */ jsx109("td", { children: r[ci] ?? "" }, ci)) }, ri)) })
14351
14497
  ] }),
14352
- dataRows.length > FILE_VIEWER_CSV_ROW_LIMIT ? /* @__PURE__ */ jsxs94("p", { className: "fd-fv-csv-note fd-body-sm fd-muted", children: [
14498
+ dataRows.length > FILE_VIEWER_CSV_ROW_LIMIT ? /* @__PURE__ */ jsxs96("p", { className: "fd-fv-csv-note fd-body-sm fd-muted", children: [
14353
14499
  "Showing the first ",
14354
14500
  FILE_VIEWER_CSV_ROW_LIMIT.toLocaleString(),
14355
14501
  " of ",
@@ -14358,24 +14504,24 @@ function PreviewBody({ file, kind, state }) {
14358
14504
  ] }) : null
14359
14505
  ] });
14360
14506
  }
14361
- if (kind === "text") return /* @__PURE__ */ jsx107(CodeBlock, { code: state.text || "", language: extensionOf(file.name || "") || void 0 });
14362
- return /* @__PURE__ */ jsxs94("div", { className: "fd-fv-fallback", children: [
14363
- /* @__PURE__ */ jsx107("span", { className: "fd-fv-fallback-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx107("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
14364
- /* @__PURE__ */ jsx107("span", { className: "fd-fv-fallback-title", children: "No preview available" }),
14365
- /* @__PURE__ */ jsxs94("span", { className: "fd-fv-fallback-meta", children: [
14507
+ if (kind === "text") return /* @__PURE__ */ jsx109(CodeBlock, { code: state.text || "", language: extensionOf(file.name || "") || void 0 });
14508
+ return /* @__PURE__ */ jsxs96("div", { className: "fd-fv-fallback", children: [
14509
+ /* @__PURE__ */ jsx109("span", { className: "fd-fv-fallback-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx109("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
14510
+ /* @__PURE__ */ jsx109("span", { className: "fd-fv-fallback-title", children: "No preview available" }),
14511
+ /* @__PURE__ */ jsxs96("span", { className: "fd-fv-fallback-meta", children: [
14366
14512
  file.mime || "Unknown type",
14367
14513
  file.size ? " \xB7 " + formatBytes(file.size) : ""
14368
14514
  ] })
14369
14515
  ] });
14370
14516
  }
14371
14517
  function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", onClose, actions, className = "" }) {
14372
- const kind = React81.useMemo(() => previewKindOf(file), [file]);
14518
+ const kind = React84.useMemo(() => previewKindOf(file), [file]);
14373
14519
  const preview = usePreview(file, kind, resolveUrl);
14374
- const [tab, setTab] = React81.useState("preview");
14375
- const [downloading, setDownloading] = React81.useState(false);
14376
- const [downloadError, setDownloadError] = React81.useState(null);
14520
+ const [tab, setTab] = React84.useState("preview");
14521
+ const [downloading, setDownloading] = React84.useState(false);
14522
+ const [downloadError, setDownloadError] = React84.useState(null);
14377
14523
  const hasSide = sidePanel != null;
14378
- React81.useEffect(() => {
14524
+ React84.useEffect(() => {
14379
14525
  setTab("preview");
14380
14526
  }, [file.id]);
14381
14527
  const download = () => {
@@ -14391,29 +14537,29 @@ function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", o
14391
14537
  a.remove();
14392
14538
  }).catch((err) => setDownloadError(err && err.message || "Download failed.")).finally(() => setDownloading(false));
14393
14539
  };
14394
- return /* @__PURE__ */ jsxs94(
14540
+ return /* @__PURE__ */ jsxs96(
14395
14541
  "section",
14396
14542
  {
14397
14543
  className: ["fd-fv", hasSide && tab === "side" ? "is-tab-side" : "is-tab-preview", className].filter(Boolean).join(" "),
14398
14544
  "aria-label": file.name || "File",
14399
14545
  children: [
14400
- /* @__PURE__ */ jsxs94("header", { className: "fd-fv-head", children: [
14401
- /* @__PURE__ */ jsx107("span", { className: "fd-fv-head-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx107("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
14402
- /* @__PURE__ */ jsxs94("span", { className: "fd-fv-head-titles", children: [
14403
- /* @__PURE__ */ jsx107("span", { className: "fd-fv-head-title", title: file.name, children: file.name }),
14404
- /* @__PURE__ */ jsxs94("span", { className: "fd-fv-head-meta", children: [
14546
+ /* @__PURE__ */ jsxs96("header", { className: "fd-fv-head", children: [
14547
+ /* @__PURE__ */ jsx109("span", { className: "fd-fv-head-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx109("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
14548
+ /* @__PURE__ */ jsxs96("span", { className: "fd-fv-head-titles", children: [
14549
+ /* @__PURE__ */ jsx109("span", { className: "fd-fv-head-title", title: file.name, children: file.name }),
14550
+ /* @__PURE__ */ jsxs96("span", { className: "fd-fv-head-meta", children: [
14405
14551
  file.mime || "Unknown type",
14406
14552
  file.size ? " \xB7 " + formatBytes(file.size) : ""
14407
14553
  ] })
14408
14554
  ] }),
14409
- /* @__PURE__ */ jsxs94("span", { className: "fd-fv-head-actions", children: [
14555
+ /* @__PURE__ */ jsxs96("span", { className: "fd-fv-head-actions", children: [
14410
14556
  actions,
14411
- /* @__PURE__ */ jsx107(Button, { variant: "secondary", size: "sm", icon: "download-simple", loading: downloading, onClick: download, children: "Download" }),
14412
- onClose ? /* @__PURE__ */ jsx107(IconButton, { icon: "x", label: "Close", onClick: onClose }) : null
14557
+ /* @__PURE__ */ jsx109(Button, { variant: "secondary", size: "sm", icon: "download-simple", loading: downloading, onClick: download, children: "Download" }),
14558
+ onClose ? /* @__PURE__ */ jsx109(IconButton, { icon: "x", label: "Close", onClick: onClose }) : null
14413
14559
  ] })
14414
14560
  ] }),
14415
- downloadError ? /* @__PURE__ */ jsx107("div", { className: "fd-fv-download-error", role: "alert", children: downloadError }) : null,
14416
- hasSide ? /* @__PURE__ */ jsx107(
14561
+ downloadError ? /* @__PURE__ */ jsx109("div", { className: "fd-fv-download-error", role: "alert", children: downloadError }) : null,
14562
+ hasSide ? /* @__PURE__ */ jsx109(
14417
14563
  Tabs,
14418
14564
  {
14419
14565
  className: "fd-fv-tabs",
@@ -14422,19 +14568,19 @@ function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", o
14422
14568
  onChange: (v) => setTab(v)
14423
14569
  }
14424
14570
  ) : null,
14425
- /* @__PURE__ */ jsxs94("div", { className: "fd-fv-body", children: [
14426
- /* @__PURE__ */ jsx107("div", { className: "fd-fv-preview", role: "region", "aria-label": "Preview of " + (file.name || "file"), children: /* @__PURE__ */ jsx107(
14571
+ /* @__PURE__ */ jsxs96("div", { className: "fd-fv-body", children: [
14572
+ /* @__PURE__ */ jsx109("div", { className: "fd-fv-preview", role: "region", "aria-label": "Preview of " + (file.name || "file"), children: /* @__PURE__ */ jsx109(
14427
14573
  LoadingRegion,
14428
14574
  {
14429
14575
  state: preview.status === "loading" ? "loading" : preview.status === "error" ? "error" : "ready",
14430
14576
  error: preview.error,
14431
14577
  label: "Loading preview of " + (file.name || "file"),
14432
14578
  onRetry: preview.status === "error" ? preview.retry : void 0,
14433
- skeleton: /* @__PURE__ */ jsx107(Skeleton, { shape: "card", h: 220 }),
14434
- children: /* @__PURE__ */ jsx107(PreviewBody, { file, kind, state: preview })
14579
+ skeleton: /* @__PURE__ */ jsx109(Skeleton, { shape: "card", h: 220 }),
14580
+ children: /* @__PURE__ */ jsx109(PreviewBody, { file, kind, state: preview })
14435
14581
  }
14436
14582
  ) }),
14437
- hasSide ? /* @__PURE__ */ jsx107("div", { className: "fd-fv-side", role: "region", "aria-label": sidePanelLabel, children: sidePanel }) : null
14583
+ hasSide ? /* @__PURE__ */ jsx109("div", { className: "fd-fv-side", role: "region", "aria-label": sidePanelLabel, children: sidePanel }) : null
14438
14584
  ] })
14439
14585
  ]
14440
14586
  }
@@ -14442,8 +14588,8 @@ function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", o
14442
14588
  }
14443
14589
 
14444
14590
  // src/components/files/FileBrowser.tsx
14445
- import * as React82 from "react";
14446
- import { Fragment as Fragment32, jsx as jsx108, jsxs as jsxs95 } from "react/jsx-runtime";
14591
+ import * as React85 from "react";
14592
+ import { Fragment as Fragment32, jsx as jsx110, jsxs as jsxs97 } from "react/jsx-runtime";
14447
14593
  function childrenOf(folders, parentId) {
14448
14594
  return folders.filter((f) => f.parentId === parentId).sort((a, b) => a.name.localeCompare(b.name));
14449
14595
  }
@@ -14515,8 +14661,8 @@ function FolderPickerMenu({
14515
14661
  }) {
14516
14662
  const panel = useInlinePanel();
14517
14663
  const { open: open2, setOpen, ref } = panel;
14518
- return /* @__PURE__ */ jsxs95("span", { className: "fd-fb-menu-anchor", ref, children: [
14519
- /* @__PURE__ */ jsx108(
14664
+ return /* @__PURE__ */ jsxs97("span", { className: "fd-fb-menu-anchor", ref, children: [
14665
+ /* @__PURE__ */ jsx110(
14520
14666
  IconButton,
14521
14667
  {
14522
14668
  icon: "arrows-out-cardinal",
@@ -14528,9 +14674,9 @@ function FolderPickerMenu({
14528
14674
  onClick: () => setOpen((v) => !v)
14529
14675
  }
14530
14676
  ),
14531
- /* @__PURE__ */ jsx108(InlinePanelSurface, { panel, align: "right", offset: 4, width: 220, maxHeight: 280, role: "menu", label, children: /* @__PURE__ */ jsxs95("div", { className: "fd-fb-menu", children: [
14532
- /* @__PURE__ */ jsx108("span", { className: "fd-overline fd-muted fd-fb-menu-title", children: "Move to\u2026" }),
14533
- destinations.map((d) => /* @__PURE__ */ jsxs95(
14677
+ /* @__PURE__ */ jsx110(InlinePanelSurface, { panel, align: "right", offset: 4, width: 220, maxHeight: 280, role: "menu", label, children: /* @__PURE__ */ jsxs97("div", { className: "fd-fb-menu", children: [
14678
+ /* @__PURE__ */ jsx110("span", { className: "fd-overline fd-muted fd-fb-menu-title", children: "Move to\u2026" }),
14679
+ destinations.map((d) => /* @__PURE__ */ jsxs97(
14534
14680
  "button",
14535
14681
  {
14536
14682
  type: "button",
@@ -14542,7 +14688,7 @@ function FolderPickerMenu({
14542
14688
  setOpen(false);
14543
14689
  },
14544
14690
  children: [
14545
- /* @__PURE__ */ jsx108("i", { className: "ph ph-" + (d.id == null ? "house-simple" : "folder-simple"), "aria-hidden": "true" }),
14691
+ /* @__PURE__ */ jsx110("i", { className: "ph ph-" + (d.id == null ? "house-simple" : "folder-simple"), "aria-hidden": "true" }),
14546
14692
  d.name
14547
14693
  ]
14548
14694
  },
@@ -14552,8 +14698,8 @@ function FolderPickerMenu({
14552
14698
  ] });
14553
14699
  }
14554
14700
  function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropPayload, actions, className = "" }) {
14555
- const [over, setOver] = React82.useState(false);
14556
- const dragCounter = React82.useRef(0);
14701
+ const [over, setOver] = React85.useState(false);
14702
+ const dragCounter = React85.useRef(0);
14557
14703
  const dropHandlers = isDropTarget ? {
14558
14704
  onDragEnter: (e) => {
14559
14705
  if (!hasInternalPayload(e)) return;
@@ -14578,8 +14724,8 @@ function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropP
14578
14724
  if (payload && onDropPayload) onDropPayload(payload);
14579
14725
  }
14580
14726
  } : {};
14581
- return /* @__PURE__ */ jsxs95("div", { className: ["fd-fb-row", over ? "is-drop-target" : "", className].filter(Boolean).join(" "), ...dropHandlers, children: [
14582
- /* @__PURE__ */ jsxs95(
14727
+ return /* @__PURE__ */ jsxs97("div", { className: ["fd-fb-row", over ? "is-drop-target" : "", className].filter(Boolean).join(" "), ...dropHandlers, children: [
14728
+ /* @__PURE__ */ jsxs97(
14583
14729
  "button",
14584
14730
  {
14585
14731
  type: "button",
@@ -14588,26 +14734,26 @@ function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropP
14588
14734
  draggable: !!draggableId,
14589
14735
  onDragStart: draggableId ? (e) => writeDragPayload(e, draggableId) : void 0,
14590
14736
  children: [
14591
- /* @__PURE__ */ jsx108("span", { className: "fd-fb-row-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx108("i", { className: "ph ph-" + icon }) }),
14592
- /* @__PURE__ */ jsxs95("span", { className: "fd-fb-row-text", children: [
14593
- /* @__PURE__ */ jsx108("span", { className: "fd-fb-row-name", title: name, children: name }),
14594
- meta ? /* @__PURE__ */ jsx108("span", { className: "fd-fb-row-meta", children: meta }) : null
14737
+ /* @__PURE__ */ jsx110("span", { className: "fd-fb-row-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx110("i", { className: "ph ph-" + icon }) }),
14738
+ /* @__PURE__ */ jsxs97("span", { className: "fd-fb-row-text", children: [
14739
+ /* @__PURE__ */ jsx110("span", { className: "fd-fb-row-name", title: name, children: name }),
14740
+ meta ? /* @__PURE__ */ jsx110("span", { className: "fd-fb-row-meta", children: meta }) : null
14595
14741
  ] })
14596
14742
  ]
14597
14743
  }
14598
14744
  ),
14599
- actions ? /* @__PURE__ */ jsx108("span", { className: "fd-fb-row-actions", children: actions }) : null
14745
+ actions ? /* @__PURE__ */ jsx110("span", { className: "fd-fb-row-actions", children: actions }) : null
14600
14746
  ] });
14601
14747
  }
14602
14748
  function TreeNode({ folder, depth, folders, currentFolderId, onNavigate, onMoveInto, canMove }) {
14603
14749
  const kids = childrenOf(folders, folder.id);
14604
- const [expanded, setExpanded] = React82.useState(() => currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId));
14605
- React82.useEffect(() => {
14750
+ const [expanded, setExpanded] = React85.useState(() => currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId));
14751
+ React85.useEffect(() => {
14606
14752
  if (currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId)) setExpanded(true);
14607
14753
  }, [currentFolderId, folder.id, folders]);
14608
14754
  const isCurrent = folder.id === currentFolderId;
14609
- return /* @__PURE__ */ jsxs95("div", { className: "fd-fb-tree-node", children: [
14610
- /* @__PURE__ */ jsx108(
14755
+ return /* @__PURE__ */ jsxs97("div", { className: "fd-fb-tree-node", children: [
14756
+ /* @__PURE__ */ jsx110(
14611
14757
  RowShell,
14612
14758
  {
14613
14759
  icon: folder.id === currentFolderId ? "folder-open" : "folder-simple",
@@ -14617,7 +14763,7 @@ function TreeNode({ folder, depth, folders, currentFolderId, onNavigate, onMoveI
14617
14763
  isDropTarget: canMove,
14618
14764
  onDropPayload: (payload) => onMoveInto(payload, folder.id),
14619
14765
  className: ["fd-fb-tree-row", isCurrent ? "is-current" : ""].filter(Boolean).join(" "),
14620
- actions: kids.length ? /* @__PURE__ */ jsx108(
14766
+ actions: kids.length ? /* @__PURE__ */ jsx110(
14621
14767
  IconButton,
14622
14768
  {
14623
14769
  icon: expanded ? "caret-down" : "caret-right",
@@ -14629,7 +14775,7 @@ function TreeNode({ folder, depth, folders, currentFolderId, onNavigate, onMoveI
14629
14775
  ) : void 0
14630
14776
  }
14631
14777
  ),
14632
- expanded && kids.length ? /* @__PURE__ */ jsx108("div", { className: "fd-fb-tree-children", style: { paddingLeft: 14 }, children: kids.map((k) => /* @__PURE__ */ jsx108(
14778
+ expanded && kids.length ? /* @__PURE__ */ jsx110("div", { className: "fd-fb-tree-children", style: { paddingLeft: 14 }, children: kids.map((k) => /* @__PURE__ */ jsx110(
14633
14779
  TreeNode,
14634
14780
  {
14635
14781
  folder: k,
@@ -14668,15 +14814,15 @@ function FileBrowser({
14668
14814
  const canUpload = perm.canUpload !== false && !!onUpload;
14669
14815
  const canRemoveFile = perm.canRemoveFile !== false && !!onRemoveFile;
14670
14816
  const canDeleteFolder = perm.canDeleteFolder !== false && !!onDeleteFolder;
14671
- const [createOpen, setCreateOpen] = React82.useState(false);
14672
- const [createName, setCreateName] = React82.useState("");
14673
- const [renameTarget, setRenameTarget] = React82.useState(null);
14674
- const [renameValue, setRenameValue] = React82.useState("");
14675
- const [deleteTarget, setDeleteTarget] = React82.useState(null);
14676
- const uploadInputRef = React82.useRef(null);
14677
- const crumbFolders = React82.useMemo(() => ancestorsOf(folders, currentFolderId), [folders, currentFolderId]);
14678
- const subfolders = React82.useMemo(() => childrenOf(folders, currentFolderId), [folders, currentFolderId]);
14679
- const currentFiles = React82.useMemo(
14817
+ const [createOpen, setCreateOpen] = React85.useState(false);
14818
+ const [createName, setCreateName] = React85.useState("");
14819
+ const [renameTarget, setRenameTarget] = React85.useState(null);
14820
+ const [renameValue, setRenameValue] = React85.useState("");
14821
+ const [deleteTarget, setDeleteTarget] = React85.useState(null);
14822
+ const uploadInputRef = React85.useRef(null);
14823
+ const crumbFolders = React85.useMemo(() => ancestorsOf(folders, currentFolderId), [folders, currentFolderId]);
14824
+ const subfolders = React85.useMemo(() => childrenOf(folders, currentFolderId), [folders, currentFolderId]);
14825
+ const currentFiles = React85.useMemo(
14680
14826
  () => files.filter((f) => f.folderId === currentFolderId).sort((a, b) => a.name.localeCompare(b.name)),
14681
14827
  [files, currentFolderId]
14682
14828
  );
@@ -14715,10 +14861,10 @@ function FileBrowser({
14715
14861
  if (deleteTarget && onDeleteFolder) onDeleteFolder(deleteTarget);
14716
14862
  setDeleteTarget(null);
14717
14863
  };
14718
- const content = /* @__PURE__ */ jsxs95("div", { className: ["fd-fb", className].filter(Boolean).join(" "), children: [
14719
- /* @__PURE__ */ jsxs95("div", { className: "fd-fb-head", children: [
14720
- /* @__PURE__ */ jsxs95("nav", { className: "fd-fb-crumbs", "aria-label": "Folder path", children: [
14721
- /* @__PURE__ */ jsx108(
14864
+ const content = /* @__PURE__ */ jsxs97("div", { className: ["fd-fb", className].filter(Boolean).join(" "), children: [
14865
+ /* @__PURE__ */ jsxs97("div", { className: "fd-fb-head", children: [
14866
+ /* @__PURE__ */ jsxs97("nav", { className: "fd-fb-crumbs", "aria-label": "Folder path", children: [
14867
+ /* @__PURE__ */ jsx110(
14722
14868
  BreadcrumbCrumb,
14723
14869
  {
14724
14870
  label: "Home",
@@ -14728,7 +14874,7 @@ function FileBrowser({
14728
14874
  onDropPayload: (p) => moveIntoFolder(p, null)
14729
14875
  }
14730
14876
  ),
14731
- crumbFolders.map((f, i) => /* @__PURE__ */ jsx108(
14877
+ crumbFolders.map((f, i) => /* @__PURE__ */ jsx110(
14732
14878
  BreadcrumbCrumb,
14733
14879
  {
14734
14880
  label: f.name,
@@ -14740,11 +14886,11 @@ function FileBrowser({
14740
14886
  f.id
14741
14887
  ))
14742
14888
  ] }),
14743
- /* @__PURE__ */ jsxs95("span", { className: "fd-fb-actions", children: [
14744
- canCreateFolder ? /* @__PURE__ */ jsx108(Button, { variant: "secondary", size: "sm", icon: "folder-simple-plus", onClick: openCreate, children: "New folder" }) : null,
14745
- canUpload ? /* @__PURE__ */ jsxs95(Fragment32, { children: [
14746
- /* @__PURE__ */ jsx108(Button, { variant: "secondary", size: "sm", icon: "upload-simple", onClick: () => uploadInputRef.current && uploadInputRef.current.click(), children: "Upload" }),
14747
- /* @__PURE__ */ jsx108(
14889
+ /* @__PURE__ */ jsxs97("span", { className: "fd-fb-actions", children: [
14890
+ canCreateFolder ? /* @__PURE__ */ jsx110(Button, { variant: "secondary", size: "sm", icon: "folder-simple-plus", onClick: openCreate, children: "New folder" }) : null,
14891
+ canUpload ? /* @__PURE__ */ jsxs97(Fragment32, { children: [
14892
+ /* @__PURE__ */ jsx110(Button, { variant: "secondary", size: "sm", icon: "upload-simple", onClick: () => uploadInputRef.current && uploadInputRef.current.click(), children: "Upload" }),
14893
+ /* @__PURE__ */ jsx110(
14748
14894
  "input",
14749
14895
  {
14750
14896
  ref: uploadInputRef,
@@ -14762,9 +14908,9 @@ function FileBrowser({
14762
14908
  ] }) : null
14763
14909
  ] })
14764
14910
  ] }),
14765
- /* @__PURE__ */ jsxs95("div", { className: "fd-fb-body", children: [
14766
- /* @__PURE__ */ jsxs95("div", { className: "fd-fb-tree", role: "region", "aria-label": "Folder tree", children: [
14767
- /* @__PURE__ */ jsx108(
14911
+ /* @__PURE__ */ jsxs97("div", { className: "fd-fb-body", children: [
14912
+ /* @__PURE__ */ jsxs97("div", { className: "fd-fb-tree", role: "region", "aria-label": "Folder tree", children: [
14913
+ /* @__PURE__ */ jsx110(
14768
14914
  RowShell,
14769
14915
  {
14770
14916
  icon: "house-simple",
@@ -14775,7 +14921,7 @@ function FileBrowser({
14775
14921
  className: ["fd-fb-tree-row", currentFolderId == null ? "is-current" : ""].filter(Boolean).join(" ")
14776
14922
  }
14777
14923
  ),
14778
- childrenOf(folders, null).map((f) => /* @__PURE__ */ jsx108(
14924
+ childrenOf(folders, null).map((f) => /* @__PURE__ */ jsx110(
14779
14925
  TreeNode,
14780
14926
  {
14781
14927
  folder: f,
@@ -14789,18 +14935,18 @@ function FileBrowser({
14789
14935
  f.id
14790
14936
  ))
14791
14937
  ] }),
14792
- /* @__PURE__ */ jsx108("div", { className: "fd-fb-main", role: "region", "aria-label": "Folder contents", children: /* @__PURE__ */ jsx108(
14938
+ /* @__PURE__ */ jsx110("div", { className: "fd-fb-main", role: "region", "aria-label": "Folder contents", children: /* @__PURE__ */ jsx110(
14793
14939
  LoadingRegion,
14794
14940
  {
14795
14941
  state: loading ? "loading" : "ready",
14796
14942
  label: "Loading folder contents",
14797
- skeleton: /* @__PURE__ */ jsxs95("div", { className: "fd-stack", style: { gap: 8, padding: 12 }, children: [
14798
- /* @__PURE__ */ jsx108(Skeleton, { h: 44, radius: "10px" }),
14799
- /* @__PURE__ */ jsx108(Skeleton, { h: 44, radius: "10px" }),
14800
- /* @__PURE__ */ jsx108(Skeleton, { h: 44, radius: "10px" })
14943
+ skeleton: /* @__PURE__ */ jsxs97("div", { className: "fd-stack", style: { gap: 8, padding: 12 }, children: [
14944
+ /* @__PURE__ */ jsx110(Skeleton, { h: 44, radius: "10px" }),
14945
+ /* @__PURE__ */ jsx110(Skeleton, { h: 44, radius: "10px" }),
14946
+ /* @__PURE__ */ jsx110(Skeleton, { h: 44, radius: "10px" })
14801
14947
  ] }),
14802
- children: isEmpty ? /* @__PURE__ */ jsx108(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__ */ jsxs95("div", { className: "fd-fb-list", children: [
14803
- subfolders.map((f) => /* @__PURE__ */ jsx108(
14948
+ children: isEmpty ? /* @__PURE__ */ jsx110(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__ */ jsxs97("div", { className: "fd-fb-list", children: [
14949
+ subfolders.map((f) => /* @__PURE__ */ jsx110(
14804
14950
  RowShell,
14805
14951
  {
14806
14952
  icon: "folder-simple",
@@ -14809,9 +14955,9 @@ function FileBrowser({
14809
14955
  draggableId: canMove ? { kind: "folder", id: f.id } : void 0,
14810
14956
  isDropTarget: canMove,
14811
14957
  onDropPayload: (p) => moveIntoFolder(p, f.id),
14812
- actions: /* @__PURE__ */ jsxs95(Fragment32, { children: [
14813
- canRenameFolder ? /* @__PURE__ */ jsx108(IconButton, { icon: "pencil-simple", label: "Rename " + f.name, size: "sm", variant: "ghost", onClick: () => openRename(f) }) : null,
14814
- canMove ? /* @__PURE__ */ jsx108(
14958
+ actions: /* @__PURE__ */ jsxs97(Fragment32, { children: [
14959
+ canRenameFolder ? /* @__PURE__ */ jsx110(IconButton, { icon: "pencil-simple", label: "Rename " + f.name, size: "sm", variant: "ghost", onClick: () => openRename(f) }) : null,
14960
+ canMove ? /* @__PURE__ */ jsx110(
14815
14961
  FolderPickerMenu,
14816
14962
  {
14817
14963
  label: "Move " + f.name,
@@ -14819,12 +14965,12 @@ function FileBrowser({
14819
14965
  onPick: (target) => moveIntoFolder({ kind: "folder", id: f.id }, target)
14820
14966
  }
14821
14967
  ) : null,
14822
- canDeleteFolder ? /* @__PURE__ */ jsx108(IconButton, { icon: "trash-simple", label: "Delete " + f.name, size: "sm", variant: "ghost", onClick: () => openDelete(f) }) : null
14968
+ canDeleteFolder ? /* @__PURE__ */ jsx110(IconButton, { icon: "trash-simple", label: "Delete " + f.name, size: "sm", variant: "ghost", onClick: () => openDelete(f) }) : null
14823
14969
  ] })
14824
14970
  },
14825
14971
  f.id
14826
14972
  )),
14827
- currentFiles.map((file) => /* @__PURE__ */ jsx108(
14973
+ currentFiles.map((file) => /* @__PURE__ */ jsx110(
14828
14974
  RowShell,
14829
14975
  {
14830
14976
  icon: iconForMime(file.mime, file.name),
@@ -14832,8 +14978,8 @@ function FileBrowser({
14832
14978
  meta: file.size ? formatBytes(file.size) : void 0,
14833
14979
  onOpen: onOpenFile ? () => onOpenFile(file) : void 0,
14834
14980
  draggableId: canMove ? { kind: "file", id: file.id } : void 0,
14835
- actions: /* @__PURE__ */ jsxs95(Fragment32, { children: [
14836
- canMove ? /* @__PURE__ */ jsx108(
14981
+ actions: /* @__PURE__ */ jsxs97(Fragment32, { children: [
14982
+ canMove ? /* @__PURE__ */ jsx110(
14837
14983
  FolderPickerMenu,
14838
14984
  {
14839
14985
  label: "Move " + file.name,
@@ -14841,7 +14987,7 @@ function FileBrowser({
14841
14987
  onPick: (target) => onMoveFile && onMoveFile(file.id, target)
14842
14988
  }
14843
14989
  ) : null,
14844
- canRemoveFile ? /* @__PURE__ */ jsx108(IconButton, { icon: "trash-simple", label: "Remove " + file.name, size: "sm", variant: "ghost", onClick: () => onRemoveFile && onRemoveFile(file) }) : null
14990
+ canRemoveFile ? /* @__PURE__ */ jsx110(IconButton, { icon: "trash-simple", label: "Remove " + file.name, size: "sm", variant: "ghost", onClick: () => onRemoveFile && onRemoveFile(file) }) : null
14845
14991
  ] })
14846
14992
  },
14847
14993
  file.id
@@ -14850,10 +14996,10 @@ function FileBrowser({
14850
14996
  }
14851
14997
  ) })
14852
14998
  ] }),
14853
- /* @__PURE__ */ jsx108(Modal, { open: createOpen, title: "New folder", onClose: () => setCreateOpen(false), footer: /* @__PURE__ */ jsxs95(Fragment32, { children: [
14854
- /* @__PURE__ */ jsx108(Button, { variant: "secondary", onClick: () => setCreateOpen(false), children: "Cancel" }),
14855
- /* @__PURE__ */ jsx108(Button, { onClick: submitCreate, disabled: !createName.trim(), children: "Create" })
14856
- ] }), children: /* @__PURE__ */ jsx108(
14999
+ /* @__PURE__ */ jsx110(Modal, { open: createOpen, title: "New folder", onClose: () => setCreateOpen(false), footer: /* @__PURE__ */ jsxs97(Fragment32, { children: [
15000
+ /* @__PURE__ */ jsx110(Button, { variant: "secondary", onClick: () => setCreateOpen(false), children: "Cancel" }),
15001
+ /* @__PURE__ */ jsx110(Button, { onClick: submitCreate, disabled: !createName.trim(), children: "Create" })
15002
+ ] }), children: /* @__PURE__ */ jsx110(
14857
15003
  "input",
14858
15004
  {
14859
15005
  className: "fd-fb-input",
@@ -14867,10 +15013,10 @@ function FileBrowser({
14867
15013
  autoFocus: true
14868
15014
  }
14869
15015
  ) }),
14870
- /* @__PURE__ */ jsx108(Modal, { open: renameTarget != null, title: "Rename folder", onClose: () => setRenameTarget(null), footer: /* @__PURE__ */ jsxs95(Fragment32, { children: [
14871
- /* @__PURE__ */ jsx108(Button, { variant: "secondary", onClick: () => setRenameTarget(null), children: "Cancel" }),
14872
- /* @__PURE__ */ jsx108(Button, { onClick: submitRename, disabled: !renameValue.trim(), children: "Save" })
14873
- ] }), children: /* @__PURE__ */ jsx108(
15016
+ /* @__PURE__ */ jsx110(Modal, { open: renameTarget != null, title: "Rename folder", onClose: () => setRenameTarget(null), footer: /* @__PURE__ */ jsxs97(Fragment32, { children: [
15017
+ /* @__PURE__ */ jsx110(Button, { variant: "secondary", onClick: () => setRenameTarget(null), children: "Cancel" }),
15018
+ /* @__PURE__ */ jsx110(Button, { onClick: submitRename, disabled: !renameValue.trim(), children: "Save" })
15019
+ ] }), children: /* @__PURE__ */ jsx110(
14874
15020
  "input",
14875
15021
  {
14876
15022
  className: "fd-fb-input",
@@ -14884,22 +15030,22 @@ function FileBrowser({
14884
15030
  autoFocus: true
14885
15031
  }
14886
15032
  ) }),
14887
- /* @__PURE__ */ jsx108(
15033
+ /* @__PURE__ */ jsx110(
14888
15034
  Modal,
14889
15035
  {
14890
15036
  open: deleteTarget != null,
14891
15037
  title: deleteTarget ? "Delete \u201C" + deleteTarget.name + "\u201D?" : "Delete folder?",
14892
15038
  description: "This can't be undone. The folder must be empty.",
14893
15039
  onClose: () => setDeleteTarget(null),
14894
- footer: /* @__PURE__ */ jsxs95(Fragment32, { children: [
14895
- /* @__PURE__ */ jsx108(Button, { variant: "secondary", onClick: () => setDeleteTarget(null), children: "Cancel" }),
14896
- /* @__PURE__ */ jsx108(Button, { variant: "danger", onClick: confirmDelete, children: "Delete" })
15040
+ footer: /* @__PURE__ */ jsxs97(Fragment32, { children: [
15041
+ /* @__PURE__ */ jsx110(Button, { variant: "secondary", onClick: () => setDeleteTarget(null), children: "Cancel" }),
15042
+ /* @__PURE__ */ jsx110(Button, { variant: "danger", onClick: confirmDelete, children: "Delete" })
14897
15043
  ] })
14898
15044
  }
14899
15045
  )
14900
15046
  ] });
14901
15047
  if (!canUpload) return content;
14902
- return /* @__PURE__ */ jsx108(Dropzone, { className: "fd-fb-dropzone", onFiles: (picked) => onUpload && onUpload(picked, currentFolderId), label: "Drop files to upload", children: content });
15048
+ return /* @__PURE__ */ jsx110(Dropzone, { className: "fd-fb-dropzone", onFiles: (picked) => onUpload && onUpload(picked, currentFolderId), label: "Drop files to upload", children: content });
14903
15049
  }
14904
15050
  function BreadcrumbCrumb({
14905
15051
  label,
@@ -14908,8 +15054,8 @@ function BreadcrumbCrumb({
14908
15054
  isDropTarget,
14909
15055
  onDropPayload
14910
15056
  }) {
14911
- const [over, setOver] = React82.useState(false);
14912
- const dragCounter = React82.useRef(0);
15057
+ const [over, setOver] = React85.useState(false);
15058
+ const dragCounter = React85.useRef(0);
14913
15059
  const dropHandlers = isDropTarget ? {
14914
15060
  onDragEnter: (e) => {
14915
15061
  if (!hasInternalPayload(e)) return;
@@ -14934,11 +15080,11 @@ function BreadcrumbCrumb({
14934
15080
  if (payload && onDropPayload) onDropPayload(payload);
14935
15081
  }
14936
15082
  } : {};
14937
- return /* @__PURE__ */ jsx108("span", { className: ["fd-fb-crumb", over ? "is-drop-target" : ""].filter(Boolean).join(" "), ...dropHandlers, children: isCurrent ? /* @__PURE__ */ jsx108("span", { className: "fd-fb-crumb-current", "aria-current": "page", children: label }) : /* @__PURE__ */ jsx108("button", { type: "button", className: "fd-fb-crumb-link", onClick, children: label }) });
15083
+ return /* @__PURE__ */ jsx110("span", { className: ["fd-fb-crumb", over ? "is-drop-target" : ""].filter(Boolean).join(" "), ...dropHandlers, children: isCurrent ? /* @__PURE__ */ jsx110("span", { className: "fd-fb-crumb-current", "aria-current": "page", children: label }) : /* @__PURE__ */ jsx110("button", { type: "button", className: "fd-fb-crumb-link", onClick, children: label }) });
14938
15084
  }
14939
15085
 
14940
15086
  // src/kits/query.ts
14941
- import * as React83 from "react";
15087
+ import * as React86 from "react";
14942
15088
 
14943
15089
  // src/kits/queryUrl.ts
14944
15090
  var historyUrlAdapter = {
@@ -15076,38 +15222,38 @@ function requestFor(params, query, paging, after) {
15076
15222
  }
15077
15223
  var toError = (e) => e instanceof Error ? e : new Error(String(e));
15078
15224
  function useServerTable({ endpoint, params, defaults, deps, prefsKey, paging = "page", url }) {
15079
- const [base] = React83.useState(() => {
15225
+ const [base] = React86.useState(() => {
15080
15226
  const store = PREFS || window.PlannerPrefs;
15081
15227
  const saved = prefsKey && store ? store.getTable(prefsKey) : {};
15082
15228
  return { ...DEFAULTS, ...defaults || {}, ...saved.pageSize ? { pageSize: saved.pageSize } : {}, ...saved.sort ? { sort: saved.sort, dir: saved.dir || "desc" } : {} };
15083
15229
  });
15084
- const [mountParams] = React83.useState(() => url ? (url.adapter ?? historyUrlAdapter).read() : null);
15085
- const address = React83.useRef(mountParams);
15086
- const [query, setQuery] = React83.useState(() => url && mountParams ? readQueryFromUrl(mountParams, url.scope, base, paging) : base);
15087
- const savePref = React83.useCallback((patch2) => {
15230
+ const [mountParams] = React86.useState(() => url ? (url.adapter ?? historyUrlAdapter).read() : null);
15231
+ const address = React86.useRef(mountParams);
15232
+ const [query, setQuery] = React86.useState(() => url && mountParams ? readQueryFromUrl(mountParams, url.scope, base, paging) : base);
15233
+ const savePref = React86.useCallback((patch2) => {
15088
15234
  const store = PREFS || window.PlannerPrefs;
15089
15235
  if (prefsKey && store) store.setTable(prefsKey, patch2);
15090
15236
  }, [prefsKey]);
15091
- const [res, setRes] = React83.useState(null);
15092
- const [loading, setLoading] = React83.useState(true);
15093
- const [loadingMore, setLoadingMore] = React83.useState(false);
15094
- const [failure, setFailure] = React83.useState(null);
15095
- const [reloadToken, setReloadToken] = React83.useState(0);
15096
- const moreController = React83.useRef(null);
15237
+ const [res, setRes] = React86.useState(null);
15238
+ const [loading, setLoading] = React86.useState(true);
15239
+ const [loadingMore, setLoadingMore] = React86.useState(false);
15240
+ const [failure, setFailure] = React86.useState(null);
15241
+ const [reloadToken, setReloadToken] = React86.useState(0);
15242
+ const moreController = React86.useRef(null);
15097
15243
  const depKey = (deps || []).join("|");
15098
15244
  const paramKey = JSON.stringify(params || {});
15099
15245
  const queryKey = JSON.stringify(query);
15100
- const lifetime = React83.useRef(null);
15101
- React83.useEffect(() => {
15246
+ const lifetime = React86.useRef(null);
15247
+ React86.useEffect(() => {
15102
15248
  const controller = new AbortController();
15103
15249
  lifetime.current = controller;
15104
15250
  return () => controller.abort();
15105
15251
  }, []);
15106
- const latest = React83.useRef({ res, loading, query, params, endpoint, url, base });
15107
- React83.useLayoutEffect(() => {
15252
+ const latest = React86.useRef({ res, loading, query, params, endpoint, url, base });
15253
+ React86.useLayoutEffect(() => {
15108
15254
  latest.current = { res, loading, query, params, endpoint, url, base };
15109
15255
  });
15110
- React83.useEffect(() => {
15256
+ React86.useEffect(() => {
15111
15257
  const controller = new AbortController();
15112
15258
  const { signal } = controller;
15113
15259
  setLoading(true);
@@ -15143,7 +15289,7 @@ function useServerTable({ endpoint, params, defaults, deps, prefsKey, paging = "
15143
15289
  };
15144
15290
  }, [endpoint, queryKey, paramKey, depKey, paging, reloadToken]);
15145
15291
  const adapter = url ? url.adapter ?? historyUrlAdapter : null;
15146
- React83.useEffect(() => {
15292
+ React86.useEffect(() => {
15147
15293
  if (!adapter) return;
15148
15294
  return adapter.subscribe((params2) => {
15149
15295
  const { url: u, base: b } = latest.current;
@@ -15493,16 +15639,219 @@ function createVersionStore(initialState, options) {
15493
15639
  }
15494
15640
 
15495
15641
  // src/kits/documentTitle.ts
15496
- import * as React84 from "react";
15642
+ import * as React87 from "react";
15497
15643
  function formatDocumentTitle(routeTitle, appName) {
15498
15644
  return [routeTitle, appName, "Flytedesk"].filter((part2) => !!part2 && part2.length > 0).join(" \xB7 ");
15499
15645
  }
15500
15646
  function useDocumentTitle(routeTitle, appName) {
15501
- React84.useEffect(() => {
15647
+ React87.useEffect(() => {
15502
15648
  if (typeof document === "undefined") return;
15503
15649
  document.title = formatDocumentTitle(routeTitle, appName);
15504
15650
  }, [routeTitle, appName]);
15505
15651
  }
15652
+
15653
+ // src/kits/chatTransport/deadline.ts
15654
+ var CHAT_CALL_DEADLINE_MS = 3e4;
15655
+ var CallDeadlineError = class extends Error {
15656
+ constructor(call, deadlineMs) {
15657
+ super(`${call} did not answer within ${deadlineMs}ms`);
15658
+ this.call = call;
15659
+ this.deadlineMs = deadlineMs;
15660
+ this.name = "CallDeadlineError";
15661
+ }
15662
+ call;
15663
+ deadlineMs;
15664
+ };
15665
+ function withDeadline(call, deadlineMs, work) {
15666
+ let timer;
15667
+ const deadline = new Promise((_resolve, reject) => {
15668
+ timer = setTimeout(() => reject(new CallDeadlineError(call, deadlineMs)), deadlineMs);
15669
+ });
15670
+ return Promise.race([work, deadline]).finally(() => clearTimeout(timer));
15671
+ }
15672
+
15673
+ // src/kits/chatTransport/chatAdapter.ts
15674
+ var CHAT_UNAVAILABLE_MESSAGE = "chat_unavailable";
15675
+ var ChatUnreachableError = class extends Error {
15676
+ constructor(message = CHAT_UNAVAILABLE_MESSAGE) {
15677
+ super(message);
15678
+ this.name = "ChatUnreachableError";
15679
+ }
15680
+ };
15681
+ function createChatAdapter(transport, { onTurnStarted, deadlineMs = CHAT_CALL_DEADLINE_MS } = {}) {
15682
+ const within = (call, work) => withDeadline(call, deadlineMs, work);
15683
+ const common = {
15684
+ async resolveThread(context) {
15685
+ try {
15686
+ const { thread_id } = await within("resolveThread", transport.resolveThread(context));
15687
+ return { thread_id };
15688
+ } catch {
15689
+ throw new Error(CHAT_UNAVAILABLE_MESSAGE);
15690
+ }
15691
+ },
15692
+ async getThread(threadId) {
15693
+ return { messages: await within("getThread", transport.getMessages(threadId)) };
15694
+ },
15695
+ cancelJob: transport.cancelTurn ? (jobId) => within("cancelJob", transport.cancelTurn(jobId)) : void 0
15696
+ };
15697
+ if (transport.streamTurn) {
15698
+ const { streamTurn } = transport;
15699
+ return {
15700
+ ...common,
15701
+ // The engine streams whenever `streamMessage` is present and calls neither of these for a turn that settles.
15702
+ // A streamed turn that answered a job id would have the engine poll one that does not exist: fail loudly.
15703
+ sendMessage: () => Promise.reject(new Error("A streaming chat starts its turns with streamMessage.")),
15704
+ getJob: () => Promise.reject(new Error("A streaming chat has no turn status to poll.")),
15705
+ async streamMessage(threadId, text, handlers, signal, attachments) {
15706
+ let started = false;
15707
+ const markStarted = () => {
15708
+ if (started) return;
15709
+ started = true;
15710
+ onTurnStarted?.();
15711
+ };
15712
+ const accepting = {
15713
+ onToken: (chunk) => (markStarted(), handlers.onToken(chunk)),
15714
+ onStep: handlers.onStep && ((step) => (markStarted(), handlers.onStep(step))),
15715
+ onThinking: handlers.onThinking && ((chunk) => (markStarted(), handlers.onThinking(chunk)))
15716
+ };
15717
+ let result;
15718
+ try {
15719
+ result = await streamTurn(threadId, text, accepting, signal, attachments);
15720
+ } catch (err) {
15721
+ if (err instanceof ChatUnreachableError) throw new Error(CHAT_UNAVAILABLE_MESSAGE);
15722
+ throw err;
15723
+ }
15724
+ if (result.job_id) throw new Error("A streamed turn must end with its final result, not a job to poll.");
15725
+ markStarted();
15726
+ return result;
15727
+ }
15728
+ };
15729
+ }
15730
+ const { startTurn, getTurn } = transport;
15731
+ return {
15732
+ ...common,
15733
+ // `signal` (the engine's Stop-button plumbing) is deliberately not wired to this call: it only starts a dispatch and
15734
+ // never streams, and aborting it could leave a dispatch started server-side with no job id for the engine to track.
15735
+ // Stop is `cancelJob`.
15736
+ async sendMessage(threadId, text, _signal, attachments) {
15737
+ const { jobId } = await within("sendMessage", startTurn(threadId, text, attachments));
15738
+ onTurnStarted?.();
15739
+ return { dispatched: true, job_id: jobId };
15740
+ },
15741
+ async getJob(jobId) {
15742
+ const status = await within("getJob", getTurn(jobId));
15743
+ return status ?? { status: "failed", error: "turn_not_found" };
15744
+ }
15745
+ };
15746
+ }
15747
+
15748
+ // src/kits/chatTransport/useChatThreads.ts
15749
+ import * as React88 from "react";
15750
+ var THREADS_LOAD_FAILED = "Your earlier conversations could not be loaded.";
15751
+ var NEW_THREAD_FAILED = "A new conversation could not be started.";
15752
+ function useChatThreads(transport, { deadlineMs = CHAT_CALL_DEADLINE_MS } = {}) {
15753
+ const toast = useToast();
15754
+ const [threads, setThreads] = React88.useState([]);
15755
+ const [reads, setReads] = React88.useState(0);
15756
+ const transportRef = useLatest(transport);
15757
+ const deadlineRef = useLatest(deadlineMs);
15758
+ const refresh2 = React88.useCallback(() => setReads((n) => n + 1), []);
15759
+ React88.useEffect(() => {
15760
+ const controller = new AbortController();
15761
+ const { signal } = controller;
15762
+ withDeadline("listThreads", deadlineRef.current, transportRef.current.listThreads(signal)).then(
15763
+ (listed) => {
15764
+ if (!signal.aborted) setThreads(listed);
15765
+ },
15766
+ () => {
15767
+ if (!signal.aborted) toast.show(THREADS_LOAD_FAILED, { tone: "error" });
15768
+ }
15769
+ );
15770
+ return () => controller.abort();
15771
+ }, [reads, toast, transportRef, deadlineRef]);
15772
+ const startNewThread = React88.useCallback(
15773
+ (onCreated) => withDeadline("createThread", deadlineRef.current, transportRef.current.createThread()).then(
15774
+ ({ thread_id }) => {
15775
+ onCreated(thread_id);
15776
+ refresh2();
15777
+ },
15778
+ () => toast.show(NEW_THREAD_FAILED, { tone: "error" })
15779
+ ),
15780
+ [deadlineRef, transportRef, refresh2, toast]
15781
+ );
15782
+ return { threads, refresh: refresh2, startNewThread };
15783
+ }
15784
+
15785
+ // src/kits/exports/downloadExport.ts
15786
+ function createExportDownloader({
15787
+ mintUrl,
15788
+ navigate = (url) => window.location.assign(url)
15789
+ }) {
15790
+ return (id) => mintUrl(id).then(
15791
+ (url) => {
15792
+ if (url) navigate(url);
15793
+ },
15794
+ () => {
15795
+ }
15796
+ );
15797
+ }
15798
+
15799
+ // src/kits/exports/useExportJobs.ts
15800
+ import * as React89 from "react";
15801
+ var EXPORT_POLL_INTERVAL_MS = 3e3;
15802
+ var EXPORT_IDLE_POLL_INTERVAL_MS = 3e4;
15803
+ function useExportJobs({ list, acknowledge }) {
15804
+ const [rows, setRows] = React89.useState([]);
15805
+ const listRef = useLatest(list);
15806
+ const acknowledgeRef = useLatest(acknowledge);
15807
+ const reload = React89.useCallback(
15808
+ () => listRef.current().then(
15809
+ (fresh) => setRows(fresh),
15810
+ () => {
15811
+ }
15812
+ ),
15813
+ [listRef]
15814
+ );
15815
+ React89.useEffect(() => {
15816
+ void reload();
15817
+ }, [reload]);
15818
+ const anyLive = rows.some(isLiveExport);
15819
+ React89.useEffect(() => {
15820
+ const timer = setInterval(() => void reload(), anyLive ? EXPORT_POLL_INTERVAL_MS : EXPORT_IDLE_POLL_INTERVAL_MS);
15821
+ return () => clearInterval(timer);
15822
+ }, [anyLive, reload]);
15823
+ const refresh2 = React89.useCallback(() => void reload(), [reload]);
15824
+ const ackExport = React89.useCallback(
15825
+ (id) => void acknowledgeRef.current(id).then(reload),
15826
+ [acknowledgeRef, reload]
15827
+ );
15828
+ return { exports: rows, ackExport, refresh: refresh2 };
15829
+ }
15830
+
15831
+ // src/kits/exports/ExportTray.tsx
15832
+ import * as React90 from "react";
15833
+ import { jsx as jsx111 } from "react/jsx-runtime";
15834
+ var EXPORT_KEPT_NOTE = "Kept for 24 hours";
15835
+ var EXPORT_FAILED_FALLBACK = "Unknown error.";
15836
+ function exportToJob(job, onDownload) {
15837
+ const base = { id: job.id, title: job.title, note: job.note };
15838
+ if (job.status === "SUCCEEDED") {
15839
+ return {
15840
+ ...base,
15841
+ status: "done",
15842
+ action: { label: "Download", icon: "download-simple", onClick: () => onDownload(job.id) },
15843
+ doneNote: EXPORT_KEPT_NOTE
15844
+ };
15845
+ }
15846
+ if (job.status === "FAILED") {
15847
+ return { ...base, status: "failed", failureReason: job.failureMessage ?? EXPORT_FAILED_FALLBACK };
15848
+ }
15849
+ return { ...base, status: "active" };
15850
+ }
15851
+ function ExportTray({ exports, onDownload, onDismiss }) {
15852
+ const jobs2 = React90.useMemo(() => exports.map((job) => exportToJob(job, onDownload)), [exports, onDownload]);
15853
+ return /* @__PURE__ */ jsx111(JobTray, { jobs: jobs2, onDismiss });
15854
+ }
15506
15855
  export {
15507
15856
  AccountMenu,
15508
15857
  AgentChatPanel,
@@ -15522,11 +15871,16 @@ export {
15522
15871
  Button,
15523
15872
  CHANNELS,
15524
15873
  CHANNEL_WEIGHTS,
15874
+ CHAT_CALL_DEADLINE_MS,
15525
15875
  CHAT_UNAVAILABLE,
15876
+ CHAT_UNAVAILABLE_MESSAGE,
15526
15877
  COPIED_FEEDBACK_MS,
15527
15878
  CORNER_STACK_INSET_PROPERTY,
15528
15879
  CORNER_STACK_OFFSET_PROPERTY,
15880
+ CSV_FAILED_FALLBACK,
15881
+ CSV_KEPT_NOTE,
15529
15882
  Calendar,
15883
+ CallDeadlineError,
15530
15884
  Card,
15531
15885
  CardGrid,
15532
15886
  CardRow,
@@ -15539,6 +15893,7 @@ export {
15539
15893
  ChatSessionBar,
15540
15894
  ChatTranscript,
15541
15895
  ChatTurn,
15896
+ ChatUnreachableError,
15542
15897
  Checkbox,
15543
15898
  Citations,
15544
15899
  Clamp,
@@ -15551,6 +15906,7 @@ export {
15551
15906
  CsiBadge,
15552
15907
  CsiHero,
15553
15908
  CsiMeter,
15909
+ CsvCard,
15554
15910
  DEFAULT_PREFS,
15555
15911
  DEFAULT_STORAGE_KEY,
15556
15912
  DEFAULT_TOAST_DURATION_MS,
@@ -15563,9 +15919,14 @@ export {
15563
15919
  Dropzone,
15564
15920
  DropzoneKit,
15565
15921
  ENTITY_ROW_METRIC_WIDTH,
15922
+ EXPORT_FAILED_FALLBACK,
15923
+ EXPORT_IDLE_POLL_INTERVAL_MS,
15924
+ EXPORT_KEPT_NOTE,
15925
+ EXPORT_POLL_INTERVAL_MS,
15566
15926
  EmptyState,
15567
15927
  EntityRow,
15568
15928
  EntityRowMetrics,
15929
+ ExportTray,
15569
15930
  FILE_VIEWER_CSV_ROW_LIMIT,
15570
15931
  FILE_VIEWER_TEXT_LIMIT,
15571
15932
  FactList,
@@ -15608,6 +15969,7 @@ export {
15608
15969
  Modal,
15609
15970
  ModeSwitch,
15610
15971
  ModelControls,
15972
+ NEW_THREAD_FAILED,
15611
15973
  NumberInput,
15612
15974
  OVERLAY_BREAKPOINT,
15613
15975
  OVERLAY_CEILING,
@@ -15621,7 +15983,9 @@ export {
15621
15983
  PreferenceMeter,
15622
15984
  ProfilePage,
15623
15985
  ProgressBar,
15986
+ QUERY_EMPTY_MESSAGE,
15624
15987
  QueryKit,
15988
+ QueryResultCard,
15625
15989
  QuotaRow,
15626
15990
  ROOT_STEP,
15627
15991
  Radio,
@@ -15655,6 +16019,7 @@ export {
15655
16019
  StepList,
15656
16020
  SurroundSound,
15657
16021
  Switch,
16022
+ THREADS_LOAD_FAILED,
15658
16023
  Tabs,
15659
16024
  Tag,
15660
16025
  TestModeBar,
@@ -15684,9 +16049,13 @@ export {
15684
16049
  computeNeedMore,
15685
16050
  computeVirtualWindow,
15686
16051
  copyToClipboard,
16052
+ createChatAdapter,
16053
+ createExportDownloader,
15687
16054
  createLocalStorageAppearanceStore,
15688
16055
  createVersionStore,
15689
16056
  eqFilter,
16057
+ exportStateOf,
16058
+ exportToJob,
15690
16059
  extensionOf,
15691
16060
  extractClipboardFiles,
15692
16061
  filterFiles,
@@ -15705,7 +16074,9 @@ export {
15705
16074
  importanceLevel,
15706
16075
  importanceTokens,
15707
16076
  installFlytedeskFavicon,
16077
+ isExpiredExport,
15708
16078
  isImage,
16079
+ isLiveExport,
15709
16080
  isSystemMessage,
15710
16081
  isUsStateCode,
15711
16082
  isWithinLayerTree,
@@ -15730,9 +16101,12 @@ export {
15730
16101
  useAppearancePrefs,
15731
16102
  useAppearanceStore,
15732
16103
  useChatEngine,
16104
+ useChatThreads,
15733
16105
  useCopyToClipboard,
15734
16106
  useCornerStackSlot,
15735
16107
  useDocumentTitle,
16108
+ useExpiryClock,
16109
+ useExportJobs,
15736
16110
  useFeatureStatus,
15737
16111
  useLayerZIndex,
15738
16112
  useOverlayLayout,
@@ -15743,6 +16117,7 @@ export {
15743
16117
  useServerTable,
15744
16118
  useSessionContext,
15745
16119
  useSheetOpenMark,
16120
+ useShownExport,
15746
16121
  useStackedLayer,
15747
16122
  useStagedFiles,
15748
16123
  useToast,
@@ -15750,6 +16125,7 @@ export {
15750
16125
  validateFilterValue,
15751
16126
  visibleMessages,
15752
16127
  watchAppearance,
16128
+ withDeadline,
15753
16129
  writeQueryToUrl
15754
16130
  };
15755
16131
  //# sourceMappingURL=index.js.map