@cboxdk/cbox-ui 0.10.3 → 0.11.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
@@ -2,9 +2,9 @@ import { cn } from './chunk-QJ4T7RR2.js';
2
2
  export { cn, niceTicks, timeTicks } from './chunk-QJ4T7RR2.js';
3
3
  import { defineCboxAppSwitcher, subscribeKnownAppCatalog, readKnownAppCatalog, secureIconUrl, initials, parseAppCatalog, signInTarget, rememberAppCatalog } from './chunk-AJCYF7SS.js';
4
4
  export { authorizeHref, parseAppCatalog, readKnownAppCatalog, rememberAppCatalog, secureIconUrl, signInTarget } from './chunk-AJCYF7SS.js';
5
- import { createContext, useContext, useMemo, useSyncExternalStore, useState, useEffect, useCallback, useRef, createElement, useId, useLayoutEffect, useImperativeHandle } from 'react';
5
+ import { createContext, useContext, useMemo, useSyncExternalStore, useState, useId, useEffect, useCallback, useRef, createElement, useLayoutEffect, useImperativeHandle } from 'react';
6
6
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import { Zap, Webhook, Wallet, Users, Timer, Tag, Sparkles, ShieldCheck, Shield, Settings, Server, Send, Search, Rocket, Receipt, Plug, Percent, Package, Network, MessageSquare, Mail, Lock, List, LifeBuoy, Layers, LayoutGrid, LayoutDashboard, Key, Inbox, Home, HardDrive, Globe, GitBranch, Folder, FileText, Database, CreditCard, Code, Cloud, Clock, Calendar, Building2, Briefcase, Boxes, BookOpen, Bell, BarChart3, Activity, PinOff, Pin, PanelLeftOpen, PanelLeftClose, Menu, ChevronsUpDown, CircleHelp, ArrowLeft, ArrowUpRight, X, CircleAlert, Ticket, UserRound, CornerDownLeft, ArrowRight, Circle, Monitor, Sun, Moon, ChevronRight, LogOut, Check, Plus } from 'lucide-react';
7
+ import { Zap, Webhook, Wallet, Users, Timer, Tag, Sparkles, ShieldCheck, Shield, Settings, Server, Send, Search, Rocket, Receipt, Plug, Percent, Package, Network, MessageSquare, Mail, Lock, List, LifeBuoy, Layers, LayoutGrid, LayoutDashboard, Key, Inbox, Home, HardDrive, Globe, GitBranch, Folder, FileText, Database, CreditCard, Code, Cloud, Clock, Calendar, Building2, Briefcase, Boxes, BookOpen, Bell, BarChart3, Activity, ChevronDown, Plus, PinOff, Pin, PanelLeftOpen, PanelLeftClose, ChevronsUpDown, CircleHelp, ArrowLeftRight, CornerDownLeft, ArrowRight, MoreHorizontal, ChevronLeft, X, ArrowUpRight, ArrowUp, CircleAlert, UserRound, Ticket, ChevronRight, ArrowLeft, Circle, Monitor, Sun, Moon, LogOut, Check } from 'lucide-react';
8
8
 
9
9
  var CboxIdContext = createContext(null);
