@krizaka/ui 4.3.0 → 4.4.1

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 (267) hide show
  1. package/dist/account-menu.d.ts +1 -1
  2. package/dist/account-menu.js +1 -1
  3. package/dist/account-menu.js.map +1 -1
  4. package/dist/account-settings.d.ts +1 -1
  5. package/dist/account-settings.js +13 -6
  6. package/dist/account-settings.js.map +1 -1
  7. package/dist/agenda.d.ts +1 -1
  8. package/dist/agenda.js +2 -1
  9. package/dist/agenda.js.map +1 -1
  10. package/dist/analysis-report.js +19 -11
  11. package/dist/analysis-report.js.map +1 -1
  12. package/dist/app-frame.d.ts +1 -1
  13. package/dist/app-frame.js.map +1 -1
  14. package/dist/app-header/search.js +2 -2
  15. package/dist/app-header/search.js.map +1 -1
  16. package/dist/avatar/defaults.js +3 -1
  17. package/dist/avatar/defaults.js.map +1 -1
  18. package/dist/avatar.js +3 -1
  19. package/dist/avatar.js.map +1 -1
  20. package/dist/bird-plate.js +8 -2
  21. package/dist/bird-plate.js.map +1 -1
  22. package/dist/blocks.css +4 -0
  23. package/dist/chapter.js +7 -4
  24. package/dist/chapter.js.map +1 -1
  25. package/dist/chat.js +1 -1
  26. package/dist/chip.d.ts +1 -1
  27. package/dist/chip.js +1 -1
  28. package/dist/{chunk-SNSQLGGS.js → chunk-5VZ37TY3.js} +1 -1
  29. package/dist/{chunk-XWJDBQU7.js.map → chunk-5VZ37TY3.js.map} +1 -1
  30. package/dist/{chunk-MTVX4RRF.js → chunk-HP7BDMVK.js} +11 -3
  31. package/dist/chunk-HP7BDMVK.js.map +1 -0
  32. package/dist/{chunk-PK3L6WQT.js → chunk-LNAAWT4Y.js} +4 -2
  33. package/dist/{chunk-PK3L6WQT.js.map → chunk-LNAAWT4Y.js.map} +1 -1
  34. package/dist/{chunk-UIP3WX5O.js → chunk-MDSP7DJR.js} +2 -2
  35. package/dist/chunk-MDSP7DJR.js.map +1 -0
  36. package/dist/{chunk-IEGTRCDI.js → chunk-NQENOT6L.js} +2 -2
  37. package/dist/{chunk-IEGTRCDI.js.map → chunk-NQENOT6L.js.map} +1 -1
  38. package/dist/{chunk-FM42KOAU.js → chunk-P7AFIKWG.js} +5 -3
  39. package/dist/chunk-P7AFIKWG.js.map +1 -0
  40. package/dist/{chunk-BCD2CRFG.js → chunk-PJNR4NTS.js} +2 -2
  41. package/dist/chunk-PJNR4NTS.js.map +1 -0
  42. package/dist/{chunk-ZFR6ZNXD.js → chunk-PVQ2KKPZ.js} +1 -1
  43. package/dist/chunk-PVQ2KKPZ.js.map +1 -0
  44. package/dist/{chunk-U4XTZMB7.js → chunk-QA3WETWT.js} +1 -1
  45. package/dist/{chunk-U4XTZMB7.js.map → chunk-QA3WETWT.js.map} +1 -1
  46. package/dist/{chunk-YXETEQQJ.js → chunk-SG2RKUVJ.js} +2 -2
  47. package/dist/{chunk-EOWV6BNQ.js → chunk-TXFX4PMN.js} +4 -2
  48. package/dist/{chunk-EOWV6BNQ.js.map → chunk-TXFX4PMN.js.map} +1 -1
  49. package/dist/{chunk-XWJDBQU7.js → chunk-V5RO6JYI.js} +1 -1
  50. package/dist/{chunk-SNSQLGGS.js.map → chunk-V5RO6JYI.js.map} +1 -1
  51. package/dist/chunk-VZ6ZALIJ.js +13 -0
  52. package/dist/chunk-VZ6ZALIJ.js.map +1 -0
  53. package/dist/{chunk-2DHL7NJW.js → chunk-XVRKKYWU.js} +5 -3
  54. package/dist/{chunk-2DHL7NJW.js.map → chunk-XVRKKYWU.js.map} +1 -1
  55. package/dist/{chunk-CDNOT2KR.js → chunk-YTYNKMNS.js} +1 -1
  56. package/dist/chunk-YTYNKMNS.js.map +1 -0
  57. package/dist/code-block.js.map +1 -1
  58. package/dist/combobox.js +2 -2
  59. package/dist/copy-button.js +2 -2
  60. package/dist/copy-button.js.map +1 -1
  61. package/dist/data-table.js +3 -3
  62. package/dist/desktop-window.d.ts +1 -1
  63. package/dist/desktop-window.js +3 -1
  64. package/dist/desktop-window.js.map +1 -1
  65. package/dist/drop-overlay.js +8 -8
  66. package/dist/drop-overlay.js.map +1 -1
  67. package/dist/elephant.d.ts +1 -1
  68. package/dist/elephant.js.map +1 -1
  69. package/dist/embed-facade.d.ts +1 -1
  70. package/dist/embed-facade.js +3 -1
  71. package/dist/embed-facade.js.map +1 -1
  72. package/dist/engine-flow.js +7 -2
  73. package/dist/engine-flow.js.map +1 -1
  74. package/dist/entity-header.js +9 -3
  75. package/dist/entity-header.js.map +1 -1
  76. package/dist/file-upload.d.ts +1 -1
  77. package/dist/file-upload.js.map +1 -1
  78. package/dist/filter-bar.d.ts +4 -4
  79. package/dist/filter-bar.js +2 -2
  80. package/dist/flock.js +9 -6
  81. package/dist/flock.js.map +1 -1
  82. package/dist/form.d.ts +3 -3
  83. package/dist/form.js.map +1 -1
  84. package/dist/genui.js +3 -3
  85. package/dist/glossary-term.d.ts +1 -1
  86. package/dist/glossary-term.js.map +1 -1
  87. package/dist/glossary.d.ts +1 -1
  88. package/dist/glossary.js.map +1 -1
  89. package/dist/identity-card.js +1 -1
  90. package/dist/index.js +1 -1
  91. package/dist/kind-config-editor.d.ts +2 -2
  92. package/dist/kind-config-editor.js +1 -1
  93. package/dist/kind-config-editor.js.map +1 -1
  94. package/dist/kpi-explained.d.ts +1 -1
  95. package/dist/kpi-explained.js +4 -4
  96. package/dist/kpi-explained.js.map +1 -1
  97. package/dist/landing-page.d.ts +10 -3
  98. package/dist/landing-page.js +8 -6
  99. package/dist/landing-page.js.map +1 -1
  100. package/dist/{lightbox-Q45BZ3HW.js → lightbox-MRB2YZEP.js} +1 -1
  101. package/dist/lightbox-MRB2YZEP.js.map +1 -0
  102. package/dist/map/cards.js +4 -2
  103. package/dist/map/cards.js.map +1 -1
  104. package/dist/map/pin.js +2 -1
  105. package/dist/map/pin.js.map +1 -1
  106. package/dist/map.d.ts +1 -1
  107. package/dist/map.js.map +1 -1
  108. package/dist/mascot-quote.js +1 -1
  109. package/dist/mascot-state.js +1 -1
  110. package/dist/mascots.js +1 -1
  111. package/dist/match-dialog.js +1 -1
  112. package/dist/motion.d.ts +1 -1
  113. package/dist/motion.js.map +1 -1
  114. package/dist/native/form.d.ts +3 -3
  115. package/dist/native/form.js.map +1 -1
  116. package/dist/native/markdown.d.ts +1 -1
  117. package/dist/native/markdown.js.map +1 -1
  118. package/dist/native/vertical-video.js.map +1 -1
  119. package/dist/native.d.ts +12 -12
  120. package/dist/native.js +12 -7
  121. package/dist/native.js.map +1 -1
  122. package/dist/nav-bar.d.ts +2 -2
  123. package/dist/nav-bar.js +1 -1
  124. package/dist/nav-bar.js.map +1 -1
  125. package/dist/next-actions.d.ts +1 -1
  126. package/dist/next-actions.js.map +1 -1
  127. package/dist/notification-preferences.d.ts +1 -1
  128. package/dist/notification-preferences.js +5 -2
  129. package/dist/notification-preferences.js.map +1 -1
  130. package/dist/page-index.js +2 -2
  131. package/dist/page-index.js.map +1 -1
  132. package/dist/product-page.js +4 -4
  133. package/dist/product-page.js.map +1 -1
  134. package/dist/promo-code-field.d.ts +1 -1
  135. package/dist/promo-code-field.js.map +1 -1
  136. package/dist/qr-code.d.ts +1 -1
  137. package/dist/qr-code.js +1 -1
  138. package/dist/rail-nav.js +3 -3
  139. package/dist/rail-nav.js.map +1 -1
  140. package/dist/retro-tv.d.ts +1 -1
  141. package/dist/retro-tv.js.map +1 -1
  142. package/dist/reviews.d.ts +2 -2
  143. package/dist/reviews.js.map +1 -1
  144. package/dist/router.d.ts +1 -1
  145. package/dist/router.js +8 -8
  146. package/dist/router.js.map +1 -1
  147. package/dist/{schema-DgjBz7-8.d.ts → schema-Dd05m48Q.d.ts} +8 -8
  148. package/dist/service-card.js +22 -13
  149. package/dist/service-card.js.map +1 -1
  150. package/dist/settings-layout.js +1 -1
  151. package/dist/shop/booking.js.map +1 -1
  152. package/dist/shop/gallery.js +7 -6
  153. package/dist/shop/gallery.js.map +1 -1
  154. package/dist/shop/hero.js.map +1 -1
  155. package/dist/shop/look.d.ts +2 -2
  156. package/dist/shop/look.js +1 -1
  157. package/dist/shop/look.js.map +1 -1
  158. package/dist/shop/map-gate.d.ts +1 -1
  159. package/dist/shop/map-gate.js +2 -2
  160. package/dist/shop/map-gate.js.map +1 -1
  161. package/dist/shop/services.js.map +1 -1
  162. package/dist/shop-composer.d.ts +10 -10
  163. package/dist/shop-composer.js +27 -14
  164. package/dist/shop-composer.js.map +1 -1
  165. package/dist/shop-gallery.js +1 -1
  166. package/dist/shop.d.ts +2 -2
  167. package/dist/shop.js +2 -2
  168. package/dist/shop.js.map +1 -1
  169. package/dist/signature.js +2 -1
  170. package/dist/signature.js.map +1 -1
  171. package/dist/site-cahier.js +7 -3
  172. package/dist/site-cahier.js.map +1 -1
  173. package/dist/site-footer.js +6 -2
  174. package/dist/site-footer.js.map +1 -1
  175. package/dist/slot-picker.js +5 -2
  176. package/dist/slot-picker.js.map +1 -1
  177. package/dist/stat.js +1 -1
  178. package/dist/status-chip.d.ts +1 -1
  179. package/dist/status-chip.js.map +1 -1
  180. package/dist/tabs.js.map +1 -1
  181. package/dist/tag-input.js +2 -2
  182. package/dist/tag-selector.js +1 -1
  183. package/dist/text-style.js +4 -3
  184. package/dist/text-style.js.map +1 -1
  185. package/dist/usage.js +8 -3
  186. package/dist/usage.js.map +1 -1
  187. package/dist/versus-card.js +1 -1
  188. package/dist/versus-card.js.map +1 -1
  189. package/dist/vertical-video.js +1 -1
  190. package/dist/vertical-video.js.map +1 -1
  191. package/dist/wall.d.ts +4 -4
  192. package/dist/wall.js +1 -1
  193. package/dist/wall.js.map +1 -1
  194. package/package.json +6 -6
  195. package/registry/account-menu.json +1 -1
  196. package/registry/account-settings.json +2 -2
  197. package/registry/agenda.json +1 -1
  198. package/registry/analysis-report.json +2 -2
  199. package/registry/app-frame.json +3 -3
  200. package/registry/app-header.json +1 -1
  201. package/registry/avatar.json +1 -1
  202. package/registry/badge.json +2 -2
  203. package/registry/bird-plate.json +1 -1
  204. package/registry/chapter.json +1 -1
  205. package/registry/chip.json +1 -1
  206. package/registry/copy-button.json +1 -1
  207. package/registry/data-table.json +1 -1
  208. package/registry/desktop-window.json +1 -1
  209. package/registry/drop-overlay.json +1 -1
  210. package/registry/elephant.json +1 -1
  211. package/registry/embed-facade.json +2 -2
  212. package/registry/engine-flow.json +2 -2
  213. package/registry/entity-header.json +1 -1
  214. package/registry/examples/landing-page/showcase.d.ts +4 -0
  215. package/registry/examples/landing-page/showcase.js +45 -0
  216. package/registry/examples/landing-page/showcase.tsx +42 -0
  217. package/registry/file-upload.json +1 -1
  218. package/registry/filter-bar.json +1 -1
  219. package/registry/flock.json +2 -2
  220. package/registry/form.json +7 -7
  221. package/registry/glossary-term.json +1 -1
  222. package/registry/glossary.json +1 -1
  223. package/registry/index.json +19 -10
  224. package/registry/kind-config-editor.json +1 -1
  225. package/registry/kpi-explained.json +1 -1
  226. package/registry/landing-page.json +61 -21
  227. package/registry/map.json +4 -4
  228. package/registry/mascot-state.json +1 -1
  229. package/registry/mascots.json +2 -2
  230. package/registry/nav-bar.json +4 -4
  231. package/registry/next-actions.json +1 -1
  232. package/registry/notification-preferences.json +1 -1
  233. package/registry/page-index.json +1 -1
  234. package/registry/page.json +4 -0
  235. package/registry/product-page.json +1 -1
  236. package/registry/promo-code-field.json +1 -1
  237. package/registry/qr-code.json +2 -2
  238. package/registry/rail-nav.json +3 -3
  239. package/registry/retro-tv.json +1 -1
  240. package/registry/reviews.json +1 -1
  241. package/registry/router.json +1 -1
  242. package/registry/service-card.json +1 -1
  243. package/registry/settings-layout.json +1 -1
  244. package/registry/shop-composer.json +7 -7
  245. package/registry/shop-gallery.json +1 -1
  246. package/registry/shop.json +11 -11
  247. package/registry/signature.json +1 -1
  248. package/registry/site-cahier.json +1 -1
  249. package/registry/site-footer.json +3 -3
  250. package/registry/slot-picker.json +1 -1
  251. package/registry/stat.json +1 -1
  252. package/registry/status-chip.json +1 -1
  253. package/registry/tabs.json +1 -1
  254. package/registry/text-style.json +1 -1
  255. package/registry/usage.json +2 -2
  256. package/registry/versus-card.json +1 -1
  257. package/registry/vertical-video.json +1 -1
  258. package/registry/wall.json +5 -5
  259. package/registry/waveform.json +2 -2
  260. package/dist/chunk-BCD2CRFG.js.map +0 -1
  261. package/dist/chunk-CDNOT2KR.js.map +0 -1
  262. package/dist/chunk-FM42KOAU.js.map +0 -1
  263. package/dist/chunk-MTVX4RRF.js.map +0 -1
  264. package/dist/chunk-UIP3WX5O.js.map +0 -1
  265. package/dist/chunk-ZFR6ZNXD.js.map +0 -1
  266. package/dist/lightbox-Q45BZ3HW.js.map +0 -1
  267. /package/dist/{chunk-YXETEQQJ.js.map → chunk-SG2RKUVJ.js.map} +0 -0
@@ -480,7 +480,7 @@
480
480
  },
481
481
  {
482
482
  "path": "app-header/search/search.tsx",
483
- "content": "// Client (a global shortcut). The top bar's search trigger: a field-like button (the glyph, the label, ⌘K) from `md`, an\n// icon below. It does not search: it opens the host's palette (`CommandDialog` of @krizaka/ui/command) — on a click, on\n// Enter, and on ⌘K / Ctrl+K from anywhere on the page.\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { SearchGlyph } from \"../../glyphs\";\nimport { Kbd } from \"../../kbd/kbd\";\n\nexport const appHeaderSearch = tv({\n slots: {\n root:\n \"inline-flex h-9 w-9 shrink-0 items-center justify-center gap-2 rounded-lg text-fg-secondary transition-colors \" +\n \"hover:bg-surface-2 hover:text-fg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none \" +\n \"md:w-56 md:justify-start md:border md:border-border-default md:bg-surface-2/60 md:px-3 md:text-xs md:hover:border-border-strong lg:w-72\",\n glyph: \"h-5 w-5 shrink-0 md:h-4 md:w-4\",\n // Hidden on a phone, still the button's name there (sr-only), so the name is the same at every width.\n label: \"sr-only md:not-sr-only md:flex-1 md:truncate md:text-left\",\n keys: \"ml-auto hidden shrink-0 items-center gap-0.5 lg:flex\",\n },\n});\nconst s = appHeaderSearch();\n\nconst isApple = () => typeof navigator !== \"undefined\" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);\n\n/** Whether a keydown is the shortcut: ⌘ or Ctrl with the key, no Alt. */\nexport function isSearchShortcut(event: Pick<KeyboardEvent, \"key\" | \"metaKey\" | \"ctrlKey\" | \"altKey\">, key: string): boolean {\n return event.key.toLowerCase() === key.toLowerCase() && (event.metaKey || event.ctrlKey) && !event.altKey;\n}\n\nexport type AppHeaderSearchProps = Omit<React.ComponentProps<\"button\">, \"children\" | \"onClick\"> & {\n /** What it searches (« Search files and checks ») — passed translated: the field's words from `md`, the button's name at every width. */\n label: string;\n /** Opens the palette: a click, Enter, and the shortcut. */\n onOpen: () => void;\n /**\n * The shortcut's key with ⌘ (Apple) or Ctrl (elsewhere), global to the page; `false` for none. One per page.\n * @default \"k\"\n */\n shortcut?: string | false;\n};\n\n/** The top bar's search trigger: a field from `md`, an icon below; it opens the host's palette, also on ⌘K. */\nexport function AppHeaderSearch({ label, onOpen, shortcut = \"k\", className, type, ...props }: AppHeaderSearchProps) {\n const [apple, setApple] = React.useState(true);\n const open = React.useRef(onOpen);\n React.useEffect(() => {\n open.current = onOpen;\n }, [onOpen]);\n\n React.useEffect(() => {\n if (!shortcut) return;\n // eslint-disable-next-line react-hooks/set-state-in-effect -- the platform is only known in the browser (no hydration mismatch)\n setApple(isApple());\n const onKey = (event: KeyboardEvent) => {\n if (!isSearchShortcut(event, shortcut)) return;\n event.preventDefault();\n open.current();\n };\n window.addEventListener(\"keydown\", onKey);\n return () => window.removeEventListener(\"keydown\", onKey);\n }, [shortcut]);\n\n const key = shortcut ? shortcut.toUpperCase() : null;\n return (\n <button\n type={type ?? \"button\"}\n aria-haspopup=\"dialog\"\n aria-keyshortcuts={key ? `Meta+${key} Control+${key}` : undefined}\n {...props}\n onClick={() => onOpen()}\n className={s.root({ className })}\n >\n <SearchGlyph className={s.glyph()} />\n <span className={s.label()}>{label}</span>\n {key && (\n <span aria-hidden className={s.keys()}>\n <Kbd size=\"sm\">{apple ? \"⌘\" : \"Ctrl\"}</Kbd>\n <Kbd size=\"sm\">{key}</Kbd>\n </span>\n )}\n </button>\n );\n}\n"
483
+ "content": "// Client (a global shortcut). The top bar's search trigger: a field-like button (the glyph, the label, ⌘K) from `md`, an\n// icon below. It does not search: it opens the host's palette (`CommandDialog` of @krizaka/ui/command) — on a click, on\n// Enter, and on ⌘K / Ctrl+K from anywhere on the page.\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { SearchGlyph } from \"../../glyphs\";\nimport { Kbd } from \"../../kbd/kbd\";\n\nexport const appHeaderSearch = tv({\n slots: {\n root:\n \"inline-flex h-9 w-9 shrink-0 items-center justify-center gap-2 rounded-lg text-fg-secondary transition-colors \" +\n \"hover:bg-surface-2 hover:text-fg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none \" +\n \"md:w-56 md:justify-start md:border md:border-border-default md:bg-surface-2/60 md:px-3 md:text-xs md:hover:border-border-strong lg:w-72\",\n glyph: \"h-5 w-5 shrink-0 md:h-4 md:w-4\",\n // Hidden on a phone, still the button's name there (sr-only), so the name is the same at every width.\n label: \"sr-only md:not-sr-only md:flex-1 md:truncate md:text-left\",\n keys: \"ml-auto hidden shrink-0 items-center gap-0.5 lg:flex\",\n },\n});\nconst s = appHeaderSearch();\n\nconst isApple = () => typeof navigator !== \"undefined\" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);\n\n/** Whether a keydown is the shortcut: ⌘ or Ctrl with the key, no Alt. */\nexport function isSearchShortcut(event: Pick<KeyboardEvent, \"key\" | \"metaKey\" | \"ctrlKey\" | \"altKey\">, key: string): boolean {\n return event.key.toLowerCase() === key.toLowerCase() && (event.metaKey || event.ctrlKey) && !event.altKey;\n}\n\nexport type AppHeaderSearchProps = Omit<React.ComponentProps<\"button\">, \"children\" | \"onClick\"> & {\n /** What it searches (« Search files and checks ») — passed translated: the field's words from `md`, the button's name at every width. */\n label: string;\n /** Opens the palette: a click, Enter, and the shortcut. */\n onOpen: () => void;\n /**\n * The shortcut's key with ⌘ (Apple) or Ctrl (elsewhere), global to the page; `false` for none. One per page.\n * @default \"k\"\n */\n shortcut?: string | false;\n};\n\n/** The top bar's search trigger: a field from `md`, an icon below; it opens the host's palette, also on ⌘K. */\nexport function AppHeaderSearch({ label, onOpen, shortcut = \"k\", className, type, ...props }: AppHeaderSearchProps) {\n const [apple, setApple] = React.useState(true);\n const open = React.useRef(onOpen);\n React.useEffect(() => {\n open.current = onOpen;\n }, [onOpen]);\n\n React.useEffect(() => {\n if (!shortcut) return;\n // eslint-disable-next-line react-hooks/set-state-in-effect -- the platform is only known in the browser (no hydration mismatch)\n setApple(isApple());\n const onKey = (event: KeyboardEvent) => {\n if (!isSearchShortcut(event, shortcut)) return;\n event.preventDefault();\n open.current();\n };\n globalThis.addEventListener(\"keydown\", onKey);\n return () => globalThis.removeEventListener(\"keydown\", onKey);\n }, [shortcut]);\n\n const key = shortcut ? shortcut.toUpperCase() : null;\n return (\n <button\n type={type ?? \"button\"}\n aria-haspopup=\"dialog\"\n aria-keyshortcuts={key ? `Meta+${key} Control+${key}` : undefined}\n {...props}\n onClick={() => onOpen()}\n className={s.root({ className })}\n >\n <SearchGlyph className={s.glyph()} />\n <span className={s.label()}>{label}</span>\n {key && (\n <span aria-hidden className={s.keys()}>\n <Kbd size=\"sm\">{apple ? \"⌘\" : \"Ctrl\"}</Kbd>\n <Kbd size=\"sm\">{key}</Kbd>\n </span>\n )}\n </button>\n );\n}\n"
484
484
  },
