@epilot/zenith-react 0.1.0-next.0 → 0.1.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 (142) hide show
  1. package/README.md +95 -15
  2. package/dist/components/appearance-boundary/appearance-boundary.js +32 -34
  3. package/dist/components/appearance-boundary/appearance-boundary.js.map +1 -1
  4. package/dist/components/badge/badge.js +1 -1
  5. package/dist/components/badge/badge.js.map +1 -1
  6. package/dist/components/breadcrumb/breadcrumb.js +10 -10
  7. package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
  8. package/dist/components/button/button.js +28 -28
  9. package/dist/components/button/button.js.map +1 -1
  10. package/dist/components/button-group/button-group.js.map +1 -1
  11. package/dist/components/callout/callout.js +13 -13
  12. package/dist/components/callout/callout.js.map +1 -1
  13. package/dist/components/card/card.js.map +1 -1
  14. package/dist/components/checkbox/checkbox.js +13 -13
  15. package/dist/components/checkbox/checkbox.js.map +1 -1
  16. package/dist/components/code-block/code-block.js +6 -6
  17. package/dist/components/code-block/code-block.js.map +1 -1
  18. package/dist/components/code-editor/code-editor.js +1 -1
  19. package/dist/components/code-editor/code-editor.js.map +1 -1
  20. package/dist/components/code-editor/indent.js.map +1 -1
  21. package/dist/components/command/command.js +7 -13
  22. package/dist/components/command/command.js.map +1 -1
  23. package/dist/components/data-table/data-table-body.js +120 -66
  24. package/dist/components/data-table/data-table-body.js.map +1 -1
  25. package/dist/components/data-table/data-table-column-header.js +7 -7
  26. package/dist/components/data-table/data-table-column-header.js.map +1 -1
  27. package/dist/components/data-table/data-table-column-order.js +277 -0
  28. package/dist/components/data-table/data-table-column-order.js.map +1 -0
  29. package/dist/components/data-table/data-table-content.js +72 -58
  30. package/dist/components/data-table/data-table-content.js.map +1 -1
  31. package/dist/components/data-table/data-table-context.js +8 -4
  32. package/dist/components/data-table/data-table-context.js.map +1 -1
  33. package/dist/components/data-table/data-table-footer.js +31 -0
  34. package/dist/components/data-table/data-table-footer.js.map +1 -0
  35. package/dist/components/data-table/data-table-header-draggable.js +151 -0
  36. package/dist/components/data-table/data-table-header-draggable.js.map +1 -0
  37. package/dist/components/data-table/data-table-header.js +130 -57
  38. package/dist/components/data-table/data-table-header.js.map +1 -1
  39. package/dist/components/data-table/data-table-resize-handle.js +137 -0
  40. package/dist/components/data-table/data-table-resize-handle.js.map +1 -0
  41. package/dist/components/data-table/data-table.js +184 -156
  42. package/dist/components/data-table/data-table.js.map +1 -1
  43. package/dist/components/data-table/hooks/use-data-table-virtualizer.js +9 -0
  44. package/dist/components/data-table/hooks/use-data-table-virtualizer.js.map +1 -0
  45. package/dist/components/date-range-picker/date-range-picker.js +197 -195
  46. package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
  47. package/dist/components/date-time-picker/calendar.js +29 -29
  48. package/dist/components/date-time-picker/calendar.js.map +1 -1
  49. package/dist/components/date-time-picker/time-picker.js +55 -55
  50. package/dist/components/date-time-picker/time-picker.js.map +1 -1
  51. package/dist/components/density-provider/density-provider.js.map +1 -1
  52. package/dist/components/dialog/dialog.js +1 -1
  53. package/dist/components/dialog/dialog.js.map +1 -1
  54. package/dist/components/drawer/drawer.js +5 -5
  55. package/dist/components/drawer/drawer.js.map +1 -1
  56. package/dist/components/dropdown-menu/dropdown-menu.js +36 -36
  57. package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
  58. package/dist/components/field/field-combobox.js +4 -4
  59. package/dist/components/field/field-combobox.js.map +1 -1
  60. package/dist/components/field/field.js +40 -40
  61. package/dist/components/field/field.js.map +1 -1
  62. package/dist/components/label/label.js +0 -28
  63. package/dist/components/label/label.js.map +1 -1
  64. package/dist/components/list/list.js +42 -52
  65. package/dist/components/list/list.js.map +1 -1
  66. package/dist/components/option-card/option-card.js +27 -25
  67. package/dist/components/option-card/option-card.js.map +1 -1
  68. package/dist/components/pill/pill.js +9 -9
  69. package/dist/components/pill/pill.js.map +1 -1
  70. package/dist/components/radio/radio.js +14 -14
  71. package/dist/components/radio/radio.js.map +1 -1
  72. package/dist/components/scroll-area/scroll-area.js +9 -9
  73. package/dist/components/scroll-area/scroll-area.js.map +1 -1
  74. package/dist/components/segmented-control/segmented-control.js +1 -1
  75. package/dist/components/segmented-control/segmented-control.js.map +1 -1
  76. package/dist/components/select/select.js +11 -11
  77. package/dist/components/select/select.js.map +1 -1
  78. package/dist/components/separator/separator.js.map +1 -1
  79. package/dist/components/skeleton/skeleton.js.map +1 -1
  80. package/dist/components/slot/compose-as-child.js.map +1 -1
  81. package/dist/components/spinner/spinner.js.map +1 -1
  82. package/dist/components/switch/switch.js +11 -11
  83. package/dist/components/switch/switch.js.map +1 -1
  84. package/dist/components/table/table-pagination.js +1 -1
  85. package/dist/components/table/table-pagination.js.map +1 -1
  86. package/dist/components/table/table.js +15 -15
  87. package/dist/components/table/table.js.map +1 -1
  88. package/dist/components/text/text.js +10 -1
  89. package/dist/components/text/text.js.map +1 -1
  90. package/dist/components/toast/toast.js +30 -32
  91. package/dist/components/toast/toast.js.map +1 -1
  92. package/dist/components/toggle/toggle.js +20 -20
  93. package/dist/components/toggle/toggle.js.map +1 -1
  94. package/dist/delivery/index.d.ts +10 -44
  95. package/dist/delivery/index.js +5 -9
  96. package/dist/index.d.ts +1994 -2272
  97. package/dist/index.js +133 -121
  98. package/dist/index.js.map +1 -1
  99. package/dist/lib/clear-button.js.map +1 -1
  100. package/dist/lib/code-highlight.js.map +1 -1
  101. package/dist/lib/code-tokens.js.map +1 -1
  102. package/dist/lib/pagination.js.map +1 -1
  103. package/dist/packages/tokens/dist/delivery/index.js +18 -48
  104. package/dist/packages/tokens/dist/delivery/index.js.map +1 -1
  105. package/dist/packages/tokens/dist/generated/core.generated.js +18 -0
  106. package/dist/packages/tokens/dist/generated/core.generated.js.map +1 -0
  107. package/dist/packages/tokens/dist/generated/palette.generated.js +5 -5
  108. package/dist/packages/tokens/dist/generated/palette.generated.js.map +1 -1
  109. package/dist/packages/tokens/dist/install.js +9 -9
  110. package/dist/packages/tokens/dist/install.js.map +1 -1
  111. package/dist/styles/document-context.js.map +1 -1
  112. package/dist/styles/make-styles.js.map +1 -1
  113. package/dist/tokens/core.meta.generated.js +2 -2
  114. package/dist/tokens/core.meta.generated.js.map +1 -1
  115. package/dist/tokens/index.d.ts +1029 -1104
  116. package/dist/tokens/index.js +1031 -1106
  117. package/dist/tokens/index.js.map +1 -1
  118. package/dist/tokens/palette.generated.js +2 -2
  119. package/dist/tokens/palette.generated.js.map +1 -1
  120. package/dist/tokens/use-palette-tokens.js.map +1 -1
  121. package/dist/tokens.json +605 -755
  122. package/dist/vendor/.bun/@dnd-kit_core@6.3.1_6f4b9a1cfb20c0ae/vendor/@dnd-kit/core/dist/core.esm.js +385 -340
  123. package/dist/vendor/.bun/@dnd-kit_core@6.3.1_6f4b9a1cfb20c0ae/vendor/@dnd-kit/core/dist/core.esm.js.map +1 -1
  124. package/dist/vendor/.bun/@dnd-kit_sortable@10.0.0_1d291640e1250bbe/vendor/@dnd-kit/sortable/dist/sortable.esm.js +344 -229
  125. package/dist/vendor/.bun/@dnd-kit_sortable@10.0.0_1d291640e1250bbe/vendor/@dnd-kit/sortable/dist/sortable.esm.js.map +1 -1
  126. package/dist/vendor/.bun/@dnd-kit_utilities@3.2.2_62547eec5a2188e3/vendor/@dnd-kit/utilities/dist/utilities.esm.js +1 -1
  127. package/dist/vendor/.bun/@tanstack_react-virtual@3.11.2_6f4b9a1cfb20c0ae/vendor/@tanstack/react-virtual/dist/esm/index.js +36 -0
  128. package/dist/vendor/.bun/@tanstack_react-virtual@3.11.2_6f4b9a1cfb20c0ae/vendor/@tanstack/react-virtual/dist/esm/index.js.map +1 -0
  129. package/dist/vendor/.bun/@tanstack_virtual-core@3.11.2/vendor/@tanstack/virtual-core/dist/esm/index.js +450 -0
  130. package/dist/vendor/.bun/@tanstack_virtual-core@3.11.2/vendor/@tanstack/virtual-core/dist/esm/index.js.map +1 -0
  131. package/dist/vendor/.bun/@tanstack_virtual-core@3.11.2/vendor/@tanstack/virtual-core/dist/esm/utils.js +50 -0
  132. package/dist/vendor/.bun/@tanstack_virtual-core@3.11.2/vendor/@tanstack/virtual-core/dist/esm/utils.js.map +1 -0
  133. package/package.json +5 -4
  134. package/scripts/migration-diagnostics-core.mjs +19 -90
  135. package/scripts/migration-diagnostics.mjs +1 -16
  136. package/scripts/migration-sweep.mjs +2 -12
  137. package/ADOPTING.md +0 -73
  138. package/dist/packages/tokens/dist/delivery/internal.js +0 -181
  139. package/dist/packages/tokens/dist/delivery/internal.js.map +0 -1
  140. package/dist/packages/tokens/dist/generated/core.meta.generated.js +0 -10
  141. package/dist/packages/tokens/dist/generated/core.meta.generated.js.map +0 -1
  142. package/dist/token-assets/core/5cd4072decf5df2a664f0b1d5f2ec250a3309101ded3056c1f87c8bbe3738d50.css +0 -22
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import * as o from "./tokens/index.js";
2
2
  import { makeZenithResetStyles as t, makeZenithStyles as a } from "./styles/make-styles.js";
3
3
  import { SLOT_ATTR as i, assertAnchorIsFirstInHead as n, mergeClasses as p, shorthands as m } from "@epilot/zenith-runtime/v1";
4
- import { BADGE_COLORS as d, Badge as x } from "./components/badge/badge.js";
4
+ import { BADGE_COLORS as x, Badge as d } from "./components/badge/badge.js";
5
5
  import { Breadcrumb as s, BreadcrumbItem as u } from "./components/breadcrumb/breadcrumb.js";
6
6
  import { Callout as D, CalloutAction as g, CalloutDescription as T, CalloutTitle as c } from "./components/callout/callout.js";
7
7
  import { Card as F, CardAction as P, CardContent as w, CardDescription as A, CardFooter as L, CardHeader as I, CardTitle as G } from "./components/card/card.js";
8
- import { Surface as O } from "./components/surface/surface.js";
9
- import { PILL_COLORS as h, Pill as v } from "./components/pill/pill.js";
10
- import { Separator as R } from "./components/separator/separator.js";
8
+ import { Surface as k } from "./components/surface/surface.js";
9
+ import { PILL_COLORS as R, Pill as h } from "./components/pill/pill.js";
10
+ import { Separator as B } from "./components/separator/separator.js";
11
11
  import { Skeleton as V } from "./components/skeleton/skeleton.js";