10
10
  function CboxIdProvider({
@@ -76,6 +76,10 @@ function useShell() {
76
76
  if (api === null) throw new Error("[cbox-ui] Shell parts must be rendered inside <CboxShell>.");
77
77
  return api;
78
78
  }
79
+ function useShellCreate() {
80
+ const api = useContext(ShellContext);
81
+ return api === null || api.renderCreate === void 0 ? null : { openCreate: api.openCreate };
82
+ }
79
83
  function useShellHelp() {
80
84
  const api = useContext(ShellContext);
81
85
  return api === null ? null : { toggleHelp: api.toggleHelp, openArticle: api.openArticle, ask: api.ask };
@@ -157,7 +161,7 @@ function Popover({
157
161
  return () => document.removeEventListener("pointerdown", down, true);
158
162
  }, [open, anchor, onClose]);
159
163
  if (!open) return null;
160
- const style = position === null ? { position: "fixed", top: 0, left: 0, visibility: "hidden" } : { position: "fixed", top: position.top, bottom: position.bottom, left: position.left, maxHeight: position.maxHeight };
164
+ const style = position === null ? { position: "fixed", top: 0, left: 0, opacity: 0, pointerEvents: "none" } : { position: "fixed", top: position.top, bottom: position.bottom, left: position.left, maxHeight: position.maxHeight };
161
165
  return /* @__PURE__ */ jsx(
162
166
  "div",
163
167
  {
@@ -340,8 +344,8 @@ var DEFAULT_FORMATS = [
340
344
  var FALLBACK_ZONES = ["UTC", "Europe/Copenhagen", "Europe/London", "Europe/Berlin", "Europe/Stockholm", "Europe/Oslo", "America/New_York", "America/Los_Angeles", "Asia/Tokyo"];
341
345
  function timeZones() {
342
346
  const supported = Intl.supportedValuesOf;
343
- const zones = typeof supported === "function" ? supported("timeZone") : FALLBACK_ZONES;
344
- return zones.map((zone) => ({ code: zone, label: zone.replace(/_/g, " ") }));
347
+ const zones2 = typeof supported === "function" ? supported("timeZone") : FALLBACK_ZONES;
348
+ return zones2.map((zone) => ({ code: zone, label: zone.replace(/_/g, " ") }));
345
349
  }
346
350
  function Avatar({ size = 30 }) {
347
351
  const { shell } = useShell();
@@ -357,7 +361,7 @@ function AccountMenu({ inline = false, onDone }) {
357
361
  const tab = inline ? 0 : -1;
358
362
  const languages = account.languages ?? DEFAULT_LANGUAGES;
359
363
  const formats = account.formats ?? DEFAULT_FORMATS;
360
- const zones = useMemo(() => view === "timeZone" ? timeZones() : [], [view]);
364
+ const zones2 = useMemo(() => view === "timeZone" ? timeZones() : [], [view]);
361
365
  useEffect(() => {
362
366
  if (view !== "main" || inline) return;
363
367
  menu.current?.querySelector('[role="menuitem"]')?.focus();
@@ -381,7 +385,7 @@ function AccountMenu({ inline = false, onDone }) {
381
385
  ] });
382
386
  if (view === "timeZone") return /* @__PURE__ */ jsxs("div", { className: "cbx-menu cbx-menu-account", children: [
383
387
  back,
384
- /* @__PURE__ */ jsx(OptionList, { label: t("Time zone"), options: zones, current: preferences.timeZone, onPick: pick("timeZone") })
388
+ /* @__PURE__ */ jsx(OptionList, { label: t("Time zone"), options: zones2, current: preferences.timeZone, onPick: pick("timeZone") })
385
389
  ] });
386
390
  const themes = [
387
391
  { value: "system", label: t("System"), icon: Monitor },
@@ -631,7 +635,7 @@ function forgetShellCatalog() {
631
635
  }
632
636
 
633
637
  // src/shell/data.ts
634
- var TONES = ["production", "sandbox", "neutral"];
638
+ var TONES = ["production", "sandbox", "neutral", "staging", "preview", "development"];
635
639
  function initialsOf(name) {
636
640
  const words = name.trim().split(/\s+/).filter(Boolean);
637
641
  const letters = words.length > 1 ? (words[0][0] ?? "") + (words[1][0] ?? "") : name.trim().slice(0, 2);
@@ -648,6 +652,9 @@ function toItem(value) {
648
652
  if (typeof row.label === "string" && row.label !== "") item.label = row.label;
649
653
  const test = row.testData ?? row.test_data;
650
654
  if (typeof test === "boolean") item.testData = test;
655
+ if (typeof row.live === "boolean") item.live = row.live;
656
+ if (typeof row.group === "string" && row.group !== "") item.group = row.group;
657
+ if (typeof row.description === "string" && row.description !== "") item.description = row.description;
651
658
  return item;
652
659
  }
653
660
  function parseListPage(body) {
@@ -687,16 +694,19 @@ function environmentFor(environments, currentName) {
687
694
  }
688
695
  return environments[0];
689
696
  }
690
- function switchPayload(levels, chosen, returnTo) {
691
- const payload = {};
697
+ function switchBody(levels, chosen, from) {
698
+ const select = {};
692
699
  const deepest = Math.max(-1, ...levels.map((level, index) => chosen[level.key] !== void 0 ? index : -1));
693
700
  levels.forEach((level, index) => {
694
701
  const id = chosen[level.key];
695
- if (id !== void 0) payload[level.key] = id;
696
- else if (index < deepest) payload[level.key] = level.current.id;
702
+ if (id !== void 0) select[level.key] = id;
703
+ else if (index < deepest) select[level.key] = level.current.id;
697
704
  });
698
- payload.return_to = returnTo;
699
- return payload;
705
+ return { select, from };
706
+ }
707
+ function switchPayload(levels, chosen, returnTo) {
708
+ const { select } = switchBody(levels, chosen, returnTo);
709
+ return { ...select, return_to: returnTo };
700
710
  }
701
711
  function cookie(name) {
702
712
  if (typeof document === "undefined") return null;
@@ -782,20 +792,58 @@ var defaultNavigate = (url, options = {}) => {
782
792
  const fields = { ...options.data ?? {} };
783
793
  const token = csrfToken();
784
794
  if (token !== null) fields._token = token;
785
- for (const [name, value] of Object.entries(fields)) {
795
+ for (const [name, value] of formFields(fields)) {
786
796
  const input = document.createElement("input");
787
797
  input.type = "hidden";
788
798
  input.name = name;
789
- input.value = String(value);
799
+ input.value = value;
790
800
  form.append(input);
791
801
  }
792
802
  document.body.append(form);
793
803
  form.submit();
794
804
  };
805
+ function formFields(data, prefix) {
806
+ const out = [];
807
+ for (const [key, value] of Object.entries(data)) {
808
+ const name = prefix === void 0 ? key : `${prefix}[${key}]`;
809
+ if (value === void 0 || value === null) continue;
810
+ if (typeof value === "object" && !Array.isArray(value)) out.push(...formFields(value, name));
811
+ else if (Array.isArray(value)) value.forEach((item, index) => out.push([`${name}[${index}]`, String(item)]));
812
+ else out.push([name, String(value)]);
813
+ }
814
+ return out;
815
+ }
795
816
  function currentLocation() {
796
817
  if (typeof window === "undefined") return "/";
797
818
  return window.location.pathname + window.location.search + window.location.hash;
798
819
  }
820
+ function isLive(item) {
821
+ if (item.live !== void 0) return item.live;
822
+ if (item.testData === true) return false;
823
+ if (item.tone !== void 0) return item.tone === "production";
824
+ return void 0;
825
+ }
826
+ function environmentLevel(levels) {
827
+ return levels.find((level) => level.key === "environment");
828
+ }
829
+ function quickEnvironments(items, current) {
830
+ const picks = [current];
831
+ const live = items.find((item) => item.id !== current.id && isLive(item) === true);
832
+ if (live !== void 0) picks.push(live);
833
+ const test = items.find((item) => item.id !== current.id && item.id !== live?.id && isLive(item) !== true);
834
+ if (test !== void 0) picks.push(test);
835
+ return picks.slice(0, 3);
836
+ }
837
+ function groupItems(items) {
838
+ const runs = /* @__PURE__ */ new Map();
839
+ for (const item of items) {
840
+ const key = item.group ?? "";
841
+ const run = runs.get(key) ?? { group: item.group, items: [] };
842
+ run.items.push(item);
843
+ runs.set(key, run);
844
+ }
845
+ return Array.from(runs.values());
846
+ }
799
847
  var DEBOUNCE_MS = 120;
800
848
  var PAGE_SIZE = 25;
801
849
  function pageSize(url) {
@@ -901,7 +949,7 @@ function ToneSquare({ tone }) {
901
949
  function isEnvironmentLevel(level) {
902
950
  return level.key === "environment";
903
951
  }
904
- function LevelPane({ level, parent, currentId, heading, viewAll = true, searchable = true, autoFocus = false, chevron = false, createLabel, onPick, onPreview, onArrowRight, onArrowLeft, handle, className }) {
952
+ function LevelPane({ level, parent, currentId, heading, viewAll = true, searchable = true, autoFocus = false, chevron = false, createLabel: createLabel2, onPick, onPreview, onArrowRight, onArrowLeft, handle, className }) {
905
953
  const { t, Link, navigate } = useShell();
906
954
  const [q, setQ] = useState("");
907
955
  const [active, setActiveRow] = useState(-1);
@@ -929,7 +977,9 @@ function LevelPane({ level, parent, currentId, heading, viewAll = true, searchab
929
977
  });
930
978
  }, [list.status, list.items, q, currentId]);
931
979
  useEffect(() => {
932
- if (autoFocus && searchable && canAutofocus()) input.current?.focus();
980
+ if (!autoFocus) return;
981
+ if (searchable && canAutofocus()) input.current?.focus();
982
+ else box.current?.focus({ preventScroll: true });
933
983
  }, [autoFocus, searchable]);
934
984
  const focusSelf = useCallback(() => {
935
985
  if (searchable) input.current?.focus();
@@ -939,7 +989,7 @@ function LevelPane({ level, parent, currentId, heading, viewAll = true, searchab
939
989
  useImperativeHandle(handle, () => ({ focus: focusSelf }), [focusSelf]);
940
990
  const optionId = (index) => `${id}-option-${index}`;
941
991
  const allId = `${id}-all`;
942
- const canCreate = level.createUrl !== void 0 && createLabel !== void 0;
992
+ const canCreate = level.createUrl !== void 0 && createLabel2 !== void 0;
943
993
  const viewAllLink = () => viewAll ? document.getElementById(allId) : null;
944
994
  const createAction = () => canCreate && !creating ? createButton.current : null;
945
995
  useEffect(() => {
@@ -974,6 +1024,10 @@ function LevelPane({ level, parent, currentId, heading, viewAll = true, searchab
974
1024
  };
975
1025
  const onKeyDown = (event) => {
976
1026
  if (event.target instanceof HTMLElement && event.target.closest(".cbx-create")) return;
1027
+ if (searchable && event.target === box.current && event.key.length === 1 && !event.metaKey && !event.ctrlKey && !event.altKey) {
1028
+ input.current?.focus();
1029
+ return;
1030
+ }
977
1031
  if (event.target instanceof HTMLElement && event.target.closest("[data-pane-action]")) return;
978
1032
  const last = options.length - 1;
979
1033
  switch (event.key) {
@@ -1089,7 +1143,7 @@ function LevelPane({ level, parent, currentId, heading, viewAll = true, searchab
1089
1143
  role: "listbox",
1090
1144
  "aria-label": heading,
1091
1145
  tabIndex: searchable ? -1 : 0,
1092
- "aria-activedescendant": searchable ? void 0 : activeId,
1146
+ "aria-activedescendant": activeId,
1093
1147
  className: "cbx-listbox",
1094
1148
  children: options.map((option, index) => {
1095
1149
  if (option.kind === "more") {
@@ -1129,12 +1183,12 @@ function LevelPane({ level, parent, currentId, heading, viewAll = true, searchab
1129
1183
  ]
1130
1184
  }
1131
1185
  ),
1132
- canCreate && /* @__PURE__ */ jsx("div", { className: "cbx-pane-foot", children: creating ? /* @__PURE__ */ jsx(InlineCreate, { level, parent, label: createLabel, onCancel: () => {
1186
+ canCreate && /* @__PURE__ */ jsx("div", { className: "cbx-pane-foot", children: creating ? /* @__PURE__ */ jsx(InlineCreate, { level, parent, label: createLabel2, onCancel: () => {
1133
1187
  setCreating(false);
1134
1188
  focusSelf();
1135
1189
  } }) : /* @__PURE__ */ jsxs("button", { ref: createButton, type: "button", className: "cbx-row cbx-row-action", "data-pane-action": "create", onClick: () => setCreating(true), onKeyDown: (event) => onActionKeyDown(event, "create"), children: [
1136
1190
  /* @__PURE__ */ jsx(Plus, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
1137
- /* @__PURE__ */ jsx("span", { className: "cbx-row-name", children: createLabel })
1191
+ /* @__PURE__ */ jsx("span", { className: "cbx-row-name", children: createLabel2 })
1138
1192
  ] }) })
1139
1193
  ] });
1140
1194
  }
@@ -1320,6 +1374,60 @@ function CascadeLabel({ levels }) {
1320
1374
  ] })
1321
1375
  ] });
1322
1376
  }
1377
+ var SHELL_ICONS = {
1378
+ activity: Activity,
1379
+ "bar-chart": BarChart3,
1380
+ bell: Bell,
1381
+ "book-open": BookOpen,
1382
+ boxes: Boxes,
1383
+ briefcase: Briefcase,
1384
+ building: Building2,
1385
+ calendar: Calendar,
1386
+ clock: Clock,
1387
+ cloud: Cloud,
1388
+ code: Code,
1389
+ "credit-card": CreditCard,
1390
+ database: Database,
1391
+ "file-text": FileText,
1392
+ folder: Folder,
1393
+ "git-branch": GitBranch,
1394
+ globe: Globe,
1395
+ "hard-drive": HardDrive,
1396
+ home: Home,
1397
+ inbox: Inbox,
1398
+ key: Key,
1399
+ "layout-dashboard": LayoutDashboard,
1400
+ "layout-grid": LayoutGrid,
1401
+ layers: Layers,
1402
+ "life-buoy": LifeBuoy,
1403
+ list: List,
1404
+ lock: Lock,
1405
+ mail: Mail,
1406
+ "message-square": MessageSquare,
1407
+ network: Network,
1408
+ package: Package,
1409
+ percent: Percent,
1410
+ plug: Plug,
1411
+ receipt: Receipt,
1412
+ rocket: Rocket,
1413
+ search: Search,
1414
+ send: Send,
1415
+ server: Server,
1416
+ settings: Settings,
1417
+ shield: Shield,
1418
+ "shield-check": ShieldCheck,
1419
+ sparkles: Sparkles,
1420
+ tag: Tag,
1421
+ timer: Timer,
1422
+ users: Users,
1423
+ wallet: Wallet,
1424
+ webhook: Webhook,
1425
+ zap: Zap
1426
+ };
1427
+ function resolveIcon(name, extra = {}) {
1428
+ if (name === void 0) return Circle;
1429
+ return extra[name] ?? SHELL_ICONS[name] ?? Circle;
1430
+ }
1323
1431
 
1324
1432
  // src/shell/help-store.ts
1325
1433
  var INITIAL_HELP_STATE = {
@@ -1399,6 +1507,14 @@ var SUPPORT_TAG = "cbox-support";
1399
1507
  function useHelpState(store, select) {
1400
1508
  return useSyncExternalStore(store.subscribe, () => select(store.get()), () => select(store.get()));
1401
1509
  }
1510
+ function useUnreadCount(store, sent) {
1511
+ const loaded = useHelpState(store, (state) => state.updatesStatus === "ready" ? state.updates.filter((update) => update.unread).length : null);
1512
+ return loaded ?? sent ?? 0;
1513
+ }
1514
+ function helpTopicName(shell) {
1515
+ const area = shell.nav.areas.find((item) => item.key === shell.nav.activeArea);
1516
+ return shell.page?.title ?? area?.label ?? shell.app.name;
1517
+ }
1402
1518
  function contextTrail(shell) {
1403
1519
  return shell.context.levels.map((level) => level.current.name).join(" / ");
1404
1520
  }
@@ -1435,7 +1551,7 @@ function whenSupportReady(host, timeoutMs = 6e3) {
1435
1551
  attempt();
1436
1552
  });
1437
1553
  }
1438
- function HelpColumn({ docked }) {
1554
+ function HelpColumn({ docked, mobile = false }) {
1439
1555
  const { shell, t, help: store, toggleHelp, navigate, preferences } = useShell();
1440
1556
  const formatDate = useShortDate(preferences.regionalFormat ?? preferences.locale, preferences.timeZone);
1441
1557
  const open = useHelpState(store, (state) => helpVisible(state, docked));
@@ -1449,6 +1565,8 @@ function HelpColumn({ docked }) {
1449
1565
  const [results, setResults] = useState(null);
1450
1566
  const [question, setQuestion] = useState("");
1451
1567
  const [chatProblem, setChatProblem] = useState(false);
1568
+ const [asked, setAsked] = useState(false);
1569
+ const [followUp, setFollowUp] = useState("");
1452
1570
  const column = useRef(null);
1453
1571
  const body = useRef(null);
1454
1572
  const chatHost = useRef(null);
@@ -1482,7 +1600,7 @@ function HelpColumn({ docked }) {
1482
1600
  if (articles.topic === help.topic && articles.status === "ready") return;
1483
1601
  const controller = new AbortController();
1484
1602
  setArticles({ topic: help.topic, items: [], status: "loading" });
1485
- requestJson(help.articlesUrl.split("{topic}").join(encodeURIComponent(help.topic)), { signal: controller.signal }).then((answer) => setArticles({ topic: help.topic, items: parseArticles(answer).slice(0, 3), status: "ready" })).catch((error) => {
1603
+ requestJson(help.articlesUrl.split("{topic}").join(encodeURIComponent(help.topic)), { signal: controller.signal }).then((answer) => setArticles({ topic: help.topic, items: parseArticles(answer).slice(0, 4), status: "ready" })).catch((error) => {
1486
1604
  if (error?.name !== "AbortError") setArticles({ topic: help.topic, items: [], status: "unavailable" });
1487
1605
  });
1488
1606
  return () => controller.abort();
@@ -1551,7 +1669,7 @@ function HelpColumn({ docked }) {
1551
1669
  if (closed) {
1552
1670
  const active = document.activeElement;
1553
1671
  if (active === null || active === document.body || column.current?.contains(active)) {
1554
- const back = opener.current?.isConnected ? opener.current : document.querySelector('.cbx-tools [aria-controls="cbx-help"]');
1672
+ const back = opener.current?.isConnected ? opener.current : document.querySelector('[aria-controls="cbx-help"]');
1555
1673
  back?.focus();
1556
1674
  }
1557
1675
  opener.current = null;
@@ -1582,7 +1700,123 @@ function HelpColumn({ docked }) {
1582
1700
  const submit = (event) => {
1583
1701
  event.preventDefault();
1584
1702
  void openChat(question.trim());
1703
+ if (question.trim() !== "") setAsked(true);
1585
1704
  };
1705
+ const pageArticles = help.articlesUrl !== void 0 ? articles.items : (help.articles ?? []).slice(0, 4);
1706
+ if (mobile) {
1707
+ const topic = helpTopicName(shell);
1708
+ const environment = environmentLevel(shell.context.levels)?.current;
1709
+ const where = shell.context.levels.map((level) => level.current.name).join(" \xB7 ");
1710
+ const chatReady = help.enabled && help.sessionUrl !== void 0;
1711
+ const close = () => toggleHelp(false);
1712
+ return /* @__PURE__ */ jsx("div", { className: "cbx-overlay cbx-sheet-backdrop", hidden: !open, onPointerDown: (event) => {
1713
+ if (event.target === event.currentTarget) close();
1714
+ }, children: /* @__PURE__ */ jsxs(
1715
+ "div",
1716
+ {
1717
+ ref: column,
1718
+ id: "cbx-help",
1719
+ className: "cbx-sheet cbx-sheet-bottom is-tall cbx-help-sheet",
1720
+ role: "dialog",
1721
+ "aria-modal": "true",
1722
+ "aria-label": t("Help with {page}", { page: topic }),
1723
+ tabIndex: -1,
1724
+ onKeyDown: (event) => {
1725
+ if (event.key === "Escape" && !event.defaultPrevented) {
1726
+ event.preventDefault();
1727
+ close();
1728
+ }
1729
+ trapTab(event, column.current);
1730
+ },
1731
+ children: [
1732
+ /* @__PURE__ */ jsx("div", { className: "cbx-sheet-handle", "aria-hidden": "true" }),
1733
+ /* @__PURE__ */ jsxs("div", { className: `cbx-sheet-head ${article !== null ? "has-back" : ""}`, children: [
1734
+ article !== null && /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-sheet-back", onClick: () => store.set({ article: null }), "aria-label": t("Back to Help"), children: /* @__PURE__ */ jsx(ChevronLeft, { size: 20, strokeWidth: 1.8, "aria-hidden": true }) }),
1735
+ /* @__PURE__ */ jsx("strong", { className: "cbx-sheet-title cbx-truncate", children: article !== null ? t("Article") : t("Help with {page}", { page: topic }) }),
1736
+ /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-icon-button", onClick: close, "aria-label": t("Close Help"), children: /* @__PURE__ */ jsx(X, { size: 18, strokeWidth: 1.8, "aria-hidden": true }) })
1737
+ ] }),
1738
+ /* @__PURE__ */ jsxs("div", { ref: body, className: "cbx-sheet-body", onScroll: (event) => store.set({ scrollTop: event.currentTarget.scrollTop }), children: [
1739
+ article !== null ? /* @__PURE__ */ jsxs("article", { className: "cbx-help-article", children: [
1740
+ /* @__PURE__ */ jsx("h2", { className: "cbx-help-article-title", children: article.title }),
1741
+ (article.body ?? article.excerpt ?? "").split(/\n{2,}/).filter(Boolean).map((paragraph, index) => /* @__PURE__ */ jsx("p", { children: paragraph }, index)),
1742
+ article.url !== void 0 && /* @__PURE__ */ jsxs("a", { className: "cbx-link", href: article.url, target: "_blank", rel: "noopener", children: [
1743
+ t("Open the full article"),
1744
+ " ",
1745
+ /* @__PURE__ */ jsx(ArrowUpRight, { size: 14, strokeWidth: 1.8, "aria-hidden": true })
1746
+ ] }),
1747
+ /* @__PURE__ */ jsx("p", { className: "cbx-eyebrow", children: t("Still stuck?") }),
1748
+ /* @__PURE__ */ jsxs(
1749
+ "form",
1750
+ {
1751
+ className: "cbx-askbar",
1752
+ onSubmit: (event) => {
1753
+ event.preventDefault();
1754
+ const text = followUp.trim();
1755
+ if (text === "") return;
1756
+ store.set({ article: null });
1757
+ setQuestion(text);
1758
+ setAsked(true);
1759
+ void openChat(text);
1760
+ },
1761
+ children: [
1762
+ /* @__PURE__ */ jsx("input", { type: "text", value: followUp, onChange: (event) => setFollowUp(event.target.value), placeholder: t("Ask a follow-up\u2026"), "aria-label": t("Ask a follow-up"), disabled: !chatReady }),
1763
+ /* @__PURE__ */ jsx("button", { type: "submit", className: "cbx-askbar-send", "aria-label": t("Ask"), disabled: !chatReady, children: /* @__PURE__ */ jsx(ArrowUp, { size: 16, strokeWidth: 2.2, "aria-hidden": true }) })
1764
+ ]
1765
+ }
1766
+ )
1767
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1768
+ unavailable && /* @__PURE__ */ jsxs("div", { className: "cbx-help-notice", role: "status", children: [
1769
+ /* @__PURE__ */ jsx(CircleAlert, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
1770
+ /* @__PURE__ */ jsx("span", { children: help.enabled ? t("Help is not available right now. The rest of the app works as usual.") : t("Help is not available here yet.") })
1771
+ ] }),
1772
+ /* @__PURE__ */ jsxs("form", { className: "cbx-askbar", onSubmit: submit, children: [
1773
+ /* @__PURE__ */ jsx("input", { ref: searchField, type: "text", value: question, onChange: (event) => setQuestion(event.target.value), placeholder: t("Ask about {page}\u2026", { page: topic }), "aria-label": t("Ask Cbox"), disabled: !chatReady }),
1774
+ /* @__PURE__ */ jsx("button", { type: "submit", className: "cbx-askbar-send", "aria-label": t("Ask"), disabled: !chatReady, children: /* @__PURE__ */ jsx(ArrowUp, { size: 16, strokeWidth: 2.2, "aria-hidden": true }) })
1775
+ ] }),
1776
+ /* @__PURE__ */ jsxs("p", { className: "cbx-ctxnote", children: [
1777
+ environment !== void 0 && /* @__PURE__ */ jsx("span", { className: `cbx-tone cbx-tone-${environment.tone ?? "neutral"}`, "aria-hidden": "true" }),
1778
+ t("Cbox sees this page: {page} in {where}", { page: topic, where })
1779
+ ] }),
1780
+ chatProblem && /* @__PURE__ */ jsx("p", { className: "cbx-create-error", role: "alert", children: t("The chat could not be opened. Try again, or use the support portal.") }),
1781
+ asked && chatReady && /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-pbtn", onClick: () => void openChat(t("I would like to talk to a person."), true), children: [
1782
+ /* @__PURE__ */ jsx(UserRound, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
1783
+ " ",
1784
+ t("Talk to a person")
1785
+ ] }),
1786
+ updates.length > 0 && /* @__PURE__ */ jsxs("section", { "aria-labelledby": "cbx-help-threads", children: [
1787
+ /* @__PURE__ */ jsx("h2", { id: "cbx-help-threads", className: "cbx-eyebrow", children: t("Your conversations") }),
1788
+ /* @__PURE__ */ jsx("div", { className: "cbx-group", children: updates.map((update) => /* @__PURE__ */ jsxs("button", { type: "button", className: `cbx-grow is-tall ${update.unread ? "is-unread" : ""}`, onClick: () => openUpdate(update), children: [
1789
+ /* @__PURE__ */ jsx("span", { className: "cbx-tile is-plain", "aria-hidden": "true", children: update.kind === "chat" ? /* @__PURE__ */ jsx(MessageSquare, { size: 16, strokeWidth: 1.8 }) : /* @__PURE__ */ jsx(Ticket, { size: 16, strokeWidth: 1.8 }) }),
1790
+ /* @__PURE__ */ jsxs("span", { className: "cbx-grow-text", children: [
1791
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-strong cbx-truncate", children: update.title }),
1792
+ update.excerpt !== void 0 && /* @__PURE__ */ jsx("span", { className: "cbx-grow-sub cbx-truncate", children: update.excerpt })
1793
+ ] }),
1794
+ update.unread && /* @__PURE__ */ jsx("span", { className: "cbx-badge", children: t("{count} new", { count: 1 }) })
1795
+ ] }, update.id)) })
1796
+ ] }),
1797
+ pageArticles.length > 0 && /* @__PURE__ */ jsxs("section", { "aria-labelledby": "cbx-help-for", children: [
1798
+ /* @__PURE__ */ jsx("h2", { id: "cbx-help-for", className: "cbx-eyebrow", children: t("For {page}", { page: topic }) }),
1799
+ /* @__PURE__ */ jsx("div", { className: "cbx-group", children: pageArticles.map((item) => /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-grow", onClick: () => store.set({ article: item }), children: [
1800
+ /* @__PURE__ */ jsx(FileText, { className: "cbx-grow-icon", size: 18, strokeWidth: 1.7, "aria-hidden": true }),
1801
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: item.title }),
1802
+ /* @__PURE__ */ jsx(ChevronRight, { className: "cbx-grow-trail", size: 16, strokeWidth: 1.8, "aria-hidden": true })
1803
+ ] }, item.id)) })
1804
+ ] }),
1805
+ /* @__PURE__ */ jsxs("div", { className: "cbx-pbtns", children: [
1806
+ /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-pbtn", onClick: () => void openChat(t("I would like to talk to a person."), true), disabled: !chatReady, children: t("Chat with support") }),
1807
+ portal !== void 0 && /* @__PURE__ */ jsxs("a", { className: "cbx-pbtn", href: portal, target: "_blank", rel: "noopener", children: [
1808
+ t("Help center"),
1809
+ " ",
1810
+ /* @__PURE__ */ jsx(ArrowUpRight, { size: 14, strokeWidth: 1.8, "aria-hidden": true })
1811
+ ] })
1812
+ ] })
1813
+ ] }),
1814
+ help.enabled && help.sessionUrl !== void 0 && /* @__PURE__ */ jsx("div", { ref: chatHost, className: "cbx-chat-host", "data-view": article !== null ? "article" : "home", children: createElement(SUPPORT_TAG, { "session-url": help.sessionUrl, intent: intentJson }) })
1815
+ ] })
1816
+ ]
1817
+ }
1818
+ ) });
1819
+ }
1586
1820
  return /* @__PURE__ */ jsxs(
1587
1821
  "div",
1588
1822
  {
@@ -1674,9 +1908,9 @@ function HelpColumn({ docked }) {
1674
1908
  results.status === "loading" && results.items.length === 0 && /* @__PURE__ */ jsx("li", { className: "cbx-list-note", children: t("Searching\u2026") })
1675
1909
  ] })
1676
1910
  ] }),
1677
- help.topic !== void 0 && articles.items.length > 0 && /* @__PURE__ */ jsxs("section", { className: "cbx-help-section", "aria-labelledby": "cbx-help-topic", children: [
1911
+ help.topic !== void 0 && pageArticles.length > 0 && /* @__PURE__ */ jsxs("section", { className: "cbx-help-section", "aria-labelledby": "cbx-help-topic", children: [
1678
1912
  /* @__PURE__ */ jsx("div", { className: "cbx-pane-heading", children: /* @__PURE__ */ jsx("span", { id: "cbx-help-topic", children: t("For this page") }) }),
1679
- /* @__PURE__ */ jsx("ul", { className: "cbx-list", role: "list", children: articles.items.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(ArticleRow, { article: item }) }, item.id)) })
1913
+ /* @__PURE__ */ jsx("ul", { className: "cbx-list", role: "list", children: pageArticles.slice(0, 3).map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(ArticleRow, { article: item }) }, item.id)) })
1680
1914
  ] }),
1681
1915
  /* @__PURE__ */ jsxs("section", { className: "cbx-help-section", "aria-labelledby": "cbx-help-ask", children: [
1682
1916
  /* @__PURE__ */ jsx("div", { className: "cbx-pane-heading", children: /* @__PURE__ */ jsx("span", { id: "cbx-help-ask", children: t("Ask Cbox") }) }),
@@ -1746,59 +1980,28 @@ function ArticleRow({ article }) {
1746
1980
  ] })
1747
1981
  ] });
1748
1982
  }
1749
- var SHELL_ICONS = {
1750
- activity: Activity,
1751
- "bar-chart": BarChart3,
1752
- bell: Bell,
1753
- "book-open": BookOpen,
1754
- boxes: Boxes,
1755
- briefcase: Briefcase,
1756
- building: Building2,
1757
- calendar: Calendar,
1758
- clock: Clock,
1759
- cloud: Cloud,
1760
- code: Code,
1761
- "credit-card": CreditCard,
1762
- database: Database,
1763
- "file-text": FileText,
1764
- folder: Folder,
1765
- "git-branch": GitBranch,
1766
- globe: Globe,
1767
- "hard-drive": HardDrive,
1768
- home: Home,
1769
- inbox: Inbox,
1770
- key: Key,
1771
- "layout-dashboard": LayoutDashboard,
1772
- "layout-grid": LayoutGrid,
1773
- layers: Layers,
1774
- "life-buoy": LifeBuoy,
1775
- list: List,
1776
- lock: Lock,
1777
- mail: Mail,
1778
- "message-square": MessageSquare,
1779
- network: Network,
1780
- package: Package,
1781
- percent: Percent,
1782
- plug: Plug,
1783
- receipt: Receipt,
1784
- rocket: Rocket,
1785
- search: Search,
1786
- send: Send,
1787
- server: Server,
1788
- settings: Settings,
1789
- shield: Shield,
1790
- "shield-check": ShieldCheck,
1791
- sparkles: Sparkles,
1792
- tag: Tag,
1793
- timer: Timer,
1794
- users: Users,
1795
- wallet: Wallet,
1796
- webhook: Webhook,
1797
- zap: Zap
1798
- };
1799
- function resolveIcon(name, extra = {}) {
1800
- if (name === void 0) return Circle;
1801
- return extra[name] ?? SHELL_ICONS[name] ?? Circle;
1983
+
1984
+ // src/shell/recent.ts
1985
+ var LIMIT = 6;
1986
+ function storageKey(app) {
1987
+ return `cbox_shell_recent_${app}`;
1988
+ }
1989
+ function recentPages(app) {
1990
+ try {
1991
+ const raw = window.localStorage.getItem(storageKey(app));
1992
+ const parsed = raw === null ? [] : JSON.parse(raw);
1993
+ return Array.isArray(parsed) ? parsed.filter((row) => typeof row === "object" && row !== null && typeof row.title === "string" && typeof row.url === "string" && row.url.startsWith("/")) : [];
1994
+ } catch {
1995
+ return [];
1996
+ }
1997
+ }
1998
+ function rememberPage(app, page) {
1999
+ if (typeof window === "undefined" || !page.url.startsWith("/")) return;
2000
+ try {
2001
+ const next = [page, ...recentPages(app).filter((row) => row.url !== page.url)].slice(0, LIMIT);
2002
+ window.localStorage.setItem(storageKey(app), JSON.stringify(next));
2003
+ } catch {
2004
+ }
1802
2005
  }
1803
2006
  function navUrl(entry) {
1804
2007
  return entry.url ?? entry.href ?? "#";
@@ -1842,144 +2045,8 @@ function NavPageList({ pages, renderPage }) {
1842
2045
  ] }, `run-${index}`)
1843
2046
  ) });
1844
2047
  }
1845
- function Sheet({ label, side, onClose, children, head }) {
1846
- const { t } = useShell();
1847
- const panel = useRef(null);
1848
- const opener = useRef(typeof document !== "undefined" ? document.activeElement : null);
1849
- useEffect(() => {
1850
- panel.current?.focus();
1851
- const back = opener.current;
1852
- return () => {
1853
- if (back instanceof HTMLElement) back.focus();
1854
- };
1855
- }, []);
1856
- return /* @__PURE__ */ jsx("div", { className: "cbx-overlay cbx-sheet-backdrop", onPointerDown: (event) => {
1857
- if (event.target === event.currentTarget) onClose();
1858
- }, children: /* @__PURE__ */ jsxs(
1859
- "div",
1860
- {
1861
- ref: panel,
1862
- className: `cbx-sheet cbx-sheet-${side}`,
1863
- role: "dialog",
1864
- "aria-modal": "true",
1865
- "aria-label": label,
1866
- tabIndex: -1,
1867
- onKeyDown: (event) => {
1868
- if (event.key === "Escape" && !event.defaultPrevented) {
1869
- event.preventDefault();
1870
- onClose();
1871
- }
1872
- trapTab(event, panel.current);
1873
- },
1874
- children: [
1875
- /* @__PURE__ */ jsxs("div", { className: "cbx-sheet-head", children: [
1876
- head ?? /* @__PURE__ */ jsx("strong", { className: "cbx-sheet-title", children: label }),
1877
- /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-icon-button", onClick: onClose, "aria-label": t("Close"), children: /* @__PURE__ */ jsx(X, { size: 18, strokeWidth: 1.8, "aria-hidden": true }) })
1878
- ] }),
1879
- /* @__PURE__ */ jsx("div", { className: "cbx-sheet-body", children })
1880
- ]
1881
- }
1882
- ) });
1883
- }
1884
- function NavSheet({ onClose }) {
1885
- const { shell, t, Link, icons } = useShell();
1886
- const [view, setView] = useState("nav");
1887
- if (view === "apps") {
1888
- return /* @__PURE__ */ jsx(
1889
- Sheet,
1890
- {
1891
- label: t("Switch app"),
1892
- side: "left",
1893
- onClose,
1894
- head: /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-row cbx-row-action cbx-back", onClick: () => setView("nav"), children: [
1895
- /* @__PURE__ */ jsx(ArrowLeft, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
1896
- /* @__PURE__ */ jsx("span", { className: "cbx-row-name", children: t("Switch app") })
1897
- ] }),
1898
- children: /* @__PURE__ */ jsx(AppGrid, { autoFocus: false })
1899
- }
1900
- );
1901
- }
1902
- return /* @__PURE__ */ jsxs(Sheet, { label: shell.app.name, side: "left", onClose, children: [
1903
- /* @__PURE__ */ jsx("nav", { "aria-label": t("Navigation"), className: "cbx-list", children: shell.nav.areas.map((area) => {
1904
- const Icon = resolveIcon(area.icon, icons);
1905
- const activeArea = area.key === shell.nav.activeArea;
1906
- return /* @__PURE__ */ jsxs("div", { className: "cbx-sheet-area", children: [
1907
- /* @__PURE__ */ jsxs(Link, { href: navUrl(area), className: `cbx-row cbx-row-action ${activeArea ? (area.pages ?? []).length > 1 ? "is-open" : "is-current" : ""}`, "aria-current": activeArea && (area.pages ?? []).length <= 1 ? "page" : void 0, onClick: onClose, children: [
1908
- /* @__PURE__ */ jsx(Icon, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
1909
- /* @__PURE__ */ jsx("span", { className: "cbx-row-name", children: area.label }),
1910
- areaLocked(area) && /* @__PURE__ */ jsxs("span", { className: "cbx-nav-lock", title: t("Not in your plan"), children: [
1911
- /* @__PURE__ */ jsx(Lock, { size: 13, strokeWidth: 1.9, "aria-hidden": true }),
1912
- /* @__PURE__ */ jsx("span", { className: "cbx-sr-only", children: t("(locked)") })
1913
- ] })
1914
- ] }),
1915
- (area.pages ?? []).length > 1 && /* @__PURE__ */ jsx("div", { className: "cbx-sheet-pages", children: /* @__PURE__ */ jsx(
1916
- NavPageList,
1917
- {
1918
- pages: area.pages ?? [],
1919
- renderPage: (page) => {
1920
- const on = activeArea && page.key === shell.nav.activePage;
1921
- return /* @__PURE__ */ jsxs(Link, { href: navUrl(page), className: `cbx-row cbx-row-action ${on ? "is-current" : ""} ${page.locked === true ? "is-locked" : ""}`, "aria-current": on ? "page" : void 0, "data-locked": page.locked === true ? "true" : void 0, onClick: onClose, children: [
1922
- /* @__PURE__ */ jsx("span", { className: "cbx-row-name", children: page.label }),
1923
- /* @__PURE__ */ jsx(NavPageMarks, { page })
1924
- ] }, page.key);
1925
- }
1926
- }
1927
- ) })
1928
- ] }, area.key);
1929
- }) }),
1930
- /* @__PURE__ */ jsxs("div", { className: "cbx-list cbx-list-foot", children: [
1931
- /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-row cbx-row-action", onClick: () => setView("apps"), children: [
1932
- /* @__PURE__ */ jsx(LayoutGrid, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
1933
- /* @__PURE__ */ jsx("span", { className: "cbx-row-name", children: t("Switch app") })
1934
- ] }),
1935
- shell.notifications.enabled && /* @__PURE__ */ jsxs(Link, { href: shell.notifications.url, className: "cbx-row cbx-row-action", onClick: onClose, children: [
1936
- /* @__PURE__ */ jsx(Bell, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
1937
- /* @__PURE__ */ jsx("span", { className: "cbx-row-name", children: t("Notifications") }),
1938
- shell.notifications.unread > 0 && /* @__PURE__ */ jsx("span", { className: "cbx-count is-inline", children: shell.notifications.unread })
1939
- ] })
1940
- ] }),
1941
- /* @__PURE__ */ jsx(AccountMenu, { inline: true, onDone: onClose })
1942
- ] });
1943
- }
1944
- function ContextSheet({ onClose }) {
1945
- const { shell, t, switchTo } = useShell();
1946
- const [organization, outer, inner] = shell.context.levels;
1947
- return /* @__PURE__ */ jsxs(Sheet, { label: t("Where you are"), side: "bottom", onClose, children: [
1948
- organization !== void 0 && /* @__PURE__ */ jsx("section", { className: "cbx-sheet-level", "aria-label": organization.label, children: /* @__PURE__ */ jsx(
1949
- LevelPane,
1950
- {
1951
- level: organization,
1952
- currentId: organization.current.id,
1953
- heading: pluralOf(organization),
1954
- createLabel: t("New {thing}", { thing: organization.label.toLowerCase() }),
1955
- onPick: (item) => switchTo({ [organization.key]: item.id })
1956
- }
1957
- ) }),
1958
- outer !== void 0 && /* @__PURE__ */ jsx("section", { className: "cbx-sheet-level", "aria-label": outer.label, children: /* @__PURE__ */ jsx(
1959
- LevelPane,
1960
- {
1961
- level: outer,
1962
- parent: organization?.current.id,
1963
- currentId: outer.current.id,
1964
- heading: pluralOf(outer),
1965
- createLabel: t("New {thing}", { thing: outer.label.toLowerCase() }),
1966
- onPick: (item) => void pickKeepingEnvironment(outer, inner, item, switchTo)
1967
- }
1968
- ) }),
1969
- outer !== void 0 && inner !== void 0 && /* @__PURE__ */ jsx("section", { className: "cbx-sheet-level", "aria-label": inner.label, children: /* @__PURE__ */ jsx(
1970
- LevelPane,
1971
- {
1972
- level: inner,
1973
- parent: outer.current.id,
1974
- currentId: inner.current.id,
1975
- heading: t("{things} in {name}", { things: pluralOf(inner), name: outer.current.name }),
1976
- createLabel: t("New {thing} in {name}", { thing: inner.label.toLowerCase(), name: outer.current.name }),
1977
- onPick: (item) => switchTo({ [outer.key]: outer.current.id, [inner.key]: item.id })
1978
- }
1979
- ) })
1980
- ] });
1981
- }
1982
2048
  var GROUP_LIMIT = 5;
2049
+ var GROUP_KIND = { page: "actions", switch: "actions", actions: "actions", goto: "actions", records: "records", pages: "pages", docs: "help" };
1983
2050
  function matchScore(text, query2) {
1984
2051
  const haystack = text.toLowerCase();
1985
2052
  const terms = query2.toLowerCase().trim().split(/\s+/).filter(Boolean);
@@ -2006,7 +2073,7 @@ function localPages(shell, query2, open, lockedLabel) {
2006
2073
  }
2007
2074
  return entries.map((entry) => ({ entry, score: matchScore(`${entry.title} ${entry.subtitle ?? ""}`, query2) })).filter(({ score }) => score > 0).sort((a, b) => b.score - a.score).map(({ entry }) => {
2008
2075
  const Icon = resolveIcon(entry.icon);
2009
- return { id: entry.id, title: entry.title, subtitle: entry.subtitle, href: entry.url, icon: /* @__PURE__ */ jsx(Icon, { size: 16, strokeWidth: 1.8, "aria-hidden": true }), run: (newTab) => open(entry.url, newTab) };
2076
+ return { id: entry.id, title: entry.title, subtitle: entry.subtitle, href: entry.url, kind: "pages", icon: /* @__PURE__ */ jsx(Icon, { size: 16, strokeWidth: 1.8, "aria-hidden": true }), run: (newTab) => open(entry.url, newTab) };
2010
2077
  });
2011
2078
  }
2012
2079
  function rows(body, group) {
@@ -2019,7 +2086,8 @@ function rows(body, group) {
2019
2086
  return Array.isArray(data) ? data.filter((row) => typeof row === "object" && row !== null) : [];
2020
2087
  }
2021
2088
  function CommandPalette({ onClose }) {
2022
- const { shell, t, navigate, switchTo, openArticle, ask } = useShell();
2089
+ const { shell, t, navigate, switchTo, openArticle, ask, mobile, openContext, openCreate, canCreate, searchRecords } = useShell();
2090
+ const [scope, setScope] = useState("all");
2023
2091
  const [input, setInput] = useState("");
2024
2092
  const [query2, setQuery] = useState("");
2025
2093
  const [groups, setGroups] = useState({});
@@ -2063,17 +2131,26 @@ function CommandPalette({ onClose }) {
2063
2131
  setGroups({});
2064
2132
  return () => controller.abort();
2065
2133
  }
2066
- if (shell.palette.searchUrl !== void 0) {
2134
+ if (searchRecords !== void 0) {
2135
+ run(
2136
+ "records",
2137
+ async () => (await searchRecords(q2, signal)).flatMap((row) => {
2138
+ const url = safeUrl(row.url);
2139
+ if (url === void 0) return [];
2140
+ return [{ id: `record:${row.id}`, title: row.title, subtitle: row.subtitle, href: url, kind: "records", icon: /* @__PURE__ */ jsx(FileText, { size: 16, strokeWidth: 1.8, "aria-hidden": true }), run: (newTab) => open(url, newTab) }];
2141
+ })
2142
+ );
2143
+ } else if (shell.palette.searchUrl !== void 0) {
2067
2144
  run(
2068
2145
  "records",
2069
2146
  async () => rows(await requestJson(withQuery(shell.palette.searchUrl, { q: q2, group: "records" }), { signal }), "records").flatMap((row) => {
2070
2147
  const url = safeUrl(row.url);
2071
2148
  if (typeof row.title !== "string" || url === void 0) return [];
2072
- return [{ id: `record:${String(row.id ?? url)}`, title: row.title, subtitle: typeof row.subtitle === "string" ? row.subtitle : void 0, href: url, icon: /* @__PURE__ */ jsx(FileText, { size: 16, strokeWidth: 1.8, "aria-hidden": true }), run: (newTab) => open(url, newTab) }];
2149
+ return [{ id: `record:${String(row.id ?? url)}`, title: row.title, subtitle: typeof row.subtitle === "string" ? row.subtitle : void 0, href: url, kind: "records", icon: /* @__PURE__ */ jsx(FileText, { size: 16, strokeWidth: 1.8, "aria-hidden": true }), run: (newTab) => open(url, newTab) }];
2073
2150
  })
2074
2151
  );
2075
2152
  }
2076
- const organization = shell.context.levels[0];
2153
+ const organization2 = shell.context.levels[0];
2077
2154
  run("goto", async () => {
2078
2155
  const loads = [];
2079
2156
  const kitGoto = shell.palette.gotoUrl === void 0 && shell.palette.searchUrl !== void 0;
@@ -2088,15 +2165,15 @@ function CommandPalette({ onClose }) {
2088
2165
  )
2089
2166
  );
2090
2167
  }
2091
- if (organization !== void 0 && !kitGoto) {
2168
+ if (organization2 !== void 0 && !kitGoto) {
2092
2169
  loads.push(
2093
- requestJson(withQuery(organization.listUrl, { q: q2, limit: "5" }), { signal }).then(
2170
+ requestJson(withQuery(organization2.listUrl, { q: q2, limit: "5" }), { signal }).then(
2094
2171
  (body) => rows(body).flatMap((row) => {
2095
2172
  if (typeof row.id !== "string" && typeof row.id !== "number" || typeof row.name !== "string") return [];
2096
2173
  const orgId = String(row.id);
2097
- return [{ id: `org:${orgId}`, title: row.name, subtitle: organization.label, icon: /* @__PURE__ */ jsx("span", { className: "cbx-chip cbx-chip-soft", "aria-hidden": "true", children: typeof row.initials === "string" ? row.initials : initialsOf(row.name) }), run: () => {
2174
+ return [{ id: `org:${orgId}`, title: row.name, subtitle: organization2.label, icon: /* @__PURE__ */ jsx("span", { className: "cbx-chip cbx-chip-soft", "aria-hidden": "true", children: typeof row.initials === "string" ? row.initials : initialsOf(row.name) }), run: () => {
2098
2175
  onClose();
2099
- switchTo({ [organization.key]: orgId });
2176
+ switchTo({ [organization2.key]: orgId });
2100
2177
  } }];
2101
2178
  })
2102
2179
  )
@@ -2132,6 +2209,7 @@ function CommandPalette({ onClose }) {
2132
2209
  title: article.title,
2133
2210
  subtitle: article.excerpt,
2134
2211
  href: article.url,
2212
+ kind: "help",
2135
2213
  icon: /* @__PURE__ */ jsx(BookOpen, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
2136
2214
  run: (newTab) => {
2137
2215
  if (newTab && article.url !== void 0) {
@@ -2145,45 +2223,129 @@ function CommandPalette({ onClose }) {
2145
2223
  );
2146
2224
  }
2147
2225
  return () => controller.abort();
2148
- }, [query2, shell]);
2226
+ }, [query2, shell, searchRecords]);
2149
2227
  const q = input.trim();
2228
+ const topic = helpTopicName(shell);
2229
+ const organization = shell.context.levels[0];
2230
+ const environment = environmentLevel(shell.context.levels);
2231
+ const envIndex = environment !== void 0 ? shell.context.levels.indexOf(environment) : -1;
2232
+ const envParent = envIndex > 0 ? shell.context.levels[envIndex - 1] : void 0;
2233
+ const environments = useContextList(environment?.listUrl, { parent: envParent?.current.id, enabled: environment !== void 0 });
2150
2234
  const pages = useMemo(() => localPages(shell, q, open, t("Locked")), [shell, q, t]);
2151
- const actions = useMemo(
2152
- () => shell.palette.actions.filter((action) => matchScore(`${action.label} ${(action.keywords ?? []).join(" ")}`, q) > 0).map((action) => {
2153
- const Icon = action.icon !== void 0 ? resolveIcon(action.icon) : Zap;
2154
- return {
2155
- id: `action:${action.id}`,
2156
- title: action.label,
2157
- href: action.method === "post" ? void 0 : action.url,
2158
- icon: /* @__PURE__ */ jsx(Icon, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
2159
- run: (newTab) => {
2160
- if (!newTab) onClose();
2161
- navigate(action.url, { method: action.method ?? "get", newTab: newTab && action.method !== "post" });
2235
+ const toItem2 = (action, prefix) => {
2236
+ const Icon = action.icon !== void 0 ? resolveIcon(action.icon) : Zap;
2237
+ return {
2238
+ id: `${prefix}:${action.id}`,
2239
+ title: action.label,
2240
+ subtitle: action.hint,
2241
+ href: action.method === "post" ? void 0 : action.url,
2242
+ kind: "actions",
2243
+ icon: /* @__PURE__ */ jsx(Icon, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
2244
+ run: (newTab) => {
2245
+ if (!newTab) onClose();
2246
+ if (!newTab && action.create !== void 0 && canCreate && findCreatable(shell, action.create) !== void 0) {
2247
+ openCreate(action.create);
2248
+ return;
2162
2249
  }
2163
- };
2164
- }),
2165
- [shell, q]
2166
- );
2167
- const sections = [
2168
- { key: "pages", label: t("Pages"), state: { status: "ready", items: pages } },
2169
- { key: "records", label: t("Records"), state: groups.records ?? { status: "idle", items: [] } },
2170
- { key: "actions", label: t("Actions"), state: { status: "ready", items: actions } },
2171
- { key: "goto", label: t("Go to"), state: groups.goto ?? { status: "idle", items: [] } },
2172
- { key: "docs", label: t("Docs and help"), state: groups.docs ?? { status: "idle", items: [] } }
2173
- ];
2174
- if (q !== "") {
2175
- sections.push({
2176
- key: "ask",
2177
- label: t("Ask Cbox"),
2178
- state: {
2179
- status: "ready",
2180
- items: [{ id: "ask", title: t("Ask Cbox: \u201C{query}\u201D", { query: q }), subtitle: t("About this page"), icon: /* @__PURE__ */ jsx(Sparkles, { size: 16, strokeWidth: 1.8, "aria-hidden": true }), run: () => {
2181
- onClose();
2182
- ask(q);
2183
- } }]
2250
+ navigate(action.url, { method: action.method ?? "get", newTab: newTab && action.method !== "post" });
2184
2251
  }
2185
- });
2186
- }
2252
+ };
2253
+ };
2254
+ const matches2 = (item, words = []) => matchScore(`${item.title} ${item.subtitle ?? ""} ${words.join(" ")}`, q) > 0;
2255
+ const createItem2 = (key) => {
2256
+ const creatable = findCreatable(shell, key);
2257
+ if (creatable === void 0 || !canCreate) return null;
2258
+ return { id: `create:${key}`, title: t("New {thing}", { thing: creatable.label.toLowerCase() }), kind: "actions", icon: /* @__PURE__ */ jsx(Plus, { size: 16, strokeWidth: 1.8, "aria-hidden": true }), run: () => {
2259
+ onClose();
2260
+ openCreate(key);
2261
+ } };
2262
+ };
2263
+ const pageCreate = shell.page?.create !== void 0 ? createItem2(shell.page.create) : null;
2264
+ const pageActions = [...pageCreate !== null ? [pageCreate] : [], ...(shell.page?.actions ?? []).map((action) => toItem2(action, "page"))];
2265
+ const globalActions = shell.palette.actions.map((action) => toItem2(action, "action"));
2266
+ const switchItems = [];
2267
+ if (environment !== void 0) {
2268
+ environments.items.filter((item) => item.id !== environment.current.id).slice(0, 3).forEach(
2269
+ (item) => switchItems.push({
2270
+ id: `switch:${item.id}`,
2271
+ title: t("Switch to {name}", { name: item.name }),
2272
+ subtitle: environment.label,
2273
+ kind: "actions",
2274
+ icon: /* @__PURE__ */ jsx(ToneSquare, { tone: item.tone }),
2275
+ run: () => {
2276
+ onClose();
2277
+ switchTo(envParent !== void 0 ? { [envParent.key]: envParent.current.id, [environment.key]: item.id } : { [environment.key]: item.id });
2278
+ }
2279
+ })
2280
+ );
2281
+ }
2282
+ if (organization !== void 0) {
2283
+ switchItems.push({
2284
+ id: "switch:organization",
2285
+ title: t("Switch {thing}", { thing: organization.label.toLowerCase() }),
2286
+ subtitle: t("Now {name}", { name: organization.current.name }),
2287
+ kind: "actions",
2288
+ icon: /* @__PURE__ */ jsx(ArrowLeftRight, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
2289
+ run: () => {
2290
+ onClose();
2291
+ openContext(organization.key, true);
2292
+ }
2293
+ });
2294
+ }
2295
+ const recent = useMemo(() => {
2296
+ if (shell.palette.recent !== void 0) {
2297
+ return shell.palette.recent.flatMap((row) => {
2298
+ const url = safeUrl(row.url);
2299
+ return url === void 0 ? [] : [{ id: `recent:${row.id}`, title: row.title, subtitle: row.subtitle, href: url, kind: "records", icon: /* @__PURE__ */ jsx(Clock, { size: 16, strokeWidth: 1.8, "aria-hidden": true }), run: (newTab) => open(url, newTab) }];
2300
+ });
2301
+ }
2302
+ const here = typeof window !== "undefined" ? window.location.pathname + window.location.search + window.location.hash : "";
2303
+ return recentPages(shell.app.key).filter((row) => row.url !== here).slice(0, 4).map((row) => ({ id: `recent:${row.url}`, title: row.title, subtitle: row.area, href: row.url, kind: "pages", icon: /* @__PURE__ */ jsx(Clock, { size: 16, strokeWidth: 1.8, "aria-hidden": true }), run: (newTab) => open(row.url, newTab) }));
2304
+ }, [shell]);
2305
+ const ready = (items) => ({ status: "ready", items });
2306
+ const sections = q === "" ? [
2307
+ pageActions.length > 0 ? { key: "page", label: t("On {page}", { page: topic }), state: ready(pageActions) } : { key: "actions", label: t("Actions"), state: ready(globalActions) },
2308
+ { key: "recent", label: t("Recent"), state: ready(recent) },
2309
+ { key: "switch", label: t("Switch"), state: ready(switchItems) }
2310
+ ] : [
2311
+ {
2312
+ key: "actions",
2313
+ label: t("Actions"),
2314
+ state: ready(
2315
+ [
2316
+ ...pageActions.filter((item) => matches2(item, (shell.page?.actions ?? []).find((action) => `page:${action.id}` === item.id)?.keywords)),
2317
+ ...globalActions.filter((item) => matches2(item, shell.palette.actions.find((action) => `action:${action.id}` === item.id)?.keywords)),
2318
+ ...(shell.create?.items ?? []).filter((creatable) => creatable.key !== shell.page?.create).map((creatable) => createItem2(creatable.key)).filter((item) => item !== null && matches2(item, findCreatable(shell, item.id.slice("create:".length))?.keywords)),
2319
+ ...switchItems.filter((item) => matches2(item))
2320
+ ]
2321
+ )
2322
+ },
2323
+ { key: "goto", label: t("Go to"), state: groups.goto ?? { status: "idle", items: [] } },
2324
+ { key: "records", label: t("Records"), state: groups.records ?? { status: "idle", items: [] } },
2325
+ { key: "pages", label: t("Pages"), state: ready(pages) },
2326
+ { key: "docs", label: t("Help"), state: groups.docs ?? { status: "idle", items: [] } }
2327
+ ];
2328
+ const scoped = sections.map((section) => {
2329
+ if (scope === "all") return section;
2330
+ const kind = section.key === "recent" || section.key === "ask" ? null : GROUP_KIND[section.key];
2331
+ if (kind !== null && kind !== scope) return null;
2332
+ return { ...section, state: { ...section.state, items: section.state.items.filter((item) => item.kind === void 0 || item.kind === scope) } };
2333
+ }).filter((section) => section !== null);
2334
+ sections.length = 0;
2335
+ sections.push(...scoped);
2336
+ if (q !== "") {
2337
+ sections.push({
2338
+ key: "ask",
2339
+ label: t("Ask Cbox"),
2340
+ state: {
2341
+ status: "ready",
2342
+ items: [{ id: "ask", title: t("Ask Cbox: \u201C{query}\u201D", { query: q }), subtitle: t("Answers with what you see on {page}", { page: topic }), icon: /* @__PURE__ */ jsx(Sparkles, { size: 16, strokeWidth: 1.8, "aria-hidden": true }), run: () => {
2343
+ onClose();
2344
+ ask(q);
2345
+ } }]
2346
+ }
2347
+ });
2348
+ }
2187
2349
  const options = [];
2188
2350
  const rendered = sections.map((section) => {
2189
2351
  const all = expanded === section.key;
@@ -2196,7 +2358,7 @@ function CommandPalette({ onClose }) {
2196
2358
  });
2197
2359
  const keyOf = (option) => option.kind === "item" ? `${option.group}:${option.item.id}` : `all:${option.group}`;
2198
2360
  const debounced = q === query2.trim() && groupsFor === q;
2199
- const current = (group) => group === "pages" || group === "actions" || debounced && sections.find((section) => section.key === group)?.state.status === "ready";
2361
+ const current = (group) => group === "pages" || group === "actions" || group === "page" || group === "recent" || group === "switch" || debounced && sections.find((section) => section.key === group)?.state.status === "ready";
2200
2362
  const busy = !debounced || sections.some((section) => section.state.status === "loading");
2201
2363
  const firstResult = options.find((option) => option.group !== "ask" && current(option.group));
2202
2364
  const autoKey = firstResult !== void 0 ? keyOf(firstResult) : !busy && options[0] !== void 0 ? keyOf(options[0]) : null;
@@ -2246,31 +2408,42 @@ function CommandPalette({ onClose }) {
2246
2408
  }
2247
2409
  };
2248
2410
  const activeOption = options[active];
2249
- return /* @__PURE__ */ jsx("div", { className: "cbx-overlay cbx-palette-backdrop", onPointerDown: (event) => {
2411
+ const scopes = [
2412
+ { value: "all", label: t("All") },
2413
+ { value: "actions", label: t("Actions") },
2414
+ { value: "records", label: t("Records") },
2415
+ { value: "pages", label: t("Pages") },
2416
+ { value: "help", label: t("Help") }
2417
+ ];
2418
+ return /* @__PURE__ */ jsx("div", { className: `cbx-overlay cbx-palette-backdrop ${mobile ? "is-sheet" : ""}`, onPointerDown: (event) => {
2250
2419
  if (event.target === event.currentTarget) onClose();
2251
- }, children: /* @__PURE__ */ jsxs("div", { ref: dialog, className: "cbx-palette", role: "dialog", "aria-modal": "true", "aria-label": t("Search"), tabIndex: -1, onKeyDown, children: [
2420
+ }, children: /* @__PURE__ */ jsxs("div", { ref: dialog, className: `cbx-palette ${mobile ? "is-sheet" : ""}`, role: "dialog", "aria-modal": "true", "aria-label": t("Search"), tabIndex: -1, onKeyDown, children: [
2421
+ mobile && /* @__PURE__ */ jsx("div", { className: "cbx-sheet-handle", "aria-hidden": "true" }),
2252
2422
  /* @__PURE__ */ jsxs("div", { className: "cbx-palette-search", children: [
2253
- /* @__PURE__ */ jsx(Search, { size: 18, strokeWidth: 1.8, "aria-hidden": true }),
2254
- /* @__PURE__ */ jsx(
2255
- "input",
2256
- {
2257
- ref: field,
2258
- type: "search",
2259
- role: "combobox",
2260
- "aria-expanded": "true",
2261
- "aria-controls": `${id}-list`,
2262
- "aria-activedescendant": activeOption !== void 0 ? `${id}-${active}` : void 0,
2263
- "aria-autocomplete": "list",
2264
- "aria-label": shell.palette.placeholder ?? t("Search or ask\u2026"),
2265
- placeholder: shell.palette.placeholder ?? t("Search or ask\u2026"),
2266
- value: input,
2267
- onChange: (event) => setInput(event.target.value),
2268
- autoComplete: "off",
2269
- spellCheck: false
2270
- }
2271
- ),
2272
- /* @__PURE__ */ jsx("kbd", { className: "cbx-kbd", children: "Esc" })
2423
+ /* @__PURE__ */ jsxs("label", { className: "cbx-palette-field", children: [
2424
+ /* @__PURE__ */ jsx(Search, { size: 18, strokeWidth: 1.8, "aria-hidden": true }),
2425
+ /* @__PURE__ */ jsx(
2426
+ "input",
2427
+ {
2428
+ ref: field,
2429
+ type: "search",
2430
+ role: "combobox",
2431
+ "aria-expanded": "true",
2432
+ "aria-controls": `${id}-list`,
2433
+ "aria-activedescendant": activeOption !== void 0 ? `${id}-${active}` : void 0,
2434
+ "aria-autocomplete": "list",
2435
+ "aria-label": shell.palette.placeholder ?? t("Search or ask\u2026"),
2436
+ placeholder: shell.palette.placeholder ?? (mobile ? t("Search, act or ask\u2026") : t("Search or ask\u2026")),
2437
+ value: input,
2438
+ onChange: (event) => setInput(event.target.value),
2439
+ autoComplete: "off",
2440
+ spellCheck: false
2441
+ }
2442
+ )
2443
+ ] }),
2444
+ mobile ? /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-palette-cancel", onClick: onClose, children: t("Cancel") }) : /* @__PURE__ */ jsx("kbd", { className: "cbx-kbd", children: "Esc" })
2273
2445
  ] }),
2446
+ /* @__PURE__ */ jsx("div", { className: "cbx-scopes", role: "radiogroup", "aria-label": t("Scope"), children: scopes.map((item) => /* @__PURE__ */ jsx("button", { type: "button", role: "radio", "aria-checked": scope === item.value, className: `cbx-scope ${scope === item.value ? "is-on" : ""}`, onClick: () => setScope(item.value), children: item.label }, item.value)) }),
2274
2447
  /* @__PURE__ */ jsxs("div", { id: `${id}-list`, role: "listbox", "aria-label": t("Results"), className: "cbx-palette-list", children: [
2275
2448
  rendered.map((section) => {
2276
2449
  const loading = section.state.status === "loading" && section.state.items.length === 0;
@@ -2281,7 +2454,7 @@ function CommandPalette({ onClose }) {
2281
2454
  section.state.status === "loading" && /* @__PURE__ */ jsx("span", { className: "cbx-palette-busy", "aria-hidden": "true" })
2282
2455
  ] }),
2283
2456
  loading && /* @__PURE__ */ jsx("div", { className: "cbx-list-note", "aria-live": "polite", children: t("Searching\u2026") }),
2284
- options.slice(section.start, section.start + section.count).map((option, offset) => {
2457
+ section.count > 0 && /* @__PURE__ */ jsx("div", { className: "cbx-palette-rows", role: "presentation", children: options.slice(section.start, section.start + section.count).map((option, offset) => {
2285
2458
  const index = section.start + offset;
2286
2459
  const on = index === active;
2287
2460
  return /* @__PURE__ */ jsx(
@@ -2295,8 +2468,10 @@ function CommandPalette({ onClose }) {
2295
2468
  onClick: (event) => choose(option, event.metaKey || event.ctrlKey),
2296
2469
  children: option.kind === "item" ? /* @__PURE__ */ jsxs(Fragment, { children: [
2297
2470
  /* @__PURE__ */ jsx("span", { className: "cbx-row-icon", children: option.item.icon }),
2298
- /* @__PURE__ */ jsx("span", { className: "cbx-row-name", title: option.item.title, children: option.item.title }),
2299
- option.item.subtitle !== void 0 && /* @__PURE__ */ jsx("span", { className: "cbx-row-label cbx-truncate", children: option.item.subtitle }),
2471
+ /* @__PURE__ */ jsxs("span", { className: "cbx-row-text", children: [
2472
+ /* @__PURE__ */ jsx("span", { className: "cbx-row-name", title: option.item.title, children: option.item.title }),
2473
+ option.item.subtitle !== void 0 && /* @__PURE__ */ jsx("span", { className: "cbx-row-label cbx-truncate", children: option.item.subtitle })
2474
+ ] }),
2300
2475
  on && /* @__PURE__ */ jsx(CornerDownLeft, { className: "cbx-row-trail", size: 14, strokeWidth: 1.8, "aria-hidden": true })
2301
2476
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2302
2477
  /* @__PURE__ */ jsx("span", { className: "cbx-row-icon", children: /* @__PURE__ */ jsx(ArrowRight, { size: 16, strokeWidth: 1.8, "aria-hidden": true }) }),
@@ -2305,7 +2480,7 @@ function CommandPalette({ onClose }) {
2305
2480
  },
2306
2481
  option.kind === "item" ? option.item.id : `all:${option.group}`
2307
2482
  );
2308
- })
2483
+ }) })
2309
2484
  ] }, section.key);
2310
2485
  }),
2311
2486
  options.length === 0 && q !== "" && /* @__PURE__ */ jsx("div", { className: "cbx-list-note", children: t("Nothing matches \u201C{query}\u201D.", { query: q }) })
@@ -2330,6 +2505,681 @@ function CommandPalette({ onClose }) {
2330
2505
  ] })
2331
2506
  ] }) });
2332
2507
  }
2508
+ function Sheet({
2509
+ label,
2510
+ side = "bottom",
2511
+ onClose,
2512
+ children,
2513
+ title,
2514
+ back,
2515
+ size,
2516
+ className,
2517
+ bodyClassName
2518
+ }) {
2519
+ const { t } = useShell();
2520
+ const panel = useRef(null);
2521
+ const opener = useRef(typeof document !== "undefined" ? document.activeElement : null);
2522
+ useEffect(() => {
2523
+ panel.current?.focus();
2524
+ const restore = opener.current;
2525
+ return () => {
2526
+ if (restore instanceof HTMLElement && restore.isConnected) restore.focus();
2527
+ };
2528
+ }, []);
2529
+ return /* @__PURE__ */ jsx("div", { className: "cbx-overlay cbx-sheet-backdrop", onPointerDown: (event) => {
2530
+ if (event.target === event.currentTarget) onClose();
2531
+ }, children: /* @__PURE__ */ jsxs(
2532
+ "div",
2533
+ {
2534
+ ref: panel,
2535
+ className: `cbx-sheet cbx-sheet-${side} ${size !== void 0 ? `is-${size}` : ""} ${className ?? ""}`,
2536
+ role: "dialog",
2537
+ "aria-modal": "true",
2538
+ "aria-label": label,
2539
+ tabIndex: -1,
2540
+ onKeyDown: (event) => {
2541
+ if (event.key === "Escape" && !event.defaultPrevented) {
2542
+ event.preventDefault();
2543
+ onClose();
2544
+ }
2545
+ trapTab(event, panel.current);
2546
+ },
2547
+ children: [
2548
+ side === "bottom" && /* @__PURE__ */ jsx("div", { className: "cbx-sheet-handle", "aria-hidden": "true" }),
2549
+ /* @__PURE__ */ jsxs("div", { className: `cbx-sheet-head ${back !== void 0 ? "has-back" : ""}`, children: [
2550
+ back !== void 0 && /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-sheet-back", onClick: back.onBack, "aria-label": back.label, children: [
2551
+ /* @__PURE__ */ jsx(ChevronLeft, { size: 20, strokeWidth: 1.8, "aria-hidden": true }),
2552
+ back.text !== void 0 && /* @__PURE__ */ jsx("span", { children: back.text })
2553
+ ] }),
2554
+ /* @__PURE__ */ jsx("strong", { className: "cbx-sheet-title cbx-truncate", children: title ?? label }),
2555
+ /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-icon-button", onClick: onClose, "aria-label": t("Close"), children: /* @__PURE__ */ jsx(X, { size: 18, strokeWidth: 1.8, "aria-hidden": true }) })
2556
+ ] }),
2557
+ /* @__PURE__ */ jsx("div", { className: `cbx-sheet-body ${bodyClassName ?? ""}`, children })
2558
+ ]
2559
+ }
2560
+ ) });
2561
+ }
2562
+ function findCreatable(shell, key) {
2563
+ if (key === void 0 || key === null) return void 0;
2564
+ return shell.create?.items.find((item) => item.key === key);
2565
+ }
2566
+ function pageCreateKey(shell) {
2567
+ return findCreatable(shell, shell.page?.create)?.key ?? findCreatable(shell, shell.create?.default)?.key ?? null;
2568
+ }
2569
+ function createLabel(shell, t) {
2570
+ const own = findCreatable(shell, shell.page?.create);
2571
+ return own !== void 0 ? t("New {thing}", { thing: own.label.toLowerCase() }) : t("Create");
2572
+ }
2573
+ function CreateSheet({ onClose }) {
2574
+ const { shell, t, mobile, createKey, renderCreate } = useShell();
2575
+ const [stack, setStack] = useState(() => findCreatable(shell, createKey) !== void 0 ? [{ kind: "tree" }, { kind: "form", key: createKey }] : [{ kind: "tree" }]);
2576
+ const top = stack[stack.length - 1];
2577
+ const below = stack.length > 1 ? stack[stack.length - 2] : null;
2578
+ const environmentLevelItem = environmentLevel(shell.context.levels)?.current ?? null;
2579
+ const notLive = environmentLevelItem !== null && isLive(environmentLevelItem) === false;
2580
+ const name = (entry) => entry === null ? "" : entry.kind === "tree" ? t("Create") : findCreatable(shell, entry.key)?.label ?? entry.key;
2581
+ const pop = () => setStack((current) => current.length > 1 ? current.slice(0, -1) : current);
2582
+ const title = top.kind === "tree" ? t("Create") : t("New {thing}", { thing: name(top).toLowerCase() });
2583
+ return /* @__PURE__ */ jsxs(
2584
+ Sheet,
2585
+ {
2586
+ label: title,
2587
+ side: mobile ? "bottom" : "right",
2588
+ size: "tall",
2589
+ onClose,
2590
+ className: "cbx-create-sheet",
2591
+ back: below !== null ? { label: t("Back to {thing}", { thing: name(below) }), text: name(below), onBack: pop } : void 0,
2592
+ children: [
2593
+ top.kind === "tree" && /* @__PURE__ */ jsx(CreateTree, { onPick: (key) => setStack([{ kind: "tree" }, { kind: "form", key }]) }),
2594
+ notLive && top.kind === "form" && /* @__PURE__ */ jsxs("p", { className: "cbx-create-env", role: "note", children: [
2595
+ /* @__PURE__ */ jsx(ToneSquare, { tone: environmentLevelItem.tone }),
2596
+ t("Creating in {environment}, not production", { environment: environmentLevelItem.name })
2597
+ ] }),
2598
+ stack.map((entry, index) => {
2599
+ if (entry.kind !== "form") return null;
2600
+ const creatable = findCreatable(shell, entry.key);
2601
+ if (creatable === void 0) return null;
2602
+ const under = stack[index - 1];
2603
+ const parent = under?.kind === "form" ? findCreatable(shell, under.key) ?? null : null;
2604
+ const form = {
2605
+ creatable,
2606
+ parent,
2607
+ submitLabel: parent !== null ? t("Create and use in {thing}", { thing: parent.label.toLowerCase() }) : creatable.submitLabel ?? t("Create {thing}", { thing: creatable.label.toLowerCase() }),
2608
+ createRef: (key, onCreated) => {
2609
+ if (findCreatable(shell, key) === void 0) return;
2610
+ setStack((current) => [...current.slice(0, index + 1), { kind: "form", key, onCreated }]);
2611
+ },
2612
+ done: (created) => {
2613
+ if (parent === null) {
2614
+ onClose();
2615
+ return;
2616
+ }
2617
+ setStack((current) => current.slice(0, index));
2618
+ if (created !== void 0) entry.onCreated?.(created);
2619
+ },
2620
+ close: onClose,
2621
+ environment: environmentLevelItem
2622
+ };
2623
+ const body = renderCreate?.(form) ?? null;
2624
+ return /* @__PURE__ */ jsx("div", { className: "cbx-create-form", hidden: entry !== top, children: body ?? /* @__PURE__ */ jsx("p", { className: "cbx-list-note", children: t("{thing} cannot be created here yet.", { thing: creatable.label }) }) }, `${index}:${entry.key}`);
2625
+ })
2626
+ ]
2627
+ }
2628
+ );
2629
+ }
2630
+ function CreateTree({ onPick }) {
2631
+ const { shell, t, icons } = useShell();
2632
+ const [q, setQ] = useState("");
2633
+ const groups = useMemo(() => {
2634
+ const items = (shell.create?.items ?? []).filter((item) => matchScore(`${item.label} ${(item.keywords ?? []).join(" ")}`, q) > 0);
2635
+ const order = [shell.nav.activeArea, ...shell.nav.areas.map((area) => area.key).filter((key) => key !== shell.nav.activeArea)];
2636
+ const keys = Array.from(new Set(items.map((item) => item.area))).sort((a, b) => {
2637
+ const ia = order.indexOf(a);
2638
+ const ib = order.indexOf(b);
2639
+ return (ia < 0 ? order.length : ia) - (ib < 0 ? order.length : ib);
2640
+ });
2641
+ return keys.map((key) => ({ area: shell.nav.areas.find((area) => area.key === key), key, items: items.filter((item) => item.area === key) }));
2642
+ }, [shell, q]);
2643
+ return /* @__PURE__ */ jsxs("div", { className: "cbx-create-tree", children: [
2644
+ /* @__PURE__ */ jsxs("label", { className: "cbx-field-search", children: [
2645
+ /* @__PURE__ */ jsx(Search, { size: 18, strokeWidth: 1.8, "aria-hidden": true }),
2646
+ /* @__PURE__ */ jsx("input", { type: "search", value: q, onChange: (event) => setQ(event.target.value), placeholder: t("What do you want to create?"), "aria-label": t("Search what to create"), autoComplete: "off" })
2647
+ ] }),
2648
+ groups.map((group) => {
2649
+ const Icon = resolveIcon(group.area?.icon, icons);
2650
+ return /* @__PURE__ */ jsxs("section", { "aria-label": group.area?.label ?? group.key, children: [
2651
+ /* @__PURE__ */ jsx("h2", { className: "cbx-eyebrow", children: group.area?.label ?? group.key }),
2652
+ /* @__PURE__ */ jsx("div", { className: "cbx-group", children: group.items.map((item) => /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-grow", onClick: () => onPick(item.key), children: [
2653
+ /* @__PURE__ */ jsx("span", { className: "cbx-tile", style: { "--cbx-hue": String(hueFor(group.key)) }, "aria-hidden": "true", children: /* @__PURE__ */ jsx(Icon, { size: 16, strokeWidth: 1.8, "aria-hidden": true }) }),
2654
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: item.label }),
2655
+ /* @__PURE__ */ jsx(ChevronRight, { className: "cbx-grow-trail", size: 16, strokeWidth: 1.8, "aria-hidden": true })
2656
+ ] }, item.key)) })
2657
+ ] }, group.key);
2658
+ }),
2659
+ groups.length === 0 && /* @__PURE__ */ jsx("p", { className: "cbx-list-note", children: t("Nothing matches \u201C{query}\u201D.", { query: q.trim() }) })
2660
+ ] });
2661
+ }
2662
+ function CreateField({ label, children, htmlFor }) {
2663
+ return /* @__PURE__ */ jsxs("div", { className: "cbx-cfield", children: [
2664
+ htmlFor !== void 0 ? /* @__PURE__ */ jsx("label", { className: "cbx-cfield-label", htmlFor, children: label }) : /* @__PURE__ */ jsx("span", { className: "cbx-cfield-label", children: label }),
2665
+ children
2666
+ ] });
2667
+ }
2668
+ function CreateRefField({ label, value, placeholder, thing, onChoose, onCreate }) {
2669
+ const { t } = useShell();
2670
+ const id = useId();
2671
+ return /* @__PURE__ */ jsxs("div", { className: "cbx-cfield", role: "group", "aria-labelledby": id, children: [
2672
+ /* @__PURE__ */ jsx("span", { id, className: "cbx-cfield-label", children: label }),
2673
+ /* @__PURE__ */ jsxs("div", { className: "cbx-group", children: [
2674
+ /* @__PURE__ */ jsxs("button", { type: "button", className: `cbx-grow ${value ? "" : "is-empty"}`, onClick: onChoose, "aria-haspopup": onChoose !== void 0 ? "dialog" : void 0, children: [
2675
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: value || placeholder }),
2676
+ /* @__PURE__ */ jsx(ChevronDown, { className: "cbx-grow-trail", size: 14, strokeWidth: 2, "aria-hidden": true })
2677
+ ] }),
2678
+ /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-grow is-accent", onClick: onCreate, children: [
2679
+ /* @__PURE__ */ jsx(Plus, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
2680
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("New {thing}", { thing: thing.toLowerCase() }) })
2681
+ ] })
2682
+ ] })
2683
+ ] });
2684
+ }
2685
+ function CreateSubmit({ form, busy = false, disabled = false }) {
2686
+ const { t } = useShell();
2687
+ return /* @__PURE__ */ jsx("button", { type: "submit", className: "cbx-button cbx-button-primary cbx-create-submit", disabled: busy || disabled, children: busy ? t("Creating\u2026") : form.submitLabel });
2688
+ }
2689
+ function CreateForm({ onSubmit, children }) {
2690
+ return /* @__PURE__ */ jsx("form", { className: "cbx-cform", onSubmit: (event) => {
2691
+ event.preventDefault();
2692
+ onSubmit(event);
2693
+ }, children });
2694
+ }
2695
+ var MAX_TABS = 4;
2696
+ function tabAreas(areas, tabs) {
2697
+ const chosen = tabs === void 0 ? areas.slice(0, MAX_TABS) : tabs.map((key) => areas.find((area) => area.key === key)).filter((area) => area !== void 0);
2698
+ return chosen.slice(0, MAX_TABS);
2699
+ }
2700
+ function pillLines(levels) {
2701
+ const main = levels[levels.length - 1];
2702
+ if (levels.length <= 1) return { top: main?.label ?? "", main };
2703
+ return { top: levels.slice(0, -1).map((level) => level.current.name).join(" \xB7 "), main };
2704
+ }
2705
+ function notLiveEnvironment(levels) {
2706
+ const environment = environmentLevel(levels)?.current;
2707
+ return environment !== void 0 && isLive(environment) === false ? environment : null;
2708
+ }
2709
+ function useUnread() {
2710
+ const { shell, help } = useShell();
2711
+ return useUnreadCount(help, shell.help.unread);
2712
+ }
2713
+ function MobileTopBar() {
2714
+ const { shell, t, openContext, toggleHelp, setOverlay, openCreate, canCreate } = useShell();
2715
+ const levels = shell.context.levels;
2716
+ const organization = levels[0];
2717
+ const { top, main } = pillLines(levels);
2718
+ const unread = useUnread();
2719
+ const topic = helpTopicName(shell);
2720
+ const trail = levels.map((level) => level.current.name).join(", ");
2721
+ return /* @__PURE__ */ jsxs("div", { className: "cbx-m-bar", children: [
2722
+ organization !== void 0 && /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-m-pill", onClick: () => openContext("root"), "aria-haspopup": "dialog", "aria-label": t("Where you work: {trail}", { trail }), children: [
2723
+ /* @__PURE__ */ jsx(Chip, { item: organization.current, tone: "solid" }),
2724
+ /* @__PURE__ */ jsxs("span", { className: "cbx-m-pill-text", children: [
2725
+ /* @__PURE__ */ jsx("span", { className: "cbx-m-pill-top", children: top }),
2726
+ /* @__PURE__ */ jsxs("span", { className: "cbx-m-pill-main", children: [
2727
+ main?.key === "environment" && /* @__PURE__ */ jsx(ToneSquare, { tone: main.current.tone }),
2728
+ /* @__PURE__ */ jsx("span", { className: "cbx-truncate", children: main?.current.name })
2729
+ ] })
2730
+ ] }),
2731
+ /* @__PURE__ */ jsx(ChevronDown, { className: "cbx-m-pill-chevron", size: 14, strokeWidth: 2, "aria-hidden": true })
2732
+ ] }),
2733
+ /* @__PURE__ */ jsx("span", { className: "cbx-m-spacer" }),
2734
+ /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-m-icon", onClick: () => toggleHelp(true), "aria-controls": "cbx-help", "aria-label": unread > 0 ? t("Help with {page}, {count} unread", { page: topic, count: unread }) : t("Help with {page}", { page: topic }), children: [
2735
+ /* @__PURE__ */ jsx(CircleHelp, { size: 21, strokeWidth: 1.8, "aria-hidden": true }),
2736
+ unread > 0 && /* @__PURE__ */ jsx("span", { className: "cbx-m-dot", "aria-hidden": "true" })
2737
+ ] }),
2738
+ /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-m-icon", onClick: () => setOverlay("palette"), "aria-label": t("Search and commands"), "aria-haspopup": "dialog", children: /* @__PURE__ */ jsx(Search, { size: 21, strokeWidth: 1.8, "aria-hidden": true }) }),
2739
+ canCreate && /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-m-icon is-primary", onClick: () => openCreate(), "aria-haspopup": "dialog", "aria-label": createLabel(shell, t), children: /* @__PURE__ */ jsx(Plus, { size: 22, strokeWidth: 2, "aria-hidden": true }) })
2740
+ ] });
2741
+ }
2742
+ function MobileAreaHead() {
2743
+ const { shell, t, Link } = useShell();
2744
+ const area = shell.nav.areas.find((item) => item.key === shell.nav.activeArea);
2745
+ const pages = area?.pages ?? [];
2746
+ const environment = notLiveEnvironment(shell.context.levels);
2747
+ const strip = useRef(null);
2748
+ useEffect(() => {
2749
+ const list = strip.current;
2750
+ const current = list?.querySelector('[aria-current="page"]');
2751
+ if (list === null || list === void 0 || current === null || current === void 0) return;
2752
+ const overflow = current.offsetLeft + current.offsetWidth - list.clientWidth;
2753
+ if (overflow > 0) list.scrollLeft = overflow + 32;
2754
+ }, [shell.nav.activePage, shell.nav.activeArea]);
2755
+ return /* @__PURE__ */ jsxs("div", { className: "cbx-m-head", children: [
2756
+ area !== void 0 && /* @__PURE__ */ jsx("p", { className: "cbx-m-title", children: area.label }),
2757
+ environment !== null && /* @__PURE__ */ jsxs("div", { className: `cbx-m-env cbx-env-${environment.tone ?? "neutral"}`, role: "status", children: [
2758
+ /* @__PURE__ */ jsx(ToneSquare, { tone: environment.tone }),
2759
+ /* @__PURE__ */ jsx("span", { children: t("{environment}. Not production, nothing here touches live customers.", { environment: environment.name }) })
2760
+ ] }),
2761
+ area !== void 0 && pages.length > 1 ? /* @__PURE__ */ jsx("nav", { ref: strip, className: "cbx-m-chips", "aria-label": t("{area} pages", { area: area.label }), children: pages.map((page) => {
2762
+ const on = page.key === shell.nav.activePage;
2763
+ return /* @__PURE__ */ jsxs(Link, { href: navUrl(page), className: `cbx-m-chip ${on ? "is-on" : ""}`, "aria-current": on ? "page" : void 0, children: [
2764
+ page.label,
2765
+ page.locked === true && /* @__PURE__ */ jsx(NavPageMarks, { page })
2766
+ ] }, page.key);
2767
+ }) }) : /* @__PURE__ */ jsx("div", { className: "cbx-m-chips-gap" })
2768
+ ] });
2769
+ }
2770
+ function TabBar({ onMore }) {
2771
+ const { shell, t, Link, icons, overlay, setOverlay } = useShell();
2772
+ const tabs = tabAreas(shell.nav.areas, shell.nav.tabs);
2773
+ const moreOpen = overlay === "more";
2774
+ const inTabs = tabs.some((area) => area.key === shell.nav.activeArea);
2775
+ return /* @__PURE__ */ jsxs("nav", { className: "cbx-tabbar", "aria-label": t("Main"), children: [
2776
+ tabs.map((area) => {
2777
+ const Icon = resolveIcon(area.icon, icons);
2778
+ const on = !moreOpen && area.key === shell.nav.activeArea;
2779
+ return /* @__PURE__ */ jsxs(Link, { href: navUrl(area), className: `cbx-tab ${on ? "is-on" : ""}`, "aria-current": on ? "page" : void 0, onClick: () => {
2780
+ if (moreOpen) setOverlay(null);
2781
+ }, children: [
2782
+ /* @__PURE__ */ jsx(Icon, { size: 23, strokeWidth: 1.7, "aria-hidden": true }),
2783
+ /* @__PURE__ */ jsx("span", { children: area.label })
2784
+ ] }, area.key);
2785
+ }),
2786
+ /* @__PURE__ */ jsxs("button", { type: "button", className: `cbx-tab ${moreOpen || !inTabs ? "is-on" : ""}`, "aria-expanded": moreOpen, "aria-controls": "cbx-more", onClick: onMore, children: [
2787
+ /* @__PURE__ */ jsx(MoreHorizontal, { size: 23, strokeWidth: 1.7, "aria-hidden": true }),
2788
+ /* @__PURE__ */ jsx("span", { children: t("More") })
2789
+ ] })
2790
+ ] });
2791
+ }
2792
+ function BackBar({ label, onBack }) {
2793
+ return /* @__PURE__ */ jsx("div", { className: "cbx-m-bar", children: /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-m-back", onClick: onBack, children: [
2794
+ /* @__PURE__ */ jsx(ChevronLeft, { size: 22, strokeWidth: 2, "aria-hidden": true }),
2795
+ label
2796
+ ] }) });
2797
+ }
2798
+ function Row({ children, onClick, href, className, ...rest }) {
2799
+ const { Link } = useShell();
2800
+ if (href !== void 0) {
2801
+ if (rest.target !== void 0) return /* @__PURE__ */ jsx("a", { href, className: `cbx-grow ${className ?? ""}`, onClick, ...rest, children });
2802
+ return /* @__PURE__ */ jsx(Link, { href, className: `cbx-grow ${className ?? ""}`, onClick, ...rest, children });
2803
+ }
2804
+ return /* @__PURE__ */ jsx("button", { type: "button", className: `cbx-grow ${className ?? ""}`, onClick, ...rest, children });
2805
+ }
2806
+ var Trail = () => /* @__PURE__ */ jsx(ChevronRight, { className: "cbx-grow-trail", size: 16, strokeWidth: 1.8, "aria-hidden": true });
2807
+ function MoreScreen({ view, setView }) {
2808
+ const { t } = useShell();
2809
+ const top = useRef(null);
2810
+ useEffect(() => {
2811
+ if (typeof window !== "undefined" && typeof window.scrollTo === "function") {
2812
+ try {
2813
+ window.scrollTo(0, 0);
2814
+ } catch {
2815
+ }
2816
+ }
2817
+ top.current?.focus({ preventScroll: true });
2818
+ }, [view]);
2819
+ let body;
2820
+ if (view.kind === "area") body = /* @__PURE__ */ jsx(MoreArea, { areaKey: view.key, onBack: () => setView({ kind: "root" }) });
2821
+ else if (view.kind === "account") body = /* @__PURE__ */ jsx(MoreAccount, { onBack: () => setView({ kind: "root" }), onOption: (which) => setView({ kind: "option", which }) });
2822
+ else if (view.kind === "option") body = /* @__PURE__ */ jsx(MoreOption, { which: view.which, onBack: () => setView({ kind: "account" }) });
2823
+ else body = /* @__PURE__ */ jsx(MoreRoot, { onArea: (key) => setView({ kind: "area", key }), onAccount: () => setView({ kind: "account" }) });
2824
+ return /* @__PURE__ */ jsx("section", { id: "cbx-more", className: "cbx-more", "aria-label": t("More"), ref: top, tabIndex: -1, children: body });
2825
+ }
2826
+ function MoreRoot({ onArea, onAccount }) {
2827
+ const { shell, t, icons, Link, setOverlay, openContext, toggleHelp } = useShell();
2828
+ const [q, setQ] = useState("");
2829
+ const unread = useUnread();
2830
+ const topic = helpTopicName(shell);
2831
+ const hits = useMemo(() => {
2832
+ const query2 = q.trim();
2833
+ if (query2 === "") return [];
2834
+ const found = [];
2835
+ for (const area of shell.nav.areas) {
2836
+ const pages = area.pages ?? [];
2837
+ if (pages.length === 0) {
2838
+ const score = matchScore(area.label, query2);
2839
+ if (score > 0) found.push({ key: area.key, label: area.label, area: area.label, url: navUrl(area), score });
2840
+ }
2841
+ for (const page of pages) {
2842
+ const score = Math.max(matchScore(page.label, query2), matchScore(`${area.label} ${page.group ?? ""}`, query2) > 0 ? 1 : 0);
2843
+ if (score > 0) found.push({ key: `${area.key}:${page.key}`, label: page.label, area: area.label, url: navUrl(page), score });
2844
+ }
2845
+ }
2846
+ return found.sort((a, b) => b.score - a.score);
2847
+ }, [q, shell]);
2848
+ const appName = shell.app.name.replace(/^Cbox\s*·?\s*/i, "");
2849
+ const account = shell.account ?? {};
2850
+ return /* @__PURE__ */ jsxs("div", { className: "cbx-more-page", children: [
2851
+ /* @__PURE__ */ jsx("div", { className: "cbx-m-bar" }),
2852
+ /* @__PURE__ */ jsx("h1", { className: "cbx-m-big", children: t("More") }),
2853
+ /* @__PURE__ */ jsxs("label", { className: "cbx-field-search", children: [
2854
+ /* @__PURE__ */ jsx(Search, { size: 18, strokeWidth: 1.8, "aria-hidden": true }),
2855
+ /* @__PURE__ */ jsx("input", { type: "search", value: q, onChange: (event) => setQ(event.target.value), placeholder: t("Search all pages"), "aria-label": t("Search all pages"), autoComplete: "off" })
2856
+ ] }),
2857
+ q.trim() !== "" ? /* @__PURE__ */ jsxs("div", { className: "cbx-group", role: "group", "aria-label": t("Pages"), children: [
2858
+ hits.map((hit) => /* @__PURE__ */ jsxs(Link, { href: hit.url, className: "cbx-grow", onClick: () => setOverlay(null), children: [
2859
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: hit.label }),
2860
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-count", children: hit.area })
2861
+ ] }, hit.key)),
2862
+ hits.length === 0 && /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-grow is-muted", onClick: () => setOverlay("palette"), children: [
2863
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("No page matches. Search finds records too.") }),
2864
+ /* @__PURE__ */ jsx(Trail, {})
2865
+ ] })
2866
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2867
+ /* @__PURE__ */ jsx("h2", { className: "cbx-eyebrow", children: appName }),
2868
+ /* @__PURE__ */ jsx("div", { className: "cbx-group", children: shell.nav.areas.map((area) => {
2869
+ const Icon = resolveIcon(area.icon, icons);
2870
+ const pages = area.pages ?? [];
2871
+ const tile = /* @__PURE__ */ jsx("span", { className: "cbx-tile", style: { "--cbx-hue": String(hueFor(area.key)) }, "aria-hidden": "true", children: /* @__PURE__ */ jsx(Icon, { size: 16, strokeWidth: 1.8, "aria-hidden": true }) });
2872
+ const lock = areaLocked(area) ? /* @__PURE__ */ jsxs("span", { className: "cbx-nav-lock", title: t("Not in your plan"), children: [
2873
+ /* @__PURE__ */ jsx(Lock, { size: 13, strokeWidth: 1.9, "aria-hidden": true }),
2874
+ /* @__PURE__ */ jsx("span", { className: "cbx-sr-only", children: t("(locked)") })
2875
+ ] }) : null;
2876
+ if (pages.length <= 1) {
2877
+ return /* @__PURE__ */ jsxs(Row, { href: navUrl(area), onClick: () => setOverlay(null), "aria-current": area.key === shell.nav.activeArea ? "page" : void 0, children: [
2878
+ tile,
2879
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: area.label }),
2880
+ lock,
2881
+ /* @__PURE__ */ jsx(Trail, {})
2882
+ ] }, area.key);
2883
+ }
2884
+ return /* @__PURE__ */ jsxs(Row, { onClick: () => onArea(area.key), children: [
2885
+ tile,
2886
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: area.label }),
2887
+ lock,
2888
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-count", children: pages.length }),
2889
+ /* @__PURE__ */ jsx(Trail, {})
2890
+ ] }, area.key);
2891
+ }) }),
2892
+ /* @__PURE__ */ jsx(WhereYouWork, { onStep: (step) => openContext(step, true) }),
2893
+ /* @__PURE__ */ jsx("h2", { className: "cbx-eyebrow", children: t("Help") }),
2894
+ /* @__PURE__ */ jsx("div", { className: "cbx-group", children: /* @__PURE__ */ jsxs(Row, { className: "is-tall", onClick: () => toggleHelp(true), "aria-haspopup": "dialog", children: [
2895
+ /* @__PURE__ */ jsx("span", { className: "cbx-tile is-accent", "aria-hidden": "true", children: /* @__PURE__ */ jsx(CircleHelp, { size: 17, strokeWidth: 1.8 }) }),
2896
+ /* @__PURE__ */ jsxs("span", { className: "cbx-grow-text", children: [
2897
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-strong", children: t("Help with {page}", { page: topic }) }),
2898
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-sub", children: t("Articles, Ask Cbox, chat with support") })
2899
+ ] }),
2900
+ unread > 0 && /* @__PURE__ */ jsx("span", { className: "cbx-badge", children: t("{count} new", { count: unread }) }),
2901
+ /* @__PURE__ */ jsx(Trail, {})
2902
+ ] }) }),
2903
+ /* @__PURE__ */ jsxs("div", { className: "cbx-group", children: [
2904
+ shell.notifications.enabled && /* @__PURE__ */ jsxs(Row, { href: shell.notifications.url, onClick: () => setOverlay(null), children: [
2905
+ /* @__PURE__ */ jsx("span", { className: "cbx-tile is-plain", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Bell, { size: 16, strokeWidth: 1.8 }) }),
2906
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("Notifications") }),
2907
+ shell.notifications.unread > 0 && /* @__PURE__ */ jsx("span", { className: "cbx-badge", children: shell.notifications.unread }),
2908
+ /* @__PURE__ */ jsx(Trail, {})
2909
+ ] }),
2910
+ /* @__PURE__ */ jsxs(Row, { onClick: () => setOverlay("apps-sheet"), "aria-haspopup": "dialog", children: [
2911
+ /* @__PURE__ */ jsx("span", { className: "cbx-tile is-primary", "aria-hidden": "true", children: /* @__PURE__ */ jsx(LayoutGrid, { size: 16, strokeWidth: 2 }) }),
2912
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("Switch app") }),
2913
+ /* @__PURE__ */ jsx(Trail, {})
2914
+ ] })
2915
+ ] }),
2916
+ /* @__PURE__ */ jsx("div", { className: "cbx-group", children: /* @__PURE__ */ jsxs(Row, { className: "is-tall", onClick: onAccount, children: [
2917
+ /* @__PURE__ */ jsx(Avatar, { size: 40 }),
2918
+ /* @__PURE__ */ jsxs("span", { className: "cbx-grow-text", children: [
2919
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-strong", children: shell.person.name }),
2920
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-sub", children: account.signedInWith !== void 0 ? account.signedInWith : t("Profile, language, theme") })
2921
+ ] }),
2922
+ /* @__PURE__ */ jsx(Trail, {})
2923
+ ] }) })
2924
+ ] })
2925
+ ] });
2926
+ }
2927
+ function WhereYouWork({ onStep }) {
2928
+ const { shell, t } = useShell();
2929
+ const levels = shell.context.levels;
2930
+ const environment = environmentLevel(levels);
2931
+ const parentOfEnvironment = environment !== void 0 ? levels[levels.indexOf(environment) - 1]?.current.id : void 0;
2932
+ const list = useContextList(environment?.listUrl, { parent: parentOfEnvironment, enabled: environment !== void 0 });
2933
+ if (levels.length === 0) return null;
2934
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2935
+ /* @__PURE__ */ jsx("h2", { className: "cbx-eyebrow", children: t("Where you work") }),
2936
+ /* @__PURE__ */ jsx("div", { className: "cbx-group", children: levels.map((level, index) => {
2937
+ const env = level.key === "environment";
2938
+ return /* @__PURE__ */ jsxs(Row, { onClick: () => onStep(env ? "environments" : level.key), "aria-haspopup": "dialog", children: [
2939
+ index === 0 ? /* @__PURE__ */ jsx(Chip, { item: level.current, tone: "soft" }) : env ? /* @__PURE__ */ jsx("span", { className: "cbx-tile is-plain", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ToneSquare, { tone: level.current.tone }) }) : /* @__PURE__ */ jsx("span", { className: "cbx-tile is-plain", "aria-hidden": "true", children: level.current.initials ?? level.current.name.slice(0, 2) }),
2940
+ /* @__PURE__ */ jsxs("span", { className: "cbx-grow-text", children: [
2941
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-sub", children: level.label }),
2942
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-strong", children: level.current.name })
2943
+ ] }),
2944
+ env && list.status === "ready" && !list.hasMore && /* @__PURE__ */ jsx("span", { className: "cbx-grow-count", children: list.items.length }),
2945
+ /* @__PURE__ */ jsx(Trail, {})
2946
+ ] }, level.key);
2947
+ }) })
2948
+ ] });
2949
+ }
2950
+ function MoreArea({ areaKey, onBack }) {
2951
+ const { shell, t, setOverlay } = useShell();
2952
+ const area = shell.nav.areas.find((item) => item.key === areaKey);
2953
+ if (area === void 0) return null;
2954
+ return /* @__PURE__ */ jsxs("div", { className: "cbx-more-page", children: [
2955
+ /* @__PURE__ */ jsx(BackBar, { label: t("More"), onBack }),
2956
+ /* @__PURE__ */ jsx("h1", { className: "cbx-m-big", children: area.label }),
2957
+ /* @__PURE__ */ jsx("div", { className: "cbx-m-gap" }),
2958
+ groupPages(area.pages ?? []).map((run, index) => /* @__PURE__ */ jsxs("section", { role: "group", "aria-label": run.group ?? area.label, children: [
2959
+ run.group !== void 0 && /* @__PURE__ */ jsx("h2", { className: "cbx-eyebrow", "aria-hidden": "true", children: run.group }),
2960
+ /* @__PURE__ */ jsx("div", { className: "cbx-group", children: run.pages.map((page) => {
2961
+ const on = area.key === shell.nav.activeArea && page.key === shell.nav.activePage;
2962
+ return /* @__PURE__ */ jsxs(Row, { href: navUrl(page), onClick: () => setOverlay(null), "aria-current": on ? "page" : void 0, className: page.locked === true ? "is-locked" : "", children: [
2963
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: page.label }),
2964
+ /* @__PURE__ */ jsx(NavPageMarks, { page }),
2965
+ /* @__PURE__ */ jsx(Trail, {})
2966
+ ] }, page.key);
2967
+ }) })
2968
+ ] }, index))
2969
+ ] });
2970
+ }
2971
+ var DEFAULT_LANGUAGES2 = [
2972
+ { code: "en", label: "English" },
2973
+ { code: "da", label: "Dansk" }
2974
+ ];
2975
+ var DEFAULT_FORMATS2 = [
2976
+ { code: "en-GB", label: "English (United Kingdom)" },
2977
+ { code: "en-US", label: "English (United States)" },
2978
+ { code: "da-DK", label: "Dansk (Danmark)" },
2979
+ { code: "de-DE", label: "Deutsch (Deutschland)" },
2980
+ { code: "sv-SE", label: "Svenska (Sverige)" },
2981
+ { code: "nb-NO", label: "Norsk bokm\xE5l (Norge)" }
2982
+ ];
2983
+ function zones() {
2984
+ const supported = Intl.supportedValuesOf;
2985
+ const list = typeof supported === "function" ? supported("timeZone") : ["UTC", "Europe/Copenhagen", "Europe/London", "Europe/Berlin", "America/New_York"];
2986
+ return list.map((zone) => ({ code: zone, label: zone.replace(/_/g, " ") }));
2987
+ }
2988
+ function MoreAccount({ onBack, onOption }) {
2989
+ const { shell, t, preferences, setPreference, navigate } = useShell();
2990
+ const account = shell.account ?? {};
2991
+ const languages = account.languages ?? DEFAULT_LANGUAGES2;
2992
+ const formats = account.formats ?? DEFAULT_FORMATS2;
2993
+ const label = (options, code, fallback) => options.find((option) => option.code === code)?.label ?? code ?? fallback;
2994
+ const themes = [
2995
+ { value: "system", label: t("System") },
2996
+ { value: "light", label: t("Light") },
2997
+ { value: "dark", label: t("Dark") }
2998
+ ];
2999
+ return /* @__PURE__ */ jsxs("div", { className: "cbx-more-page", children: [
3000
+ /* @__PURE__ */ jsx(BackBar, { label: t("More"), onBack }),
3001
+ /* @__PURE__ */ jsx("h1", { className: "cbx-m-big", children: t("Account") }),
3002
+ /* @__PURE__ */ jsx("div", { className: "cbx-m-gap" }),
3003
+ /* @__PURE__ */ jsxs("div", { className: "cbx-group", children: [
3004
+ /* @__PURE__ */ jsxs("div", { className: "cbx-grow is-tall is-static", children: [
3005
+ /* @__PURE__ */ jsx(Avatar, { size: 40 }),
3006
+ /* @__PURE__ */ jsxs("span", { className: "cbx-grow-text", children: [
3007
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-strong", children: shell.person.name }),
3008
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-sub", children: account.signedInWith ?? t("Signed in with Cbox ID") })
3009
+ ] })
3010
+ ] }),
3011
+ account.profileUrl !== void 0 && /* @__PURE__ */ jsxs("a", { className: "cbx-grow", href: account.profileUrl, children: [
3012
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("Profile and security") }),
3013
+ /* @__PURE__ */ jsx(ArrowUpRight, { className: "cbx-grow-trail", size: 16, strokeWidth: 1.8, "aria-hidden": true })
3014
+ ] })
3015
+ ] }),
3016
+ /* @__PURE__ */ jsxs("div", { className: "cbx-group", children: [
3017
+ /* @__PURE__ */ jsxs(Row, { onClick: () => onOption("locale"), children: [
3018
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("Language") }),
3019
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-value", children: label(languages, preferences.locale, "English") })
3020
+ ] }),
3021
+ /* @__PURE__ */ jsxs(Row, { onClick: () => onOption("regionalFormat"), children: [
3022
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("Regional format") }),
3023
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-value", children: label(formats, preferences.regionalFormat, t("Automatic")) })
3024
+ ] }),
3025
+ /* @__PURE__ */ jsxs(Row, { onClick: () => onOption("timeZone"), children: [
3026
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("Time zone") }),
3027
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-value", children: (preferences.timeZone ?? t("Automatic")).replace(/_/g, " ") })
3028
+ ] })
3029
+ ] }),
3030
+ /* @__PURE__ */ jsx("h2", { className: "cbx-eyebrow", id: "cbx-theme-label", children: t("Theme") }),
3031
+ /* @__PURE__ */ jsx("div", { className: "cbx-seg", role: "radiogroup", "aria-labelledby": "cbx-theme-label", children: themes.map((theme) => /* @__PURE__ */ jsx("button", { type: "button", role: "radio", "aria-checked": preferences.theme === theme.value, className: preferences.theme === theme.value ? "is-on" : "", onClick: () => setPreference("theme", theme.value), children: theme.label }, theme.value)) }),
3032
+ (account.switchAccountUrl !== void 0 || account.signOutUrl !== void 0) && /* @__PURE__ */ jsxs("div", { className: "cbx-group", children: [
3033
+ account.switchAccountUrl !== void 0 && /* @__PURE__ */ jsx("a", { className: "cbx-grow", href: account.switchAccountUrl, children: /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("Switch account") }) }),
3034
+ account.signOutUrl !== void 0 && /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-grow is-danger", onClick: () => navigate(account.signOutUrl, { method: account.signOutMethod ?? "post" }), children: /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("Sign out") }) })
3035
+ ] })
3036
+ ] });
3037
+ }
3038
+ function MoreOption({ which, onBack }) {
3039
+ const { shell, t, preferences, setPreference } = useShell();
3040
+ const account = shell.account ?? {};
3041
+ const options = which === "locale" ? account.languages ?? DEFAULT_LANGUAGES2 : which === "regionalFormat" ? account.formats ?? DEFAULT_FORMATS2 : zones();
3042
+ const title = which === "locale" ? t("Language") : which === "regionalFormat" ? t("Regional format") : t("Time zone");
3043
+ return /* @__PURE__ */ jsxs("div", { className: "cbx-more-page", children: [
3044
+ /* @__PURE__ */ jsx(BackBar, { label: t("Account"), onBack }),
3045
+ /* @__PURE__ */ jsx("h1", { className: "cbx-m-big", children: title }),
3046
+ /* @__PURE__ */ jsx("div", { className: "cbx-m-gap" }),
3047
+ /* @__PURE__ */ jsx(
3048
+ OptionList,
3049
+ {
3050
+ label: title,
3051
+ options,
3052
+ current: preferences[which],
3053
+ autoFocus: false,
3054
+ onPick: (code) => {
3055
+ setPreference(which, code);
3056
+ onBack();
3057
+ }
3058
+ }
3059
+ )
3060
+ ] });
3061
+ }
3062
+ function useMoreView() {
3063
+ const [view, setView] = useState({ kind: "root" });
3064
+ return [view, setView];
3065
+ }
3066
+ function ContextSheet({ onClose }) {
3067
+ const { shell, t, switchTo, contextStep } = useShell();
3068
+ const [step, setStep] = useState(contextStep.step);
3069
+ const direct = contextStep.direct;
3070
+ const levels = shell.context.levels;
3071
+ const back = () => direct ? onClose() : setStep("root");
3072
+ if (step === "environments") {
3073
+ const environment = environmentLevel(levels);
3074
+ if (environment !== void 0) {
3075
+ const index = levels.indexOf(environment);
3076
+ const parent = levels[index - 1];
3077
+ return /* @__PURE__ */ jsx(Sheet, { label: parent !== void 0 && index > 0 ? t("{things} in {name}", { things: pluralOf(environment), name: parent.current.name }) : pluralOf(environment), size: "tall", onClose, back: { label: t("Back"), onBack: back }, children: /* @__PURE__ */ jsx(EnvironmentList, { level: environment, parent: index > 0 ? parent?.current.id : void 0, parentName: index > 0 ? parent?.current.name : void 0, onPick: (item) => switchTo(parent !== void 0 && index > 0 ? { [parent.key]: parent.current.id, [environment.key]: item.id } : { [environment.key]: item.id }) }) });
3078
+ }
3079
+ }
3080
+ const level = levels.find((item) => item.key === step);
3081
+ if (step !== "root" && level !== void 0) {
3082
+ const index = levels.indexOf(level);
3083
+ const parent = index > 0 ? levels[index - 1] : void 0;
3084
+ const inner = levels[index + 1];
3085
+ return /* @__PURE__ */ jsx(Sheet, { label: level.label, size: "tall", onClose, back: { label: t("Back"), onBack: back }, children: /* @__PURE__ */ jsx("div", { className: "cbx-sheet-level", children: /* @__PURE__ */ jsx(
3086
+ LevelPane,
3087
+ {
3088
+ level,
3089
+ parent: parent?.current.id,
3090
+ currentId: level.current.id,
3091
+ heading: pluralOf(level),
3092
+ createLabel: t("New {thing}", { thing: level.label.toLowerCase() }),
3093
+ onPick: (item) => index === 0 ? switchTo({ [level.key]: item.id }) : void pickKeepingEnvironment(level, inner, item, switchTo)
3094
+ }
3095
+ ) }) });
3096
+ }
3097
+ return /* @__PURE__ */ jsx(Sheet, { label: t("Where you work"), onClose, children: /* @__PURE__ */ jsx(ContextRoot, { onStep: setStep }) });
3098
+ }
3099
+ function ContextRoot({ onStep }) {
3100
+ const { shell, t, switchTo } = useShell();
3101
+ const levels = shell.context.levels;
3102
+ const environment = environmentLevel(levels);
3103
+ const above = levels.filter((level) => level !== environment);
3104
+ const envIndex = environment !== void 0 ? levels.indexOf(environment) : -1;
3105
+ const parent = envIndex > 0 ? levels[envIndex - 1] : void 0;
3106
+ const list = useContextList(environment?.listUrl, { parent: parent?.current.id, enabled: environment !== void 0 });
3107
+ const picks = environment !== void 0 ? quickEnvironments(list.items, environment.current) : [];
3108
+ const pick = (item) => {
3109
+ if (environment === void 0) return;
3110
+ switchTo(parent !== void 0 ? { [parent.key]: parent.current.id, [environment.key]: item.id } : { [environment.key]: item.id });
3111
+ };
3112
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3113
+ /* @__PURE__ */ jsx("div", { className: "cbx-group", children: above.map((level, index) => /* @__PURE__ */ jsxs(Row, { onClick: () => onStep(level.key), children: [
3114
+ index === 0 && /* @__PURE__ */ jsx(Chip, { item: level.current, tone: "soft" }),
3115
+ /* @__PURE__ */ jsxs("span", { className: "cbx-grow-text", children: [
3116
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-sub", children: level.label }),
3117
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-strong", children: level.current.name })
3118
+ ] }),
3119
+ /* @__PURE__ */ jsx(Trail, {})
3120
+ ] }, level.key)) }),
3121
+ environment !== void 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
3122
+ /* @__PURE__ */ jsx("h2", { className: "cbx-eyebrow", children: environment.label }),
3123
+ /* @__PURE__ */ jsxs("div", { className: "cbx-group", role: "group", "aria-label": environment.label, children: [
3124
+ picks.map((item) => {
3125
+ const current = item.id === environment.current.id;
3126
+ return /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-grow", "aria-current": current ? "true" : void 0, onClick: () => current ? void 0 : pick(item), children: [
3127
+ /* @__PURE__ */ jsx(ToneSquare, { tone: item.tone }),
3128
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label cbx-grow-strong", children: item.name }),
3129
+ current && /* @__PURE__ */ jsx(Check, { className: "cbx-grow-check", size: 18, strokeWidth: 2, "aria-label": t("Current") })
3130
+ ] }, item.id);
3131
+ }),
3132
+ /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-grow is-accent", onClick: () => onStep("environments"), children: [
3133
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: list.status === "ready" && !list.hasMore ? t("All {count} {things}", { count: list.items.length, things: pluralOf(environment).toLowerCase() }) : t("All {things}", { things: pluralOf(environment).toLowerCase() }) }),
3134
+ /* @__PURE__ */ jsx(Trail, {})
3135
+ ] })
3136
+ ] })
3137
+ ] })
3138
+ ] });
3139
+ }
3140
+ function EnvironmentList({ level, parent, parentName, onPick }) {
3141
+ const { t } = useShell();
3142
+ const [q, setQ] = useState("");
3143
+ const [creating, setCreating] = useState(false);
3144
+ const list = useContextList(level.listUrl, { q, parent });
3145
+ const plural = pluralOf(level);
3146
+ return /* @__PURE__ */ jsxs("div", { className: "cbx-env-list", children: [
3147
+ /* @__PURE__ */ jsxs("label", { className: "cbx-field-search", children: [
3148
+ /* @__PURE__ */ jsx(Search, { size: 18, strokeWidth: 1.8, "aria-hidden": true }),
3149
+ /* @__PURE__ */ jsx("input", { type: "search", value: q, onChange: (event) => setQ(event.target.value), placeholder: t("Search {things}", { things: plural.toLowerCase() }), "aria-label": t("Search {things}", { things: plural.toLowerCase() }), autoComplete: "off" })
3150
+ ] }),
3151
+ groupItems(list.items).map((run, index) => /* @__PURE__ */ jsxs("section", { "aria-label": run.group ?? plural, children: [
3152
+ run.group !== void 0 && /* @__PURE__ */ jsx("h2", { className: "cbx-eyebrow", children: run.group }),
3153
+ /* @__PURE__ */ jsx("div", { className: "cbx-group", children: run.items.map((item) => {
3154
+ const current = item.id === level.current.id;
3155
+ return /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-grow", "aria-current": current ? "true" : void 0, onClick: () => current ? void 0 : onPick(item), children: [
3156
+ /* @__PURE__ */ jsx(ToneSquare, { tone: item.tone }),
3157
+ /* @__PURE__ */ jsxs("span", { className: "cbx-grow-text", children: [
3158
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-strong", children: item.name }),
3159
+ (item.description ?? item.label) !== void 0 && /* @__PURE__ */ jsx("span", { className: "cbx-grow-sub", children: item.description ?? item.label })
3160
+ ] }),
3161
+ current && /* @__PURE__ */ jsx(Check, { className: "cbx-grow-check", size: 18, strokeWidth: 2, "aria-label": t("Current") })
3162
+ ] }, item.id);
3163
+ }) })
3164
+ ] }, run.group ?? `run-${index}`)),
3165
+ list.hasMore && /* @__PURE__ */ jsx("div", { className: "cbx-group", children: /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-grow is-accent", onClick: list.loadMore, children: /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: list.loadingMore ? t("Loading\u2026") : t("Show more") }) }) }),
3166
+ list.status === "loading" && list.items.length === 0 && /* @__PURE__ */ jsx("p", { className: "cbx-list-note", "aria-live": "polite", children: t("Loading\u2026") }),
3167
+ list.status === "error" && /* @__PURE__ */ jsxs("p", { className: "cbx-list-note", role: "alert", children: [
3168
+ t("{things} could not be loaded.", { things: plural }),
3169
+ " ",
3170
+ /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-link", onClick: list.retry, children: t("Try again") })
3171
+ ] }),
3172
+ list.status === "ready" && list.items.length === 0 && /* @__PURE__ */ jsx("p", { className: "cbx-list-note", "aria-live": "polite", children: q.trim() === "" ? t("No {things} yet.", { things: plural.toLowerCase() }) : t("Nothing matches \u201C{query}\u201D.", { query: q.trim() }) }),
3173
+ level.createUrl !== void 0 && /* @__PURE__ */ jsx("div", { className: "cbx-group", children: creating ? /* @__PURE__ */ jsx("div", { className: "cbx-grow is-static", children: /* @__PURE__ */ jsx(InlineCreate, { level, parent, label: parentName !== void 0 ? t("New {thing} in {name}", { thing: level.label.toLowerCase(), name: parentName }) : t("New {thing}", { thing: level.label.toLowerCase() }), onCancel: () => setCreating(false) }) }) : /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-grow is-accent", onClick: () => setCreating(true), children: [
3174
+ /* @__PURE__ */ jsx(Plus, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
3175
+ /* @__PURE__ */ jsx("span", { className: "cbx-grow-label", children: t("New {thing}", { thing: level.label.toLowerCase() }) })
3176
+ ] }) })
3177
+ ] });
3178
+ }
3179
+ function AppsSheet({ onClose }) {
3180
+ const { t } = useShell();
3181
+ return /* @__PURE__ */ jsx(Sheet, { label: t("Switch app"), onClose, children: /* @__PURE__ */ jsx(AppGrid, { autoFocus: false }) });
3182
+ }
2333
3183
  var PlainLink = ({ href, children, ...props }) => /* @__PURE__ */ jsx("a", { href, ...props, children });