485
485
  {
486
486
  "path": "glyphs.tsx",
@@ -460,7 +460,7 @@
460
460
  },
461
461
  {
462
462
  "path": "avatar/default-avatar.ts",
463
- "content": "// The default profile pictures of the Krizaka family: what a product shows when a person has no photo.\n// They are generated from this file (tools/export-brand.mjs renders them to SVG and WebP and uploads them to Bunny,\n// `people/defaults/v1/<brand>/…`), so the pictures and the URLs that name them cannot drift apart.\n\n/** A brand of the default avatars. */\nexport type DefaultAvatarBrand = \"krizaka\" | \"sovkora\" | \"verikora\" | \"folioviv\";\n/**\n * What the picture is of. `person`: a neutral silhouette. `plain`: the brand's gradient alone, ready for initials.\n * `folder`, `organisation` and `shop` are the pictures of a thing that is not a person (a folder or collection, a company, a shop):\n * a glyph on the gradient, never a silhouette. The central sets of these kinds are in the Krizaka org JSON (`defaults`, `@krizaka/org`).\n */\nexport type DefaultAvatarKind = \"person\" | \"plain\" | \"folder\" | \"organisation\" | \"shop\";\n/** The kinds of entity that have a set of default pictures of their own (`plain` is a style of `person`). */\nexport type DefaultAvatarEntityKind = \"person\" | \"folder\" | \"organisation\" | \"shop\";\nexport type DefaultAvatarSize = 256 | 512;\n\nexport const DEFAULT_AVATAR_BRANDS: readonly DefaultAvatarBrand[] = [\"krizaka\", \"sovkora\", \"verikora\", \"folioviv\"];\n/** The two styles of the legacy brand sets (`people/defaults/v1/<brand>`); the kinds of the central sets are `DEFAULT_AVATAR_ENTITY_KINDS`. */\nexport const DEFAULT_AVATAR_KINDS: readonly DefaultAvatarKind[] = [\"person\", \"plain\"];\nexport const DEFAULT_AVATAR_ENTITY_KINDS: readonly DefaultAvatarEntityKind[] = [\"person\", \"folder\", \"organisation\", \"shop\"];\nexport const DEFAULT_AVATAR_SIZES: readonly DefaultAvatarSize[] = [256, 512];\n/** How many tones each brand has: a person always gets the same one from their seed, so a list is not one colour. */\n// @fixed: the number of tone files drawn per brand in the published set (`people/defaults/v1/<brand>/person-<1..6>`)\nexport const DEFAULT_AVATAR_TONES = 6;\n\n/** Where the set lives. `v1` is the set's version: a changed picture is a new version folder, never an overwrite. */\nexport const DEFAULT_AVATAR_BASE = \"https://krizaka-assets.b-cdn.net/people/defaults/v1\";\n\nexport interface DefaultAvatar {\n /** The brand of the product showing the avatar: its gradient, its hues. */\n brand: DefaultAvatarBrand;\n /** Any stable text or number of the person (their id): the same seed gives the same tone everywhere. */\n seed?: string | number;\n /** Force a tone, 1 to 6, instead of deriving it from `seed`. */\n tone?: number;\n /**\n * `person` (default): a silhouette. `plain`: the gradient alone. `folder`, `organisation`, `shop`: that thing's glyph, drawn here\n * (a data URL, no request) — a folder is never given a person.\n * @default \"person\"\n */\n kind?: DefaultAvatarKind;\n /**\n * The family's central set (`listDefaults(\"person\")` of `@krizaka/org`): when given with a `seed`, the avatar is the set's picture for that seed —\n * the same person has the same picture in every product — instead of the brand's silhouette. An empty set, or no seed, draws the silhouette.\n */\n set?: readonly DefaultAvatarPicture[];\n}\n\n/** The mark gradient of each brand (BRAND.md, `$extensions[\"com.krizaka\"].mark`) as [hue, saturation %, lightness %] and the hue spread of its tones. */\nconst BRANDS: Record<DefaultAvatarBrand, { from: [number, number, number]; to: [number, number, number]; spread: number }> = {\n krizaka: { from: [217, 92, 53], to: [217, 92, 68], spread: 14 },\n sovkora: { from: [26, 90.5, 37.1], to: [26, 92, 45], spread: 7 },\n verikora: { from: [232, 50, 55], to: [248, 50, 58], spread: 10 },\n folioviv: { from: [140, 48, 34], to: [22, 60, 46], spread: 10 },\n};\n\n/** White on top of a stop must stay visible: a stop is darkened until the contrast reaches this (WCAG 1.4.11, non-text). */\nconst MIN_CONTRAST = 3.2;\nconst OFFSETS = [0, -1, 1, -2, 2, 3] as const;\n\nfunction hslToHex([h, s, l]: [number, number, number]): string {\n const sat = s / 100;\n const light = l / 100;\n const k = (n: number) => (n + (((h % 360) + 360) % 360) / 30) % 12;\n const a = sat * Math.min(light, 1 - light);\n const channel = (n: number) => Math.round(255 * (light - a * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1))));\n return `#${[0, 8, 4].map((n) => channel(n).toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\nconst channelLuminance = (v: number) => (v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\nconst whiteContrast = (hex: string) => {\n const [r, g, b] = [1, 3, 5].map((i) => channelLuminance(Number.parseInt(hex.slice(i, i + 2), 16) / 255));\n return 1.05 / (0.2126 * r! + 0.7152 * g! + 0.0722 * b! + 0.05);\n};\n/** The stop, darkened one point of lightness at a time until white reads on it. */\nfunction readable([h, s, l]: [number, number, number]): string {\n let hex = hslToHex([h, s, l]);\n for (let light = l; whiteContrast(hex) < MIN_CONTRAST && light > 10; light -= 1) hex = hslToHex([h, s, light]);\n return hex;\n}\n\n/** The two stops (hex) of tone `tone` (1 to 6) of a brand. */\nexport function defaultAvatarTone(brand: DefaultAvatarBrand, tone: number): readonly [string, string] {\n const b = BRANDS[brand];\n const o = OFFSETS[(clampTone(tone) - 1) % OFFSETS.length] * b.spread;\n return [readable([b.from[0] + o, b.from[1], b.from[2]]), readable([b.to[0] + o, b.to[1], b.to[2]])];\n}\n\nconst clampTone = (tone: number) => Math.min(DEFAULT_AVATAR_TONES, Math.max(1, Math.round(tone)));\n\n/** 32-bit FNV-1a of a seed: the rule of the family's default pictures (`@krizaka/org`'s `seedHash` is the same function). */\nexport function defaultAvatarSeedHash(seed: string | number): number {\n let h = 0x811c9dc5;\n for (const ch of String(seed)) {\n h ^= ch.codePointAt(0)!;\n h = Math.imul(h, 0x01000193) >>> 0;\n }\n return h;\n}\n\n/** 1 to 6 from a seed (FNV-1a): stable across renders, devices and products. */\nexport function defaultAvatarToneOf(seed: string | number | undefined): number {\n if (seed === undefined) return 1;\n return (defaultAvatarSeedHash(seed) % DEFAULT_AVATAR_TONES) + 1;\n}\n\n/**\n * One picture of the family's central set, as `@krizaka/org` lists it (`listDefaults(\"person\")` items fit as they are): the sizes it is served in.\n * `disabled` pictures are never picked.\n */\nexport interface DefaultAvatarPicture {\n id: string;\n disabled?: boolean;\n urls: { webp: Readonly<Record<string, string>> };\n}\n\n/** The picture a seed gets from a set: `set[fnv1a(seed) mod n]` among the pictures not disabled, in the set's order — the same rule as `@krizaka/org`'s `defaultFor`. */\nexport function pickDefaultPicture<T extends DefaultAvatarPicture>(set: readonly T[], seed: string | number): T | undefined {\n const usable = set.filter((picture) => !picture.disabled);\n return usable[defaultAvatarSeedHash(seed) % usable.length];\n}\n\nconst resolveTone = (a: DefaultAvatar) => (a.tone === undefined ? defaultAvatarToneOf(a.seed) : clampTone(a.tone));\n\n/** The file name of a picture in the set: `person-3` + 256 → `person-3-256.webp`; `svg` has no size. */\nexport function defaultAvatarFile(kind: DefaultAvatarKind, tone: number, size: DefaultAvatarSize | \"svg\"): string {\n return size === \"svg\" ? `${kind}-${tone}.svg` : `${kind}-${tone}-${size}.webp`;\n}\n\n/** Linear on purpose: a `/\\/+$/` regex backtracks quadratically on a long run of slashes. */\nfunction trimTrailingSlashes(value: string): string {\n let end = value.length;\n while (end > 0 && value[end - 1] === \"/\") end--;\n return value.slice(0, end);\n}\n\n/**\n * The URL of a default avatar: `defaultAvatarUrl({ brand: \"sovkora\", seed: user.id })`.\n * @param size 256 for lists, 512 for a profile; `\"svg\"` for the vector.\n * @param base Another host or version of the set (a self-hosted copy); the default is the Krizaka CDN.\n */\nexport function defaultAvatarUrl(avatar: DefaultAvatar, { size = 256, base = DEFAULT_AVATAR_BASE }: { size?: DefaultAvatarSize | \"svg\"; base?: string } = {}): string {\n if (isGlyphKind(avatar.kind)) return defaultAvatarDataUrl(avatar);\n if (avatar.set && avatar.seed !== undefined) {\n // The size asked, as the set serves it (256 and 512; the vector has none, so it stays the brand's silhouette).\n const picked = pickDefaultPicture(avatar.set, avatar.seed)?.urls.webp[size];\n if (picked) return picked;\n }\n return `${trimTrailingSlashes(base)}/${avatar.brand}/${defaultAvatarFile(avatar.kind ?? \"person\", resolveTone(avatar), size)}`;\n}\n\nconst GLYPHS: Record<\"folder\" | \"organisation\" | \"shop\", (from: string) => string> = {\n folder: () => `<path d=\"M96 176a28 28 0 0 1 28-28h92l40 44h132a28 28 0 0 1 28 28v152a28 28 0 0 1-28 28H124a28 28 0 0 1-28-28z\" fill=\"#fff\" fill-opacity=\".92\"/>`,\n organisation: (from) =>\n `<rect x=\"136\" y=\"104\" width=\"240\" height=\"304\" rx=\"16\" fill=\"#fff\" fill-opacity=\".92\"/>${[160, 226, 292]\n .flatMap((y) => [168, 236, 304].map((x) => `<rect x=\"${x}\" y=\"${y}\" width=\"40\" height=\"40\" rx=\"6\" fill=\"${from}\"/>`))\n .join(\"\")}<rect x=\"232\" y=\"352\" width=\"48\" height=\"56\" rx=\"6\" fill=\"${from}\"/>`,\n shop: (from) =>\n `<path d=\"M112 132h288l24 84a56 56 0 0 1-112 0 56 56 0 0 1-112 0 56 56 0 0 1-112 0z\" fill=\"#fff\" fill-opacity=\".92\"/><rect x=\"136\" y=\"292\" width=\"240\" height=\"116\" rx=\"12\" fill=\"#fff\" fill-opacity=\".92\"/><rect x=\"226\" y=\"326\" width=\"60\" height=\"82\" rx=\"8\" fill=\"${from}\"/><rect x=\"156\" y=\"318\" width=\"48\" height=\"44\" rx=\"6\" fill=\"${from}\"/><rect x=\"308\" y=\"318\" width=\"48\" height=\"44\" rx=\"6\" fill=\"${from}\"/>`,\n};\n\ntype GlyphKind = keyof typeof GLYPHS;\nconst isGlyphKind = (kind: DefaultAvatarKind | undefined): kind is GlyphKind => kind === \"folder\" || kind === \"organisation\" || kind === \"shop\";\n\n/** The picture as a `data:` URL: nothing to fetch, so a folder, an organisation or a shop always has its picture (offline, in a test, before the CDN answers). */\nexport function defaultAvatarDataUrl(avatar: DefaultAvatar): string {\n return `data:image/svg+xml,${encodeURIComponent(defaultAvatarSvg(avatar))}`;\n}\n\n/** The SVG source of a default avatar, 512 × 512 and square (the Avatar clips it round). */\nexport function defaultAvatarSvg(avatar: DefaultAvatar): string {\n const [from, to] = defaultAvatarTone(avatar.brand, resolveTone(avatar));\n const kind = avatar.kind ?? \"person\";\n const person = isGlyphKind(kind)\n ? GLYPHS[kind](from)\n : kind === \"person\"\n ? `<circle cx=\"256\" cy=\"200\" r=\"86\" fill=\"#fff\" fill-opacity=\".92\"/><path d=\"M84 512c0-108 78-182 172-182s172 74 172 182z\" fill=\"#fff\" fill-opacity=\".92\"/>`\n : \"\";\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" width=\"512\" height=\"512\"><defs><linearGradient id=\"g\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stop-color=\"${from}\"/><stop offset=\"1\" stop-color=\"${to}\"/></linearGradient><radialGradient id=\"l\" cx=\".28\" cy=\".18\" r=\".85\"><stop offset=\"0\" stop-color=\"#fff\" stop-opacity=\".24\"/><stop offset=\"1\" stop-color=\"#fff\" stop-opacity=\"0\"/></radialGradient></defs><rect width=\"512\" height=\"512\" fill=\"url(#g)\"/><rect width=\"512\" height=\"512\" fill=\"url(#l)\"/>${person}</svg>`;\n}\n"
463
+ "content": "// The default profile pictures of the Krizaka family: what a product shows when a person has no photo.\n// They are generated from this file (tools/export-brand.mjs renders them to SVG and WebP and uploads them to Bunny,\n// `people/defaults/v1/<brand>/…`), so the pictures and the URLs that name them cannot drift apart.\n\n/** A brand of the default avatars. */\nexport type DefaultAvatarBrand = \"krizaka\" | \"sovkora\" | \"verikora\" | \"folioviv\";\n/**\n * What the picture is of. `person`: a neutral silhouette. `plain`: the brand's gradient alone, ready for initials.\n * `folder`, `organisation` and `shop` are the pictures of a thing that is not a person (a folder or collection, a company, a shop):\n * a glyph on the gradient, never a silhouette. The central sets of these kinds are in the Krizaka org JSON (`defaults`, `@krizaka/org`).\n */\nexport type DefaultAvatarKind = \"person\" | \"plain\" | \"folder\" | \"organisation\" | \"shop\";\n/** The kinds of entity that have a set of default pictures of their own (`plain` is a style of `person`). */\nexport type DefaultAvatarEntityKind = \"person\" | \"folder\" | \"organisation\" | \"shop\";\nexport type DefaultAvatarSize = 256 | 512;\n\nexport const DEFAULT_AVATAR_BRANDS: readonly DefaultAvatarBrand[] = [\"krizaka\", \"sovkora\", \"verikora\", \"folioviv\"];\n/** The two styles of the legacy brand sets (`people/defaults/v1/<brand>`); the kinds of the central sets are `DEFAULT_AVATAR_ENTITY_KINDS`. */\nexport const DEFAULT_AVATAR_KINDS: readonly DefaultAvatarKind[] = [\"person\", \"plain\"];\nexport const DEFAULT_AVATAR_ENTITY_KINDS: readonly DefaultAvatarEntityKind[] = [\"person\", \"folder\", \"organisation\", \"shop\"];\nexport const DEFAULT_AVATAR_SIZES: readonly DefaultAvatarSize[] = [256, 512];\n/** How many tones each brand has: a person always gets the same one from their seed, so a list is not one colour. */\n// @fixed: the number of tone files drawn per brand in the published set (`people/defaults/v1/<brand>/person-<1..6>`)\nexport const DEFAULT_AVATAR_TONES = 6;\n\n/** Where the set lives. `v1` is the set's version: a changed picture is a new version folder, never an overwrite. */\nexport const DEFAULT_AVATAR_BASE = \"https://krizaka-assets.b-cdn.net/people/defaults/v1\";\n\nexport interface DefaultAvatar {\n /** The brand of the product showing the avatar: its gradient, its hues. */\n brand: DefaultAvatarBrand;\n /** Any stable text or number of the person (their id): the same seed gives the same tone everywhere. */\n seed?: string | number;\n /** Force a tone, 1 to 6, instead of deriving it from `seed`. */\n tone?: number;\n /**\n * `person` (default): a silhouette. `plain`: the gradient alone. `folder`, `organisation`, `shop`: that thing's glyph, drawn here\n * (a data URL, no request) — a folder is never given a person.\n * @default \"person\"\n */\n kind?: DefaultAvatarKind;\n /**\n * The family's central set (`listDefaults(\"person\")` of `@krizaka/org`): when given with a `seed`, the avatar is the set's picture for that seed —\n * the same person has the same picture in every product — instead of the brand's silhouette. An empty set, or no seed, draws the silhouette.\n */\n set?: readonly DefaultAvatarPicture[];\n}\n\n/** The mark gradient of each brand (BRAND.md, `$extensions[\"com.krizaka\"].mark`) as [hue, saturation %, lightness %] and the hue spread of its tones. */\nconst BRANDS: Record<DefaultAvatarBrand, { from: [number, number, number]; to: [number, number, number]; spread: number }> = {\n krizaka: { from: [217, 92, 53], to: [217, 92, 68], spread: 14 },\n sovkora: { from: [26, 90.5, 37.1], to: [26, 92, 45], spread: 7 },\n verikora: { from: [232, 50, 55], to: [248, 50, 58], spread: 10 },\n folioviv: { from: [140, 48, 34], to: [22, 60, 46], spread: 10 },\n};\n\n/** White on top of a stop must stay visible: a stop is darkened until the contrast reaches this (WCAG 1.4.11, non-text). */\nconst MIN_CONTRAST = 3.2;\nconst OFFSETS = [0, -1, 1, -2, 2, 3] as const;\n\nfunction hslToHex([h, s, l]: [number, number, number]): string {\n const sat = s / 100;\n const light = l / 100;\n const k = (n: number) => (n + (((h % 360) + 360) % 360) / 30) % 12;\n const a = sat * Math.min(light, 1 - light);\n const channel = (n: number) => Math.round(255 * (light - a * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1))));\n return `#${[0, 8, 4].map((n) => channel(n).toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\nconst channelLuminance = (v: number) => (v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\nconst whiteContrast = (hex: string) => {\n const [r, g, b] = [1, 3, 5].map((i) => channelLuminance(Number.parseInt(hex.slice(i, i + 2), 16) / 255));\n return 1.05 / (0.2126 * r! + 0.7152 * g! + 0.0722 * b! + 0.05);\n};\n/** The stop, darkened one point of lightness at a time until white reads on it. */\nfunction readable([h, s, l]: [number, number, number]): string {\n let hex = hslToHex([h, s, l]);\n for (let light = l; whiteContrast(hex) < MIN_CONTRAST && light > 10; light -= 1) hex = hslToHex([h, s, light]);\n return hex;\n}\n\n/** The two stops (hex) of tone `tone` (1 to 6) of a brand. */\nexport function defaultAvatarTone(brand: DefaultAvatarBrand, tone: number): readonly [string, string] {\n const b = BRANDS[brand];\n const o = OFFSETS[(clampTone(tone) - 1) % OFFSETS.length] * b.spread;\n return [readable([b.from[0] + o, b.from[1], b.from[2]]), readable([b.to[0] + o, b.to[1], b.to[2]])];\n}\n\nconst clampTone = (tone: number) => Math.min(DEFAULT_AVATAR_TONES, Math.max(1, Math.round(tone)));\n\n/** 32-bit FNV-1a of a seed: the rule of the family's default pictures (`@krizaka/org`'s `seedHash` is the same function). */\nexport function defaultAvatarSeedHash(seed: string | number): number {\n let h = 0x811c9dc5;\n for (const ch of String(seed)) {\n h ^= ch.codePointAt(0)!;\n h = Math.imul(h, 0x01000193) >>> 0;\n }\n return h;\n}\n\n/** 1 to 6 from a seed (FNV-1a): stable across renders, devices and products. */\nexport function defaultAvatarToneOf(seed: string | number | undefined): number {\n if (seed === undefined) return 1;\n return (defaultAvatarSeedHash(seed) % DEFAULT_AVATAR_TONES) + 1;\n}\n\n/**\n * One picture of the family's central set, as `@krizaka/org` lists it (`listDefaults(\"person\")` items fit as they are): the sizes it is served in.\n * `disabled` pictures are never picked.\n */\nexport interface DefaultAvatarPicture {\n id: string;\n disabled?: boolean;\n urls: { webp: Readonly<Record<string, string>> };\n}\n\n/** The picture a seed gets from a set: `set[fnv1a(seed) mod n]` among the pictures not disabled, in the set's order — the same rule as `@krizaka/org`'s `defaultFor`. */\nexport function pickDefaultPicture<T extends DefaultAvatarPicture>(set: readonly T[], seed: string | number): T | undefined {\n const usable = set.filter((picture) => !picture.disabled);\n return usable[defaultAvatarSeedHash(seed) % usable.length];\n}\n\nconst resolveTone = (a: DefaultAvatar) => (a.tone === undefined ? defaultAvatarToneOf(a.seed) : clampTone(a.tone));\n\n/** The file name of a picture in the set: `person-3` + 256 → `person-3-256.webp`; `svg` has no size. */\nexport function defaultAvatarFile(kind: DefaultAvatarKind, tone: number, size: DefaultAvatarSize | \"svg\"): string {\n return size === \"svg\" ? `${kind}-${tone}.svg` : `${kind}-${tone}-${size}.webp`;\n}\n\n/** Linear on purpose: a `/\\/+$/` regex backtracks quadratically on a long run of slashes. */\nfunction trimTrailingSlashes(value: string): string {\n let end = value.length;\n while (end > 0 && value[end - 1] === \"/\") end--;\n return value.slice(0, end);\n}\n\n/**\n * The URL of a default avatar: `defaultAvatarUrl({ brand: \"sovkora\", seed: user.id })`.\n * @param size 256 for lists, 512 for a profile; `\"svg\"` for the vector.\n * @param base Another host or version of the set (a self-hosted copy); the default is the Krizaka CDN.\n */\nexport function defaultAvatarUrl(avatar: DefaultAvatar, { size = 256, base = DEFAULT_AVATAR_BASE }: { size?: DefaultAvatarSize | \"svg\"; base?: string } = {}): string {\n if (isGlyphKind(avatar.kind)) return defaultAvatarDataUrl(avatar);\n if (avatar.set && avatar.seed !== undefined) {\n // The size asked, as the set serves it (256 and 512; the vector has none, so it stays the brand's silhouette).\n const picked = pickDefaultPicture(avatar.set, avatar.seed)?.urls.webp[size];\n if (picked) return picked;\n }\n return `${trimTrailingSlashes(base)}/${avatar.brand}/${defaultAvatarFile(avatar.kind ?? \"person\", resolveTone(avatar), size)}`;\n}\n\nconst GLYPHS: Record<\"folder\" | \"organisation\" | \"shop\", (from: string) => string> = {\n folder: () => `<path d=\"M96 176a28 28 0 0 1 28-28h92l40 44h132a28 28 0 0 1 28 28v152a28 28 0 0 1-28 28H124a28 28 0 0 1-28-28z\" fill=\"#fff\" fill-opacity=\".92\"/>`,\n organisation: (from) =>\n `<rect x=\"136\" y=\"104\" width=\"240\" height=\"304\" rx=\"16\" fill=\"#fff\" fill-opacity=\".92\"/>${[160, 226, 292]\n .flatMap((y) => [168, 236, 304].map((x) => `<rect x=\"${x}\" y=\"${y}\" width=\"40\" height=\"40\" rx=\"6\" fill=\"${from}\"/>`))\n .join(\"\")}<rect x=\"232\" y=\"352\" width=\"48\" height=\"56\" rx=\"6\" fill=\"${from}\"/>`,\n shop: (from) =>\n `<path d=\"M112 132h288l24 84a56 56 0 0 1-112 0 56 56 0 0 1-112 0 56 56 0 0 1-112 0z\" fill=\"#fff\" fill-opacity=\".92\"/><rect x=\"136\" y=\"292\" width=\"240\" height=\"116\" rx=\"12\" fill=\"#fff\" fill-opacity=\".92\"/><rect x=\"226\" y=\"326\" width=\"60\" height=\"82\" rx=\"8\" fill=\"${from}\"/><rect x=\"156\" y=\"318\" width=\"48\" height=\"44\" rx=\"6\" fill=\"${from}\"/><rect x=\"308\" y=\"318\" width=\"48\" height=\"44\" rx=\"6\" fill=\"${from}\"/>`,\n};\n\ntype GlyphKind = keyof typeof GLYPHS;\nconst isGlyphKind = (kind: DefaultAvatarKind | undefined): kind is GlyphKind => kind === \"folder\" || kind === \"organisation\" || kind === \"shop\";\n\n/** The picture as a `data:` URL: nothing to fetch, so a folder, an organisation or a shop always has its picture (offline, in a test, before the CDN answers). */\nexport function defaultAvatarDataUrl(avatar: DefaultAvatar): string {\n return `data:image/svg+xml,${encodeURIComponent(defaultAvatarSvg(avatar))}`;\n}\n\n/** The SVG source of a default avatar, 512 × 512 and square (the Avatar clips it round). */\nexport function defaultAvatarSvg(avatar: DefaultAvatar): string {\n const [from, to] = defaultAvatarTone(avatar.brand, resolveTone(avatar));\n const kind = avatar.kind ?? \"person\";\n let person = \"\";\n if (isGlyphKind(kind)) person = GLYPHS[kind](from);\n else if (kind === \"person\") person = `<circle cx=\"256\" cy=\"200\" r=\"86\" fill=\"#fff\" fill-opacity=\".92\"/><path d=\"M84 512c0-108 78-182 172-182s172 74 172 182z\" fill=\"#fff\" fill-opacity=\".92\"/>`;\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" width=\"512\" height=\"512\"><defs><linearGradient id=\"g\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stop-color=\"${from}\"/><stop offset=\"1\" stop-color=\"${to}\"/></linearGradient><radialGradient id=\"l\" cx=\".28\" cy=\".18\" r=\".85\"><stop offset=\"0\" stop-color=\"#fff\" stop-opacity=\".24\"/><stop offset=\"1\" stop-color=\"#fff\" stop-opacity=\"0\"/></radialGradient></defs><rect width=\"512\" height=\"512\" fill=\"url(#g)\"/><rect width=\"512\" height=\"512\" fill=\"url(#l)\"/>${person}</svg>`;\n}\n"
464
464
  },
