nish-ui 1.4.1 → 1.5.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
@@ -8557,9 +8557,208 @@ var NumberField = forwardRef3(function NumberField2({ value, onCommit, min, max,
8557
8557
  ] });
8558
8558
  });
8559
8559
 
8560
+ // src/components/service-tokens.tsx
8561
+ import {
8562
+ useCallback as useCallback9,
8563
+ useEffect as useEffect21,
8564
+ useMemo as useMemo6,
8565
+ useRef as useRef20,
8566
+ useState as useState20
8567
+ } from "react";
8568
+ import { Fragment as Fragment13, jsx as jsx24, jsxs as jsxs23 } from "react/jsx-runtime";
8569
+ function useServiceTokens(url = "/api/service-tokens") {
8570
+ const [tokens, setTokens] = useState20(
8571
+ void 0
8572
+ );
8573
+ const [loading, setLoading] = useState20(true);
8574
+ const [error, setError] = useState20(null);
8575
+ const [nonce, setNonce] = useState20(0);
8576
+ const seq = useRef20(0);
8577
+ useEffect21(() => {
8578
+ const mine = ++seq.current;
8579
+ const ctl = new AbortController();
8580
+ apiFetch(url, { signal: ctl.signal }).then((r) => {
8581
+ if (seq.current !== mine) return;
8582
+ setTokens(r.tokens);
8583
+ setLoading(false);
8584
+ }).catch((e) => {
8585
+ if (seq.current !== mine || e instanceof Error && e.name === "AbortError")
8586
+ return;
8587
+ setError(e instanceof Error ? e.message : "Failed to load");
8588
+ setLoading(false);
8589
+ });
8590
+ return () => ctl.abort();
8591
+ }, [url, nonce]);
8592
+ const reload = useCallback9(() => {
8593
+ setLoading(true);
8594
+ setError(null);
8595
+ setNonce((n) => n + 1);
8596
+ }, []);
8597
+ const revoke = useCallback9(
8598
+ async (id) => {
8599
+ const r = await apiFetch(
8600
+ `${url}/${encodeURIComponent(id)}/revoke`,
8601
+ // A JSON body (and so a JSON content type): some apps refuse non-JSON writes.
8602
+ { method: "POST", body: {} }
8603
+ );
8604
+ seq.current++;
8605
+ setTokens(r.tokens);
8606
+ setError(null);
8607
+ setLoading(false);
8608
+ },
8609
+ [url]
8610
+ );
8611
+ return { tokens, loading, error, reload, revoke };
8612
+ }
8613
+ var DEFAULT_DESCRIPTION = "Machine clients, like the nish MCP server, use these tokens to read this app. Revoking one stops it at once.";
8614
+ function when(raw) {
8615
+ if (!raw) return "";
8616
+ const d = /^\d{4}-\d{2}-\d{2}$/.test(raw) ? `${raw}T12:00:00` : raw;
8617
+ const out = date(d, "medium");
8618
+ return out === "\u2014" || out === "" || Number.isNaN(new Date(d).getTime()) ? raw : out;
8619
+ }
8620
+ function sortTokens(list) {
8621
+ return [...list].sort(
8622
+ (a, b) => Number(a.revoked) - Number(b.revoked) || a.name.localeCompare(b.name)
8623
+ );
8624
+ }
8625
+ function ServiceTokensSection({
8626
+ tokens,
8627
+ error,
8628
+ onRetry,
8629
+ onRevoke,
8630
+ title = "Service tokens",
8631
+ description = DEFAULT_DESCRIPTION,
8632
+ id = "service-tokens",
8633
+ className
8634
+ }) {
8635
+ const [target, setTarget] = useState20(null);
8636
+ const [pending, setPending] = useState20(false);
8637
+ const [failure, setFailure] = useState20(null);
8638
+ const mounted = useRef20(true);
8639
+ useEffect21(() => {
8640
+ mounted.current = true;
8641
+ return () => {
8642
+ mounted.current = false;
8643
+ };
8644
+ }, []);
8645
+ const sorted = useMemo6(
8646
+ () => tokens ? sortTokens(tokens) : void 0,
8647
+ [tokens]
8648
+ );
8649
+ const close = () => {
8650
+ setTarget(null);
8651
+ setFailure(null);
8652
+ };
8653
+ const confirm = async () => {
8654
+ if (!target) return;
8655
+ setPending(true);
8656
+ setFailure(null);
8657
+ try {
8658
+ await onRevoke(target.id);
8659
+ if (mounted.current) close();
8660
+ } catch (e) {
8661
+ if (mounted.current)
8662
+ setFailure(
8663
+ e instanceof Error ? e.message : "Could not revoke the token."
8664
+ );
8665
+ } finally {
8666
+ if (mounted.current) setPending(false);
8667
+ }
8668
+ };
8669
+ const errorRow = sorted !== void 0 && error ? /* @__PURE__ */ jsxs23("div", { className: "flex flex-wrap items-center gap-2 px-4 py-2", children: [
8670
+ /* @__PURE__ */ jsx24(
8671
+ "p",
8672
+ {
8673
+ role: "alert",
8674
+ className: "min-w-0 flex-1 break-words text-sm text-th-loss",
8675
+ children: error
8676
+ }
8677
+ ),
8678
+ onRetry ? /* @__PURE__ */ jsx24(Button, { size: "sm", onClick: onRetry, children: "Try again" }) : null
8679
+ ] }) : null;
8680
+ let content;
8681
+ if (sorted === void 0 && error) {
8682
+ content = /* @__PURE__ */ jsxs23("div", { className: "grid gap-2 p-4", children: [
8683
+ /* @__PURE__ */ jsx24(ErrorState, { message: error, compact: true }),
8684
+ onRetry ? /* @__PURE__ */ jsx24("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx24(Button, { size: "sm", onClick: onRetry, children: "Try again" }) }) : null
8685
+ ] });
8686
+ } else if (sorted === void 0) {
8687
+ content = /* @__PURE__ */ jsx24("div", { className: "p-4", children: /* @__PURE__ */ jsx24(SkeletonRows, { rows: 3, height: 48, label: "Loading service tokens" }) });
8688
+ } else if (sorted.length === 0) {
8689
+ content = /* @__PURE__ */ jsxs23(Fragment13, { children: [
8690
+ errorRow,
8691
+ /* @__PURE__ */ jsx24("p", { className: "px-4 py-6 text-sm text-th-hi3", children: "No service tokens. No machine client can read this app." })
8692
+ ] });
8693
+ } else {
8694
+ const rows = sorted.map((t) => {
8695
+ const parts = [t.id, t.scopes.join(", "), `created ${when(t.created)}`];
8696
+ if (t.source === "env") parts.push("from SERVICE_TOKENS");
8697
+ return /* @__PURE__ */ jsx24(
8698
+ SettingRow,
8699
+ {
8700
+ label: /* @__PURE__ */ jsx24("span", { className: cn("break-words", t.revoked && "text-th-hi3"), children: t.name }),
8701
+ description: /* @__PURE__ */ jsx24("span", { className: "break-words", children: parts.join(" \xB7 ") }),
8702
+ inline: true,
8703
+ children: t.revoked ? /* @__PURE__ */ jsx24(
8704
+ Badge,
8705
+ {
8706
+ tone: "neutral",
8707
+ title: t.revokedAt ? `Revoked ${when(t.revokedAt)}` : "Revoked",
8708
+ children: "Revoked"
8709
+ }
8710
+ ) : /* @__PURE__ */ jsx24(
8711
+ Button,
8712
+ {
8713
+ variant: "danger",
8714
+ size: "sm",
8715
+ "aria-label": `Revoke ${t.name}`,
8716
+ onClick: () => setTarget(t),
8717
+ children: "Revoke"
8718
+ }
8719
+ )
8720
+ },
8721
+ `${t.id}:${t.name}:${t.created}`
8722
+ );
8723
+ });
8724
+ content = /* @__PURE__ */ jsxs23(Fragment13, { children: [
8725
+ errorRow,
8726
+ rows
8727
+ ] });
8728
+ }
8729
+ return /* @__PURE__ */ jsxs23(Fragment13, { children: [
8730
+ /* @__PURE__ */ jsx24(
8731
+ SettingsSection,
8732
+ {
8733
+ title,
8734
+ description,
8735
+ id,
8736
+ className,
8737
+ children: content
8738
+ }
8739
+ ),
8740
+ target ? /* @__PURE__ */ jsx24(
8741
+ ConfirmDialog,
8742
+ {
8743
+ title: `Revoke ${target.name}?`,
8744
+ body: /* @__PURE__ */ jsxs23(Fragment13, { children: [
8745
+ /* @__PURE__ */ jsx24("p", { children: 'Anything using this token gets "Unauthorized" from now on. This cannot be undone: to restore access, issue a new token with npm run tokens in nishant/mcp.' }),
8746
+ failure ? /* @__PURE__ */ jsx24("p", { role: "alert", className: "mt-3 text-th-loss", children: failure }) : null
8747
+ ] }),
8748
+ confirmLabel: "Revoke",
8749
+ cancelLabel: "Cancel",
8750
+ tone: "danger",
8751
+ pending,
8752
+ onConfirm: () => void confirm(),
8753
+ onCancel: close
8754
+ }
8755
+ ) : null
8756
+ ] });
8757
+ }
8758
+
8560
8759
  // src/components/combobox.tsx
8561
- import { useCallback as useCallback9, useEffect as useEffect21, useId as useId11, useMemo as useMemo6, useRef as useRef20, useState as useState20 } from "react";
8562
- import { jsx as jsx24, jsxs as jsxs23 } from "react/jsx-runtime";
8760
+ import { useCallback as useCallback10, useEffect as useEffect22, useId as useId11, useMemo as useMemo7, useRef as useRef21, useState as useState21 } from "react";
8761
+ import { jsx as jsx25, jsxs as jsxs24 } from "react/jsx-runtime";
8563
8762
  var MAX_SHOWN = 50;
8564
8763
  var DEBOUNCE_MS = 200;
8565
8764
  var defaultFilter = (o, q) => {
@@ -8586,41 +8785,41 @@ function Combobox({
8586
8785
  const autoId = useId11().replace(/[^a-zA-Z0-9_-]/g, "");
8587
8786
  const inputId = id ?? `nish-cb-${autoId}`;
8588
8787
  const listId = `nish-cb-list-${autoId}`;
8589
- const [open, setOpen] = useState20(false);
8590
- const [text, setText] = useState20("");
8591
- const [dirty, setDirty] = useState20(false);
8592
- const [active, setActive] = useState20(-1);
8593
- const inputRef = useRef20(null);
8594
- const listRef = useRef20(null);
8595
- const debounceRef = useRef20(void 0);
8596
- const selected = useMemo6(() => options.find((o) => o.value === value) ?? null, [options, value]);
8788
+ const [open, setOpen] = useState21(false);
8789
+ const [text, setText] = useState21("");
8790
+ const [dirty, setDirty] = useState21(false);
8791
+ const [active, setActive] = useState21(-1);
8792
+ const inputRef = useRef21(null);
8793
+ const listRef = useRef21(null);
8794
+ const debounceRef = useRef21(void 0);
8795
+ const selected = useMemo7(() => options.find((o) => o.value === value) ?? null, [options, value]);
8597
8796
  const label = selected?.label ?? value ?? "";
8598
8797
  const shown = dirty ? text : label;
8599
8798
  const hasValue = value != null && value !== "";
8600
- const visible = useMemo6(() => {
8799
+ const visible = useMemo7(() => {
8601
8800
  const serverFiltered = onQueryChange != null && filter == null;
8602
8801
  const test = filter ?? defaultFilter;
8603
8802
  const list = !dirty || serverFiltered ? options : options.filter((o) => test(o, text));
8604
8803
  return list.slice(0, MAX_SHOWN);
8605
8804
  }, [options, dirty, text, filter, onQueryChange]);
8606
- useEffect21(() => () => window.clearTimeout(debounceRef.current), []);
8607
- useEffect21(() => {
8805
+ useEffect22(() => () => window.clearTimeout(debounceRef.current), []);
8806
+ useEffect22(() => {
8608
8807
  if (!open || active < 0) return;
8609
8808
  const el = listRef.current?.querySelector(`[data-index="${active}"]`);
8610
8809
  el?.scrollIntoView?.({ block: "nearest" });
8611
8810
  }, [open, active]);
8612
- useEffect21(() => {
8811
+ useEffect22(() => {
8613
8812
  if (open) listRef.current?.scrollIntoView?.({ block: "nearest" });
8614
8813
  }, [open]);
8615
- const reset = useCallback9(() => {
8814
+ const reset = useCallback10(() => {
8616
8815
  setDirty(false);
8617
8816
  setText("");
8618
8817
  }, []);
8619
- const close = useCallback9(() => {
8818
+ const close = useCallback10(() => {
8620
8819
  setOpen(false);
8621
8820
  setActive(-1);
8622
8821
  }, []);
8623
- const select = useCallback9(
8822
+ const select = useCallback10(
8624
8823
  (opt) => {
8625
8824
  if (opt.disabled) return;
8626
8825
  onChange(opt.value, opt);
@@ -8735,8 +8934,8 @@ function Combobox({
8735
8934
  inputRef.current?.focus();
8736
8935
  }
8737
8936
  const activeId = open && active >= 0 && visible[active] ? `${listId}-opt-${active}` : void 0;
8738
- return /* @__PURE__ */ jsxs23("div", { className: cn("relative w-full min-w-0", className), children: [
8739
- /* @__PURE__ */ jsx24(
8937
+ return /* @__PURE__ */ jsxs24("div", { className: cn("relative w-full min-w-0", className), children: [
8938
+ /* @__PURE__ */ jsx25(
8740
8939
  "input",
8741
8940
  {
8742
8941
  ref: inputRef,
@@ -8766,7 +8965,7 @@ function Combobox({
8766
8965
  className: fieldClass({ size, className: "pr-11" })
8767
8966
  }
8768
8967
  ),
8769
- hasValue && !disabled ? /* @__PURE__ */ jsx24(
8968
+ hasValue && !disabled ? /* @__PURE__ */ jsx25(
8770
8969
  "button",
8771
8970
  {
8772
8971
  type: "button",
@@ -8775,11 +8974,11 @@ function Combobox({
8775
8974
  onMouseDown: (e) => e.preventDefault(),
8776
8975
  onClick: clear,
8777
8976
  className: "absolute inset-y-0 right-0 flex w-11 items-center justify-center text-th-hi3 hover:text-th-hi",
8778
- children: /* @__PURE__ */ jsx24("span", { className: "flex size-8 items-center justify-center rounded-md hover:bg-th-elevated", children: /* @__PURE__ */ jsx24(XIcon, { size: 16 }) })
8977
+ children: /* @__PURE__ */ jsx25("span", { className: "flex size-8 items-center justify-center rounded-md hover:bg-th-elevated", children: /* @__PURE__ */ jsx25(XIcon, { size: 16 }) })
8779
8978
  }
8780
8979
  ) : null,
8781
- /* @__PURE__ */ jsx24("div", { role: "status", "aria-live": "polite", className: "sr-only", children: open ? loading ? "Searching\u2026" : visible.length === 0 ? emptyText : `${visible.length} ${visible.length === 1 ? "result" : "results"}` : "" }),
8782
- open ? /* @__PURE__ */ jsxs23(
8980
+ /* @__PURE__ */ jsx25("div", { role: "status", "aria-live": "polite", className: "sr-only", children: open ? loading ? "Searching\u2026" : visible.length === 0 ? emptyText : `${visible.length} ${visible.length === 1 ? "result" : "results"}` : "" }),
8981
+ open ? /* @__PURE__ */ jsxs24(
8783
8982
  "ul",
8784
8983
  {
8785
8984
  ref: listRef,
@@ -8791,7 +8990,7 @@ function Combobox({
8791
8990
  children: [
8792
8991
  visible.map((o, i) => {
8793
8992
  const isSelected = selected?.value === o.value;
8794
- return /* @__PURE__ */ jsxs23(
8993
+ return /* @__PURE__ */ jsxs24(
8795
8994
  "li",
8796
8995
  {
8797
8996
  id: `${listId}-opt-${i}`,
@@ -8808,18 +9007,18 @@ function Combobox({
8808
9007
  o.disabled && "cursor-not-allowed opacity-50"
8809
9008
  ),
8810
9009
  children: [
8811
- /* @__PURE__ */ jsx24("span", { className: "min-w-0 flex-1 truncate", children: o.label }),
8812
- o.hint ? /* @__PURE__ */ jsx24("span", { className: "shrink-0 truncate text-xs text-th-hi3", children: o.hint }) : null,
8813
- isSelected ? /* @__PURE__ */ jsx24(CheckIcon, { size: 16, className: "shrink-0 text-th-accent" }) : null
9010
+ /* @__PURE__ */ jsx25("span", { className: "min-w-0 flex-1 truncate", children: o.label }),
9011
+ o.hint ? /* @__PURE__ */ jsx25("span", { className: "shrink-0 truncate text-xs text-th-hi3", children: o.hint }) : null,
9012
+ isSelected ? /* @__PURE__ */ jsx25(CheckIcon, { size: 16, className: "shrink-0 text-th-accent" }) : null
8814
9013
  ]
8815
9014
  },
8816
9015
  o.value
8817
9016
  );
8818
9017
  }),
8819
- loading ? /* @__PURE__ */ jsxs23("li", { role: "presentation", className: "flex min-h-11 items-center gap-2 px-3 text-sm text-th-hi3", children: [
8820
- /* @__PURE__ */ jsx24(Spinner, { size: "sm" }),
9018
+ loading ? /* @__PURE__ */ jsxs24("li", { role: "presentation", className: "flex min-h-11 items-center gap-2 px-3 text-sm text-th-hi3", children: [
9019
+ /* @__PURE__ */ jsx25(Spinner, { size: "sm" }),
8821
9020
  "Searching\u2026"
8822
- ] }) : visible.length === 0 ? /* @__PURE__ */ jsx24("li", { role: "presentation", className: "flex min-h-11 items-center px-3 text-sm text-th-hi3", children: emptyText }) : null
9021
+ ] }) : visible.length === 0 ? /* @__PURE__ */ jsx25("li", { role: "presentation", className: "flex min-h-11 items-center px-3 text-sm text-th-hi3", children: emptyText }) : null
8823
9022
  ]
8824
9023
  }
8825
9024
  ) : null
@@ -8828,10 +9027,10 @@ function Combobox({
8828
9027
 
8829
9028
  // src/components/split.tsx
8830
9029
  import {
8831
- useEffect as useEffect22,
9030
+ useEffect as useEffect23,
8832
9031
  useLayoutEffect as useLayoutEffect5,
8833
- useRef as useRef21,
8834
- useState as useState21
9032
+ useRef as useRef22,
9033
+ useState as useState22
8835
9034
  } from "react";
8836
9035
 
8837
9036
  // src/split-layout.ts
@@ -9238,7 +9437,7 @@ function isValidLayout(node, count) {
9238
9437
  }
9239
9438
 
9240
9439
  // src/components/split.tsx
9241
- import { Fragment as Fragment13, jsx as jsx25, jsxs as jsxs24 } from "react/jsx-runtime";
9440
+ import { Fragment as Fragment14, jsx as jsx26, jsxs as jsxs25 } from "react/jsx-runtime";
9242
9441
  function nodeAt(node, path) {
9243
9442
  let cur = node;
9244
9443
  for (const i of path) {
@@ -9264,14 +9463,14 @@ function equalizeAt(node, path) {
9264
9463
  }
9265
9464
  function SplitDividers({ layout, w, h, gap, onResize, onDragChange, minPane, barInset = 0 }) {
9266
9465
  const coarse = useMediaQuery("(pointer: coarse)");
9267
- const drag = useRef21(null);
9466
+ const drag = useRef22(null);
9268
9467
  const hit = coarse ? 44 : 24;
9269
9468
  const baseMin = minPane ?? { w: 160, h: 90 };
9270
- const onDragChangeRef = useRef21(onDragChange);
9271
- useEffect22(() => {
9469
+ const onDragChangeRef = useRef22(onDragChange);
9470
+ useEffect23(() => {
9272
9471
  onDragChangeRef.current = onDragChange;
9273
9472
  });
9274
- useEffect22(
9473
+ useEffect23(
9275
9474
  () => () => {
9276
9475
  if (drag.current) {
9277
9476
  drag.current = null;
@@ -9337,11 +9536,11 @@ function SplitDividers({ layout, w, h, gap, onResize, onDragChange, minPane, bar
9337
9536
  reset(d);
9338
9537
  }
9339
9538
  };
9340
- return /* @__PURE__ */ jsx25(Fragment13, { children: dividers.map((d) => {
9539
+ return /* @__PURE__ */ jsx26(Fragment14, { children: dividers.map((d) => {
9341
9540
  const vertical = d.dir === "row";
9342
9541
  const pad = (hit - (vertical ? d.w : d.h)) / 2;
9343
9542
  const style = vertical ? { left: d.x - pad, top: d.y + barInset, width: d.w + pad * 2, height: Math.max(0, d.h - barInset) } : { left: d.x, top: d.y - (barInset > 0 ? pad * 2 : pad), width: d.w, height: d.h + pad * 2 };
9344
- return /* @__PURE__ */ jsx25(
9543
+ return /* @__PURE__ */ jsx26(
9345
9544
  "div",
9346
9545
  {
9347
9546
  role: "separator",
@@ -9362,7 +9561,7 @@ function SplitDividers({ layout, w, h, gap, onResize, onDragChange, minPane, bar
9362
9561
  "group absolute z-20 flex items-center justify-center outline-none",
9363
9562
  vertical ? "cursor-col-resize" : "cursor-row-resize"
9364
9563
  ),
9365
- children: /* @__PURE__ */ jsx25(
9564
+ children: /* @__PURE__ */ jsx26(
9366
9565
  "span",
9367
9566
  {
9368
9567
  className: cn(
@@ -9392,14 +9591,14 @@ function SplitStage({
9392
9591
  children,
9393
9592
  className
9394
9593
  }) {
9395
- const ref = useRef21(null);
9396
- const [size, setSize] = useState21({ w: 0, h: 0 });
9397
- const [resizing, setResizing] = useState21(false);
9594
+ const ref = useRef22(null);
9595
+ const [size, setSize] = useState22({ w: 0, h: 0 });
9596
+ const [resizing, setResizing] = useState22(false);
9398
9597
  const reduced = useMediaQuery("(prefers-reduced-motion: reduce)");
9399
9598
  const showDividers = resizable && !!layout && slots.length > 1;
9400
9599
  if (!showDividers && resizing) setResizing(false);
9401
- const onSizeRef = useRef21(onSize);
9402
- useEffect22(() => {
9600
+ const onSizeRef = useRef22(onSize);
9601
+ useEffect23(() => {
9403
9602
  onSizeRef.current = onSize;
9404
9603
  });
9405
9604
  useLayoutEffect5(() => {
@@ -9416,7 +9615,7 @@ function SplitStage({
9416
9615
  ro.observe(el);
9417
9616
  return () => ro.disconnect();
9418
9617
  }, []);
9419
- useEffect22(() => {
9618
+ useEffect23(() => {
9420
9619
  onSizeRef.current?.(size);
9421
9620
  }, [size]);
9422
9621
  const measured = size.w > 0 && size.h > 0;
@@ -9424,13 +9623,13 @@ function SplitStage({
9424
9623
  const active = dragging || resizing;
9425
9624
  const move = animate && !reduced && !active;
9426
9625
  const transition = move ? "left 180ms ease-out, top 180ms ease-out, width 180ms ease-out, height 180ms ease-out" : "none";
9427
- return /* @__PURE__ */ jsxs24("div", { ref, className: cn("relative overflow-hidden", className), ...active ? { "data-dragging": "" } : {}, children: [
9626
+ return /* @__PURE__ */ jsxs25("div", { ref, className: cn("relative overflow-hidden", className), ...active ? { "data-dragging": "" } : {}, children: [
9428
9627
  layout && // DOM order follows `items`, not slot order, so a swap never moves a node.
9429
9628
  items2.map((id) => {
9430
9629
  const slot = slots.indexOf(id);
9431
9630
  const rect = slot >= 0 ? rects[slot] : void 0;
9432
9631
  if (!rect) return null;
9433
- return /* @__PURE__ */ jsx25(
9632
+ return /* @__PURE__ */ jsx26(
9434
9633
  "div",
9435
9634
  {
9436
9635
  "data-split-pane": id,
@@ -9447,7 +9646,7 @@ function SplitStage({
9447
9646
  id
9448
9647
  );
9449
9648
  }),
9450
- showDividers && measured && layout && /* @__PURE__ */ jsx25(
9649
+ showDividers && measured && layout && /* @__PURE__ */ jsx26(
9451
9650
  SplitDividers,
9452
9651
  {
9453
9652
  layout,
@@ -9465,7 +9664,7 @@ function SplitStage({
9465
9664
  }
9466
9665
  function LayoutPresetIcon({ node, width = 56, height = 36, className }) {
9467
9666
  const rects = computeRects(node, width - 4, height - 4, 2);
9468
- return /* @__PURE__ */ jsx25(
9667
+ return /* @__PURE__ */ jsx26(
9469
9668
  "svg",
9470
9669
  {
9471
9670
  width,
@@ -9475,7 +9674,7 @@ function LayoutPresetIcon({ node, width = 56, height = 36, className }) {
9475
9674
  "aria-hidden": "true",
9476
9675
  focusable: "false",
9477
9676
  ...className ? { className } : {},
9478
- children: rects.map((r, i) => /* @__PURE__ */ jsx25(
9677
+ children: rects.map((r, i) => /* @__PURE__ */ jsx26(
9479
9678
  "rect",
9480
9679
  {
9481
9680
  x: r.x + 2.5,
@@ -9506,7 +9705,7 @@ function LayoutPresetPicker({
9506
9705
  className,
9507
9706
  label = "Layout presets"
9508
9707
  }) {
9509
- const group = useRef21(null);
9708
+ const group = useRef22(null);
9510
9709
  const onKeyDown = (e) => {
9511
9710
  const n = options.length;
9512
9711
  if (n === 0) return;
@@ -9523,7 +9722,7 @@ function LayoutPresetPicker({
9523
9722
  onChange(next.id);
9524
9723
  group.current?.querySelectorAll('[role="radio"]')[to]?.focus();
9525
9724
  };
9526
- return /* @__PURE__ */ jsxs24(
9725
+ return /* @__PURE__ */ jsxs25(
9527
9726
  "div",
9528
9727
  {
9529
9728
  className: cn(
@@ -9532,7 +9731,7 @@ function LayoutPresetPicker({
9532
9731
  className
9533
9732
  ),
9534
9733
  children: [
9535
- /* @__PURE__ */ jsx25("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx25(ScrollRow, { label, children: /* @__PURE__ */ jsx25(
9734
+ /* @__PURE__ */ jsx26("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx26(ScrollRow, { label, children: /* @__PURE__ */ jsx26(
9536
9735
  "div",
9537
9736
  {
9538
9737
  ref: group,
@@ -9543,7 +9742,7 @@ function LayoutPresetPicker({
9543
9742
  children: options.map((o, i) => {
9544
9743
  const on = value === o.id;
9545
9744
  const hasValue = options.some((x) => x.id === value);
9546
- return /* @__PURE__ */ jsx25(Tooltip, { tip: o.hint, side: "bottom", focusable: false, children: /* @__PURE__ */ jsxs24(
9745
+ return /* @__PURE__ */ jsx26(Tooltip, { tip: o.hint, side: "bottom", focusable: false, children: /* @__PURE__ */ jsxs25(
9547
9746
  "button",
9548
9747
  {
9549
9748
  type: "button",
@@ -9558,8 +9757,8 @@ function LayoutPresetPicker({
9558
9757
  on ? "border-th-accent bg-th-accent-soft text-th-hi" : "border-transparent text-th-hi3 hover:bg-th-elevated hover:text-th-hi2"
9559
9758
  ),
9560
9759
  children: [
9561
- /* @__PURE__ */ jsx25(LayoutPresetIcon, { node: o.node }),
9562
- /* @__PURE__ */ jsx25("span", { className: "whitespace-nowrap", children: o.label })
9760
+ /* @__PURE__ */ jsx26(LayoutPresetIcon, { node: o.node }),
9761
+ /* @__PURE__ */ jsx26("span", { className: "whitespace-nowrap", children: o.label })
9563
9762
  ]
9564
9763
  }
9565
9764
  ) }, o.id);
@@ -9567,15 +9766,15 @@ function LayoutPresetPicker({
9567
9766
  }
9568
9767
  ) }) }),
9569
9768
  actions,
9570
- note ? /* @__PURE__ */ jsx25("p", { className: "hidden shrink-0 text-xs text-th-hi3 lg:block", children: note }) : null
9769
+ note ? /* @__PURE__ */ jsx26("p", { className: "hidden shrink-0 text-xs text-th-hi3 lg:block", children: note }) : null
9571
9770
  ]
9572
9771
  }
9573
9772
  );
9574
9773
  }
9575
9774
 
9576
9775
  // src/components/media.tsx
9577
- import { useState as useState22 } from "react";
9578
- import { Fragment as Fragment14, jsx as jsx26, jsxs as jsxs25 } from "react/jsx-runtime";
9776
+ import { useState as useState23 } from "react";
9777
+ import { Fragment as Fragment15, jsx as jsx27, jsxs as jsxs26 } from "react/jsx-runtime";
9579
9778
  function safeSrc(src) {
9580
9779
  if (!src) return null;
9581
9780
  const s = src.trim().replace(/[\t\n\r]/g, "").replace(/\\/g, "/");
@@ -9594,11 +9793,11 @@ var THUMB_BOX = {
9594
9793
  };
9595
9794
  function MediaThumb({ src, shape = "wide", size = "md", fallback, alt = "", className }) {
9596
9795
  const url = safeSrc(src);
9597
- const [failedUrl, setFailedUrl] = useState22(null);
9796
+ const [failedUrl, setFailedUrl] = useState23(null);
9598
9797
  const failed = failedUrl !== null && failedUrl === url;
9599
9798
  const box = cn("relative block shrink-0 overflow-hidden bg-th-elevated", THUMB_BOX[shape][size], className);
9600
9799
  if (url && !failed) {
9601
- return /* @__PURE__ */ jsx26("span", { className: box, children: /* @__PURE__ */ jsx26(
9800
+ return /* @__PURE__ */ jsx27("span", { className: box, children: /* @__PURE__ */ jsx27(
9602
9801
  "img",
9603
9802
  {
9604
9803
  src: url,
@@ -9612,7 +9811,7 @@ function MediaThumb({ src, shape = "wide", size = "md", fallback, alt = "", clas
9612
9811
  }
9613
9812
  ) });
9614
9813
  }
9615
- return /* @__PURE__ */ jsx26("span", { className: cn(box, "flex items-center justify-center text-th-hi3 [&>svg]:size-5"), role: alt ? "img" : void 0, "aria-label": alt || void 0, children: fallback });
9814
+ return /* @__PURE__ */ jsx27("span", { className: cn(box, "flex items-center justify-center text-th-hi3 [&>svg]:size-5"), role: alt ? "img" : void 0, "aria-label": alt || void 0, children: fallback });
9616
9815
  }
9617
9816
  function MediaRow({
9618
9817
  thumbnailUrl,
@@ -9637,11 +9836,11 @@ function MediaRow({
9637
9836
  const size = thumbSize ?? (small ? "sm" : "md");
9638
9837
  const badgeSize = small ? "xs" : "sm";
9639
9838
  const hasBadges = live !== void 0 || !!badges;
9640
- const subtitle = meta || detail ? /* @__PURE__ */ jsxs25(Fragment14, { children: [
9641
- meta ? /* @__PURE__ */ jsx26("span", { className: "block truncate", children: meta }) : null,
9642
- detail ? /* @__PURE__ */ jsx26("span", { className: cn("block truncate text-th-hi3", compact ? "text-3xs" : "text-xs"), children: detail }) : null
9839
+ const subtitle = meta || detail ? /* @__PURE__ */ jsxs26(Fragment15, { children: [
9840
+ meta ? /* @__PURE__ */ jsx27("span", { className: "block truncate", children: meta }) : null,
9841
+ detail ? /* @__PURE__ */ jsx27("span", { className: cn("block truncate text-th-hi3", compact ? "text-3xs" : "text-xs"), children: detail }) : null
9643
9842
  ] }) : void 0;
9644
- return /* @__PURE__ */ jsx26(
9843
+ return /* @__PURE__ */ jsx27(
9645
9844
  ListRow,
9646
9845
  {
9647
9846
  as,
@@ -9651,13 +9850,13 @@ function MediaRow({
9651
9850
  href,
9652
9851
  onClick,
9653
9852
  chevron,
9654
- icon: /* @__PURE__ */ jsx26(MediaThumb, { src: thumbnailUrl, shape: thumbShape, size, fallback }),
9853
+ icon: /* @__PURE__ */ jsx27(MediaThumb, { src: thumbnailUrl, shape: thumbShape, size, fallback }),
9655
9854
  title,
9656
9855
  titleLines: 2,
9657
9856
  subtitle,
9658
- trailing: hasBadges || trailing ? /* @__PURE__ */ jsxs25("span", { className: "flex items-center gap-2", children: [
9659
- hasBadges ? /* @__PURE__ */ jsxs25("span", { className: "flex flex-col items-end gap-1", children: [
9660
- live === true ? /* @__PURE__ */ jsx26(Badge, { tone: "loss", size: badgeSize, children: "Live" }) : live === false ? /* @__PURE__ */ jsx26(Badge, { tone: "neutral", size: badgeSize, children: "Offline" }) : null,
9857
+ trailing: hasBadges || trailing ? /* @__PURE__ */ jsxs26("span", { className: "flex items-center gap-2", children: [
9858
+ hasBadges ? /* @__PURE__ */ jsxs26("span", { className: "flex flex-col items-end gap-1", children: [
9859
+ live === true ? /* @__PURE__ */ jsx27(Badge, { tone: "loss", size: badgeSize, children: "Live" }) : live === false ? /* @__PURE__ */ jsx27(Badge, { tone: "neutral", size: badgeSize, children: "Offline" }) : null,
9661
9860
  badges
9662
9861
  ] }) : null,
9663
9862
  trailing
@@ -9666,7 +9865,7 @@ function MediaRow({
9666
9865
  );
9667
9866
  }
9668
9867
  function MediaChip({ thumbnailUrl, label, onClick, action, className }) {
9669
- return /* @__PURE__ */ jsxs25(
9868
+ return /* @__PURE__ */ jsxs26(
9670
9869
  "button",
9671
9870
  {
9672
9871
  type: "button",
@@ -9677,19 +9876,19 @@ function MediaChip({ thumbnailUrl, label, onClick, action, className }) {
9677
9876
  className
9678
9877
  ),
9679
9878
  children: [
9680
- /* @__PURE__ */ jsx26("span", { className: "block aspect-video w-10 shrink-0 overflow-hidden rounded-[var(--nish-radius-sm)] bg-th-elevated", children: /* @__PURE__ */ jsx26(MediaChipImage, { src: thumbnailUrl }) }),
9681
- /* @__PURE__ */ jsx26("span", { className: "min-w-0 max-w-56 truncate", children: label }),
9682
- action ? /* @__PURE__ */ jsx26("span", { className: "shrink-0 text-th-accent", children: action }) : null
9879
+ /* @__PURE__ */ jsx27("span", { className: "block aspect-video w-10 shrink-0 overflow-hidden rounded-[var(--nish-radius-sm)] bg-th-elevated", children: /* @__PURE__ */ jsx27(MediaChipImage, { src: thumbnailUrl }) }),
9880
+ /* @__PURE__ */ jsx27("span", { className: "min-w-0 max-w-56 truncate", children: label }),
9881
+ action ? /* @__PURE__ */ jsx27("span", { className: "shrink-0 text-th-accent", children: action }) : null
9683
9882
  ]
9684
9883
  }
9685
9884
  );
9686
9885
  }
9687
9886
  function MediaChipImage({ src }) {
9688
9887
  const url = safeSrc(src);
9689
- const [failedUrl, setFailedUrl] = useState22(null);
9888
+ const [failedUrl, setFailedUrl] = useState23(null);
9690
9889
  const failed = failedUrl !== null && failedUrl === url;
9691
9890
  if (!url || failed) return null;
9692
- return /* @__PURE__ */ jsx26(
9891
+ return /* @__PURE__ */ jsx27(
9693
9892
  "img",
9694
9893
  {
9695
9894
  src: url,
@@ -9797,6 +9996,7 @@ export {
9797
9996
  SectionNav,
9798
9997
  Segmented,
9799
9998
  Select,
9999
+ ServiceTokensSection,
9800
10000
  SettingRow,
9801
10001
  SettingsIcon,
9802
10002
  SettingsSection,
@@ -9904,6 +10104,7 @@ export {
9904
10104
  useSaveStatus,
9905
10105
  useScrollEdges,
9906
10106
  useScrollSpy,
10107
+ useServiceTokens,
9907
10108
  useStuck,
9908
10109
  useTheme,
9909
10110
  useToast,