2334
3184
  function writeCookie(key, value) {
2335
3185
  if (typeof document === "undefined") return;
@@ -2356,11 +3206,15 @@ function useIsMac() {
2356
3206
  }, []);
2357
3207
  return mac;
2358
3208
  }
2359
- function CboxShell({ shell, children, navigate = defaultNavigate, LinkComponent = PlainLink, icons = {}, onPreferenceChange, helpStore, brandAssetBase = "/brand", mainId = "main-content" }) {
3209
+ function CboxShell({ shell, children, navigate = defaultNavigate, LinkComponent = PlainLink, icons = {}, onPreferenceChange, helpStore, brandAssetBase = "/brand", mainId = "main-content", renderCreate, searchRecords }) {
2360
3210
  const { t } = useCboxLocalization();
2361
3211
  const [store] = useState(() => helpStore ?? sharedHelpStore());
2362
3212
  const [preferences, setPreferences] = useState(shell.preferences);
2363
3213
  const [overlay, setOverlay] = useState(null);
3214
+ const [contextStep, setContextStep] = useState({ step: "root", direct: false });
3215
+ const [createKey, setCreateKey] = useState(null);
3216
+ const mobile = useMedia(MOBILE, false);
3217
+ const [moreView, setMoreView] = useMoreView();
2364
3218
  if (!store.get().seeded) store.set({ open: shell.preferences.helpOpen, restored: shell.preferences.helpOpen, seeded: true });
2365
3219
  const serverPreferences = JSON.stringify(shell.preferences);
2366
3220
  useEffect(() => {
@@ -2387,6 +3241,7 @@ function CboxShell({ shell, children, navigate = defaultNavigate, LinkComponent
2387
3241
  const switchUrl = shell.context.switchUrl;
2388
3242
  const scope = levels.map((level) => `${level.key}:${level.current.id}`).join("|");
2389
3243
  if (scopeLists(scope)) forgetShellCatalog();
3244
+ const canCreate = renderCreate !== void 0 && (shell.create?.items.length ?? 0) > 0;
2390
3245
  const api = useMemo(
2391
3246
  () => ({
2392
3247
  shell,
@@ -2410,10 +3265,29 @@ function CboxShell({ shell, children, navigate = defaultNavigate, LinkComponent
2410
3265
  },
2411
3266
  switchTo: (chosen) => {
2412
3267
  setOverlay(null);
2413
- navigate(switchUrl, { method: "post", data: switchPayload(levels, chosen, currentLocation()) });
2414
- }
3268
+ navigate(switchUrl, { method: "post", data: switchBody(levels, chosen, currentLocation()) });
3269
+ },
3270
+ mobile,
3271
+ contextStep,
3272
+ openContext: (step = "root", direct = false) => {
3273
+ if (mobile) {
3274
+ setContextStep({ step, direct, underMore: overlay === "more" });
3275
+ setOverlay("context-sheet");
3276
+ return;
3277
+ }
3278
+ setOverlay(step === "root" || step === levels[0]?.key || levels.length < 2 ? "org" : "context");
3279
+ },
3280
+ createKey,
3281
+ canCreate,
3282
+ openCreate: (key) => {
3283
+ if (!canCreate) return;
3284
+ setCreateKey(key ?? pageCreateKey(shell));
3285
+ setOverlay("create");
3286
+ },
3287
+ renderCreate,
3288
+ searchRecords
2415
3289
  }),
2416
- [shell, t, navigate, LinkComponent, icons, preferences, setPreference, overlay, store, toggleHelp, levels, switchUrl]
3290
+ [shell, t, navigate, LinkComponent, icons, preferences, setPreference, overlay, store, toggleHelp, levels, switchUrl, mobile, contextStep, createKey, canCreate, renderCreate, searchRecords]
2417
3291
  );
2418
3292
  const preferencesRef = useRef(preferences);
2419
3293
  preferencesRef.current = preferences;
@@ -2434,44 +3308,88 @@ function CboxShell({ shell, children, navigate = defaultNavigate, LinkComponent
2434
3308
  const page = `${shell.nav.activeArea}|${shell.nav.activePage ?? ""}|${shell.page?.title ?? ""}`;
2435
3309
  useEffect(() => {
2436
3310
  setOverlay((current) => current === "palette" ? current : null);
3311
+ setMoreView({ kind: "root" });
3312
+ if (shell.page?.title !== void 0) {
3313
+ const area = shell.nav.areas.find((item) => item.key === shell.nav.activeArea);
3314
+ rememberPage(shell.app.key, { title: shell.page.title, area: area?.label, url: currentLocation() });
3315
+ }
2437
3316
  }, [page]);
2438
3317
  const docked = useMedia(HELP_DOCKED, true);
2439
- const mobile = useMedia(MOBILE, false);
2440
3318
  const testData = levels.some((level) => level.current.testData === true);
2441
3319
  const helpOpen = useHelpState(store, (state) => helpVisible(state, docked));
2442
- const banners = shellBanners(shell, testData);
3320
+ const notLive = notLiveEnvironment(levels);
3321
+ const banners = shellBanners(shell, testData).filter((banner) => !(mobile && notLive !== null && banner.kind === "sandbox"));
3322
+ const envBanner = !mobile && notLive !== null && !banners.some((banner) => banner.kind === "sandbox") ? notLive : null;
3323
+ const strips = banners.map((banner, index) => /* @__PURE__ */ jsxs("div", { className: `cbx-banner cbx-banner-${banner.kind}`, role: "status", children: [
3324
+ /* @__PURE__ */ jsx("span", { className: "cbx-banner-text", children: banner.text }),
3325
+ banner.action !== void 0 && /* @__PURE__ */ jsx(LinkComponent, { href: navUrl(banner.action), className: "cbx-banner-action", children: banner.action.label })
3326
+ ] }, `${banner.kind}-${index}`));
3327
+ const skip = /* @__PURE__ */ jsx(
3328
+ "a",
3329
+ {
3330
+ className: "cbx-skip-link",
3331
+ href: `#${mainId}`,
3332
+ onClick: (event) => {
3333
+ const main = document.getElementById(mainId);
3334
+ if (main === null) return;
3335
+ event.preventDefault();
3336
+ main.focus();
3337
+ main.scrollIntoView?.({ block: "start" });
3338
+ },
3339
+ children: t("Skip to content")
3340
+ }
3341
+ );
3342
+ const overlays = /* @__PURE__ */ jsxs(Fragment, { children: [
3343
+ overlay === "palette" && /* @__PURE__ */ jsx(CommandPalette, { onClose: () => setOverlay(null) }),
3344
+ overlay === "context-sheet" && /* @__PURE__ */ jsx(ContextSheet, { onClose: () => setOverlay(contextStep.underMore === true ? "more" : null) }, `${contextStep.step}:${String(contextStep.direct)}`),
3345
+ overlay === "apps-sheet" && /* @__PURE__ */ jsx(AppsSheet, { onClose: () => setOverlay("more") }),
3346
+ overlay === "create" && /* @__PURE__ */ jsx(CreateSheet, { onClose: () => setOverlay(null) }, createKey ?? "tree")
3347
+ ] });
3348
+ if (mobile) {
3349
+ const moreOpen = overlay === "more" || overlay === "apps-sheet" || overlay === "context-sheet" && contextStep.underMore === true;
3350
+ return /* @__PURE__ */ jsx(ShellContext.Provider, { value: api, children: /* @__PURE__ */ jsxs("div", { className: "cbx-shell is-mobile", "data-help-open": helpOpen, children: [
3351
+ skip,
3352
+ /* @__PURE__ */ jsxs("div", { className: "cbx-shell-column", children: [
3353
+ /* @__PURE__ */ jsxs("header", { className: "cbx-m-chrome", hidden: moreOpen, children: [
3354
+ /* @__PURE__ */ jsx(MobileTopBar, {}),
3355
+ /* @__PURE__ */ jsx(MobileAreaHead, {}),
3356
+ strips
3357
+ ] }),
3358
+ /* @__PURE__ */ jsxs("main", { id: mainId, tabIndex: -1, className: "cbx-shell-main canvas-gradient", children: [
3359
+ moreOpen && /* @__PURE__ */ jsx(MoreScreen, { view: moreView, setView: setMoreView }),
3360
+ /* @__PURE__ */ jsx("div", { className: "cbx-m-page", hidden: moreOpen, children })
3361
+ ] })
3362
+ ] }),
3363
+ /* @__PURE__ */ jsx(
3364
+ TabBar,
3365
+ {
3366
+ onMore: () => {
3367
+ setMoreView({ kind: "root" });
3368
+ setOverlay("more");
3369
+ }
3370
+ }
3371
+ ),
3372
+ /* @__PURE__ */ jsx(HelpColumn, { docked: false, mobile: true }),
3373
+ overlays
3374
+ ] }) });
3375
+ }
2443
3376
  return /* @__PURE__ */ jsx(ShellContext.Provider, { value: api, children: /* @__PURE__ */ jsxs("div", { className: "cbx-shell", "data-help-open": helpOpen, children: [
2444
- /* @__PURE__ */ jsx(
2445
- "a",
2446
- {
2447
- className: "cbx-skip-link",
2448
- href: `#${mainId}`,
2449
- onClick: (event) => {
2450
- const main = document.getElementById(mainId);
2451
- if (main === null) return;
2452
- event.preventDefault();
2453
- main.focus();
2454
- main.scrollIntoView?.({ block: "start" });
2455
- },
2456
- children: t("Skip to content")
2457
- }
2458
- ),
3377
+ skip,
2459
3378
  /* @__PURE__ */ jsx(Rail, { brandAssetBase }),
2460
3379
  /* @__PURE__ */ jsxs("div", { className: "cbx-shell-column", children: [
2461
- /* @__PURE__ */ jsx(Header, { mobile }),
2462
- banners.map((banner, index) => /* @__PURE__ */ jsxs("div", { className: `cbx-banner cbx-banner-${banner.kind}`, role: "status", children: [
2463
- /* @__PURE__ */ jsx("span", { className: "cbx-banner-text", children: banner.text }),
2464
- banner.action !== void 0 && /* @__PURE__ */ jsx(LinkComponent, { href: navUrl(banner.action), className: "cbx-banner-action", children: banner.action.label })
2465
- ] }, `${banner.kind}-${index}`)),
3380
+ /* @__PURE__ */ jsx(Header, {}),
3381
+ envBanner !== null && /* @__PURE__ */ jsxs("div", { className: `cbx-banner cbx-banner-env cbx-env-${envBanner.tone ?? "neutral"}`, role: "status", children: [
3382
+ /* @__PURE__ */ jsx(ToneSquare, { tone: envBanner.tone }),
3383
+ /* @__PURE__ */ jsx("span", { className: "cbx-banner-text", children: t("{environment}. Not production, nothing here touches live customers.", { environment: envBanner.name }) })
3384
+ ] }),
3385
+ strips,
2466
3386
  /* @__PURE__ */ jsxs("div", { className: "cbx-shell-body", children: [
2467
3387
  /* @__PURE__ */ jsx(Subnav, {}),
2468
3388
  /* @__PURE__ */ jsx("main", { id: mainId, tabIndex: -1, className: "cbx-shell-main canvas-gradient", children })
2469
3389
  ] })
2470
3390
  ] }),
2471
3391
  /* @__PURE__ */ jsx(HelpColumn, { docked }),
2472
- overlay === "palette" && /* @__PURE__ */ jsx(CommandPalette, { onClose: () => setOverlay(null) }),
2473
- overlay === "nav-sheet" && /* @__PURE__ */ jsx(NavSheet, { onClose: () => setOverlay(null) }),
2474
- overlay === "context-sheet" && /* @__PURE__ */ jsx(ContextSheet, { onClose: () => setOverlay(null) })
3392
+ overlays
2475
3393
  ] }) });
2476
3394
  }
2477
3395
  function AppMark() {
@@ -2590,7 +3508,7 @@ function Subnav() {
2590
3508
  ) })
2591
3509
  ] });
2592
3510
  }
2593
- function Header({ mobile }) {
3511
+ function Header() {
2594
3512
  const { shell, t, overlay, setOverlay, help, toggleHelp, Link } = useShell();
2595
3513
  const mac = useIsMac();
2596
3514
  const org = useRef(null);
@@ -2598,33 +3516,36 @@ function Header({ mobile }) {
2598
3516
  const apps = useRef(null);
2599
3517
  const docked = useMedia(HELP_DOCKED, true);
2600
3518
  const helpOpen = useHelpState(help, (state) => helpVisible(state, docked));
2601
- const unread = useHelpState(help, (state) => state.updates.filter((update) => update.unread).length);
3519
+ const unread = useUnreadCount(help, shell.help.unread);
2602
3520
  const [organization, ...rest] = shell.context.levels;
2603
- const trail = shell.context.levels.map((level) => level.current.name).join(" / ");
2604
3521
  const close = useCallback(() => setOverlay(null), [setOverlay]);
3522
+ const triggerKeyDown = (event, menu) => {
3523
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
3524
+ event.preventDefault();
3525
+ if (overlay !== menu) setOverlay(menu);
3526
+ else document.querySelector('.cbx-popover .cbx-pane-search input, .cbx-popover [role="listbox"]')?.focus();
3527
+ } else if (event.key === "Escape" && overlay === menu) {
3528
+ event.preventDefault();
3529
+ setOverlay(null);
3530
+ }
3531
+ };
2605
3532
  return /* @__PURE__ */ jsxs("header", { className: "cbx-header", children: [
2606
- /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-icon-button cbx-only-mobile", onClick: () => setOverlay("nav-sheet"), "aria-label": t("Open navigation"), "aria-haspopup": "dialog", children: /* @__PURE__ */ jsx(Menu, { size: 20, strokeWidth: 1.8, "aria-hidden": true }) }),
2607
3533
  organization !== void 0 && /* @__PURE__ */ jsxs("div", { className: "cbx-context cbx-only-desktop", children: [
2608
- /* @__PURE__ */ jsxs("button", { ref: org, type: "button", className: `cbx-trigger ${overlay === "org" ? "is-open" : ""}`, "aria-haspopup": "dialog", "aria-expanded": overlay === "org", "aria-label": t("{level}: {name}", { level: organization.label, name: organization.current.name }), onClick: () => setOverlay(overlay === "org" ? null : "org"), children: [
3534
+ /* @__PURE__ */ jsxs("button", { ref: org, type: "button", className: `cbx-trigger ${overlay === "org" ? "is-open" : ""}`, "aria-haspopup": "dialog", "aria-expanded": overlay === "org", "aria-label": t("{level}: {name}", { level: organization.label, name: organization.current.name }), onClick: () => setOverlay(overlay === "org" ? null : "org"), onKeyDown: (event) => triggerKeyDown(event, "org"), children: [
2609
3535
  /* @__PURE__ */ jsx(Chip, { item: organization.current, tone: "solid" }),
2610
3536
  /* @__PURE__ */ jsx("span", { className: "cbx-trigger-text", title: organization.current.name, children: organization.current.name }),
2611
3537
  /* @__PURE__ */ jsx(ChevronsUpDown, { className: "cbx-trigger-chevron", size: 14, strokeWidth: 1.8, "aria-hidden": true })
2612
3538
  ] }),
2613
- !mobile && /* @__PURE__ */ jsx(Popover, { open: overlay === "org", anchor: org, label: organization.label, onClose: close, children: /* @__PURE__ */ jsx(OrganizationMenu, { level: organization }) }),
3539
+ /* @__PURE__ */ jsx(Popover, { open: overlay === "org", anchor: org, label: organization.label, onClose: close, children: /* @__PURE__ */ jsx(OrganizationMenu, { level: organization }) }),
2614
3540
  rest.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
2615
3541
  /* @__PURE__ */ jsx("span", { className: "cbx-separator", "aria-hidden": "true", children: "/" }),
2616
- /* @__PURE__ */ jsxs("button", { ref: second, type: "button", className: `cbx-trigger ${overlay === "context" ? "is-open" : ""}`, "aria-haspopup": "dialog", "aria-expanded": overlay === "context", "aria-label": rest.map((level) => t("{level}: {name}", { level: level.label, name: level.current.name })).join(", "), onClick: () => setOverlay(overlay === "context" ? null : "context"), children: [
3542
+ /* @__PURE__ */ jsxs("button", { ref: second, type: "button", className: `cbx-trigger ${overlay === "context" ? "is-open" : ""}`, "aria-haspopup": "dialog", "aria-expanded": overlay === "context", "aria-label": rest.map((level) => t("{level}: {name}", { level: level.label, name: level.current.name })).join(", "), onClick: () => setOverlay(overlay === "context" ? null : "context"), onKeyDown: (event) => triggerKeyDown(event, "context"), children: [
2617
3543
  /* @__PURE__ */ jsx(CascadeLabel, { levels: rest }),
2618
3544
  /* @__PURE__ */ jsx(ChevronsUpDown, { className: "cbx-trigger-chevron", size: 14, strokeWidth: 1.8, "aria-hidden": true })
2619
3545
  ] }),
2620
- !mobile && /* @__PURE__ */ jsx(Popover, { open: overlay === "context", anchor: second, label: rest.map((level) => level.label).join(" / "), onClose: close, children: /* @__PURE__ */ jsx(CascadeMenu, { levels: rest, parent: organization.current.id }) })
3546
+ /* @__PURE__ */ jsx(Popover, { open: overlay === "context", anchor: second, label: rest.map((level) => level.label).join(" / "), onClose: close, children: /* @__PURE__ */ jsx(CascadeMenu, { levels: rest, parent: organization.current.id }) })
2621
3547
  ] })
2622
3548
  ] }),
2623
- organization !== void 0 && /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-trigger cbx-context-mobile cbx-only-mobile", onClick: () => setOverlay("context-sheet"), "aria-haspopup": "dialog", "aria-label": t("Where you are: {trail}", { trail }), children: [
2624
- /* @__PURE__ */ jsx(Chip, { item: organization.current, tone: "solid" }),
2625
- /* @__PURE__ */ jsx("span", { className: "cbx-trigger-text", children: trail }),
2626
- /* @__PURE__ */ jsx(ChevronsUpDown, { className: "cbx-trigger-chevron", size: 14, strokeWidth: 1.8, "aria-hidden": true })
2627
- ] }),
2628
3549
  /* @__PURE__ */ jsxs("div", { className: "cbx-tools", children: [
2629
3550
  /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-search-button", onClick: () => setOverlay("palette"), "aria-label": t("Search or ask\u2026"), "aria-keyshortcuts": mac ? "Meta+K" : "Control+K", children: [
2630
3551
  /* @__PURE__ */ jsx(Search, { size: 16, strokeWidth: 1.8, "aria-hidden": true }),
@@ -2641,7 +3562,7 @@ function Header({ mobile }) {
2641
3562
  shell.notifications.unread > 0 && /* @__PURE__ */ jsx("span", { className: "cbx-count", "aria-hidden": "true", children: shell.notifications.unread })
2642
3563
  ] }),
2643
3564
  /* @__PURE__ */ jsx("button", { ref: apps, type: "button", className: `cbx-tool cbx-tool-icon cbx-only-desktop ${overlay === "apps" ? "is-on" : ""}`, onClick: () => setOverlay(overlay === "apps" ? null : "apps"), "aria-haspopup": "dialog", "aria-expanded": overlay === "apps", "aria-label": t("Switch app"), title: t("Switch app"), children: /* @__PURE__ */ jsx(LayoutGrid, { size: 16, strokeWidth: 1.8, "aria-hidden": true }) }),
2644
- !mobile && /* @__PURE__ */ jsx(Popover, { open: overlay === "apps", anchor: apps, placement: "bottom-end", label: t("Switch app"), onClose: close, children: /* @__PURE__ */ jsx(AppGrid, {}) })
3565
+ /* @__PURE__ */ jsx(Popover, { open: overlay === "apps", anchor: apps, placement: "bottom-end", label: t("Switch app"), onClose: close, children: /* @__PURE__ */ jsx(AppGrid, {}) })
2645
3566
  ] })
2646
3567
  ] });
2647
3568
  }
@@ -3040,7 +3961,7 @@ function ComboboxGroupRows({
3040
3961
  /* @__PURE__ */ jsx("span", { className: "truncate text-[13px] font-medium text-foreground", children: opt.label }),
3041
3962
  opt.secondary !== void 0 ? /* @__PURE__ */ jsx("span", { className: "text-mono truncate text-[10px] text-muted-foreground", children: opt.secondary }) : null
3042
3963
  ] }),