465
465
  {
466
466
  "path": "avatar/defaults.ts",
@@ -89,7 +89,7 @@
89
89
  },
90
90
  {
91
91
  "name": "tone",
92
- "type": "\"success\" | \"warning\" | \"danger\" | \"neutral\" | \"accent\" | \"scrim\"",
92
+ "type": "\"accent\" | \"success\" | \"warning\" | \"danger\" | \"neutral\" | \"scrim\"",
93
93
  "default": "neutral",
94
94
  "description": "neutral · accent · success · warning · danger (soft tints, the text stays a text role) · scrim (on a media).",
95
95
  "required": false
@@ -299,7 +299,7 @@
299
299
  },
300
300
  {
301
301
  "name": "tone",
302
- "type": "\"success\" | \"warning\" | \"danger\" | \"neutral\" | \"accent\" | \"scrim\"",
302
+ "type": "\"accent\" | \"success\" | \"warning\" | \"danger\" | \"neutral\" | \"scrim\"",
303
303
  "default": "neutral",
304
304
  "description": "neutral · accent · success · warning · danger (soft tints, the text stays a text role) · scrim (on a media).",
305
305
  "required": false
@@ -146,7 +146,7 @@
146
146
  "files": [
147
147
  {
148
148
  "path": "bird-plate/bird-plate.tsx",
149
- "content": "// Client (each bird has an id per instance). The bird plate of the Cahier (ADR-004, blocks.css): the flock drawn as a\n// naturalist's plate — each bird a figure, numbered, a hairline leading from the drawing to its caption, and the\n// caption is the bird's promise as the film says it. The birds are the `Mascot` renders, never redrawn; one bird per\n// subject (the brand reference, §5).\nimport type * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { type MascotBird, type MascotMood, type MascotTone } from \"../mascots/geometry\";\nimport { Mascot } from \"../mascots/mascot\";\n\nexport interface PlateFigure {\n /** The bird. */\n bird: MascotBird;\n /** Its mood. @default \"welcome\" */\n mood?: MascotMood;\n /** `own` — the bird's signature colours (the film's); `brand` — the host's accent. @default \"own\" */\n tone?: MascotTone;\n /** Its name in the caption: `the falcon`. */\n label: React.ReactNode;\n /** Its promise, word for word as the film says it: `keeps watch: security comes first.` */\n promise?: React.ReactNode;\n}\n\nexport type BirdPlateProps = Omit<React.HTMLAttributes<HTMLElement>, \"title\"> & {\n /** The plate's title: `Plate I · The flock`. */\n title?: React.ReactNode;\n /** One line under the title. */\n subtitle?: React.ReactNode;\n /** The figures, in order: each is numbered `fig. n`. */\n figures: readonly PlateFigure[];\n /** The first figure's number (a page that continues a plate). @default 1 */\n start?: number;\n /** The word before the number. @default \"fig.\" */\n figureLabel?: string;\n /** The separator between the figure number and its label. @default \" · \" */\n separator?: string;\n /**\n * `grid` — the figures side by side (two to five); `single` — one large figure, its caption beside it.\n * @default \"grid\"\n */\n layout?: \"grid\" | \"single\";\n /** The birds' idle loops (they pause off screen and stop under reduced motion). @default false */\n animated?: boolean;\n};\n\n/** A naturalist's plate of the flock: numbered figures, a leader line from each bird to its caption, its promise. */\nexport function BirdPlate({ title, subtitle, figures, start = 1, figureLabel = \"fig.\", separator = \" · \", layout = \"grid\", animated = false, className, ...props }: BirdPlateProps) {\n const single = layout === \"single\";\n return (\n <figure className={cn(\"kz-plate\", className)} data-layout={single ? \"single\" : undefined} {...props}>\n {(title || subtitle) && (\n <figcaption className=\"kz-plate-head\">\n {title && <span className=\"kz-plate-title\">{title}</span>}\n {subtitle && <span className=\"kz-plate-sub\">{subtitle}</span>}\n </figcaption>\n )}\n <ol className=\"kz-plate-figures\" start={start}>\n {figures.map((f, i) => (\n <li key={i} className=\"kz-plate-figure\">\n <Mascot bird={f.bird} mood={f.mood ?? \"welcome\"} tone={f.tone ?? \"own\"} size={single ? 168 : 112} animated={animated} className=\"kz-plate-bird\" aria-hidden />\n <p className=\"kz-plate-caption\">\n <b>\n {figureLabel} {start + i}{separator}{f.label}\n </b>\n {f.promise && <span> {f.promise}</span>}\n </p>\n </li>\n ))}\n </ol>\n </figure>\n );\n}\n"
149
+ "content": "// Client (each bird has an id per instance). The bird plate of the Cahier (ADR-004, blocks.css): the flock drawn as a\n// naturalist's plate — each bird a figure, numbered, a hairline leading from the drawing to its caption, and the\n// caption is the bird's promise as the film says it. The birds are the `Mascot` renders, never redrawn; one bird per\n// subject (the brand reference, §5).\nimport type * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { type MascotBird, type MascotMood, type MascotTone } from \"../mascots/geometry\";\nimport { Mascot } from \"../mascots/mascot\";\n\nexport interface PlateFigure {\n /** The bird. */\n bird: MascotBird;\n /** Its mood. @default \"welcome\" */\n mood?: MascotMood;\n /** `own` — the bird's signature colours (the film's); `brand` — the host's accent. @default \"own\" */\n tone?: MascotTone;\n /** Its name in the caption: `the falcon`. */\n label: React.ReactNode;\n /** Its promise, word for word as the film says it: `keeps watch: security comes first.` */\n promise?: React.ReactNode;\n}\n\nexport type BirdPlateProps = Omit<React.HTMLAttributes<HTMLElement>, \"title\"> & {\n /** The plate's title: `Plate I · The flock`. */\n title?: React.ReactNode;\n /** One line under the title. */\n subtitle?: React.ReactNode;\n /** The figures, in order: each is numbered `fig. n`. */\n figures: readonly PlateFigure[];\n /** The first figure's number (a page that continues a plate). @default 1 */\n start?: number;\n /** The word before the number. @default \"fig.\" */\n figureLabel?: string;\n /** The separator between the figure number and its label. @default \" · \" */\n separator?: string;\n /**\n * `grid` — the figures side by side (two to five); `single` — one large figure, its caption beside it.\n * @default \"grid\"\n */\n layout?: \"grid\" | \"single\";\n /** The birds' idle loops (they pause off screen and stop under reduced motion). @default false */\n animated?: boolean;\n};\n\n/** A naturalist's plate of the flock: numbered figures, a leader line from each bird to its caption, its promise. */\nexport function BirdPlate({ title, subtitle, figures, start = 1, figureLabel = \"fig.\", separator = \" · \", layout = \"grid\", animated = false, className, ...props }: BirdPlateProps) {\n const single = layout === \"single\";\n // A figure keys on its bird and on how many figures before it show that bird: unique even when a bird repeats.\n const seen = new Map<string, number>();\n const keys = figures.map((f) => {\n const n = seen.get(f.bird) ?? 0;\n seen.set(f.bird, n + 1);\n return `${f.bird}-${n}`;\n });\n return (\n <figure className={cn(\"kz-plate\", className)} data-layout={single ? \"single\" : undefined} {...props}>\n {(title || subtitle) && (\n <figcaption className=\"kz-plate-head\">\n {title && <span className=\"kz-plate-title\">{title}</span>}\n {subtitle && <span className=\"kz-plate-sub\">{subtitle}</span>}\n </figcaption>\n )}\n <ol className=\"kz-plate-figures\" start={start}>\n {figures.map((f, i) => (\n <li key={keys[i]} className=\"kz-plate-figure\">\n <Mascot bird={f.bird} mood={f.mood ?? \"welcome\"} tone={f.tone ?? \"own\"} size={single ? 168 : 112} animated={animated} className=\"kz-plate-bird\" aria-hidden />\n <p className=\"kz-plate-caption\">\n <b>\n {figureLabel} {start + i}{separator}{f.label}\n </b>\n {f.promise && <span> {f.promise}</span>}\n </p>\n </li>\n ))}\n </ol>\n </figure>\n );\n}\n"
150
150
  },
151
151
  {
152
152
  "path": "bird-plate/index.ts",
@@ -317,7 +317,7 @@
317
317
  },
318
318
  {
319
319
  "path": "chapter/chapter.tsx",
320
- "content": "// Server-safe. The chapters of a story on the Cahier (ADR-004, blocks.css, krizaka-ui#617): a sober timeline, never a\n// stack of boxes. The rows sit on the notebook's ruled lines (`data-paper=\"lines\"`, the ruling of `Page`), the number\n// hangs in the margin beside its red rule (`data-margin`), the serif title is the link, the period is quiet.\n// - `ChapterIndex` — the chapters in reading order, one ruled line each (two at most), the latest marked « New »;\n// - `ChapterHead` — the head of a chapter's page: number in the margin, title, one quiet meta line, the standfirst;\n// - `ChapterFoot` — its foot: the previous and next chapters on the lines, then one line back to the story.\n// No border per row, no card, no button: the paper carries the rhythm. Every word arrives as a prop.\n// `ChapterIndex variant=\"album\"` (#621): each row is the chapter's cover as a `TapedPhoto`, the prints facing each other\n// from left to right, and beside it the same number, title, line and period — light, on the same lines.\nimport type * as React from \"react\";\n\nimport { BlockLink, type LinkComponent } from \"../block-link\";\nimport { cn } from \"../cn\";\nimport { TapedPhoto } from \"../taped-photo\";\n\n/** The notebook under the rows: `lines` (the ruling of `Page`, aligned on the rows) or `false` (the page's own paper). */\ntype ChapterPaper = \"lines\" | false;\n\nexport interface ChapterEntry {\n /** Its number, hung in the margin: `01`, `§ 1`. */\n number: React.ReactNode;\n /** The title, in the serif: the link. */\n title: React.ReactNode;\n /** Where it leads. */\n href: string;\n /** When it happened, quiet on the right (under the title on a phone): `janv. – mars 2026`, or a `<time>`. */\n period?: React.ReactNode;\n /** One more line under the title (what was faced → what was built). Off unless given: the chapter's page says it. */\n detail?: React.ReactNode;\n /** The latest chapter: a small mark after the title, in the hue (`newLabel`). */\n isNew?: boolean;\n /** The page the reader is on. */\n current?: boolean;\n /** Its cover, drawn by the `album` variant as a taped print. Decorative there (`alt=\"\"`): the title carries the link. */\n cover?: ChapterCover;\n}\n\n/** A chapter's cover: its intrinsic size gives the print its aspect-ratio, so nothing shifts while it loads. */\nexport interface ChapterCover {\n src: string;\n width: number;\n height: number;\n srcSet?: string;\n /** @default \"(max-width: 34rem) 60vw, 26rem\" */\n sizes?: string;\n}\n\n/** The covers above the fold load at once; the rest wait for the reader. */\nconst EAGER_COVERS = 2;\n/** The prints face each other: the left one leans left, the right one leans right (TapedPhoto's practice). */\nconst ALBUM_TILT = 1.4;\n\nfunction ChapterPrint({ cover, index }: { cover: ChapterCover; index: number }) {\n return (\n <TapedPhoto className=\"kz-chapter-print\" tilt={index % 2 === 0 ? -ALBUM_TILT : ALBUM_TILT} aria-hidden>\n <img\n src={cover.src}\n srcSet={cover.srcSet}\n sizes={cover.srcSet ? (cover.sizes ?? \"(max-width: 34rem) 60vw, 26rem\") : undefined}\n width={cover.width}\n height={cover.height}\n alt=\"\"\n loading={index < EAGER_COVERS ? \"eager\" : \"lazy\"}\n decoding=\"async\"\n />\n </TapedPhoto>\n );\n}\n\n/** One ruled row: number in the margin, the title as the link (its hit area the whole row), an aside on the right. */\nfunction ChapterRow({\n number,\n title,\n href,\n aside,\n mark,\n detail,\n current,\n rel,\n linkAs,\n}: {\n number?: React.ReactNode;\n title: React.ReactNode;\n href: string;\n aside?: React.ReactNode;\n mark?: React.ReactNode;\n detail?: React.ReactNode;\n current?: boolean;\n rel?: string;\n linkAs?: LinkComponent;\n}) {\n return (\n <>\n <span className=\"kz-chapter-no\">{number}</span>\n <BlockLink href={href} linkAs={linkAs} rel={rel} className=\"kz-chapter-link\" aria-current={current ? \"page\" : undefined}>\n <span className=\"kz-chapter-title\">{title}</span>\n {mark && (\n <>\n {\" \"}\n <span className=\"kz-chapter-new\">{mark}</span>\n </>\n )}\n </BlockLink>\n {aside && (\n <>\n {/* A space, not a margin: in a narrow column the period runs on after the title, and starts flush when it wraps. */}{\" \"}\n <span className=\"kz-chapter-period\">{aside}</span>\n </>\n )}\n {detail && <span className=\"kz-chapter-detail\">{detail}</span>}\n </>\n );\n}\n\nexport type ChapterIndexProps = Omit<React.OlHTMLAttributes<HTMLOListElement>, \"children\"> & {\n /** The chapters, in reading order. */\n chapters: readonly ChapterEntry[];\n /** The word of the latest chapter's mark. @default \"New\" */\n newLabel?: React.ReactNode;\n /** The accessible name of the list, when no heading names it (`aria-labelledby`). */\n label?: string;\n /** The ruling under the rows. `false` when the page is ruled already and the list starts on its module. @default \"lines\" */\n paper?: ChapterPaper;\n /** The app's router link (Next's `Link`), so internal chapters prefetch. */\n linkAs?: LinkComponent;\n /**\n * `lines` — one ruled line per chapter (the compact index); `album` — each chapter's `cover` as a taped print beside\n * its title, its `detail` (one short line) and its period, the rows alternating left and right.\n * @default \"lines\"\n */\n variant?: \"lines\" | \"album\";\n};\n\n/** The chapters of a story as a sober timeline: one ruled line each (or a taped print each), the number in the margin, the title the link. */\nexport function ChapterIndex({ chapters, newLabel = \"New\", label, paper = \"lines\", linkAs, variant = \"lines\", className, ...props }: ChapterIndexProps) {\n const album = variant === \"album\";\n return (\n // `role=\"list\"`: a list without bullets is still a list to VoiceOver.\n <ol\n role=\"list\"\n aria-label={label}\n data-paper={paper || undefined}\n data-margin=\"\"\n data-variant={album ? \"album\" : undefined}\n className={cn(\"kz-chapters\", className)}\n {...props}\n >\n {chapters.map((c, i) => (\n <li key={i} className=\"kz-chapter-row\" data-new={c.isNew ? \"\" : undefined} data-detail={c.detail ? \"\" : undefined}>\n {album && c.cover && <ChapterPrint cover={c.cover} index={i} />}\n <ChapterRow number={c.number} title={c.title} href={c.href} aside={c.period} mark={c.isNew ? newLabel : undefined} detail={c.detail} current={c.current} linkAs={linkAs} />\n </li>\n ))}\n </ol>\n );\n}\n\nexport type ChapterHeadProps = Omit<React.HTMLAttributes<HTMLElement>, \"title\"> & {\n /** The chapter's number, hung in the margin: `01`, `Chapitre 1`. */\n number: React.ReactNode;\n /** The title: the page's `h1`. */\n title: React.ReactNode;\n /** When it happened: `janv. – mars 2026`. */\n period?: React.ReactNode;\n /** How long it reads: `8 min`. */\n readingTime?: React.ReactNode;\n /** What was faced: the first half of the standfirst. */\n faced?: React.ReactNode;\n /** What was built: its second half, after the arrow. */\n built?: React.ReactNode;\n /** The words a screen reader says before each half (the arrow is drawn, not read): `[\"What I faced\", \"What we built\"]`. */\n versusLabels?: readonly [string, string];\n /** The level of the title. @default 1 */\n level?: 1 | 2;\n};\n\n/** The head of a chapter: the number in the margin, the title, the period and the reading time, the standfirst once. */\nexport function ChapterHead({ number, title, period, readingTime, faced, built, versusLabels, level = 1, className, children, ...props }: ChapterHeadProps) {\n const H = level === 1 ? \"h1\" : \"h2\";\n const meta = [period, readingTime].filter((m) => m !== undefined && m !== null && m !== \"\");\n return (\n <header data-margin=\"\" className={cn(\"kz-chapter-head\", className)} {...props}>\n <p className=\"kz-chapter-no\">{number}</p>\n <H className=\"kz-chapter-head-title\">{title}</H>\n {meta.length > 0 && (\n <p className=\"kz-chapter-meta\">\n {meta.map((m, i) => (\n <span key={i}>\n {i > 0 && <span aria-hidden> · </span>}\n {m}\n </span>\n ))}\n </p>\n )}\n {faced && built && (\n <p className=\"kz-chapter-standfirst\">\n {versusLabels && <span className=\"kz-sr-only\">{versusLabels[0]}, </span>}\n {faced}\n <span className=\"kz-chapter-arrow\" aria-hidden>\n {\" → \"}\n </span>\n {versusLabels && <span className=\"kz-sr-only\">; {versusLabels[1]}, </span>}\n {built}\n </p>\n )}\n {children}\n </header>\n );\n}\n\nexport interface ChapterLink {\n /** Its number, in the margin: `02`. */\n number?: React.ReactNode;\n /** Its title, the link. */\n title: React.ReactNode;\n /** Where it leads. */\n href: string;\n}\n\nexport type ChapterFootProps = Omit<React.HTMLAttributes<HTMLElement>, \"children\"> & {\n /** The chapter before this one (none on the first). */\n previous?: ChapterLink;\n /** The chapter after this one (none on the latest). */\n next?: ChapterLink;\n /** The line back to the story: `{ href: \"/\", label: \"Back to the story\" }`. */\n back?: { href: string; label: React.ReactNode };\n /** The quiet words beside each link. @default { previous: \"Previous\", next: \"Next\" } */\n labels?: { previous: React.ReactNode; next: React.ReactNode };\n /** The accessible name of the navigation. @default \"Chapters\" */\n label?: string;\n /** The ruling under the links. @default \"lines\" */\n paper?: ChapterPaper;\n /** The app's router link (Next's `Link`). */\n linkAs?: LinkComponent;\n};\n\n/** The foot of a chapter: the previous and the next on the ruled lines, then one line back to the story. */\nexport function ChapterFoot({\n previous,\n next,\n back,\n labels = { previous: \"Previous\", next: \"Next\" },\n label = \"Chapters\",\n paper = \"lines\",\n linkAs,\n className,\n ...props\n}: ChapterFootProps) {\n return (\n <nav aria-label={label} data-paper={paper || undefined} data-margin=\"\" className={cn(\"kz-chapters kz-chapter-foot\", className)} {...props}>\n <ul role=\"list\">\n {previous && (\n <li className=\"kz-chapter-row\" data-dir=\"previous\">\n <ChapterRow\n number={previous.number}\n title={previous.title}\n href={previous.href}\n rel=\"prev\"\n linkAs={linkAs}\n aside={\n <>\n <span aria-hidden>← </span>\n {labels.previous}\n </>\n }\n />\n </li>\n )}\n {next && (\n <li className=\"kz-chapter-row\" data-dir=\"next\">\n <ChapterRow\n number={next.number}\n title={next.title}\n href={next.href}\n rel=\"next\"\n linkAs={linkAs}\n aside={\n <>\n {labels.next}\n <span aria-hidden> →</span>\n </>\n }\n />\n </li>\n )}\n </ul>\n {back && (\n <p className=\"kz-chapter-back\">\n <BlockLink href={back.href} linkAs={linkAs} className=\"kz-chapter-back-link\">\n <span aria-hidden>↩ </span>\n {back.label}\n </BlockLink>\n </p>\n )}\n </nav>\n );\n}\n"
320
+ "content": "// Server-safe. The chapters of a story on the Cahier (ADR-004, blocks.css, krizaka-ui#617): a sober timeline, never a\n// stack of boxes. The rows sit on the notebook's ruled lines (`data-paper=\"lines\"`, the ruling of `Page`), the number\n// hangs in the margin beside its red rule (`data-margin`), the serif title is the link, the period is quiet.\n// - `ChapterIndex` — the chapters in reading order, one ruled line each (two at most), the latest marked « New »;\n// - `ChapterHead` — the head of a chapter's page: number in the margin, title, one quiet meta line, the standfirst;\n// - `ChapterFoot` — its foot: the previous and next chapters on the lines, then one line back to the story.\n// No border per row, no card, no button: the paper carries the rhythm. Every word arrives as a prop.\n// `ChapterIndex variant=\"album\"` (#621): each row is the chapter's cover as a `TapedPhoto`, the prints facing each other\n// from left to right, and beside it the same number, title, line and period — light, on the same lines.\nimport type * as React from \"react\";\n\nimport { BlockLink, type LinkComponent } from \"../block-link\";\nimport { cn } from \"../cn\";\nimport { TapedPhoto } from \"../taped-photo\";\n\n/** The notebook under the rows: `lines` (the ruling of `Page`, aligned on the rows) or `false` (the page's own paper). */\ntype ChapterPaper = \"lines\" | false;\n\nexport interface ChapterEntry {\n /** Its number, hung in the margin: `01`, `§ 1`. */\n number: React.ReactNode;\n /** The title, in the serif: the link. */\n title: React.ReactNode;\n /** Where it leads. */\n href: string;\n /** When it happened, quiet on the right (under the title on a phone): `janv. – mars 2026`, or a `<time>`. */\n period?: React.ReactNode;\n /** One more line under the title (what was faced → what was built). Off unless given: the chapter's page says it. */\n detail?: React.ReactNode;\n /** The latest chapter: a small mark after the title, in the hue (`newLabel`). */\n isNew?: boolean;\n /** The page the reader is on. */\n current?: boolean;\n /** Its cover, drawn by the `album` variant as a taped print. Decorative there (`alt=\"\"`): the title carries the link. */\n cover?: ChapterCover;\n}\n\n/** A chapter's cover: its intrinsic size gives the print its aspect-ratio, so nothing shifts while it loads. */\nexport interface ChapterCover {\n src: string;\n width: number;\n height: number;\n srcSet?: string;\n /** @default \"(max-width: 34rem) 60vw, 26rem\" */\n sizes?: string;\n}\n\n/** The covers above the fold load at once; the rest wait for the reader. */\nconst EAGER_COVERS = 2;\n/** The prints face each other: the left one leans left, the right one leans right (TapedPhoto's practice). */\nconst ALBUM_TILT = 1.4;\n\nfunction ChapterPrint({ cover, index }: Readonly<{ cover: ChapterCover; index: number }>) {\n return (\n <TapedPhoto className=\"kz-chapter-print\" tilt={index % 2 === 0 ? -ALBUM_TILT : ALBUM_TILT} aria-hidden>\n <img\n src={cover.src}\n srcSet={cover.srcSet}\n sizes={cover.srcSet ? (cover.sizes ?? \"(max-width: 34rem) 60vw, 26rem\") : undefined}\n width={cover.width}\n height={cover.height}\n alt=\"\"\n loading={index < EAGER_COVERS ? \"eager\" : \"lazy\"}\n decoding=\"async\"\n />\n </TapedPhoto>\n );\n}\n\n/** One ruled row: number in the margin, the title as the link (its hit area the whole row), an aside on the right. */\nfunction ChapterRow({\n number,\n title,\n href,\n aside,\n mark,\n detail,\n current,\n rel,\n linkAs,\n}: Readonly<{\n number?: React.ReactNode;\n title: React.ReactNode;\n href: string;\n aside?: React.ReactNode;\n mark?: React.ReactNode;\n detail?: React.ReactNode;\n current?: boolean;\n rel?: string;\n linkAs?: LinkComponent;\n}>) {\n return (\n <>\n <span className=\"kz-chapter-no\">{number}</span>\n <BlockLink href={href} linkAs={linkAs} rel={rel} className=\"kz-chapter-link\" aria-current={current ? \"page\" : undefined}>\n <span className=\"kz-chapter-title\">{title}</span>\n {mark && (\n <>\n {\" \"}\n <span className=\"kz-chapter-new\">{mark}</span>\n </>\n )}\n </BlockLink>\n {aside && (\n <>\n {/* A space, not a margin: in a narrow column the period runs on after the title, and starts flush when it wraps. */}{\" \"}\n <span className=\"kz-chapter-period\">{aside}</span>\n </>\n )}\n {detail && <span className=\"kz-chapter-detail\">{detail}</span>}\n </>\n );\n}\n\nexport type ChapterIndexProps = Omit<React.OlHTMLAttributes<HTMLOListElement>, \"children\"> & {\n /** The chapters, in reading order. */\n chapters: readonly ChapterEntry[];\n /** The word of the latest chapter's mark. @default \"New\" */\n newLabel?: React.ReactNode;\n /** The accessible name of the list, when no heading names it (`aria-labelledby`). */\n label?: string;\n /** The ruling under the rows. `false` when the page is ruled already and the list starts on its module. @default \"lines\" */\n paper?: ChapterPaper;\n /** The app's router link (Next's `Link`), so internal chapters prefetch. */\n linkAs?: LinkComponent;\n /**\n * `lines` — one ruled line per chapter (the compact index); `album` — each chapter's `cover` as a taped print beside\n * its title, its `detail` (one short line) and its period, the rows alternating left and right.\n * @default \"lines\"\n */\n variant?: \"lines\" | \"album\";\n};\n\n/** The chapters of a story as a sober timeline: one ruled line each (or a taped print each), the number in the margin, the title the link. */\nexport function ChapterIndex({ chapters, newLabel = \"New\", label, paper = \"lines\", linkAs, variant = \"lines\", className, ...props }: ChapterIndexProps) {\n const album = variant === \"album\";\n return (\n // `role=\"list\"`: a list without bullets is still a list to VoiceOver.\n <ol\n role=\"list\"\n aria-label={label}\n data-paper={paper || undefined}\n data-margin=\"\"\n data-variant={album ? \"album\" : undefined}\n className={cn(\"kz-chapters\", className)}\n {...props}\n >\n {chapters.map((c, i) => (\n <li key={c.href} className=\"kz-chapter-row\" data-new={c.isNew ? \"\" : undefined} data-detail={c.detail ? \"\" : undefined}>\n {album && c.cover && <ChapterPrint cover={c.cover} index={i} />}\n <ChapterRow number={c.number} title={c.title} href={c.href} aside={c.period} mark={c.isNew ? newLabel : undefined} detail={c.detail} current={c.current} linkAs={linkAs} />\n </li>\n ))}\n </ol>\n );\n}\n\nexport type ChapterHeadProps = Omit<React.HTMLAttributes<HTMLElement>, \"title\"> & {\n /** The chapter's number, hung in the margin: `01`, `Chapitre 1`. */\n number: React.ReactNode;\n /** The title: the page's `h1`. */\n title: React.ReactNode;\n /** When it happened: `janv. – mars 2026`. */\n period?: React.ReactNode;\n /** How long it reads: `8 min`. */\n readingTime?: React.ReactNode;\n /** What was faced: the first half of the standfirst. */\n faced?: React.ReactNode;\n /** What was built: its second half, after the arrow. */\n built?: React.ReactNode;\n /** The words a screen reader says before each half (the arrow is drawn, not read): `[\"What I faced\", \"What we built\"]`. */\n versusLabels?: readonly [string, string];\n /** The level of the title. @default 1 */\n level?: 1 | 2;\n};\n\n/** The head of a chapter: the number in the margin, the title, the period and the reading time, the standfirst once. */\nexport function ChapterHead({ number, title, period, readingTime, faced, built, versusLabels, level = 1, className, children, ...props }: ChapterHeadProps) {\n const H = level === 1 ? \"h1\" : \"h2\";\n const meta = [\n { key: \"period\", value: period },\n { key: \"readingTime\", value: readingTime },\n ].filter((m) => m.value !== undefined && m.value !== null && m.value !== \"\");\n return (\n <header data-margin=\"\" className={cn(\"kz-chapter-head\", className)} {...props}>\n <p className=\"kz-chapter-no\">{number}</p>\n <H className=\"kz-chapter-head-title\">{title}</H>\n {meta.length > 0 && (\n <p className=\"kz-chapter-meta\">\n {meta.map((m, i) => (\n <span key={m.key}>\n {i > 0 && <span aria-hidden> · </span>}\n {m.value}\n </span>\n ))}\n </p>\n )}\n {faced && built && (\n <p className=\"kz-chapter-standfirst\">\n {versusLabels && <span className=\"kz-sr-only\">{versusLabels[0]}, </span>}\n {faced}\n <span className=\"kz-chapter-arrow\" aria-hidden>\n {\" → \"}\n </span>\n {versusLabels && <span className=\"kz-sr-only\">; {versusLabels[1]}, </span>}\n {built}\n </p>\n )}\n {children}\n </header>\n );\n}\n\nexport interface ChapterLink {\n /** Its number, in the margin: `02`. */\n number?: React.ReactNode;\n /** Its title, the link. */\n title: React.ReactNode;\n /** Where it leads. */\n href: string;\n}\n\nexport type ChapterFootProps = Omit<React.HTMLAttributes<HTMLElement>, \"children\"> & {\n /** The chapter before this one (none on the first). */\n previous?: ChapterLink;\n /** The chapter after this one (none on the latest). */\n next?: ChapterLink;\n /** The line back to the story: `{ href: \"/\", label: \"Back to the story\" }`. */\n back?: { href: string; label: React.ReactNode };\n /** The quiet words beside each link. @default { previous: \"Previous\", next: \"Next\" } */\n labels?: { previous: React.ReactNode; next: React.ReactNode };\n /** The accessible name of the navigation. @default \"Chapters\" */\n label?: string;\n /** The ruling under the links. @default \"lines\" */\n paper?: ChapterPaper;\n /** The app's router link (Next's `Link`). */\n linkAs?: LinkComponent;\n};\n\n/** The foot of a chapter: the previous and the next on the ruled lines, then one line back to the story. */\nexport function ChapterFoot({\n previous,\n next,\n back,\n labels = { previous: \"Previous\", next: \"Next\" },\n label = \"Chapters\",\n paper = \"lines\",\n linkAs,\n className,\n ...props\n}: ChapterFootProps) {\n return (\n <nav aria-label={label} data-paper={paper || undefined} data-margin=\"\" className={cn(\"kz-chapters kz-chapter-foot\", className)} {...props}>\n <ul role=\"list\">\n {previous && (\n <li className=\"kz-chapter-row\" data-dir=\"previous\">\n <ChapterRow\n number={previous.number}\n title={previous.title}\n href={previous.href}\n rel=\"prev\"\n linkAs={linkAs}\n aside={\n <>\n <span aria-hidden>← </span>\n {labels.previous}\n </>\n }\n />\n </li>\n )}\n {next && (\n <li className=\"kz-chapter-row\" data-dir=\"next\">\n <ChapterRow\n number={next.number}\n title={next.title}\n href={next.href}\n rel=\"next\"\n linkAs={linkAs}\n aside={\n <>\n {labels.next}\n <span aria-hidden> →</span>\n </>\n }\n />\n </li>\n )}\n </ul>\n {back && (\n <p className=\"kz-chapter-back\">\n <BlockLink href={back.href} linkAs={linkAs} className=\"kz-chapter-back-link\">\n <span aria-hidden>↩ </span>\n {back.label}\n </BlockLink>\n </p>\n )}\n </nav>\n );\n}\n"
321
321
  },
322
322
  {
323
323
  "path": "chapter/index.ts",
@@ -644,7 +644,7 @@
644
644
  },
645
645
  {
646
646
  "path": "chip/tag-chip.tsx",
647
- "content": "// Client (a Radix radio group, and `Chip`'s context). The tags of a workspace (krizaka-ts#89, `@krizaka/organize`): a name\n// with a colour marker beside it. The marker is a NAME of the closed palette (`MARKERS`: blue · green · amber · red ·\n// violet · gray), mapped to `--kz-tag-<name>` — a dot (≥ 3:1) or Verikora's bookmark ribbon. It sits beside the name and\n// never fills the chip, and the name is always written: the colour is never the only signal.\nimport type { Marker } from \"@krizaka/organize/contract\";\nimport { RadioGroup as RadioPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { Chip, type ChipProps } from \"./chip\";\nimport { TAG_MARKERS } from \"./markers\";\n\n/** The six names of the closed palette (`@krizaka/organize` `MARKERS`; a test keeps them equal). */\nexport const MARKERS: readonly Marker[] = TAG_MARKERS;\nexport type { Marker };\n\n/** The marker's shape: a `dot`, or the `ribbon` (a bookmark: a rectangle with a notch at the bottom). */\nexport type MarkerShape = \"dot\" | \"ribbon\";\n\n/** The CSS custom property the marker reads its colour from: `--kz-tag-<name>`. */\nconst markerVar = (marker: Marker) => `var(--kz-tag-${marker})`;\n\nexport type TagMarkerProps = Omit<React.ComponentProps<\"span\">, \"children\"> & {\n /** A name of the closed palette. */\n marker: Marker;\n /**\n * dot · ribbon.\n * @default \"dot\"\n */\n shape?: MarkerShape;\n};\n\n/** The marker alone, decorative (`aria-hidden`): put the tag's name beside it. */\nexport function TagMarker({ marker, shape = \"dot\", className, style, ...props }: TagMarkerProps) {\n return (\n <span\n aria-hidden\n data-marker={marker}\n data-shape={shape}\n className={cn(\n \"inline-block shrink-0 bg-(--kz-marker) data-[shape=dot]:h-2.5 data-[shape=dot]:w-2.5 data-[shape=dot]:rounded-full\",\n \"data-[shape=ribbon]:h-3.5 data-[shape=ribbon]:w-2.5 data-[shape=ribbon]:[clip-path:polygon(0_0,100%_0,100%_100%,50%_72%,0_100%)]\",\n className,\n )}\n style={{ ...style, [\"--kz-marker\" as string]: markerVar(marker) }}\n {...props}\n />\n );\n}\n\nexport type TagChipProps = ChipProps & {\n /** The tag's marker: a name of the closed palette (`blue · green · amber · red · violet · gray`). */\n marker: Marker;\n /**\n * dot · ribbon.\n * @default \"dot\"\n */\n shape?: MarkerShape;\n};\n\n/**\n * A tag: its marker and its name. Alone a toggle (a filter), inside `Chip.Group` an item, or `removable` (a tag worn by a\n * file) — the behaviour of `Chip`, with the marker before the name.\n */\nexport function TagChip({ marker, shape, children, ...props }: TagChipProps) {\n const content = (\n <>\n <TagMarker marker={marker} shape={shape} />\n {children}\n </>\n );\n return <Chip {...(props as ChipProps)}>{content}</Chip>;\n}\n\nexport type MarkerPickerProps = {\n /** The group's accessible name (\"Colour of the tag\"), passed translated. */\n label: string;\n /** The name of each colour, passed translated: `{ blue: \"Blue\", … }`. The swatches are named, never colour alone. */\n names: Readonly<Record<Marker, string>>;\n /** The colour chosen (controlled). */\n value?: Marker;\n /** The colour chosen at first, uncontrolled. */\n defaultValue?: Marker;\n /** Called with the colour chosen. */\n onValueChange?: (value: Marker) => void;\n /** The colours offered (default: the six). */\n markers?: readonly Marker[];\n /** Not available. */\n disabled?: boolean;\n /** Classes merged on the root. */\n className?: string;\n};\n\n/** Recolours a tag from the closed palette: a radio group of swatches (arrow keys), the chosen one ticked and named. */\nexport function MarkerPicker({ label, names, value, defaultValue, onValueChange, markers = MARKERS, disabled, className }: MarkerPickerProps) {\n return (\n <RadioPrimitive.Root\n aria-label={label}\n value={value}\n defaultValue={defaultValue}\n onValueChange={(next) => onValueChange?.(next as Marker)}\n disabled={disabled}\n orientation=\"horizontal\"\n className={cn(\"flex flex-wrap items-center gap-1.5\", className)}\n >\n {markers.map((marker) => (\n <RadioPrimitive.Item\n key={marker}\n value={marker}\n aria-label={names[marker]}\n title={names[marker]}\n className={cn(\n \"inline-flex h-8 w-8 items-center justify-center rounded-full border border-border-default bg-surface-1 transition-colors\",\n \"hover:border-border-strong focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40\",\n \"data-[state=checked]:border-(--kz-marker) data-[state=checked]:bg-surface-2\",\n )}\n style={{ [\"--kz-marker\" as string]: markerVar(marker) }}\n >\n <span aria-hidden className=\"relative inline-flex h-4 w-4 items-center justify-center rounded-full bg-(--kz-marker)\">\n <RadioPrimitive.Indicator forceMount className=\"hidden h-full w-full items-center justify-center data-[state=checked]:flex\">\n {/* The tick is the second signal: a shape, not a colour (it reads in the page's text colour on the swatch's ring). */}\n <svg viewBox=\"0 0 24 24\" className=\"h-3 w-3 text-surface-0\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"4\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n </RadioPrimitive.Indicator>\n </span>\n </RadioPrimitive.Item>\n ))}\n </RadioPrimitive.Root>\n );\n}\n"
647
+ "content": "// Client (a Radix radio group, and `Chip`'s context). The tags of a workspace (krizaka-ts#89, `@krizaka/organize`): a name\n// with a colour marker beside it. The marker is a NAME of the closed palette (`MARKERS`: blue · green · amber · red ·\n// violet · gray), mapped to `--kz-tag-<name>` — a dot (≥ 3:1) or Verikora's bookmark ribbon. It sits beside the name and\n// never fills the chip, and the name is always written: the colour is never the only signal.\nimport type { Marker } from \"@krizaka/organize/contract\";\nimport { RadioGroup as RadioPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { Chip, type ChipProps } from \"./chip\";\nimport { TAG_MARKERS } from \"./markers\";\n\n/** The six names of the closed palette (`@krizaka/organize` `MARKERS`; a test keeps them equal). */\nexport const MARKERS: readonly Marker[] = TAG_MARKERS;\nexport type { Marker };\n\n/** The marker's shape: a `dot`, or the `ribbon` (a bookmark: a rectangle with a notch at the bottom). */\nexport type MarkerShape = \"dot\" | \"ribbon\";\n\n/** The CSS custom property the marker reads its colour from: `--kz-tag-<name>`. */\nconst markerVar = (marker: Marker) => `var(--kz-tag-${marker})`;\n\nexport type TagMarkerProps = Omit<React.ComponentProps<\"span\">, \"children\"> & {\n /** A name of the closed palette. */\n marker: Marker;\n /**\n * dot · ribbon.\n * @default \"dot\"\n */\n shape?: MarkerShape;\n};\n\n/** The marker alone, decorative (`aria-hidden`): put the tag's name beside it. */\nexport function TagMarker({ marker, shape = \"dot\", className, style, ...props }: TagMarkerProps) {\n return (\n <span\n aria-hidden\n data-marker={marker}\n data-shape={shape}\n className={cn(\n \"inline-block shrink-0 bg-(--kz-marker) data-[shape=dot]:h-2.5 data-[shape=dot]:w-2.5 data-[shape=dot]:rounded-full\",\n \"data-[shape=ribbon]:h-3.5 data-[shape=ribbon]:w-2.5 data-[shape=ribbon]:[clip-path:polygon(0_0,100%_0,100%_100%,50%_72%,0_100%)]\",\n className,\n )}\n style={{ ...style, [\"--kz-marker\" as string]: markerVar(marker) }}\n {...props}\n />\n );\n}\n\nexport type TagChipProps = ChipProps & {\n /** The tag's marker: a name of the closed palette (`blue · green · amber · red · violet · gray`). */\n marker: Marker;\n /**\n * dot · ribbon.\n * @default \"dot\"\n */\n shape?: MarkerShape;\n};\n\n/**\n * A tag: its marker and its name. Alone a toggle (a filter), inside `Chip.Group` an item, or `removable` (a tag worn by a\n * file) — the behaviour of `Chip`, with the marker before the name.\n */\nexport function TagChip({ marker, shape, children, ...props }: TagChipProps) {\n const content = (\n <>\n <TagMarker marker={marker} shape={shape} />\n {children}\n </>\n );\n return <Chip {...(props as ChipProps)}>{content}</Chip>;\n}\n\nexport type MarkerPickerProps = {\n /** The group's accessible name (\"Colour of the tag\"), passed translated. */\n label: string;\n /** The name of each colour, passed translated: `{ blue: \"Blue\", … }`. The swatches are named, never colour alone. */\n names: Readonly<Record<Marker, string>>;\n /** The colour chosen (controlled). */\n value?: Marker;\n /** The colour chosen at first, uncontrolled. */\n defaultValue?: Marker;\n /** Called with the colour chosen. */\n onValueChange?: (value: Marker) => void;\n /** The colours offered (default: the six). */\n markers?: readonly Marker[];\n /** Not available. */\n disabled?: boolean;\n /** Classes merged on the root. */\n className?: string;\n};\n\n/** Recolours a tag from the closed palette: a radio group of swatches (arrow keys), the chosen one ticked and named. */\nexport function MarkerPicker({ label, names, value, defaultValue, onValueChange, markers = MARKERS, disabled, className }: Readonly<MarkerPickerProps>) {\n return (\n <RadioPrimitive.Root\n aria-label={label}\n value={value}\n defaultValue={defaultValue}\n onValueChange={(next) => onValueChange?.(next as Marker)}\n disabled={disabled}\n orientation=\"horizontal\"\n className={cn(\"flex flex-wrap items-center gap-1.5\", className)}\n >\n {markers.map((marker) => (\n <RadioPrimitive.Item\n key={marker}\n value={marker}\n aria-label={names[marker]}\n title={names[marker]}\n className={cn(\n \"inline-flex h-8 w-8 items-center justify-center rounded-full border border-border-default bg-surface-1 transition-colors\",\n \"hover:border-border-strong focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40\",\n \"data-[state=checked]:border-(--kz-marker) data-[state=checked]:bg-surface-2\",\n )}\n style={{ [\"--kz-marker\" as string]: markerVar(marker) }}\n >\n <span aria-hidden className=\"relative inline-flex h-4 w-4 items-center justify-center rounded-full bg-(--kz-marker)\">\n <RadioPrimitive.Indicator forceMount className=\"hidden h-full w-full items-center justify-center data-[state=checked]:flex\">\n {/* The tick is the second signal: a shape, not a colour (it reads in the page's text colour on the swatch's ring). */}\n <svg viewBox=\"0 0 24 24\" className=\"h-3 w-3 text-surface-0\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"4\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n </RadioPrimitive.Indicator>\n </span>\n </RadioPrimitive.Item>\n ))}\n </RadioPrimitive.Root>\n );\n}\n"
648
648
  },
