@burojs/ui-shadcn 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +26 -7
  2. package/dist/bulk-summary-CwSd6Yjb.cjs +108 -0
  3. package/dist/bulk-summary-CwSd6Yjb.cjs.map +1 -0
  4. package/dist/bulk-summary-GxMDP4bw.js +108 -0
  5. package/dist/bulk-summary-GxMDP4bw.js.map +1 -0
  6. package/dist/button-BxnnE28H.cjs +55 -0
  7. package/dist/button-BxnnE28H.cjs.map +1 -0
  8. package/dist/button-MWVeZaqj.js +44 -0
  9. package/dist/button-MWVeZaqj.js.map +1 -0
  10. package/dist/candidates-gate-CX2PBu6l.js +63 -0
  11. package/dist/candidates-gate-CX2PBu6l.js.map +1 -0
  12. package/dist/candidates-gate-DiFI52r7.cjs +70 -0
  13. package/dist/candidates-gate-DiFI52r7.cjs.map +1 -0
  14. package/dist/candidates-relation-picker-CBsVcnPR.js +82 -0
  15. package/dist/candidates-relation-picker-CBsVcnPR.js.map +1 -0
  16. package/dist/candidates-relation-picker-Dd_GVLlu.cjs +84 -0
  17. package/dist/candidates-relation-picker-Dd_GVLlu.cjs.map +1 -0
  18. package/dist/check-confirm-dialog-BRByTFpg.cjs +1534 -0
  19. package/dist/check-confirm-dialog-BRByTFpg.cjs.map +1 -0
  20. package/dist/check-confirm-dialog-CkaVTPT9.js +1232 -0
  21. package/dist/check-confirm-dialog-CkaVTPT9.js.map +1 -0
  22. package/dist/dialog-B_rt9S1c.js +63 -0
  23. package/dist/dialog-B_rt9S1c.js.map +1 -0
  24. package/dist/dialog-DRNUq9EA.cjs +112 -0
  25. package/dist/dialog-DRNUq9EA.cjs.map +1 -0
  26. package/dist/filter-builder-B3mZFL-K.cjs +1761 -0
  27. package/dist/filter-builder-B3mZFL-K.cjs.map +1 -0
  28. package/dist/filter-builder-DOnaXNfP.js +1605 -0
  29. package/dist/filter-builder-DOnaXNfP.js.map +1 -0
  30. package/dist/flow-runtime-B6zOHYqI.cjs +255 -0
  31. package/dist/flow-runtime-B6zOHYqI.cjs.map +1 -0
  32. package/dist/flow-runtime-D8h99FSg.js +252 -0
  33. package/dist/flow-runtime-D8h99FSg.js.map +1 -0
  34. package/dist/flow-screen-CX05b3G9.cjs +705 -0
  35. package/dist/flow-screen-CX05b3G9.cjs.map +1 -0
  36. package/dist/flow-screen-CmbARSqg.js +701 -0
  37. package/dist/flow-screen-CmbARSqg.js.map +1 -0
  38. package/dist/index.cjs +6453 -17494
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +3754 -3621
  41. package/dist/index.d.ts +3754 -3621
  42. package/dist/index.js +6217 -17219
  43. package/dist/index.js.map +1 -1
  44. package/dist/inline-flow-host-B7U1OJUe.cjs +112 -0
  45. package/dist/inline-flow-host-B7U1OJUe.cjs.map +1 -0
  46. package/dist/inline-flow-host-C3H2UpSA.js +112 -0
  47. package/dist/inline-flow-host-C3H2UpSA.js.map +1 -0
  48. package/dist/input-BI0czGyI.cjs +23 -0
  49. package/dist/input-BI0czGyI.cjs.map +1 -0
  50. package/dist/input-CUPStzZO.js +17 -0
  51. package/dist/input-CUPStzZO.js.map +1 -0
  52. package/dist/label-66W1qbke.js +29 -0
  53. package/dist/label-66W1qbke.js.map +1 -0
  54. package/dist/label-w6JYf2cF.cjs +36 -0
  55. package/dist/label-w6JYf2cF.cjs.map +1 -0
  56. package/dist/layout/theme-storage-key.cjs +5 -10
  57. package/dist/layout/theme-storage-key.cjs.map +1 -1
  58. package/dist/layout/theme-storage-key.d.cts +2 -23
  59. package/dist/layout/theme-storage-key.d.ts +2 -23
  60. package/dist/layout/theme-storage-key.js +5 -2
  61. package/dist/layout/theme-storage-key.js.map +1 -1
  62. package/dist/lazy-relation-picker-dialog-2oxnA6IR.js +14 -0
  63. package/dist/lazy-relation-picker-dialog-2oxnA6IR.js.map +1 -0
  64. package/dist/lazy-relation-picker-dialog-BfAGKzUG.cjs +19 -0
  65. package/dist/lazy-relation-picker-dialog-BfAGKzUG.cjs.map +1 -0
  66. package/dist/markdown/index.cjs +424 -511
  67. package/dist/markdown/index.cjs.map +1 -1
  68. package/dist/markdown/index.d.cts +1072 -34
  69. package/dist/markdown/index.d.ts +1072 -34
  70. package/dist/markdown/index.js +411 -459
  71. package/dist/markdown/index.js.map +1 -1
  72. package/dist/page-flow-route-CQ7HsbBm.cjs +277 -0
  73. package/dist/page-flow-route-CQ7HsbBm.cjs.map +1 -0
  74. package/dist/page-flow-route-CyXSvXSE.js +277 -0
  75. package/dist/page-flow-route-CyXSvXSE.js.map +1 -0
  76. package/dist/peek-filter-CnqHwTMU.cjs +51 -0
  77. package/dist/peek-filter-CnqHwTMU.cjs.map +1 -0
  78. package/dist/peek-filter-ErLfO153.js +28 -0
  79. package/dist/peek-filter-ErLfO153.js.map +1 -0
  80. package/dist/place-node--GdsP688.js +7315 -0
  81. package/dist/place-node--GdsP688.js.map +1 -0
  82. package/dist/place-node-SIp4XYQH.cjs +7833 -0
  83. package/dist/place-node-SIp4XYQH.cjs.map +1 -0
  84. package/dist/related-list-cards-B6x9HQQp.js +42 -0
  85. package/dist/related-list-cards-B6x9HQQp.js.map +1 -0
  86. package/dist/related-list-cards-nxuODlIA.cjs +42 -0
  87. package/dist/related-list-cards-nxuODlIA.cjs.map +1 -0
  88. package/dist/related-list-timeline-BYJKEbmA.cjs +142 -0
  89. package/dist/related-list-timeline-BYJKEbmA.cjs.map +1 -0
  90. package/dist/related-list-timeline-DEdfd-rr.js +142 -0
  91. package/dist/related-list-timeline-DEdfd-rr.js.map +1 -0
  92. package/dist/related-rows-B4levHcR.js +186 -0
  93. package/dist/related-rows-B4levHcR.js.map +1 -0
  94. package/dist/related-rows-zh5f_4QR.cjs +209 -0
  95. package/dist/related-rows-zh5f_4QR.cjs.map +1 -0
  96. package/dist/relation-create-BOaUe12G.cjs +362 -0
  97. package/dist/relation-create-BOaUe12G.cjs.map +1 -0
  98. package/dist/relation-create-Bg-eEJLs.js +337 -0
  99. package/dist/relation-create-Bg-eEJLs.js.map +1 -0
  100. package/dist/relation-many-picker-B-NCEUgX.cjs +465 -0
  101. package/dist/relation-many-picker-B-NCEUgX.cjs.map +1 -0
  102. package/dist/relation-many-picker-gdAOD-qK.js +464 -0
  103. package/dist/relation-many-picker-gdAOD-qK.js.map +1 -0
  104. package/dist/relation-picker-BAY77ivO.js +462 -0
  105. package/dist/relation-picker-BAY77ivO.js.map +1 -0
  106. package/dist/relation-picker-Da_uhFvA.cjs +479 -0
  107. package/dist/relation-picker-Da_uhFvA.cjs.map +1 -0
  108. package/dist/relation-picker-dialog-M0pQaWlp.cjs +300 -0
  109. package/dist/relation-picker-dialog-M0pQaWlp.cjs.map +1 -0
  110. package/dist/relation-picker-dialog-hA9rYrZB.js +299 -0
  111. package/dist/relation-picker-dialog-hA9rYrZB.js.map +1 -0
  112. package/dist/resource-page-router-OSQyRA5b.cjs +1779 -0
  113. package/dist/resource-page-router-OSQyRA5b.cjs.map +1 -0
  114. package/dist/resource-page-router-T4vS5gbJ.js +1582 -0
  115. package/dist/resource-page-router-T4vS5gbJ.js.map +1 -0
  116. package/dist/rich-text-DFerywgz.js +457 -0
  117. package/dist/rich-text-DFerywgz.js.map +1 -0
  118. package/dist/rich-text-vTyVjDoa.cjs +460 -0
  119. package/dist/rich-text-vTyVjDoa.cjs.map +1 -0
  120. package/dist/search-access-B7G5oR8n.cjs +812 -0
  121. package/dist/search-access-B7G5oR8n.cjs.map +1 -0
  122. package/dist/search-access-CURsWn-U.js +669 -0
  123. package/dist/search-access-CURsWn-U.js.map +1 -0
  124. package/dist/shell-BPlk8hEa.js +205 -0
  125. package/dist/shell-BPlk8hEa.js.map +1 -0
  126. package/dist/shell-DxhlsPwm.cjs +271 -0
  127. package/dist/shell-DxhlsPwm.cjs.map +1 -0
  128. package/dist/skeleton-U2noefj5.js +13 -0
  129. package/dist/skeleton-U2noefj5.js.map +1 -0
  130. package/dist/skeleton-_1gP7wan.cjs +18 -0
  131. package/dist/skeleton-_1gP7wan.cjs.map +1 -0
  132. package/dist/styles.css +255 -17
  133. package/dist/theme/theme-css.cjs +95 -96
  134. package/dist/theme/theme-css.cjs.map +1 -1
  135. package/dist/theme/theme-css.d.cts +10 -8
  136. package/dist/theme/theme-css.d.ts +10 -8
  137. package/dist/theme/theme-css.js +94 -94
  138. package/dist/theme/theme-css.js.map +1 -1
  139. package/dist/theme/theme-storage.cjs +34 -39
  140. package/dist/theme/theme-storage.cjs.map +1 -1
  141. package/dist/theme/theme-storage.d.cts +3 -1
  142. package/dist/theme/theme-storage.d.ts +3 -1
  143. package/dist/theme/theme-storage.js +33 -37
  144. package/dist/theme/theme-storage.js.map +1 -1
  145. package/dist/theme-storage-key-pYlp4aDS.d.cts +31 -0
  146. package/dist/theme-storage-key-pYlp4aDS.d.ts +31 -0
  147. package/dist/toaster-C7CiYA4Z.cjs +248 -0
  148. package/dist/toaster-C7CiYA4Z.cjs.map +1 -0
  149. package/dist/toaster-CfCRLgR-.js +164 -0
  150. package/dist/toaster-CfCRLgR-.js.map +1 -0
  151. package/dist/use-dialog-filter-state-BBCC0OEK.cjs +92 -0
  152. package/dist/use-dialog-filter-state-BBCC0OEK.cjs.map +1 -0
  153. package/dist/use-dialog-filter-state-BDcgS5Oz.js +87 -0
  154. package/dist/use-dialog-filter-state-BDcgS5Oz.js.map +1 -0
  155. package/dist/use-theme-DFlpXils.cjs +257 -0
  156. package/dist/use-theme-DFlpXils.cjs.map +1 -0
  157. package/dist/use-theme-dnE3Od3I.js +175 -0
  158. package/dist/use-theme-dnE3Od3I.js.map +1 -0
  159. package/package.json +18 -17
  160. package/dist/chunk-ABUQPOOE.js +0 -11
  161. package/dist/chunk-ABUQPOOE.js.map +0 -1
  162. package/dist/chunk-DBGGWBFG.cjs +0 -199
  163. package/dist/chunk-DBGGWBFG.cjs.map +0 -1
  164. package/dist/chunk-FMX4GLCQ.js +0 -6
  165. package/dist/chunk-FMX4GLCQ.js.map +0 -1
  166. package/dist/chunk-UC57Z243.js +0 -143
  167. package/dist/chunk-UC57Z243.js.map +0 -1
  168. package/dist/chunk-UPGPO75B.js +0 -164
  169. package/dist/chunk-UPGPO75B.js.map +0 -1
  170. package/dist/chunk-VXJAXJ3U.cjs +0 -8
  171. package/dist/chunk-VXJAXJ3U.cjs.map +0 -1
  172. package/dist/chunk-W7AEYE7A.cjs +0 -13
  173. package/dist/chunk-W7AEYE7A.cjs.map +0 -1
  174. package/dist/chunk-YF5IW525.cjs +0 -155
  175. package/dist/chunk-YF5IW525.cjs.map +0 -1
  176. package/dist/rich-text-6V7WZ3WV.cjs +0 -518
  177. package/dist/rich-text-6V7WZ3WV.cjs.map +0 -1
  178. package/dist/rich-text-N2FZEJJV.js +0 -491
  179. package/dist/rich-text-N2FZEJJV.js.map +0 -1