3043
- isActive ? /* @__PURE__ */ jsx(Check3, {}) : null
3964
+ isActive ? /* @__PURE__ */ jsx(Check4, {}) : null
3044
3965
  ] });
3045
3966
  const className = cn(
3046
3967
  "group block w-full rounded-sm transition-colors text-left",
@@ -3100,7 +4021,7 @@ function FooterLink({
3100
4021
  LinkComponent,
3101
4022
  onAfterClick
3102
4023
  }) {
3103
- const className = "flex items-center gap-2 border-t border-border/60 px-3 py-2.5 text-[13px] font-medium text-info transition-colors hover:bg-info-soft";
4024
+ const className = "flex items-center gap-2 border-t border-border/60 px-3 py-2.5 text-[13px] font-medium text-info-text transition-colors hover:bg-info-soft";
3104
4025
  if (LinkComponent !== void 0) {
3105
4026
  return /* @__PURE__ */ jsxs(
3106
4027
  LinkComponent,
@@ -3109,7 +4030,7 @@ function FooterLink({
3109
4030
  prefetch: true,
3110
4031
  className,
3111
4032
  children: [
3112
- /* @__PURE__ */ jsx(Plus2, {}),
4033
+ /* @__PURE__ */ jsx(Plus5, {}),
3113
4034
  /* @__PURE__ */ jsx("span", { children: label })
3114
4035
  ]
3115
4036
  }
@@ -3122,7 +4043,7 @@ function FooterLink({
3122
4043
  className,
3123
4044
  onClick: onAfterClick,
3124
4045
  children: [
3125
- /* @__PURE__ */ jsx(Plus2, {}),
4046
+ /* @__PURE__ */ jsx(Plus5, {}),
3126
4047
  /* @__PURE__ */ jsx("span", { children: label })
3127
4048
  ]
3128
4049
  }
@@ -3151,7 +4072,7 @@ function ComboboxAvatarChip({
3151
4072
  style,
3152
4073
  className: cn(
3153
4074
  "flex h-5 w-5 shrink-0 items-center justify-center rounded-sm text-[9px] font-semibold tracking-tight",
3154
- avatar.accent === void 0 && "bg-info-soft text-info"
4075
+ avatar.accent === void 0 && "bg-info-soft text-info-text"
3155
4076
  ),
3156
4077
  children: initials2
3157
4078
  }
@@ -3222,7 +4143,7 @@ function Chevron({ open }) {
3222
4143
  }
3223
4144
  );
3224
4145
  }
3225
- function Check3() {
4146
+ function Check4() {
3226
4147
  return /* @__PURE__ */ jsx(
3227
4148
  "svg",
3228
4149
  {
@@ -3240,7 +4161,7 @@ function Check3() {
3240
4161
  }
3241
4162
  );
3242
4163
  }
3243
- function Plus2() {
4164
+ function Plus5() {
3244
4165
  return /* @__PURE__ */ jsx(
3245
4166
  "svg",
3246
4167
  {
@@ -3306,15 +4227,15 @@ function SectionHeader({
3306
4227
  "header",
3307
4228
  {
3308
4229
  className: cn(
3309
- "flex flex-col gap-3 border-b border-border px-5 py-4 sm:flex-row sm:items-center sm:justify-between",
4230
+ "flex flex-wrap items-center justify-between gap-x-4 gap-y-3 border-b border-border px-5 py-4",
3310
4231
  className
3311
4232
  ),
3312
4233
  children: [
3313
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
4234
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-[1_1_12rem] space-y-1", children: [
3314
4235
  /* @__PURE__ */ jsx("h2", { className: "text-[15px] leading-none font-semibold text-foreground", children: title }),
3315
4236
  description ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description }) : null
3316
4237
  ] }),
3317
- actions ? /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions }) : null
4238
+ actions ? /* @__PURE__ */ jsx("div", { className: "flex max-w-full flex-wrap items-center gap-2", children: actions }) : null
3318
4239
  ]
3319
4240
  }
3320
4241
  );
@@ -3778,10 +4699,10 @@ function RowLink({
3778
4699
  );
3779
4700
  }
3780
4701
  var toneStyles = {
3781
- info: { bg: "bg-info-soft", fg: "text-info" },
3782
- success: { bg: "bg-success-soft", fg: "text-success" },
3783
- warning: { bg: "bg-warning-soft", fg: "text-warning" },
3784
- destructive: { bg: "bg-destructive-soft", fg: "text-destructive" },
4702
+ info: { bg: "bg-info-soft", fg: "text-info-text" },
4703
+ success: { bg: "bg-success-soft", fg: "text-success-text" },
4704
+ warning: { bg: "bg-warning-soft", fg: "text-warning-text" },
4705
+ destructive: { bg: "bg-destructive-soft", fg: "text-destructive-text" },
3785
4706
  neutral: { bg: "bg-secondary", fg: "text-foreground" }
3786
4707
  };
3787
4708
  function StatTile({
@@ -3814,7 +4735,7 @@ function StatTile({
3814
4735
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-0.5", children: [
3815
4736
  /* @__PURE__ */ jsx("p", { className: "tabular text-2xl leading-none font-semibold tracking-tight text-foreground", children: value }),
3816
4737
  /* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: label }),
3817
- suffix ? /* @__PURE__ */ jsx("p", { className: "text-mono truncate text-[10px] text-muted-foreground/80", children: suffix }) : null
4738
+ suffix ? /* @__PURE__ */ jsx("p", { className: "text-mono truncate text-[10px] text-muted-foreground", children: suffix }) : null
3818
4739
  ] })
3819
4740
  ]
3820
4741
  }
@@ -3822,10 +4743,10 @@ function StatTile({
3822
4743
  }
3823
4744
  var toneStyles2 = {
3824
4745
  neutral: "border-border bg-secondary text-secondary-foreground",
3825
- info: "border-info/20 bg-info-soft text-info",
3826
- success: "border-success/20 bg-success-soft text-success",
3827
- warning: "border-warning/20 bg-warning-soft text-warning",
3828
- destructive: "border-destructive/20 bg-destructive-soft text-destructive",
4746
+ info: "border-info/20 bg-info-soft text-info-text",
4747
+ success: "border-success/20 bg-success-soft text-success-text",
4748
+ warning: "border-warning/20 bg-warning-soft text-warning-text",
4749
+ destructive: "border-destructive/20 bg-destructive-soft text-destructive-text",
3829
4750
  muted: "border-border bg-card text-muted-foreground"
3830
4751
  };
3831
4752
  var dotStyles = {
@@ -4101,7 +5022,7 @@ function InboxSurface({ open, onClose }) {
4101
5022
  )
4102
5023
  ] }) : /* @__PURE__ */ jsx("span", { children: "\u2014" }),
4103
5024
  children: error !== null ? /* @__PURE__ */ jsxs("div", { className: "px-5 py-8 text-center", children: [
4104
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-destructive", children: t("Couldn't load inbox") }),
5025
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-destructive-text", children: t("Couldn't load inbox") }),
4105
5026
  /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: error })
4106
5027
  ] }) : loading && inbox === null ? /* @__PURE__ */ jsx("div", { className: "px-5 py-12 text-center text-sm text-muted-foreground", children: t("Loading\u2026") }) : filtered.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-5 py-12", children: /* @__PURE__ */ jsx(
4107
5028
  EmptyState,
@@ -4353,6 +5274,6 @@ function Sparkline({ values, color = "var(--chart-1)", width = 90, height = 20 }
4353
5274
  ] });
