@eifi1/ui-kit 0.52.0 → 0.53.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.
Files changed (193) hide show
  1. package/README.md +47 -54
  2. package/dist/billing/cancel-subscription.d.ts +5 -14
  3. package/dist/billing/cancel-subscription.js +1 -3
  4. package/dist/billing/cancel-subscription.js.map +1 -1
  5. package/dist/billing/plan-card.d.ts +5 -13
  6. package/dist/billing/plan-card.js +3 -11
  7. package/dist/billing/plan-card.js.map +1 -1
  8. package/dist/billing/plan-switch.d.ts +5 -14
  9. package/dist/billing/plan-switch.js +1 -3
  10. package/dist/billing/plan-switch.js.map +1 -1
  11. package/dist/chart.d.ts +3 -14
  12. package/dist/chart.js +64 -11
  13. package/dist/chart.js.map +1 -1
  14. package/dist/components/date-field.d.ts +1 -1
  15. package/dist/components/date-field.js.map +1 -1
  16. package/dist/components/date-picker.d.ts +1 -1
  17. package/dist/components/date-picker.js.map +1 -1
  18. package/dist/components/date-range-picker.d.ts +4 -17
  19. package/dist/components/date-range-picker.js +2 -2
  20. package/dist/components/date-range-picker.js.map +1 -1
  21. package/dist/components/nav-pills.d.ts +1 -1
  22. package/dist/components/nav-pills.js.map +1 -1
  23. package/dist/components/series-chart-axes.d.ts +1 -1
  24. package/dist/components/series-chart-axes.js.map +1 -1
  25. package/dist/components/series-chart.d.ts +64 -19
  26. package/dist/components/series-chart.js +2 -1
  27. package/dist/components/series-chart.js.map +1 -1
  28. package/dist/components/treemap-labels.d.ts +6 -1
  29. package/dist/components/treemap-labels.js +2 -2
  30. package/dist/components/treemap-labels.js.map +1 -1
  31. package/dist/components/treemap.d.ts +29 -4
  32. package/dist/components/treemap.js +22 -9
  33. package/dist/components/treemap.js.map +1 -1
  34. package/dist/data-table.d.ts +1 -6
  35. package/dist/data-table.js +1 -9
  36. package/dist/data-table.js.map +1 -1
  37. package/dist/demo/demo-countdown.d.ts +0 -5
  38. package/dist/demo/demo-countdown.js +0 -4
  39. package/dist/demo/demo-countdown.js.map +1 -1
  40. package/dist/eslint/index.js +1 -1
  41. package/dist/feedback/feedback-mutation.d.ts +11 -23
  42. package/dist/feedback/feedback-mutation.js +1 -9
  43. package/dist/feedback/feedback-mutation.js.map +1 -1
  44. package/dist/feedback/feedback-public-list.d.ts +1 -6
  45. package/dist/feedback/feedback-public-list.js +1 -2
  46. package/dist/feedback/feedback-public-list.js.map +1 -1
  47. package/dist/feedback/feedback-row-detail-labels.js +0 -8
  48. package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
  49. package/dist/feedback/feedback-row-detail.d.ts +3 -50
  50. package/dist/feedback/feedback-row-detail.js +0 -8
  51. package/dist/feedback/feedback-row-detail.js.map +1 -1
  52. package/dist/feedback/feedback-status-undo.d.ts +3 -19
  53. package/dist/feedback/feedback-status-undo.js.map +1 -1
  54. package/dist/feedback/feedback-thread.d.ts +0 -9
  55. package/dist/feedback/feedback-thread.js.map +1 -1
  56. package/dist/feedback.d.ts +6 -40
  57. package/dist/feedback.js +88 -46
  58. package/dist/feedback.js.map +1 -1
  59. package/dist/i18n/defaults.js +0 -4
  60. package/dist/i18n/defaults.js.map +1 -1
  61. package/dist/i18n/german.js +2 -19
  62. package/dist/i18n/german.js.map +1 -1
  63. package/dist/i18n/kit-labels.d.ts +5 -14
  64. package/dist/i18n/kit-labels.js.map +1 -1
  65. package/dist/i18n/locales/en.js +2 -30
  66. package/dist/i18n/locales/en.js.map +3 -3
  67. package/dist/i18n/locales/es.js +2 -19
  68. package/dist/i18n/locales/es.js.map +1 -1
  69. package/dist/i18n/locales/fr.js +2 -19
  70. package/dist/i18n/locales/fr.js.map +1 -1
  71. package/dist/i18n/locales/hu.js +2 -19
  72. package/dist/i18n/locales/hu.js.map +1 -1
  73. package/dist/i18n/locales/it.js +2 -20
  74. package/dist/i18n/locales/it.js.map +1 -1
  75. package/dist/i18n/locales/zh.js +2 -19
  76. package/dist/i18n/locales/zh.js.map +1 -1
  77. package/dist/i18n/review.js +9 -4
  78. package/dist/i18n/review.js.map +1 -1
  79. package/dist/i18n/shared-labels.js +0 -1
  80. package/dist/i18n/shared-labels.js.map +1 -1
  81. package/dist/index.d.ts +15 -64
  82. package/dist/index.js +22 -102
  83. package/dist/index.js.map +1 -1
  84. package/dist/rhf/fields.d.ts +2 -2
  85. package/dist/rhf/fields.js.map +1 -1
  86. package/dist/search/search-index.d.ts +0 -6
  87. package/dist/search/search-index.js +0 -4
  88. package/dist/search/search-index.js.map +1 -1
  89. package/dist/search.d.ts +1 -8
  90. package/dist/search.js +2 -7
  91. package/dist/search.js.map +1 -1
  92. package/dist/shell/account-menu-language.d.ts +7 -21
  93. package/dist/shell/account-menu-language.js +1 -3
  94. package/dist/shell/account-menu-language.js.map +1 -1
  95. package/dist/shell/account-menu-text-size.d.ts +9 -23
  96. package/dist/shell/account-menu-text-size.js +2 -3
  97. package/dist/shell/account-menu-text-size.js.map +1 -1
  98. package/dist/shell/app-shell.d.ts +0 -10
  99. package/dist/shell/app-shell.js +1 -7
  100. package/dist/shell/app-shell.js.map +1 -1
  101. package/dist/shell/company-switcher.d.ts +1 -1
  102. package/dist/shell/company-switcher.js.map +1 -1
  103. package/dist/shell/dev-menu.d.ts +1 -1
  104. package/dist/shell/dev-menu.js.map +1 -1
  105. package/dist/shell/top-bar-parts-labels.d.ts +1 -1
  106. package/dist/shell/top-bar-parts-labels.js.map +1 -1
  107. package/dist/shell.d.ts +7 -29
  108. package/dist/shell.js +12 -42
  109. package/dist/shell.js.map +1 -1
  110. package/dist/sync.d.ts +2 -6
  111. package/dist/sync.js +2 -15
  112. package/dist/sync.js.map +1 -1
  113. package/dist/theme/chart-palette.d.ts +0 -5
  114. package/dist/theme/chart-palette.js +0 -2
  115. package/dist/theme/chart-palette.js.map +1 -1
  116. package/package.json +1 -1
  117. package/src/billing/cancel-subscription.tsx +5 -16
  118. package/src/billing/plan-card.tsx +7 -24
  119. package/src/billing/plan-switch.tsx +5 -16
  120. package/src/chart.ts +62 -13
  121. package/src/components/date-field.tsx +1 -1
  122. package/src/components/date-picker.tsx +0 -1
  123. package/src/components/date-range-picker.tsx +6 -22
  124. package/src/components/nav-pills.tsx +1 -1
  125. package/src/components/series-chart-axes.ts +6 -1
  126. package/src/components/series-chart.tsx +78 -21
  127. package/src/components/treemap-labels.ts +11 -3
  128. package/src/components/treemap.tsx +65 -12
  129. package/src/data-table.ts +1 -11
  130. package/src/demo/demo-countdown.ts +3 -8
  131. package/src/feedback/feedback-mutation.ts +12 -33
  132. package/src/feedback/feedback-public-list.tsx +1 -7
  133. package/src/feedback/feedback-row-detail-labels.ts +0 -8
  134. package/src/feedback/feedback-row-detail.tsx +8 -58
  135. package/src/feedback/feedback-status-undo.ts +4 -18
  136. package/src/feedback/feedback-thread.tsx +0 -10
  137. package/src/feedback.ts +89 -48
  138. package/src/i18n/defaults.ts +0 -4
  139. package/src/i18n/german.ts +2 -19
  140. package/src/i18n/kit-labels.tsx +5 -14
  141. package/src/i18n/locales/es.ts +2 -19
  142. package/src/i18n/locales/fr.ts +2 -19
  143. package/src/i18n/locales/hu.ts +2 -19
  144. package/src/i18n/locales/it.ts +2 -20
  145. package/src/i18n/locales/zh.ts +2 -19
  146. package/src/i18n/review.ts +9 -4
  147. package/src/i18n/shared-labels.ts +0 -1
  148. package/src/index.ts +30 -112
  149. package/src/rhf/fields.tsx +2 -2
  150. package/src/search/search-index.ts +0 -15
  151. package/src/search.ts +8 -8
  152. package/src/shell/account-menu-language.tsx +7 -27
  153. package/src/shell/account-menu-text-size.tsx +13 -32
  154. package/src/shell/app-shell.tsx +0 -13
  155. package/src/shell/company-switcher.tsx +1 -1
  156. package/src/shell/dev-menu.tsx +1 -1
  157. package/src/shell/top-bar-parts-labels.ts +1 -1
  158. package/src/shell.ts +17 -44
  159. package/src/sync.ts +2 -15
  160. package/src/theme/chart-palette.ts +0 -2
  161. package/tokens.css +4 -4
  162. package/dist/billing/dialog-close.d.ts +0 -29
  163. package/dist/billing/dialog-close.js +0 -8
  164. package/dist/billing/dialog-close.js.map +0 -1
  165. package/dist/components/field-sync-labels.d.ts +0 -3
  166. package/dist/components/field-sync-labels.js +0 -12
  167. package/dist/components/field-sync-labels.js.map +0 -1
  168. package/dist/components/field-sync.d.ts +0 -186
  169. package/dist/components/field-sync.js +0 -269
  170. package/dist/components/field-sync.js.map +0 -1
  171. package/dist/components/section-nav.d.ts +0 -44
  172. package/dist/components/section-nav.js +0 -33
  173. package/dist/components/section-nav.js.map +0 -1
  174. package/dist/components/sign-chip-labels.d.ts +0 -3
  175. package/dist/components/sign-chip-labels.js +0 -11
  176. package/dist/components/sign-chip-labels.js.map +0 -1
  177. package/dist/components/sign-chip.d.ts +0 -77
  178. package/dist/components/sign-chip.js +0 -47
  179. package/dist/components/sign-chip.js.map +0 -1
  180. package/dist/lib/isin.d.ts +0 -38
  181. package/dist/lib/isin.js +0 -36
  182. package/dist/lib/isin.js.map +0 -1
  183. package/dist/shell/role-switcher.d.ts +0 -28
  184. package/dist/shell/role-switcher.js +0 -31
  185. package/dist/shell/role-switcher.js.map +0 -1
  186. package/src/billing/dialog-close.ts +0 -34
  187. package/src/components/field-sync-labels.ts +0 -14
  188. package/src/components/field-sync.tsx +0 -504
  189. package/src/components/section-nav.tsx +0 -72
  190. package/src/components/sign-chip-labels.ts +0 -13
  191. package/src/components/sign-chip.tsx +0 -133
  192. package/src/lib/isin.ts +0 -72
  193. package/src/shell/role-switcher.tsx +0 -53
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shell/app-shell.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Link, NavLink, matchPath, useHref, useLocation } from \"react-router\";\nimport { ChevronRight, MoreHorizontal, PanelLeftClose, PanelLeftOpen } from \"lucide-react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { scrollIntoStrip, useStripFade } from \"../lib/strip-fade\";\nimport { dirOf, type Direction } from \"../lib/direction\";\nimport { readStored, writeStored } from \"../lib/safe-storage\";\nimport { registerDeviceSetting } from \"../lib/device-settings\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { pickLinkRenderer } from \"../components/text-link\";\nimport { DialogFrame } from \"../components/dialog-frame\";\nimport { CompactControls } from \"../components/field-parts\";\nimport { mergeRefs } from \"../components/field-parts\";\nimport { useAnchoredRect } from \"../hooks/use-anchored-rect\";\nimport { anchoredInline } from \"../hooks/use-anchored-panel\";\nimport { useDismissLayer } from \"../hooks/use-dismiss\";\nimport { useBreakpoint } from \"../hooks/use-breakpoint\";\nimport { TEXT_SIZES, useTextSize } from \"../theme/text-size\";\nimport type { TextSize } from \"../theme/text-size\";\nimport { DEFAULT_APP_SHELL_LABELS, useKitLabels, useKitLink, type LabelOverride } from \"../i18n/kit-labels\";\nimport type { KitLinkComponent, KitLinkProps } from \"../i18n/kit-labels\";\nimport { DEFAULT_APP_SHELL_MORE_LABELS } from \"./app-shell-labels\";\n\nexport interface AppShellSubItem {\n to: string;\n label: string;\n icon: LucideIcon;\n /** Passed to NavLink's `end` (exact match). Defaults to true. */\n end?: boolean;\n}\n\nexport interface AppShellNavItem {\n to: string;\n label: string;\n /** Optional shorter label for the MOBILE BOTTOM BAR only (the sidebar, its\n * tooltips and any palette built on this list keep `label`).\n *\n * The bar divides the viewport into `nav.length` equal cells, so a label's room\n * shrinks with every entry added — at six entries on a 406 px phone that is ~67 px,\n * and \"Import & Export\" wrapped to two lines and pushed the row taller than its\n * neighbours (keksdose feedback live #210). A per-item override is better than\n * shortening the real label, which the sidebar has ample room for and which is the\n * name the rest of the product uses. */\n shortLabel?: string;\n /** 0.48: the text size from which the bar uses {@link shortLabel} — `\"large\"` keeps the\n * full label at Normal, where five cells hold \"Transactions\" whole, and shortens it\n * from Large up (keksdose dev#613, which read `useTextSize()` in its layout to decide).\n * Default `\"normal\"`: the short label at every size, as before. */\n shortLabelFrom?: TextSize;\n /** 0.49: `shortLabel` is another word for the page, not a shortening of `label` —\n * keksdose's \"Activity\" for \"Transactions\". Without it a development build warns once\n * when `shortLabel` does not start with `label`'s first word (an abbreviation of that\n * word, \"Trans.\" for \"Transactions\", counts), because a bar cell that names a page\n * differently from the sidebar, the title and the palette is a page the reader\n * looks for twice. */\n shortLabelIsAlias?: boolean;\n /** 0.49: which entries sit in the phone bar when they do not all fit\n * ({@link AppShellProps.mobileMaxItems}). Lower first: the entries with a priority take\n * the bar's cells in its order, then the rest in the list's order; the bar still shows\n * its entries in the list's order, and the others go under \"More\". Unset: the list's\n * order decides (as before). */\n mobilePriority?: number;\n /** 0.31.0: leave this entry out of the MOBILE BOTTOM BAR; the sidebar keeps it.\n * For an entry a phone reaches another way — the brand link to the start page —\n * when one cell fewer is what keeps the others' labels whole (the bar divides its\n * width evenly, see `shortLabel`). Its group's sub-row still shows while one of its\n * pages is open. Named like `DataTable`'s column `mobileHidden`. */\n mobileHidden?: boolean;\n icon: LucideIcon;\n /** Passed to NavLink's `end` (exact match). Defaults to true. */\n end?: boolean;\n /** Optional `data-tour` value rendered on this item's link (both the desktop\n * sidebar and the mobile bottom bar), so a guided tour can spotlight ONE nav\n * entry precisely instead of matching by href (feedback #338). */\n dataTour?: string;\n /** Optional sub-items. When present, hovering (or focusing) the item opens a\n * flyout to the right of the sidebar with a header (this item's label) and the\n * sub-items as icon + title links. Works collapsed or expanded. On the phone (0.49)\n * the bar's cell opens a sheet of them instead of linking to `to` — the sheet lists\n * `to` first as \"Overview\" when no sub-item is that page — and the pages of the group\n * the reader is in show as the row above the bar (`mobileSubNav`). */\n items?: AppShellSubItem[];\n}\n\n/**\n * One entry of the sidebar's bottom area ({@link AppShellProps.sidebarFooterItems}) —\n * the version link and the legal links kastlan hand-built in `sidebarFooter`.\n *\n * - `link` (default): one link. Expanded it shows `icon` + `text` (default `label`),\n * with `hint` as a tooltip if given; collapsed it is the icon alone, named and\n * tooltipped by `label`.\n * - `links`: a small group — the legal links. Expanded, a `<nav>` named `label` holding\n * the links as a wrapping row of small text; collapsed, ONE icon link to `to` (default\n * the first link's), named and tooltipped by `label`, since a column of icons for\n * \"Imprint\", \"Privacy\" and \"Terms\" would say nothing an icon can.\n */\nexport type AppShellSidebarFooterItem =\n | {\n kind?: \"link\";\n key: string;\n to: string;\n icon: LucideIcon;\n /** The link's name, and the tooltip when collapsed (\"What's new · v1.4.0\"). */\n label: string;\n /** Visible text when expanded (\"Kastlan v1.4.0\"). Default `label`. */\n text?: ReactNode;\n /** A tooltip on the expanded link (\"What's new\"). */\n hint?: string;\n /** Leaves the app: a plain `<a target=\"_blank\" rel=\"noopener noreferrer\">`. */\n external?: boolean;\n /**\n * 0.42.0 (docs/admin-harmonization.md §6.9): a count of what waits behind the link —\n * kastlan's \"Administration\" with its To-triage count. A pill at the end of the\n * expanded link, a corner dot on the collapsed icon; `0`, `null` or none shows\n * nothing, and above 99 it reads \"99+\". The count joins the link's name, in\n * `badgeLabel`'s words when given (\"Administration, 3 waiting\").\n */\n badge?: number | null;\n /** The badge's words for a reader — `adminArea.waiting(count)`. Default: the number. */\n badgeLabel?: string;\n }\n | {\n kind: \"links\";\n key: string;\n icon: LucideIcon;\n /** The group's name — its `<nav>` label, and the collapsed icon's name (\"Legal\"). */\n label: string;\n /** The collapsed icon's target. Default the first link's `to`. */\n to?: string;\n links: { to: string; label: string; external?: boolean }[];\n };\n\n/**\n * The words of the phone bar's \"More\" cell and its sheet (0.32,\n * docs/text-size-harmonization.md §4 Navigation, §10.7) — the `appShellMore` namespace of\n * `<UiKitProvider labels>`, overridable per shell through `moreLabels`.\n */\nexport interface AppShellMoreLabels {\n /** The cell's visible label, under its icon — one short word. */\n more: string;\n /** The sheet's heading, and so its accessible name. */\n moreTitle: string;\n /** 0.49: a parent entry's own page in the sheet its bar cell opens, above its pages,\n * when no page is that one — \"Overview\". */\n overview: string;\n}\n\n// Defined in ./app-shell-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_APP_SHELL_MORE_LABELS };\n\n/**\n * The most cells the phone bar holds, \"More\" included, per text size (0.49 KIT-6; 0.32\n * §10.7): five at Normal and Large, four at Extra large. Eight entries are four and\n * \"More\" at Normal; a fifth of a 390 px phone holds one word of the bar's type, and a\n * sixth no longer does once the type grows. A fifth of a 360 px phone at 150 % is 48 px\n * of Normal-sized room.\n */\nexport const DEFAULT_MOBILE_MAX_ITEMS: Readonly<Record<TextSize, number>> = {\n normal: 5,\n large: 5,\n xlarge: 4,\n};\n\n/**\n * The phone bar's cells (0.49 KIT-6): every entry when there are at most `maxItems`,\n * else `maxItems − 1` entries and a \"More\" cell for the rest. Which entries stay is\n * `priority`'s call — lower first, entries without one after them in the list's order —\n * and both halves keep the list's order. Never fewer than one entry beside More.\n */\nexport function pickMobileBar<T>(\n entries: readonly T[],\n maxItems: number,\n priority?: (entry: T) => number | undefined,\n): { shown: T[]; hidden: T[] } {\n const cells = Math.max(1, Math.floor(maxItems));\n if (entries.length <= cells) return { shown: [...entries], hidden: [] };\n const keep = Math.max(1, cells - 1);\n const rank = (i: number) => priority?.(entries[i]!) ?? Number.POSITIVE_INFINITY;\n const chosen = new Set(\n entries\n .map((_, i) => i)\n .sort((a, b) => rank(a) - rank(b) || a - b)\n .slice(0, keep),\n );\n return {\n shown: entries.filter((_, i) => chosen.has(i)),\n hidden: entries.filter((_, i) => !chosen.has(i)),\n };\n}\n\n/**\n * Split the bar's entries into the cells shown and the ones under \"More\", in the app's\n * order (§10.7: the app puts its four most used first, or orders by role). One hidden\n * entry is no saving — the More cell would take its place — so the bar then shows them\n * all: the cell count is the same either way, and a real entry beats a detour.\n */\nexport function splitMobileBar<T>(entries: readonly T[], max: number): { shown: T[]; hidden: T[] } {\n // Entries before More, as 0.32 counted them; {@link pickMobileBar} counts cells.\n const limit = Math.max(1, Math.floor(max));\n if (entries.length <= limit + 1) return { shown: [...entries], hidden: [] };\n return { shown: entries.slice(0, limit), hidden: entries.slice(limit) };\n}\n\n/** The bar's cell count at `size`: `mobileMaxItems`, else the default. */\nfunction mobileCells(maxItems: AppShellProps[\"mobileMaxItems\"], size: TextSize): number {\n if (maxItems === undefined) return DEFAULT_MOBILE_MAX_ITEMS[size];\n return typeof maxItems === \"number\" ? maxItems : (maxItems[size] ?? DEFAULT_MOBILE_MAX_ITEMS[size]);\n}\n\n/** The kit's dev switch, as `lib/logger.ts` reads it: a development build, never a\n * production one, never under vitest. Read per call so a test can switch it on. */\nfunction devWarnings(): boolean {\n return Boolean(import.meta.env?.DEV) && !import.meta.env?.VITEST;\n}\n\nconst warnedNav = new Set<string>();\n\nfunction warnNavOnce(key: string, message: string): void {\n if (warnedNav.has(key)) return;\n warnedNav.add(key);\n console.warn(message);\n}\n\n/** The first word of a label, lower-cased: letters and digits up to the first other\n * character (\"Import & Export\" → \"import\", \"Trans.\" → \"trans\"). */\nfunction firstWord(text: string): string {\n return (text.trim().match(/^[\\p{L}\\p{N}]+/u)?.[0] ?? \"\").toLocaleLowerCase();\n}\n\n/** Whether `short` names `label`: its first word is `label`'s first word or an\n * abbreviation of it (\"Trans.\" for \"Transactions\"), or the other way round. */\nfunction shortLabelNamesLabel(short: string, label: string): boolean {\n const s = firstWord(short);\n const l = firstWord(label);\n return s === \"\" || l === \"\" || l.startsWith(s) || s.startsWith(l);\n}\n\nconst TEXT_SIZE_WORDS: Record<TextSize, string> = { normal: \"Normal\", large: \"Large\", xlarge: \"Extra large\" };\n\n/** A development build's notes on `nav` (0.49 KIT-6): a `shortLabel` that is another word\n * than its `label` without `shortLabelIsAlias`. */\nfunction useNavDevWarnings(nav: AppShellNavItem[]): void {\n useEffect(() => {\n if (!devWarnings()) return;\n for (const item of nav) {\n if (item.shortLabel === undefined || item.shortLabelIsAlias) continue;\n if (shortLabelNamesLabel(item.shortLabel, item.label)) continue;\n const from = item.shortLabelFrom ?? \"normal\";\n const where = from === \"normal\" ? \"at every text size\" : `from ${TEXT_SIZE_WORDS[from]} text up`;\n warnNavOnce(\n `shortLabel|${item.to}|${item.shortLabel}|${item.label}`,\n `[ui-kit] AppShell nav \"${item.to}\": shortLabel \"${item.shortLabel}\" does not start with ` +\n `\"${item.label.trim().split(/\\s+/)[0]}\", the first word of its label \"${item.label}\". The phone bar ` +\n `shows it ${where}, so the page has another name there than in the sidebar and its title. ` +\n \"Shorten the label instead, or pass shortLabelIsAlias: true if the other word is meant.\",\n );\n }\n }, [nav]);\n}\n\n/**\n * Exported and `<div>`-shaped. This is the outermost element of every consuming app, so\n * there is nothing above it to hang an id, a landmark label or a `data-tour` anchor on —\n * and nothing a consumer can wrap it in either, since the root owns the `h-dvh` and\n * `overflow-hidden` the whole layout is built on (audit §api-design).\n */\nexport interface AppShellProps extends ComponentPropsWithoutRef<\"div\"> {\n /** Navigation entries — shared by the desktop sidebar and mobile bottom bar. */\n nav: AppShellNavItem[];\n /** The composed top bar (e.g. the shared TopBar with app-owned actions). */\n topBar: ReactNode;\n /** Main content — typically the router `<Outlet />`. */\n children: ReactNode;\n /** Desktop-only footer rendered below the content (hidden on mobile). */\n footer?: ReactNode;\n /** Extra sidebar content above the collapse toggle (e.g. a version link).\n * Receives the collapsed state so it can render compact vs. full. */\n sidebarFooter?: (collapsed: boolean) => ReactNode;\n /** The sidebar's bottom area as data — a version link, the legal links — drawn full\n * when expanded and as icon + tooltip when collapsed. Rendered above\n * `sidebarFooter`, which stays for anything the data cannot describe. */\n sidebarFooterItems?: AppShellSidebarFooterItem[];\n /** The router link for `sidebarFooterItems`. Default: the provider's\n * `linkComponent`, else react-router's `Link`. */\n renderLink?: KitLinkComponent;\n /** localStorage key for the persisted collapse state. */\n collapseStorageKey?: string;\n /** Default: `appShell.collapse` from the {@link UiKitProvider}, else English. */\n collapseLabel?: string;\n /** Default: `appShell.expand` from the {@link UiKitProvider}, else English. */\n expandLabel?: string;\n /** How an entry's `items` are revealed in the EXPANDED desktop sidebar.\n *\n * - `\"flyout\"` (default) — a panel beside the sidebar on hover/focus. Compact: the\n * sidebar stays one row per group however many pages a group holds.\n * - `\"inline\"` — a disclosure under the entry, the pattern of MUI's nested List and\n * most documentation sites. Every page is visible at once, and the group holding\n * the current page opens on its own, so the reader can see where they are without\n * hovering anything.\n *\n * The icon-only (collapsed) sidebar always uses the flyout: an indented list has no\n * room there. The mobile bottom bar ignores `items` in both modes. */\n subNav?: \"flyout\" | \"inline\";\n /** Accessible name of the inline disclosure button, given the group's label.\n * Only used with `subNav=\"inline\"`. Its expanded state is carried by\n * `aria-expanded`, so one wording serves both directions. Default:\n * `appShell.toggleGroup` from the {@link UiKitProvider}, else English. */\n toggleGroupLabel?: (groupLabel: string) => string;\n /** Below `md`: show the current group's `items` as a scrollable row above the\n * bottom bar — the phone's counterpart of the sidebar's second level. Default true;\n * `false` keeps the single bar, where a group entry only links to its own `to`. */\n mobileSubNav?: boolean;\n /**\n * How the phone sub-nav lays out a group with more pages than fit on one row.\n * `\"wrap\"`: every page in view, on as many rows as it takes — the bar grows.\n * `\"scroll\"`: one row that scrolls sideways, faded at a cut edge, with the current\n * page scrolled into view. A long group took four rows (~130px) of a 390px screen\n * above the bottom bar (showcase audit); scrolling gives that back at the price of\n * pages hidden past the edge, so it is the app's call, per shell.\n *\n * Unset (0.32.2, kastlan's 0.32.1 report): `\"wrap\"` at Normal and `\"scroll\"` at Large\n * and Extra large, where a wrapped group of eight pages took six or seven rows and\n * covered the page — the other half of what `mobileMaxItems` does for the bar.\n */\n mobileSubNavLayout?: \"wrap\" | \"scroll\";\n /**\n * The most cells the phone bar holds, \"More\" included (0.49 KIT-6). When `nav` (after\n * `mobileHidden`) has more entries, the bar keeps `mobileMaxItems − 1` of them and a\n * last \"More\" cell opens a sheet with the rest, each group with its pages. Which\n * entries stay is the items' `mobilePriority`, else the list's order (so the app puts\n * its most used entries first, or orders by role: kastlan's manager and accountant see\n * different firsts).\n *\n * Default {@link DEFAULT_MOBILE_MAX_ITEMS}: 5 at Normal and Large, 4 at Extra large —\n * eight entries are four and \"More\". A number replaces the default at every size;\n * `{ xlarge: 5 }` replaces it at one size only. Never fewer than one entry beside More.\n */\n mobileMaxItems?: number | Partial<Record<TextSize, number>>;\n /** The More cell's words over the provider's `appShellMore`. */\n moreLabels?: Partial<AppShellMoreLabels>;\n /**\n * Lay the shell out inside its PARENT'S box instead of the viewport: `h-full` rather\n * than `h-dvh`, its own scroll container at every width, a bottom bar pinned to the\n * shell rather than the window, `--app-nav-h` published on the shell alone, and no\n * persisted collapse state unless `collapseStorageKey` is passed. For an app preview,\n * a device frame, a docs example.\n *\n * Implied for a shell rendered inside another AppShell, which is the case this\n * exists for: the inner one used to publish its own nav height on `<html>`, fight\n * the outer one over it, and remove it on unmount from under the outer app.\n */\n embedded?: boolean;\n /** The shell's root, where the rest of the props go (0.34, API-2, refactor audit\n * 2026-10) — merged with its own ref, which `--app-nav-h` is published on. */\n ref?: Ref<HTMLDivElement>;\n}\n\n/** True below an AppShell — how a nested shell knows it is one. */\nconst AppShellNesting = createContext(false);\n\n/**\n * The bottom nav's own height, published as `--app-nav-h` so anything that has to sit\n * ON it can stop guessing.\n *\n * Keksdose live #314 is what this is for. Its rework — *\"Stick it to the bottom\n * touching the bottom icon bar with budget, accounts, … Currently there is a small gap\n * which confuses\"* — was a receipt footer pinned at `bottom-20`, because `<main>`\n * reserves `pb-20` for this nav and 20 looked like the nav's height. It is not: the\n * padding is generous CLEARANCE, and the nav is content-sized (icon + label + `py-2`,\n * about 56px), so the footer floated ~24px above the bar.\n *\n * Measured rather than named, because the height is not a constant anyone owns: it is\n * an icon, a translated label that can wrap or truncate, and whatever the platform does\n * with the safe-area inset. A hard-coded `bottom-14` would be the same guess one number\n * lower, and it would be wrong again the first time a label needed two lines.\n *\n * `0px` when the nav is not rendered — above `md` it is `display:none`, which observes\n * as a zero box — so a consumer can write `bottom-[var(--app-nav-h,0px)]` once and get\n * the right answer at both widths without a breakpoint of its own.\n */\nfunction useNavHeightVar(\n ref: React.RefObject<HTMLElement | null>,\n shellRef: React.RefObject<HTMLElement | null>,\n embedded: boolean,\n): void {\n // Re-run when the breakpoint flips. A ResizeObserver SKIPS an element that is not\n // being rendered, so the nav going `display:none` above `md` fires no callback and\n // would leave the last phone height published — a desktop footer would then sit 56px\n // off the bottom after a live resize. `useBreakpoint(\"md\")` is the nav's own `md:hidden`\n // at the text size in force (0.32), so the two cannot disagree about where the\n // boundary is — at Extra large both move to 72rem.\n const isMdUp = useBreakpoint(\"md\", false);\n useEffect(() => {\n const node = ref.current;\n const shell = shellRef.current;\n // Always on the shell's own root, so everything inside it — a nested shell's\n // content included — reads the nearest bar's height. On <html> as well only for\n // the OUTERMOST shell, for what it portals to <body> (a sheet docking on the bar).\n // The DOM check backs up the context for a shell mounted in a separate React root.\n const global = !embedded && !shell?.parentElement?.closest(\"[data-app-shell]\");\n const targets = [shell, global ? document.documentElement : null].filter((el): el is HTMLElement => el !== null);\n // `getBoundingClientRect().height`, rounded DOWN — not `offsetHeight`, and not\n // ceil. Measured on the running app at 406x816: the bar is **55.5px** tall, and\n // both `offsetHeight` and `Math.ceil` answer 56. That is why live #314 round four\n // was *\"No change. Still a pixel inbetween\"* — the previous fix was arithmetically\n // a no-op on the very value it was meant to correct.\n //\n // 56 is the wrong side. A sticky element with `bottom: X` puts its bottom edge X\n // above the viewport bottom, and the bar's TOP edge is at its own height: so\n // X = 56 lands the footer at y=760.0 against a bar starting at y=760.5, i.e. half\n // a CSS pixel of page showing through — about 1.4 device pixels on his phone,\n // which is exactly the hairline in the screenshot.\n //\n // The two errors are not symmetric, and I had them backwards the first time.\n // Too SMALL tucks the sticky element under a bar that is opaque and painted above\n // it (`z-30` against `z-10`): invisible. Too LARGE opens the seam. So floor, and\n // consumers subtract a further pixel (see `invoice-line-totals.tsx`) for the case\n // where the height lands on a whole pixel and floor leaves no overlap at all.\n const publish = () => {\n const value = `${node ? Math.floor(node.getBoundingClientRect().height) : 0}px`;\n for (const el of targets) el.style.setProperty(\"--app-nav-h\", value);\n };\n publish();\n // The observer is the refinement, not the mechanism: `publish()` above is already\n // right for a static nav, and jsdom has no ResizeObserver unless a test stubs one.\n // ONE cleanup for every branch, though — an early `return` on the no-observer path\n // left the variable behind on unmount, which a stale `bottom:` offset on whatever\n // rendered next would have inherited.\n const ro = node && typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(publish) : null;\n if (ro && node) ro.observe(node);\n return () => {\n ro?.disconnect();\n for (const el of targets) el.style.removeProperty(\"--app-nav-h\");\n };\n }, [ref, shellRef, embedded, isMdUp]);\n}\n\n/**\n * The responsive application shell: a top bar, a collapsible desktop sidebar\n * (icon-only when collapsed, with tooltips), a mobile bottom nav bar, the main\n * content area, and an optional desktop footer. Router-aware via react-router\n * `NavLink`; domain-free — nav items, brand, footer and the top bar's actions\n * are all supplied by the app.\n */\nexport function AppShell({\n nav,\n topBar,\n children,\n footer,\n sidebarFooter,\n sidebarFooterItems,\n renderLink,\n collapseStorageKey: collapseStorageKeyProp,\n collapseLabel,\n expandLabel,\n subNav = \"flyout\",\n mobileSubNav = true,\n mobileSubNavLayout: mobileSubNavLayoutProp,\n mobileMaxItems,\n moreLabels,\n toggleGroupLabel,\n embedded: embeddedProp,\n className,\n ref,\n ...rest\n}: AppShellProps) {\n const embedded = useContext(AppShellNesting) || !!embeddedProp;\n const { size: textSize } = useTextSize();\n const large = textSize !== \"normal\";\n const mobileSubNavLayout = mobileSubNavLayoutProp ?? (large ? \"scroll\" : \"wrap\");\n // The bottom bar's cells: every entry the phone does not reach another way, up to the\n // text size's limit, More included; the rest go under More (§10.7, KIT-6).\n const maxItems = mobileCells(mobileMaxItems, textSize);\n const { shown: barNav, hidden: moreNav } = pickMobileBar(\n nav.filter((item) => !item.mobileHidden),\n maxItems,\n (item) => item.mobilePriority,\n );\n useNavDevWarnings(nav);\n // An embedded shell sharing the default key would overwrite the outer app's sidebar\n // preference with its own — so it persists only when given a key of its own.\n const collapseStorageKey = collapseStorageKeyProp ?? (embedded ? null : \"appLayout.sidebarCollapsed\");\n // The three props are per-shell overrides of the provider's `appShell`; one left\n // undefined falls through to the provider rather than to English.\n const labels = useKitLabels(\"appShell\", DEFAULT_APP_SHELL_LABELS, {\n collapse: collapseLabel,\n expand: expandLabel,\n toggleGroup: toggleGroupLabel,\n });\n // Through the guarded helpers, not `window.localStorage` directly. The read runs\n // inside a `useState` initialiser — i.e. during render of the top-level shell — and\n // `localStorage` THROWS where site data is blocked (Safari private browsing, a\n // partitioned webview). Unguarded, that was not a lost sidebar preference: nothing\n // in the application mounted at all.\n const [collapsed, setCollapsed] = useState(\n () => collapseStorageKey !== null && readStored(collapseStorageKey) === \"1\",\n );\n // The inline sidebar is an ACCORDION: one group open at a time, keyed by its `to`.\n // Held here rather than per group so opening one can close the other — two lists\n // open at once pushed every entry below them off a laptop screen.\n const [openGroup, setOpenGroup] = useState<string | null>(null);\n // Publishes `--app-nav-h` for anything that has to sit on the bottom bar.\n const navRef = useRef<HTMLDivElement>(null);\n const rootRef = useRef<HTMLDivElement>(null);\n const setRoot = useMemo(() => mergeRefs(rootRef, ref), [ref]);\n useNavHeightVar(navRef, rootRef, embedded);\n useEffect(() => {\n if (collapseStorageKey !== null) writeStored(collapseStorageKey, collapsed ? \"1\" : \"0\");\n }, [collapsed, collapseStorageKey]);\n // Reset this device's settings (docs/settings-harmonization.md §11.4): the sidebar\n // unfolds, live, and the effect above writes \"0\". An embedded shell without a key of\n // its own stores nothing and joins nothing.\n useEffect(() => {\n if (collapseStorageKey === null) return;\n return registerDeviceSetting({ key: collapseStorageKey, kind: \"view\", reset: () => setCollapsed(false) });\n }, [collapseStorageKey]);\n // §4: at Large and Extra large the sidebar never collapses to icons only — a glyph\n // with its name in a tooltip is the very thing a reader who asked for bigger type\n // cannot use. The persisted preference is left alone, so Normal gets it back, and the\n // toggle goes while it could not do anything.\n const iconOnly = collapsed && !large;\n\n return (\n // The caller's attributes go on the shell's own root, never on the `data-tour=\"nav\"`\n // wrappers below — those are the kit's anchors for its own guided tour (#313/#322),\n // and a second element answering to the same selector is a tour that highlights the\n // wrong thing or nothing at all.\n <AppShellNesting.Provider value={true}>\n <div\n {...rest}\n ref={setRoot}\n data-app-shell=\"\"\n className={cn(\n \"relative flex flex-col\",\n embedded\n ? // `contain: layout` makes this box the containing block for the `fixed`\n // bottom bar below, so it pins to the shell rather than to the window.\n \"h-full min-h-0 overflow-hidden [contain:layout]\"\n : \"min-h-screen md:h-dvh md:overflow-hidden\",\n className,\n )}\n >\n {/* §4: \"the top bar keeps its essential icons\" — its IconButtons stay icons at\n Large (their labels the names and tooltips) and a locked one keeps its reason\n in the tooltip: a bar 3rem tall has no room for words under every glyph. */}\n <CompactControls>{topBar}</CompactControls>\n <div className=\"flex flex-1 min-h-0\">\n <aside\n className={cn(\n // `border-e`: the sidebar sits at the START, which is the right in RTL.\n \"hidden md:flex md:flex-col border-e border-subtle bg-surface transition-[width] duration-200 ease-out overflow-hidden\",\n // Embedded, the row it sits in is already the shell's height; the sticky\n // offsets below are measured against the window's top bar.\n embedded ? \"md:self-stretch\" : \"md:sticky md:top-12 md:self-start md:h-[calc(100vh-3rem)]\",\n iconOnly ? \"md:w-14\" : \"md:w-60\",\n )}\n >\n {/* The `<nav>` is flex-1 so it fills the sidebar's height (with empty\n space below the items); the data-tour marker goes on the INNER,\n fit-content wrapper so the guided-tour spotlight hugs the actual nav\n items instead of the whole tall column (feedback #322). The marker\n also tags the mobile bottom bar below; the tour targets\n `[data-tour=\"nav\"]` and resolves to whichever is visible (#313). */}\n <nav className=\"flex-1 px-2 py-3 overflow-y-auto overflow-x-hidden\">\n <div data-tour=\"nav\" className=\"space-y-1\">\n {nav.map((item) => (\n <SidebarNavItem\n key={item.to}\n item={item}\n collapsed={iconOnly}\n inline={subNav === \"inline\"}\n toggleGroupLabel={labels.toggleGroup}\n openGroup={openGroup}\n setOpenGroup={setOpenGroup}\n />\n ))}\n </div>\n </nav>\n {!!sidebarFooterItems?.length && (\n <SidebarFooterItems items={sidebarFooterItems} collapsed={iconOnly} renderLink={renderLink} />\n )}\n {sidebarFooter?.(iconOnly)}\n {/* No toggle at Large: the sidebar cannot collapse there (see `iconOnly`). */}\n {!large && (\n <div className=\"border-t border-subtle p-2\">\n {collapsed ? (\n <Tooltip label={labels.expand} side=\"end\" portal className=\"block\">\n <button\n type=\"button\"\n onClick={() => setCollapsed(false)}\n aria-label={labels.expand}\n className=\"flex w-full items-center justify-center min-h-9 rounded-md text-muted hover:bg-hover hover:text-secondary\"\n >\n <PanelLeftOpen className=\"size-4 shrink-0 rtl:-scale-x-100\" />\n </button>\n </Tooltip>\n ) : (\n <button\n type=\"button\"\n onClick={() => setCollapsed(true)}\n aria-label={labels.collapse}\n className=\"flex w-full items-center gap-3 min-h-9 px-3 py-2 rounded-md text-sm text-muted hover:bg-hover hover:text-secondary\"\n >\n <PanelLeftClose className=\"size-4 shrink-0 rtl:-scale-x-100\" />\n {/* Never drawn at Large (the toggle is not), so the class matters at\n Normal only — the kit's one name for it all the same (round 0.34 T1). */}\n <span className=\"truncate-until-large\">{labels.collapse}</span>\n </button>\n )}\n </div>\n )}\n </aside>\n\n {/* Content column beside the sidebar. main grows to fill so the footer\n sits at the bottom — at the viewport edge when content is short,\n beside the sidebar rather than under it. */}\n <div className=\"flex flex-1 flex-col min-w-0 md:min-h-0\">\n {/* `scrollbar-gutter: stable` reserves the scrollbar's track whether or\n not it is currently needed. Without it this element — the app's only\n scroll container from md up — narrows its own client box by the\n scrollbar width the moment a page's content outgrows it, and widens\n it again when the next page fits. Every centred `mx-auto` container\n inside then jumps sideways by half a scrollbar, and any fluid-width\n content changes width outright. Keksdose feedback #403 caught it as\n \"slight width increase/decrease\" when switching to the notifications\n settings section and back: that section is the only one tall enough\n to scroll. Platform-dependent, which is why it is easy to miss —\n overlay scrollbars (macOS, most Linux builds) take no layout space,\n classic ones (Windows) take ~15px.\n\n `both-edges`, not the bare `stable`: a one-sided reservation keeps the\n width stable but moves the middle. On a page short enough not to\n scroll, nothing is painted into the reserved track, so every centred\n `mx-auto` container sits half a scrollbar left of the optical centre\n and every full-bleed child stops ~15px short on the right. Keksdose\n feedback #491 (/settings#data) and #498 (/budgets) both reported it as\n \"the left boundary looks smaller / cut off compared to the right\" on\n the one element per page whose frame is a saturated colour — the rose\n destructive-action cards. Reserving the track on both edges keeps the\n content centred whether or not the scrollbar is showing. */}\n {/* `relative` makes <main> the containing block for everything absolutely\n positioned inside it. Tailwind's `sr-only` is `position:absolute`; with no\n positioned ancestor it resolves against the INITIAL containing block, is\n laid out at its offset from the top of the DOCUMENT, and grows\n `<html>`'s scroll height past the viewport — a second scrollbar beside this\n one that scrolls into empty space. Guarding it per component (see\n sr-only-containment.test) could never be complete: any page's own\n `sr-only` span re-opened it. Here it is closed for every child at once. */}\n {/* Below `md` the bottom room is the nav plus the larger of 1.5rem and what the\n floating launchers take above it (`--app-float-clearance`, published by\n every kit FAB, FloatingPanel and FloatingActionGroup while mounted — keksdose\n dev#612: the last row ended under the help launcher). From `md` up, where\n there is no nav, the launchers' room alone (0.49 KIT-11): the last row\n scrolls clear of a corner button there too. */}\n <main\n className={cn(\n \"relative flex-1 max-w-full overflow-x-clip pb-[calc(var(--app-nav-h,4rem)+max(1.5rem,var(--app-float-clearance,0px)))] md:pb-[var(--app-float-clearance,0px)] md:min-h-0 md:overflow-y-auto md:[scrollbar-gutter:stable_both-edges]\",\n // The list page's fill (0.40, docs/page-layout-harmonization.md §1.3): while\n // a `fillHeight` DataTable is inside, a flex column — a banner above the\n // page keeps its own height and the page (a `FillHeight`) takes the rest,\n // so `<main>` no longer overflows by the banner. Its children do not shrink\n // (a banner of a fixed height or `overflow-hidden` would): the page grows\n // into the rest from a zero basis, and a window too short for the page's\n // floor scrolls `<main>`. Every other page lays out as before. Below `md`\n // the document scrolls and nothing fills.\n // The children's `shrink-0` carries no `:has`: `flex-shrink` does nothing\n // outside a flex container, and a `:has(…) > *` rule cost a style recalc of\n // the whole page on every DOM insertion under it (17–45 ms per scrolled step\n // of a `virtualize` table, 0.48.2). `[&&>*]` doubles the class, so it stays\n // as specific as FillHeight's `has-[…]:flex-1` (whose `flex: 1` would set\n // shrink 1) and, emitted after it, still wins.\n \"md:has-[[data-fill-height]]:flex md:has-[[data-fill-height]]:flex-col md:[&&>*]:shrink-0\",\n // Embedded there is no document scroll to lean on below `md` either.\n embedded && \"min-h-0 overflow-y-auto\",\n )}\n >\n {children}\n </main>\n {footer}\n </div>\n </div>\n\n {/* The phone navigation: the group bar, and above it — when the current page\n belongs to a group with pages of its own — the row of those pages. The pair\n is the phone's version of the sidebar's two levels; without the upper row a\n group's `items` were simply unreachable below `md`. ONE measured box, so\n `--app-nav-h` covers both rows and whatever docks on the bar sits on the\n whole of it. */}\n <div ref={navRef} className=\"md:hidden fixed bottom-0 inset-x-0 z-30 border-t border-subtle bg-surface\">\n {mobileSubNav && <MobileSubNav nav={nav} layout={mobileSubNavLayout} />}\n <nav\n data-tour=\"nav\"\n className=\"grid\"\n style={{ gridTemplateColumns: `repeat(${barNav.length + (moreNav.length ? 1 : 0)}, minmax(0, 1fr))` }}\n >\n {barNav.map((item) =>\n item.items?.length ? (\n <MobileGroupCell key={item.to} item={item} labels={moreLabels} />\n ) : (\n <MobileNavItem key={item.to} item={item} />\n ),\n )}\n {moreNav.length > 0 && <MobileMoreCell hidden={moreNav} labels={moreLabels} />}\n </nav>\n </div>\n </div>\n </AppShellNesting.Provider>\n );\n}\n\nconst routerLink: KitLinkComponent = ({ href, ...p }) => <Link to={href} {...p} />;\nconst plainLink: KitLinkComponent = ({ children, ...p }) => <a {...p}>{children}</a>;\n\nconst FOOTER_ICON_LINK =\n \"flex min-h-8 items-center justify-center rounded-md text-muted hover:bg-hover hover:text-secondary\";\n\n/** A footer link's count as drawn: nothing for none, \"99+\" past 99. */\nfunction footerBadgeText(badge: number | null | undefined): string | null {\n if (typeof badge !== \"number\" || !(badge > 0)) return null;\n return badge > 99 ? \"99+\" : String(Math.floor(badge));\n}\n\n/** The count's pill — the solid \"count\" look of `Chip` (warning, the pending count's\n * tone, as `FloatingActionGroup`'s badge), sized for the footer's small text. */\nconst FOOTER_BADGE =\n \"inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-warning px-1 text-micro font-semibold leading-4 tabular-nums text-warning-contrast\";\n\n/** Calls the link renderer as a component, so a router link's hooks are its own. */\nfunction RenderedLink({ render, ...props }: KitLinkProps & { render: KitLinkComponent }) {\n return render(props);\n}\n\n/** The sidebar's bottom area, from {@link AppShellSidebarFooterItem}s. */\nfunction SidebarFooterItems({\n items,\n collapsed,\n renderLink,\n}: {\n items: AppShellSidebarFooterItem[];\n collapsed: boolean;\n renderLink?: KitLinkComponent;\n}) {\n const kitLink = useKitLink();\n const linkTo = (to: string, external: boolean | undefined, { children, ...props }: Omit<KitLinkProps, \"href\">) => {\n // The kit's one link rule (`pickLinkRenderer`): an external `to` or an in-page\n // `#anchor` is a plain `<a>` even without `external`; only `external` opens a tab.\n const InApp = pickLinkRenderer(renderLink, kitLink ?? routerLink, to) ?? plainLink;\n return external ? (\n <a href={to} target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ) : (\n <RenderedLink render={InApp} href={to} {...props}>\n {children}\n </RenderedLink>\n );\n };\n\n return (\n <div data-slot=\"sidebar-footer-items\" className={cn(\"px-2 py-1\", collapsed ? \"space-y-1\" : \"space-y-1.5\")}>\n {items.map((item) => {\n if (collapsed) {\n const to = item.kind === \"links\" ? (item.to ?? item.links[0]?.to) : item.to;\n if (!to) return null;\n const external = item.kind === \"links\" ? item.links.find((l) => l.to === to)?.external : item.external;\n const count = item.kind === \"links\" ? null : footerBadgeText(item.badge);\n const spoken = count === null || item.kind === \"links\" ? null : (item.badgeLabel ?? count);\n return (\n <Tooltip key={item.key} label={item.label} side=\"end\" portal className=\"block\">\n {linkTo(to, external, {\n \"aria-label\": spoken === null ? item.label : `${item.label}, ${spoken}`,\n className: cn(FOOTER_ICON_LINK, count !== null && \"relative\"),\n children: (\n <>\n <item.icon className=\"size-4\" aria-hidden />\n {count !== null && (\n <span aria-hidden data-badge=\"\" className={cn(FOOTER_BADGE, \"absolute -top-0.5 end-0.5\")}>\n {count}\n </span>\n )}\n </>\n ),\n })}\n </Tooltip>\n );\n }\n if (item.kind === \"links\") {\n return (\n <nav\n key={item.key}\n aria-label={item.label}\n className=\"flex flex-wrap justify-center gap-x-3 gap-y-0.5 text-caption text-muted\"\n >\n {item.links.map((l) => (\n <span key={l.to}>\n {linkTo(l.to, l.external, {\n className: \"rounded-sm hover:text-secondary hover:underline\",\n children: l.label,\n })}\n </span>\n ))}\n </nav>\n );\n }\n const count = footerBadgeText(item.badge);\n const link = linkTo(item.to, item.external, {\n className: cn(FOOTER_ICON_LINK, \"gap-1.5 text-xs font-medium\"),\n children: (\n <>\n <item.icon className=\"size-3.5 shrink-0\" aria-hidden />\n {/* Wraps from Large up (text size §10.17, round 0.34 T1): the link is\n `min-h-8`, so it grows a line rather than cut \"Feedb…\". */}\n <span className=\"min-w-0 truncate-until-large\">{item.text ?? item.label}</span>\n {count !== null && (\n <>\n <span aria-hidden data-badge=\"\" className={FOOTER_BADGE}>\n {count}\n </span>\n <span className=\"sr-only\">, {item.badgeLabel ?? count}</span>\n </>\n )}\n </>\n ),\n });\n return item.hint ? (\n <Tooltip key={item.key} label={item.hint} side=\"top\" portal className=\"block\">\n {link}\n </Tooltip>\n ) : (\n <div key={item.key}>{link}</div>\n );\n })}\n </div>\n );\n}\n\n/**\n * A bar cell's look, shared by the entries and the More cell. The active page needs a\n * clear marker, not just a subtle text shade (feedback #327): brand-accent icon + label,\n * bolder weight, and a top accent bar spanning the cell so it reads at a glance.\n */\nconst mobileCellClass = (active: boolean) =>\n cn(\n // `h-full`: the grid row stretches every cell to the tallest one's height, so a\n // label on two lines never leaves its neighbours a different shape.\n \"relative flex h-full w-full flex-col items-center justify-start py-2 text-caption gap-0.5 transition-colors\",\n \"before:absolute before:content-[''] before:inset-x-4 before:top-0 before:h-0.5 before:rounded-full before:transition-colors\",\n active ? \"font-semibold text-brand before:bg-brand\" : \"text-muted before:bg-transparent\",\n );\n\n/**\n * A bar cell's label (0.32, §10.7): up to TWO lines, never an ellipsis on one. At Large\n * a cell is a fifth of a phone holding type a quarter bigger, and one line truncated\n * \"Transactions\" to \"Trans…\" in every app (Kurvenschmiede). Two lines and then a clamp,\n * centred, a long word broken (and hyphenated where the page's `lang` allows) rather\n * than overflowing into the next cell. `shortLabel` still wins where the app has one.\n *\n * `data-truncate-ok` (text size §10.17, round 0.34 T1): the clamp is that decision, not\n * an accident — the size sweep finds \"Sowing calen…\" in a 65 px cell at 360 px / Extra\n * large, and a third line would make every cell of the bar taller for one long word.\n * The whole label stays the link's accessible name; an app with a long one gives the bar\n * a `shortLabel`.\n */\nfunction MobileCellLabel({ children }: { children: ReactNode }) {\n return (\n <span\n data-truncate-ok=\"\"\n className=\"line-clamp-2 max-w-full break-words px-0.5 text-center leading-tight hyphens-auto\"\n >\n {children}\n </span>\n );\n}\n\n/** One cell of the phone's group bar. Marked while the group's own page OR any of its\n * pages is current — NavLink alone only knows its own `to`, which left the bar with\n * nothing marked on every sub-page (the same defect the sidebar had). */\nfunction MobileNavItem({ item }: { item: AppShellNavItem }) {\n const subActive = useSubItemActive(item);\n const label = useCellLabel(item);\n return (\n <NavLink\n to={item.to}\n end={item.end ?? true}\n data-tour={item.dataTour}\n className={({ isActive }) => mobileCellClass(isActive || subActive)}\n >\n <span className=\"relative\">\n <item.icon className=\"size-5\" />\n </span>\n <MobileCellLabel>{label}</MobileCellLabel>\n </NavLink>\n );\n}\n\n/** The bar cell's label: `shortLabel` from its text size up (0.48), else `label`. */\nfunction useCellLabel(item: AppShellNavItem): string {\n const { size } = useTextSize();\n return item.shortLabel !== undefined &&\n TEXT_SIZES.indexOf(size) >= TEXT_SIZES.indexOf(item.shortLabelFrom ?? \"normal\")\n ? item.shortLabel\n : item.label;\n}\n\n/** A link in one of the phone's sheets — an entry (`level=\"entry\"`) or a page under one. */\nfunction SheetLink({\n to,\n end,\n icon: Icon,\n label,\n onClick,\n level,\n}: {\n to: string;\n end?: boolean;\n icon: LucideIcon;\n label: string;\n onClick: () => void;\n level: \"entry\" | \"page\";\n}) {\n return (\n <NavLink\n to={to}\n end={end ?? true}\n onClick={onClick}\n className={({ isActive }) =>\n cn(\n level === \"entry\"\n ? \"flex min-h-11 items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors\"\n : \"flex min-h-11 items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors\",\n isActive\n ? \"bg-inverse text-inverse\"\n : level === \"entry\"\n ? \"text-primary hover:bg-hover\"\n : \"text-secondary hover:bg-hover\",\n )\n }\n >\n <Icon aria-hidden className={level === \"entry\" ? \"size-5 shrink-0\" : \"size-4 shrink-0 opacity-70\"} />\n <span className=\"min-w-0 break-words leading-snug\">{label}</span>\n </NavLink>\n );\n}\n\n/**\n * A bar cell for an entry with pages (0.49 KIT-6): on a phone the entry opens a sheet of\n * its pages instead of linking to its own `to` — a tap on \"Reports\" used to land on the\n * overview with the pages one more step away, in the row above the bar, which only\n * appears once you are in the group. The sheet lists the entry's own page first, as\n * \"Overview\", when none of the pages is that page. Marked while the entry's page or one\n * of its pages is current, as the link was.\n *\n * Tours find the entry by `a[href]` or its `dataTour`, as on the More cell: an inert,\n * pointer-transparent anchor over the button carries them (see {@link MobileMoreCell}).\n */\nfunction MobileGroupCell({\n item,\n labels: labelsProp,\n}: {\n item: AppShellNavItem;\n labels?: LabelOverride<AppShellMoreLabels>;\n}) {\n const labels: AppShellMoreLabels = useKitLabels(\"appShellMore\", DEFAULT_APP_SHELL_MORE_LABELS, labelsProp);\n const { pathname } = useLocation();\n const [open, setOpen] = useState(false);\n const label = useCellLabel(item);\n const active = entryIsCurrent(item, pathname);\n const close = () => setOpen(false);\n const pages = item.items ?? [];\n const ownPageListed = pages.some((sub) => sub.to === item.to);\n return (\n <div data-slot=\"app-shell-group\" className=\"relative min-w-0\">\n <button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // The cell may show a shortLabel; the button's name is the entry's.\n aria-label={label === item.label ? undefined : item.label}\n onClick={() => setOpen(true)}\n className={mobileCellClass(active)}\n >\n <span className=\"relative\">\n <item.icon aria-hidden className=\"size-5\" />\n </span>\n <MobileCellLabel>{label}</MobileCellLabel>\n </button>\n <TourAnchor to={item.to} dataTour={item.dataTour} />\n {pages\n .filter((sub) => sub.to !== item.to)\n .map((sub) => (\n <TourAnchor key={sub.to} to={sub.to} />\n ))}\n <DialogFrame open={open} onClose={close} title={item.label} closeButton bodyClassName=\"space-y-1\">\n <ul className=\"space-y-1\">\n {!ownPageListed && (\n <li>\n <SheetLink\n to={item.to}\n end={item.end}\n icon={item.icon}\n label={labels.overview}\n onClick={close}\n level=\"entry\"\n />\n </li>\n )}\n {pages.map((sub) => (\n <li key={sub.to}>\n <SheetLink to={sub.to} end={sub.end} icon={sub.icon} label={sub.label} onClick={close} level=\"entry\" />\n </li>\n ))}\n </ul>\n </DialogFrame>\n </div>\n );\n}\n\n/** Whether the current route is `item`'s page or one of its pages. */\nfunction entryIsCurrent(item: AppShellNavItem, pathname: string): boolean {\n return (\n !!matchPath({ path: item.to, end: item.end ?? true }, pathname) ||\n !!item.items?.some((sub) => matchPath({ path: sub.to, end: sub.end ?? true }, pathname))\n );\n}\n\n/** A hidden entry's link, resolved as the router would write it (basename included). */\nfunction TourAnchor({ to, dataTour }: { to: string; dataTour?: string }) {\n const href = useHref(to);\n return (\n // eslint-disable-next-line jsx-a11y/anchor-has-content -- a tour anchor, aria-hidden and inert; the More button under it is the control (see MobileMoreCell)\n <a\n href={href}\n data-tour={dataTour}\n // Not a control: no name, no tab stop, no pointer — the More button under it\n // takes the tap. It exists only to be FOUND (see MobileMoreCell).\n aria-hidden\n tabIndex={-1}\n className=\"pointer-events-none absolute inset-0\"\n />\n );\n}\n\n/**\n * The bar's \"More\" cell (0.32, docs/text-size-harmonization.md §4, §10.7): the entries\n * past `mobileMaxItems`, in a sheet — each entry as a link, and under a group its pages,\n * since a group the bar no longer shows has no sub-row to reach them by either. Marked\n * active while the current page is one of them, as the cell it replaced would be.\n *\n * **Tour anchors.** A guided tour finds a nav entry by `[data-tour=\"nav\"] a[href=\"/x\"]`\n * (keksdose's tours) or by the entry's own `dataTour`. An entry under More has no link\n * in the bar, and the sidebar's copy is `display:none` on a phone, so such a step would\n * spotlight nothing. So the More cell carries the hidden entries' links — one `<a>` per\n * entry and per page of a hidden group, with the entry's `href` and `dataTour` — laid\n * over the cell (`absolute inset-0`): both selectors resolve to a visible box, and that\n * box is the More cell, which is where the reader has to go next. They are\n * `aria-hidden`, out of the tab order and pointer-transparent, so neither a screen\n * reader nor a tap ever meets them; the button under them is the one control.\n */\nfunction MobileMoreCell({\n hidden,\n labels: labelsProp,\n}: {\n hidden: AppShellNavItem[];\n labels?: LabelOverride<AppShellMoreLabels>;\n}) {\n const labels: AppShellMoreLabels = useKitLabels(\"appShellMore\", DEFAULT_APP_SHELL_MORE_LABELS, labelsProp);\n const { pathname } = useLocation();\n const [open, setOpen] = useState(false);\n const active = hidden.some((item) => entryIsCurrent(item, pathname));\n const close = () => setOpen(false);\n return (\n <div data-slot=\"app-shell-more\" className=\"relative min-w-0\">\n <button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={() => setOpen(true)}\n className={mobileCellClass(active)}\n >\n <span className=\"relative\">\n <MoreHorizontal aria-hidden className=\"size-5\" />\n </span>\n <MobileCellLabel>{labels.more}</MobileCellLabel>\n </button>\n {hidden.flatMap((item) => [\n <TourAnchor key={item.to} to={item.to} dataTour={item.dataTour} />,\n ...(item.items ?? []).map((sub) => <TourAnchor key={`${item.to} ${sub.to}`} to={sub.to} />),\n ])}\n <DialogFrame open={open} onClose={close} title={labels.moreTitle} closeButton bodyClassName=\"space-y-1\">\n <ul className=\"space-y-1\">\n {hidden.map((item) => (\n <li key={item.to}>\n <SheetLink\n to={item.to}\n end={item.end}\n icon={item.icon}\n label={item.label}\n onClick={close}\n level=\"entry\"\n />\n {!!item.items?.length && (\n <ul aria-label={item.label} className=\"ms-[1.3rem] mt-0.5 space-y-0.5 border-s border-subtle ps-2\">\n {item.items.map((sub) => (\n <li key={sub.to}>\n <SheetLink\n to={sub.to}\n end={sub.end}\n icon={sub.icon}\n label={sub.label}\n onClick={close}\n level=\"page\"\n />\n </li>\n ))}\n </ul>\n )}\n </li>\n ))}\n </ul>\n </DialogFrame>\n </div>\n );\n}\n\n/**\n * The upper row of the phone navigation: the pages of the group the reader is in, as\n * a sideways-scrolling row of pills. Rendered only while such a group is current —\n * on a page outside every group the bar stays one row, rather than showing an empty\n * shelf or guessing a group.\n *\n * It slides in over 200ms (fade only under reduced motion) and wraps onto more rows\n * rather than scrolling, so every page of the group is in view at once.\n */\nfunction MobileSubNav({ nav, layout }: { nav: AppShellNavItem[]; layout: \"wrap\" | \"scroll\" }) {\n const { pathname } = useLocation();\n const scroll = layout === \"scroll\";\n const listRef = useRef<HTMLUListElement>(null);\n const fade = useStripFade(listRef);\n // The current page into view — the row only, never the page.\n useLayoutEffect(() => {\n const list = listRef.current;\n const current = list?.querySelector<HTMLElement>('[aria-current=\"page\"]');\n if (scroll && list && current) scrollIntoStrip(list, current);\n }, [scroll, pathname]);\n const group = nav.find(\n (item) =>\n !!item.items?.length &&\n (matchPath({ path: item.to, end: item.end ?? true }, pathname) ||\n item.items.some((sub) => matchPath({ path: sub.to, end: sub.end ?? true }, pathname))),\n );\n\n if (!group) return null;\n return (\n <nav\n aria-label={group.label}\n // Keyed by group so switching groups replays the entrance.\n key={group.to}\n className=\"animate-subnav border-b border-subtle\"\n >\n <ul\n ref={listRef}\n // `wrap` (default) takes as many rows as the group needs: a sideways row hides\n // pages past the edge, and every page of the group in view is the point of the\n // row. The bar grows with it — `--app-nav-h` measures it. `scroll` is the app's\n // opt-in trade: one row, the cut edge faded (see mobileSubNavLayout).\n className={cn(\n \"flex gap-1.5 px-3 py-2\",\n scroll ? \"overflow-x-auto overscroll-x-contain [scrollbar-width:none]\" : \"flex-wrap\",\n )}\n data-overflow={scroll ? fade.overflow : undefined}\n style={scroll && fade.mask ? { maskImage: fade.mask, WebkitMaskImage: fade.mask } : undefined}\n >\n {group.items!.map((sub) => (\n <li key={sub.to} className=\"shrink-0\">\n <NavLink\n to={sub.to}\n end={sub.end ?? true}\n className={({ isActive }) =>\n cn(\n \"flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs transition-colors\",\n isActive\n ? \"border-brand bg-brand font-medium text-brand-contrast\"\n : \"border-subtle text-secondary hover:bg-hover\",\n )\n }\n >\n <sub.icon className=\"size-3.5 shrink-0\" aria-hidden />\n {sub.label}\n </NavLink>\n </li>\n ))}\n </ul>\n </nav>\n );\n}\n\n/** `strong` is the current page; `trail` is the group that CONTAINS the current page\n * while the page itself is shown elsewhere (the inline list below it). */\nconst navLinkClass =\n (collapsed: boolean, forceActive: boolean, trail = false) =>\n ({ isActive }: { isActive: boolean }) =>\n `flex items-center gap-3 min-h-9 ${collapsed ? \"justify-center px-2\" : \"px-3\"} py-2 rounded-md text-sm transition-colors duration-150 ${\n isActive || (forceActive && !trail)\n ? \"bg-inverse text-inverse\"\n : forceActive\n ? \"font-medium text-primary hover:bg-hover\"\n : \"text-secondary hover:bg-hover\"\n }`;\n\n/** Whether any of an entry's sub-items is the current route. NavLink only knows about\n * its OWN `to`, so without this a group whose pages live at sibling paths\n * (`/fields`, `/numbers`, …) lost its highlight the moment the reader left the one\n * page the group linked to — the sidebar then marked nothing at all, and the only\n * \"you are here\" left was inside a flyout that is closed unless hovered. */\nfunction useSubItemActive(item: AppShellNavItem): boolean {\n const { pathname } = useLocation();\n return !!item.items?.some((sub) => matchPath({ path: sub.to, end: sub.end ?? true }, pathname));\n}\n\n/** A single desktop sidebar entry. Plain link (with a tooltip when collapsed) —\n * unless it has sub-items, in which case hovering/focusing opens a flyout, or (with\n * `inline`) a disclosure lists them underneath. */\nfunction SidebarNavItem({\n item,\n collapsed,\n inline,\n toggleGroupLabel,\n openGroup,\n setOpenGroup,\n}: {\n item: AppShellNavItem;\n collapsed: boolean;\n inline: boolean;\n toggleGroupLabel: (groupLabel: string) => string;\n openGroup: string | null;\n setOpenGroup: (to: string | null) => void;\n}) {\n const hasSub = !!item.items?.length;\n const subActive = useSubItemActive(item);\n\n // In the EXPANDED sidebar a group is one component in both styles, so switching\n // between them is a transition of the same element (the page list folding away or\n // unfolding) rather than one tree replaced by another. The icon-only sidebar keeps\n // the plain flyout below: an indented list has no room there.\n if (hasSub && !collapsed) {\n return (\n <SidebarGroup\n item={item}\n subActive={subActive}\n inline={inline}\n toggleGroupLabel={toggleGroupLabel}\n open={openGroup === item.to}\n setOpenGroup={setOpenGroup}\n />\n );\n }\n\n const link = (\n <NavLink\n to={item.to}\n end={item.end ?? true}\n data-tour={item.dataTour}\n className={navLinkClass(collapsed, subActive)}\n aria-haspopup={hasSub ? \"menu\" : undefined}\n >\n <span className=\"relative shrink-0\">\n <item.icon className=\"size-4\" />\n </span>\n {/* Wraps rather than truncates: in the sidebar a label cut to \"Checkbox, switch\n & sl…\" hides the one word that tells two pages apart, and there is height\n to spare. (The phone bar clamps at two lines instead, since 0.32 §10.7.) */}\n {!collapsed && <span className=\"min-w-0 flex-1 break-words leading-snug\">{item.label}</span>}\n {!collapsed && hasSub && <ChevronRight className=\"size-3.5 shrink-0 opacity-60 rtl:-scale-x-100\" />}\n </NavLink>\n );\n\n if (hasSub) return <SidebarFlyout item={item}>{link}</SidebarFlyout>;\n return collapsed ? (\n <Tooltip label={item.label} side=\"end\" portal className=\"block\">\n {link}\n </Tooltip>\n ) : (\n link\n );\n}\n\n/**\n * An entry with sub-items in the expanded sidebar.\n *\n * - `inline`: the entry's own link (its overview page) plus a chevron button that\n * shows or hides the sub-items indented beneath it. Two controls rather than one\n * because they do two different things — a row that both navigated AND toggled\n * would make \"open the overview\" and \"peek at the pages\" the same click.\n * - flyout: the link alone, with the sub-items in a panel beside the sidebar on\n * hover/focus. The inline list is still rendered, folded shut, so that switching\n * styles animates it rather than swapping it.\n *\n * THE FOLD is a `grid-template-rows` transition from `0fr` to `1fr` — the one way to\n * animate to a content-sized height without measuring it, so a translated label that\n * wraps to two lines unfolds exactly as far as it needs. `visibility` rides the same\n * transition so a shut list drops out of the accessibility tree only once it has\n * finished closing, and `inert` takes its links out of the tab order immediately.\n */\nfunction SidebarGroup({\n item,\n subActive,\n inline,\n toggleGroupLabel,\n open,\n setOpenGroup,\n}: {\n item: AppShellNavItem;\n subActive: boolean;\n inline: boolean;\n toggleGroupLabel: (groupLabel: string) => string;\n /** Whether this is the sidebar's one open group (see AppShell's `openGroup`). */\n open: boolean;\n setOpenGroup: (to: string | null) => void;\n}) {\n const listId = useId();\n const { pathname } = useLocation();\n const onOwnPage = !!matchPath({ path: item.to, end: item.end ?? true }, pathname);\n // Opening follows the reader: arriving on this group's overview or one of its pages\n // (by link, by the pager, by Back) opens it — and, the sidebar holding ONE open\n // group, closes whichever was open before. Both folds run at once, so the eye sees\n // one list hand over to the other. Run in an effect after mount, so the current\n // group UNFOLDS into view on load rather than appearing already open.\n const here = subActive || onOwnPage;\n useEffect(() => {\n if (here) setOpenGroup(item.to);\n }, [here, item.to, setOpenGroup]);\n const expanded = inline && open;\n\n const link = (\n <NavLink\n to={item.to}\n end={item.end ?? true}\n data-tour={item.dataTour}\n aria-haspopup={inline ? undefined : \"menu\"}\n // `trail` (inline only): while a page of the group is current, the group row is\n // the breadcrumb, not the destination — the page's own row below carries the\n // strong marker, and two inverse rows would say \"you are here\" twice. In the\n // flyout style the pages are out of sight, so the group row IS the marker.\n className={(state) => cn(navLinkClass(false, subActive, inline)(state), \"min-w-0 flex-1\")}\n >\n <span className=\"relative shrink-0\">\n <item.icon className=\"size-4\" />\n </span>\n <span className=\"min-w-0 flex-1 break-words leading-snug\">{item.label}</span>\n {!inline && <ChevronRight className=\"size-3.5 shrink-0 opacity-60 rtl:-scale-x-100\" />}\n </NavLink>\n );\n\n return (\n <div>\n {inline ? (\n <div className=\"flex items-center gap-0.5\">\n {link}\n <button\n type=\"button\"\n aria-expanded={open}\n aria-controls={listId}\n aria-label={toggleGroupLabel(item.label)}\n onClick={() => setOpenGroup(open ? null : item.to)}\n className=\"flex size-9 shrink-0 items-center justify-center rounded-md text-muted hover:bg-hover hover:text-secondary\"\n >\n <ChevronRight\n aria-hidden\n className={cn(\n \"size-3.5 transition-transform duration-200 ease-out motion-reduce:transition-none rtl:-scale-x-100\",\n // Under dir=\"rtl\" the chevron is MIRRORED first (scale applies before rotate), so\n // it starts pointing left and a +90° turn would point it UP — hence −90° there.\n open && \"rotate-90 rtl:-rotate-90\",\n )}\n />\n </button>\n </div>\n ) : (\n <SidebarFlyout item={item}>{link}</SidebarFlyout>\n )}\n <div\n id={listId}\n inert={!expanded}\n className=\"grid transition-[grid-template-rows,visibility] duration-200 ease-out motion-reduce:transition-none\"\n style={{\n gridTemplateRows: expanded ? \"1fr\" : \"0fr\",\n visibility: expanded ? \"visible\" : \"hidden\",\n }}\n >\n <div\n className={cn(\n \"min-h-0 overflow-hidden transition-opacity duration-200 ease-out motion-reduce:transition-none\",\n expanded ? \"opacity-100\" : \"opacity-0\",\n )}\n >\n {/* The rule and indent live on the list INSIDE the clipping box: margin or\n padding on the element whose row is collapsing to 0fr would hold it open\n by that much. */}\n <ul className=\"ms-[1.3rem] mt-0.5 space-y-0.5 border-s border-subtle ps-2\">\n {item.items!.map((sub) => (\n <li key={sub.to}>\n <NavLink\n to={sub.to}\n end={sub.end ?? true}\n className={({ isActive }) =>\n cn(\n \"flex min-h-8 items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors\",\n isActive ? \"bg-inverse text-inverse\" : \"text-secondary hover:bg-hover\",\n )\n }\n >\n <sub.icon className=\"size-4 shrink-0 opacity-70\" aria-hidden />\n <span className=\"min-w-0 break-words leading-snug\">{sub.label}</span>\n </NavLink>\n </li>\n ))}\n </ul>\n </div>\n </div>\n </div>\n );\n}\n\n// Only ONE sidebar flyout should be on screen at a time. Each open flyout parks its\n// \"close now\" here so the next item to open can dismiss it immediately, instead of\n// leaving the previous panel up for the 140ms travel delay while the cursor moves\n// down the nav list — which showed two panels at once.\nlet activeFlyoutClose: (() => void) | null = null;\n\n/**\n * Wraps a nav item that has sub-items: on hover or keyboard focus it opens a\n * portalled flyout to the right of the sidebar (portalled so the sidebar's\n * `overflow-hidden` can't clip it) with the item's label as a header and each\n * sub-item as an icon + title link. A short close delay lets the cursor travel\n * from the item onto the panel; Escape / outside-move close it.\n */\nfunction SidebarFlyout({ item, children }: { item: AppShellNavItem; children: ReactNode }) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const [open, setOpen] = useState(false);\n // The flyout is portalled out of the subtree whose `dir` it inherited; read on open.\n const [dir, setDir] = useState<Direction>(\"ltr\");\n\n // Anchor the flyout to the item's END edge — its right, or its left in RTL, where\n // the sidebar sits on the right of the window — and keep it on the glass (Wave 2,\n // DUP-7). Right to left it hangs by its `right`, which a fixed box measures from\n // inside the scrollbar: `innerWidth` counted the bar and put the flyout a bar's width\n // off its item. The hook re-measures on scroll/resize (the nav list can scroll); the\n // panel's own width is measured once it is up, before paint.\n const rect = useAnchoredRect(wrapperRef, open);\n const panelRef = useRef<HTMLDivElement>(null);\n const [panelWidth, setPanelWidth] = useState(0);\n const placed = rect !== null;\n useLayoutEffect(() => {\n if (open && placed) setPanelWidth(panelRef.current?.offsetWidth ?? 0);\n }, [open, placed]);\n const at = rect ? anchoredInline(rect, panelWidth, { dir, align: \"after\" }) : null;\n const pos = rect && at ? { top: rect.top, ...(dir === \"rtl\" ? { right: at.right } : { left: at.left }) } : null;\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current);\n closeTimer.current = null;\n }\n }, []);\n // Stable identity: the coordinator above holds this so a sibling item can close\n // THIS flyout without waiting out its travel delay.\n const closeNow = useCallback(() => {\n cancelClose();\n setOpen(false);\n }, [cancelClose]);\n const openMenu = useCallback(() => {\n cancelClose();\n if (activeFlyoutClose && activeFlyoutClose !== closeNow) activeFlyoutClose();\n activeFlyoutClose = closeNow;\n setDir(dirOf(wrapperRef.current));\n setOpen(true);\n }, [cancelClose, closeNow]);\n const scheduleClose = useCallback(() => {\n cancelClose();\n closeTimer.current = setTimeout(() => {\n setOpen(false);\n if (activeFlyoutClose === closeNow) activeFlyoutClose = null;\n }, 140);\n }, [cancelClose, closeNow]);\n\n // Close on Escape while open — a layer on the kit's Escape stack (Wave 2, DUP-1).\n useDismissLayer(open, () => setOpen(false));\n\n useEffect(\n () => () => {\n cancelClose();\n if (activeFlyoutClose === closeNow) activeFlyoutClose = null;\n },\n [cancelClose, closeNow],\n );\n\n return (\n // Not a control: hover and focus-within on the nav link inside. Focus (the\n // keyboard path) opens it exactly as hover does, Escape closes it.\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- hover/focus-within wrapper around a real link\n <div\n ref={wrapperRef}\n className=\"relative\"\n onMouseEnter={openMenu}\n onMouseLeave={scheduleClose}\n onFocus={openMenu}\n onBlur={scheduleClose}\n >\n {children}\n {open &&\n pos &&\n createPortal(\n // Keeps the flyout open while the pointer crosses into it; keyboard users\n // reach it by focus, which the wrapper above already handles.\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- pointer-only hover bridge\n <div\n ref={panelRef}\n dir={dir}\n style={{ position: \"fixed\", ...pos }}\n className=\"z-40 ps-1\"\n onMouseEnter={cancelClose}\n onMouseLeave={scheduleClose}\n >\n <div\n role=\"menu\"\n aria-label={item.label}\n className=\"animate-flyout min-w-52 overflow-hidden rounded-md border border-subtle bg-surface shadow-lg\"\n >\n <div className=\"border-b border-subtle px-3 py-2 text-caption font-semibold uppercase tracking-wide text-muted\">\n {item.label}\n </div>\n <ul className=\"py-1\">\n {item.items!.map((sub) => (\n <li key={sub.to}>\n <NavLink\n to={sub.to}\n end={sub.end ?? true}\n role=\"menuitem\"\n onClick={() => setOpen(false)}\n className={({ isActive }) =>\n cn(\n \"flex items-center gap-2.5 px-3 py-2 text-sm\",\n isActive ? \"bg-active font-medium text-primary\" : \"text-secondary hover:bg-hover\",\n )\n }\n >\n <sub.icon className=\"size-4 shrink-0 text-placeholder\" />\n <span className=\"min-w-0 break-words leading-snug\">{sub.label}</span>\n </NavLink>\n </li>\n ))}\n </ul>\n </div>\n </div>,\n document.body,\n )}\n </div>\n );\n}\n"],"mappings":";AA8iBQ,SAoOU,UApOV,KAoDU,YApDV;AA9iBR;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,oBAAoB;AAC7B,SAAS,MAAM,SAAS,WAAW,SAAS,mBAAmB;AAC/D,SAAS,cAAc,gBAAgB,gBAAgB,qBAAqB;AAE5E,SAAS,UAAU;AACnB,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,aAA6B;AACtC,SAAS,YAAY,mBAAmB;AACxC,SAAS,6BAA6B;AACtC,SAAS,eAAe;AACxB,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,YAAY,mBAAmB;AAExC,SAAS,0BAA0B,cAAc,kBAAsC;AAEvF,SAAS,qCAAqC;AAwIvC,MAAM,2BAA+D;AAAA,EAC1E,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AACV;AAQO,SAAS,cACd,SACA,UACA,UAC6B;AAC7B,QAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,CAAC;AAC9C,MAAI,QAAQ,UAAU,MAAO,QAAO,EAAE,OAAO,CAAC,GAAG,OAAO,GAAG,QAAQ,CAAC,EAAE;AACtE,QAAM,OAAO,KAAK,IAAI,GAAG,QAAQ,CAAC;AAClC,QAAM,OAAO,CAAC,MAAc,WAAW,QAAQ,CAAC,CAAE,KAAK,OAAO;AA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oBACC,MAAK;AAAA,oBACL,cAAY,KAAK;AAAA,oBACjB,WAAU;AAAA,oBAEV;AAAA,0CAAC,SAAI,WAAU,kGACZ,eAAK,OACR;AAAA,sBACA,oBAAC,QAAG,WAAU,QACX,eAAK,MAAO,IAAI,CAAC,QAChB,oBAAC,QACC;AAAA,wBAAC;AAAA;AAAA,0BACC,IAAI,IAAI;AAAA,0BACR,KAAK,IAAI,OAAO;AAAA,0BAChB,MAAK;AAAA,0BACL,SAAS,MAAM,QAAQ,KAAK;AAAA,0BAC5B,WAAW,CAAC,EAAE,SAAS,MACrB;AAAA,4BACE;AAAA,4BACA,WAAW,uCAAuC;AAAA,0BACpD;AAAA,0BAGF;AAAA,gDAAC,IAAI,MAAJ,EAAS,WAAU,oCAAmC;AAAA,4BACvD,oBAAC,UAAK,WAAU,oCAAoC,cAAI,OAAM;AAAA;AAAA;AAAA,sBAChE,KAfO,IAAI,EAgBb,CACD,GACH;AAAA;AAAA;AAAA,gBACF;AAAA;AAAA,YACF;AAAA,YACA,SAAS;AAAA,UACX;AAAA;AAAA;AAAA,IACJ;AAAA;AAEJ;","names":["count"]}
1
+ {"version":3,"sources":["../../src/shell/app-shell.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Link, NavLink, matchPath, useHref, useLocation } from \"react-router\";\nimport { ChevronRight, MoreHorizontal, PanelLeftClose, PanelLeftOpen } from \"lucide-react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { scrollIntoStrip, useStripFade } from \"../lib/strip-fade\";\nimport { dirOf, type Direction } from \"../lib/direction\";\nimport { readStored, writeStored } from \"../lib/safe-storage\";\nimport { registerDeviceSetting } from \"../lib/device-settings\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { pickLinkRenderer } from \"../components/text-link\";\nimport { DialogFrame } from \"../components/dialog-frame\";\nimport { CompactControls } from \"../components/field-parts\";\nimport { mergeRefs } from \"../components/field-parts\";\nimport { useAnchoredRect } from \"../hooks/use-anchored-rect\";\nimport { anchoredInline } from \"../hooks/use-anchored-panel\";\nimport { useDismissLayer } from \"../hooks/use-dismiss\";\nimport { useBreakpoint } from \"../hooks/use-breakpoint\";\nimport { TEXT_SIZES, useTextSize } from \"../theme/text-size\";\nimport type { TextSize } from \"../theme/text-size\";\nimport { DEFAULT_APP_SHELL_LABELS, useKitLabels, useKitLink, type LabelOverride } from \"../i18n/kit-labels\";\nimport type { KitLinkComponent, KitLinkProps } from \"../i18n/kit-labels\";\nimport { DEFAULT_APP_SHELL_MORE_LABELS } from \"./app-shell-labels\";\n\nexport interface AppShellSubItem {\n to: string;\n label: string;\n icon: LucideIcon;\n /** Passed to NavLink's `end` (exact match). Defaults to true. */\n end?: boolean;\n}\n\nexport interface AppShellNavItem {\n to: string;\n label: string;\n /** Optional shorter label for the MOBILE BOTTOM BAR only (the sidebar, its\n * tooltips and any palette built on this list keep `label`).\n *\n * The bar divides the viewport into `nav.length` equal cells, so a label's room\n * shrinks with every entry added — at six entries on a 406 px phone that is ~67 px,\n * and \"Import & Export\" wrapped to two lines and pushed the row taller than its\n * neighbours (keksdose feedback live #210). A per-item override is better than\n * shortening the real label, which the sidebar has ample room for and which is the\n * name the rest of the product uses. */\n shortLabel?: string;\n /** 0.48: the text size from which the bar uses {@link shortLabel} — `\"large\"` keeps the\n * full label at Normal, where five cells hold \"Transactions\" whole, and shortens it\n * from Large up (keksdose dev#613, which read `useTextSize()` in its layout to decide).\n * Default `\"normal\"`: the short label at every size, as before. */\n shortLabelFrom?: TextSize;\n /** 0.49: `shortLabel` is another word for the page, not a shortening of `label` —\n * keksdose's \"Activity\" for \"Transactions\". Without it a development build warns once\n * when `shortLabel` does not start with `label`'s first word (an abbreviation of that\n * word, \"Trans.\" for \"Transactions\", counts), because a bar cell that names a page\n * differently from the sidebar, the title and the palette is a page the reader\n * looks for twice. */\n shortLabelIsAlias?: boolean;\n /** 0.49: which entries sit in the phone bar when they do not all fit\n * ({@link AppShellProps.mobileMaxItems}). Lower first: the entries with a priority take\n * the bar's cells in its order, then the rest in the list's order; the bar still shows\n * its entries in the list's order, and the others go under \"More\". Unset: the list's\n * order decides (as before). */\n mobilePriority?: number;\n /** 0.31.0: leave this entry out of the MOBILE BOTTOM BAR; the sidebar keeps it.\n * For an entry a phone reaches another way — the brand link to the start page —\n * when one cell fewer is what keeps the others' labels whole (the bar divides its\n * width evenly, see `shortLabel`). Its group's sub-row still shows while one of its\n * pages is open. Named like `DataTable`'s column `mobileHidden`. */\n mobileHidden?: boolean;\n icon: LucideIcon;\n /** Passed to NavLink's `end` (exact match). Defaults to true. */\n end?: boolean;\n /** Optional `data-tour` value rendered on this item's link (both the desktop\n * sidebar and the mobile bottom bar), so a guided tour can spotlight ONE nav\n * entry precisely instead of matching by href (feedback #338). */\n dataTour?: string;\n /** Optional sub-items. When present, hovering (or focusing) the item opens a\n * flyout to the right of the sidebar with a header (this item's label) and the\n * sub-items as icon + title links. Works collapsed or expanded. On the phone (0.49)\n * the bar's cell opens a sheet of them instead of linking to `to` — the sheet lists\n * `to` first as \"Overview\" when no sub-item is that page — and the pages of the group\n * the reader is in show as the row above the bar (`mobileSubNav`). */\n items?: AppShellSubItem[];\n}\n\n/**\n * One entry of the sidebar's bottom area ({@link AppShellProps.sidebarFooterItems}) —\n * the version link and the legal links kastlan hand-built in `sidebarFooter`.\n *\n * - `link` (default): one link. Expanded it shows `icon` + `text` (default `label`),\n * with `hint` as a tooltip if given; collapsed it is the icon alone, named and\n * tooltipped by `label`.\n * - `links`: a small group — the legal links. Expanded, a `<nav>` named `label` holding\n * the links as a wrapping row of small text; collapsed, ONE icon link to `to` (default\n * the first link's), named and tooltipped by `label`, since a column of icons for\n * \"Imprint\", \"Privacy\" and \"Terms\" would say nothing an icon can.\n */\nexport type AppShellSidebarFooterItem =\n | {\n kind?: \"link\";\n key: string;\n to: string;\n icon: LucideIcon;\n /** The link's name, and the tooltip when collapsed (\"What's new · v1.4.0\"). */\n label: string;\n /** Visible text when expanded (\"Kastlan v1.4.0\"). Default `label`. */\n text?: ReactNode;\n /** A tooltip on the expanded link (\"What's new\"). */\n hint?: string;\n /** Leaves the app: a plain `<a target=\"_blank\" rel=\"noopener noreferrer\">`. */\n external?: boolean;\n /**\n * 0.42.0 (docs/admin-harmonization.md §6.9): a count of what waits behind the link —\n * kastlan's \"Administration\" with its To-triage count. A pill at the end of the\n * expanded link, a corner dot on the collapsed icon; `0`, `null` or none shows\n * nothing, and above 99 it reads \"99+\". The count joins the link's name, in\n * `badgeLabel`'s words when given (\"Administration, 3 waiting\").\n */\n badge?: number | null;\n /** The badge's words for a reader — `adminArea.waiting(count)`. Default: the number. */\n badgeLabel?: string;\n }\n | {\n kind: \"links\";\n key: string;\n icon: LucideIcon;\n /** The group's name — its `<nav>` label, and the collapsed icon's name (\"Legal\"). */\n label: string;\n /** The collapsed icon's target. Default the first link's `to`. */\n to?: string;\n links: { to: string; label: string; external?: boolean }[];\n };\n\n/**\n * The words of the phone bar's \"More\" cell and its sheet (0.32,\n * docs/text-size-harmonization.md §4 Navigation, §10.7) — the `appShellMore` namespace of\n * `<UiKitProvider labels>`, overridable per shell through `moreLabels`.\n */\nexport interface AppShellMoreLabels {\n /** The cell's visible label, under its icon — one short word. */\n more: string;\n /** The sheet's heading, and so its accessible name. */\n moreTitle: string;\n /** 0.49: a parent entry's own page in the sheet its bar cell opens, above its pages,\n * when no page is that one — \"Overview\". */\n overview: string;\n}\n\n// Defined in ./app-shell-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_APP_SHELL_MORE_LABELS };\n\n/**\n * The most cells the phone bar holds, \"More\" included, per text size (0.49 KIT-6; 0.32\n * §10.7): five at Normal and Large, four at Extra large. Eight entries are four and\n * \"More\" at Normal; a fifth of a 390 px phone holds one word of the bar's type, and a\n * sixth no longer does once the type grows. A fifth of a 360 px phone at 150 % is 48 px\n * of Normal-sized room.\n */\nexport const DEFAULT_MOBILE_MAX_ITEMS: Readonly<Record<TextSize, number>> = {\n normal: 5,\n large: 5,\n xlarge: 4,\n};\n\n/**\n * The phone bar's cells (0.49 KIT-6): every entry when there are at most `maxItems`,\n * else `maxItems − 1` entries and a \"More\" cell for the rest. Which entries stay is\n * `priority`'s call — lower first, entries without one after them in the list's order —\n * and both halves keep the list's order. Never fewer than one entry beside More.\n */\nexport function pickMobileBar<T>(\n entries: readonly T[],\n maxItems: number,\n priority?: (entry: T) => number | undefined,\n): { shown: T[]; hidden: T[] } {\n const cells = Math.max(1, Math.floor(maxItems));\n if (entries.length <= cells) return { shown: [...entries], hidden: [] };\n const keep = Math.max(1, cells - 1);\n const rank = (i: number) => priority?.(entries[i]!) ?? Number.POSITIVE_INFINITY;\n const chosen = new Set(\n entries\n .map((_, i) => i)\n .sort((a, b) => rank(a) - rank(b) || a - b)\n .slice(0, keep),\n );\n return {\n shown: entries.filter((_, i) => chosen.has(i)),\n hidden: entries.filter((_, i) => !chosen.has(i)),\n };\n}\n\n/** The bar's cell count at `size`: `mobileMaxItems`, else the default. */\nfunction mobileCells(maxItems: AppShellProps[\"mobileMaxItems\"], size: TextSize): number {\n if (maxItems === undefined) return DEFAULT_MOBILE_MAX_ITEMS[size];\n return typeof maxItems === \"number\" ? maxItems : (maxItems[size] ?? DEFAULT_MOBILE_MAX_ITEMS[size]);\n}\n\n/** The kit's dev switch, as `lib/logger.ts` reads it: a development build, never a\n * production one, never under vitest. Read per call so a test can switch it on. */\nfunction devWarnings(): boolean {\n return Boolean(import.meta.env?.DEV) && !import.meta.env?.VITEST;\n}\n\nconst warnedNav = new Set<string>();\n\nfunction warnNavOnce(key: string, message: string): void {\n if (warnedNav.has(key)) return;\n warnedNav.add(key);\n console.warn(message);\n}\n\n/** The first word of a label, lower-cased: letters and digits up to the first other\n * character (\"Import & Export\" → \"import\", \"Trans.\" → \"trans\"). */\nfunction firstWord(text: string): string {\n return (text.trim().match(/^[\\p{L}\\p{N}]+/u)?.[0] ?? \"\").toLocaleLowerCase();\n}\n\n/** Whether `short` names `label`: its first word is `label`'s first word or an\n * abbreviation of it (\"Trans.\" for \"Transactions\"), or the other way round. */\nfunction shortLabelNamesLabel(short: string, label: string): boolean {\n const s = firstWord(short);\n const l = firstWord(label);\n return s === \"\" || l === \"\" || l.startsWith(s) || s.startsWith(l);\n}\n\nconst TEXT_SIZE_WORDS: Record<TextSize, string> = { normal: \"Normal\", large: \"Large\", xlarge: \"Extra large\" };\n\n/** A development build's notes on `nav` (0.49 KIT-6): a `shortLabel` that is another word\n * than its `label` without `shortLabelIsAlias`. */\nfunction useNavDevWarnings(nav: AppShellNavItem[]): void {\n useEffect(() => {\n if (!devWarnings()) return;\n for (const item of nav) {\n if (item.shortLabel === undefined || item.shortLabelIsAlias) continue;\n if (shortLabelNamesLabel(item.shortLabel, item.label)) continue;\n const from = item.shortLabelFrom ?? \"normal\";\n const where = from === \"normal\" ? \"at every text size\" : `from ${TEXT_SIZE_WORDS[from]} text up`;\n warnNavOnce(\n `shortLabel|${item.to}|${item.shortLabel}|${item.label}`,\n `[ui-kit] AppShell nav \"${item.to}\": shortLabel \"${item.shortLabel}\" does not start with ` +\n `\"${item.label.trim().split(/\\s+/)[0]}\", the first word of its label \"${item.label}\". The phone bar ` +\n `shows it ${where}, so the page has another name there than in the sidebar and its title. ` +\n \"Shorten the label instead, or pass shortLabelIsAlias: true if the other word is meant.\",\n );\n }\n }, [nav]);\n}\n\n/**\n * Exported and `<div>`-shaped. This is the outermost element of every consuming app, so\n * there is nothing above it to hang an id, a landmark label or a `data-tour` anchor on —\n * and nothing a consumer can wrap it in either, since the root owns the `h-dvh` and\n * `overflow-hidden` the whole layout is built on (audit §api-design).\n */\nexport interface AppShellProps extends ComponentPropsWithoutRef<\"div\"> {\n /** Navigation entries — shared by the desktop sidebar and mobile bottom bar. */\n nav: AppShellNavItem[];\n /** The composed top bar (e.g. the shared TopBar with app-owned actions). */\n topBar: ReactNode;\n /** Main content — typically the router `<Outlet />`. */\n children: ReactNode;\n /** Desktop-only footer rendered below the content (hidden on mobile). */\n footer?: ReactNode;\n /** Extra sidebar content above the collapse toggle (e.g. a version link).\n * Receives the collapsed state so it can render compact vs. full. */\n sidebarFooter?: (collapsed: boolean) => ReactNode;\n /** The sidebar's bottom area as data — a version link, the legal links — drawn full\n * when expanded and as icon + tooltip when collapsed. Rendered above\n * `sidebarFooter`, which stays for anything the data cannot describe. */\n sidebarFooterItems?: AppShellSidebarFooterItem[];\n /** The router link for `sidebarFooterItems`. Default: the provider's\n * `linkComponent`, else react-router's `Link`. */\n renderLink?: KitLinkComponent;\n /** localStorage key for the persisted collapse state. */\n collapseStorageKey?: string;\n /** Default: `appShell.collapse` from the {@link UiKitProvider}, else English. */\n collapseLabel?: string;\n /** Default: `appShell.expand` from the {@link UiKitProvider}, else English. */\n expandLabel?: string;\n /** How an entry's `items` are revealed in the EXPANDED desktop sidebar.\n *\n * - `\"flyout\"` (default) — a panel beside the sidebar on hover/focus. Compact: the\n * sidebar stays one row per group however many pages a group holds.\n * - `\"inline\"` — a disclosure under the entry, the pattern of MUI's nested List and\n * most documentation sites. Every page is visible at once, and the group holding\n * the current page opens on its own, so the reader can see where they are without\n * hovering anything.\n *\n * The icon-only (collapsed) sidebar always uses the flyout: an indented list has no\n * room there. The mobile bottom bar ignores `items` in both modes. */\n subNav?: \"flyout\" | \"inline\";\n /** Accessible name of the inline disclosure button, given the group's label.\n * Only used with `subNav=\"inline\"`. Its expanded state is carried by\n * `aria-expanded`, so one wording serves both directions. Default:\n * `appShell.toggleGroup` from the {@link UiKitProvider}, else English. */\n toggleGroupLabel?: (groupLabel: string) => string;\n /** Below `md`: show the current group's `items` as a scrollable row above the\n * bottom bar — the phone's counterpart of the sidebar's second level. Default true;\n * `false` keeps the single bar, where a group entry only links to its own `to`. */\n mobileSubNav?: boolean;\n /**\n * How the phone sub-nav lays out a group with more pages than fit on one row.\n * `\"wrap\"`: every page in view, on as many rows as it takes — the bar grows.\n * `\"scroll\"`: one row that scrolls sideways, faded at a cut edge, with the current\n * page scrolled into view. A long group took four rows (~130px) of a 390px screen\n * above the bottom bar (showcase audit); scrolling gives that back at the price of\n * pages hidden past the edge, so it is the app's call, per shell.\n *\n * Unset (0.32.2, kastlan's 0.32.1 report): `\"wrap\"` at Normal and `\"scroll\"` at Large\n * and Extra large, where a wrapped group of eight pages took six or seven rows and\n * covered the page — the other half of what `mobileMaxItems` does for the bar.\n */\n mobileSubNavLayout?: \"wrap\" | \"scroll\";\n /**\n * The most cells the phone bar holds, \"More\" included (0.49 KIT-6). When `nav` (after\n * `mobileHidden`) has more entries, the bar keeps `mobileMaxItems − 1` of them and a\n * last \"More\" cell opens a sheet with the rest, each group with its pages. Which\n * entries stay is the items' `mobilePriority`, else the list's order (so the app puts\n * its most used entries first, or orders by role: kastlan's manager and accountant see\n * different firsts).\n *\n * Default {@link DEFAULT_MOBILE_MAX_ITEMS}: 5 at Normal and Large, 4 at Extra large —\n * eight entries are four and \"More\". A number replaces the default at every size;\n * `{ xlarge: 5 }` replaces it at one size only. Never fewer than one entry beside More.\n */\n mobileMaxItems?: number | Partial<Record<TextSize, number>>;\n /** The More cell's words over the provider's `appShellMore`. */\n moreLabels?: Partial<AppShellMoreLabels>;\n /**\n * Lay the shell out inside its PARENT'S box instead of the viewport: `h-full` rather\n * than `h-dvh`, its own scroll container at every width, a bottom bar pinned to the\n * shell rather than the window, `--app-nav-h` published on the shell alone, and no\n * persisted collapse state unless `collapseStorageKey` is passed. For an app preview,\n * a device frame, a docs example.\n *\n * Implied for a shell rendered inside another AppShell, which is the case this\n * exists for: the inner one used to publish its own nav height on `<html>`, fight\n * the outer one over it, and remove it on unmount from under the outer app.\n */\n embedded?: boolean;\n /** The shell's root, where the rest of the props go (0.34, API-2, refactor audit\n * 2026-10) — merged with its own ref, which `--app-nav-h` is published on. */\n ref?: Ref<HTMLDivElement>;\n}\n\n/** True below an AppShell — how a nested shell knows it is one. */\nconst AppShellNesting = createContext(false);\n\n/**\n * The bottom nav's own height, published as `--app-nav-h` so anything that has to sit\n * ON it can stop guessing.\n *\n * Keksdose live #314 is what this is for. Its rework — *\"Stick it to the bottom\n * touching the bottom icon bar with budget, accounts, … Currently there is a small gap\n * which confuses\"* — was a receipt footer pinned at `bottom-20`, because `<main>`\n * reserves `pb-20` for this nav and 20 looked like the nav's height. It is not: the\n * padding is generous CLEARANCE, and the nav is content-sized (icon + label + `py-2`,\n * about 56px), so the footer floated ~24px above the bar.\n *\n * Measured rather than named, because the height is not a constant anyone owns: it is\n * an icon, a translated label that can wrap or truncate, and whatever the platform does\n * with the safe-area inset. A hard-coded `bottom-14` would be the same guess one number\n * lower, and it would be wrong again the first time a label needed two lines.\n *\n * `0px` when the nav is not rendered — above `md` it is `display:none`, which observes\n * as a zero box — so a consumer can write `bottom-[var(--app-nav-h,0px)]` once and get\n * the right answer at both widths without a breakpoint of its own.\n */\nfunction useNavHeightVar(\n ref: React.RefObject<HTMLElement | null>,\n shellRef: React.RefObject<HTMLElement | null>,\n embedded: boolean,\n): void {\n // Re-run when the breakpoint flips. A ResizeObserver SKIPS an element that is not\n // being rendered, so the nav going `display:none` above `md` fires no callback and\n // would leave the last phone height published — a desktop footer would then sit 56px\n // off the bottom after a live resize. `useBreakpoint(\"md\")` is the nav's own `md:hidden`\n // at the text size in force (0.32), so the two cannot disagree about where the\n // boundary is — at Extra large both move to 72rem.\n const isMdUp = useBreakpoint(\"md\", false);\n useEffect(() => {\n const node = ref.current;\n const shell = shellRef.current;\n // Always on the shell's own root, so everything inside it — a nested shell's\n // content included — reads the nearest bar's height. On <html> as well only for\n // the OUTERMOST shell, for what it portals to <body> (a sheet docking on the bar).\n // The DOM check backs up the context for a shell mounted in a separate React root.\n const global = !embedded && !shell?.parentElement?.closest(\"[data-app-shell]\");\n const targets = [shell, global ? document.documentElement : null].filter((el): el is HTMLElement => el !== null);\n // `getBoundingClientRect().height`, rounded DOWN — not `offsetHeight`, and not\n // ceil. Measured on the running app at 406x816: the bar is **55.5px** tall, and\n // both `offsetHeight` and `Math.ceil` answer 56. That is why live #314 round four\n // was *\"No change. Still a pixel inbetween\"* — the previous fix was arithmetically\n // a no-op on the very value it was meant to correct.\n //\n // 56 is the wrong side. A sticky element with `bottom: X` puts its bottom edge X\n // above the viewport bottom, and the bar's TOP edge is at its own height: so\n // X = 56 lands the footer at y=760.0 against a bar starting at y=760.5, i.e. half\n // a CSS pixel of page showing through — about 1.4 device pixels on his phone,\n // which is exactly the hairline in the screenshot.\n //\n // The two errors are not symmetric, and I had them backwards the first time.\n // Too SMALL tucks the sticky element under a bar that is opaque and painted above\n // it (`z-30` against `z-10`): invisible. Too LARGE opens the seam. So floor, and\n // consumers subtract a further pixel (see `invoice-line-totals.tsx`) for the case\n // where the height lands on a whole pixel and floor leaves no overlap at all.\n const publish = () => {\n const value = `${node ? Math.floor(node.getBoundingClientRect().height) : 0}px`;\n for (const el of targets) el.style.setProperty(\"--app-nav-h\", value);\n };\n publish();\n // The observer is the refinement, not the mechanism: `publish()` above is already\n // right for a static nav, and jsdom has no ResizeObserver unless a test stubs one.\n // ONE cleanup for every branch, though — an early `return` on the no-observer path\n // left the variable behind on unmount, which a stale `bottom:` offset on whatever\n // rendered next would have inherited.\n const ro = node && typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(publish) : null;\n if (ro && node) ro.observe(node);\n return () => {\n ro?.disconnect();\n for (const el of targets) el.style.removeProperty(\"--app-nav-h\");\n };\n }, [ref, shellRef, embedded, isMdUp]);\n}\n\n/**\n * The responsive application shell: a top bar, a collapsible desktop sidebar\n * (icon-only when collapsed, with tooltips), a mobile bottom nav bar, the main\n * content area, and an optional desktop footer. Router-aware via react-router\n * `NavLink`; domain-free — nav items, brand, footer and the top bar's actions\n * are all supplied by the app.\n */\nexport function AppShell({\n nav,\n topBar,\n children,\n footer,\n sidebarFooter,\n sidebarFooterItems,\n renderLink,\n collapseStorageKey: collapseStorageKeyProp,\n collapseLabel,\n expandLabel,\n subNav = \"flyout\",\n mobileSubNav = true,\n mobileSubNavLayout: mobileSubNavLayoutProp,\n mobileMaxItems,\n moreLabels,\n toggleGroupLabel,\n embedded: embeddedProp,\n className,\n ref,\n ...rest\n}: AppShellProps) {\n const embedded = useContext(AppShellNesting) || !!embeddedProp;\n const { size: textSize } = useTextSize();\n const large = textSize !== \"normal\";\n const mobileSubNavLayout = mobileSubNavLayoutProp ?? (large ? \"scroll\" : \"wrap\");\n // The bottom bar's cells: every entry the phone does not reach another way, up to the\n // text size's limit, More included; the rest go under More (§10.7, KIT-6).\n const maxItems = mobileCells(mobileMaxItems, textSize);\n const { shown: barNav, hidden: moreNav } = pickMobileBar(\n nav.filter((item) => !item.mobileHidden),\n maxItems,\n (item) => item.mobilePriority,\n );\n useNavDevWarnings(nav);\n // An embedded shell sharing the default key would overwrite the outer app's sidebar\n // preference with its own — so it persists only when given a key of its own.\n const collapseStorageKey = collapseStorageKeyProp ?? (embedded ? null : \"appLayout.sidebarCollapsed\");\n // The three props are per-shell overrides of the provider's `appShell`; one left\n // undefined falls through to the provider rather than to English.\n const labels = useKitLabels(\"appShell\", DEFAULT_APP_SHELL_LABELS, {\n collapse: collapseLabel,\n expand: expandLabel,\n toggleGroup: toggleGroupLabel,\n });\n // Through the guarded helpers, not `window.localStorage` directly. The read runs\n // inside a `useState` initialiser — i.e. during render of the top-level shell — and\n // `localStorage` THROWS where site data is blocked (Safari private browsing, a\n // partitioned webview). Unguarded, that was not a lost sidebar preference: nothing\n // in the application mounted at all.\n const [collapsed, setCollapsed] = useState(\n () => collapseStorageKey !== null && readStored(collapseStorageKey) === \"1\",\n );\n // The inline sidebar is an ACCORDION: one group open at a time, keyed by its `to`.\n // Held here rather than per group so opening one can close the other — two lists\n // open at once pushed every entry below them off a laptop screen.\n const [openGroup, setOpenGroup] = useState<string | null>(null);\n // Publishes `--app-nav-h` for anything that has to sit on the bottom bar.\n const navRef = useRef<HTMLDivElement>(null);\n const rootRef = useRef<HTMLDivElement>(null);\n const setRoot = useMemo(() => mergeRefs(rootRef, ref), [ref]);\n useNavHeightVar(navRef, rootRef, embedded);\n useEffect(() => {\n if (collapseStorageKey !== null) writeStored(collapseStorageKey, collapsed ? \"1\" : \"0\");\n }, [collapsed, collapseStorageKey]);\n // Reset this device's settings (docs/settings-harmonization.md §11.4): the sidebar\n // unfolds, live, and the effect above writes \"0\". An embedded shell without a key of\n // its own stores nothing and joins nothing.\n useEffect(() => {\n if (collapseStorageKey === null) return;\n return registerDeviceSetting({ key: collapseStorageKey, kind: \"view\", reset: () => setCollapsed(false) });\n }, [collapseStorageKey]);\n // §4: at Large and Extra large the sidebar never collapses to icons only — a glyph\n // with its name in a tooltip is the very thing a reader who asked for bigger type\n // cannot use. The persisted preference is left alone, so Normal gets it back, and the\n // toggle goes while it could not do anything.\n const iconOnly = collapsed && !large;\n\n return (\n // The caller's attributes go on the shell's own root, never on the `data-tour=\"nav\"`\n // wrappers below — those are the kit's anchors for its own guided tour (#313/#322),\n // and a second element answering to the same selector is a tour that highlights the\n // wrong thing or nothing at all.\n <AppShellNesting.Provider value={true}>\n <div\n {...rest}\n ref={setRoot}\n data-app-shell=\"\"\n className={cn(\n \"relative flex flex-col\",\n embedded\n ? // `contain: layout` makes this box the containing block for the `fixed`\n // bottom bar below, so it pins to the shell rather than to the window.\n \"h-full min-h-0 overflow-hidden [contain:layout]\"\n : \"min-h-screen md:h-dvh md:overflow-hidden\",\n className,\n )}\n >\n {/* §4: \"the top bar keeps its essential icons\" — its IconButtons stay icons at\n Large (their labels the names and tooltips) and a locked one keeps its reason\n in the tooltip: a bar 3rem tall has no room for words under every glyph. */}\n <CompactControls>{topBar}</CompactControls>\n <div className=\"flex flex-1 min-h-0\">\n <aside\n className={cn(\n // `border-e`: the sidebar sits at the START, which is the right in RTL.\n \"hidden md:flex md:flex-col border-e border-subtle bg-surface transition-[width] duration-200 ease-out overflow-hidden\",\n // Embedded, the row it sits in is already the shell's height; the sticky\n // offsets below are measured against the window's top bar.\n embedded ? \"md:self-stretch\" : \"md:sticky md:top-12 md:self-start md:h-[calc(100vh-3rem)]\",\n iconOnly ? \"md:w-14\" : \"md:w-60\",\n )}\n >\n {/* The `<nav>` is flex-1 so it fills the sidebar's height (with empty\n space below the items); the data-tour marker goes on the INNER,\n fit-content wrapper so the guided-tour spotlight hugs the actual nav\n items instead of the whole tall column (feedback #322). The marker\n also tags the mobile bottom bar below; the tour targets\n `[data-tour=\"nav\"]` and resolves to whichever is visible (#313). */}\n <nav className=\"flex-1 px-2 py-3 overflow-y-auto overflow-x-hidden\">\n <div data-tour=\"nav\" className=\"space-y-1\">\n {nav.map((item) => (\n <SidebarNavItem\n key={item.to}\n item={item}\n collapsed={iconOnly}\n inline={subNav === \"inline\"}\n toggleGroupLabel={labels.toggleGroup}\n openGroup={openGroup}\n setOpenGroup={setOpenGroup}\n />\n ))}\n </div>\n </nav>\n {!!sidebarFooterItems?.length && (\n <SidebarFooterItems items={sidebarFooterItems} collapsed={iconOnly} renderLink={renderLink} />\n )}\n {sidebarFooter?.(iconOnly)}\n {/* No toggle at Large: the sidebar cannot collapse there (see `iconOnly`). */}\n {!large && (\n <div className=\"border-t border-subtle p-2\">\n {collapsed ? (\n <Tooltip label={labels.expand} side=\"end\" portal className=\"block\">\n <button\n type=\"button\"\n onClick={() => setCollapsed(false)}\n aria-label={labels.expand}\n className=\"flex w-full items-center justify-center min-h-9 rounded-md text-muted hover:bg-hover hover:text-secondary\"\n >\n <PanelLeftOpen className=\"size-4 shrink-0 rtl:-scale-x-100\" />\n </button>\n </Tooltip>\n ) : (\n <button\n type=\"button\"\n onClick={() => setCollapsed(true)}\n aria-label={labels.collapse}\n className=\"flex w-full items-center gap-3 min-h-9 px-3 py-2 rounded-md text-sm text-muted hover:bg-hover hover:text-secondary\"\n >\n <PanelLeftClose className=\"size-4 shrink-0 rtl:-scale-x-100\" />\n {/* Never drawn at Large (the toggle is not), so the class matters at\n Normal only — the kit's one name for it all the same (round 0.34 T1). */}\n <span className=\"truncate-until-large\">{labels.collapse}</span>\n </button>\n )}\n </div>\n )}\n </aside>\n\n {/* Content column beside the sidebar. main grows to fill so the footer\n sits at the bottom — at the viewport edge when content is short,\n beside the sidebar rather than under it. */}\n <div className=\"flex flex-1 flex-col min-w-0 md:min-h-0\">\n {/* `scrollbar-gutter: stable` reserves the scrollbar's track whether or\n not it is currently needed. Without it this element — the app's only\n scroll container from md up — narrows its own client box by the\n scrollbar width the moment a page's content outgrows it, and widens\n it again when the next page fits. Every centred `mx-auto` container\n inside then jumps sideways by half a scrollbar, and any fluid-width\n content changes width outright. Keksdose feedback #403 caught it as\n \"slight width increase/decrease\" when switching to the notifications\n settings section and back: that section is the only one tall enough\n to scroll. Platform-dependent, which is why it is easy to miss —\n overlay scrollbars (macOS, most Linux builds) take no layout space,\n classic ones (Windows) take ~15px.\n\n `both-edges`, not the bare `stable`: a one-sided reservation keeps the\n width stable but moves the middle. On a page short enough not to\n scroll, nothing is painted into the reserved track, so every centred\n `mx-auto` container sits half a scrollbar left of the optical centre\n and every full-bleed child stops ~15px short on the right. Keksdose\n feedback #491 (/settings#data) and #498 (/budgets) both reported it as\n \"the left boundary looks smaller / cut off compared to the right\" on\n the one element per page whose frame is a saturated colour — the rose\n destructive-action cards. Reserving the track on both edges keeps the\n content centred whether or not the scrollbar is showing. */}\n {/* `relative` makes <main> the containing block for everything absolutely\n positioned inside it. Tailwind's `sr-only` is `position:absolute`; with no\n positioned ancestor it resolves against the INITIAL containing block, is\n laid out at its offset from the top of the DOCUMENT, and grows\n `<html>`'s scroll height past the viewport — a second scrollbar beside this\n one that scrolls into empty space. Guarding it per component (see\n sr-only-containment.test) could never be complete: any page's own\n `sr-only` span re-opened it. Here it is closed for every child at once. */}\n {/* Below `md` the bottom room is the nav plus the larger of 1.5rem and what the\n floating launchers take above it (`--app-float-clearance`, published by\n every kit FAB, FloatingPanel and FloatingActionGroup while mounted — keksdose\n dev#612: the last row ended under the help launcher). From `md` up, where\n there is no nav, the launchers' room alone (0.49 KIT-11): the last row\n scrolls clear of a corner button there too. */}\n <main\n className={cn(\n \"relative flex-1 max-w-full overflow-x-clip pb-[calc(var(--app-nav-h,4rem)+max(1.5rem,var(--app-float-clearance,0px)))] md:pb-[var(--app-float-clearance,0px)] md:min-h-0 md:overflow-y-auto md:[scrollbar-gutter:stable_both-edges]\",\n // The list page's fill (0.40, docs/page-layout-harmonization.md §1.3): while\n // a `fillHeight` DataTable is inside, a flex column — a banner above the\n // page keeps its own height and the page (a `FillHeight`) takes the rest,\n // so `<main>` no longer overflows by the banner. Its children do not shrink\n // (a banner of a fixed height or `overflow-hidden` would): the page grows\n // into the rest from a zero basis, and a window too short for the page's\n // floor scrolls `<main>`. Every other page lays out as before. Below `md`\n // the document scrolls and nothing fills.\n // The children's `shrink-0` carries no `:has`: `flex-shrink` does nothing\n // outside a flex container, and a `:has(…) > *` rule cost a style recalc of\n // the whole page on every DOM insertion under it (17–45 ms per scrolled step\n // of a `virtualize` table, 0.48.2). `[&&>*]` doubles the class, so it stays\n // as specific as FillHeight's `has-[…]:flex-1` (whose `flex: 1` would set\n // shrink 1) and, emitted after it, still wins.\n \"md:has-[[data-fill-height]]:flex md:has-[[data-fill-height]]:flex-col md:[&&>*]:shrink-0\",\n // Embedded there is no document scroll to lean on below `md` either.\n embedded && \"min-h-0 overflow-y-auto\",\n )}\n >\n {children}\n </main>\n {footer}\n </div>\n </div>\n\n {/* The phone navigation: the group bar, and above it — when the current page\n belongs to a group with pages of its own — the row of those pages. The pair\n is the phone's version of the sidebar's two levels; without the upper row a\n group's `items` were simply unreachable below `md`. ONE measured box, so\n `--app-nav-h` covers both rows and whatever docks on the bar sits on the\n whole of it. */}\n <div ref={navRef} className=\"md:hidden fixed bottom-0 inset-x-0 z-30 border-t border-subtle bg-surface\">\n {mobileSubNav && <MobileSubNav nav={nav} layout={mobileSubNavLayout} />}\n <nav\n data-tour=\"nav\"\n className=\"grid\"\n style={{ gridTemplateColumns: `repeat(${barNav.length + (moreNav.length ? 1 : 0)}, minmax(0, 1fr))` }}\n >\n {barNav.map((item) =>\n item.items?.length ? (\n <MobileGroupCell key={item.to} item={item} labels={moreLabels} />\n ) : (\n <MobileNavItem key={item.to} item={item} />\n ),\n )}\n {moreNav.length > 0 && <MobileMoreCell hidden={moreNav} labels={moreLabels} />}\n </nav>\n </div>\n </div>\n </AppShellNesting.Provider>\n );\n}\n\nconst routerLink: KitLinkComponent = ({ href, ...p }) => <Link to={href} {...p} />;\nconst plainLink: KitLinkComponent = ({ children, ...p }) => <a {...p}>{children}</a>;\n\nconst FOOTER_ICON_LINK =\n \"flex min-h-8 items-center justify-center rounded-md text-muted hover:bg-hover hover:text-secondary\";\n\n/** A footer link's count as drawn: nothing for none, \"99+\" past 99. */\nfunction footerBadgeText(badge: number | null | undefined): string | null {\n if (typeof badge !== \"number\" || !(badge > 0)) return null;\n return badge > 99 ? \"99+\" : String(Math.floor(badge));\n}\n\n/** The count's pill — the solid \"count\" look of `Chip` (warning, the pending count's\n * tone, as `FloatingActionGroup`'s badge), sized for the footer's small text. */\nconst FOOTER_BADGE =\n \"inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-warning px-1 text-micro font-semibold leading-4 tabular-nums text-warning-contrast\";\n\n/** Calls the link renderer as a component, so a router link's hooks are its own. */\nfunction RenderedLink({ render, ...props }: KitLinkProps & { render: KitLinkComponent }) {\n return render(props);\n}\n\n/** The sidebar's bottom area, from {@link AppShellSidebarFooterItem}s. */\nfunction SidebarFooterItems({\n items,\n collapsed,\n renderLink,\n}: {\n items: AppShellSidebarFooterItem[];\n collapsed: boolean;\n renderLink?: KitLinkComponent;\n}) {\n const kitLink = useKitLink();\n const linkTo = (to: string, external: boolean | undefined, { children, ...props }: Omit<KitLinkProps, \"href\">) => {\n // The kit's one link rule (`pickLinkRenderer`): an external `to` or an in-page\n // `#anchor` is a plain `<a>` even without `external`; only `external` opens a tab.\n const InApp = pickLinkRenderer(renderLink, kitLink ?? routerLink, to) ?? plainLink;\n return external ? (\n <a href={to} target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ) : (\n <RenderedLink render={InApp} href={to} {...props}>\n {children}\n </RenderedLink>\n );\n };\n\n return (\n <div data-slot=\"sidebar-footer-items\" className={cn(\"px-2 py-1\", collapsed ? \"space-y-1\" : \"space-y-1.5\")}>\n {items.map((item) => {\n if (collapsed) {\n const to = item.kind === \"links\" ? (item.to ?? item.links[0]?.to) : item.to;\n if (!to) return null;\n const external = item.kind === \"links\" ? item.links.find((l) => l.to === to)?.external : item.external;\n const count = item.kind === \"links\" ? null : footerBadgeText(item.badge);\n const spoken = count === null || item.kind === \"links\" ? null : (item.badgeLabel ?? count);\n return (\n <Tooltip key={item.key} label={item.label} side=\"end\" portal className=\"block\">\n {linkTo(to, external, {\n \"aria-label\": spoken === null ? item.label : `${item.label}, ${spoken}`,\n className: cn(FOOTER_ICON_LINK, count !== null && \"relative\"),\n children: (\n <>\n <item.icon className=\"size-4\" aria-hidden />\n {count !== null && (\n <span aria-hidden data-badge=\"\" className={cn(FOOTER_BADGE, \"absolute -top-0.5 end-0.5\")}>\n {count}\n </span>\n )}\n </>\n ),\n })}\n </Tooltip>\n );\n }\n if (item.kind === \"links\") {\n return (\n <nav\n key={item.key}\n aria-label={item.label}\n className=\"flex flex-wrap justify-center gap-x-3 gap-y-0.5 text-caption text-muted\"\n >\n {item.links.map((l) => (\n <span key={l.to}>\n {linkTo(l.to, l.external, {\n className: \"rounded-sm hover:text-secondary hover:underline\",\n children: l.label,\n })}\n </span>\n ))}\n </nav>\n );\n }\n const count = footerBadgeText(item.badge);\n const link = linkTo(item.to, item.external, {\n className: cn(FOOTER_ICON_LINK, \"gap-1.5 text-xs font-medium\"),\n children: (\n <>\n <item.icon className=\"size-3.5 shrink-0\" aria-hidden />\n {/* Wraps from Large up (text size §10.17, round 0.34 T1): the link is\n `min-h-8`, so it grows a line rather than cut \"Feedb…\". */}\n <span className=\"min-w-0 truncate-until-large\">{item.text ?? item.label}</span>\n {count !== null && (\n <>\n <span aria-hidden data-badge=\"\" className={FOOTER_BADGE}>\n {count}\n </span>\n <span className=\"sr-only\">, {item.badgeLabel ?? count}</span>\n </>\n )}\n </>\n ),\n });\n return item.hint ? (\n <Tooltip key={item.key} label={item.hint} side=\"top\" portal className=\"block\">\n {link}\n </Tooltip>\n ) : (\n <div key={item.key}>{link}</div>\n );\n })}\n </div>\n );\n}\n\n/**\n * A bar cell's look, shared by the entries and the More cell. The active page needs a\n * clear marker, not just a subtle text shade (feedback #327): brand-accent icon + label,\n * bolder weight, and a top accent bar spanning the cell so it reads at a glance.\n */\nconst mobileCellClass = (active: boolean) =>\n cn(\n // `h-full`: the grid row stretches every cell to the tallest one's height, so a\n // label on two lines never leaves its neighbours a different shape.\n \"relative flex h-full w-full flex-col items-center justify-start py-2 text-caption gap-0.5 transition-colors\",\n \"before:absolute before:content-[''] before:inset-x-4 before:top-0 before:h-0.5 before:rounded-full before:transition-colors\",\n active ? \"font-semibold text-brand before:bg-brand\" : \"text-muted before:bg-transparent\",\n );\n\n/**\n * A bar cell's label (0.32, §10.7): up to TWO lines, never an ellipsis on one. At Large\n * a cell is a fifth of a phone holding type a quarter bigger, and one line truncated\n * \"Transactions\" to \"Trans…\" in every app (Kurvenschmiede). Two lines and then a clamp,\n * centred, a long word broken (and hyphenated where the page's `lang` allows) rather\n * than overflowing into the next cell. `shortLabel` still wins where the app has one.\n *\n * `data-truncate-ok` (text size §10.17, round 0.34 T1): the clamp is that decision, not\n * an accident — the size sweep finds \"Sowing calen…\" in a 65 px cell at 360 px / Extra\n * large, and a third line would make every cell of the bar taller for one long word.\n * The whole label stays the link's accessible name; an app with a long one gives the bar\n * a `shortLabel`.\n */\nfunction MobileCellLabel({ children }: { children: ReactNode }) {\n return (\n <span\n data-truncate-ok=\"\"\n className=\"line-clamp-2 max-w-full break-words px-0.5 text-center leading-tight hyphens-auto\"\n >\n {children}\n </span>\n );\n}\n\n/** One cell of the phone's group bar. Marked while the group's own page OR any of its\n * pages is current — NavLink alone only knows its own `to`, which left the bar with\n * nothing marked on every sub-page (the same defect the sidebar had). */\nfunction MobileNavItem({ item }: { item: AppShellNavItem }) {\n const subActive = useSubItemActive(item);\n const label = useCellLabel(item);\n return (\n <NavLink\n to={item.to}\n end={item.end ?? true}\n data-tour={item.dataTour}\n className={({ isActive }) => mobileCellClass(isActive || subActive)}\n >\n <span className=\"relative\">\n <item.icon className=\"size-5\" />\n </span>\n <MobileCellLabel>{label}</MobileCellLabel>\n </NavLink>\n );\n}\n\n/** The bar cell's label: `shortLabel` from its text size up (0.48), else `label`. */\nfunction useCellLabel(item: AppShellNavItem): string {\n const { size } = useTextSize();\n return item.shortLabel !== undefined &&\n TEXT_SIZES.indexOf(size) >= TEXT_SIZES.indexOf(item.shortLabelFrom ?? \"normal\")\n ? item.shortLabel\n : item.label;\n}\n\n/** A link in one of the phone's sheets — an entry (`level=\"entry\"`) or a page under one. */\nfunction SheetLink({\n to,\n end,\n icon: Icon,\n label,\n onClick,\n level,\n}: {\n to: string;\n end?: boolean;\n icon: LucideIcon;\n label: string;\n onClick: () => void;\n level: \"entry\" | \"page\";\n}) {\n return (\n <NavLink\n to={to}\n end={end ?? true}\n onClick={onClick}\n className={({ isActive }) =>\n cn(\n level === \"entry\"\n ? \"flex min-h-11 items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors\"\n : \"flex min-h-11 items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors\",\n isActive\n ? \"bg-inverse text-inverse\"\n : level === \"entry\"\n ? \"text-primary hover:bg-hover\"\n : \"text-secondary hover:bg-hover\",\n )\n }\n >\n <Icon aria-hidden className={level === \"entry\" ? \"size-5 shrink-0\" : \"size-4 shrink-0 opacity-70\"} />\n <span className=\"min-w-0 break-words leading-snug\">{label}</span>\n </NavLink>\n );\n}\n\n/**\n * A bar cell for an entry with pages (0.49 KIT-6): on a phone the entry opens a sheet of\n * its pages instead of linking to its own `to` — a tap on \"Reports\" used to land on the\n * overview with the pages one more step away, in the row above the bar, which only\n * appears once you are in the group. The sheet lists the entry's own page first, as\n * \"Overview\", when none of the pages is that page. Marked while the entry's page or one\n * of its pages is current, as the link was.\n *\n * Tours find the entry by `a[href]` or its `dataTour`, as on the More cell: an inert,\n * pointer-transparent anchor over the button carries them (see {@link MobileMoreCell}).\n */\nfunction MobileGroupCell({\n item,\n labels: labelsProp,\n}: {\n item: AppShellNavItem;\n labels?: LabelOverride<AppShellMoreLabels>;\n}) {\n const labels: AppShellMoreLabels = useKitLabels(\"appShellMore\", DEFAULT_APP_SHELL_MORE_LABELS, labelsProp);\n const { pathname } = useLocation();\n const [open, setOpen] = useState(false);\n const label = useCellLabel(item);\n const active = entryIsCurrent(item, pathname);\n const close = () => setOpen(false);\n const pages = item.items ?? [];\n const ownPageListed = pages.some((sub) => sub.to === item.to);\n return (\n <div data-slot=\"app-shell-group\" className=\"relative min-w-0\">\n <button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // The cell may show a shortLabel; the button's name is the entry's.\n aria-label={label === item.label ? undefined : item.label}\n onClick={() => setOpen(true)}\n className={mobileCellClass(active)}\n >\n <span className=\"relative\">\n <item.icon aria-hidden className=\"size-5\" />\n </span>\n <MobileCellLabel>{label}</MobileCellLabel>\n </button>\n <TourAnchor to={item.to} dataTour={item.dataTour} />\n {pages\n .filter((sub) => sub.to !== item.to)\n .map((sub) => (\n <TourAnchor key={sub.to} to={sub.to} />\n ))}\n <DialogFrame open={open} onClose={close} title={item.label} closeButton bodyClassName=\"space-y-1\">\n <ul className=\"space-y-1\">\n {!ownPageListed && (\n <li>\n <SheetLink\n to={item.to}\n end={item.end}\n icon={item.icon}\n label={labels.overview}\n onClick={close}\n level=\"entry\"\n />\n </li>\n )}\n {pages.map((sub) => (\n <li key={sub.to}>\n <SheetLink to={sub.to} end={sub.end} icon={sub.icon} label={sub.label} onClick={close} level=\"entry\" />\n </li>\n ))}\n </ul>\n </DialogFrame>\n </div>\n );\n}\n\n/** Whether the current route is `item`'s page or one of its pages. */\nfunction entryIsCurrent(item: AppShellNavItem, pathname: string): boolean {\n return (\n !!matchPath({ path: item.to, end: item.end ?? true }, pathname) ||\n !!item.items?.some((sub) => matchPath({ path: sub.to, end: sub.end ?? true }, pathname))\n );\n}\n\n/** A hidden entry's link, resolved as the router would write it (basename included). */\nfunction TourAnchor({ to, dataTour }: { to: string; dataTour?: string }) {\n const href = useHref(to);\n return (\n // eslint-disable-next-line jsx-a11y/anchor-has-content -- a tour anchor, aria-hidden and inert; the More button under it is the control (see MobileMoreCell)\n <a\n href={href}\n data-tour={dataTour}\n // Not a control: no name, no tab stop, no pointer — the More button under it\n // takes the tap. It exists only to be FOUND (see MobileMoreCell).\n aria-hidden\n tabIndex={-1}\n className=\"pointer-events-none absolute inset-0\"\n />\n );\n}\n\n/**\n * The bar's \"More\" cell (0.32, docs/text-size-harmonization.md §4, §10.7): the entries\n * past `mobileMaxItems`, in a sheet — each entry as a link, and under a group its pages,\n * since a group the bar no longer shows has no sub-row to reach them by either. Marked\n * active while the current page is one of them, as the cell it replaced would be.\n *\n * **Tour anchors.** A guided tour finds a nav entry by `[data-tour=\"nav\"] a[href=\"/x\"]`\n * (keksdose's tours) or by the entry's own `dataTour`. An entry under More has no link\n * in the bar, and the sidebar's copy is `display:none` on a phone, so such a step would\n * spotlight nothing. So the More cell carries the hidden entries' links — one `<a>` per\n * entry and per page of a hidden group, with the entry's `href` and `dataTour` — laid\n * over the cell (`absolute inset-0`): both selectors resolve to a visible box, and that\n * box is the More cell, which is where the reader has to go next. They are\n * `aria-hidden`, out of the tab order and pointer-transparent, so neither a screen\n * reader nor a tap ever meets them; the button under them is the one control.\n */\nfunction MobileMoreCell({\n hidden,\n labels: labelsProp,\n}: {\n hidden: AppShellNavItem[];\n labels?: LabelOverride<AppShellMoreLabels>;\n}) {\n const labels: AppShellMoreLabels = useKitLabels(\"appShellMore\", DEFAULT_APP_SHELL_MORE_LABELS, labelsProp);\n const { pathname } = useLocation();\n const [open, setOpen] = useState(false);\n const active = hidden.some((item) => entryIsCurrent(item, pathname));\n const close = () => setOpen(false);\n return (\n <div data-slot=\"app-shell-more\" className=\"relative min-w-0\">\n <button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={() => setOpen(true)}\n className={mobileCellClass(active)}\n >\n <span className=\"relative\">\n <MoreHorizontal aria-hidden className=\"size-5\" />\n </span>\n <MobileCellLabel>{labels.more}</MobileCellLabel>\n </button>\n {hidden.flatMap((item) => [\n <TourAnchor key={item.to} to={item.to} dataTour={item.dataTour} />,\n ...(item.items ?? []).map((sub) => <TourAnchor key={`${item.to} ${sub.to}`} to={sub.to} />),\n ])}\n <DialogFrame open={open} onClose={close} title={labels.moreTitle} closeButton bodyClassName=\"space-y-1\">\n <ul className=\"space-y-1\">\n {hidden.map((item) => (\n <li key={item.to}>\n <SheetLink\n to={item.to}\n end={item.end}\n icon={item.icon}\n label={item.label}\n onClick={close}\n level=\"entry\"\n />\n {!!item.items?.length && (\n <ul aria-label={item.label} className=\"ms-[1.3rem] mt-0.5 space-y-0.5 border-s border-subtle ps-2\">\n {item.items.map((sub) => (\n <li key={sub.to}>\n <SheetLink\n to={sub.to}\n end={sub.end}\n icon={sub.icon}\n label={sub.label}\n onClick={close}\n level=\"page\"\n />\n </li>\n ))}\n </ul>\n )}\n </li>\n ))}\n </ul>\n </DialogFrame>\n </div>\n );\n}\n\n/**\n * The upper row of the phone navigation: the pages of the group the reader is in, as\n * a sideways-scrolling row of pills. Rendered only while such a group is current —\n * on a page outside every group the bar stays one row, rather than showing an empty\n * shelf or guessing a group.\n *\n * It slides in over 200ms (fade only under reduced motion) and wraps onto more rows\n * rather than scrolling, so every page of the group is in view at once.\n */\nfunction MobileSubNav({ nav, layout }: { nav: AppShellNavItem[]; layout: \"wrap\" | \"scroll\" }) {\n const { pathname } = useLocation();\n const scroll = layout === \"scroll\";\n const listRef = useRef<HTMLUListElement>(null);\n const fade = useStripFade(listRef);\n // The current page into view — the row only, never the page.\n useLayoutEffect(() => {\n const list = listRef.current;\n const current = list?.querySelector<HTMLElement>('[aria-current=\"page\"]');\n if (scroll && list && current) scrollIntoStrip(list, current);\n }, [scroll, pathname]);\n const group = nav.find(\n (item) =>\n !!item.items?.length &&\n (matchPath({ path: item.to, end: item.end ?? true }, pathname) ||\n item.items.some((sub) => matchPath({ path: sub.to, end: sub.end ?? true }, pathname))),\n );\n\n if (!group) return null;\n return (\n <nav\n aria-label={group.label}\n // Keyed by group so switching groups replays the entrance.\n key={group.to}\n className=\"animate-subnav border-b border-subtle\"\n >\n <ul\n ref={listRef}\n // `wrap` (default) takes as many rows as the group needs: a sideways row hides\n // pages past the edge, and every page of the group in view is the point of the\n // row. The bar grows with it — `--app-nav-h` measures it. `scroll` is the app's\n // opt-in trade: one row, the cut edge faded (see mobileSubNavLayout).\n className={cn(\n \"flex gap-1.5 px-3 py-2\",\n scroll ? \"overflow-x-auto overscroll-x-contain [scrollbar-width:none]\" : \"flex-wrap\",\n )}\n data-overflow={scroll ? fade.overflow : undefined}\n style={scroll && fade.mask ? { maskImage: fade.mask, WebkitMaskImage: fade.mask } : undefined}\n >\n {group.items!.map((sub) => (\n <li key={sub.to} className=\"shrink-0\">\n <NavLink\n to={sub.to}\n end={sub.end ?? true}\n className={({ isActive }) =>\n cn(\n \"flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs transition-colors\",\n isActive\n ? \"border-brand bg-brand font-medium text-brand-contrast\"\n : \"border-subtle text-secondary hover:bg-hover\",\n )\n }\n >\n <sub.icon className=\"size-3.5 shrink-0\" aria-hidden />\n {sub.label}\n </NavLink>\n </li>\n ))}\n </ul>\n </nav>\n );\n}\n\n/** `strong` is the current page; `trail` is the group that CONTAINS the current page\n * while the page itself is shown elsewhere (the inline list below it). */\nconst navLinkClass =\n (collapsed: boolean, forceActive: boolean, trail = false) =>\n ({ isActive }: { isActive: boolean }) =>\n `flex items-center gap-3 min-h-9 ${collapsed ? \"justify-center px-2\" : \"px-3\"} py-2 rounded-md text-sm transition-colors duration-150 ${\n isActive || (forceActive && !trail)\n ? \"bg-inverse text-inverse\"\n : forceActive\n ? \"font-medium text-primary hover:bg-hover\"\n : \"text-secondary hover:bg-hover\"\n }`;\n\n/** Whether any of an entry's sub-items is the current route. NavLink only knows about\n * its OWN `to`, so without this a group whose pages live at sibling paths\n * (`/fields`, `/numbers`, …) lost its highlight the moment the reader left the one\n * page the group linked to — the sidebar then marked nothing at all, and the only\n * \"you are here\" left was inside a flyout that is closed unless hovered. */\nfunction useSubItemActive(item: AppShellNavItem): boolean {\n const { pathname } = useLocation();\n return !!item.items?.some((sub) => matchPath({ path: sub.to, end: sub.end ?? true }, pathname));\n}\n\n/** A single desktop sidebar entry. Plain link (with a tooltip when collapsed) —\n * unless it has sub-items, in which case hovering/focusing opens a flyout, or (with\n * `inline`) a disclosure lists them underneath. */\nfunction SidebarNavItem({\n item,\n collapsed,\n inline,\n toggleGroupLabel,\n openGroup,\n setOpenGroup,\n}: {\n item: AppShellNavItem;\n collapsed: boolean;\n inline: boolean;\n toggleGroupLabel: (groupLabel: string) => string;\n openGroup: string | null;\n setOpenGroup: (to: string | null) => void;\n}) {\n const hasSub = !!item.items?.length;\n const subActive = useSubItemActive(item);\n\n // In the EXPANDED sidebar a group is one component in both styles, so switching\n // between them is a transition of the same element (the page list folding away or\n // unfolding) rather than one tree replaced by another. The icon-only sidebar keeps\n // the plain flyout below: an indented list has no room there.\n if (hasSub && !collapsed) {\n return (\n <SidebarGroup\n item={item}\n subActive={subActive}\n inline={inline}\n toggleGroupLabel={toggleGroupLabel}\n open={openGroup === item.to}\n setOpenGroup={setOpenGroup}\n />\n );\n }\n\n const link = (\n <NavLink\n to={item.to}\n end={item.end ?? true}\n data-tour={item.dataTour}\n className={navLinkClass(collapsed, subActive)}\n aria-haspopup={hasSub ? \"menu\" : undefined}\n >\n <span className=\"relative shrink-0\">\n <item.icon className=\"size-4\" />\n </span>\n {/* Wraps rather than truncates: in the sidebar a label cut to \"Checkbox, switch\n & sl…\" hides the one word that tells two pages apart, and there is height\n to spare. (The phone bar clamps at two lines instead, since 0.32 §10.7.) */}\n {!collapsed && <span className=\"min-w-0 flex-1 break-words leading-snug\">{item.label}</span>}\n {!collapsed && hasSub && <ChevronRight className=\"size-3.5 shrink-0 opacity-60 rtl:-scale-x-100\" />}\n </NavLink>\n );\n\n if (hasSub) return <SidebarFlyout item={item}>{link}</SidebarFlyout>;\n return collapsed ? (\n <Tooltip label={item.label} side=\"end\" portal className=\"block\">\n {link}\n </Tooltip>\n ) : (\n link\n );\n}\n\n/**\n * An entry with sub-items in the expanded sidebar.\n *\n * - `inline`: the entry's own link (its overview page) plus a chevron button that\n * shows or hides the sub-items indented beneath it. Two controls rather than one\n * because they do two different things — a row that both navigated AND toggled\n * would make \"open the overview\" and \"peek at the pages\" the same click.\n * - flyout: the link alone, with the sub-items in a panel beside the sidebar on\n * hover/focus. The inline list is still rendered, folded shut, so that switching\n * styles animates it rather than swapping it.\n *\n * THE FOLD is a `grid-template-rows` transition from `0fr` to `1fr` — the one way to\n * animate to a content-sized height without measuring it, so a translated label that\n * wraps to two lines unfolds exactly as far as it needs. `visibility` rides the same\n * transition so a shut list drops out of the accessibility tree only once it has\n * finished closing, and `inert` takes its links out of the tab order immediately.\n */\nfunction SidebarGroup({\n item,\n subActive,\n inline,\n toggleGroupLabel,\n open,\n setOpenGroup,\n}: {\n item: AppShellNavItem;\n subActive: boolean;\n inline: boolean;\n toggleGroupLabel: (groupLabel: string) => string;\n /** Whether this is the sidebar's one open group (see AppShell's `openGroup`). */\n open: boolean;\n setOpenGroup: (to: string | null) => void;\n}) {\n const listId = useId();\n const { pathname } = useLocation();\n const onOwnPage = !!matchPath({ path: item.to, end: item.end ?? true }, pathname);\n // Opening follows the reader: arriving on this group's overview or one of its pages\n // (by link, by the pager, by Back) opens it — and, the sidebar holding ONE open\n // group, closes whichever was open before. Both folds run at once, so the eye sees\n // one list hand over to the other. Run in an effect after mount, so the current\n // group UNFOLDS into view on load rather than appearing already open.\n const here = subActive || onOwnPage;\n useEffect(() => {\n if (here) setOpenGroup(item.to);\n }, [here, item.to, setOpenGroup]);\n const expanded = inline && open;\n\n const link = (\n <NavLink\n to={item.to}\n end={item.end ?? true}\n data-tour={item.dataTour}\n aria-haspopup={inline ? undefined : \"menu\"}\n // `trail` (inline only): while a page of the group is current, the group row is\n // the breadcrumb, not the destination — the page's own row below carries the\n // strong marker, and two inverse rows would say \"you are here\" twice. In the\n // flyout style the pages are out of sight, so the group row IS the marker.\n className={(state) => cn(navLinkClass(false, subActive, inline)(state), \"min-w-0 flex-1\")}\n >\n <span className=\"relative shrink-0\">\n <item.icon className=\"size-4\" />\n </span>\n <span className=\"min-w-0 flex-1 break-words leading-snug\">{item.label}</span>\n {!inline && <ChevronRight className=\"size-3.5 shrink-0 opacity-60 rtl:-scale-x-100\" />}\n </NavLink>\n );\n\n return (\n <div>\n {inline ? (\n <div className=\"flex items-center gap-0.5\">\n {link}\n <button\n type=\"button\"\n aria-expanded={open}\n aria-controls={listId}\n aria-label={toggleGroupLabel(item.label)}\n onClick={() => setOpenGroup(open ? null : item.to)}\n className=\"flex size-9 shrink-0 items-center justify-center rounded-md text-muted hover:bg-hover hover:text-secondary\"\n >\n <ChevronRight\n aria-hidden\n className={cn(\n \"size-3.5 transition-transform duration-200 ease-out motion-reduce:transition-none rtl:-scale-x-100\",\n // Under dir=\"rtl\" the chevron is MIRRORED first (scale applies before rotate), so\n // it starts pointing left and a +90° turn would point it UP — hence −90° there.\n open && \"rotate-90 rtl:-rotate-90\",\n )}\n />\n </button>\n </div>\n ) : (\n <SidebarFlyout item={item}>{link}</SidebarFlyout>\n )}\n <div\n id={listId}\n inert={!expanded}\n className=\"grid transition-[grid-template-rows,visibility] duration-200 ease-out motion-reduce:transition-none\"\n style={{\n gridTemplateRows: expanded ? \"1fr\" : \"0fr\",\n visibility: expanded ? \"visible\" : \"hidden\",\n }}\n >\n <div\n className={cn(\n \"min-h-0 overflow-hidden transition-opacity duration-200 ease-out motion-reduce:transition-none\",\n expanded ? \"opacity-100\" : \"opacity-0\",\n )}\n >\n {/* The rule and indent live on the list INSIDE the clipping box: margin or\n padding on the element whose row is collapsing to 0fr would hold it open\n by that much. */}\n <ul className=\"ms-[1.3rem] mt-0.5 space-y-0.5 border-s border-subtle ps-2\">\n {item.items!.map((sub) => (\n <li key={sub.to}>\n <NavLink\n to={sub.to}\n end={sub.end ?? true}\n className={({ isActive }) =>\n cn(\n \"flex min-h-8 items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors\",\n isActive ? \"bg-inverse text-inverse\" : \"text-secondary hover:bg-hover\",\n )\n }\n >\n <sub.icon className=\"size-4 shrink-0 opacity-70\" aria-hidden />\n <span className=\"min-w-0 break-words leading-snug\">{sub.label}</span>\n </NavLink>\n </li>\n ))}\n </ul>\n </div>\n </div>\n </div>\n );\n}\n\n// Only ONE sidebar flyout should be on screen at a time. Each open flyout parks its\n// \"close now\" here so the next item to open can dismiss it immediately, instead of\n// leaving the previous panel up for the 140ms travel delay while the cursor moves\n// down the nav list — which showed two panels at once.\nlet activeFlyoutClose: (() => void) | null = null;\n\n/**\n * Wraps a nav item that has sub-items: on hover or keyboard focus it opens a\n * portalled flyout to the right of the sidebar (portalled so the sidebar's\n * `overflow-hidden` can't clip it) with the item's label as a header and each\n * sub-item as an icon + title link. A short close delay lets the cursor travel\n * from the item onto the panel; Escape / outside-move close it.\n */\nfunction SidebarFlyout({ item, children }: { item: AppShellNavItem; children: ReactNode }) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const [open, setOpen] = useState(false);\n // The flyout is portalled out of the subtree whose `dir` it inherited; read on open.\n const [dir, setDir] = useState<Direction>(\"ltr\");\n\n // Anchor the flyout to the item's END edge — its right, or its left in RTL, where\n // the sidebar sits on the right of the window — and keep it on the glass (Wave 2,\n // DUP-7). Right to left it hangs by its `right`, which a fixed box measures from\n // inside the scrollbar: `innerWidth` counted the bar and put the flyout a bar's width\n // off its item. The hook re-measures on scroll/resize (the nav list can scroll); the\n // panel's own width is measured once it is up, before paint.\n const rect = useAnchoredRect(wrapperRef, open);\n const panelRef = useRef<HTMLDivElement>(null);\n const [panelWidth, setPanelWidth] = useState(0);\n const placed = rect !== null;\n useLayoutEffect(() => {\n if (open && placed) setPanelWidth(panelRef.current?.offsetWidth ?? 0);\n }, [open, placed]);\n const at = rect ? anchoredInline(rect, panelWidth, { dir, align: \"after\" }) : null;\n const pos = rect && at ? { top: rect.top, ...(dir === \"rtl\" ? { right: at.right } : { left: at.left }) } : null;\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current);\n closeTimer.current = null;\n }\n }, []);\n // Stable identity: the coordinator above holds this so a sibling item can close\n // THIS flyout without waiting out its travel delay.\n const closeNow = useCallback(() => {\n cancelClose();\n setOpen(false);\n }, [cancelClose]);\n const openMenu = useCallback(() => {\n cancelClose();\n if (activeFlyoutClose && activeFlyoutClose !== closeNow) activeFlyoutClose();\n activeFlyoutClose = closeNow;\n setDir(dirOf(wrapperRef.current));\n setOpen(true);\n }, [cancelClose, closeNow]);\n const scheduleClose = useCallback(() => {\n cancelClose();\n closeTimer.current = setTimeout(() => {\n setOpen(false);\n if (activeFlyoutClose === closeNow) activeFlyoutClose = null;\n }, 140);\n }, [cancelClose, closeNow]);\n\n // Close on Escape while open — a layer on the kit's Escape stack (Wave 2, DUP-1).\n useDismissLayer(open, () => setOpen(false));\n\n useEffect(\n () => () => {\n cancelClose();\n if (activeFlyoutClose === closeNow) activeFlyoutClose = null;\n },\n [cancelClose, closeNow],\n );\n\n return (\n // Not a control: hover and focus-within on the nav link inside. Focus (the\n // keyboard path) opens it exactly as hover does, Escape closes it.\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- hover/focus-within wrapper around a real link\n <div\n ref={wrapperRef}\n className=\"relative\"\n onMouseEnter={openMenu}\n onMouseLeave={scheduleClose}\n onFocus={openMenu}\n onBlur={scheduleClose}\n >\n {children}\n {open &&\n pos &&\n createPortal(\n // Keeps the flyout open while the pointer crosses into it; keyboard users\n // reach it by focus, which the wrapper above already handles.\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- pointer-only hover bridge\n <div\n ref={panelRef}\n dir={dir}\n style={{ position: \"fixed\", ...pos }}\n className=\"z-40 ps-1\"\n onMouseEnter={cancelClose}\n onMouseLeave={scheduleClose}\n >\n <div\n role=\"menu\"\n aria-label={item.label}\n className=\"animate-flyout min-w-52 overflow-hidden rounded-md border border-subtle bg-surface shadow-lg\"\n >\n <div className=\"border-b border-subtle px-3 py-2 text-caption font-semibold uppercase tracking-wide text-muted\">\n {item.label}\n </div>\n <ul className=\"py-1\">\n {item.items!.map((sub) => (\n <li key={sub.to}>\n <NavLink\n to={sub.to}\n end={sub.end ?? true}\n role=\"menuitem\"\n onClick={() => setOpen(false)}\n className={({ isActive }) =>\n cn(\n \"flex items-center gap-2.5 px-3 py-2 text-sm\",\n isActive ? \"bg-active font-medium text-primary\" : \"text-secondary hover:bg-hover\",\n )\n }\n >\n <sub.icon className=\"size-4 shrink-0 text-placeholder\" />\n <span className=\"min-w-0 break-words leading-snug\">{sub.label}</span>\n </NavLink>\n </li>\n ))}\n </ul>\n </div>\n </div>,\n document.body,\n )}\n </div>\n );\n}\n"],"mappings":";AAiiBQ,SAoOU,UApOV,KAoDU,YApDV;AAjiBR;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,oBAAoB;AAC7B,SAAS,MAAM,SAAS,WAAW,SAAS,mBAAmB;AAC/D,SAAS,cAAc,gBAAgB,gBAAgB,qBAAqB;AAE5E,SAAS,UAAU;AACnB,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,aAA6B;AACtC,SAAS,YAAY,mBAAmB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A;AAAA,IAIE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,WAAU;AAAA,QACV,cAAc;AAAA,QACd,cAAc;AAAA,QACd,SAAS;AAAA,QACT,QAAQ;AAAA,QAEP;AAAA;AAAA,UACA,QACC,OACA;AAAA;AAAA;AAAA;AAAA,YAIE;AAAA,cAAC;AAAA;AAAA,gBACC,KAAK;AAAA,gBACL;AAAA,gBACA,OAAO,EAAE,UAAU,SAAS,GAAG,IAAI;AAAA,gBACnC,WAAU;AAAA,gBACV,cAAc;AAAA,gBACd,cAAc;AAAA,gBAEd;AAAA,kBAAC;AAAA;AAAA,oBACC,MAAK;AAAA,oBACL,cAAY,KAAK;AAAA,oBACjB,WAAU;AAAA,oBAEV;AAAA,0CAAC,SAAI,WAAU,kGACZ,eAAK,OACR;AAAA,sBACA,oBAAC,QAAG,WAAU,QACX,eAAK,MAAO,IAAI,CAAC,QAChB,oBAAC,QACC;AAAA,wBAAC;AAAA;AAAA,0BACC,IAAI,IAAI;AAAA,0BACR,KAAK,IAAI,OAAO;AAAA,0BAChB,MAAK;AAAA,0BACL,SAAS,MAAM,QAAQ,KAAK;AAAA,0BAC5B,WAAW,CAAC,EAAE,SAAS,MACrB;AAAA,4BACE;AAAA,4BACA,WAAW,uCAAuC;AAAA,0BACpD;AAAA,0BAGF;AAAA,gDAAC,IAAI,MAAJ,EAAS,WAAU,oCAAmC;AAAA,4BACvD,oBAAC,UAAK,WAAU,oCAAoC,cAAI,OAAM;AAAA;AAAA;AAAA,sBAChE,KAfO,IAAI,EAgBb,CACD,GACH;AAAA;AAAA;AAAA,gBACF;AAAA;AAAA,YACF;AAAA,YACA,SAAS;AAAA,UACX;AAAA;AAAA;AAAA,IACJ;AAAA;AAEJ;","names":["count"]}
@@ -43,7 +43,7 @@ export interface CompanySwitcherProps<Id extends string | number> {
43
43
  * The company switcher in the top bar (docs/auth-harmonization.md §5.3, §8): a kastlan
44
44
  * user may belong to several companies, and the access token carries the current one,
45
45
  * so switching is a request for new tokens — `onSwitch`, the app's. Built on
46
- * {@link OptionSwitcherMenu}, like `RoleSwitcher`: the icon trigger, the current company
46
+ * {@link OptionSwitcherMenu}: the icon trigger, the current company
47
47
  * in its tooltip, the list with a check on the current one.
48
48
  *
49
49
  * **Only for more than one company** — a user in one company has nothing to switch, and
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shell/company-switcher.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { Building2 } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { Spinner } from \"../components/spinner\";\nimport { OptionSwitcherMenu } from \"./option-switcher-menu\";\nimport { TOPBAR_TRIGGER_CLASS } from \"./topbar-controls\";\nimport { DEFAULT_COMPANY_SWITCHER_LABELS } from \"./company-switcher-labels\";\n\n/** Every string the switcher renders or speaks — the `companySwitcher` namespace. A\n * different context (keksdose's budgets) renames them all. */\nexport interface CompanySwitcherLabels {\n /** The trigger's and the menu's accessible name. */\n switchCompany: string;\n /** The small heading over the list. */\n heading: string;\n /** The trigger's tooltip (and description), given the current company's name. */\n current: (name: string) => string;\n /** Read after the current company's name in the list, where the eye sees a check. */\n currentMark: string;\n /** Said while a switch is running. */\n switching: string;\n}\n\n// Defined in ./company-switcher-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_COMPANY_SWITCHER_LABELS };\n\n/** One company the user belongs to — kastlan's `/auth/me` `companies[]` (§5.3). */\nexport interface CompanySwitcherCompany<Id extends string | number = string | number> {\n /** kastlan's ids are numbers; a string works the same. */\n id: Id;\n name: string;\n}\n\nexport interface CompanySwitcherProps<Id extends string | number> {\n /** Every company the user belongs to. With fewer than two there is nothing to\n * switch, and nothing renders. */\n companies: readonly CompanySwitcherCompany<Id>[];\n /** The company the session is in — `/auth/me`'s `current_company_id`. */\n currentId: Id;\n /**\n * Another company was picked: `POST /auth/switch-company {company_id}`, store the\n * fresh tokens, reload what is company-scoped. While the promise runs the switcher is\n * disabled, so a second pick cannot race the first; a rejection frees it (the app\n * says why). Picking the current company does nothing.\n */\n onSwitch: (id: Id) => Promise<unknown> | void;\n /** The trigger's glyph. Default a building; keksdose's budgets would pass a wallet. */\n icon?: ReactNode;\n labels?: LabelOverride<CompanySwitcherLabels>;\n}\n\n/**\n * The company switcher in the top bar (docs/auth-harmonization.md §5.3, §8): a kastlan\n * user may belong to several companies, and the access token carries the current one,\n * so switching is a request for new tokens — `onSwitch`, the app's. Built on\n * {@link OptionSwitcherMenu}, like `RoleSwitcher`: the icon trigger, the current company\n * in its tooltip, the list with a check on the current one.\n *\n * **Only for more than one company** — a user in one company has nothing to switch, and\n * the top bar stays as it was. **Disabled while a switch runs**: the trigger is swapped\n * for a disabled one with a spinner (`aria-busy`), and \"Switching company…\" is said, so\n * a second pick cannot race the first. The kit never sends the request.\n *\n * A generic context switcher: the labels rename it (\"Switch budget\", \"Budgets\"), `icon`\n * replaces the building, and `id` may be a number (kastlan's) or a string.\n */\nexport function CompanySwitcher<Id extends string | number>({\n companies,\n currentId,\n onSwitch,\n icon,\n labels: labelsProp,\n}: CompanySwitcherProps<Id>) {\n const labels = useKitLabels(\"companySwitcher\", DEFAULT_COMPANY_SWITCHER_LABELS, labelsProp);\n const [pending, setPending] = useState(false);\n const { announce, regionProps } = useAnnounce();\n if (companies.length < 2) return null;\n\n const current = companies.find((c) => c.id === currentId);\n const select = (value: string) => {\n if (pending) return;\n const picked = companies.find((c) => String(c.id) === value);\n if (!picked || picked.id === currentId) return;\n const result = onSwitch(picked.id);\n if (typeof (result as PromiseLike<unknown> | undefined)?.then !== \"function\") return;\n setPending(true);\n announce(labels.switching);\n (result as PromiseLike<unknown>).then(\n () => setPending(false),\n () => setPending(false),\n );\n };\n\n return (\n <>\n {pending ? (\n <button\n type=\"button\"\n disabled\n aria-busy=\"true\"\n aria-label={labels.switchCompany}\n className={cn(TOPBAR_TRIGGER_CLASS, \"cursor-wait opacity-60 hover:bg-transparent\")}\n >\n <Spinner label={null} />\n </button>\n ) : (\n <OptionSwitcherMenu<string>\n aria-label={labels.switchCompany}\n title={current ? labels.current(current.name) : undefined}\n heading={labels.heading}\n icon={icon ?? <Building2 className=\"size-5\" />}\n options={companies.map((c) => ({\n value: String(c.id),\n label:\n c.id === currentId ? (\n // `relative`: the sr-only mark needs a local containing block.\n <span className=\"relative\">\n {c.name}\n <span className=\"sr-only\"> {labels.currentMark}</span>\n </span>\n ) : (\n c.name\n ),\n }))}\n value={String(currentId)}\n onSelect={select}\n />\n )}\n {/* Outside both triggers, so it survives the swap and is read when it changes. */}\n <span {...regionProps} />\n </>\n );\n}\n"],"mappings":";AAiGI,mBASM,KAeQ,YAxBd;AAjGJ,SAAS,gBAAgB;AAEzB,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB,SAAS,oBAAwC;AACjD,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,uCAAuC;AA4DzC,SAAS,gBAA4C;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AACV,GAA6B;AAC3B,QAAM,SAAS,aAAa,mBAAmB,iCAAiC,UAAU;AAC1F,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,EAAE,UAAU,YAAY,IAAI,YAAY;AAC9C,MAAI,UAAU,SAAS,EAAG,QAAO;AAEjC,QAAM,UAAU,UAAU,KAAK,CAAC,MAAM,EAAE,OAAO,SAAS;AACxD,QAAM,SAAS,CAAC,UAAkB;AAChC,QAAI,QAAS;AACb,UAAM,SAAS,UAAU,KAAK,CAAC,MAAM,OAAO,EAAE,EAAE,MAAM,KAAK;AAC3D,QAAI,CAAC,UAAU,OAAO,OAAO,UAAW;AACxC,UAAM,SAAS,SAAS,OAAO,EAAE;AACjC,QAAI,OAAQ,QAA6C,SAAS,WAAY;AAC9E,eAAW,IAAI;AACf,aAAS,OAAO,SAAS;AACzB,IAAC,OAAgC;AAAA,MAC/B,MAAM,WAAW,KAAK;AAAA,MACtB,MAAM,WAAW,KAAK;AAAA,IACxB;AAAA,EACF;AAEA,SACE,iCACG;AAAA,cACC;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,UAAQ;AAAA,QACR,aAAU;AAAA,QACV,cAAY,OAAO;AAAA,QACnB,WAAW,GAAG,sBAAsB,6CAA6C;AAAA,QAEjF,8BAAC,WAAQ,OAAO,MAAM;AAAA;AAAA,IACxB,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,cAAY,OAAO;AAAA,QACnB,OAAO,UAAU,OAAO,QAAQ,QAAQ,IAAI,IAAI;AAAA,QAChD,SAAS,OAAO;AAAA,QAChB,MAAM,QAAQ,oBAAC,aAAU,WAAU,UAAS;AAAA,QAC5C,SAAS,UAAU,IAAI,CAAC,OAAO;AAAA,UAC7B,OAAO,OAAO,EAAE,EAAE;AAAA,UAClB,OACE,EAAE,OAAO;AAAA;AAAA,YAEP,qBAAC,UAAK,WAAU,YACb;AAAA,gBAAE;AAAA,cACH,qBAAC,UAAK,WAAU,WAAU;AAAA;AAAA,gBAAE,OAAO;AAAA,iBAAY;AAAA,eACjD;AAAA,cAEA,EAAE;AAAA,QAER,EAAE;AAAA,QACF,OAAO,OAAO,SAAS;AAAA,QACvB,UAAU;AAAA;AAAA,IACZ;AAAA,IAGF,oBAAC,UAAM,GAAG,aAAa;AAAA,KACzB;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/shell/company-switcher.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { Building2 } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { Spinner } from \"../components/spinner\";\nimport { OptionSwitcherMenu } from \"./option-switcher-menu\";\nimport { TOPBAR_TRIGGER_CLASS } from \"./topbar-controls\";\nimport { DEFAULT_COMPANY_SWITCHER_LABELS } from \"./company-switcher-labels\";\n\n/** Every string the switcher renders or speaks — the `companySwitcher` namespace. A\n * different context (keksdose's budgets) renames them all. */\nexport interface CompanySwitcherLabels {\n /** The trigger's and the menu's accessible name. */\n switchCompany: string;\n /** The small heading over the list. */\n heading: string;\n /** The trigger's tooltip (and description), given the current company's name. */\n current: (name: string) => string;\n /** Read after the current company's name in the list, where the eye sees a check. */\n currentMark: string;\n /** Said while a switch is running. */\n switching: string;\n}\n\n// Defined in ./company-switcher-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_COMPANY_SWITCHER_LABELS };\n\n/** One company the user belongs to — kastlan's `/auth/me` `companies[]` (§5.3). */\nexport interface CompanySwitcherCompany<Id extends string | number = string | number> {\n /** kastlan's ids are numbers; a string works the same. */\n id: Id;\n name: string;\n}\n\nexport interface CompanySwitcherProps<Id extends string | number> {\n /** Every company the user belongs to. With fewer than two there is nothing to\n * switch, and nothing renders. */\n companies: readonly CompanySwitcherCompany<Id>[];\n /** The company the session is in — `/auth/me`'s `current_company_id`. */\n currentId: Id;\n /**\n * Another company was picked: `POST /auth/switch-company {company_id}`, store the\n * fresh tokens, reload what is company-scoped. While the promise runs the switcher is\n * disabled, so a second pick cannot race the first; a rejection frees it (the app\n * says why). Picking the current company does nothing.\n */\n onSwitch: (id: Id) => Promise<unknown> | void;\n /** The trigger's glyph. Default a building; keksdose's budgets would pass a wallet. */\n icon?: ReactNode;\n labels?: LabelOverride<CompanySwitcherLabels>;\n}\n\n/**\n * The company switcher in the top bar (docs/auth-harmonization.md §5.3, §8): a kastlan\n * user may belong to several companies, and the access token carries the current one,\n * so switching is a request for new tokens — `onSwitch`, the app's. Built on\n * {@link OptionSwitcherMenu}: the icon trigger, the current company\n * in its tooltip, the list with a check on the current one.\n *\n * **Only for more than one company** — a user in one company has nothing to switch, and\n * the top bar stays as it was. **Disabled while a switch runs**: the trigger is swapped\n * for a disabled one with a spinner (`aria-busy`), and \"Switching company…\" is said, so\n * a second pick cannot race the first. The kit never sends the request.\n *\n * A generic context switcher: the labels rename it (\"Switch budget\", \"Budgets\"), `icon`\n * replaces the building, and `id` may be a number (kastlan's) or a string.\n */\nexport function CompanySwitcher<Id extends string | number>({\n companies,\n currentId,\n onSwitch,\n icon,\n labels: labelsProp,\n}: CompanySwitcherProps<Id>) {\n const labels = useKitLabels(\"companySwitcher\", DEFAULT_COMPANY_SWITCHER_LABELS, labelsProp);\n const [pending, setPending] = useState(false);\n const { announce, regionProps } = useAnnounce();\n if (companies.length < 2) return null;\n\n const current = companies.find((c) => c.id === currentId);\n const select = (value: string) => {\n if (pending) return;\n const picked = companies.find((c) => String(c.id) === value);\n if (!picked || picked.id === currentId) return;\n const result = onSwitch(picked.id);\n if (typeof (result as PromiseLike<unknown> | undefined)?.then !== \"function\") return;\n setPending(true);\n announce(labels.switching);\n (result as PromiseLike<unknown>).then(\n () => setPending(false),\n () => setPending(false),\n );\n };\n\n return (\n <>\n {pending ? (\n <button\n type=\"button\"\n disabled\n aria-busy=\"true\"\n aria-label={labels.switchCompany}\n className={cn(TOPBAR_TRIGGER_CLASS, \"cursor-wait opacity-60 hover:bg-transparent\")}\n >\n <Spinner label={null} />\n </button>\n ) : (\n <OptionSwitcherMenu<string>\n aria-label={labels.switchCompany}\n title={current ? labels.current(current.name) : undefined}\n heading={labels.heading}\n icon={icon ?? <Building2 className=\"size-5\" />}\n options={companies.map((c) => ({\n value: String(c.id),\n label:\n c.id === currentId ? (\n // `relative`: the sr-only mark needs a local containing block.\n <span className=\"relative\">\n {c.name}\n <span className=\"sr-only\"> {labels.currentMark}</span>\n </span>\n ) : (\n c.name\n ),\n }))}\n value={String(currentId)}\n onSelect={select}\n />\n )}\n {/* Outside both triggers, so it survives the swap and is read when it changes. */}\n <span {...regionProps} />\n </>\n );\n}\n"],"mappings":";AAiGI,mBASM,KAeQ,YAxBd;AAjGJ,SAAS,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,OAAO;AAAA,QAChB,MAAM,QAAQ,oBAAC,aAAU,WAAU,UAAS;AAAA,QAC5C,SAAS,UAAU,IAAI,CAAC,OAAO;AAAA,UAC7B,OAAO,OAAO,EAAE,EAAE;AAAA,UAClB,OACE,EAAE,OAAO;AAAA;AAAA,YAEP,qBAAC,UAAK,WAAU,YACb;AAAA,gBAAE;AAAA,cACH,qBAAC,UAAK,WAAU,WAAU;AAAA;AAAA,gBAAE,OAAO;AAAA,iBAAY;AAAA,eACjD;AAAA,cAEA,EAAE;AAAA,QAER,EAAE;AAAA,QACF,OAAO,OAAO,SAAS;AAAA,QACvB,UAAU;AAAA;AAAA,IACZ;AAAA,IAGF,oBAAC,UAAM,GAAG,aAAa;AAAA,KACzB;AAEJ;","names":[]}
@@ -77,7 +77,7 @@ export interface DevMenuProps<R extends string, P extends string> {
77
77
  }
78
78
  /**
79
79
  * The top bar's local-dev menu (docs/top-bar-harmonization.md §2.7, §2.7.1, §6.2, §6.3):
80
- * ONE amber flask, `RoleSwitcher`'s, over the kit's Account section and the app's own.
80
+ * ONE amber flask over the kit's Account section and the app's own.
81
81
  *
82
82
  * 0.42's `DevSwitchers` drew a flask per switcher and had no place for anything else,
83
83
  * and an app has more dev controls than a role and a plan — keksdose's budget role, a