12
12
  import { Spinner as E } from "./components/spinner/spinner.js";
13
- import { Table as N, TableBody as U, TableCaption as Z, TableCell as j, TableDensityContext as q, TableFooter as z, TableHead as J, TableHeader as K, TableRow as Q } from "./components/table/table.js";
13
+ import { Table as z, TableBody as N, TableCaption as U, TableCell as Z, TableDensityContext as j, TableFooter as q, TableHead as J, TableHeader as K, TableRow as Q } from "./components/table/table.js";
14
14
  import { Accordion as X, AccordionContent as Y, AccordionItem as $, AccordionTrigger as oo } from "./components/accordion/accordion.js";
15
15
  import { Button as ro } from "./components/button/button.js";
16
16
  import { ButtonGroup as ao, ButtonGroupSeparator as lo, ButtonGroupText as io } from "./components/button-group/button-group.js";
@@ -22,87 +22,93 @@ import { Avatar as go } from "./components/avatar/avatar.js";
22
22
  import { AvatarGroup as co } from "./components/avatar/avatar-group.js";
23
23
  import { Tabs as Fo, TabsContent as Po, TabsList as wo, TabsTrigger as Ao } from "./components/tabs/tabs.js";
24
24
  import { Toggle as Io } from "./components/toggle/toggle.js";
25
- import { ToggleGroup as ko, ToggleGroupItem as Oo } from "./components/toggle/toggle-group.js";
26
- import { AlertDialog as ho, AlertDialogAction as vo, AlertDialogCancel as Bo, AlertDialogContent as Ro, AlertDialogDescription as yo, AlertDialogFooter as Vo, AlertDialogHeader as Ho, AlertDialogOverlay as Eo, AlertDialogPortal as _o, AlertDialogTitle as No, AlertDialogTrigger as Uo } from "./components/alert-dialog/alert-dialog.js";
27
- import { AppearanceBoundary as jo } from "./components/appearance-boundary/appearance-boundary.js";
28
- import { DensityProvider as zo, useDensity as Jo } from "./components/density-provider/density-provider.js";
25
+ import { ToggleGroup as Oo, ToggleGroupItem as ko } from "./components/toggle/toggle-group.js";
26
+ import { AlertDialog as Ro, AlertDialogAction as ho, AlertDialogCancel as vo, AlertDialogContent as Bo, AlertDialogDescription as yo, AlertDialogFooter as Vo, AlertDialogHeader as Ho, AlertDialogOverlay as Eo, AlertDialogPortal as _o, AlertDialogTitle as zo, AlertDialogTrigger as No } from "./components/alert-dialog/alert-dialog.js";
27
+ import { AppearanceBoundary as Zo } from "./components/appearance-boundary/appearance-boundary.js";
28
+ import { DensityProvider as qo, useDensity as Jo } from "./components/density-provider/density-provider.js";
29
29
  import { Dialog as Qo, DialogClose as Wo, DialogContent as Xo, DialogDescription as Yo, DialogFooter as $o, DialogHeader as oe, DialogOverlay as ee, DialogPortal as re, DialogTitle as te, DialogTrigger as ae } from "./components/dialog/dialog.js";
30
- import { Drawer as ie, DrawerClose as ne, DrawerContent as pe, DrawerDescription as me, DrawerFooter as be, DrawerHeader as de, DrawerOverlay as xe, DrawerPortal as Ce, DrawerTitle as se, DrawerTrigger as ue } from "./components/drawer/drawer.js";
31
- import { DropdownMenu as De, DropdownMenuCheckboxItem as ge, DropdownMenuContent as Te, DropdownMenuGroup as ce, DropdownMenuItem as Se, DropdownMenuLabel as Fe, DropdownMenuPortal as Pe, DropdownMenuRadioGroup as we, DropdownMenuRadioItem as Ae, DropdownMenuSeparator as Le, DropdownMenuShortcut as Ie, DropdownMenuSub as Ge, DropdownMenuSubContent as ke, DropdownMenuSubTrigger as Oe, DropdownMenuTrigger as Me } from "./components/dropdown-menu/dropdown-menu.js";
32
- import { Popover as ve, PopoverAnchor as Be, PopoverContent as Re, PopoverPortal as ye, PopoverTrigger as Ve } from "./components/popover/popover.js";
30
+ import { Drawer as ie, DrawerClose as ne, DrawerContent as pe, DrawerDescription as me, DrawerFooter as be, DrawerHeader as xe, DrawerOverlay as de, DrawerPortal as Ce, DrawerTitle as se, DrawerTrigger as ue } from "./components/drawer/drawer.js";
31
+ import { DropdownMenu as De, DropdownMenuCheckboxItem as ge, DropdownMenuContent as Te, DropdownMenuGroup as ce, DropdownMenuItem as Se, DropdownMenuLabel as Fe, DropdownMenuPortal as Pe, DropdownMenuRadioGroup as we, DropdownMenuRadioItem as Ae, DropdownMenuSeparator as Le, DropdownMenuShortcut as Ie, DropdownMenuSub as Ge, DropdownMenuSubContent as Oe, DropdownMenuSubTrigger as ke, DropdownMenuTrigger as Me } from "./components/dropdown-menu/dropdown-menu.js";
32
+ import { Popover as he, PopoverAnchor as ve, PopoverContent as Be, PopoverPortal as ye, PopoverTrigger as Ve } from "./components/popover/popover.js";
33
33
  import { ScrollArea as Ee, ScrollAreaViewport as _e } from "./components/scroll-area/scroll-area.js";
34
- import { ScrollOverflow as Ue, useScrollOverflow as Ze } from "./components/scroll-overflow/scroll-overflow.js";
35
- import { Select as qe, SelectContent as ze, SelectGroup as Je, SelectItem as Ke, SelectLabel as Qe, SelectScrollDownButton as We, SelectScrollUpButton as Xe, SelectSeparator as Ye, SelectTriggerClear as $e, SelectValue as or } from "./components/select/select.js";
34
+ import { ScrollOverflow as Ne, useScrollOverflow as Ue } from "./components/scroll-overflow/scroll-overflow.js";
35
+ import { Select as je, SelectContent as qe, SelectGroup as Je, SelectItem as Ke, SelectLabel as Qe, SelectScrollDownButton as We, SelectScrollUpButton as Xe, SelectSeparator as Ye, SelectTriggerClear as $e, SelectValue as or } from "./components/select/select.js";
36
36
  import { Toaster as rr, toast as tr } from "./components/toast/toast.js";
37
37
  import { Tooltip as lr, TooltipContent as ir, TooltipPortal as nr, TooltipProvider as pr, TooltipTrigger as mr } from "./components/tooltip/tooltip.js";
38
- import { CollapsibleSidebar as dr, CollapsibleSidebarCondensed as xr, CollapsibleSidebarContent as Cr, CollapsibleSidebarToggle as sr, useCollapsibleSidebar as ur } from "./components/collapsible-sidebar/collapsible-sidebar.js";
39
- import { Field as Dr, FieldContent as gr, FieldDescription as Tr, FieldError as cr, FieldGroup as Sr, FieldGroupAddon as Fr, FieldInput as Pr, FieldInputGroup as wr, FieldLabel as Ar, FieldLabelContent as Lr, FieldSet as Ir, FieldTextarea as Gr, fieldDescriptionVariants as kr, fieldVariants as Or, inputGroupAddonVariants as Mr, useFieldContext as hr } from "./components/field/field.js";
40
- import { SelectTrigger as Br } from "./components/field/field-select.js";
41
- import { Combobox as yr, ComboboxClear as Vr, ComboboxClearValue as Hr, ComboboxContent as Er, ComboboxEmpty as _r, ComboboxGroup as Nr, ComboboxGroupLabel as Ur, ComboboxInput as Zr, ComboboxItem as jr, ComboboxItemCheckIcon as qr, ComboboxList as zr, ComboboxLoading as Jr, ComboboxPlaceholder as Kr, ComboboxSeparator as Qr, ComboboxTrigger as Wr, ComboboxValue as Xr } from "./components/field/field-combobox.js";
38
+ import { CollapsibleSidebar as xr, CollapsibleSidebarCondensed as dr, CollapsibleSidebarContent as Cr, CollapsibleSidebarToggle as sr, useCollapsibleSidebar as ur } from "./components/collapsible-sidebar/collapsible-sidebar.js";
39
+ import { Field as Dr, FieldContent as gr, FieldDescription as Tr, FieldError as cr, FieldGroup as Sr, FieldGroupAddon as Fr, FieldInput as Pr, FieldInputGroup as wr, FieldLabel as Ar, FieldLabelContent as Lr, FieldSet as Ir, FieldTextarea as Gr, fieldDescriptionVariants as Or, fieldVariants as kr, inputGroupAddonVariants as Mr, useFieldContext as Rr } from "./components/field/field.js";
40
+ import { SelectTrigger as vr } from "./components/field/field-select.js";
41
+ import { Combobox as yr, ComboboxClear as Vr, ComboboxClearValue as Hr, ComboboxContent as Er, ComboboxEmpty as _r, ComboboxGroup as zr, ComboboxGroupLabel as Nr, ComboboxInput as Ur, ComboboxItem as Zr, ComboboxItemCheckIcon as jr, ComboboxList as qr, ComboboxLoading as Jr, ComboboxPlaceholder as Kr, ComboboxSeparator as Qr, ComboboxTrigger as Wr, ComboboxValue as Xr } from "./components/field/field-combobox.js";
42
42
  import { List as $r, ListGroup as ot, ListGroupContent as et, ListGroupLabel as rt, ListItem as tt, ListItemActions as at, ListItemDescription as lt, ListItemText as it } from "./components/list/list.js";
43
- import { OptionCard as pt, OptionCardContent as mt, OptionCardControl as bt, OptionCardDescription as dt, OptionCardGroup as xt, OptionCardMedia as Ct, OptionCardTitle as st } from "./components/option-card/option-card.js";
43
+ import { OptionCard as pt, OptionCardContent as mt, OptionCardControl as bt, OptionCardDescription as xt, OptionCardGroup as dt, OptionCardMedia as Ct, OptionCardTitle as st } from "./components/option-card/option-card.js";
44
44
  import { SegmentedControl as ft, SegmentedControlItem as Dt } from "./components/segmented-control/segmented-control.js";
45
45
  import { DateTimePicker as Tt } from "./components/date-time-picker/date-time-picker.js";
46
46
  import { DateRangePicker as St } from "./components/date-range-picker/date-range-picker.js";
47
47
  import { Text as Pt } from "./components/text/text.js";
48
48
  import { CodeBlock as At } from "./components/code-block/code-block.js";
49
49
  import { CodeEditor as It } from "./components/code-editor/code-editor.js";
50
- import { CODE_LANGUAGES as kt, isCodeLanguageSupported as Ot, registerCodeLanguage as Mt } from "./lib/code-highlight.js";
51
- import { DataTable as vt } from "./components/data-table/data-table.js";
52
- import { DataTableBody as Rt } from "./components/data-table/data-table-body.js";
50
+ import { CODE_LANGUAGES as Ot, isCodeLanguageSupported as kt, registerCodeLanguage as Mt } from "./lib/code-highlight.js";
51
+ import { DataTable as ht } from "./components/data-table/data-table.js";
52
+ import { DataTableBody as Bt } from "./components/data-table/data-table-body.js";
53
53
  import { DataTableContent as Vt } from "./components/data-table/data-table-content.js";
54
54
  import { DataTableHeader as Et } from "./components/data-table/data-table-header.js";
55
- import { DataTableLoading as Nt } from "./components/data-table/data-table-loading.js";
56
- import { DataTableError as Zt } from "./components/data-table/data-table-error.js";
57
- import { DataTablePagination as qt } from "./components/data-table/data-table-pagination.js";
55
+ import { DataTableLoading as zt } from "./components/data-table/data-table-loading.js";
56
+ import { DataTableError as Ut } from "./components/data-table/data-table-error.js";
57
+ import { DataTablePagination as jt } from "./components/data-table/data-table-pagination.js";
58
58
  import { DataTableToolbar as Jt } from "./components/data-table/data-table-toolbar.js";