@@ -1,164 +0,0 @@
1
- import { cn } from './chunk-ABUQPOOE.js';
2
- import * as React3 from 'react';
3
- import { Slot } from '@radix-ui/react-slot';
4
- import { cva } from 'class-variance-authority';
5
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
- import { useOptionalT } from '@burojs/react';
7
- import * as DialogPrimitive from '@radix-ui/react-dialog';
8
- import { IconX } from '@tabler/icons-react';
9
- import * as LabelPrimitive from '@radix-ui/react-label';
10
-
11
- var buttonVariants = cva(
12
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
13
- {
14
- variants: {
15
- variant: {
16
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
17
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
18
- outline: "border border-input bg-background text-foreground hover:bg-accent hover:text-accent-foreground",
19
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
20
- ghost: "hover:bg-accent hover:text-accent-foreground",
21
- link: "text-primary underline-offset-4 hover:underline"
22
- },
23
- size: {
24
- // Shadcn new-york current defaults. The shared stylesheet keeps the
25
- // standard 16px root; editable controls choose responsive typography
26
- // locally when they need mobile `text-base` and desktop `md:text-sm`.
27
- default: "h-9 px-4 py-2",
28
- sm: "h-8 rounded-md px-3 text-xs",
29
- lg: "h-10 rounded-md px-6",
30
- icon: "h-9 w-9"
31
- }
32
- },
33
- defaultVariants: {
34
- variant: "default",
35
- size: "default"
36
- }
37
- }
38
- );
39
- var Button = React3.forwardRef(
40
- ({ className, variant, size, asChild = false, ...props }, ref) => {
41
- const Comp = asChild ? Slot : "button";
42
- return /* @__PURE__ */ jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
43
- }
44
- );
45
- Button.displayName = "Button";
46
- var Input = React3.forwardRef(
47
- ({ className, type, ...props }, ref) => {
48
- return /* @__PURE__ */ jsx(
49
- "input",
50
- {
51
- type,
52
- className: cn(
53
- "flex h-9 w-full rounded-md border border-input bg-background text-foreground px-3 py-1 text-base md:text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 disabled:bg-input-disabled",
54
- className
55
- ),
56
- ref,
57
- ...props
58
- }
59
- );
60
- }
61
- );
62
- Input.displayName = "Input";
63
- var Dialog = DialogPrimitive.Root;
64
- var DialogTrigger = DialogPrimitive.Trigger;
65
- var DialogClose = DialogPrimitive.Close;
66
- var DialogPortal = DialogPrimitive.Portal;
67
- var DialogOverlay = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
68
- DialogPrimitive.Overlay,
69
- {
70
- ref,
71
- className: cn(
72
- "fixed inset-0 z-50 bg-overlay/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-[var(--duration-overlay)] ease-[var(--ease-overlay)]",
73
- className
74
- ),
75
- ...props
76
- }
77
- ));
78
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
79
- var DialogContent = React3.forwardRef(({ className, children, overlayClassName, showClose = true, ...props }, ref) => {
80
- const t = useOptionalT();
81
- return /* @__PURE__ */ jsxs(DialogPortal, { children: [
82
- /* @__PURE__ */ jsx(DialogOverlay, { className: overlayClassName }),
83
- /* @__PURE__ */ jsxs(
84
- DialogPrimitive.Content,
85
- {
86
- ref,
87
- className: cn(
88
- "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background text-foreground p-6 shadow-lg duration-[var(--duration-overlay)] ease-[var(--ease-overlay)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
89
- className
90
- ),
91
- ...props,
92
- children: [
93
- children,
94
- showClose && /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
95
- /* @__PURE__ */ jsx(IconX, { className: "h-4 w-4" }),
96
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("actions.close", { defaultValue: "Close" }) })
97
- ] })
98
- ]
99
- }
100
- )
101
- ] });
102
- });
103
- DialogContent.displayName = DialogPrimitive.Content.displayName;
104
- function DialogHeader({ className, ...props }) {
105
- return /* @__PURE__ */ jsx(
106
- "div",
107
- {
108
- className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className),
109
- ...props
110
- }
111
- );
112
- }
113
- DialogHeader.displayName = "DialogHeader";
114
- function DialogFooter({ className, ...props }) {
115
- return /* @__PURE__ */ jsx(
116
- "div",
117
- {
118
- className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className),
119
- ...props
120
- }
121
- );
122
- }
123
- DialogFooter.displayName = "DialogFooter";
124
- var DialogTitle = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
125
- DialogPrimitive.Title,
126
- {
127
- ref,
128
- className: cn("text-lg font-semibold leading-none tracking-tight", className),
129
- ...props
130
- }
131
- ));
132
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
133
- var DialogDescription = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
134
- DialogPrimitive.Description,
135
- {
136
- ref,
137
- className: cn("text-sm text-muted-foreground", className),
138
- ...props
139
- }
140
- ));
141
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
142
- var labelVariants = cva(
143
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
144
- );
145
- var Label = React3.forwardRef(
146
- ({ className, required, children, ...props }, ref) => {
147
- const t = useOptionalT();
148
- return /* @__PURE__ */ jsxs(LabelPrimitive.Root, { ref, className: cn(labelVariants(), className), ...props, children: [
149
- children,
150
- required && /* @__PURE__ */ jsxs(Fragment, { children: [
151
- /* @__PURE__ */ jsx("span", { className: "ml-0.5 text-destructive", "aria-hidden": "true", children: "*" }),
152
- /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
153
- " ",
154
- t("validation.requiredHint", { defaultValue: "(required)" })
155
- ] })
156
- ] })
157
- ] });
158
- }
159
- );
160
- Label.displayName = LabelPrimitive.Root.displayName;
161
-
162
- export { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Input, Label, buttonVariants };
163
- //# sourceMappingURL=chunk-UPGPO75B.js.map
164
- //# sourceMappingURL=chunk-UPGPO75B.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/primitives/button.tsx","../src/primitives/input.tsx","../src/primitives/dialog.tsx","../src/primitives/label.tsx"],"names":["React","React2","jsx","cva","React4","useOpt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Content":["'use client';\n\nimport * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from '../lib/cn.js';\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground hover:bg-primary/90',\n destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',\n outline:\n 'border border-input bg-background text-foreground hover:bg-accent hover:text-accent-foreground',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',\n ghost: 'hover:bg-accent hover:text-accent-foreground',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n // Shadcn new-york current defaults. The shared stylesheet keeps the\n // standard 16px root; editable controls choose responsive typography\n // locally when they need mobile `text-base` and desktop `md:text-sm`.\n default: 'h-9 px-4 py-2',\n sm: 'h-8 rounded-md px-3 text-xs',\n lg: 'h-10 rounded-md px-6',\n icon: 'h-9 w-9',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n },\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button';\n return (\n <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />\n );\n },\n);\nButton.displayName = 'Button';\n\nexport { Button, buttonVariants };\n","'use client';\n\nimport * as React from 'react';\nimport { cn } from '../lib/cn.js';\n\nexport type InputProps = React.InputHTMLAttributes<HTMLInputElement>;\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ className, type, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n 'flex h-9 w-full rounded-md border border-input bg-background text-foreground px-3 py-1 text-base md:text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 disabled:bg-input-disabled',\n className,\n )}\n ref={ref}\n {...props}\n />\n );\n },\n);\nInput.displayName = 'Input';\n\nexport { Input };\n","'use client';\nimport { useOptionalT } from '@burojs/react';\n\nimport * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { IconX } from '@tabler/icons-react';\nimport { cn } from '../lib/cn.js';\n\nconst Dialog = DialogPrimitive.Root;\nconst DialogTrigger = DialogPrimitive.Trigger;\nconst DialogClose = DialogPrimitive.Close;\nconst DialogPortal = DialogPrimitive.Portal;\n\nexport type DialogOverlayProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n DialogOverlayProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-50 bg-overlay/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-[var(--duration-overlay)] ease-[var(--ease-overlay)]',\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nexport type DialogContentProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {\n /**\n * Optional className applied to the rendered `<DialogOverlay>`.\n * Useful for case-by-case backdrop styling (e.g. the command palette\n * applies `backdrop-blur-sm` to soften the underlying chrome) without\n * having to fork the whole `DialogContent` wrapper.\n */\n overlayClassName?: string;\n /** Whether the standard visual close button is rendered. Defaults to true. */\n showClose?: boolean;\n};\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(({ className, children, overlayClassName, showClose = true, ...props }, ref) => {\n const t = useOptionalT();\n return (\n <DialogPortal>\n <DialogOverlay className={overlayClassName} />\n {/* No slide-* class here on purpose. This surface centres itself with\n `translate-x-[-50%] translate-y-[-50%]`, which Tailwind v4 compiles\n to the `translate` CSS property; tw-animate-css's slide keyframes\n write `transform`. `translate` and `transform` COMPOSE instead of\n one overriding the other, so a `slide-in-from-*`/`slide-out-to-*`\n class here would ADD an offset on top of the centring and the\n dialog would animate in diagonally — see\n tests/overlay-animation.test.tsx. Fade + zoom are safe: zoom only\n feeds `--tw-enter-scale`, which lives inside the keyframe's own\n `transform`. */}\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background text-foreground p-6 shadow-lg duration-[var(--duration-overlay)] ease-[var(--ease-overlay)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg',\n className,\n )}\n {...props}\n >\n {children}\n {showClose && (\n <DialogPrimitive.Close className=\"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <IconX className=\"h-4 w-4\" />\n <span className=\"sr-only\">{t('actions.close', { defaultValue: 'Close' })}</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n );\n});\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nexport type DialogHeaderProps = React.HTMLAttributes<HTMLDivElement>;\n\nfunction DialogHeader({ className, ...props }: DialogHeaderProps) {\n return (\n <div\n className={cn('flex flex-col space-y-1.5 text-center sm:text-left', className)}\n {...props}\n />\n );\n}\nDialogHeader.displayName = 'DialogHeader';\n\nexport type DialogFooterProps = React.HTMLAttributes<HTMLDivElement>;\n\nfunction DialogFooter({ className, ...props }: DialogFooterProps) {\n return (\n <div\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}\n {...props}\n />\n );\n}\nDialogFooter.displayName = 'DialogFooter';\n\nexport type DialogTitleProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>;\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n DialogTitleProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold leading-none tracking-tight', className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nexport type DialogDescriptionProps = React.ComponentPropsWithoutRef<\n typeof DialogPrimitive.Description\n>;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n DialogDescriptionProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogTitle,\n DialogDescription,\n DialogFooter,\n DialogClose,\n};\n","'use client';\nimport { useOptionalT } from '@burojs/react';\n\nimport * as React from 'react';\nimport * as LabelPrimitive from '@radix-ui/react-label';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from '../lib/cn.js';\n\nconst labelVariants = cva(\n 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n);\n\nexport type LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &\n VariantProps<typeof labelVariants> & {\n /**\n * When true, append a destructive-colored asterisk after the label text\n * plus a screen-reader-only \"(required)\" hint. This is the single-source\n * required-indicator style — every form should render its required-field\n * label as `<Label required>...</Label>` rather than hand-rolling the\n * asterisk markup. The visual asterisk is `aria-hidden`; AT users get\n * the spoken hint via the sr-only span. (Inputs are still expected to\n * carry their own `aria-required` / `required` HTML attributes for the\n * native semantics.)\n */\n required?: boolean;\n };\n\nconst Label = React.forwardRef<React.ElementRef<typeof LabelPrimitive.Root>, LabelProps>(\n ({ className, required, children, ...props }, ref) => {\n // Localized because this renders inside a Russian-primary product; a\n // screen-reader user should not hear an English \"(required)\".\n const t = useOptionalT();\n return (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props}>\n {children}\n {required && (\n <>\n <span className=\"ml-0.5 text-destructive\" aria-hidden=\"true\">\n *\n </span>\n <span className=\"sr-only\">\n {' '}\n {t('validation.requiredHint', { defaultValue: '(required)' })}\n </span>\n </>\n )}\n </LabelPrimitive.Root>\n );\n },\n);\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n"]}
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- // src/layout/theme-storage-key.ts
4
- var THEME_STORAGE_KEY = "buro-theme";
5
-
6
- exports.THEME_STORAGE_KEY = THEME_STORAGE_KEY;
7
- //# sourceMappingURL=chunk-VXJAXJ3U.cjs.map
8
- //# sourceMappingURL=chunk-VXJAXJ3U.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/layout/theme-storage-key.ts"],"names":[],"mappings":";;;AAoBO,IAAM,iBAAA,GAAoB","file":"chunk-VXJAXJ3U.cjs","sourcesContent":["/**\n * The ONE localStorage key every theme-aware place in the app must agree on.\n * Exported so nothing re-types the string — two files agreeing on a literal\n * is how they drift.\n *\n * Deliberately its own module: no `'use client'`, no React import, nothing\n * that would pull in `use-theme.ts`'s hook (or the rest of the kit's client\n * component tree). That matters because the ONE consumer that needs this\n * constant outside a hook is the bootstrap `<script>` in the playground's\n * root `app/layout.tsx` — a Server Component, which cannot itself carry\n * `'use client'`. Importing from the package's main entry (`@burojs/ui-shadcn`)\n * there fails Next's server/client boundary check, because that entry\n * bundles the whole kit — including many components that call hooks —\n * into one file without a top-level `'use client'` directive (tsup drops it\n * when bundling multiple client modules together). Importing this file\n * directly via the `@burojs/ui-shadcn/theme-storage-key` subpath sidesteps\n * that: it has no hooks, so a Server Component can import the real string\n * value at build/SSR time. `use-theme.ts` re-exports the same constant for\n * everyone else, so there is exactly one literal in the whole codebase.\n */\nexport const THEME_STORAGE_KEY = 'buro-theme';\n"]}
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- var clsx = require('clsx');
4
- var tailwindMerge = require('tailwind-merge');
5
-
6
- // src/lib/cn.ts
7
- function cn(...inputs) {
8
- return tailwindMerge.twMerge(clsx.clsx(inputs));
9
- }
10
-
11
- exports.cn = cn;
12
- //# sourceMappingURL=chunk-W7AEYE7A.cjs.map
13
- //# sourceMappingURL=chunk-W7AEYE7A.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/cn.ts"],"names":["twMerge","clsx"],"mappings":";;;;;;AAGO,SAAS,MAAM,MAAA,EAA8B;AAClD,EAAA,OAAOA,qBAAA,CAAQC,SAAA,CAAK,MAAM,CAAC,CAAA;AAC7B","file":"chunk-W7AEYE7A.cjs","sourcesContent":["import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n"]}
@@ -1,155 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkVXJAXJ3U_cjs = require('./chunk-VXJAXJ3U.cjs');
4
- var GithubSlugger = require('github-slugger');
5
- var react = require('react');
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
-
9
- var GithubSlugger__default = /*#__PURE__*/_interopDefault(GithubSlugger);
10
-
11
- var DOC_ID_PREFIX = "user-content-";
12
- function docSlug(text) {
13
- return new GithubSlugger__default.default().slug(text);
14
- }
15
- function readDocHash() {
16
- if (typeof window === "undefined") return "";
17
- const raw = window.location.hash.replace(/^#/, "");
18
- if (raw === "") return "";
19
- try {
20
- return decodeURIComponent(raw);
21
- } catch {
22
- return raw;
23
- }
24
- }
25
- function findDocAnchor(hash, root = document) {
26
- let id = hash.replace(/^#/, "");
27
- if (id === "") return null;
28
- try {
29
- id = decodeURIComponent(id);
30
- } catch {
31
- }
32
- const doc = root.ownerDocument ?? root;
33
- const pick = (candidate) => {
34
- const el = doc.getElementById(candidate);
35
- if (!el) return null;
36
- return root === doc || root.contains(el) ? el : null;
37
- };
38
- return pick(DOC_ID_PREFIX + id) ?? pick(id);
39
- }
40
- function placeInScroller(target) {
41
- let container = target.parentElement;
42
- while (container) {
43
- const style = getComputedStyle(container);
44
- if (/(auto|scroll)/.test(style.overflowY) && container.scrollHeight > container.clientHeight + 1) {
45
- break;
46
- }
47
- container = container.parentElement;
48
- }
49
- if (!container) {
50
- target.scrollIntoView({ block: "start", behavior: "auto" });
51
- return;
52
- }
53
- const margin = Number.parseFloat(getComputedStyle(target).scrollMarginTop) || 0;
54
- const delta = target.getBoundingClientRect().top - container.getBoundingClientRect().top - margin;
55
- container.scrollTop += delta;
56
- }
57
- function scrollToDocAnchor(hash, root = document.body, settleMs = 1500) {
58
- let stopped = false;
59
- const go = () => {
60
- if (stopped) return;
61
- const target = findDocAnchor(hash, root);
62
- if (target) placeInScroller(target);
63
- };
64
- const raf1 = requestAnimationFrame(() => requestAnimationFrame(go));
65
- const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => requestAnimationFrame(go));
66
- observer?.observe(root);
67
- const timer = setTimeout(() => {
68
- stopped = true;
69
- observer?.disconnect();
70
- }, settleMs);
71
- return () => {
72
- stopped = true;
73
- cancelAnimationFrame(raf1);
74
- observer?.disconnect();
75
- clearTimeout(timer);
76
- };
77
- }
78
- function docShareUrl(slug, href = window.location.href) {
79
- const url = new URL(href);
80
- const safe = /[#?%\s]/.test(slug) ? encodeURIComponent(slug) : slug;
81
- return `${url.origin}${url.pathname}${url.search}#${safe}`;
82
- }
83
- function systemPrefersDark() {
84
- return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches;
85
- }
86
- function readChoice() {
87
- if (typeof window === "undefined") return "system";
88
- try {
89
- const saved = window.localStorage.getItem(chunkVXJAXJ3U_cjs.THEME_STORAGE_KEY);
90
- if (saved === "light" || saved === "dark") return saved;
91
- } catch {
92
- }
93
- return "system";
94
- }
95
- function resolveTheme(choice) {
96
- if (choice === "light" || choice === "dark") return choice;
97
- return systemPrefersDark() ? "dark" : "light";
98
- }
99
- function applyDomClass(resolved) {
100
- if (typeof document === "undefined") return;
101
- document.documentElement.classList.toggle("dark", resolved === "dark");
102
- }
103
- function persistChoice(choice) {
104
- if (typeof window === "undefined") return;
105
- try {
106
- if (choice === "system") window.localStorage.removeItem(chunkVXJAXJ3U_cjs.THEME_STORAGE_KEY);
107
- else window.localStorage.setItem(chunkVXJAXJ3U_cjs.THEME_STORAGE_KEY, choice);
108
- } catch {
109
- }
110
- }
111
- function useTheme() {
112
- const [state, setState] = react.useState({ choice: "system", resolved: "light" });
113
- react.useEffect(() => {
114
- const choice = readChoice();
115
- setState({ choice, resolved: resolveTheme(choice) });
116
- const root = document.documentElement;
117
- const observer = new MutationObserver(() => {
118
- const resolved = root.classList.contains("dark") ? "dark" : "light";
119
- setState((prev) => prev.resolved === resolved ? prev : { ...prev, resolved });
120
- });
121
- observer.observe(root, { attributes: true, attributeFilter: ["class"] });
122
- const mql = typeof window.matchMedia === "function" ? window.matchMedia("(prefers-color-scheme: dark)") : void 0;
123
- const onSystemChange = (event) => {
124
- const choice2 = readChoice();
125
- if (choice2 !== "system") return;
126
- const resolved = event.matches ? "dark" : "light";
127
- applyDomClass(resolved);
128
- setState(
129
- (prev) => prev.choice === choice2 && prev.resolved === resolved ? prev : { choice: choice2, resolved }
130
- );
131
- };
132
- mql?.addEventListener("change", onSystemChange);
133
- return () => {
134
- observer.disconnect();
135
- mql?.removeEventListener("change", onSystemChange);
136
- };
137
- }, []);
138
- const setTheme = react.useCallback((next) => {
139
- const resolved = resolveTheme(next);
140
- applyDomClass(resolved);
141
- persistChoice(next);
142
- setState({ choice: next, resolved });
143
- }, []);
144
- return { choice: state.choice, resolved: state.resolved, setTheme };
145
- }
146
-
147
- exports.DOC_ID_PREFIX = DOC_ID_PREFIX;
148
- exports.docShareUrl = docShareUrl;
149
- exports.docSlug = docSlug;
150
- exports.findDocAnchor = findDocAnchor;
151
- exports.readDocHash = readDocHash;
152
- exports.scrollToDocAnchor = scrollToDocAnchor;
153
- exports.useTheme = useTheme;
154
- //# sourceMappingURL=chunk-YF5IW525.cjs.map
155
- //# sourceMappingURL=chunk-YF5IW525.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/markdown/anchors.ts","../src/layout/use-theme.ts"],"names":["GithubSlugger","THEME_STORAGE_KEY","useState","useEffect","choice","useCallback"],"mappings":";;;;;;;;;;AAkBO,IAAM,aAAA,GAAgB;AAUtB,SAAS,QAAQ,IAAA,EAAsB;AAC5C,EAAA,OAAO,IAAIA,8BAAA,EAAc,CAAE,IAAA,CAAK,IAAI,CAAA;AACtC;AAWO,SAAS,WAAA,GAAsB;AACpC,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,EAAa,OAAO,EAAA;AAC1C,EAAA,MAAM,MAAM,MAAA,CAAO,QAAA,CAAS,IAAA,CAAK,OAAA,CAAQ,MAAM,EAAE,CAAA;AACjD,EAAA,IAAI,GAAA,KAAQ,IAAI,OAAO,EAAA;AACvB,EAAA,IAAI;AACF,IAAA,OAAO,mBAAmB,GAAG,CAAA;AAAA,EAC/B,CAAA,CAAA,MAAQ;AAEN,IAAA,OAAO,GAAA;AAAA,EACT;AACF;AASO,SAAS,aAAA,CAAc,IAAA,EAAc,IAAA,GAA2B,QAAA,EAA0B;AAC/F,EAAA,IAAI,EAAA,GAAK,IAAA,CAAK,OAAA,CAAQ,IAAA,EAAM,EAAE,CAAA;AAC9B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A,KAAWA,OAAAA,IAAU,IAAA,CAAK,QAAA,KAAa,QAAA,GAAW,IAAA,GAAO,EAAE,MAAA,EAAAA,OAAAA,EAAQ,QAAA;AAAS,OACnF;AAAA,IACF,CAAA;AACA,IAAA,GAAA,EAAK,gBAAA,CAAiB,UAAU,cAAc,CAAA;AAE9C,IAAA,OAAO,MAAM;AACX,MAAA,QAAA,CAAS,UAAA,EAAW;AACpB,MAAA,GAAA,EAAK,mBAAA,CAAoB,UAAU,cAAc,CAAA;AAAA,IACnD,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,QAAA,GAAWC,iBAAA,CAAY,CAAC,IAAA,KAAsB;AAClD,IAAA,MAAM,QAAA,GAAW,aAAa,IAAI,CAAA;AAClC,IAAA,aAAA,CAAc,QAAQ,CAAA;AACtB,IAAA,aAAA,CAAc,IAAI,CAAA;AAClB,IAAA,QAAA,CAAS,EAAE,MAAA,EAAQ,IAAA,EAAM,QAAA,EAAU,CAAA;AAAA,EACrC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,CAAM,QAAQ,QAAA,EAAU,KAAA,CAAM,UAAU,QAAA,EAAS;AACpE","file":"chunk-YF5IW525.cjs","sourcesContent":["import GithubSlugger from 'github-slugger';\n\n/**\n * Anchor identity for documentation, in ONE place.\n *\n * Three things have to agree on what `#kak-ustroen-gtin` means: `rehype-slug`,\n * which stamps ids onto headings; the FAQ accordion, which is built from\n * headings but never goes through rehype; and whatever scrolls to a hash. When\n * they disagree the link simply does nothing — no error, no console warning,\n * the page just sits there — so the algorithm lives here and everyone imports it.\n *\n * `github-slugger` is not an extra dependency: `rehype-slug` uses it internally,\n * which is exactly why it is the right choice — matching its output by\n * reimplementing it would be a slow-motion bug in a language with case rules,\n * combining marks and a Cyrillic alphabet.\n */\n\n/** Prefix `rehype-sanitize` renames every id to. See `defaultSchema.clobberPrefix`. */\nexport const DOC_ID_PREFIX = 'user-content-';\n\n/**\n * Slug for a heading's text — the value that appears in a shareable `#hash`.\n *\n * A fresh slugger per call ON PURPOSE. `GithubSlugger` is stateful: it\n * remembers what it has emitted and disambiguates repeats as `foo-1`, `foo-2`.\n * That is right when walking one document top to bottom, and wrong here, where\n * the same heading must produce the same hash every time it is asked about.\n */\nexport function docSlug(text: string): string {\n return new GithubSlugger().slug(text);\n}\n\n/**\n * The current fragment, DECODED, without its `#`.\n *\n * `window.location.hash` hands back a percent-encoded string —\n * `#%D0%BF%D0%BE%D1%87%D0%B5%D0%BC%D1%83…` for `#почему…` — so every\n * comparison against a slug fails, silently, for exactly the alphabet this\n * project writes its documentation in. It works perfectly in English, which is\n * the worst possible way for it to be wrong.\n */\nexport function readDocHash(): string {\n if (typeof window === 'undefined') return '';\n const raw = window.location.hash.replace(/^#/, '');\n if (raw === '') return '';\n try {\n return decodeURIComponent(raw);\n } catch {\n // A malformed escape sequence is not worth throwing over.\n return raw;\n }\n}\n\n/**\n * Find the element a hash points at.\n *\n * Tries the prefixed id first, because a heading inside sanitized Markdown is\n * the common case, then the bare one for anchors we render ourselves (the FAQ\n * accordion, which is built from React and never passes through the sanitizer).\n */\nexport function findDocAnchor(hash: string, root: Document | Element = document): Element | null {\n let id = hash.replace(/^#/, '');\n if (id === '') return null;\n try {\n id = decodeURIComponent(id);\n } catch {\n /* keep the raw form */\n }\n\n /*\n `getElementById`, NOT `querySelector('#'+id)`.\n\n A fragment is user input — it arrives from the address bar — and `#a.b:c`\n is a perfectly ordinary thing to paste and an invalid CSS selector, so\n `querySelector` throws a `SyntaxError` on it. `CSS.escape` would fix that\n where it exists, and it does not exist in jsdom, so the crash would have\n been invisible to the unit suite and live only in production. Looking an id\n up by id involves no selector parsing at all.\n */\n const doc = root.ownerDocument ?? (root as Document);\n const pick = (candidate: string): Element | null => {\n const el = doc.getElementById(candidate);\n if (!el) return null;\n // Scoped lookups must not reach outside their root — the handbook searches\n // within the open article so a stale heading elsewhere cannot win.\n return root === doc || root.contains(el) ? el : null;\n };\n return pick(DOC_ID_PREFIX + id) ?? pick(id);\n}\n\n/**\n * Bring an element to the top of ITS OWN scroll container, and nothing else.\n *\n * `scrollIntoView` cannot be used here. It scrolls EVERY scrollable ancestor,\n * the document included — and the document does scroll in this shell, because\n * `SidebarInset` is `min-h-svh` and the app's own sidebar can exceed a short\n * viewport. Clicking an anchor therefore dragged the whole page up: the app\n * header and the handbook's own search box went off the top of the screen, and\n * the layout read as broken. Caught in a screenshot, not by any assertion.\n *\n * Walking to the nearest scrollable ancestor and moving only that keeps the\n * effect where the reader expects it — inside the column they are reading.\n * `scroll-margin-top` is honoured by hand, since we are no longer going through\n * the API that would apply it.\n */\nfunction placeInScroller(target: Element): void {\n let container = target.parentElement;\n while (container) {\n const style = getComputedStyle(container);\n if (\n /(auto|scroll)/.test(style.overflowY) &&\n container.scrollHeight > container.clientHeight + 1\n ) {\n break;\n }\n container = container.parentElement;\n }\n if (!container) {\n // Nothing between here and the document scrolls; the browser's own\n // behaviour is then exactly right.\n target.scrollIntoView({ block: 'start', behavior: 'auto' });\n return;\n }\n const margin = Number.parseFloat(getComputedStyle(target).scrollMarginTop) || 0;\n const delta = target.getBoundingClientRect().top - container.getBoundingClientRect().top - margin;\n container.scrollTop += delta;\n}\n\n/**\n * Scroll to an anchor and KEEP it in view while the article settles.\n *\n * One `scrollIntoView` is not enough here. An article's height is not final\n * when its markup lands: a mermaid diagram renders asynchronously and a lazily\n * loaded image has no height until it arrives, and either one appearing ABOVE\n * the target pushes it back down — the reader watches the page scroll to the\n * right place and then drift away from it. Measured: the target ended 731px\n * down a 709px pane, i.e. just off the bottom.\n *\n * So the scroll is repeated whenever the container resizes, for a short window\n * and no longer. The window is a deliberate ceiling rather than a guess at how\n * long rendering takes: after it, the reader owns the scroll position, and\n * yanking it back because a late image loaded would be worse than being a few\n * pixels off.\n */\nexport function scrollToDocAnchor(\n hash: string,\n root: Element = document.body,\n settleMs = 1500,\n): () => void {\n let stopped = false;\n const go = () => {\n if (stopped) return;\n const target = findDocAnchor(hash, root);\n if (target) placeInScroller(target);\n };\n // Two frames: markdown → hast → DOM, then layout.\n const raf1 = requestAnimationFrame(() => requestAnimationFrame(go));\n\n const observer =\n typeof ResizeObserver === 'undefined'\n ? null\n : new ResizeObserver(() => requestAnimationFrame(go));\n observer?.observe(root);\n const timer = setTimeout(() => {\n stopped = true;\n observer?.disconnect();\n }, settleMs);\n\n return () => {\n stopped = true;\n cancelAnimationFrame(raf1);\n observer?.disconnect();\n clearTimeout(timer);\n };\n}\n\n/**\n * A shareable url for an anchor on the current page — READABLE.\n *\n * `new URL(…).toString()` percent-encodes the fragment, so a Russian heading\n * becomes forty characters of `%D0%BF%D0%BE…`. That is correct and unusable:\n * the entire point of this link is being pasted into a message where a person\n * reads it, and a wall of escapes tells them nothing about where it goes.\n * Browsers accept a literal fragment and encode it themselves on navigation.\n *\n * The slug is still escaped if it contains anything that would change how the\n * url PARSES — `#`, `?`, whitespace, or a stray `%`. `github-slugger` does not\n * emit those, but this is the one place where being wrong produces a link that\n * silently points somewhere else.\n */\nexport function docShareUrl(slug: string, href: string = window.location.href): string {\n const url = new URL(href);\n const safe = /[#?%\\s]/.test(slug) ? encodeURIComponent(slug) : slug;\n return `${url.origin}${url.pathname}${url.search}#${safe}`;\n}\n","'use client';\nimport { useCallback, useEffect, useState } from 'react';\nimport { THEME_STORAGE_KEY } from './theme-storage-key.js';\n\n/**\n * Re-exported here so most consumers only need one import path. The\n * bootstrap script in `apps/playground/src/app/layout.tsx` is the one\n * exception — see `./theme-storage-key.js` for why it imports the constant\n * from that separate, hook-free module instead of from here.\n */\nexport { THEME_STORAGE_KEY };\n\n/** What the user picked. `'system'` means \"no explicit choice\" — nothing is\n * persisted for it; its absence from storage IS the `system` state. */\nexport type ThemeChoice = 'light' | 'dark' | 'system';\n\n/** What is actually painted. Never `'system'` — every reader (Toaster,\n * CodeMirror, Mermaid) only ever needs to know light or dark. */\nexport type ResolvedTheme = 'light' | 'dark';\n\nexport interface UseThemeResult {\n /** The persisted preference, including `'system'`. Only the theme\n * submenu (the one place with a three-way control) needs this. */\n choice: ThemeChoice;\n /** The resolved light/dark value, kept in sync with the `dark` class on\n * `<html>`. This is what every read-only consumer wants. */\n resolved: ResolvedTheme;\n /** Set a new choice: applies the `dark` class immediately and persists\n * (or, for `'system'`, clears) the preference. */\n setTheme: (next: ThemeChoice) => void;\n}\n\nfunction systemPrefersDark(): boolean {\n return (\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-color-scheme: dark)').matches\n );\n}\n\nfunction readChoice(): ThemeChoice {\n if (typeof window === 'undefined') return 'system';\n try {\n const saved = window.localStorage.getItem(THEME_STORAGE_KEY);\n if (saved === 'light' || saved === 'dark') return saved;\n } catch {\n // localStorage may be disabled — fall through to system\n }\n return 'system';\n}\n\nfunction resolveTheme(choice: ThemeChoice): ResolvedTheme {\n if (choice === 'light' || choice === 'dark') return choice;\n return systemPrefersDark() ? 'dark' : 'light';\n}\n\nfunction applyDomClass(resolved: ResolvedTheme): void {\n if (typeof document === 'undefined') return;\n document.documentElement.classList.toggle('dark', resolved === 'dark');\n}\n\nfunction persistChoice(choice: ThemeChoice): void {\n if (typeof window === 'undefined') return;\n try {\n if (choice === 'system') window.localStorage.removeItem(THEME_STORAGE_KEY);\n else window.localStorage.setItem(THEME_STORAGE_KEY, choice);\n } catch {\n // localStorage may be disabled — the class flip already applied.\n }\n}\n\ninterface ThemeState {\n choice: ThemeChoice;\n resolved: ResolvedTheme;\n}\n\n/**\n * Single source of truth for light/dark/system, replacing seven places that\n * each used to know about the theme independently (a bootstrap script, a\n * command-palette action, a submenu, an unused kit component, and three\n * MutationObserver-based readers).\n *\n * Read-only consumers (Toaster, CodeMirror, Mermaid) only need `resolved`\n * and don't call the public `setTheme` — they stay in sync via the\n * `<html class=\"dark\">` MutationObserver below, which fires regardless of\n * WHICH writer flipped it. That is deliberate: it's the same mechanism these\n * three already used individually before this hook existed, now shared\n * instead of duplicated, and it means a future writer doesn't need to know\n * about every reader. Every mounted instance — including these \"read-only\"\n * ones — still runs its OWN `onSystemChange` listener below and applies the\n * class itself on an OS change; see that listener for why re-reading storage\n * there (rather than trusting this instance's local `choice`) is required\n * for that to be safe with several instances mounted at once.\n *\n * `choice` (the three-way value, including `'system'`) is NOT synchronized\n * the same way — the `dark` class alone can't tell \"explicitly dark\" apart\n * from \"system, and the system happens to be dark\". The only consumer that\n * needs `choice` is the theme submenu, and Radix unmounts a closed dropdown's\n * content, so it re-reads storage fresh every time it opens; no live\n * cross-component sync of `choice` is needed in practice.\n *\n * NOT used by the bootstrap `<script>` in `app/layout.tsx` — see the comment\n * there for why a hook cannot do that job.\n */\nexport function useTheme(): UseThemeResult {\n // Safe default for the very first client render, corrected synchronously\n // by the effect below on mount — mirrors the pattern the three readers\n // used before migrating here (start light/false, fix it post-mount) so no\n // component newly grows a hydration-mismatch warning.\n const [state, setState] = useState<ThemeState>({ choice: 'system', resolved: 'light' });\n\n useEffect(() => {\n const choice = readChoice();\n setState({ choice, resolved: resolveTheme(choice) });\n\n const root = document.documentElement;\n const observer = new MutationObserver(() => {\n const resolved: ResolvedTheme = root.classList.contains('dark') ? 'dark' : 'light';\n setState((prev) => (prev.resolved === resolved ? prev : { ...prev, resolved }));\n });\n observer.observe(root, { attributes: true, attributeFilter: ['class'] });\n\n const mql =\n typeof window.matchMedia === 'function'\n ? window.matchMedia('(prefers-color-scheme: dark)')\n : undefined;\n const onSystemChange = (event: { matches: boolean }) => {\n // Re-read the stored choice instead of trusting this instance's own\n // `prev.choice`: `choice` is captured once at mount and never\n // resynchronised, but several `useTheme()` instances mount at once\n // (Toaster, CodeMirror, Mermaid, the admin layout, the theme submenu\n // while open). If a later explicit pick only updates the instance that\n // made it, every OTHER instance still believes `system` applies and\n // would repaint the whole app back to the OS value on the next\n // preference flip — silently overriding storage, which is why this\n // must not trust local state. Storage is already the single source of\n // truth (`setTheme('system')` clears the key), so a fresh read here is\n // correct in both directions: an explicit pick is respected, and\n // `system` is honoured even once the one instance that set it has\n // unmounted. Every other live instance's listener fires on the same OS\n // change and independently reaches the same conclusion, so several\n // instances may call `applyDomClass` with the same value for one\n // event — redundant, but harmless, and not worth coordinating.\n const choice = readChoice();\n if (choice !== 'system') return;\n const resolved: ResolvedTheme = event.matches ? 'dark' : 'light';\n applyDomClass(resolved);\n setState((prev) =>\n prev.choice === choice && prev.resolved === resolved ? prev : { choice, resolved },\n );\n };\n mql?.addEventListener('change', onSystemChange);\n\n return () => {\n observer.disconnect();\n mql?.removeEventListener('change', onSystemChange);\n };\n }, []);\n\n const setTheme = useCallback((next: ThemeChoice) => {\n const resolved = resolveTheme(next);\n applyDomClass(resolved);\n persistChoice(next);\n setState({ choice: next, resolved });\n }, []);\n\n return { choice: state.choice, resolved: state.resolved, setTheme };\n}\n"]}