4354
5275
  }
4355
5276
 
4356
- export { APP_HUES, AppContent, AppShell, CHART_PALETTE, CboxAppCatalog, CboxAppIcon, CboxBrand, CboxIdProvider, CboxLocalizationProvider, CboxServiceMark, CboxShell, CboxSurfaces, Combobox, DataPanel, EmptyState, Heading, KeyValue, KeyValueList, PageHeader, PageShell, PageTabs, PanelBody, RowLink, SHELL_ICONS, SectionHeader, Sparkline, StatTile, StatusPill, applyTheme, buildUrlSearch, contextTrail, createHelpStore, defineUrlSchema, environmentFor, hueFor, initialsOf, interpolate, pageIntent, parseListPage, parseShellCatalog, parseUrlSearch, settingsHref, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useKnownAppCatalog, useShellHelp, withQuery };
5277
+ export { APP_HUES, AppContent, AppShell, CHART_PALETTE, CboxAppCatalog, CboxAppIcon, CboxBrand, CboxIdProvider, CboxLocalizationProvider, CboxServiceMark, CboxShell, CboxSurfaces, Combobox, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, EmptyState, Heading, KeyValue, KeyValueList, PageHeader, PageShell, PageTabs, PanelBody, RowLink, SHELL_ICONS, SectionHeader, Sparkline, StatTile, StatusPill, applyTheme, buildUrlSearch, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useKnownAppCatalog, useShellCreate, useShellHelp, withQuery };
4357
5278
  //# sourceMappingURL=index.js.map
4358
5279
  //# sourceMappingURL=index.js.map