649
649
  {
650
650
  "path": "meta.ts",
@@ -219,7 +219,7 @@
219
219
  "files": [
220
220
  {
221
221
  "path": "copy-button/copy-button.tsx",
222
- "content": "// Client (a state, the clipboard). Copies a value and says so in a polite live region. Without the Clipboard API\n// (an insecure page, an old webview) it falls back to a selected, read-only field the person copies by hand: the\n// failure is never silent.\nimport * as React from \"react\";\n\nimport { Button, type ButtonProps } from \"../button/button\";\nimport { cn } from \"../cn\";\nimport { CheckGlyph, CopyGlyph } from \"../glyphs\";\n\nexport type CopyButtonProps = Omit<ButtonProps, \"onClick\" | \"asChild\" | \"value\" | \"children\"> & {\n /** The text to copy. */\n value: string;\n /** The words of the button (and its accessible name), passed translated: \"Copy link\". Icon only: set `iconOnly`. */\n label: string;\n /** What it says once copied, announced politely: \"Copied\". */\n copiedLabel: string;\n /** Said when the clipboard is unavailable, above the selected value: \"Press Ctrl+C to copy\". */\n fallbackLabel: string;\n /** Shows only the icon (the label stays the accessible name). */\n iconOnly?: boolean;\n /** Replaces the copy icon (a `@krizaka/icons` one, say). */\n icon?: React.ReactNode;\n /** Replaces the check icon shown once copied. */\n copiedIcon?: React.ReactNode;\n /** How long \"Copied\" stays, in milliseconds (1800 by default). */\n resetMs?: number;\n /** Called after the value is copied. */\n onCopy?: () => void;\n};\n\n/** A button that copies `value`. State: `data-copied`. */\nexport function CopyButton({ value, label, copiedLabel, fallbackLabel, iconOnly, icon, copiedIcon, resetMs = 1800, onCopy, variant = \"secondary\", className, ...props }: CopyButtonProps) {\n const [copied, setCopied] = React.useState(false);\n const [manual, setManual] = React.useState(false);\n const fieldRef = React.useRef<HTMLInputElement>(null);\n React.useEffect(() => {\n if (!copied) return;\n const timer = window.setTimeout(() => setCopied(false), resetMs);\n return () => window.clearTimeout(timer);\n }, [copied, resetMs]);\n React.useEffect(() => {\n if (manual) fieldRef.current?.select();\n }, [manual]);\n const copy = async () => {\n try {\n await navigator.clipboard.writeText(value);\n setManual(false);\n setCopied(true);\n onCopy?.();\n } catch {\n // No Clipboard API, or refused: show the value selected, to copy by hand.\n setManual(true);\n }\n };\n const name = copied ? copiedLabel : label;\n return (\n <span className=\"inline-flex flex-col gap-1.5\">\n <Button type=\"button\" variant={variant} aria-label={iconOnly ? name : undefined} title={iconOnly ? name : undefined} data-copied={copied ? \"\" : undefined} className={cn(className)} onClick={() => void copy()} {...props}>\n {copied ? (copiedIcon ?? <CheckGlyph />) : (icon ?? <CopyGlyph />)}\n {!iconOnly && <span>{name}</span>}\n </Button>\n <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {copied ? copiedLabel : \"\"}\n </span>\n {manual && (\n <label className=\"flex flex-col gap-1 text-xs text-fg-secondary\">\n {fallbackLabel}\n <input ref={fieldRef} readOnly value={value} onFocus={(event) => event.currentTarget.select()} className=\"h-9 rounded-lg border border-border-control bg-surface-2 px-2 text-sm text-fg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\" />\n </label>\n )}\n </span>\n );\n}\n"
222
+ "content": "// Client (a state, the clipboard). Copies a value and says so in a polite live region. Without the Clipboard API\n// (an insecure page, an old webview) it falls back to a selected, read-only field the person copies by hand: the\n// failure is never silent.\nimport * as React from \"react\";\n\nimport { Button, type ButtonProps } from \"../button/button\";\nimport { cn } from \"../cn\";\nimport { CheckGlyph, CopyGlyph } from \"../glyphs\";\n\nexport type CopyButtonProps = Omit<ButtonProps, \"onClick\" | \"asChild\" | \"value\" | \"children\"> & {\n /** The text to copy. */\n value: string;\n /** The words of the button (and its accessible name), passed translated: \"Copy link\". Icon only: set `iconOnly`. */\n label: string;\n /** What it says once copied, announced politely: \"Copied\". */\n copiedLabel: string;\n /** Said when the clipboard is unavailable, above the selected value: \"Press Ctrl+C to copy\". */\n fallbackLabel: string;\n /** Shows only the icon (the label stays the accessible name). */\n iconOnly?: boolean;\n /** Replaces the copy icon (a `@krizaka/icons` one, say). */\n icon?: React.ReactNode;\n /** Replaces the check icon shown once copied. */\n copiedIcon?: React.ReactNode;\n /** How long \"Copied\" stays, in milliseconds (1800 by default). */\n resetMs?: number;\n /** Called after the value is copied. */\n onCopy?: () => void;\n};\n\n/** A button that copies `value`. State: `data-copied`. */\nexport function CopyButton({ value, label, copiedLabel, fallbackLabel, iconOnly, icon, copiedIcon, resetMs = 1800, onCopy, variant = \"secondary\", className, ...props }: CopyButtonProps) {\n const [copied, setCopied] = React.useState(false);\n const [manual, setManual] = React.useState(false);\n const fieldRef = React.useRef<HTMLInputElement>(null);\n React.useEffect(() => {\n if (!copied) return;\n const timer = globalThis.setTimeout(() => setCopied(false), resetMs);\n return () => globalThis.clearTimeout(timer);\n }, [copied, resetMs]);\n React.useEffect(() => {\n if (manual) fieldRef.current?.select();\n }, [manual]);\n const copy = async () => {\n try {\n await navigator.clipboard.writeText(value);\n setManual(false);\n setCopied(true);\n onCopy?.();\n } catch {\n // No Clipboard API, or refused: show the value selected, to copy by hand.\n setManual(true);\n }\n };\n const name = copied ? copiedLabel : label;\n return (\n <span className=\"inline-flex flex-col gap-1.5\">\n <Button type=\"button\" variant={variant} aria-label={iconOnly ? name : undefined} title={iconOnly ? name : undefined} data-copied={copied ? \"\" : undefined} className={cn(className)} onClick={() => void copy()} {...props}>\n {copied ? (copiedIcon ?? <CheckGlyph />) : (icon ?? <CopyGlyph />)}\n {!iconOnly && <span>{name}</span>}\n </Button>\n <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {copied ? copiedLabel : \"\"}\n </span>\n {manual && (\n <label className=\"flex flex-col gap-1 text-xs text-fg-secondary\">\n {fallbackLabel}\n <input ref={fieldRef} readOnly value={value} onFocus={(event) => event.currentTarget.select()} className=\"h-9 rounded-lg border border-border-control bg-surface-2 px-2 text-sm text-fg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\" />\n </label>\n )}\n </span>\n );\n}\n"
223
223
  },
224
224
  {
225
225
  "path": "copy-button/index.ts",
@@ -815,7 +815,7 @@
815
815
  },
816
816
  {
817
817
  "path": "data-table/toolbar.tsx",
818
- "content": "// The toolbar of a DataTable — its filters (a FilterBar built from the columns), the columns menu and the CSV export —\n// connected to the table they sit in through `useDataTable()`. Words come from the table's `labels`.\nimport * as React from \"react\";\n\nimport { Button } from \"../button\";\nimport { DropdownMenu } from \"../dropdown-menu\";\nimport { Input } from \"../field\";\nimport { type ActiveFilter, FilterBar, FilterMenu } from \"../filter-bar\";\nimport { ChevronGlyph } from \"../glyphs\";\nimport { SearchField } from \"../search-field\";\nimport { dataTableCsv } from \"./csv\";\nimport { type DataTableColumn, useDataTable } from \"./data-table\";\nimport type { FilterValue } from \"./engine\";\n\nexport type DataTableFiltersProps = {\n /** The search's wait after the last key, in ms, before the filter applies (a request, in server mode). Default 250. */\n debounce?: number;\n /** More controls in the bar (a date range picker, a toggle). */\n children?: React.ReactNode;\n /** Classes merged on the bar. */\n className?: string;\n};\n\nconst asRange = (value: FilterValue | undefined): [number | null, number | null] =>\n Array.isArray(value) && value.length === 2 && (typeof value[0] !== \"string\" || typeof value[1] !== \"string\") ? [value[0] as number | null, value[1] as number | null] : [null, null];\nconst asList = (value: FilterValue | undefined): readonly string[] => (Array.isArray(value) ? (value as readonly string[]) : []);\nconst number = (text: string) => (text.trim() === \"\" || Number.isNaN(Number(text)) ? null : Number(text));\n\n/**\n * The filters of the table, from its columns: a search per `text` column, a menu of values (with their counts) per\n * `facet` column, two bounds per `range` column; the filters in force as removable chips, \"clear all\", and the count\n * of results, announced.\n */\nexport function DataTableFilters({ debounce = 250, children, className }: DataTableFiltersProps) {\n const { table, columns, labels, filters, setFilters, resultCount, manualFiltering } = useDataTable();\n const set = (id: string, value: FilterValue | null) => {\n const next = { ...filters };\n if (value === null || value === \"\" || (Array.isArray(value) && (value.length === 0 || (value.length === 2 && value[0] == null && value[1] == null)))) delete next[id];\n else next[id] = value;\n setFilters(next);\n };\n const filterable = columns.filter((column) => column.filter);\n const optionsOf = (column: DataTableColumn<object>) => {\n if (column.options) return column.options;\n // The values found in the rows, with their counts — the other filters applied (TanStack's facets).\n const facets = manualFiltering ? new Map<unknown, number>() : (table.getColumn(column.id)?.getFacetedUniqueValues() ?? new Map<unknown, number>());\n return [...facets.entries()]\n .filter(([value]) => value != null && value !== \"\")\n .map(([value, count]) => ({ value: String(value), label: String(value), count }))\n .sort((a, b) => a.label.localeCompare(b.label, undefined, { numeric: true }));\n };\n const active: ActiveFilter[] = filterable.flatMap((column) => {\n const value = filters[column.id];\n if (value === undefined) return [];\n let text: string;\n if (column.filter === \"facet\") {\n const options = optionsOf(column);\n text = asList(value).map((v) => options.find((o) => o.value === v)?.label ?? v).join(\", \");\n } else if (column.filter === \"range\") {\n const [min, max] = asRange(value);\n text = `${min ?? \"…\"}–${max ?? \"…\"}`;\n } else text = String(value);\n const label = labels.activeFilter(column.header, text);\n return [{ id: column.id, label, onRemove: () => set(column.id, null) }];\n });\n return (\n <FilterBar\n label={labels.filters}\n active={active}\n onClearAll={() => setFilters({})}\n clearLabel={labels.clearFilters}\n removeLabel={labels.removeFilter}\n results={labels.results(resultCount)}\n className={className}\n >\n {filterable.map((column) => {\n if (column.filter === \"text\")\n return (\n <TextFilter\n key={column.id}\n label={labels.search(column.header)}\n value={typeof filters[column.id] === \"string\" ? (filters[column.id] as string) : \"\"}\n debounce={debounce}\n onCommit={(query) => set(column.id, query)}\n />\n );\n if (column.filter === \"facet\")\n return (\n <FilterMenu key={column.id} label={column.header} options={optionsOf(column)} value={asList(filters[column.id])} onValueChange={(value) => set(column.id, value)} />\n );\n const [min, max] = asRange(filters[column.id]);\n const bounds = manualFiltering ? undefined : table.getColumn(column.id)?.getFacetedMinMaxValues();\n return (\n <span key={column.id} className=\"inline-flex items-center gap-1.5\">\n <Input\n type=\"number\"\n inputMode=\"decimal\"\n aria-label={labels.rangeFrom(column.header)}\n placeholder={bounds ? String(bounds[0]) : labels.rangeFrom(column.header)}\n value={min ?? \"\"}\n onChange={(event) => set(column.id, [number(event.currentTarget.value), max])}\n className=\"h-11 w-28\"\n />\n <span aria-hidden className=\"text-fg-secondary\">\n –\n </span>\n <Input\n type=\"number\"\n inputMode=\"decimal\"\n aria-label={labels.rangeTo(column.header)}\n placeholder={bounds ? String(bounds[1]) : labels.rangeTo(column.header)}\n value={max ?? \"\"}\n onChange={(event) => set(column.id, [min, number(event.currentTarget.value)])}\n className=\"h-11 w-28\"\n />\n </span>\n );\n })}\n {children}\n </FilterBar>\n );\n}\n\nexport type DataTableColumnsMenuProps = {\n /** Opens the menu at first (a story, a test). */\n defaultOpen?: boolean;\n /** Classes merged on the button. */\n className?: string;\n};\n\n/** A menu of the `hideable` columns, each a checkbox: the person chooses what the table shows. */\nexport function DataTableColumnsMenu({ defaultOpen, className }: DataTableColumnsMenuProps) {\n const { table, columns, labels } = useDataTable();\n return (\n <DropdownMenu.Root defaultOpen={defaultOpen} modal={false}>\n <DropdownMenu.Trigger asChild>\n <Button variant=\"outline\" size=\"sm\" className={className}>\n {labels.columns}\n <ChevronGlyph className=\"h-4 w-4\" />\n </Button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"end\" aria-label={labels.columns}>\n {columns\n .filter((column) => column.hideable !== false)\n .map((column) => {\n const instance = table.getColumn(column.id);\n return (\n <DropdownMenu.CheckboxItem\n key={column.id}\n checked={instance?.getIsVisible() ?? true}\n onSelect={(event) => event.preventDefault()}\n onCheckedChange={(checked) => instance?.toggleVisibility(Boolean(checked))}\n >\n {column.header}\n </DropdownMenu.CheckboxItem>\n );\n })}\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n );\n}\n\nexport type DataTableExportProps = {\n /** The file's name. Default `\"export.csv\"`. */\n filename?: string;\n /** Receives the CSV instead of downloading it (send it to the server, a test). */\n onExport?: (csv: string) => void;\n /** Classes merged on the button. */\n className?: string;\n};\n\n/** Downloads what the table shows — the filtered and sorted rows of every page, the visible columns — as CSV. */\nexport function DataTableExport({ filename = \"export.csv\", onExport, className }: DataTableExportProps) {\n const { table, columns, labels, exportRows } = useDataTable();\n const run = () => {\n const visible = columns.filter((column) => table.getColumn(column.id)?.getIsVisible() !== false);\n const csv = dataTableCsv(exportRows(), visible);\n if (onExport) return onExport(csv);\n const url = URL.createObjectURL(new Blob([\"\", csv], { type: \"text/csv;charset=utf-8\" }));\n const link = Object.assign(document.createElement(\"a\"), { href: url, download: filename });\n link.click();\n setTimeout(() => URL.revokeObjectURL(url), 0);\n };\n return (\n <Button variant=\"outline\" size=\"sm\" className={className} onClick={run}>\n {labels.export}\n </Button>\n );\n}\n\n/**\n * A text filter: what is typed stays a draft until the debounce commits it, and a value that changes from outside\n * (back or forward on a `routeKey` table, « Clear all ») replaces the draft — the box always says what filters the rows.\n */\nfunction TextFilter({ label, value, debounce, onCommit }: { label: string; value: string; debounce?: number; onCommit: (query: string) => void }) {\n const [draft, setDraft] = React.useState(value);\n const [seen, setSeen] = React.useState(value);\n const [committed, setCommitted] = React.useState(value);\n if (value !== seen) {\n setSeen(value);\n if (value !== committed) {\n setCommitted(value);\n setDraft(value);\n }\n }\n return (\n <SearchField\n label={label}\n placeholder={label}\n value={draft}\n onValueChange={setDraft}\n debounce={debounce}\n onSearch={(query) => {\n setCommitted(query);\n onCommit(query);\n }}\n landmark={false}\n size=\"sm\"\n className=\"min-w-48 flex-1\"\n />\n );\n}\n"
818
+ "content": "// The toolbar of a DataTable — its filters (a FilterBar built from the columns), the columns menu and the CSV export —\n// connected to the table they sit in through `useDataTable()`. Words come from the table's `labels`.\nimport * as React from \"react\";\n\nimport { Button } from \"../button\";\nimport { DropdownMenu } from \"../dropdown-menu\";\nimport { Input } from \"../field\";\nimport { type ActiveFilter, FilterBar, FilterMenu } from \"../filter-bar\";\nimport { ChevronGlyph } from \"../glyphs\";\nimport { SearchField } from \"../search-field\";\nimport { dataTableCsv } from \"./csv\";\nimport { type DataTableColumn, useDataTable } from \"./data-table\";\nimport type { FilterValue } from \"./engine\";\n\nexport type DataTableFiltersProps = {\n /** The search's wait after the last key, in ms, before the filter applies (a request, in server mode). Default 250. */\n debounce?: number;\n /** More controls in the bar (a date range picker, a toggle). */\n children?: React.ReactNode;\n /** Classes merged on the bar. */\n className?: string;\n};\n\nconst asRange = (value: FilterValue | undefined): [number | null, number | null] =>\n Array.isArray(value) && value.length === 2 && (typeof value[0] !== \"string\" || typeof value[1] !== \"string\") ? [value[0] as number | null, value[1] as number | null] : [null, null];\nconst asList = (value: FilterValue | undefined): readonly string[] => (Array.isArray(value) ? (value as readonly string[]) : []);\nconst number = (text: string) => (text.trim() === \"\" || Number.isNaN(Number(text)) ? null : Number(text));\n\n/**\n * The filters of the table, from its columns: a search per `text` column, a menu of values (with their counts) per\n * `facet` column, two bounds per `range` column; the filters in force as removable chips, \"clear all\", and the count\n * of results, announced.\n */\nexport function DataTableFilters({ debounce = 250, children, className }: DataTableFiltersProps) {\n const { table, columns, labels, filters, setFilters, resultCount, manualFiltering } = useDataTable();\n const set = (id: string, value: FilterValue | null) => {\n const next = { ...filters };\n if (value === null || value === \"\" || (Array.isArray(value) && (value.length === 0 || (value.length === 2 && value[0] == null && value[1] == null)))) delete next[id];\n else next[id] = value;\n setFilters(next);\n };\n const filterable = columns.filter((column) => column.filter);\n const optionsOf = (column: DataTableColumn<object>) => {\n if (column.options) return column.options;\n // The values found in the rows, with their counts — the other filters applied (TanStack's facets).\n const facets = manualFiltering ? new Map<unknown, number>() : (table.getColumn(column.id)?.getFacetedUniqueValues() ?? new Map<unknown, number>());\n return [...facets.entries()]\n .filter(([value]) => value != null && value !== \"\")\n .map(([value, count]) => ({ value: String(value), label: String(value), count }))\n .sort((a, b) => a.label.localeCompare(b.label, undefined, { numeric: true }));\n };\n const active: ActiveFilter[] = filterable.flatMap((column) => {\n const value = filters[column.id];\n if (value === undefined) return [];\n let text: string;\n if (column.filter === \"facet\") {\n const options = optionsOf(column);\n text = asList(value).map((v) => options.find((o) => o.value === v)?.label ?? v).join(\", \");\n } else if (column.filter === \"range\") {\n const [min, max] = asRange(value);\n text = `${min ?? \"…\"}–${max ?? \"…\"}`;\n } else text = String(value);\n const label = labels.activeFilter(column.header, text);\n return [{ id: column.id, label, onRemove: () => set(column.id, null) }];\n });\n return (\n <FilterBar\n label={labels.filters}\n active={active}\n onClearAll={() => setFilters({})}\n clearLabel={labels.clearFilters}\n removeLabel={labels.removeFilter}\n results={labels.results(resultCount)}\n className={className}\n >\n {filterable.map((column) => {\n if (column.filter === \"text\")\n return (\n <TextFilter\n key={column.id}\n label={labels.search(column.header)}\n value={typeof filters[column.id] === \"string\" ? (filters[column.id] as string) : \"\"}\n debounce={debounce}\n onCommit={(query) => set(column.id, query)}\n />\n );\n if (column.filter === \"facet\")\n return (\n <FilterMenu key={column.id} label={column.header} options={optionsOf(column)} value={asList(filters[column.id])} onValueChange={(value) => set(column.id, value)} />\n );\n const [min, max] = asRange(filters[column.id]);\n const bounds = manualFiltering ? undefined : table.getColumn(column.id)?.getFacetedMinMaxValues();\n return (\n <span key={column.id} className=\"inline-flex items-center gap-1.5\">\n <Input\n type=\"number\"\n inputMode=\"decimal\"\n aria-label={labels.rangeFrom(column.header)}\n placeholder={bounds ? String(bounds[0]) : labels.rangeFrom(column.header)}\n value={min ?? \"\"}\n onChange={(event) => set(column.id, [number(event.currentTarget.value), max])}\n className=\"h-11 w-28\"\n />\n <span aria-hidden className=\"text-fg-secondary\">\n –\n </span>\n <Input\n type=\"number\"\n inputMode=\"decimal\"\n aria-label={labels.rangeTo(column.header)}\n placeholder={bounds ? String(bounds[1]) : labels.rangeTo(column.header)}\n value={max ?? \"\"}\n onChange={(event) => set(column.id, [min, number(event.currentTarget.value)])}\n className=\"h-11 w-28\"\n />\n </span>\n );\n })}\n {children}\n </FilterBar>\n );\n}\n\nexport type DataTableColumnsMenuProps = {\n /** Opens the menu at first (a story, a test). */\n defaultOpen?: boolean;\n /** Classes merged on the button. */\n className?: string;\n};\n\n/** A menu of the `hideable` columns, each a checkbox: the person chooses what the table shows. */\nexport function DataTableColumnsMenu({ defaultOpen, className }: DataTableColumnsMenuProps) {\n const { table, columns, labels } = useDataTable();\n return (\n <DropdownMenu.Root defaultOpen={defaultOpen} modal={false}>\n <DropdownMenu.Trigger asChild>\n <Button variant=\"outline\" size=\"sm\" className={className}>\n {labels.columns}\n <ChevronGlyph className=\"h-4 w-4\" />\n </Button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"end\" aria-label={labels.columns}>\n {columns\n .filter((column) => column.hideable !== false)\n .map((column) => {\n const instance = table.getColumn(column.id);\n return (\n <DropdownMenu.CheckboxItem\n key={column.id}\n checked={instance?.getIsVisible() ?? true}\n onSelect={(event) => event.preventDefault()}\n onCheckedChange={(checked) => instance?.toggleVisibility(Boolean(checked))}\n >\n {column.header}\n </DropdownMenu.CheckboxItem>\n );\n })}\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n );\n}\n\nexport type DataTableExportProps = {\n /** The file's name. Default `\"export.csv\"`. */\n filename?: string;\n /** Receives the CSV instead of downloading it (send it to the server, a test). */\n onExport?: (csv: string) => void;\n /** Classes merged on the button. */\n className?: string;\n};\n\n/** Downloads what the table shows — the filtered and sorted rows of every page, the visible columns — as CSV. */\nexport function DataTableExport({ filename = \"export.csv\", onExport, className }: DataTableExportProps) {\n const { table, columns, labels, exportRows } = useDataTable();\n const run = () => {\n const visible = columns.filter((column) => table.getColumn(column.id)?.getIsVisible() !== false);\n const csv = dataTableCsv(exportRows(), visible);\n if (onExport) return onExport(csv);\n const url = URL.createObjectURL(new Blob([\"\", csv], { type: \"text/csv;charset=utf-8\" }));\n const link = Object.assign(document.createElement(\"a\"), { href: url, download: filename });\n link.click();\n setTimeout(() => URL.revokeObjectURL(url), 0);\n };\n return (\n <Button variant=\"outline\" size=\"sm\" className={className} onClick={run}>\n {labels.export}\n </Button>\n );\n}\n\n/**\n * A text filter: what is typed stays a draft until the debounce commits it, and a value that changes from outside\n * (back or forward on a `routeKey` table, « Clear all ») replaces the draft — the box always says what filters the rows.\n */\nfunction TextFilter({ label, value, debounce, onCommit }: Readonly<{ label: string; value: string; debounce?: number; onCommit: (query: string) => void }>) {\n const [draft, setDraft] = React.useState(value);\n const [seen, setSeen] = React.useState(value);\n const [committed, setCommitted] = React.useState(value);\n if (value !== seen) {\n setSeen(value);\n if (value !== committed) {\n setCommitted(value);\n setDraft(value);\n }\n }\n return (\n <SearchField\n label={label}\n placeholder={label}\n value={draft}\n onValueChange={setDraft}\n debounce={debounce}\n onSearch={(query) => {\n setCommitted(query);\n onCommit(query);\n }}\n landmark={false}\n size=\"sm\"\n className=\"min-w-48 flex-1\"\n />\n );\n}\n"
819
819
  },
820
820
  {
821
821
  "path": "data-table/use-route-table.ts",
@@ -243,7 +243,7 @@
243
243
  },
244
244
  {
245
245
  "path": "desktop-window/desktop-window.tsx",
246
- "content": "// Client (the panes' sizes, the pointer, the shortcuts). The window of a Mac app (Tauri 2 on the system WebView, ADR-002):\n// a sidebar, the content and an inspector in a three-pane split — resizable by pointer and keyboard, collapsible — under a\n// toolbar that moves the window and clears the traffic lights, at the desktop's density with a native-feeling focus ring.\n// The commands (`desktopMenus`) are written once for the native menu bar, the page's shortcuts and the palette.\nimport { type ShortcutMap, useShortcuts } from \"@krizaka/ui/app-shell\";\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { type DesktopCommand, type DesktopMenus, desktopMenus } from \"./commands\";\nimport { clamp, dragged, keyed, paneMax } from \"./panes\";\n\nexport const desktopWindow = tv({\n slots: {\n root:\n \"kz-desktop-window flex h-[var(--kz-window-height,100dvh)] min-w-0 select-none overflow-hidden bg-surface-0 text-[13px] text-fg \" +\n // The macOS focus ring: a 3 px halo of the accent, over a 1 px accent edge, only for the keyboard.\n \"[&_:focus-visible]:outline-hidden [&_:focus-visible]:ring-[3px]! [&_:focus-visible]:ring-ring/50! [&_:focus-visible]:ring-offset-0!\",\n pane: \"relative flex min-h-0 shrink-0 flex-col overflow-hidden data-[collapsed]:hidden\",\n sidebar: \"border-e border-border-subtle bg-surface-1\",\n titlebar: \"h-[var(--kz-titlebar-inset,1.75rem)] shrink-0\",\n scroll: \"min-h-0 flex-1 overflow-y-auto\",\n middle: \"flex min-h-0 min-w-0 flex-1 flex-col\",\n inspector: \"border-s border-border-subtle bg-surface-1\",\n separator:\n \"group/sep relative z-10 -mx-[3px] w-[6px] shrink-0 cursor-col-resize touch-none data-[collapsed]:hidden \" +\n \"after:absolute after:inset-y-0 after:left-[2px] after:w-px after:bg-transparent hover:after:bg-border-strong data-[active]:after:bg-accent focus-visible:after:bg-accent\",\n content: \"min-h-0 min-w-0 flex-1 overflow-y-auto select-text\",\n toolbar:\n \"flex h-[var(--kz-toolbar-height,3rem)] shrink-0 items-center gap-2 border-b border-border-subtle bg-surface-0 px-3 \" +\n // With the sidebar folded the traffic lights sit over the toolbar: its first control starts after them.\n \"[[data-sidebar=closed]_&]:ps-[var(--kz-traffic-lights-inset,4.75rem)]\",\n toolbarTitle: \"min-w-0 flex-1 truncate text-[13px] font-semibold\",\n toolbarGroup: \"flex shrink-0 items-center gap-1\",\n toggle:\n \"inline-flex h-7 w-7 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-surface-2 hover:text-fg cursor-default aria-pressed:text-fg-accent\",\n },\n});\nconst s = desktopWindow();\n\nexport interface DesktopWindowLabels {\n /** The sidebar's accessible name (`Library`). */\n sidebar: string;\n /** The inspector's accessible name (`Details`). */\n inspector: string;\n /** The separators' names (`Resize the sidebar`, `Resize the inspector`). */\n resizeSidebar: string;\n resizeInspector: string;\n /** The toolbar buttons that fold the panes (`Show or hide the sidebar`). */\n toggleSidebar: string;\n toggleInspector: string;\n}\n\nexport interface DesktopWindowProps {\n /** The sidebar's content: a list of places, a `Tree`. It scrolls by itself. */\n sidebar: React.ReactNode;\n /** The main content under the toolbar. */\n children: React.ReactNode;\n /** The inspector's content: the selected item's details. Without it, a two-pane window. */\n inspector?: React.ReactNode;\n /** The toolbar's title, centred in the drag region. */\n title?: React.ReactNode;\n /** After the sidebar's toggle, at the start of the toolbar (back, forward). */\n toolbarStart?: React.ReactNode;\n /** Before the inspector's toggle, at the end of the toolbar (actions, search). */\n toolbarEnd?: React.ReactNode;\n /** The words of the panes, the dividers and the toggles — passed translated. */\n labels: DesktopWindowLabels;\n /** The sidebar is open (controlled). Pair with `onSidebarOpenChange`: the menu bar's command toggles it too. */\n sidebarOpen?: boolean;\n /** The sidebar starts open (default true) when uncontrolled. */\n defaultSidebarOpen?: boolean;\n /** Called when the sidebar folds or unfolds (the toolbar, a divider, the shortcut). */\n onSidebarOpenChange?: (open: boolean) => void;\n /** The inspector is open (controlled). */\n inspectorOpen?: boolean;\n /** The inspector starts open (default true) when uncontrolled. */\n defaultInspectorOpen?: boolean;\n /** Called when the inspector folds or unfolds. */\n onInspectorOpenChange?: (open: boolean) => void;\n /** The sizes in px: the sidebar's, the inspector's. Persist them with `onSizesChange`. */\n defaultSizes?: { sidebar?: number; inspector?: number };\n /** Called with the sizes in px after a drag or a key: persist them. */\n onSizesChange?: (sizes: { sidebar: number; inspector: number }) => void;\n /** The least the content keeps when the window is narrow (default 360). */\n contentMin?: number;\n /** The keys that fold the panes (a chord, or `false` for none): ⌘B and ⌘I by default. Pass `false` when the menu bar's commands (`useDesktopCommands`) own them. */\n shortcuts?: { sidebar?: string | false; inspector?: string | false };\n /** Classes for the window (`[--kz-window-height:34rem]` to size it inside a page). */\n className?: string;\n}\n\nconst SIDEBAR: { min: number; max: number } = { min: 180, max: 360 };\nconst INSPECTOR: { min: number; max: number } = { min: 240, max: 480 };\n\nconst glyph = (d: string) => (\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d={d} />\n </svg>\n);\n\nfunction useOpen(controlled: boolean | undefined, initial: boolean, onChange?: (open: boolean) => void) {\n const [own, setOwn] = React.useState(initial);\n const open = controlled ?? own;\n const set = React.useCallback(\n (next: boolean) => {\n if (controlled === undefined) setOwn(next);\n onChange?.(next);\n },\n [controlled, onChange],\n );\n return [open, set] as const;\n}\n\ntype Edge = \"sidebar\" | \"inspector\";\n\n/** The window of a Mac app: sidebar · content · inspector, a toolbar that moves the window, the desktop's density. */\nexport function DesktopWindow({\n sidebar, children, inspector, title, toolbarStart, toolbarEnd, labels, sidebarOpen, defaultSidebarOpen = true, onSidebarOpenChange, inspectorOpen, defaultInspectorOpen = true, onInspectorOpenChange, defaultSizes, onSizesChange, contentMin = 360, shortcuts, className,\n}: DesktopWindowProps) {\n const [sideOpen, setSideOpen] = useOpen(sidebarOpen, defaultSidebarOpen, onSidebarOpenChange);\n const [inspOpen, setInspOpen] = useOpen(inspectorOpen, defaultInspectorOpen, onInspectorOpenChange);\n const [sizes, setSizes] = React.useState({ sidebar: clamp(defaultSizes?.sidebar ?? 240, SIDEBAR.min, SIDEBAR.max), inspector: clamp(defaultSizes?.inspector ?? 300, INSPECTOR.min, INSPECTOR.max) });\n const [active, setActive] = React.useState<Edge | null>(null);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n const toggles = React.useRef<Record<Edge, HTMLButtonElement | null>>({ sidebar: null, inspector: null });\n const sidebarId = React.useId();\n const inspectorId = React.useId();\n const hasInspector = inspector != null;\n const sideShown = sideOpen;\n const inspShown = hasInspector && inspOpen;\n\n const keys = { sidebar: shortcuts?.sidebar === undefined ? \"mod+b\" : shortcuts.sidebar, inspector: shortcuts?.inspector === undefined ? \"mod+i\" : shortcuts.inspector };\n const map: Record<string, () => void> = {};\n if (keys.sidebar) map[keys.sidebar] = () => setSideOpen(!sideOpen);\n if (keys.inspector && hasInspector) map[keys.inspector] = () => setInspOpen(!inspOpen);\n useShortcuts(map as ShortcutMap);\n\n const commit = (edge: Edge, size: number) => {\n const next = { ...sizes, [edge]: size };\n setSizes(next);\n onSizesChange?.(next);\n };\n // The window's width, to keep the content its room: measured, and followed while the window is resized.\n React.useLayoutEffect(() => {\n const element = root.current;\n if (!element) return;\n const measure = () => setWidth(element.getBoundingClientRect().width);\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n const ceiling = (edge: Edge) => {\n const other = edge === \"sidebar\" ? (inspShown ? sizes.inspector : 0) : sideShown ? sizes.sidebar : 0;\n const limits = edge === \"sidebar\" ? SIDEBAR : INSPECTOR;\n // The separators overlap the panes (negative margins): they take no width of their own.\n return paneMax(limits, width || Number.POSITIVE_INFINITY, other, contentMin, 0);\n };\n const direction = (): 1 | -1 => (root.current && getComputedStyle(root.current).direction === \"rtl\" ? -1 : 1);\n const sideOf = (edge: Edge): 1 | -1 => (edge === \"sidebar\" ? 1 : -1);\n const limitsOf = (edge: Edge) => (edge === \"sidebar\" ? SIDEBAR : INSPECTOR);\n\n const onPointerDown = (edge: Edge) => (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.button !== 0) return;\n event.currentTarget.setPointerCapture(event.pointerId);\n const startX = event.clientX;\n const start = sizes[edge];\n const max = ceiling(edge);\n const dir = direction();\n setActive(edge);\n const target = event.currentTarget;\n const move = (e: PointerEvent) => commit(edge, dragged(start, e.clientX - startX, dir, sideOf(edge), limitsOf(edge), max));\n const stop = () => {\n setActive(null);\n target.removeEventListener(\"pointermove\", move);\n target.removeEventListener(\"pointerup\", stop);\n target.removeEventListener(\"pointercancel\", stop);\n };\n target.addEventListener(\"pointermove\", move);\n target.addEventListener(\"pointerup\", stop);\n target.addEventListener(\"pointercancel\", stop);\n };\n const onKeyDown = (edge: Edge) => (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n (edge === \"sidebar\" ? setSideOpen : setInspOpen)(false);\n // The separator goes with the pane: the focus goes to the button that brings it back.\n queueMicrotask(() => toggles.current[edge]?.focus());\n return;\n }\n const next = keyed(event.key, sizes[edge], direction(), sideOf(edge), limitsOf(edge), event.shiftKey, ceiling(edge));\n if (next === null) return;\n event.preventDefault();\n commit(edge, next);\n };\n\n const separator = (edge: Edge, controls: string, label: string) => (\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-controls={controls}\n aria-valuemin={limitsOf(edge).min}\n aria-valuemax={ceiling(edge)}\n aria-valuenow={sizes[edge]}\n tabIndex={0}\n data-edge={edge}\n data-active={active === edge ? \"\" : undefined}\n className={s.separator()}\n onPointerDown={onPointerDown(edge)}\n onKeyDown={onKeyDown(edge)}\n onDoubleClick={() => (edge === \"sidebar\" ? setSideOpen(false) : setInspOpen(false))}\n />\n );\n const toggle = (edge: Edge, label: string, pressed: boolean, onClick: () => void, d: string) => (\n <button type=\"button\" ref={(el) => { toggles.current[edge] = el; }} className={s.toggle()} aria-label={label} aria-pressed={pressed} onClick={onClick}>\n {glyph(d)}\n </button>\n );\n\n return (\n <div ref={root} data-desktop=\"\" data-sidebar={sideShown ? \"open\" : \"closed\"} className={s.root({ className })}>\n <aside id={sidebarId} aria-label={labels.sidebar} data-collapsed={sideShown ? undefined : \"\"} className={s.pane({ className: s.sidebar() })} style={{ width: sizes.sidebar }}>\n <div aria-hidden data-tauri-drag-region=\"\" className={s.titlebar()} />\n <div className={s.scroll()}>{sidebar}</div>\n </aside>\n {sideShown && separator(\"sidebar\", sidebarId, labels.resizeSidebar)}\n <div className={s.middle()}>\n <header data-tauri-drag-region=\"\" className={s.toolbar()}>\n <div className={s.toolbarGroup()}>\n {toggle(\"sidebar\", labels.toggleSidebar, sideShown, () => setSideOpen(!sideOpen), \"M4 5h16v14H4zM9 5v14\")}\n {toolbarStart}\n </div>\n <div data-tauri-drag-region=\"\" className={s.toolbarTitle()}>\n {title}\n </div>\n <div className={s.toolbarGroup()}>\n {toolbarEnd}\n {hasInspector && toggle(\"inspector\", labels.toggleInspector, inspShown, () => setInspOpen(!inspOpen), \"M4 5h16v14H4zM15 5v14\")}\n </div>\n </header>\n <main id=\"content\" tabIndex={-1} className={s.content()}>\n {children}\n </main>\n </div>\n {inspShown && separator(\"inspector\", inspectorId, labels.resizeInspector)}\n {hasInspector && (\n <aside id={inspectorId} aria-label={labels.inspector} data-collapsed={inspShown ? undefined : \"\"} className={s.pane({ className: s.inspector() })} style={{ width: sizes.inspector }}>\n <div className={s.scroll()}>{inspector}</div>\n </aside>\n )}\n </div>\n );\n}\n\n/**\n * The window's commands as one source: registers their chords in the page (`useShortcuts`, the browser's too) and returns\n * the native menu bar's data — `menus` and `handlers` for `setNativeMenu(bridge, { labels, menus }, handlers)` of\n * `@krizaka/app-desktop` — so the menu shows the keys the page answers.\n */\nexport function useDesktopCommands(commands: readonly DesktopCommand[]): DesktopMenus {\n const menus = React.useMemo(() => desktopMenus(commands), [commands]);\n useShortcuts(menus.shortcuts as ShortcutMap);\n return menus;\n}\n"
246
+ "content": "// Client (the panes' sizes, the pointer, the shortcuts). The window of a Mac app (Tauri 2 on the system WebView, ADR-002):\n// a sidebar, the content and an inspector in a three-pane split — resizable by pointer and keyboard, collapsible — under a\n// toolbar that moves the window and clears the traffic lights, at the desktop's density with a native-feeling focus ring.\n// The commands (`desktopMenus`) are written once for the native menu bar, the page's shortcuts and the palette.\nimport { type ShortcutMap, useShortcuts } from \"@krizaka/ui/app-shell\";\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { type DesktopCommand, type DesktopMenus, desktopMenus } from \"./commands\";\nimport { clamp, dragged, keyed, paneMax } from \"./panes\";\n\nexport const desktopWindow = tv({\n slots: {\n root:\n \"kz-desktop-window flex h-[var(--kz-window-height,100dvh)] min-w-0 select-none overflow-hidden bg-surface-0 text-[13px] text-fg \" +\n // The macOS focus ring: a 3 px halo of the accent, over a 1 px accent edge, only for the keyboard.\n \"[&_:focus-visible]:outline-hidden [&_:focus-visible]:ring-[3px]! [&_:focus-visible]:ring-ring/50! [&_:focus-visible]:ring-offset-0!\",\n pane: \"relative flex min-h-0 shrink-0 flex-col overflow-hidden data-[collapsed]:hidden\",\n sidebar: \"border-e border-border-subtle bg-surface-1\",\n titlebar: \"h-[var(--kz-titlebar-inset,1.75rem)] shrink-0\",\n scroll: \"min-h-0 flex-1 overflow-y-auto\",\n middle: \"flex min-h-0 min-w-0 flex-1 flex-col\",\n inspector: \"border-s border-border-subtle bg-surface-1\",\n separator:\n \"group/sep relative z-10 -mx-[3px] w-[6px] shrink-0 cursor-col-resize touch-none data-[collapsed]:hidden \" +\n \"after:absolute after:inset-y-0 after:left-[2px] after:w-px after:bg-transparent hover:after:bg-border-strong data-[active]:after:bg-accent focus-visible:after:bg-accent\",\n content: \"min-h-0 min-w-0 flex-1 overflow-y-auto select-text\",\n toolbar:\n \"flex h-[var(--kz-toolbar-height,3rem)] shrink-0 items-center gap-2 border-b border-border-subtle bg-surface-0 px-3 \" +\n // With the sidebar folded the traffic lights sit over the toolbar: its first control starts after them.\n \"[[data-sidebar=closed]_&]:ps-[var(--kz-traffic-lights-inset,4.75rem)]\",\n toolbarTitle: \"min-w-0 flex-1 truncate text-[13px] font-semibold\",\n toolbarGroup: \"flex shrink-0 items-center gap-1\",\n toggle:\n \"inline-flex h-7 w-7 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-surface-2 hover:text-fg cursor-default aria-pressed:text-fg-accent\",\n },\n});\nconst s = desktopWindow();\n\nexport interface DesktopWindowLabels {\n /** The sidebar's accessible name (`Library`). */\n sidebar: string;\n /** The inspector's accessible name (`Details`). */\n inspector: string;\n /** The separators' names (`Resize the sidebar`, `Resize the inspector`). */\n resizeSidebar: string;\n resizeInspector: string;\n /** The toolbar buttons that fold the panes (`Show or hide the sidebar`). */\n toggleSidebar: string;\n toggleInspector: string;\n}\n\nexport interface DesktopWindowProps {\n /** The sidebar's content: a list of places, a `Tree`. It scrolls by itself. */\n sidebar: React.ReactNode;\n /** The main content under the toolbar. */\n children: React.ReactNode;\n /** The inspector's content: the selected item's details. Without it, a two-pane window. */\n inspector?: React.ReactNode;\n /** The toolbar's title, centred in the drag region. */\n title?: React.ReactNode;\n /** After the sidebar's toggle, at the start of the toolbar (back, forward). */\n toolbarStart?: React.ReactNode;\n /** Before the inspector's toggle, at the end of the toolbar (actions, search). */\n toolbarEnd?: React.ReactNode;\n /** The words of the panes, the dividers and the toggles — passed translated. */\n labels: DesktopWindowLabels;\n /** The sidebar is open (controlled). Pair with `onSidebarOpenChange`: the menu bar's command toggles it too. */\n sidebarOpen?: boolean;\n /** The sidebar starts open (default true) when uncontrolled. */\n defaultSidebarOpen?: boolean;\n /** Called when the sidebar folds or unfolds (the toolbar, a divider, the shortcut). */\n onSidebarOpenChange?: (open: boolean) => void;\n /** The inspector is open (controlled). */\n inspectorOpen?: boolean;\n /** The inspector starts open (default true) when uncontrolled. */\n defaultInspectorOpen?: boolean;\n /** Called when the inspector folds or unfolds. */\n onInspectorOpenChange?: (open: boolean) => void;\n /** The sizes in px: the sidebar's, the inspector's. Persist them with `onSizesChange`. */\n defaultSizes?: { sidebar?: number; inspector?: number };\n /** Called with the sizes in px after a drag or a key: persist them. */\n onSizesChange?: (sizes: { sidebar: number; inspector: number }) => void;\n /** The least the content keeps when the window is narrow (default 360). */\n contentMin?: number;\n /** The keys that fold the panes (a chord, or `false` for none): ⌘B and ⌘I by default. Pass `false` when the menu bar's commands (`useDesktopCommands`) own them. */\n shortcuts?: { sidebar?: string | false; inspector?: string | false };\n /** Classes for the window (`[--kz-window-height:34rem]` to size it inside a page). */\n className?: string;\n}\n\nconst SIDEBAR: { min: number; max: number } = { min: 180, max: 360 };\nconst INSPECTOR: { min: number; max: number } = { min: 240, max: 480 };\n\nconst glyph = (d: string) => (\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d={d} />\n </svg>\n);\n\nfunction useOpen(controlled: boolean | undefined, initial: boolean, onChange?: (open: boolean) => void) {\n const [own, setOwn] = React.useState(initial);\n const open = controlled ?? own;\n const set = React.useCallback(\n (next: boolean) => {\n if (controlled === undefined) setOwn(next);\n onChange?.(next);\n },\n [controlled, onChange],\n );\n return [open, set] as const;\n}\n\ntype Edge = \"sidebar\" | \"inspector\";\n\n/** The window of a Mac app: sidebar · content · inspector, a toolbar that moves the window, the desktop's density. */\nexport function DesktopWindow({\n sidebar, children, inspector, title, toolbarStart, toolbarEnd, labels, sidebarOpen, defaultSidebarOpen = true, onSidebarOpenChange, inspectorOpen, defaultInspectorOpen = true, onInspectorOpenChange, defaultSizes, onSizesChange, contentMin = 360, shortcuts, className,\n}: Readonly<DesktopWindowProps>) {\n const [sideOpen, setSideOpen] = useOpen(sidebarOpen, defaultSidebarOpen, onSidebarOpenChange);\n const [inspOpen, setInspOpen] = useOpen(inspectorOpen, defaultInspectorOpen, onInspectorOpenChange);\n const [sizes, setSizes] = React.useState({ sidebar: clamp(defaultSizes?.sidebar ?? 240, SIDEBAR.min, SIDEBAR.max), inspector: clamp(defaultSizes?.inspector ?? 300, INSPECTOR.min, INSPECTOR.max) });\n const [active, setActive] = React.useState<Edge | null>(null);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n const toggles = React.useRef<Record<Edge, HTMLButtonElement | null>>({ sidebar: null, inspector: null });\n const sidebarId = React.useId();\n const inspectorId = React.useId();\n const hasInspector = inspector != null;\n const sideShown = sideOpen;\n const inspShown = hasInspector && inspOpen;\n\n const keys = { sidebar: shortcuts?.sidebar === undefined ? \"mod+b\" : shortcuts.sidebar, inspector: shortcuts?.inspector === undefined ? \"mod+i\" : shortcuts.inspector };\n const map: Record<string, () => void> = {};\n if (keys.sidebar) map[keys.sidebar] = () => setSideOpen(!sideOpen);\n if (keys.inspector && hasInspector) map[keys.inspector] = () => setInspOpen(!inspOpen);\n useShortcuts(map as ShortcutMap);\n\n const commit = (edge: Edge, size: number) => {\n const next = { ...sizes, [edge]: size };\n setSizes(next);\n onSizesChange?.(next);\n };\n // The window's width, to keep the content its room: measured, and followed while the window is resized.\n React.useLayoutEffect(() => {\n const element = root.current;\n if (!element) return;\n const measure = () => setWidth(element.getBoundingClientRect().width);\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n const ceiling = (edge: Edge) => {\n let other: number;\n if (edge === \"sidebar\") other = inspShown ? sizes.inspector : 0;\n else other = sideShown ? sizes.sidebar : 0;\n const limits = edge === \"sidebar\" ? SIDEBAR : INSPECTOR;\n // The separators overlap the panes (negative margins): they take no width of their own.\n return paneMax(limits, width || Number.POSITIVE_INFINITY, other, contentMin, 0);\n };\n const direction = (): 1 | -1 => (root.current && getComputedStyle(root.current).direction === \"rtl\" ? -1 : 1);\n const sideOf = (edge: Edge): 1 | -1 => (edge === \"sidebar\" ? 1 : -1);\n const limitsOf = (edge: Edge) => (edge === \"sidebar\" ? SIDEBAR : INSPECTOR);\n\n const onPointerDown = (edge: Edge) => (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.button !== 0) return;\n event.currentTarget.setPointerCapture(event.pointerId);\n const startX = event.clientX;\n const start = sizes[edge];\n const max = ceiling(edge);\n const dir = direction();\n setActive(edge);\n const target = event.currentTarget;\n const move = (e: PointerEvent) => commit(edge, dragged(start, e.clientX - startX, dir, sideOf(edge), limitsOf(edge), max));\n const stop = () => {\n setActive(null);\n target.removeEventListener(\"pointermove\", move);\n target.removeEventListener(\"pointerup\", stop);\n target.removeEventListener(\"pointercancel\", stop);\n };\n target.addEventListener(\"pointermove\", move);\n target.addEventListener(\"pointerup\", stop);\n target.addEventListener(\"pointercancel\", stop);\n };\n const onKeyDown = (edge: Edge) => (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n (edge === \"sidebar\" ? setSideOpen : setInspOpen)(false);\n // The separator goes with the pane: the focus goes to the button that brings it back.\n queueMicrotask(() => toggles.current[edge]?.focus());\n return;\n }\n const next = keyed(event.key, sizes[edge], direction(), sideOf(edge), limitsOf(edge), event.shiftKey, ceiling(edge));\n if (next === null) return;\n event.preventDefault();\n commit(edge, next);\n };\n\n const separator = (edge: Edge, controls: string, label: string) => (\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-controls={controls}\n aria-valuemin={limitsOf(edge).min}\n aria-valuemax={ceiling(edge)}\n aria-valuenow={sizes[edge]}\n tabIndex={0}\n data-edge={edge}\n data-active={active === edge ? \"\" : undefined}\n className={s.separator()}\n onPointerDown={onPointerDown(edge)}\n onKeyDown={onKeyDown(edge)}\n onDoubleClick={() => (edge === \"sidebar\" ? setSideOpen(false) : setInspOpen(false))}\n />\n );\n const toggle = (edge: Edge, label: string, pressed: boolean, onClick: () => void, d: string) => (\n <button type=\"button\" ref={(el) => { toggles.current[edge] = el; }} className={s.toggle()} aria-label={label} aria-pressed={pressed} onClick={onClick}>\n {glyph(d)}\n </button>\n );\n\n return (\n <div ref={root} data-desktop=\"\" data-sidebar={sideShown ? \"open\" : \"closed\"} className={s.root({ className })}>\n <aside id={sidebarId} aria-label={labels.sidebar} data-collapsed={sideShown ? undefined : \"\"} className={s.pane({ className: s.sidebar() })} style={{ width: sizes.sidebar }}>\n <div aria-hidden data-tauri-drag-region=\"\" className={s.titlebar()} />\n <div className={s.scroll()}>{sidebar}</div>\n </aside>\n {sideShown && separator(\"sidebar\", sidebarId, labels.resizeSidebar)}\n <div className={s.middle()}>\n <header data-tauri-drag-region=\"\" className={s.toolbar()}>\n <div className={s.toolbarGroup()}>\n {toggle(\"sidebar\", labels.toggleSidebar, sideShown, () => setSideOpen(!sideOpen), \"M4 5h16v14H4zM9 5v14\")}\n {toolbarStart}\n </div>\n <div data-tauri-drag-region=\"\" className={s.toolbarTitle()}>\n {title}\n </div>\n <div className={s.toolbarGroup()}>\n {toolbarEnd}\n {hasInspector && toggle(\"inspector\", labels.toggleInspector, inspShown, () => setInspOpen(!inspOpen), \"M4 5h16v14H4zM15 5v14\")}\n </div>\n </header>\n <main id=\"content\" tabIndex={-1} className={s.content()}>\n {children}\n </main>\n </div>\n {inspShown && separator(\"inspector\", inspectorId, labels.resizeInspector)}\n {hasInspector && (\n <aside id={inspectorId} aria-label={labels.inspector} data-collapsed={inspShown ? undefined : \"\"} className={s.pane({ className: s.inspector() })} style={{ width: sizes.inspector }}>\n <div className={s.scroll()}>{inspector}</div>\n </aside>\n )}\n </div>\n );\n}\n\n/**\n * The window's commands as one source: registers their chords in the page (`useShortcuts`, the browser's too) and returns\n * the native menu bar's data — `menus` and `handlers` for `setNativeMenu(bridge, { labels, menus }, handlers)` of\n * `@krizaka/app-desktop` — so the menu shows the keys the page answers.\n */\nexport function useDesktopCommands(commands: readonly DesktopCommand[]): DesktopMenus {\n const menus = React.useMemo(() => desktopMenus(commands), [commands]);\n useShortcuts(menus.shortcuts as ShortcutMap);\n return menus;\n}\n"
247
247
  },
248
248
  {
249
249
  "path": "desktop-window/index.ts",
@@ -118,7 +118,7 @@
118
118
  "files": [
119
119
  {
120
120
  "path": "drop-overlay/drop-overlay.tsx",
121
- "content": "// Client (window listeners). The whole window is the drop target: while files are dragged over the page a full-window overlay\n// says so, and the dropped files go to `onFiles` (accepted, rejected). No dashed box in the page; the product keeps a real\n// file input behind its primary action for the keyboard and for phones. Motion: motion.css (« DROP OVERLAY »).\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { type AcceptRule, dragHasFiles, splitDropped } from \"./files\";\n\nexport type DropOverlayProps = Omit<React.ComponentProps<\"div\">, \"children\" | \"onDrop\"> & {\n /** What the overlay says (“Drop to check”) — passed translated. */\n label: string;\n /** One line under it (“PDF or text”). */\n hint?: string;\n /** What is accepted: MIME types, families (`image/*`) or extensions (`.pdf`). */\n accept?: readonly AcceptRule[];\n /** Turns the window back into a plain page (while a modal is open, signed out). */\n disabled?: boolean;\n} & (\n | {\n /** Controlled form (a desktop app's native drops, which arrive as paths): shown while true, the DOM listeners are off. */\n active: boolean;\n /** Not called in the controlled form. */\n onFiles?: (accepted: File[], rejected: File[]) => void;\n }\n | {\n /** Leave undefined to handle DOM drops. */\n active?: undefined;\n /** The files dropped: the accepted ones, then the ones `accept` refused. */\n onFiles: (accepted: File[], rejected: File[]) => void;\n }\n);\n\n/** Drag a file anywhere on the page: a full-window overlay accepts it. */\nexport function DropOverlay({\n label,\n hint,\n onFiles,\n accept,\n disabled,\n active: controlled,\n className,\n ...props\n}: DropOverlayProps) {\n const isControlled = controlled !== undefined;\n const [dragging, setActive] = React.useState(false);\n const depth = React.useRef(0);\n const latest = React.useRef({ onFiles, accept });\n React.useEffect(() => {\n latest.current = { onFiles, accept };\n });\n\n React.useEffect(() => {\n if (disabled || isControlled) return;\n const reset = () => {\n depth.current = 0;\n setActive(false);\n };\n const carrying = (event: Event) => dragHasFiles((event as DragEvent).dataTransfer);\n const enter = (event: Event) => {\n if (!carrying(event)) return;\n depth.current += 1;\n setActive(true);\n };\n const over = (event: Event) => {\n if (carrying(event)) event.preventDefault();\n };\n const leave = (event: Event) => {\n if (!carrying(event)) return;\n depth.current = Math.max(0, depth.current - 1);\n if (depth.current === 0) setActive(false);\n };\n const drop = (event: Event) => {\n if (!carrying(event)) return;\n event.preventDefault();\n const files = Array.from((event as DragEvent).dataTransfer?.files ?? []);\n reset();\n const { accepted, rejected } = splitDropped(files, latest.current.accept);\n latest.current.onFiles?.(accepted, rejected);\n };\n window.addEventListener(\"dragenter\", enter);\n window.addEventListener(\"dragover\", over);\n window.addEventListener(\"dragleave\", leave);\n window.addEventListener(\"drop\", drop);\n return () => {\n window.removeEventListener(\"dragenter\", enter);\n window.removeEventListener(\"dragover\", over);\n window.removeEventListener(\"dragleave\", leave);\n window.removeEventListener(\"drop\", drop);\n reset();\n };\n }, [disabled, isControlled]);\n\n if (!(isControlled ? controlled && !disabled : dragging)) return null;\n return (\n <div role=\"status\" data-state=\"open\" className={cn(\"kz-drop-overlay\", className)} {...props}>\n <div className=\"kz-drop-overlay-card\">\n <span className=\"text-lg font-semibold text-fg\">{label}</span>\n {hint ? <span className=\"text-sm text-fg-secondary\">{hint}</span> : null}\n </div>\n </div>\n );\n}\n"
121
+ "content": "// Client (window listeners). The whole window is the drop target: while files are dragged over the page a full-window overlay\n// says so, and the dropped files go to `onFiles` (accepted, rejected). No dashed box in the page; the product keeps a real\n// file input behind its primary action for the keyboard and for phones. Motion: motion.css (« DROP OVERLAY »).\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { type AcceptRule, dragHasFiles, splitDropped } from \"./files\";\n\nexport type DropOverlayProps = Omit<React.ComponentProps<\"div\">, \"children\" | \"onDrop\"> & {\n /** What the overlay says (“Drop to check”) — passed translated. */\n label: string;\n /** One line under it (“PDF or text”). */\n hint?: string;\n /** What is accepted: MIME types, families (`image/*`) or extensions (`.pdf`). */\n accept?: readonly AcceptRule[];\n /** Turns the window back into a plain page (while a modal is open, signed out). */\n disabled?: boolean;\n} & (\n | {\n /** Controlled form (a desktop app's native drops, which arrive as paths): shown while true, the DOM listeners are off. */\n active: boolean;\n /** Not called in the controlled form. */\n onFiles?: (accepted: File[], rejected: File[]) => void;\n }\n | {\n /** Leave undefined to handle DOM drops. */\n active?: undefined;\n /** The files dropped: the accepted ones, then the ones `accept` refused. */\n onFiles: (accepted: File[], rejected: File[]) => void;\n }\n);\n\n/** Drag a file anywhere on the page: a full-window overlay accepts it. */\nexport function DropOverlay({\n label,\n hint,\n onFiles,\n accept,\n disabled,\n active: controlled,\n className,\n ...props\n}: DropOverlayProps) {\n const isControlled = controlled !== undefined;\n const [dragging, setActive] = React.useState(false);\n const depth = React.useRef(0);\n const latest = React.useRef({ onFiles, accept });\n React.useEffect(() => {\n latest.current = { onFiles, accept };\n });\n\n React.useEffect(() => {\n if (disabled || isControlled) return;\n const reset = () => {\n depth.current = 0;\n setActive(false);\n };\n const carrying = (event: Event) => dragHasFiles((event as DragEvent).dataTransfer);\n const enter = (event: Event) => {\n if (!carrying(event)) return;\n depth.current += 1;\n setActive(true);\n };\n const over = (event: Event) => {\n if (carrying(event)) event.preventDefault();\n };\n const leave = (event: Event) => {\n if (!carrying(event)) return;\n depth.current = Math.max(0, depth.current - 1);\n if (depth.current === 0) setActive(false);\n };\n const drop = (event: Event) => {\n if (!carrying(event)) return;\n event.preventDefault();\n const files = Array.from((event as DragEvent).dataTransfer?.files ?? []);\n reset();\n const { accepted, rejected } = splitDropped(files, latest.current.accept);\n latest.current.onFiles?.(accepted, rejected);\n };\n globalThis.addEventListener(\"dragenter\", enter);\n globalThis.addEventListener(\"dragover\", over);\n globalThis.addEventListener(\"dragleave\", leave);\n globalThis.addEventListener(\"drop\", drop);\n return () => {\n globalThis.removeEventListener(\"dragenter\", enter);\n globalThis.removeEventListener(\"dragover\", over);\n globalThis.removeEventListener(\"dragleave\", leave);\n globalThis.removeEventListener(\"drop\", drop);\n reset();\n };\n }, [disabled, isControlled]);\n\n if (!(isControlled ? controlled && !disabled : dragging)) return null;\n return (\n <div role=\"status\" data-state=\"open\" className={cn(\"kz-drop-overlay\", className)} {...props}>\n <div className=\"kz-drop-overlay-card\">\n <span className=\"text-lg font-semibold text-fg\">{label}</span>\n {hint ? <span className=\"text-sm text-fg-secondary\">{hint}</span> : null}\n </div>\n </div>\n );\n}\n"
122
122
  },
123
123
  {
124
124
  "path": "drop-overlay/files.ts",
@@ -131,7 +131,7 @@
131
131
  },
132
132
  {
133
133
  "path": "elephant/elephant.tsx",
134
- "content": "import type { SVGProps } from \"react\";\n\nimport { warnDeprecated } from \"../deprecated\";\nimport { ELEPHANT as G } from \"./geometry\";\n\nexport interface ElephantProps extends Omit<SVGProps<SVGSVGElement>, \"width\" | \"height\" | \"title\"> {\n /** `standing` with the ear folded down, or `flying` with the ear spread like a wing. */\n pose?: \"standing\" | \"flying\";\n /** Width and height in pixels. */\n size?: number;\n /** The wing flaps gently (a flying elephant only). Off with `false`; always off under prefers-reduced-motion. */\n animated?: boolean;\n /** An accessible name (the mark becomes an image); without it the mark is decorative. */\n title?: string;\n}\n\nconst CSS = `\n.kz-elephant-flap { transform-box: view-box; transform-origin: ${G.motion.origin}; animation: kz-elephant-flap ${G.motion.flap}s ease-in-out infinite; }\n@keyframes kz-elephant-flap { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-${G.motion.angle}deg); } }\n@media (prefers-reduced-motion: reduce) { .kz-elephant-flap { animation: none; } }\n`;\n\nconst line = { strokeWidth: G.stroke, strokeLinecap: \"square\", strokeLinejoin: \"miter\", fill: \"none\" } as const;\n\n/**\n * The elephant: a small, playful mark from the neighbour joke — « the elephant with those ears can fly ». Not a product\n * logo: a quiet figure for the hero of a page or the closing of a chat. Sage body, sand ear, flat colours that read on\n * both themes; decorative by default.\n * @deprecated Since 3.55 (ADR-006, krizaka-ui#674): no product uses it. Removed in 4.0.\n */\nexport function Elephant({ pose = \"standing\", size = 64, animated = true, title, className, ...rest }: ElephantProps) {\n warnDeprecated(\"elephant\");\n const flying = pose === \"flying\";\n const p = flying ? G.flying : G.standing;\n const a11y = title ? { role: \"img\" as const, \"aria-label\": title } : { \"aria-hidden\": true as const };\n return (\n <svg width={size} height={size} viewBox={G.viewBox} xmlns=\"http://www.w3.org/2000/svg\" className={className} data-pose={pose} {...a11y} {...rest}>\n {flying && animated ? <style>{CSS}</style> : null}\n {flying ? <path d={G.flying.wind} stroke={G.sage} opacity=\".45\" {...line} /> : null}\n <path d={p.body} stroke={G.sage} {...line} />\n <path d={p.trunk} stroke={G.sage} {...line} />\n <path d={p.tail} stroke={G.sage} {...line} />\n <g className={flying && animated ? \"kz-elephant-flap\" : undefined}>\n <path d={p.ear} stroke={G.sand} {...line} />\n </g>\n <circle cx={G.eye.cx} cy={G.eye.cy} r={G.eye.r} fill={G.sage} />\n </svg>\n );\n}\n"
134
+ "content": "import type { SVGProps } from \"react\";\n\nimport { warnDeprecated } from \"../deprecated\";\nimport { ELEPHANT as G } from \"./geometry\";\n\nexport interface ElephantProps extends Omit<SVGProps<SVGSVGElement>, \"width\" | \"height\" | \"title\"> {\n /** `standing` with the ear folded down, or `flying` with the ear spread like a wing. */\n pose?: \"standing\" | \"flying\";\n /** Width and height in pixels. */\n size?: number;\n /** The wing flaps gently (a flying elephant only). Off with `false`; always off under prefers-reduced-motion. */\n animated?: boolean;\n /** An accessible name (the mark becomes an image); without it the mark is decorative. */\n title?: string;\n}\n\nconst CSS = `\n.kz-elephant-flap { transform-box: view-box; transform-origin: ${G.motion.origin}; animation: kz-elephant-flap ${G.motion.flap}s ease-in-out infinite; }\n@keyframes kz-elephant-flap { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-${G.motion.angle}deg); } }\n@media (prefers-reduced-motion: reduce) { .kz-elephant-flap { animation: none; } }\n`;\n\nconst line = { strokeWidth: G.stroke, strokeLinecap: \"square\", strokeLinejoin: \"miter\", fill: \"none\" } as const;\n\n/**\n * The elephant: a small, playful mark from the neighbour joke — « the elephant with those ears can fly ». Not a product\n * logo: a quiet figure for the hero of a page or the closing of a chat. Sage body, sand ear, flat colours that read on\n * both themes; decorative by default.\n * @deprecated Since 3.55 (ADR-006, krizaka-ui#674): no product uses it. Removed in 4.0.\n */\nexport function Elephant({ pose = \"standing\", size = 64, animated = true, title, className, ...rest }: Readonly<ElephantProps>) {\n warnDeprecated(\"elephant\");\n const flying = pose === \"flying\";\n const p = flying ? G.flying : G.standing;\n const a11y = title ? { role: \"img\" as const, \"aria-label\": title } : { \"aria-hidden\": true as const };\n return (\n <svg width={size} height={size} viewBox={G.viewBox} xmlns=\"http://www.w3.org/2000/svg\" className={className} data-pose={pose} {...a11y} {...rest}>\n {flying && animated ? <style>{CSS}</style> : null}\n {flying ? <path d={G.flying.wind} stroke={G.sage} opacity=\".45\" {...line} /> : null}\n <path d={p.body} stroke={G.sage} {...line} />\n <path d={p.trunk} stroke={G.sage} {...line} />\n <path d={p.tail} stroke={G.sage} {...line} />\n <g className={flying && animated ? \"kz-elephant-flap\" : undefined}>\n <path d={p.ear} stroke={G.sand} {...line} />\n </g>\n <circle cx={G.eye.cx} cy={G.eye.cy} r={G.eye.r} fill={G.sage} />\n </svg>\n );\n}\n"
135
135
  },
136
136
  {
137
137
  "path": "elephant/geometry.ts",
@@ -151,11 +151,11 @@
151
151
  "files": [
152
152
  {
153
153
  "path": "embed-facade/embed-facade.tsx",
154
- "content": "\"use client\";\n\n// A click-to-load facade for a platform's short video (krizaka-ui#605, the lite-youtube-embed pattern). Until the visitor\n// asks, nothing is requested from TikTok, YouTube or Instagram: no frame, no script, no platform picture. The poster is the\n// host's own copy. After the click: one frame, a minimal sandbox and permissions. Loi 25: no third-party tracker without consent.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { EMBED_PLATFORMS, type EmbedPlatform, embedUrl, isOwnPoster } from \"./embed-url\";\n\nexport interface EmbedFacadeProps extends Omit<React.ComponentProps<\"div\">, \"title\" | \"children\" | \"onLoad\"> {\n /** Which platform's frame to load. */\n platform: EmbedPlatform;\n /** The public address of the post (`embedUrl` validates it; anything else renders nothing). */\n url: string;\n /** The accessible name of the video (\"Latest reel\"), passed translated: it names the frame once loaded. */\n title: string;\n /** The button: what it does and which platform it loads (\"Load TikTok and play\"), passed translated. */\n playLabel: string;\n /** The host's own copy of the picture (never an address on the platform: those are refused, they would be a request). */\n poster?: string;\n /** A line under the button, for what the platform will receive on the click (translated). */\n notice?: React.ReactNode;\n /** The ratio of the box when it stands alone; inside a television's screen it fills its parent. @default \"9 / 16\" */\n aspectRatio?: string;\n /** Called once, when the visitor has asked and the frame is added. */\n onLoad?: () => void;\n}\n\nconst SANDBOX = \"allow-scripts allow-same-origin allow-presentation allow-popups allow-popups-to-escape-sandbox\";\n\n/** A short video from a platform, behind a button: the frame exists only after the click. */\nexport function EmbedFacade({ platform, url, title, playLabel, poster, notice, aspectRatio = \"9 / 16\", onLoad, className, style, ...props }: EmbedFacadeProps) {\n const frame = embedUrl(platform, url);\n const [loaded, setLoaded] = React.useState(false);\n const ref = React.useRef<HTMLIFrameElement>(null);\n React.useEffect(() => {\n if (loaded) ref.current?.focus();\n }, [loaded]);\n if (!frame) return null;\n const load = () => {\n setLoaded(true);\n onLoad?.();\n };\n return (\n <div\n role=\"group\"\n aria-label={title}\n className={cn(\"kz-embed\", className)}\n data-platform={platform}\n data-loaded={loaded ? \"\" : undefined}\n style={{ ...style, [\"--kz-embed-ratio\" as string]: aspectRatio }}\n {...props}\n >\n {loaded ? (\n <iframe ref={ref} src={frame} title={title} sandbox={SANDBOX} allow=\"fullscreen; encrypted-media\" allowFullScreen referrerPolicy=\"strict-origin-when-cross-origin\" className=\"kz-embed-frame\" />\n ) : (\n <>\n {poster && isOwnPoster(poster) && <img src={poster} alt=\"\" loading=\"lazy\" decoding=\"async\" referrerPolicy=\"no-referrer\" className=\"kz-embed-poster\" />}\n <div className=\"kz-embed-gate\">\n <button type=\"button\" onClick={load} className=\"kz-embed-play\" data-platform-name={EMBED_PLATFORMS[platform]}>\n <svg aria-hidden=\"true\" focusable=\"false\" viewBox=\"0 0 16 16\" width=\"16\" height=\"16\"><path d=\"M4 2.5v11l9-5.5Z\" fill=\"currentColor\" /></svg>\n <span>{playLabel}</span>\n </button>\n {notice && <p className=\"kz-embed-notice\">{notice}</p>}\n </div>\n </>\n )}\n </div>\n );\n}\n"
154
+ "content": "\"use client\";\n\n// A click-to-load facade for a platform's short video (krizaka-ui#605, the lite-youtube-embed pattern). Until the visitor\n// asks, nothing is requested from TikTok, YouTube or Instagram: no frame, no script, no platform picture. The poster is the\n// host's own copy. After the click: one frame, a minimal sandbox and permissions. Loi 25: no third-party tracker without consent.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { EMBED_PLATFORMS, type EmbedPlatform, embedUrl, isOwnPoster } from \"./embed-url\";\n\nexport interface EmbedFacadeProps extends Omit<React.ComponentProps<\"div\">, \"title\" | \"children\" | \"onLoad\"> {\n /** Which platform's frame to load. */\n platform: EmbedPlatform;\n /** The public address of the post (`embedUrl` validates it; anything else renders nothing). */\n url: string;\n /** The accessible name of the video (\"Latest reel\"), passed translated: it names the frame once loaded. */\n title: string;\n /** The button: what it does and which platform it loads (\"Load TikTok and play\"), passed translated. */\n playLabel: string;\n /** The host's own copy of the picture (never an address on the platform: those are refused, they would be a request). */\n poster?: string;\n /** A line under the button, for what the platform will receive on the click (translated). */\n notice?: React.ReactNode;\n /** The ratio of the box when it stands alone; inside a television's screen it fills its parent. @default \"9 / 16\" */\n aspectRatio?: string;\n /** Called once, when the visitor has asked and the frame is added. */\n onLoad?: () => void;\n}\n\nconst SANDBOX = \"allow-scripts allow-same-origin allow-presentation allow-popups allow-popups-to-escape-sandbox\";\n\n/** A short video from a platform, behind a button: the frame exists only after the click. */\nexport function EmbedFacade({ platform, url, title, playLabel, poster, notice, aspectRatio = \"9 / 16\", onLoad, className, style, ...props }: Readonly<EmbedFacadeProps>) {\n const frame = embedUrl(platform, url);\n const [loaded, setLoaded] = React.useState(false);\n const ref = React.useRef<HTMLIFrameElement>(null);\n React.useEffect(() => {\n if (loaded) ref.current?.focus();\n }, [loaded]);\n if (!frame) return null;\n const load = () => {\n setLoaded(true);\n onLoad?.();\n };\n return (\n <div\n role=\"group\"\n aria-label={title}\n className={cn(\"kz-embed\", className)}\n data-platform={platform}\n data-loaded={loaded ? \"\" : undefined}\n style={{ ...style, [\"--kz-embed-ratio\" as string]: aspectRatio }}\n {...props}\n >\n {loaded ? (\n <iframe ref={ref} src={frame} title={title} sandbox={SANDBOX} allow=\"fullscreen; encrypted-media\" allowFullScreen referrerPolicy=\"strict-origin-when-cross-origin\" className=\"kz-embed-frame\" />\n ) : (\n <>\n {poster && isOwnPoster(poster) && <img src={poster} alt=\"\" loading=\"lazy\" decoding=\"async\" referrerPolicy=\"no-referrer\" className=\"kz-embed-poster\" />}\n <div className=\"kz-embed-gate\">\n <button type=\"button\" onClick={load} className=\"kz-embed-play\" data-platform-name={EMBED_PLATFORMS[platform]}>\n <svg aria-hidden=\"true\" focusable=\"false\" viewBox=\"0 0 16 16\" width=\"16\" height=\"16\"><path d=\"M4 2.5v11l9-5.5Z\" fill=\"currentColor\" /></svg>\n <span>{playLabel}</span>\n </button>\n {notice && <p className=\"kz-embed-notice\">{notice}</p>}\n </div>\n </>\n )}\n </div>\n );\n}\n"
155
155
  },
156
156
  {
157
157
  "path": "embed-facade/embed-url.ts",
158
- "content": "// The pure part of the facade (krizaka-ui#605): which addresses may ever be embedded, and what the frame's address is.\n// Nothing here touches the network or the DOM, so a server (the shop's editor) can validate with the same function the page uses.\n\n/** The platforms a facade can load after a click. */\nexport type EmbedPlatform = \"tiktok\" | \"youtube-shorts\" | \"instagram\";\n\n/** The platforms' names, as proper nouns (they are not translated). */\nexport const EMBED_PLATFORMS: Readonly<Record<EmbedPlatform, string>> = Object.freeze({ tiktok: \"TikTok\", \"youtube-shorts\": \"YouTube Shorts\", instagram: \"Instagram\" });\n\nconst TIKTOK_HOSTS = new Set([\"tiktok.com\", \"www.tiktok.com\"]);\nconst YOUTUBE_HOSTS = new Set([\"youtube.com\", \"www.youtube.com\", \"m.youtube.com\"]);\nconst INSTAGRAM_HOSTS = new Set([\"instagram.com\", \"www.instagram.com\"]);\n\n/** Every host a platform's frame or picture lives on: a poster served from one of them would be a request before the click. */\nconst PLATFORM_DOMAINS = [\"tiktok.com\", \"tiktokcdn.com\", \"tiktokcdn-us.com\", \"youtube.com\", \"youtu.be\", \"youtube-nocookie.com\", \"ytimg.com\", \"googlevideo.com\", \"instagram.com\", \"cdninstagram.com\", \"fbcdn.net\", \"facebook.com\"];\n\nfunction parse(url: string): URL | null {\n try {\n const u = new URL(url);\n // https only, no credentials, no port: the address is a public post, nothing else.\n if (u.protocol !== \"https:\" || u.username || u.password || u.port) return null;\n return u;\n } catch {\n return null;\n }\n}\n\nconst tiktok = (host: string, path: string): string | null => {\n const id = TIKTOK_HOSTS.has(host) ? /^\\/@[\\w.-]{1,64}\\/video\\/(\\d{8,25})\\/?$/.exec(path)?.[1] : undefined;\n return id ? `https://www.tiktok.com/embed/v2/${id}` : null;\n};\n\nconst youtube = (host: string, path: string): string | null => {\n let id: string | undefined;\n if (YOUTUBE_HOSTS.has(host)) id = /^\\/shorts\\/([\\w-]{11})\\/?$/.exec(path)?.[1];\n else if (host === \"youtu.be\") id = /^\\/([\\w-]{11})\\/?$/.exec(path)?.[1];\n return id ? `https://www.youtube-nocookie.com/embed/${id}` : null;\n};\n\nconst instagram = (host: string, path: string): string | null => {\n const match = INSTAGRAM_HOSTS.has(host) ? /^\\/(?:[\\w.]{1,30}\\/)?(p|reel|reels|tv)\\/([\\w-]{5,40})\\/?$/.exec(path) : null;\n return match ? `https://www.instagram.com/${match[1] === \"reels\" ? \"reel\" : match[1]}/${match[2]}/embed` : null;\n};\n\nconst PARSERS: Readonly<Record<EmbedPlatform, (host: string, path: string) => string | null>> = { tiktok, \"youtube-shorts\": youtube, instagram };\n\n/**\n * The address of the platform's frame for a public post, or `null` for anything else: another host, `http:`, a short\n * link we cannot resolve without asking the platform, a profile page. Exact hosts, exact paths.\n */\nexport function embedUrl(platform: EmbedPlatform, url: string): string | null {\n const u = parse(url);\n return u ? PARSERS[platform](u.hostname.toLowerCase(), u.pathname) : null;\n}\n\n/** Whether a poster may be drawn before the click: a path of the host's own origin, or an https picture that is not on a platform's domain (the host copies it to its own storage). */\nexport function isOwnPoster(poster: string): boolean {\n if (poster.startsWith(\"/\") && !poster.startsWith(\"//\")) return true;\n // An inline picture is no request at all.\n if (/^data:image\\/(?:png|jpeg|webp|gif|svg\\+xml)[;,]/i.test(poster)) return true;\n const u = parse(poster);\n if (!u) return false;\n const host = u.hostname.toLowerCase();\n return !PLATFORM_DOMAINS.some((domain) => host === domain || host.endsWith(`.${domain}`));\n}\n"
158
+ "content": "// The pure part of the facade (krizaka-ui#605): which addresses may ever be embedded, and what the frame's address is.\n// Nothing here touches the network or the DOM, so a server (the shop's editor) can validate with the same function the page uses.\n\n/** The platforms a facade can load after a click. */\nexport type EmbedPlatform = \"tiktok\" | \"youtube-shorts\" | \"instagram\";\n\n/** The platforms' names, as proper nouns (they are not translated). */\nexport const EMBED_PLATFORMS: Readonly<Record<EmbedPlatform, string>> = Object.freeze({ tiktok: \"TikTok\", \"youtube-shorts\": \"YouTube Shorts\", instagram: \"Instagram\" });\n\nconst TIKTOK_HOSTS = new Set([\"tiktok.com\", \"www.tiktok.com\"]);\nconst YOUTUBE_HOSTS = new Set([\"youtube.com\", \"www.youtube.com\", \"m.youtube.com\"]);\nconst INSTAGRAM_HOSTS = new Set([\"instagram.com\", \"www.instagram.com\"]);\n\n/** Every host a platform's frame or picture lives on: a poster served from one of them would be a request before the click. */\nconst PLATFORM_DOMAINS = [\"tiktok.com\", \"tiktokcdn.com\", \"tiktokcdn-us.com\", \"youtube.com\", \"youtu.be\", \"youtube-nocookie.com\", \"ytimg.com\", \"googlevideo.com\", \"instagram.com\", \"cdninstagram.com\", \"fbcdn.net\", \"facebook.com\"];\n\nfunction parse(url: string): URL | null {\n try {\n const u = new URL(url);\n // https only, no credentials, no port: the address is a public post, nothing else.\n if (u.protocol !== \"https:\" || u.username || u.password || u.port) return null;\n return u;\n } catch {\n return null;\n }\n}\n\nconst tiktok = (host: string, path: string): string | null => {\n const id = TIKTOK_HOSTS.has(host) ? /^\\/@[\\w.-]{1,64}\\/video\\/(\\d{8,25})\\/?$/.exec(path)?.[1] : undefined;\n return id ? `https://www.tiktok.com/embed/v2/${id}` : null;\n};\n\nconst youtube = (host: string, path: string): string | null => {\n let id: string | undefined;\n if (YOUTUBE_HOSTS.has(host)) id = /^\\/shorts\\/([\\w-]{11})\\/?$/.exec(path)?.[1];\n else if (host === \"youtu.be\") id = /^\\/([\\w-]{11})\\/?$/.exec(path)?.[1];\n return id ? `https://www.youtube-nocookie.com/embed/${id}` : null;\n};\n\nconst instagram = (host: string, path: string): string | null => {\n const match = INSTAGRAM_HOSTS.has(host) ? /^\\/(?:[\\w.]{1,30}\\/)?(p|reel|reels|tv)\\/([\\w-]{5,40})\\/?$/.exec(path) : null;\n if (!match) return null;\n const kind = match[1] === \"reels\" ? \"reel\" : match[1];\n return `https://www.instagram.com/${kind}/${match[2]}/embed`;\n};\n\nconst PARSERS: Readonly<Record<EmbedPlatform, (host: string, path: string) => string | null>> = { tiktok, \"youtube-shorts\": youtube, instagram };\n\n/**\n * The address of the platform's frame for a public post, or `null` for anything else: another host, `http:`, a short\n * link we cannot resolve without asking the platform, a profile page. Exact hosts, exact paths.\n */\nexport function embedUrl(platform: EmbedPlatform, url: string): string | null {\n const u = parse(url);\n return u ? PARSERS[platform](u.hostname.toLowerCase(), u.pathname) : null;\n}\n\n/** Whether a poster may be drawn before the click: a path of the host's own origin, or an https picture that is not on a platform's domain (the host copies it to its own storage). */\nexport function isOwnPoster(poster: string): boolean {\n if (poster.startsWith(\"/\") && !poster.startsWith(\"//\")) return true;\n // An inline picture is no request at all.\n if (/^data:image\\/(?:png|jpeg|webp|gif|svg\\+xml)[;,]/i.test(poster)) return true;\n const u = parse(poster);\n if (!u) return false;\n const host = u.hostname.toLowerCase();\n return !PLATFORM_DOMAINS.some((domain) => host === domain || host.endsWith(`.${domain}`));\n}\n"
159
159
  },
160
160
  {
161
161
  "path": "embed-facade/index.ts",