59
- import { DataTableColumnVisibility as Qt } from "./components/data-table/data-table-column-visibility.js";
60
- import { DataTableColumnHeader as Xt } from "./components/data-table/data-table-column-header.js";
61
- import { DataTableRow as $t } from "./components/data-table/data-table-row.js";
62
- import { getSelectedRowData as ea } from "./components/data-table/get-selected-row-data.js";
63
- import { getPinnedColumnOffset as ta, isFirstRightPinnedColumn as aa, isLastLeftPinnedColumn as la } from "./components/data-table/data-table-pinning-utils.js";
64
- import { TablePagination as na } from "./components/table/table-pagination.js";
65
- import { calculatePagination as ma, clampPage as ba, getPageNumbers as da } from "./lib/pagination.js";
66
- import { ClearButton as Ca } from "./lib/clear-button.js";
67
- import { Calendar as ua } from "./components/date-time-picker/calendar.js";
68
- import { DateTimePickerInput as Da } from "./components/date-time-picker/date-time-picker-input.js";
69
- import { DateTimePickerPanel as Ta } from "./components/date-time-picker/date-time-picker-panel.js";
70
- import { DateTimePickerPopover as Sa } from "./components/date-time-picker/date-time-picker-popover.js";
71
- import { DateTimePickerRoot as Pa } from "./components/date-time-picker/date-time-picker-context.js";
72
- import { RangeCalendar as Aa } from "./components/date-range-picker/range-calendar.js";
73
- import { TimePicker as Ia } from "./components/date-time-picker/time-picker.js";
74
- import { ensureCoreTokens as ka, ensurePaletteTokens as Oa, ensurePaletteTokensFor as Ma } from "./packages/tokens/dist/install.js";
75
- import { useDataTable as va } from "./components/data-table/hooks/use-data-table.js";
76
- import { useDataTableContent as Ra } from "./components/data-table/hooks/use-data-table-content.js";
59
+ import { DataTableFooter as Qt } from "./components/data-table/data-table-footer.js";
60
+ import { DataTableResizeHandle as Xt } from "./components/data-table/data-table-resize-handle.js";
61
+ import { DataTableColumnVisibility as $t } from "./components/data-table/data-table-column-visibility.js";
62
+ import { DataTableColumnOrder as ea } from "./components/data-table/data-table-column-order.js";
63
+ import { DataTableHeaderDraggable as ta } from "./components/data-table/data-table-header-draggable.js";
64
+ import { DataTableColumnHeader as la } from "./components/data-table/data-table-column-header.js";
65
+ import { DataTableRow as na } from "./components/data-table/data-table-row.js";
66
+ import { getSelectedRowData as ma } from "./components/data-table/get-selected-row-data.js";
67
+ import { getPinnedColumnOffset as xa, isFirstRightPinnedColumn as da, isLastLeftPinnedColumn as Ca } from "./components/data-table/data-table-pinning-utils.js";
68
+ import { DataTableVirtualizerContext as ua } from "./components/data-table/data-table-context.js";
69
+ import { TablePagination as Da } from "./components/table/table-pagination.js";
70
+ import { calculatePagination as Ta, clampPage as ca, getPageNumbers as Sa } from "./lib/pagination.js";
71
+ import { ClearButton as Pa } from "./lib/clear-button.js";
72
+ import { Calendar as Aa } from "./components/date-time-picker/calendar.js";
73
+ import { DateTimePickerInput as Ia } from "./components/date-time-picker/date-time-picker-input.js";
74
+ import { DateTimePickerPanel as Oa } from "./components/date-time-picker/date-time-picker-panel.js";
75
+ import { DateTimePickerPopover as Ma } from "./components/date-time-picker/date-time-picker-popover.js";
76
+ import { DateTimePickerRoot as ha } from "./components/date-time-picker/date-time-picker-context.js";
77
+ import { RangeCalendar as Ba } from "./components/date-range-picker/range-calendar.js";
78
+ import { TimePicker as Va } from "./components/date-time-picker/time-picker.js";
79
+ import { ensureCoreTokens as Ea, ensurePaletteTokens as _a, ensurePaletteTokensFor as za } from "./packages/tokens/dist/install.js";
80
+ import { useDataTable as Ua } from "./components/data-table/hooks/use-data-table.js";
81
+ import { useDataTableContent as ja } from "./components/data-table/hooks/use-data-table-content.js";
82
+ import { useDataTableVirtualizer as Ja } from "./components/data-table/hooks/use-data-table-virtualizer.js";
77
83
  export {
78
84
  X as Accordion,
79
85
  Y as AccordionContent,
80
86
  $ as AccordionItem,
81
87
  oo as AccordionTrigger,
82
- ho as AlertDialog,
83
- vo as AlertDialogAction,
84
- Bo as AlertDialogCancel,
85
- Ro as AlertDialogContent,
88
+ Ro as AlertDialog,
89
+ ho as AlertDialogAction,
90
+ vo as AlertDialogCancel,
91
+ Bo as AlertDialogContent,
86
92
  yo as AlertDialogDescription,
87
93
  Vo as AlertDialogFooter,
88
94
  Ho as AlertDialogHeader,
89
95
  Eo as AlertDialogOverlay,
90
96
  _o as AlertDialogPortal,
91
- No as AlertDialogTitle,
92
- Uo as AlertDialogTrigger,
93
- jo as AppearanceBoundary,
97
+ zo as AlertDialogTitle,
98
+ No as AlertDialogTrigger,
99
+ Zo as AppearanceBoundary,
94
100
  go as Avatar,
95
101
  co as AvatarGroup,
96
- d as BADGE_COLORS,
97
- x as Badge,
102
+ x as BADGE_COLORS,
103
+ d as Badge,
98
104
  s as Breadcrumb,
99
105
  u as BreadcrumbItem,
100
106
  ro as Button,
101
107
  ao as ButtonGroup,
102
108
  lo as ButtonGroupSeparator,
103
109
  io as ButtonGroupText,
104
- kt as CODE_LANGUAGES,
105
- ua as Calendar,
110
+ Ot as CODE_LANGUAGES,
111
+ Aa as Calendar,
106
112
  D as Callout,
107
113
  g as CalloutAction,
108
114
  T as CalloutDescription,
@@ -115,31 +121,36 @@ export {
115
121
  I as CardHeader,
116
122
  G as CardTitle,
117
123
  po as Checkbox,
118
- Ca as ClearButton,
124
+ Pa as ClearButton,
119
125
  At as CodeBlock,
120
126
  It as CodeEditor,
121
- dr as CollapsibleSidebar,
122
- xr as CollapsibleSidebarCondensed,
127
+ xr as CollapsibleSidebar,
128
+ dr as CollapsibleSidebarCondensed,
123
129
  Cr as CollapsibleSidebarContent,
124
130
  sr as CollapsibleSidebarToggle,
125
- vt as DataTable,
126
- Rt as DataTableBody,
127
- Xt as DataTableColumnHeader,
128
- Qt as DataTableColumnVisibility,
131
+ ht as DataTable,
132
+ Bt as DataTableBody,
133
+ la as DataTableColumnHeader,
134
+ ea as DataTableColumnOrder,
135
+ $t as DataTableColumnVisibility,
129
136
  Vt as DataTableContent,
130
- Zt as DataTableError,
137
+ Ut as DataTableError,
138
+ Qt as DataTableFooter,
131
139
  Et as DataTableHeader,
132
- Nt as DataTableLoading,
133
- qt as DataTablePagination,
134
- $t as DataTableRow,
140
+ ta as DataTableHeaderDraggable,
141
+ zt as DataTableLoading,
142
+ jt as DataTablePagination,
143
+ Xt as DataTableResizeHandle,
144
+ na as DataTableRow,
135
145
  Jt as DataTableToolbar,
146
+ ua as DataTableVirtualizerContext,
136
147
  St as DateRangePicker,
137
148
  Tt as DateTimePicker,
138
- Da as DateTimePickerInput,
139
- Ta as DateTimePickerPanel,
140
- Sa as DateTimePickerPopover,
141
- Pa as DateTimePickerRoot,
142
- zo as DensityProvider,
149
+ Ia as DateTimePickerInput,
150
+ Oa as DateTimePickerPanel,
151
+ Ma as DateTimePickerPopover,
152
+ ha as DateTimePickerRoot,
153
+ qo as DensityProvider,
143
154
  Qo as Dialog,
144
155
  Wo as DialogClose,
145
156
  Xo as DialogContent,
@@ -155,8 +166,8 @@ export {
155
166
  pe as DrawerContent,
156
167
  me as DrawerDescription,
157
168
  be as DrawerFooter,
158
- de as DrawerHeader,
159
- xe as DrawerOverlay,
169
+ xe as DrawerHeader,
170
+ de as DrawerOverlay,
160
171
  Ce as DrawerPortal,
161
172
  se as DrawerTitle,
162
173
  ue as DrawerTrigger,
@@ -172,8 +183,8 @@ export {
172
183
  Le as DropdownMenuSeparator,
173
184
  Ie as DropdownMenuShortcut,
174
185
  Ge as DropdownMenuSub,
175
- ke as DropdownMenuSubContent,
176
- Oe as DropdownMenuSubTrigger,
186
+ Oe as DropdownMenuSubContent,
187
+ ke as DropdownMenuSubTrigger,
177
188
  Me as DropdownMenuTrigger,
178
189
  Dr as Field,
179
190
  yr as FieldCombobox,
@@ -181,12 +192,12 @@ export {
181
192
  Hr as FieldComboboxClearValue,
182
193
  Er as FieldComboboxContent,
183
194
  _r as FieldComboboxEmpty,
184
- Nr as FieldComboboxGroup,
185
- Ur as FieldComboboxGroupLabel,
186
- Zr as FieldComboboxInput,
187
- jr as FieldComboboxItem,
188
- qr as FieldComboboxItemCheckIcon,
189
- zr as FieldComboboxList,
195
+ zr as FieldComboboxGroup,
196
+ Nr as FieldComboboxGroupLabel,
197
+ Ur as FieldComboboxInput,
198
+ Zr as FieldComboboxItem,
199
+ jr as FieldComboboxItemCheckIcon,
200
+ qr as FieldComboboxList,
190
201
  Jr as FieldComboboxLoading,
191
202
  Kr as FieldComboboxPlaceholder,
192
203
  Qr as FieldComboboxSeparator,
@@ -215,82 +226,82 @@ export {
215
226
  pt as OptionCard,
216
227
  mt as OptionCardContent,
217
228
  bt as OptionCardControl,
218
- dt as OptionCardDescription,
219
- xt as OptionCardGroup,
229
+ xt as OptionCardDescription,
230
+ dt as OptionCardGroup,
220
231
  Ct as OptionCardMedia,
221
232
  st as OptionCardTitle,
222
- h as PILL_COLORS,
223
- v as Pill,
224
- ve as Popover,
225
- Be as PopoverAnchor,
226
- Re as PopoverContent,
233
+ R as PILL_COLORS,
234
+ h as Pill,
235
+ he as Popover,
236
+ ve as PopoverAnchor,
237
+ Be as PopoverContent,
227
238
  ye as PopoverPortal,
228
239
  Ve as PopoverTrigger,
229
240
  Co as RadioGroup,
230
241
  so as RadioGroupItem,
231
- Aa as RangeCalendar,
242
+ Ba as RangeCalendar,
232
243
  i as SLOT_ATTR,
233
244
  Ee as ScrollArea,
234
245
  _e as ScrollAreaViewport,
235
- Ue as ScrollOverflow,
246
+ Ne as ScrollOverflow,
236
247
  ft as SegmentedControl,
237
248
  Dt as SegmentedControlItem,
238
- qe as Select,
239
- ze as SelectContent,
249
+ je as Select,
250
+ qe as SelectContent,
240
251
  Je as SelectGroup,
241
252
  Ke as SelectItem,
242
253
  Qe as SelectLabel,
243
254
  We as SelectScrollDownButton,
244
255
  Xe as SelectScrollUpButton,
245
256
  Ye as SelectSeparator,
246
- Br as SelectTrigger,
257
+ vr as SelectTrigger,
247
258
  $e as SelectTriggerClear,
248
259
  or as SelectValue,
249
- R as Separator,
260
+ B as Separator,
250
261
  V as Skeleton,
251
262
  E as Spinner,
252
- O as Surface,
263
+ k as Surface,
253
264
  fo as Switch,
254
- N as Table,
255
- U as TableBody,
256
- Z as TableCaption,
257
- j as TableCell,
258
- q as TableDensityContext,
259
- z as TableFooter,
265
+ z as Table,
266
+ N as TableBody,
267
+ U as TableCaption,
268
+ Z as TableCell,
269
+ j as TableDensityContext,
270
+ q as TableFooter,
260
271
  J as TableHead,
261
272
  K as TableHeader,
262
- na as TablePagination,
273
+ Da as TablePagination,
263
274
  Q as TableRow,
264
275
  Fo as Tabs,
265
276
  Po as TabsContent,
266
277
  wo as TabsList,
267
278
  Ao as TabsTrigger,
268
279
  Pt as Text,
269
- Ia as TimePicker,
280
+ Va as TimePicker,
270
281
  rr as Toaster,
271
282
  Io as Toggle,
272
- ko as ToggleGroup,
273
- Oo as ToggleGroupItem,
283
+ Oo as ToggleGroup,
284
+ ko as ToggleGroupItem,
274
285
  lr as Tooltip,
275
286
  ir as TooltipContent,
276
287
  nr as TooltipPortal,
277
288
  pr as TooltipProvider,
278
289
  mr as TooltipTrigger,
279
290
  n as assertAnchorIsFirstInHead,
280
- ma as calculatePagination,
281
- ba as clampPage,
282
- ka as ensureCoreTokens,
283
- Oa as ensurePaletteTokens,
284
- Ma as ensurePaletteTokensFor,
285
- kr as fieldDescriptionVariants,
286
- Or as fieldVariants,
287
- da as getPageNumbers,
288
- ta as getPinnedColumnOffset,
289
- ea as getSelectedRowData,
291
+ Ta as calculatePagination,
292
+ ca as clampPage,
293
+ Ea as ensureCoreTokens,
294
+ _a as ensurePaletteTokens,
295
+ za as ensurePaletteTokensFor,
296
+ Or as fieldDescriptionVariants,
297
+ kr as fieldVariants,
298
+ Sa as getPageNumbers,
299
+ xa as getPinnedColumnOffset,
300
+ ma as getSelectedRowData,
290
301
  Mr as inputGroupAddonVariants,
291
- Ot as isCodeLanguageSupported,
292
- aa as isFirstRightPinnedColumn,
293
- la as isLastLeftPinnedColumn,
302
+ kt as isCodeLanguageSupported,
303
+ da as isFirstRightPinnedColumn,
304
+ Ca as isLastLeftPinnedColumn,
294
305
  t as makeZenithResetStyles,
295
306
  a as makeZenithStyles,
296
307
  p as mergeClasses,
@@ -299,10 +310,11 @@ export {
299
310
  tr as toast,
300
311
  o as tokens,
301
312
  ur as useCollapsibleSidebar,
302
- va as useDataTable,
303
- Ra as useDataTableContent,
313
+ Ua as useDataTable,
314
+ ja as useDataTableContent,
315
+ Ja as useDataTableVirtualizer,
304
316
  Jo as useDensity,
305
- hr as useFieldContext,
306
- Ze as useScrollOverflow
317
+ Rr as useFieldContext,
318
+ Ue as useScrollOverflow
307
319
  };
308
320
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"clear-button.js","sources":["../../src/lib/clear-button.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { mergeClasses } from \"@epilot/zenith-runtime/v1\"\n\nimport { SLOT_ATTR } from \"../renderer/contract\"\nimport { makeZenithStyles } from \"../styles/make-styles\"\nimport * as tokens from \"../tokens\"\nimport { CloseIcon } from \"./icons\"\n\n/**\n * ClearButton — v1's shared dismiss button ported to Griffel atoms.\n *\n * v1 (`packages/react/src/lib/clear-button.tsx`) paints a round, shrink-proof, hover-tinted icon\n * button and falls back to a size-3 `CloseIcon` when no children are given. Only the mechanism\n * changes here: `rounded-full` becomes a literal fully-rounded radius and `hover:bg-current/10`\n * becomes a single `:hover` atom (`color-mix(in srgb, currentColor 10%, transparent)`) — the colour\n * comes from `currentColor`, so one rule covers every host. The focus-visible ring is 2px solid\n * `accent-a8` with a 1px offset, exactly as v1.\n *\n * Both Callout and Pill compose this instead of inlining their own approximation, so the hover,\n * focus and fallback-icon behaviour lives in one place.\n */\n\nconst useStyles = makeZenithStyles({\n root: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n // rounded-full — no token for a fully rounded radius.\n borderRadius: \"9999px\",\n flexShrink: 0,\n cursor: \"pointer\",\n \":hover\": {\n // v1's `hover:bg-current/10` — a literal because no token expresses a currentColor tint.\n backgroundColor: \"color-mix(in srgb, currentColor 10%, transparent)\",\n },\n \":focus-visible\": {\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineOffset: \"1px\",\n outlineColor: tokens.accentA8,\n },\n },\n icon: {\n // size-3 — the CloseIcon fallback.\n width: \"0.75rem\",\n height: \"0.75rem\",\n },\n})\n\nexport type ClearButtonProps = React.ComponentProps<\"button\"> & {\n label?: string\n}\n\nexport const ClearButton = React.forwardRef<\n HTMLButtonElement,\n ClearButtonProps\n>(function ClearButton(\n { className, label = \"Remove\", children, ...props },\n ref\n) {\n const styles = useStyles()\n\n return (\n <button\n ref={ref}\n type=\"button\"\n data-slot=\"clear-button\"\n {...{ [SLOT_ATTR]: \"clear-button\" }}\n aria-label={label}\n className={mergeClasses(styles.root, className)}\n {...props}\n >\n {children ?? <CloseIcon className={styles.icon} />}\n </button>\n )\n})\n"],"names":["useStyles","makeZenithStyles","tokens.accentA8","ClearButton","React","className","label","children","props","ref","styles","jsx","SLOT_ATTR","mergeClasses","CloseIcon"],"mappings":";;;;;;AAuBA,MAAMA,IAAYC,EAAiB;AAAA,EACjC,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA;AAAA,IAEhB,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,UAAU;AAAA;AAAA,MAER,iBAAiB;AAAA,IAAA;AAAA,IAEnB,kBAAkB;AAAA,MAChB,cAAc;AAAA,MACd,cAAc;AAAA,MACd,eAAe;AAAA,MACf,cAAcC;AAAAA,IAAO;AAAA,EACvB;AAAA,EAEF,MAAM;AAAA;AAAA,IAEJ,OAAO;AAAA,IACP,QAAQ;AAAA,EAAA;AAEZ,CAAC,GAMYC,IAAcC,EAAM,WAG/B,SACA,EAAE,WAAAC,GAAW,OAAAC,IAAQ,UAAU,UAAAC,GAAU,GAAGC,EAAA,GAC5CC,GACA;AACA,QAAMC,IAASV,EAAA;AAEf,SACE,gBAAAW;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAF;AAAA,MACA,MAAK;AAAA,MACL,aAAU;AAAA,MACJ,CAACG,CAAS,GAAG;AAAA,MACnB,cAAYN;AAAA,MACZ,WAAWO,EAAaH,EAAO,MAAML,CAAS;AAAA,MAC7C,GAAGG;AAAA,MAEH,UAAAD,KAAY,gBAAAI,EAACG,GAAA,EAAU,WAAWJ,EAAO,KAAA,CAAM;AAAA,IAAA;AAAA,EAAA;AAGtD,CAAC;"}
1
+ {"version":3,"file":"clear-button.js","sources":["../../src/lib/clear-button.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { mergeClasses } from \"@epilot/zenith-runtime/v1\"\n\nimport { SLOT_ATTR } from \"../renderer/contract\"\nimport { makeZenithStyles } from \"../styles/make-styles\"\nimport * as tokens from \"../tokens\"\nimport { CloseIcon } from \"./icons\"\n\n/** ClearButton — v1's shared dismiss button ported to Griffel atoms. */\n\nconst useStyles = makeZenithStyles({\n root: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n // rounded-full — no token for a fully rounded radius.\n borderRadius: \"9999px\",\n flexShrink: 0,\n cursor: \"pointer\",\n \":hover\": {\n // v1's `hover:bg-current/10` — a literal because no token expresses a currentColor tint.\n backgroundColor: \"color-mix(in srgb, currentColor 10%, transparent)\",\n },\n \":focus-visible\": {\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineOffset: \"1px\",\n outlineColor: tokens.accentA8,\n },\n },\n icon: {\n // size-3 — the CloseIcon fallback.\n width: \"0.75rem\",\n height: \"0.75rem\",\n },\n})\n\nexport type ClearButtonProps = React.ComponentProps<\"button\"> & {\n label?: string\n}\n\nexport const ClearButton = React.forwardRef<\n HTMLButtonElement,\n ClearButtonProps\n>(function ClearButton(\n { className, label = \"Remove\", children, ...props },\n ref\n) {\n const styles = useStyles()\n\n return (\n <button\n ref={ref}\n type=\"button\"\n data-slot=\"clear-button\"\n {...{ [SLOT_ATTR]: \"clear-button\" }}\n aria-label={label}\n className={mergeClasses(styles.root, className)}\n {...props}\n >\n {children ?? <CloseIcon className={styles.icon} />}\n </button>\n )\n})\n"],"names":["useStyles","makeZenithStyles","tokens.accentA8","ClearButton","React","className","label","children","props","ref","styles","jsx","SLOT_ATTR","mergeClasses","CloseIcon"],"mappings":";;;;;;AAWA,MAAMA,IAAYC,EAAiB;AAAA,EACjC,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA;AAAA,IAEhB,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,UAAU;AAAA;AAAA,MAER,iBAAiB;AAAA,IAAA;AAAA,IAEnB,kBAAkB;AAAA,MAChB,cAAc;AAAA,MACd,cAAc;AAAA,MACd,eAAe;AAAA,MACf,cAAcC;AAAAA,IAAO;AAAA,EACvB;AAAA,EAEF,MAAM;AAAA;AAAA,IAEJ,OAAO;AAAA,IACP,QAAQ;AAAA,EAAA;AAEZ,CAAC,GAMYC,IAAcC,EAAM,WAG/B,SACA,EAAE,WAAAC,GAAW,OAAAC,IAAQ,UAAU,UAAAC,GAAU,GAAGC,EAAA,GAC5CC,GACA;AACA,QAAMC,IAASV,EAAA;AAEf,SACE,gBAAAW;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAF;AAAA,MACA,MAAK;AAAA,MACL,aAAU;AAAA,MACJ,CAACG,CAAS,GAAG;AAAA,MACnB,cAAYN;AAAA,MACZ,WAAWO,EAAaH,EAAO,MAAML,CAAS;AAAA,MAC7C,GAAGG;AAAA,MAEH,UAAAD,KAAY,gBAAAI,EAACG,GAAA,EAAU,WAAWJ,EAAO,KAAA,CAAM;AAAA,IAAA;AAAA,EAAA;AAGtD,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"code-highlight.js","sources":["../../src/lib/code-highlight.ts"],"sourcesContent":["import { refractor } from \"refractor/core\"\nimport bash from \"refractor/bash\"\nimport css from \"refractor/css\"\nimport javascript from \"refractor/javascript\"\nimport json from \"refractor/json\"\nimport jsx from \"refractor/jsx\"\nimport markdown from \"refractor/markdown\"\nimport markup from \"refractor/markup\"\nimport tsx from \"refractor/tsx\"\nimport typescript from \"refractor/typescript\"\nimport yaml from \"refractor/yaml\"\n\n/**\n * Tokenization for the code surfaces. Prism grammars via refractor, on a registry that starts\n * empty and carries exactly the ten shipped languages.\n *\n * WHY refractor AND WHY ONLY TEN — CODE-HIGHLIGHTING-DECISION.md has the comparison, the measured\n * sizes and the rejected alternatives. The two facts that matter when editing this file:\n *\n * - refractor emits DATA (a hast tree), never HTML, so nothing here needs `innerHTML` and there is\n * no raw-markup entry point to guard. `highlightCode` takes a string and returns plain objects.\n * - `refractor/core` starts with no grammars, and each grammar is its own module. The ten below\n * cost 20,683 B gzip together; the all-languages entry would cost 219,904 B. Adding one here\n * is a measurable decision, which is why `registerCodeLanguage` exists instead — a consumer who\n * needs Python imports that one grammar module and pays for Python.\n */\n\n/**\n * A Prism grammar, as its own module default-exports it.\n *\n * Described STRUCTURALLY rather than as refractor's own `Syntax` type, and that is load-bearing:\n * this type reaches the published declarations, and a consumer has not installed refractor, so an\n * import of it there would resolve to nothing. TypeScript does not error on an unresolved import\n * inside a `.d.ts` under `skipLibCheck` — it widens the type to `any` and says nothing, which is\n * how a whole package's props once went untyped in two pilot MFEs. `gate:dts-self-contained` is\n * what catches that, and it caught this.\n *\n * A grammar is a function carrying these two properties; the call signature is refractor's\n * business, so only the properties are described here.\n */\nexport type CodeGrammar = {\n displayName: string\n aliases: string[]\n}\n\nconst DEFAULT_SYNTAXES: CodeGrammar[] = [\n // `markup` before the JSX/TSX pair and `javascript` before `typescript`: each of the later ones\n // extends an earlier one, and Prism resolves that at registration time.\n markup,\n css,\n javascript,\n typescript,\n jsx,\n tsx,\n json,\n bash,\n yaml,\n markdown,\n]\n\n/**\n * The languages the package ships a grammar for. Aliases resolve too — `js`, `ts`, `html`, `sh`,\n * `shell`, `yml`, `md` all work, and so does `plaintext`, which Prism registers as a no-op — so\n * this is the canonical list, not the accepted one. `language` stays a plain `string` on both\n * components precisely so a registered extra language is as valid as a shipped one.\n */\nexport const CODE_LANGUAGES = [\n \"bash\",\n \"css\",\n \"html\",\n \"javascript\",\n \"json\",\n \"jsx\",\n \"markdown\",\n \"tsx\",\n \"typescript\",\n \"yaml\",\n] as const\n\nexport type CodeLanguage = (typeof CODE_LANGUAGES)[number]\n\n/**\n * Registration is lazy rather than run at module scope, so importing this module is genuinely free\n * of effects (`sideEffects: false` is a promise this package keeps) and so registration order\n * cannot depend on which module a bundler happened to evaluate first.\n */\nlet defaultsRegistered = false\nfunction ensureDefaults(): void {\n if (defaultsRegistered) return\n defaultsRegistered = true\n for (const syntax of DEFAULT_SYNTAXES)\n refractor.register(syntax as Parameters<typeof refractor.register>[0])\n}\n\n/**\n * Teach the code surfaces one more Prism grammar.\n *\n * Import the grammar module for the language you need from refractor and pass its default export;\n * the component docs carry a copyable example. You pay for that grammar and nothing else.\n *\n * Idempotent, synchronous, and safe to call during module initialization — it touches no DOM and\n * reads no browser global, so it is equally valid on a server.\n */\nexport function registerCodeLanguage(syntax: CodeGrammar): void {\n ensureDefaults()\n refractor.register(syntax as Parameters<typeof refractor.register>[0])\n}\n\n/** True when `language` (name or alias) has a grammar and will actually be highlighted. */\nexport function isCodeLanguageSupported(language: string | undefined): boolean {\n if (language === undefined || language === \"\") return false\n ensureDefaults()\n return refractor.registered(language)\n}\n\n/**\n * One node of highlighted code.\n *\n * Deliberately NOT hast: a `token` node carries a Prism token TYPE, not a tag name and not a class\n * string, because the consumer of this tree is a Griffel component that maps the type to an atom.\n * Nothing downstream can turn a value in here into an element, which is the property that makes\n * the whole feature safe without sanitization.\n */\nexport type CodeTokenNode =\n | { kind: \"text\"; value: string }\n | { kind: \"token\"; type: string; children: CodeTokenNode[] }\n\n/** Minimal shape of what refractor returns; narrowed rather than imported to keep hast out of the public types. */\ntype HastLike = {\n type: string\n tagName?: string\n value?: string\n properties?: { className?: unknown }\n children?: HastLike[]\n}\n\n/**\n * Prism labels a token with `[\"token\", <type>, ...]`, and sometimes decorates a nested block with\n * `[\"language-css\"]` and no `token` at all. The type is the first class that is neither `token` nor\n * a `language-*` marker; when there is none the node is a passthrough wrapper and contributes no\n * styling of its own.\n */\nfunction tokenTypeOf(properties: HastLike[\"properties\"]): string | undefined {\n const raw = properties?.className\n if (!Array.isArray(raw)) return undefined\n for (const entry of raw) {\n if (typeof entry !== \"string\") continue\n if (entry === \"token\" || entry.startsWith(\"language-\")) continue\n return entry\n }\n return undefined\n}\n\nfunction convert(nodes: HastLike[] | undefined): CodeTokenNode[] {\n const out: CodeTokenNode[] = []\n for (const node of nodes ?? []) {\n if (node.type === \"text\") {\n if (typeof node.value === \"string\" && node.value !== \"\")\n out.push({ kind: \"text\", value: node.value })\n continue\n }\n if (node.type !== \"element\") continue\n const children = convert(node.children)\n const type = tokenTypeOf(node.properties)\n if (type === undefined) {\n // A wrapper with nothing to say: splice its children in rather than emit an empty span.\n out.push(...children)\n continue\n }\n out.push({ kind: \"token\", type, children })\n }\n return out\n}\n\n/**\n * Tokenize `code` as `language`, or return `null` when there is no grammar for it.\n *\n * `null` is the plain-text fallback and is not an error: an unknown language, a missing one, and\n * `plaintext` all mean \"render the string as it is\". Callers must treat it that way — the string is\n * always the source of truth, and highlighting is decoration over it.\n *\n * Pure and synchronous: same input, same tree, on a server or in a browser. That is what lets the\n * server render and the first client render agree byte for byte.\n */\nexport function highlightCode(\n code: string,\n language: string | undefined\n): CodeTokenNode[] | null {\n if (!isCodeLanguageSupported(language)) return null\n try {\n return convert(\n refractor.highlight(code, language as string).children as HastLike[]\n )\n } catch {\n // A grammar that throws on pathological input must degrade to plain text, never take the page\n // down with it. The code still renders; it just renders unhighlighted.\n return null\n }\n}\n\n/**\n * Split a token tree into one array per line, cutting tokens that span newlines.\n *\n * Needed because a line-numbered rendering is a grid of rows, while Prism happily produces one\n * token covering a whole block comment or template literal. Splitting re-opens the enclosing token\n * on every line it continues onto, so a comment stays comment-coloured on all of them.\n *\n * The newlines themselves are dropped: the row structure encodes them, and re-emitting them would\n * double the line breaks a selection copies.\n *\n * Shape of the recursion, which is the whole correctness argument: `splitNode` returns one entry\n * per line the node covers, so its length minus one is exactly the number of newlines inside it.\n * `splitNodes` then joins each node's FIRST line onto the line in progress and starts a new line\n * for each subsequent one. Nesting falls out for free, because a token's own split is just its\n * children's split with the wrapper re-applied per line.\n */\nfunction splitNode(node: CodeTokenNode): CodeTokenNode[][] {\n if (node.kind === \"text\")\n return node.value\n .split(\"\\n\")\n .map((part) =>\n part === \"\" ? [] : [{ kind: \"text\", value: part } as const]\n )\n\n return splitNodes(node.children).map((line) =>\n line.length === 0\n ? []\n : [{ kind: \"token\", type: node.type, children: line } as const]\n )\n}\n\nfunction splitNodes(nodes: CodeTokenNode[]): CodeTokenNode[][] {\n const lines: CodeTokenNode[][] = [[]]\n for (const node of nodes) {\n const nodeLines = splitNode(node)\n lines[lines.length - 1].push(...nodeLines[0])\n for (let i = 1; i < nodeLines.length; i++) lines.push(nodeLines[i])\n }\n return lines\n}\n\nexport function splitTokenLines(nodes: CodeTokenNode[]): CodeTokenNode[][] {\n return splitNodes(nodes)\n}\n"],"names":["DEFAULT_SYNTAXES","markup","css","javascript","typescript","jsx","tsx","json","bash","yaml","markdown","CODE_LANGUAGES","defaultsRegistered","ensureDefaults","syntax","refractor","registerCodeLanguage","isCodeLanguageSupported","language","tokenTypeOf","properties","raw","entry","convert","nodes","out","node","children","type","highlightCode","code","splitNode","part","splitNodes","line","lines","nodeLines","i","splitTokenLines"],"mappings":";;;;;;;;;;;AA6CA,MAAMA,IAAkC;AAAA;AAAA;AAAA,EAGtCC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AACF,GAQaC,IAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASA,IAAIC,IAAqB;AACzB,S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AA,EAElD,QAAQ;AAGN,WAAO;AAAA,EACT;AACF;AAkBA,SAASa,EAAUL,GAAwC;AACzD,SAAIA,EAAK,SAAS,SACTA,EAAK,MACT,MAAM;AAAA,CAAI,EACV;AAAA,IAAI,CAACM,MACJA,MAAS,KAAK,CAAA,IAAK,CAAC,EAAE,MAAM,QAAQ,OAAOA,EAAA,CAAe;AAAA,EAAA,IAGzDC,EAAWP,EAAK,QAAQ,EAAE;AAAA,IAAI,CAACQ,MACpCA,EAAK,WAAW,IACZ,CAAA,IACA,CAAC,EAAE,MAAM,SAAS,MAAMR,EAAK,MAAM,UAAUQ,GAAe;AAAA,EAAA;AAEpE;AAEA,SAASD,EAAWT,GAA2C;AAC7D,QAAMW,IAA2B,CAAC,EAAE;AACpC,aAAWT,KAAQF,GAAO;AACxB,UAAMY,IAAYL,EAAUL,CAAI;AAChC,IAAAS,EAAMA,EAAM,SAAS,CAAC,EAAE,KAAK,GAAGC,EAAU,CAAC,CAAC;AAC5C,aAASC,IAAI,GAAGA,IAAID,EAAU,QAAQC,IAAK,CAAAF,EAAM,KAAKC,EAAUC,CAAC,CAAC;AAAA,EACpE;AACA,SAAOF;AACT;AAEO,SAASG,EAAgBd,GAA2C;AACzE,SAAOS,EAAWT,CAAK;AACzB;"}
1
+ {"version":3,"file":"code-highlight.js","sources":["../../src/lib/code-highlight.ts"],"sourcesContent":["import { refractor } from \"refractor/core\"\nimport bash from \"refractor/bash\"\nimport css from \"refractor/css\"\nimport javascript from \"refractor/javascript\"\nimport json from \"refractor/json\"\nimport jsx from \"refractor/jsx\"\nimport markdown from \"refractor/markdown\"\nimport markup from \"refractor/markup\"\nimport tsx from \"refractor/tsx\"\nimport typescript from \"refractor/typescript\"\nimport yaml from \"refractor/yaml\"\n\n/**\n * Tokenization for the code surfaces. Prism grammars via refractor, on a registry that starts\n * empty and carries exactly the ten shipped languages.\n */\n\n/**\n * A Prism grammar, as its own module default-exports it. Described STRUCTURALLY rather than as\n * refractor's own `Syntax` type, and that is load-bearing: this type reaches the published\n * declarations, and a consumer has not installed refractor, so an import of it there would resolve\n * to nothing.\n */\nexport type CodeGrammar = {\n displayName: string\n aliases: string[]\n}\n\nconst DEFAULT_SYNTAXES: CodeGrammar[] = [\n // `markup` before the JSX/TSX pair and `javascript` before `typescript`: each of the later ones\n // extends an earlier one, and Prism resolves that at registration time.\n markup,\n css,\n javascript,\n typescript,\n jsx,\n tsx,\n json,\n bash,\n yaml,\n markdown,\n]\n\n/**\n * The languages the package ships a grammar for. Aliases resolve too — `js`, `ts`, `html`, `sh`,\n * `shell`, `yml`, `md` all work, and so does `plaintext`, which Prism registers as a no-op — so\n * this is the canonical list, not the accepted one. `language` stays a plain `string` on both\n * components precisely so a registered extra language is as valid as a shipped one.\n */\nexport const CODE_LANGUAGES = [\n \"bash\",\n \"css\",\n \"html\",\n \"javascript\",\n \"json\",\n \"jsx\",\n \"markdown\",\n \"tsx\",\n \"typescript\",\n \"yaml\",\n] as const\n\nexport type CodeLanguage = (typeof CODE_LANGUAGES)[number]\n\n/**\n * Registration is lazy rather than run at module scope, so importing this module is genuinely free\n * of effects (`sideEffects: false` is a promise this package keeps) and so registration order\n * cannot depend on which module a bundler happened to evaluate first.\n */\nlet defaultsRegistered = false\nfunction ensureDefaults(): void {\n if (defaultsRegistered) return\n defaultsRegistered = true\n for (const syntax of DEFAULT_SYNTAXES)\n refractor.register(syntax as Parameters<typeof refractor.register>[0])\n}\n\n/**\n * Teach the code surfaces one more Prism grammar. Import the grammar module for the language you\n * need from refractor and pass its default export; the component docs carry a copyable example.\n * You pay for that grammar and nothing else.\n */\nexport function registerCodeLanguage(syntax: CodeGrammar): void {\n ensureDefaults()\n refractor.register(syntax as Parameters<typeof refractor.register>[0])\n}\n\n/** True when `language` (name or alias) has a grammar and will actually be highlighted. */\nexport function isCodeLanguageSupported(language: string | undefined): boolean {\n if (language === undefined || language === \"\") return false\n ensureDefaults()\n return refractor.registered(language)\n}\n\n/**\n * One node of highlighted code. Deliberately NOT hast: a `token` node carries a Prism token TYPE,\n * not a tag name and not a class string, because the consumer of this tree is a Griffel component\n * that maps the type to an atom.\n */\nexport type CodeTokenNode =\n | { kind: \"text\"; value: string }\n | { kind: \"token\"; type: string; children: CodeTokenNode[] }\n\n/** Minimal shape of what refractor returns; narrowed rather than imported to keep hast out of the public types. */\ntype HastLike = {\n type: string\n tagName?: string\n value?: string\n properties?: { className?: unknown }\n children?: HastLike[]\n}\n\n/**\n * Prism labels a token with `[\"token\", <type>, ...]`, and sometimes decorates a nested block with\n * `[\"language-css\"]` and no `token` at all. The type is the first class that is neither `token` nor\n * a `language-*` marker; when there is none the node is a passthrough wrapper and contributes no\n * styling of its own.\n */\nfunction tokenTypeOf(properties: HastLike[\"properties\"]): string | undefined {\n const raw = properties?.className\n if (!Array.isArray(raw)) return undefined\n for (const entry of raw) {\n if (typeof entry !== \"string\") continue\n if (entry === \"token\" || entry.startsWith(\"language-\")) continue\n return entry\n }\n return undefined\n}\n\nfunction convert(nodes: HastLike[] | undefined): CodeTokenNode[] {\n const out: CodeTokenNode[] = []\n for (const node of nodes ?? []) {\n if (node.type === \"text\") {\n if (typeof node.value === \"string\" && node.value !== \"\")\n out.push({ kind: \"text\", value: node.value })\n continue\n }\n if (node.type !== \"element\") continue\n const children = convert(node.children)\n const type = tokenTypeOf(node.properties)\n if (type === undefined) {\n // A wrapper with nothing to say: splice its children in rather than emit an empty span.\n out.push(...children)\n continue\n }\n out.push({ kind: \"token\", type, children })\n }\n return out\n}\n\n/**\n * Tokenize `code` as `language`, or return `null` when there is no grammar for it. `null` is the\n * plain-text fallback and is not an error: an unknown language, a missing one, and `plaintext` all\n * mean \"render the string as it is\". Callers must treat it that way — the string is always the\n * source of truth, and highlighting is decoration over it.\n */\nexport function highlightCode(\n code: string,\n language: string | undefined\n): CodeTokenNode[] | null {\n if (!isCodeLanguageSupported(language)) return null\n try {\n return convert(\n refractor.highlight(code, language as string).children as HastLike[]\n )\n } catch {\n // A grammar that throws on pathological input must degrade to plain text, never take the page\n // down with it. The code still renders; it just renders unhighlighted.\n return null\n }\n}\n\n/**\n * Split a token tree into one array per line, cutting tokens that span newlines. Needed because a\n * line-numbered rendering is a grid of rows, while Prism happily produces one token covering a\n * whole block comment or template literal.\n */\nfunction splitNode(node: CodeTokenNode): CodeTokenNode[][] {\n if (node.kind === \"text\")\n return node.value\n .split(\"\\n\")\n .map((part) =>\n part === \"\" ? [] : [{ kind: \"text\", value: part } as const]\n )\n\n return splitNodes(node.children).map((line) =>\n line.length === 0\n ? []\n : [{ kind: \"token\", type: node.type, children: line } as const]\n )\n}\n\nfunction splitNodes(nodes: CodeTokenNode[]): CodeTokenNode[][] {\n const lines: CodeTokenNode[][] = [[]]\n for (const node of nodes) {\n const nodeLines = splitNode(node)\n lines[lines.length - 1].push(...nodeLines[0])\n for (let i = 1; i < nodeLines.length; i++) lines.push(nodeLines[i])\n }\n return lines\n}\n\nexport function splitTokenLines(nodes: CodeTokenNode[]): CodeTokenNode[][] {\n return splitNodes(nodes)\n}\n"],"names":["DEFAULT_SYNTAXES","markup","css","javascript","typescript","jsx","tsx","json","bash","yaml","markdown","CODE_LANGUAGES","defaultsRegistered","ensureDefaults","syntax","refractor","registerCodeLanguage","isCodeLanguageSupported","language","tokenTypeOf","properties","raw","entry","convert","nodes","out","node","children","type","highlightCode","code","splitNode","part","splitNodes","line","lines","nodeLines","i","splitTokenLines"],"mappings":";;;;;;;;;;;AA4BA,MAAMA,IAAkC;AAAA;AAAA;AAAA,EAGtCC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AACF,GAQaC,IAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASA,IAAIC,IAAqB;AACzB,SAASC,IAAuB;AAC9B,MAAI,CAAAD,GACJ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ACT;AACF;AAOA,SAASa,EAAUL,GAAwC;AACzD,SAAIA,EAAK,SAAS,SACTA,EAAK,MACT,MAAM;AAAA,CAAI,EACV;AAAA,IAAI,CAACM,MACJA,MAAS,KAAK,CAAA,IAAK,CAAC,EAAE,MAAM,QAAQ,OAAOA,EAAA,CAAe;AAAA,EAAA,IAGzDC,EAAWP,EAAK,QAAQ,EAAE;AAAA,IAAI,CAACQ,MACpCA,EAAK,WAAW,IACZ,CAAA,IACA,CAAC,EAAE,MAAM,SAAS,MAAMR,EAAK,MAAM,UAAUQ,GAAe;AAAA,EAAA;AAEpE;AAEA,SAASD,EAAWT,GAA2C;AAC7D,QAAMW,IAA2B,CAAC,EAAE;AACpC,aAAWT,KAAQF,GAAO;AACxB,UAAMY,IAAYL,EAAUL,CAAI;AAChC,IAAAS,EAAMA,EAAM,SAAS,CAAC,EAAE,KAAK,GAAGC,EAAU,CAAC,CAAC;AAC5C,aAASC,IAAI,GAAGA,IAAID,EAAU,QAAQC,IAAK,CAAAF,EAAM,KAAKC,EAAUC,CAAC,CAAC;AAAA,EACpE;AACA,SAAOF;AACT;AAEO,SAASG,EAAgBd,GAA2C;AACzE,SAAOS,EAAWT,CAAK;AACzB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"code-tokens.js","sources":["../../src/lib/code-tokens.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { makeZenithStyles } from \"../styles/make-styles\"\nimport * as tokens from \"../tokens\"\nimport type { CodeTokenNode } from \"./code-highlight\"\n\n/**\n * The syntax theme, and the one renderer both code surfaces use.\n *\n * WHY IT IS A HOOK AND NOT A COMPONENT. CodeBlock renders tokens inside per-line rows and\n * CodeEditor renders them as one run; a renderer function composes into both, where a component\n * would force CodeBlock to wrap every line in an extra element. It exports no capitalised binding,\n * so there is no component here that could owe anyone a forwarded ref.\n *\n * WHY THESE COLOURS. Every hue is one of the six families in the CORE sheet — accent, gray, error,\n * warning, success, info. That is not an aesthetic choice: `AGENTS.md` rule 9 requires\n * `useZenithPaletteTokensFor` for any family outside those six, and a code block that installed the\n * palette sheet would pull ~63 kB of CSS onto every page that renders one. Staying inside core also\n * means light and dark resolve through ordinary custom-property inheritance, with no JavaScript\n * reading the theme — which is what makes the server and client renders identical.\n *\n * Step 11 of each scale is Radix's \"low-contrast text\" step, the one intended for accessible text\n * on a steps 1-3 background, which is what both surfaces paint.\n */\nconst useTokenStyles = makeZenithStyles({\n /** Structure you read past: comments, punctuation, operators. */\n muted: {\n color: tokens.grayA11,\n },\n /** Language keywords and at-rules. */\n keyword: {\n color: tokens.accent11,\n },\n /** Anything quoted or literal-textual. */\n string: {\n color: tokens.success11,\n },\n /** Numbers, booleans, null, and other value literals. */\n literal: {\n color: tokens.warning11,\n },\n /** Names: tags, functions, classes, object keys, attributes, variables. */\n name: {\n color: tokens.info11,\n },\n /** Removed lines in a diff, and nothing else. */\n deleted: {\n color: tokens.error11,\n },\n /** Markdown emphasis carries weight and slant, not colour. */\n strong: {\n fontWeight: tokens.fontWeightBold,\n },\n emphasis: {\n fontStyle: \"italic\",\n },\n})\n\ntype TokenRole = keyof ReturnType<typeof useTokenStyles>\n\n/**\n * Prism token type to colour role.\n *\n * Derived by tokenizing representative samples of all ten shipped languages and collecting every\n * class Prism actually emitted, rather than from a theme someone remembered — an unmapped type is\n * not a bug, it inherits the surrounding code colour, which is the right default for the long tail.\n */\nconst TOKEN_ROLES: Record<string, TokenRole> = {\n // Muted\n comment: \"muted\",\n prolog: \"muted\",\n cdata: \"muted\",\n doctype: \"muted\",\n \"doctype-tag\": \"muted\",\n punctuation: \"muted\",\n operator: \"muted\",\n \"attr-equals\": \"muted\",\n \"template-punctuation\": \"muted\",\n \"interpolation-punctuation\": \"muted\",\n \"script-punctuation\": \"muted\",\n \"regex-delimiter\": \"muted\",\n spread: \"muted\",\n shebang: \"muted\",\n\n // Keyword\n keyword: \"keyword\",\n atrule: \"keyword\",\n rule: \"keyword\",\n selector: \"keyword\",\n \"for-or-select\": \"keyword\",\n list: \"keyword\",\n blockquote: \"keyword\",\n\n // String\n string: \"string\",\n char: \"string\",\n \"attr-value\": \"string\",\n \"template-string\": \"string\",\n regex: \"string\",\n \"regex-source\": \"string\",\n \"regex-flags\": \"string\",\n url: \"string\",\n content: \"string\",\n code: \"string\",\n \"code-snippet\": \"string\",\n \"code-block\": \"string\",\n inserted: \"string\",\n\n // Literal\n number: \"literal\",\n boolean: \"literal\",\n constant: \"literal\",\n null: \"literal\",\n symbol: \"literal\",\n unit: \"literal\",\n important: \"literal\",\n\n // Name\n tag: \"name\",\n \"class-name\": \"name\",\n function: \"name\",\n \"function-variable\": \"name\",\n builtin: \"name\",\n property: \"name\",\n key: \"name\",\n \"attr-name\": \"name\",\n variable: \"name\",\n title: \"name\",\n name: \"name\",\n \"code-language\": \"name\",\n interpolation: \"name\",\n\n // Standalone\n deleted: \"deleted\",\n bold: \"strong\",\n italic: \"emphasis\",\n}\n\nexport type CodeTokenRenderer = (nodes: CodeTokenNode[]) => React.ReactNode\n\n/**\n * Returns the function that turns a token tree into React elements.\n *\n * Every element it can produce is a `<span>` — the token TYPE only ever selects a class, never a\n * tag — so no grammar, present or future, can introduce an element with behaviour. There is no\n * `dangerouslySetInnerHTML` anywhere in this path and no string is ever parsed as markup.\n */\nexport function useCodeTokenRenderer(): CodeTokenRenderer {\n const styles = useTokenStyles()\n\n return React.useCallback(\n function renderNodes(nodes: CodeTokenNode[]): React.ReactNode {\n return nodes.map((node, index) => {\n if (node.kind === \"text\") return node.value\n const role = TOKEN_ROLES[node.type]\n return (\n <span\n // Tokens have no identity beyond their position, and the whole run re-renders whenever\n // the source changes.\n key={index}\n className={role === undefined ? undefined : styles[role]}\n data-code-token={node.type}\n >\n {renderNodes(node.children)}\n </span>\n )\n })\n },\n [styles]\n )\n}\n"],"names":["useTokenStyles","makeZenithStyles","tokens.grayA11","tokens.accent11","tokens.success11","tokens.warning11","tokens.info11","tokens.error11","tokens.fontWeightBold","TOKEN_ROLES","useCodeTokenRenderer","styles","React","renderNod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ACV,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,WAAW;AAAA;AAAA,EAGX,KAAK;AAAA,EACL,cAAc;AAAA,EACd,UAAU;AAAA,EACV,qBAAqB;AAAA,EACrB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,KAAK;AAAA,EACL,aAAa;AAAA,EACb,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,eAAe;AAAA;AAAA,EAGf,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AACV;AAWO,SAASC,IAA0C;AACxD,QAAMC,IAASX,EAAA;AAEf,SAAOY,EAAM;AAAA,IACX,SAASC,EAAYC,GAAyC;AAC5D,aAAOA,EAAM,IAAI,CAACC,GAAMC,MAAU;AAChC,YAAID,EAAK,SAAS,OAAQ,QAAOA,EAAK;AACtC,cAAME,IAAOR,EAAYM,EAAK,IAAI;AAClC,eACE,gBAAAG;AAAA,UAAC;AAAA,UAAA;AAAA,YAIC,WAAWD,MAAS,SAAY,SAAYN,EAAOM,CAAI;AAAA,YACvD,mBAAiBF,EAAK;AAAA,YAErB,UAAAF,EAAYE,EAAK,QAAQ;AAAA,UAAA;AAAA,UAJrBC;AAAA,QAAA;AAAA,MAOX,CAAC;AAAA,IACH;AAAA,IACA,CAACL,CAAM;AAAA,EAAA;AAEX;"}
1
+ {"version":3,"file":"code-tokens.js","sources":["../../src/lib/code-tokens.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { makeZenithStyles } from \"../styles/make-styles\"\nimport * as tokens from \"../tokens\"\nimport type { CodeTokenNode } from \"./code-highlight\"\n\n/**\n * The syntax theme, and the one renderer both code surfaces use. WHY IT IS A HOOK AND NOT A\n * COMPONENT. CodeBlock renders tokens inside per-line rows and CodeEditor renders them as one run;\n * a renderer function composes into both, where a component would force CodeBlock to wrap every\n * line in an extra element.\n */\nconst useTokenStyles = makeZenithStyles({\n /** Structure you read past: comments, punctuation, operators. */\n muted: {\n color: tokens.grayA11,\n },\n /** Language keywords and at-rules. */\n keyword: {\n color: tokens.accent11,\n },\n /** Anything quoted or literal-textual. */\n string: {\n color: tokens.success11,\n },\n /** Numbers, booleans, null, and other value literals. */\n literal: {\n color: tokens.warning11,\n },\n /** Names: tags, functions, classes, object keys, attributes, variables. */\n name: {\n color: tokens.info11,\n },\n /** Removed lines in a diff, and nothing else. */\n deleted: {\n color: tokens.error11,\n },\n /** Markdown emphasis carries weight and slant, not colour. */\n strong: {\n fontWeight: tokens.fontWeightBold,\n },\n emphasis: {\n fontStyle: \"italic\",\n },\n})\n\ntype TokenRole = keyof ReturnType<typeof useTokenStyles>\n\n/**\n * Prism token type to colour role.\n *\n * Derived by tokenizing representative samples of all ten shipped languages and collecting every\n * class Prism actually emitted, rather than from a theme someone remembered — an unmapped type is\n * not a bug, it inherits the surrounding code colour, which is the right default for the long tail.\n */\nconst TOKEN_ROLES: Record<string, TokenRole> = {\n // Muted\n comment: \"muted\",\n prolog: \"muted\",\n cdata: \"muted\",\n doctype: \"muted\",\n \"doctype-tag\": \"muted\",\n punctuation: \"muted\",\n operator: \"muted\",\n \"attr-equals\": \"muted\",\n \"template-punctuation\": \"muted\",\n \"interpolation-punctuation\": \"muted\",\n \"script-punctuation\": \"muted\",\n \"regex-delimiter\": \"muted\",\n spread: \"muted\",\n shebang: \"muted\",\n\n // Keyword\n keyword: \"keyword\",\n atrule: \"keyword\",\n rule: \"keyword\",\n selector: \"keyword\",\n \"for-or-select\": \"keyword\",\n list: \"keyword\",\n blockquote: \"keyword\",\n\n // String\n string: \"string\",\n char: \"string\",\n \"attr-value\": \"string\",\n \"template-string\": \"string\",\n regex: \"string\",\n \"regex-source\": \"string\",\n \"regex-flags\": \"string\",\n url: \"string\",\n content: \"string\",\n code: \"string\",\n \"code-snippet\": \"string\",\n \"code-block\": \"string\",\n inserted: \"string\",\n\n // Literal\n number: \"literal\",\n boolean: \"literal\",\n constant: \"literal\",\n null: \"literal\",\n symbol: \"literal\",\n unit: \"literal\",\n important: \"literal\",\n\n // Name\n tag: \"name\",\n \"class-name\": \"name\",\n function: \"name\",\n \"function-variable\": \"name\",\n builtin: \"name\",\n property: \"name\",\n key: \"name\",\n \"attr-name\": \"name\",\n variable: \"name\",\n title: \"name\",\n name: \"name\",\n \"code-language\": \"name\",\n interpolation: \"name\",\n\n // Standalone\n deleted: \"deleted\",\n bold: \"strong\",\n italic: \"emphasis\",\n}\n\nexport type CodeTokenRenderer = (nodes: CodeTokenNode[]) => React.ReactNode\n\n/**\n * Returns the function that turns a token tree into React elements.\n *\n * Every element it can produce is a `<span>` — the token TYPE only ever selects a class, never a\n * tag — so no grammar, present or future, can introduce an element with behaviour. There is no\n * `dangerouslySetInnerHTML` anywhere in this path and no string is ever parsed as markup.\n */\nexport function useCodeTokenRenderer(): CodeTokenRenderer {\n const styles = useTokenStyles()\n\n return React.useCallback(\n function renderNodes(nodes: CodeTokenNode[]): React.ReactNode {\n return nodes.map((node, index) => {\n if (node.kind === \"text\") return node.value\n const role = TOKEN_ROLES[node.type]\n return (\n <span\n // Tokens have no identity beyond their position, and the whole run re-renders whenever\n // the source changes.\n key={index}\n className={role === undefined ? undefined : styles[role]}\n data-code-token={node.type}\n >\n {renderNodes(node.children)}\n </span>\n )\n })\n },\n [styles]\n )\n}\n"],"names":["useTokenStyles","makeZenithStyles","tokens.grayA11","tokens.accent11","tokens.success11","tokens.warning11","tokens.info11","tokens.error11","tokens.fontWeightBold","TOKEN_ROLES","useCodeTokenRenderer","styles","React","renderNodes","nodes","node","index","role","jsx"],"mappings":";;;;AAYA,MAAMA,IAAiBC,EAAiB;AAAA;AAAA,EAEtC,OAAO;AAAA,IACL,OAAOC;AAAAA,EAAO;AAAA;AAAA,EAGhB,SAAS;AAAA,IACP,OAAOC;AAAAA,EAAO;AAAA;AAAA,EAGhB,QAAQ;AAAA,IACN,OAAOC;AAAAA,EAAO;AAAA;AAAA,EAGhB,SAAS;AAAA,IACP,OAAOC;AAAAA,EAA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B,eAAe;AAAA;AAAA,EAGf,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AACV;AAWO,SAASC,IAA0C;AACxD,QAAMC,IAASX,EAAA;AAEf,SAAOY,EAAM;AAAA,IACX,SAASC,EAAYC,GAAyC;AAC5D,aAAOA,EAAM,IAAI,CAACC,GAAMC,MAAU;AAChC,YAAID,EAAK,SAAS,OAAQ,QAAOA,EAAK;AACtC,cAAME,IAAOR,EAAYM,EAAK,IAAI;AAClC,eACE,gBAAAG;AAAA,UAAC;AAAA,UAAA;AAAA,YAIC,WAAWD,MAAS,SAAY,SAAYN,EAAOM,CAAI;AAAA,YACvD,mBAAiBF,EAAK;AAAA,YAErB,UAAAF,EAAYE,EAAK,QAAQ;AAAA,UAAA;AAAA,UAJrBC;AAAA,QAAA;AAAA,MAOX,CAAC;AAAA,IACH;AAAA,IACA,CAACL,CAAM;AAAA,EAAA;AAEX;"}
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.js","sources":["../../src/lib/pagination.ts"],"sourcesContent":["/**\n * Pagination utility functions for calculating pagination metadata.\n */\n\nexport type PaginationParams = {\n page: number\n pageSize: number\n totalItems: number\n}\n\nexport type PaginationMeta = {\n /** Total number of pages */\n totalPages: number\n /** First item index on current page (1-indexed for display) */\n start: number\n /** Last item index on current page (1-indexed for display) */\n end: number\n /** Whether there is a next page */\n hasNextPage: boolean\n /** Whether there is a previous page */\n hasPreviousPage: boolean\n /** Whether current page is the first page */\n isFirstPage: boolean\n /** Whether current page is the last page */\n isLastPage: boolean\n}\n\n/**\n * Calculate pagination metadata from current state.\n *\n * @example\n * ```tsx\n * const meta = calculatePagination({ page: 1, pageSize: 10, totalItems: 25 })\n * // Returns: { totalPages: 3, start: 1, end: 10, hasNextPage: true, ... }\n * ```\n */\nexport function calculatePagination(params: PaginationParams): PaginationMeta {\n const { page, pageSize, totalItems } = params\n\n const totalPages = Math.max(1, Math.ceil(totalItems / pageSize))\n const clampedPage = clampPage(page, totalPages)\n const start = totalItems === 0 ? 0 : (clampedPage - 1) * pageSize + 1\n const end = Math.min(clampedPage * pageSize, totalItems)\n\n return {\n totalPages,\n start,\n end,\n hasNextPage: clampedPage < totalPages,\n hasPreviousPage: clampedPage > 1,\n isFirstPage: clampedPage === 1,\n isLastPage: clampedPage >= totalPages,\n }\n}\n\n/**\n * Clamp a page number to valid bounds.\n *\n * @example\n * ```tsx\n * clampPage(5, 3) // Returns 3 (clamped to max)\n * clampPage(0, 3) // Returns 1 (clamped to min)\n * ```\n */\nexport function clampPage(page: number, totalPages: number): number {\n return Math.max(1, Math.min(page, Math.max(1, totalPages)))\n}\n\n/** Represents a page number or an ellipsis marker in pagination */\nexport type PageItem =\n | { type: \"page\"; page: number }\n | { type: \"ellipsis\"; targetPage: number }\n\n/**\n * Generate page numbers with ellipsis for pagination UI.\n *\n * Pattern rules:\n * - Fixed slot count: always shows TOTAL_SLOTS items (default: 7)\n * - Right ellipsis when not near end: [pages..., ..., lastPage]\n * - Near end: expanded window with no ellipsis\n * - Ellipsis is clickable and jumps to midpoint\n *\n * @example\n * ```tsx\n * getPageNumbers(1, 10) // [1, 2, 3, 4, 5, ellipsis→7, 10] (7 items)\n * getPageNumbers(5, 10) // [3, 4, 5, 6, 7, ellipsis→8, 10] (7 items)\n * getPageNumbers(7, 10) // [4, 5, 6, 7, 8, 9, 10] (7 items - expanded)\n * getPageNumbers(10, 10) // [4, 5, 6, 7, 8, 9, 10] (7 items - expanded)\n * getPageNumbers(2, 5) // [1, 2, 3, 4, 5] (5 items - small table)\n * ```\n */\nexport function getPageNumbers(\n currentPage: number,\n totalPages: number,\n siblingCount: number = 2\n): PageItem[] {\n const WINDOW_SIZE = siblingCount * 2 + 1 // 5 pages by default\n const TOTAL_SLOTS = WINDOW_SIZE + 2 // 7 slots (5 + ellipsis + last)\n const clampedPage = clampPage(currentPage, totalPages)\n\n // Helper to create page item\n const page = (n: number): PageItem => ({ type: \"page\", page: n })\n\n // Small table: show all pages\n if (totalPages <= TOTAL_SLOTS) {\n return Array.from({ length: totalPages }, (_, i) => page(i + 1))\n }\n\n // Calculate the window centered on current page\n let windowStart = clampedPage - siblingCount\n let windowEnd = clampedPage + siblingCount\n\n // Clamp window to valid range\n if (windowStart < 1) {\n windowStart = 1\n windowEnd = WINDOW_SIZE\n }\n\n // Determine if we should use expanded window (near end)\n // Switch to expanded mode when window end + 2 >= totalPages\n const useExpandedWindow = windowEnd + 2 >= totalPages\n\n if (useExpandedWindow) {\n // Show TOTAL_SLOTS consecutive pages ending at totalPages\n const expandedStart = totalPages - TOTAL_SLOTS + 1\n return Array.from({ length: TOTAL_SLOTS }, (_, i) =>\n page(expandedStart + i)\n )\n }\n\n // Normal mode: window + ellipsis + lastPage\n const windowPages = Array.from({ length: WINDOW_SIZE }, (_, i) =>\n page(windowStart + i)\n )\n\n const rightEllipsisTarget = Math.max(\n windowEnd + 1,\n Math.floor((windowEnd + totalPages) / 2)\n )\n\n return [\n ...windowPages,\n { type: \"ellipsis\", targetPage: rightEllipsisTarget },\n page(totalPages),\n ]\n}\n"],"names":["calculatePagination","params","page","pageSize","totalItems","totalPages","clampedPage","clampPage","start","end","getPageNumbers","currentPage","siblingCount","WINDOW_SIZE","TOTAL_SLOTS","n","_","i","windowStart","windowEnd","expandedStart","windowPages","rightEllipsisTarget"],"mappings":"AAoCO,SAASA,EAAoBC,GAA0C;AAC5E,QAAM,EAAE,MAAAC,GAAM,UAAAC,GAAU,YAAAC,EAAA,IAAeH,GAEjCI,IAAa,KAAK,IAAI,GAAG,KAAK,KAAKD,IAAaD,CAAQ,CAAC,GACzDG,IAAcC,EAAUL,GAAMG,CAAU,GACxCG,IAAQJ,MAAe,IAAI,KAAKE,IAAc,KAAKH,IAAW,GAC9DM,IAAM,KAAK,IAAIH,IAAcH,GAAUC,CAAU;AAEvD,SAAO;AAAA,IACL,YAAAC;AAAA,IACA,OAAAG;AAAA,IACA,KAAAC;AAAA,IACA,aAAaH,IAAcD;AAAA,IAC3B,iBAAiBC,IAAc;AAAA,IAC/B,aAAaA,MAAgB;AAAA,IAC7B,YAAYA,KAAeD;AAAA,EAAA;AAE/B;AAWO,SAASE,EAAUL,GAAcG,GAA4B;AAClE,SAAO,KAAK,IAAI,GAAG,KAAK,IAAIH,GAAM,KAAK,IAAI,GAAGG,CAAU,CAAC,CAAC;AAC5D;AAyBO,SAASK,EACdC,GACAN,GACAO,IAAuB,GACX;AACZ,QAAMC,IAAcD,IAAe,IAAI,GACjCE,IAAcD,IAAc,GAC5BP,IAAcC,EAAUI,GAAaN,CAAU,GAG/CH,IAAO,CAACa,OAAyB,EAAE,MAAM,QAAQ,MAAMA;AAG7D,MAAIV,KAAcS;AAChB,WAAO,MAAM,KAAK,EAAE,QAAQT,EAAA,GAAc,CAACW,GAAGC,MAAMf,EAAKe,IAAI,CAAC,CAAC;AAIjE,MAAIC,IAAcZ,IAAcM,GAC5BO,IAAYb,IAAcM;AAY9B,MATIM,IAAc,MAChBA,IAAc,GACdC,IAAYN,IAKYM,IAAY,KAAKd,GAEpB;AAErB,UAAMe,IAAgBf,IAAaS,IAAc;AACjD,WAAO,MAAM;AAAA,MAAK,EAAE,QAAQA,EAAA;AAAA,MAAe,CAACE,GAAGC,MAC7Cf,EAAKkB,IAAgBH,CAAC;AAAA,IAAA;AAAA,EAE1B;AAGA,QAAMI,IAAc,MAAM;AAAA,IAAK,EAAE,QAAQR,EAAA;AAAA,IAAe,CAACG,GAAGC,MAC1Df,EAAKgB,IAAcD,CAAC;AAAA,EAAA,GAGhBK,IAAsB,KAAK;AAAA,IAC/BH,IAAY;AAAA,IACZ,KAAK,OAAOA,IAAYd,KAAc,CAAC;AAAA,EAAA;AAGzC,SAAO;AAAA,IACL,GAAGgB;AAAA,IACH,EAAE,MAAM,YAAY,YAAYC,EAAA;AAAA,IAChCpB,EAAKG,CAAU;AAAA,EAAA;AAEnB;"}
1
+ {"version":3,"file":"pagination.js","sources":["../../src/lib/pagination.ts"],"sourcesContent":["/**\n * Pagination utility functions for calculating pagination metadata.\n */\n\nexport type PaginationParams = {\n page: number\n pageSize: number\n totalItems: number\n}\n\nexport type PaginationMeta = {\n /** Total number of pages */\n totalPages: number\n /** First item index on current page (1-indexed for display) */\n start: number\n /** Last item index on current page (1-indexed for display) */\n end: number\n /** Whether there is a next page */\n hasNextPage: boolean\n /** Whether there is a previous page */\n hasPreviousPage: boolean\n /** Whether current page is the first page */\n isFirstPage: boolean\n /** Whether current page is the last page */\n isLastPage: boolean\n}\n\n/**\n * Calculate pagination metadata from current state.\n *\n * @example\n * ```tsx\n * const meta = calculatePagination({ page: 1, pageSize: 10, totalItems: 25 })\n * // Returns: { totalPages: 3, start: 1, end: 10, hasNextPage: true, ... }\n * ```\n */\nexport function calculatePagination(params: PaginationParams): PaginationMeta {\n const { page, pageSize, totalItems } = params\n\n const totalPages = Math.max(1, Math.ceil(totalItems / pageSize))\n const clampedPage = clampPage(page, totalPages)\n const start = totalItems === 0 ? 0 : (clampedPage - 1) * pageSize + 1\n const end = Math.min(clampedPage * pageSize, totalItems)\n\n return {\n totalPages,\n start,\n end,\n hasNextPage: clampedPage < totalPages,\n hasPreviousPage: clampedPage > 1,\n isFirstPage: clampedPage === 1,\n isLastPage: clampedPage >= totalPages,\n }\n}\n\n/**\n * Clamp a page number to valid bounds. ```tsx clampPage(5, 3) // Returns 3 (clamped to max)\n * clampPage(0, 3) // Returns 1 (clamped to min) ```\n * @example\n */\nexport function clampPage(page: number, totalPages: number): number {\n return Math.max(1, Math.min(page, Math.max(1, totalPages)))\n}\n\n/** Represents a page number or an ellipsis marker in pagination */\nexport type PageItem =\n { type: \"page\"; page: number } | { type: \"ellipsis\"; targetPage: number }\n\n/**\n * Generate page numbers with ellipsis for pagination UI.\n * @example\n */\nexport function getPageNumbers(\n currentPage: number,\n totalPages: number,\n siblingCount: number = 2\n): PageItem[] {\n const WINDOW_SIZE = siblingCount * 2 + 1 // 5 pages by default\n const TOTAL_SLOTS = WINDOW_SIZE + 2 // 7 slots (5 + ellipsis + last)\n const clampedPage = clampPage(currentPage, totalPages)\n\n // Helper to create page item\n const page = (n: number): PageItem => ({ type: \"page\", page: n })\n\n // Small table: show all pages\n if (totalPages <= TOTAL_SLOTS) {\n return Array.from({ length: totalPages }, (_, i) => page(i + 1))\n }\n\n // Calculate the window centered on current page\n let windowStart = clampedPage - siblingCount\n let windowEnd = clampedPage + siblingCount\n\n // Clamp window to valid range\n if (windowStart < 1) {\n windowStart = 1\n windowEnd = WINDOW_SIZE\n }\n\n // Determine if we should use expanded window (near end)\n // Switch to expanded mode when window end + 2 >= totalPages\n const useExpandedWindow = windowEnd + 2 >= totalPages\n\n if (useExpandedWindow) {\n // Show TOTAL_SLOTS consecutive pages ending at totalPages\n const expandedStart = totalPages - TOTAL_SLOTS + 1\n return Array.from({ length: TOTAL_SLOTS }, (_, i) =>\n page(expandedStart + i)\n )\n }\n\n // Normal mode: window + ellipsis + lastPage\n const windowPages = Array.from({ length: WINDOW_SIZE }, (_, i) =>\n page(windowStart + i)\n )\n\n const rightEllipsisTarget = Math.max(\n windowEnd + 1,\n Math.floor((windowEnd + totalPages) / 2)\n )\n\n return [\n ...windowPages,\n { type: \"ellipsis\", targetPage: rightEllipsisTarget },\n page(totalPages),\n ]\n}\n"],"names":["calculatePagination","params","page","pageSize","totalItems","totalPages","clampedPage","clampPage","start","end","getPageNumbers","currentPage","siblingCount","WINDOW_SIZE","TOTAL_SLOTS","n","_","i","windowStart","windowEnd","expandedStart","windowPages","rightEllipsisTarget"],"mappings":"AAoCO,SAASA,EAAoBC,GAA0C;AAC5E,QAAM,EAAE,MAAAC,GAAM,UAAAC,GAAU,YAAAC,EAAA,IAAeH,GAEjCI,IAAa,KAAK,IAAI,GAAG,KAAK,KAAKD,IAAaD,CAAQ,CAAC,GACzDG,IAAcC,EAAUL,GAAMG,CAAU,GACxCG,IAAQJ,MAAe,IAAI,KAAKE,IAAc,KAAKH,IAAW,GAC9DM,IAAM,KAAK,IAAIH,IAAcH,GAAUC,CAAU;AAEvD,SAAO;AAAA,I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