@overdoser/react-toolkit 0.20.0 → 0.22.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 (212) hide show
  1. package/AGENTS.md +2 -1
  2. package/CHANGELOG.md +41 -0
  3. package/components/Accordion/Accordion.js +160 -177
  4. package/components/Accordion/Accordion.module.scss.js +19 -35
  5. package/components/ActionButton/ActionButton.js +155 -209
  6. package/components/ActionButton/ActionButton.module.scss.js +24 -46
  7. package/components/ActionButton/CopyButton.js +52 -64
  8. package/components/Alert/Alert.js +93 -96
  9. package/components/Alert/Alert.module.scss.js +17 -32
  10. package/components/Avatar/Avatar.js +44 -55
  11. package/components/Avatar/Avatar.module.scss.js +22 -42
  12. package/components/Badge/Badge.js +15 -37
  13. package/components/Badge/Badge.module.scss.js +16 -30
  14. package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  15. package/components/Breadcrumbs/Breadcrumbs.js +52 -48
  16. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +9 -16
  17. package/components/Button/Button.js +35 -57
  18. package/components/Button/Button.module.scss.js +24 -46
  19. package/components/Card/Card.js +94 -131
  20. package/components/Card/Card.module.scss.js +34 -59
  21. package/components/Chart/AreaChart.d.ts +1 -1
  22. package/components/Chart/AreaChart.js +248 -249
  23. package/components/Chart/Axis.d.ts +2 -2
  24. package/components/Chart/Axis.js +34 -43
  25. package/components/Chart/BarChart.d.ts +1 -1
  26. package/components/Chart/BarChart.js +307 -348
  27. package/components/Chart/Chart.module.scss.js +31 -60
  28. package/components/Chart/ChartContainer.js +33 -41
  29. package/components/Chart/ChartLegend.d.ts +1 -1
  30. package/components/Chart/ChartLegend.js +31 -30
  31. package/components/Chart/ChartTooltip.d.ts +1 -1
  32. package/components/Chart/ChartTooltip.js +45 -40
  33. package/components/Chart/LineChart.d.ts +1 -1
  34. package/components/Chart/LineChart.js +220 -232
  35. package/components/Chart/PieChart.d.ts +1 -1
  36. package/components/Chart/PieChart.js +224 -240
  37. package/components/Chart/RadarChart.d.ts +1 -1
  38. package/components/Chart/RadarChart.js +166 -215
  39. package/components/Chart/Sparkline.js +73 -68
  40. package/components/Chart/TradingChart.d.ts +1 -1
  41. package/components/Chart/TradingChart.js +804 -701
  42. package/components/Chart/scales.js +28 -35
  43. package/components/Chart/trading/indicators.js +61 -62
  44. package/components/Chart/trading/period.js +46 -68
  45. package/components/Chart/useChartDimensions.js +30 -22
  46. package/components/Chip/Chip.js +98 -141
  47. package/components/Chip/Chip.module.scss.js +31 -58
  48. package/components/CodeBlock/CodeBlock.js +111 -119
  49. package/components/CodeBlock/CodeBlock.module.scss.js +22 -42
  50. package/components/CommandPalette/CommandPalette.js +387 -392
  51. package/components/CommandPalette/CommandPalette.module.scss.js +27 -48
  52. package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
  53. package/components/ConfirmDialog/ConfirmDialog.js +184 -199
  54. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +11 -20
  55. package/components/Divider/Divider.js +25 -36
  56. package/components/Divider/Divider.module.scss.js +16 -30
  57. package/components/Draggable/Draggable.d.ts +1 -1
  58. package/components/Draggable/Draggable.js +157 -164
  59. package/components/Draggable/Draggable.module.scss.js +9 -16
  60. package/components/Drawer/Drawer.js +104 -126
  61. package/components/Drawer/Drawer.module.scss.js +65 -118
  62. package/components/Dropdown/Dropdown.js +175 -234
  63. package/components/Dropdown/Dropdown.module.scss.js +28 -52
  64. package/components/Dropdown/DropdownItem.js +55 -58
  65. package/components/Dropdown/DropdownLabel.js +14 -11
  66. package/components/Dropdown/DropdownSeparator.js +13 -11
  67. package/components/Dropdown/dropdownContext.js +4 -5
  68. package/components/Dropdown/useContextMenu.js +27 -17
  69. package/components/Dropzone/Dropzone.js +99 -105
  70. package/components/Dropzone/Dropzone.module.scss.js +11 -20
  71. package/components/EmptyState/EmptyState.js +57 -54
  72. package/components/EmptyState/EmptyState.module.scss.js +13 -24
  73. package/components/Form/Form.d.ts +1 -1
  74. package/components/Form/Form.js +31 -34
  75. package/components/Form/Form.module.scss.js +15 -28
  76. package/components/Form/FormField.d.ts +1 -1
  77. package/components/Form/FormField.js +71 -75
  78. package/components/Form/FormRow.d.ts +1 -1
  79. package/components/Form/FormRow.js +11 -8
  80. package/components/Form/formFieldDefaults.js +4 -5
  81. package/components/ImageViewer/ImageViewer.js +312 -201
  82. package/components/ImageViewer/ImageViewer.module.scss.js +25 -46
  83. package/components/ImageViewer/useZoomPan.js +206 -137
  84. package/components/Kbd/Kbd.js +24 -21
  85. package/components/Kbd/Kbd.module.scss.js +9 -16
  86. package/components/KeyValueList/KeyValueList.js +119 -123
  87. package/components/KeyValueList/KeyValueList.module.scss.js +22 -42
  88. package/components/Link/Link.js +45 -59
  89. package/components/Link/Link.module.scss.js +9 -15
  90. package/components/List/List.js +22 -46
  91. package/components/List/List.module.scss.js +11 -20
  92. package/components/Loader/Loader.js +152 -182
  93. package/components/Loader/Loader.module.scss.js +39 -69
  94. package/components/Modal/Modal.js +93 -105
  95. package/components/Modal/Modal.module.scss.js +17 -32
  96. package/components/PageHeader/PageHeader.js +79 -73
  97. package/components/PageHeader/PageHeader.module.scss.js +22 -42
  98. package/components/Pagination/Pagination.js +62 -83
  99. package/components/Pagination/Pagination.module.scss.js +12 -22
  100. package/components/Pagination/paginationRange.js +15 -22
  101. package/components/Popover/Popover.js +110 -134
  102. package/components/Popover/Popover.module.scss.js +11 -20
  103. package/components/ProgressBar/ProgressBar.d.ts +15 -1
  104. package/components/ProgressBar/ProgressBar.js +56 -89
  105. package/components/ProgressBar/ProgressBar.module.scss.js +28 -50
  106. package/components/RelativeTime/RelativeTime.js +36 -43
  107. package/components/RelativeTime/RelativeTime.module.scss.js +3 -7
  108. package/components/SegmentedControl/SegmentedControl.js +93 -129
  109. package/components/SegmentedControl/SegmentedControl.module.scss.js +20 -38
  110. package/components/Skeleton/Skeleton.js +36 -50
  111. package/components/Skeleton/Skeleton.module.scss.js +14 -24
  112. package/components/Spinner/Spinner.js +25 -25
  113. package/components/Spinner/Spinner.module.scss.js +11 -19
  114. package/components/SplitButton/SplitButton.js +149 -196
  115. package/components/SplitButton/SplitButton.module.scss.js +30 -56
  116. package/components/SplitPane/SplitPane.js +134 -170
  117. package/components/SplitPane/SplitPane.module.scss.js +13 -24
  118. package/components/StatCard/StatCard.js +132 -125
  119. package/components/StatCard/StatCard.module.scss.js +41 -71
  120. package/components/StatusDot/StatusDot.js +28 -39
  121. package/components/StatusDot/StatusDot.module.scss.js +17 -31
  122. package/components/Table/Table.d.ts +1 -1
  123. package/components/Table/Table.js +381 -451
  124. package/components/Table/Table.module.scss.js +41 -80
  125. package/components/Table/useTableSort.js +51 -42
  126. package/components/Tabs/Tabs.js +109 -161
  127. package/components/Tabs/Tabs.module.scss.js +27 -52
  128. package/components/ThemeToggle/ThemeToggle.js +122 -98
  129. package/components/ThemeToggle/ThemeToggle.module.scss.js +12 -22
  130. package/components/Timeline/GanttTimeline.js +357 -318
  131. package/components/Timeline/GanttTimeline.module.scss.js +28 -54
  132. package/components/Timeline/HistoryTimeline.js +486 -450
  133. package/components/Timeline/HistoryTimeline.module.scss.js +30 -58
  134. package/components/Timeline/Timeline.module.scss.js +75 -140
  135. package/components/Timeline/TimelineShared.d.ts +7 -7
  136. package/components/Timeline/TimelineShared.js +288 -279
  137. package/components/Timeline/TraceEventDetails.d.ts +3 -3
  138. package/components/Timeline/TraceEventDetails.js +244 -177
  139. package/components/Timeline/TraceTimeline.js +823 -783
  140. package/components/Timeline/TraceTimeline.module.scss.js +97 -188
  141. package/components/Timeline/historyLayout.js +336 -263
  142. package/components/Timeline/timelineCore.js +208 -183
  143. package/components/Timeline/traceEvent.js +59 -61
  144. package/components/Timeline/traceLayout.js +101 -90
  145. package/components/Timeline/useTimeline.js +76 -79
  146. package/components/Timer/Timer.js +190 -156
  147. package/components/Timer/Timer.module.scss.js +28 -54
  148. package/components/Toast/Toast.d.ts +1 -1
  149. package/components/Toast/Toast.js +128 -128
  150. package/components/Toast/Toast.module.scss.js +36 -61
  151. package/components/Toast/toastStore.js +58 -62
  152. package/components/ToggleIconButton/ToggleIconButton.js +36 -58
  153. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +14 -26
  154. package/components/Tooltip/Tooltip.d.ts +1 -1
  155. package/components/Tooltip/Tooltip.js +76 -85
  156. package/components/Tooltip/Tooltip.module.scss.js +16 -29
  157. package/components/Typography/Typography.js +10 -35
  158. package/components/Typography/Typography.module.scss.js +29 -52
  159. package/components/inputs/Checkbox/Checkbox.js +27 -51
  160. package/components/inputs/Checkbox/Checkbox.module.scss.js +9 -16
  161. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  162. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +16 -30
  163. package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
  164. package/components/inputs/DatePicker/CalendarPanel.js +263 -286
  165. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +22 -40
  166. package/components/inputs/DatePicker/DatePicker.js +115 -142
  167. package/components/inputs/DatePicker/DatePicker.module.scss.js +13 -24
  168. package/components/inputs/DatePicker/dateUtils.js +32 -41
  169. package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
  170. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +19 -36
  171. package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
  172. package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
  173. package/components/inputs/DateTimePicker/TimeField.js +131 -132
  174. package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
  175. package/components/inputs/Input/Input.js +98 -109
  176. package/components/inputs/Input/Input.module.scss.js +14 -26
  177. package/components/inputs/NumberInput/NumberInput.js +112 -132
  178. package/components/inputs/NumberInput/NumberInput.module.scss.js +13 -24
  179. package/components/inputs/Radio/Radio.js +50 -73
  180. package/components/inputs/Radio/Radio.module.scss.js +8 -14
  181. package/components/inputs/SearchInput/SearchInput.js +98 -115
  182. package/components/inputs/SearchInput/SearchInput.module.scss.js +7 -12
  183. package/components/inputs/Select/Select.d.ts +55 -3
  184. package/components/inputs/Select/Select.js +696 -682
  185. package/components/inputs/Select/Select.module.scss.js +49 -72
  186. package/components/inputs/Slider/Slider.js +97 -128
  187. package/components/inputs/Slider/Slider.module.scss.js +8 -14
  188. package/components/inputs/Switch/Switch.js +11 -8
  189. package/components/inputs/Textarea/Textarea.js +42 -58
  190. package/components/inputs/Textarea/Textarea.module.scss.js +13 -24
  191. package/hooks/useClickOutside.js +17 -14
  192. package/hooks/useDebouncedValue.js +13 -14
  193. package/hooks/useElementSize.js +27 -22
  194. package/hooks/useEscapeLayer.js +28 -29
  195. package/hooks/useFocusTrap.js +27 -38
  196. package/hooks/useKeyboard.js +76 -64
  197. package/hooks/useMediaQuery.js +10 -15
  198. package/hooks/useNow.js +28 -33
  199. package/hooks/usePersistedState.js +98 -94
  200. package/hooks/usePortalPosition.d.ts +2 -1
  201. package/hooks/usePortalPosition.js +28 -19
  202. package/hooks/useResizable.js +106 -104
  203. package/hooks/useTheme.js +28 -23
  204. package/index.css +2 -1
  205. package/index.js +96 -214
  206. package/index.layered.css +2 -3
  207. package/llms.txt +28 -4
  208. package/manifest.json +41 -4
  209. package/package.json +1 -1
  210. package/utils/formatBytes.js +29 -13
  211. package/utils/themeScript.js +6 -8
  212. package/utils/timeAgo.js +59 -32
@@ -1,450 +1,486 @@
1
- import { jsx as l, jsxs as c, Fragment as ne } from "react/jsx-runtime";
2
- import { forwardRef as ct, useRef as L, useState as S, useCallback as j, useEffect as dt, useMemo as xe, useLayoutEffect as ut } from "react";
3
- import f from "clsx";
4
- import r from "./Timeline.module.scss.js";
5
- import i from "./HistoryTimeline.module.scss.js";
6
- import { TIMELINE_PALETTE_VARS as m, fmtDateTime as A, eventMatches as mt, fmtDur as D, tint as ht, fmtDate as pt, fmtClock as ke, ticks as ft, DAY as E } from "./timelineCore.js";
7
- import { computeHistoryLayout as gt } from "./historyLayout.js";
8
- import { TimelineSummary as vt, TimelineSegmented as He, TimelineZoomControls as wt, TimelineLegend as yt, HighlightText as Me, TimelineTooltip as Nt } from "./TimelineShared.js";
9
- import { useNowTicker as bt, useContainerWidth as St, useTimelinePan as Tt, useWheelZoom as xt, animateScrollTo as kt, wheelZoomAllowed as Ht } from "./useTimeline.js";
10
- const Mt = {
11
- created: m[0],
12
- done: m[0],
13
- live: m[0],
14
- payment: m[1],
15
- people: m[1],
16
- review: m[2],
17
- action: m[2],
18
- offer: m[2],
19
- fulfilment: m[3],
20
- analysis: m[3],
21
- shipping: m[4],
22
- interview: m[4],
23
- exception: "var(--crk-timeline-danger, #b3372f)",
24
- alert: "var(--crk-timeline-danger, #b3372f)"
25
- }, Vt = ct(
26
- function(Ce, Le) {
27
- const {
28
- events: le,
29
- subjectName: oe,
30
- orientation: ie,
31
- defaultOrientation: De,
32
- onOrientationChange: Ee,
33
- spacing: re,
34
- defaultSpacing: Pe = "equal",
35
- onSpacingChange: Oe,
36
- highlight: q,
37
- defaultHighlight: We,
38
- onHighlightChange: Re,
39
- showSearch: Ae = !0,
40
- renderSearch: ae,
41
- tagColors: se,
42
- showControls: ce = !0,
43
- wheelZoom: Fe = "ctrl",
44
- showLegend: Ve = !0,
45
- showSummary: F = !1,
46
- summaryPlacement: T = "left",
47
- summaryDefaultPosition: ze,
48
- maxHeight: de,
49
- selectedEventId: X,
50
- defaultSelectedEventId: Ie = null,
51
- onEventSelect: Ye,
52
- renderCard: ue,
53
- renderTooltip: V,
54
- renderDetails: K,
55
- classes: h,
56
- className: Ze,
57
- style: je
58
- } = Ce, w = L(null), [qe, Xe] = S(
59
- () => De ?? (typeof window < "u" && window.innerWidth < 700 ? "vertical" : "horizontal")
60
- ), z = ie ?? qe, y = z === "horizontal", [Ke, Ue] = S(Pe), U = re ?? Ke, [_e, me] = S(1), [he, pe] = S(!0), [b, _] = S(null), [Ge, Be] = S(Ie), P = X !== void 0 ? X : Ge, [N, Je] = S({ l: 0, t: 0, w: 0, h: 0 }), fe = L(F);
61
- fe.current = F;
62
- const G = L(null), B = j(() => {
63
- const e = w.current;
64
- e && Je(
65
- (n) => n.l === e.scrollLeft && n.t === e.scrollTop && n.w === e.clientWidth && n.h === e.clientHeight ? n : { l: e.scrollLeft, t: e.scrollTop, w: e.clientWidth, h: e.clientHeight }
66
- );
67
- }, []), $e = j(() => {
68
- !fe.current || G.current != null || (G.current = requestAnimationFrame(() => {
69
- G.current = null, B();
70
- }));
71
- }, [B]);
72
- dt(() => {
73
- F && B();
74
- });
75
- const [Qe, et] = S(We ?? ""), J = q !== void 0 ? q : Qe, x = J.trim(), ge = (e) => {
76
- q === void 0 && et(e), Re?.(e);
77
- }, ve = ae ? ae({ value: J, setValue: ge }) : Ae ? /* @__PURE__ */ l(
78
- "input",
79
- {
80
- className: f(r.searchInput, h?.search),
81
- placeholder: "Highlight keyword in events…",
82
- "aria-label": "Highlight keyword",
83
- value: J,
84
- onChange: (e) => ge(e.target.value)
85
- }
86
- ) : null, d = xe(
87
- () => le.map((e) => ({
88
- ...e,
89
- end: e.end !== void 0 ? e.end : e.ongoing ? null : e.start
90
- })).sort((e, n) => e.start - n.start),
91
- [le]
92
- ), tt = d.some((e) => e.end == null), k = bt(tt, 500), nt = St(w), O = Tt(w), M = j(
93
- (e) => {
94
- const n = e || "event", t = { ...Mt, ...se };
95
- if (t[n]) return t[n];
96
- const o = String(n).charCodeAt(0) || 0;
97
- return m[(String(n).length + o) % m.length];
98
- },
99
- [se]
100
- ), s = gt(
101
- d.map((e) => ({
102
- id: e.id,
103
- title: String(e.title || ""),
104
- detail: String(e.detail || ""),
105
- start: e.start,
106
- end: e.end ?? null
107
- })),
108
- {
109
- orientation: z,
110
- spacing: U,
111
- containerWidth: nt,
112
- viewportHeight: typeof window < "u" && window.innerHeight || 800,
113
- now: k,
114
- k: he ? "fit" : _e
115
- }
116
- ), I = new Map(s.items.map((e) => [e.id, e])), we = L(s.kFit), ye = L(s.kEff);
117
- we.current = s.kFit, ye.current = s.kEff;
118
- const H = L(null);
119
- ut(() => {
120
- const e = w.current;
121
- H.current && e && (H.current.left != null && (e.scrollLeft = H.current.left), H.current.top != null && (e.scrollTop = H.current.top), H.current = null);
122
- });
123
- const $ = j(
124
- (e, n) => {
125
- const t = w.current;
126
- if (!t) return;
127
- const o = we.current || 1, p = ye.current || 1, u = Math.max(o * 0.3, Math.min(Math.max(o, 1) * 40, p * e)), g = y ? t.scrollLeft : t.scrollTop, v = u / p;
128
- H.current = y ? { left: (g + n) * v - n } : { top: (g + n) * v - n }, pe(!1), me(u);
129
- },
130
- [y]
131
- );
132
- xt(
133
- w,
134
- (e) => {
135
- if (!Ht(Fe, e)) return;
136
- e.preventDefault();
137
- const n = w.current;
138
- if (!n) return;
139
- const t = n.getBoundingClientRect(), o = y ? e.clientX - t.left : e.clientY - t.top;
140
- $(Math.exp(-(e.deltaY || e.deltaX) * 22e-4), o);
141
- },
142
- z
143
- );
144
- const Ne = () => {
145
- const e = w.current;
146
- return e ? y ? e.clientWidth / 2 : e.clientHeight / 2 : 300;
147
- }, Q = (e) => {
148
- X === void 0 && Be(e ? e.id : null), Ye?.(e);
149
- }, lt = (e) => {
150
- ie === void 0 && Xe(e), Ee?.(e);
151
- }, ot = (e) => {
152
- re === void 0 && Ue(e), Oe?.(e);
153
- }, it = (e) => {
154
- const n = window.innerWidth || 1200, t = window.innerHeight || 800, o = e.clientX < n * 0.55 ? Math.max(12, n - 340) : 16, p = Math.max(130, Math.min(e.clientY, t - 130));
155
- return { x: o, y: p };
156
- }, W = d.length ? d[0].start : k, rt = d.length ? Math.max(W + 1, ...d.map((e) => e.end == null ? k : Math.max(e.end, e.start))) : k + 1, Y = Math.max(1, rt - W), be = (e, n) => {
157
- const t = new Date(e);
158
- return n === "y" ? String(t.getFullYear()) : n === "my" ? t.toLocaleString("en", { month: "short" }) + " " + t.getFullYear() : n === "d" ? pt(e) : n === "cms" ? ke(e, !0) : ke(e);
159
- };
160
- let ee = [];
161
- if (U === "proportional" && s.mapT) {
162
- const e = s.mapT, n = e(W), t = y ? s.innerW : s.innerH, o = W + (t - n) / Math.max(1, s.innerSpan) * Y, p = ft(W, o, Math.max(200, t - n), 90), u = p.step >= 360 * E ? "y" : p.step >= 28 * E ? "my" : p.step >= E ? "d" : p.step < 1e3 ? "cms" : "c";
163
- ee = p.list.map((g) => ({
164
- pos: Math.round(e(g.t)),
165
- label: be(g.t, u)
166
- }));
167
- } else {
168
- const e = Y > 550 * E ? "y" : Y > 60 * E ? "my" : Y > 2 * E ? "d" : "c", n = y ? 72 : 18;
169
- let t = null, o = -1e9;
170
- d.forEach((p, u) => {
171
- const g = be(p.start, e), v = Math.round(s.posArr[u]);
172
- g !== t && v - o >= n && (ee.push({ pos: v, label: g }), t = g, o = v);
173
- });
174
- }
175
- const at = xe(() => {
176
- const e = [];
177
- return d.forEach((n) => {
178
- const t = n.tag || "event";
179
- e.includes(t) || e.push(t);
180
- }), e;
181
- }, [d]), a = P != null && d.find((e) => e.id === P) || null, Se = a ? a.end == null : !1, R = F ? /* @__PURE__ */ l(
182
- vt,
183
- {
184
- className: h?.summary,
185
- placement: T,
186
- floatingDefaultPosition: ze,
187
- items: d.map((e, n) => {
188
- const t = I.get(e.id), o = !t || !N.w && !N.h ? !0 : (!N.w || t.cardLeft < N.l + N.w && t.cardLeft + t.cardW > N.l) && (!N.h || t.cardTop < N.t + N.h && t.cardTop + t.cardH > N.t);
189
- return {
190
- id: e.id,
191
- number: String(n + 1).padStart(2, "0"),
192
- label: e.title,
193
- color: M(e.tag),
194
- time: A(e.start),
195
- inView: o,
196
- selected: P === e.id
197
- };
198
- }),
199
- onPick: (e) => {
200
- const n = I.get(e), t = w.current;
201
- if (!n || !t) return;
202
- const o = {};
203
- (t.clientWidth || !t.clientHeight) && (o.left = Math.max(0, n.dotX - t.clientWidth / 2)), t.clientHeight && (o.top = Math.max(0, n.dotY - t.clientHeight / 2)), kt(t, o);
204
- }
205
- }
206
- ) : null;
207
- return /* @__PURE__ */ c("div", { ref: Le, className: f(r.root, h?.root, Ze), style: je, children: [
208
- (ce || ve) && /* @__PURE__ */ c("div", { className: f(r.toolbar, h?.toolbar), children: [
209
- /* @__PURE__ */ l("div", { className: r.toolbarText }),
210
- ve,
211
- ce && /* @__PURE__ */ c(ne, { children: [
212
- /* @__PURE__ */ l(
213
- He,
214
- {
215
- value: z,
216
- options: [
217
- { value: "horizontal", label: "Horizontal" },
218
- { value: "vertical", label: "Vertical" }
219
- ],
220
- onChange: lt
221
- }
222
- ),
223
- /* @__PURE__ */ l(
224
- He,
225
- {
226
- value: U,
227
- options: [
228
- { value: "equal", label: "Equal" },
229
- {
230
- value: "log",
231
- label: "Log",
232
- title: "Logarithmic gaps — long waits compressed"
233
- },
234
- { value: "proportional", label: "Proportional" }
235
- ],
236
- onChange: ot
237
- }
238
- ),
239
- /* @__PURE__ */ l(
240
- wt,
241
- {
242
- zoomPct: `${Math.round(s.kEff / s.kFit * 100)}%`,
243
- fitActive: he,
244
- onZoomIn: () => $(1.5, Ne()),
245
- onZoomOut: () => $(1 / 1.5, Ne()),
246
- onFit: () => {
247
- pe(!0), me(1);
248
- }
249
- }
250
- )
251
- ] })
252
- ] }),
253
- Ve && /* @__PURE__ */ l(
254
- yt,
255
- {
256
- className: h?.legend,
257
- items: at.map((e) => ({ name: e, color: M(e) }))
258
- }
259
- ),
260
- T === "top" && R,
261
- /* @__PURE__ */ c("div", { className: r.layout, children: [
262
- T === "left" && R,
263
- /* @__PURE__ */ c("div", { className: r.main, children: [
264
- /* @__PURE__ */ c("div", { className: r.cardWrap, children: [
265
- /* @__PURE__ */ l("div", { className: f(r.card, h?.card), children: /* @__PURE__ */ l(
266
- "div",
267
- {
268
- ref: w,
269
- className: f(
270
- r.scroller,
271
- y ? i.scrollerH : i.scrollerV,
272
- h?.scroller
273
- ),
274
- style: de != null ? { maxHeight: de } : void 0,
275
- onPointerDown: O.onPointerDown,
276
- onPointerMove: O.onPointerMove,
277
- onPointerUp: O.onPointerUp,
278
- onPointerLeave: O.onPointerUp,
279
- onScroll: $e,
280
- children: /* @__PURE__ */ c(
281
- "div",
282
- {
283
- className: i.inner,
284
- style: { width: s.innerW, height: s.innerH },
285
- children: [
286
- ee.map(
287
- (e, n) => y ? /* @__PURE__ */ c("span", { children: [
288
- /* @__PURE__ */ l("span", { className: i.gridlineH, style: { left: e.pos } }),
289
- /* @__PURE__ */ l("span", { className: i.tickLabelH, style: { left: e.pos }, children: e.label })
290
- ] }, n) : /* @__PURE__ */ c("span", { children: [
291
- /* @__PURE__ */ l("span", { className: i.gridlineV, style: { top: e.pos } }),
292
- /* @__PURE__ */ l("span", { className: i.tickLabelV, style: { top: e.pos }, children: e.label })
293
- ] }, n)
294
- ),
295
- y ? /* @__PURE__ */ l("div", { className: i.axisH, style: { top: s.axisY } }) : /* @__PURE__ */ l("div", { className: i.axisV, style: { left: s.axisX } }),
296
- d.map((e, n) => {
297
- const t = I.get(e.id);
298
- if (!t) return null;
299
- const o = e.end == null, u = (o ? k : e.end) - e.start, g = o || u > 0, v = mt(e, x), Z = M(e.tag), Te = {
300
- index: n,
301
- number: String(n + 1).padStart(2, "0"),
302
- color: Z,
303
- ongoing: o,
304
- condensed: t.condensed,
305
- durationMs: u
306
- };
307
- return /* @__PURE__ */ c("span", { children: [
308
- t.segs.map((C, te) => /* @__PURE__ */ l(
309
- "span",
310
- {
311
- className: i.seg,
312
- style: {
313
- left: C.l,
314
- top: C.t,
315
- width: C.w,
316
- height: C.h,
317
- background: Z
318
- }
319
- },
320
- te
321
- )),
322
- /* @__PURE__ */ l(
323
- "span",
324
- {
325
- className: f(i.dot, h?.dot),
326
- style: { left: t.dotX, top: t.dotY, borderColor: Z }
327
- }
328
- ),
329
- /* @__PURE__ */ l(
330
- "div",
331
- {
332
- className: f(i.eventCard, h?.eventCard),
333
- style: {
334
- left: t.cardLeft,
335
- top: t.cardTop,
336
- width: t.cardW,
337
- height: t.cardH,
338
- opacity: x && !v ? 0.3 : 1,
339
- background: x && v ? "var(--crk-timeline-hl-wash-soft, #fff9e8)" : void 0,
340
- borderColor: x && v ? "var(--crk-timeline-hl-border, #e8b931)" : void 0,
341
- boxShadow: x && v ? "0 0 0 3px #f9e9b8" : "0 1px 3px rgba(35,32,28,.06)"
342
- },
343
- onClick: () => {
344
- O.wasDragSuppressed() || (_(null), Q(P === e.id ? null : e));
345
- },
346
- onMouseEnter: (C) => {
347
- if (P === e.id) return;
348
- const te = (e.detail || "").length > 80;
349
- if (!V && !te && !o) return;
350
- const st = it(C);
351
- _({
352
- ...st,
353
- id: e.id,
354
- title: e.title,
355
- time: A(e.start),
356
- durLine: o ? "ongoing · " + D(u) + " so far" : u > 0 ? "duration " + D(u) : "instant event",
357
- detail: e.detail || ""
358
- });
359
- },
360
- onMouseLeave: () => _(null),
361
- children: ue ? ue(e, Te) : /* @__PURE__ */ c(ne, { children: [
362
- /* @__PURE__ */ c("div", { className: i.cardTitle, children: [
363
- /* @__PURE__ */ l("span", { className: i.cardNum, children: Te.number }),
364
- " ",
365
- /* @__PURE__ */ l("span", { className: i.cardTagDot, style: { background: Z } }),
366
- /* @__PURE__ */ l(Me, { text: e.title, query: x }),
367
- o && /* @__PURE__ */ l("span", { className: f(r.pulseDot, i.cardOngoingDot) })
368
- ] }),
369
- /* @__PURE__ */ l("div", { className: i.cardTime, children: A(e.start) }),
370
- !t.condensed && !!e.detail && /* @__PURE__ */ l("div", { className: i.cardDetail, children: /* @__PURE__ */ l(Me, { text: e.detail, query: x }) }),
371
- g && /* @__PURE__ */ l("div", { className: i.cardDur, children: o ? "ongoing · " + D(u) : "took " + D(u) })
372
- ] })
373
- }
374
- )
375
- ] }, e.id);
376
- })
377
- ]
378
- }
379
- )
380
- }
381
- ) }),
382
- T === "bubble" && R
383
- ] }),
384
- /* @__PURE__ */ l("div", { className: f(r.footnote, h?.footnote), children: "Click a card to open details in the side panel · scroll zooms · drag pans · overlapping events stack around the axis with Z-shaped leads" })
385
- ] }),
386
- a && K && /* @__PURE__ */ l("aside", { className: f(r.aside, i.drawer, h?.drawer), children: K(a, { close: () => Q(null), ongoing: Se }) }),
387
- a && !K && /* @__PURE__ */ c("aside", { className: f(r.aside, i.drawer, h?.drawer), children: [
388
- /* @__PURE__ */ c("div", { className: i.drawerHead, children: [
389
- /* @__PURE__ */ l(
390
- "span",
391
- {
392
- className: i.drawerTag,
393
- style: {
394
- background: ht(M(a.tag), 12),
395
- color: M(a.tag)
396
- },
397
- children: a.tag || "event"
398
- }
399
- ),
400
- (oe ?? a.subject) != null && /* @__PURE__ */ l("span", { className: i.drawerSubject, children: oe ?? a.subject }),
401
- /* @__PURE__ */ l("div", { className: i.drawerSpacer }),
402
- /* @__PURE__ */ l(
403
- "button",
404
- {
405
- type: "button",
406
- className: r.asideClose,
407
- "aria-label": "Close details",
408
- onClick: () => Q(null),
409
- children: "✕"
410
- }
411
- )
412
- ] }),
413
- /* @__PURE__ */ l("div", { className: i.drawerTitle, children: a.title }),
414
- /* @__PURE__ */ l("div", { className: i.drawerTiming, children: A(a.start) + (Se ? " · ongoing, " + D(k - a.start) + " so far" : a.end > a.start ? " → " + A(a.end) + " · " + D(a.end - a.start) : "") }),
415
- /* @__PURE__ */ l("div", { className: i.drawerDetail, children: a.detail || "—" }),
416
- /* @__PURE__ */ l("div", { className: r.asideSection, children: "Raw event" }),
417
- /* @__PURE__ */ l("pre", { className: r.asideRaw, children: JSON.stringify(a, null, 2) })
418
- ] }),
419
- (T === "right" || T === "floating") && R
420
- ] }),
421
- T === "bottom" && R,
422
- b && (() => {
423
- const e = d.find((o) => o.id === b.id), n = e ? d.indexOf(e) : -1, t = e && V ? V(e, {
424
- index: n,
425
- number: String(n + 1).padStart(2, "0"),
426
- color: M(e.tag),
427
- ongoing: e.end == null,
428
- condensed: I.get(e.id)?.condensed ?? !1,
429
- durationMs: (e.end == null ? k : e.end) - e.start
430
- }) : void 0;
431
- return V && t == null ? null : /* @__PURE__ */ l(Nt, { x: b.x, y: b.y, className: h?.tooltip, children: t !== void 0 ? t : /* @__PURE__ */ c(ne, { children: [
432
- /* @__PURE__ */ l("div", { className: r.tooltipTitle, children: b.title }),
433
- /* @__PURE__ */ l(
434
- "div",
435
- {
436
- className: f(r.tooltipLine, r.tooltipMono),
437
- style: { marginTop: 4 },
438
- children: b.time
439
- }
440
- ),
441
- /* @__PURE__ */ l("div", { className: r.tooltipLine, children: b.durLine }),
442
- b.detail && /* @__PURE__ */ l("div", { className: r.tooltipDim, style: { marginTop: 5 }, children: b.detail })
443
- ] }) });
444
- })()
445
- ] });
446
- }
447
- );
448
- export {
449
- Vt as HistoryTimeline
450
- };
1
+ import { forwardRef as e, useCallback as t, useEffect as n, useLayoutEffect as r, useMemo as i, useRef as a, useState as o } from "react";
2
+ import s from "clsx";
3
+ import c from "./Timeline.module.scss.js";
4
+ import l from "./HistoryTimeline.module.scss.js";
5
+ import { TIMELINE_PALETTE_VARS as u, eventMatches as ee, fmtClock as d, fmtDate as te, fmtDateTime as f, fmtDur as p, ticks as ne, tint as re } from "./timelineCore.js";
6
+ import { computeHistoryLayout as ie } from "./historyLayout.js";
7
+ import { HighlightText as ae, TimelineLegend as oe, TimelineSegmented as se, TimelineSummary as ce, TimelineTooltip as le, TimelineZoomControls as ue } from "./TimelineShared.js";
8
+ import { animateScrollTo as de, useContainerWidth as fe, useNowTicker as pe, useTimelinePan as me, useWheelZoom as he, wheelZoomAllowed as ge } from "./useTimeline.js";
9
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
10
+ // src/components/Timeline/HistoryTimeline.tsx
11
+ var _e = {
12
+ created: u[0],
13
+ done: u[0],
14
+ live: u[0],
15
+ payment: u[1],
16
+ people: u[1],
17
+ review: u[2],
18
+ action: u[2],
19
+ offer: u[2],
20
+ fulfilment: u[3],
21
+ analysis: u[3],
22
+ shipping: u[4],
23
+ interview: u[4],
24
+ exception: "var(--crk-timeline-danger, #b3372f)",
25
+ alert: "var(--crk-timeline-danger, #b3372f)"
26
+ }, _ = e(function(e, _) {
27
+ let { events: ve, subjectName: ye, orientation: be, defaultOrientation: xe, onOrientationChange: Se, spacing: Ce, defaultSpacing: we = "equal", onSpacingChange: Te, highlight: v, defaultHighlight: Ee, onHighlightChange: De, showSearch: Oe = !0, renderSearch: ke, tagColors: Ae, showControls: je = !0, wheelZoom: Me = "ctrl", showLegend: Ne = !0, showSummary: y = !1, summaryPlacement: b = "left", summaryDefaultPosition: Pe, maxHeight: x, selectedEventId: S, defaultSelectedEventId: Fe = null, onEventSelect: Ie, renderCard: C, renderTooltip: w, renderDetails: T, classes: E, className: Le, style: Re } = e, D = a(null), [ze, Be] = o(() => xe ?? (typeof window < "u" && window.innerWidth < 700 ? "vertical" : "horizontal")), O = be ?? ze, k = O === "horizontal", [Ve, He] = o(we), A = Ce ?? Ve, [Ue, We] = o(1), [Ge, Ke] = o(!0), [j, M] = o(null), [qe, Je] = o(Fe), N = S === void 0 ? qe : S, [P, Ye] = o({
28
+ l: 0,
29
+ t: 0,
30
+ w: 0,
31
+ h: 0
32
+ }), Xe = a(y);
33
+ Xe.current = y;
34
+ let F = a(null), I = t(() => {
35
+ let e = D.current;
36
+ e && Ye((t) => t.l === e.scrollLeft && t.t === e.scrollTop && t.w === e.clientWidth && t.h === e.clientHeight ? t : {
37
+ l: e.scrollLeft,
38
+ t: e.scrollTop,
39
+ w: e.clientWidth,
40
+ h: e.clientHeight
41
+ });
42
+ }, []), Ze = t(() => {
43
+ Xe.current && F.current == null && (F.current = requestAnimationFrame(() => {
44
+ F.current = null, I();
45
+ }));
46
+ }, [I]);
47
+ n(() => {
48
+ y && I();
49
+ });
50
+ let [Qe, $e] = o(Ee ?? ""), L = v === void 0 ? Qe : v, R = L.trim(), et = (e) => {
51
+ v === void 0 && $e(e), De?.(e);
52
+ }, tt = ke ? ke({
53
+ value: L,
54
+ setValue: et
55
+ }) : Oe ? /* @__PURE__ */ h("input", {
56
+ className: s(c.searchInput, E?.search),
57
+ placeholder: "Highlight keyword in events…",
58
+ "aria-label": "Highlight keyword",
59
+ value: L,
60
+ onChange: (e) => et(e.target.value)
61
+ }) : null, z = i(() => ve.map((e) => ({
62
+ ...e,
63
+ end: e.end === void 0 ? e.ongoing ? null : e.start : e.end
64
+ })).sort((e, t) => e.start - t.start), [ve]), nt = z.some((e) => e.end == null), B = pe(nt, 500), rt = fe(D), V = me(D), H = t((e) => {
65
+ let t = e || "event", n = {
66
+ ..._e,
67
+ ...Ae
68
+ };
69
+ if (n[t]) return n[t];
70
+ let r = String(t).charCodeAt(0) || 0;
71
+ return u[(String(t).length + r) % u.length];
72
+ }, [Ae]), U = ie(z.map((e) => ({
73
+ id: e.id,
74
+ title: String(e.title || ""),
75
+ detail: String(e.detail || ""),
76
+ start: e.start,
77
+ end: e.end ?? null
78
+ })), {
79
+ orientation: O,
80
+ spacing: A,
81
+ containerWidth: rt,
82
+ viewportHeight: typeof window < "u" && window.innerHeight || 800,
83
+ now: B,
84
+ k: Ge ? "fit" : Ue
85
+ }), W = new Map(U.items.map((e) => [e.id, e])), it = a(U.kFit), at = a(U.kEff);
86
+ it.current = U.kFit, at.current = U.kEff;
87
+ let G = a(null);
88
+ r(() => {
89
+ let e = D.current;
90
+ G.current && e && (G.current.left != null && (e.scrollLeft = G.current.left), G.current.top != null && (e.scrollTop = G.current.top), G.current = null);
91
+ });
92
+ let K = t((e, t) => {
93
+ let n = D.current;
94
+ if (!n) return;
95
+ let r = it.current || 1, i = at.current || 1, a = Math.max(r * .3, Math.min(Math.max(r, 1) * 40, i * e)), o = k ? n.scrollLeft : n.scrollTop, s = a / i;
96
+ G.current = k ? { left: (o + t) * s - t } : { top: (o + t) * s - t }, Ke(!1), We(a);
97
+ }, [k]);
98
+ he(D, (e) => {
99
+ if (!ge(Me, e)) return;
100
+ e.preventDefault();
101
+ let t = D.current;
102
+ if (!t) return;
103
+ let n = t.getBoundingClientRect(), r = k ? e.clientX - n.left : e.clientY - n.top;
104
+ K(Math.exp(-(e.deltaY || e.deltaX) * .0022), r);
105
+ }, O);
106
+ let ot = () => {
107
+ let e = D.current;
108
+ return e ? k ? e.clientWidth / 2 : e.clientHeight / 2 : 300;
109
+ }, q = (e) => {
110
+ S === void 0 && Je(e ? e.id : null), Ie?.(e);
111
+ }, st = (e) => {
112
+ be === void 0 && Be(e), Se?.(e);
113
+ }, ct = (e) => {
114
+ Ce === void 0 && He(e), Te?.(e);
115
+ }, lt = (e) => {
116
+ let t = window.innerWidth || 1200, n = window.innerHeight || 800;
117
+ return {
118
+ x: e.clientX < t * .55 ? Math.max(12, t - 340) : 16,
119
+ y: Math.max(130, Math.min(e.clientY, n - 130))
120
+ };
121
+ }, J = z.length ? z[0].start : B, ut = z.length ? Math.max(J + 1, ...z.map((e) => e.end == null ? B : Math.max(e.end, e.start))) : B + 1, Y = Math.max(1, ut - J), dt = (e, t) => {
122
+ let n = new Date(e);
123
+ return t === "y" ? String(n.getFullYear()) : t === "my" ? n.toLocaleString("en", { month: "short" }) + " " + n.getFullYear() : t === "d" ? te(e) : t === "cms" ? d(e, !0) : d(e);
124
+ }, X = [];
125
+ if (A === "proportional" && U.mapT) {
126
+ let e = U.mapT, t = e(J), n = k ? U.innerW : U.innerH, r = J + (n - t) / Math.max(1, U.innerSpan) * Y, i = ne(J, r, Math.max(200, n - t), 90), a = i.step >= 31104e6 ? "y" : i.step >= 24192e5 ? "my" : i.step >= 864e5 ? "d" : i.step < 1e3 ? "cms" : "c";
127
+ X = i.list.map((t) => ({
128
+ pos: Math.round(e(t.t)),
129
+ label: dt(t.t, a)
130
+ }));
131
+ } else {
132
+ let e = Y > 4752e7 ? "y" : Y > 5184e6 ? "my" : Y > 1728e5 ? "d" : "c", t = k ? 72 : 18, n = null, r = -1e9;
133
+ z.forEach((i, a) => {
134
+ let o = dt(i.start, e), s = Math.round(U.posArr[a]);
135
+ o !== n && s - r >= t && (X.push({
136
+ pos: s,
137
+ label: o
138
+ }), n = o, r = s);
139
+ });
140
+ }
141
+ let ft = i(() => {
142
+ let e = [];
143
+ return z.forEach((t) => {
144
+ let n = t.tag || "event";
145
+ e.includes(n) || e.push(n);
146
+ }), e;
147
+ }, [z]), Z = N == null ? null : z.find((e) => e.id === N) || null, Q = Z ? Z.end == null : !1, $ = y ? /* @__PURE__ */ h(ce, {
148
+ className: E?.summary,
149
+ placement: b,
150
+ floatingDefaultPosition: Pe,
151
+ items: z.map((e, t) => {
152
+ let n = W.get(e.id), r = !n || !P.w && !P.h || (!P.w || n.cardLeft < P.l + P.w && n.cardLeft + n.cardW > P.l) && (!P.h || n.cardTop < P.t + P.h && n.cardTop + n.cardH > P.t);
153
+ return {
154
+ id: e.id,
155
+ number: String(t + 1).padStart(2, "0"),
156
+ label: e.title,
157
+ color: H(e.tag),
158
+ time: f(e.start),
159
+ inView: r,
160
+ selected: N === e.id
161
+ };
162
+ }),
163
+ onPick: (e) => {
164
+ let t = W.get(e), n = D.current;
165
+ if (!t || !n) return;
166
+ let r = {};
167
+ (n.clientWidth || !n.clientHeight) && (r.left = Math.max(0, t.dotX - n.clientWidth / 2)), n.clientHeight && (r.top = Math.max(0, t.dotY - n.clientHeight / 2)), de(n, r);
168
+ }
169
+ }) : null;
170
+ return /* @__PURE__ */ g("div", {
171
+ ref: _,
172
+ className: s(c.root, E?.root, Le),
173
+ style: Re,
174
+ children: [
175
+ (je || tt) && /* @__PURE__ */ g("div", {
176
+ className: s(c.toolbar, E?.toolbar),
177
+ children: [
178
+ /* @__PURE__ */ h("div", { className: c.toolbarText }),
179
+ tt,
180
+ je && /* @__PURE__ */ g(m, { children: [
181
+ /* @__PURE__ */ h(se, {
182
+ value: O,
183
+ options: [{
184
+ value: "horizontal",
185
+ label: "Horizontal"
186
+ }, {
187
+ value: "vertical",
188
+ label: "Vertical"
189
+ }],
190
+ onChange: st
191
+ }),
192
+ /* @__PURE__ */ h(se, {
193
+ value: A,
194
+ options: [
195
+ {
196
+ value: "equal",
197
+ label: "Equal"
198
+ },
199
+ {
200
+ value: "log",
201
+ label: "Log",
202
+ title: "Logarithmic gaps — long waits compressed"
203
+ },
204
+ {
205
+ value: "proportional",
206
+ label: "Proportional"
207
+ }
208
+ ],
209
+ onChange: ct
210
+ }),
211
+ /* @__PURE__ */ h(ue, {
212
+ zoomPct: `${Math.round(U.kEff / U.kFit * 100)}%`,
213
+ fitActive: Ge,
214
+ onZoomIn: () => K(1.5, ot()),
215
+ onZoomOut: () => K(1 / 1.5, ot()),
216
+ onFit: () => {
217
+ Ke(!0), We(1);
218
+ }
219
+ })
220
+ ] })
221
+ ]
222
+ }),
223
+ Ne && /* @__PURE__ */ h(oe, {
224
+ className: E?.legend,
225
+ items: ft.map((e) => ({
226
+ name: e,
227
+ color: H(e)
228
+ }))
229
+ }),
230
+ b === "top" && $,
231
+ /* @__PURE__ */ g("div", {
232
+ className: c.layout,
233
+ children: [
234
+ b === "left" && $,
235
+ /* @__PURE__ */ g("div", {
236
+ className: c.main,
237
+ children: [/* @__PURE__ */ g("div", {
238
+ className: c.cardWrap,
239
+ children: [/* @__PURE__ */ h("div", {
240
+ className: s(c.card, E?.card),
241
+ children: /* @__PURE__ */ h("div", {
242
+ ref: D,
243
+ className: s(c.scroller, k ? l.scrollerH : l.scrollerV, E?.scroller),
244
+ style: x == null ? void 0 : { maxHeight: x },
245
+ onPointerDown: V.onPointerDown,
246
+ onPointerMove: V.onPointerMove,
247
+ onPointerUp: V.onPointerUp,
248
+ onPointerLeave: V.onPointerUp,
249
+ onScroll: Ze,
250
+ children: /* @__PURE__ */ g("div", {
251
+ className: l.inner,
252
+ style: {
253
+ width: U.innerW,
254
+ height: U.innerH
255
+ },
256
+ children: [
257
+ X.map((e, t) => k ? /* @__PURE__ */ g("span", { children: [/* @__PURE__ */ h("span", {
258
+ className: l.gridlineH,
259
+ style: { left: e.pos }
260
+ }), /* @__PURE__ */ h("span", {
261
+ className: l.tickLabelH,
262
+ style: { left: e.pos },
263
+ children: e.label
264
+ })] }, t) : /* @__PURE__ */ g("span", { children: [/* @__PURE__ */ h("span", {
265
+ className: l.gridlineV,
266
+ style: { top: e.pos }
267
+ }), /* @__PURE__ */ h("span", {
268
+ className: l.tickLabelV,
269
+ style: { top: e.pos },
270
+ children: e.label
271
+ })] }, t)),
272
+ k ? /* @__PURE__ */ h("div", {
273
+ className: l.axisH,
274
+ style: { top: U.axisY }
275
+ }) : /* @__PURE__ */ h("div", {
276
+ className: l.axisV,
277
+ style: { left: U.axisX }
278
+ }),
279
+ z.map((e, t) => {
280
+ let n = W.get(e.id);
281
+ if (!n) return null;
282
+ let r = e.end == null, i = (r ? B : e.end) - e.start, a = r || i > 0, o = ee(e, R), u = H(e.tag), d = {
283
+ index: t,
284
+ number: String(t + 1).padStart(2, "0"),
285
+ color: u,
286
+ ongoing: r,
287
+ condensed: n.condensed,
288
+ durationMs: i
289
+ };
290
+ return /* @__PURE__ */ g("span", { children: [
291
+ n.segs.map((e, t) => /* @__PURE__ */ h("span", {
292
+ className: l.seg,
293
+ style: {
294
+ left: e.l,
295
+ top: e.t,
296
+ width: e.w,
297
+ height: e.h,
298
+ background: u
299
+ }
300
+ }, t)),
301
+ /* @__PURE__ */ h("span", {
302
+ className: s(l.dot, E?.dot),
303
+ style: {
304
+ left: n.dotX,
305
+ top: n.dotY,
306
+ borderColor: u
307
+ }
308
+ }),
309
+ /* @__PURE__ */ h("div", {
310
+ className: s(l.eventCard, E?.eventCard),
311
+ style: {
312
+ left: n.cardLeft,
313
+ top: n.cardTop,
314
+ width: n.cardW,
315
+ height: n.cardH,
316
+ opacity: R && !o ? .3 : 1,
317
+ background: R && o ? "var(--crk-timeline-hl-wash-soft, #fff9e8)" : void 0,
318
+ borderColor: R && o ? "var(--crk-timeline-hl-border, #e8b931)" : void 0,
319
+ boxShadow: R && o ? "0 0 0 3px #f9e9b8" : "0 1px 3px rgba(35,32,28,.06)"
320
+ },
321
+ onClick: () => {
322
+ V.wasDragSuppressed() || (M(null), q(N === e.id ? null : e));
323
+ },
324
+ onMouseEnter: (t) => {
325
+ if (N === e.id) return;
326
+ let n = (e.detail || "").length > 80;
327
+ if (!w && !n && !r) return;
328
+ let a = lt(t);
329
+ M({
330
+ ...a,
331
+ id: e.id,
332
+ title: e.title,
333
+ time: f(e.start),
334
+ durLine: r ? "ongoing · " + p(i) + " so far" : i > 0 ? "duration " + p(i) : "instant event",
335
+ detail: e.detail || ""
336
+ });
337
+ },
338
+ onMouseLeave: () => M(null),
339
+ children: C ? C(e, d) : /* @__PURE__ */ g(m, { children: [
340
+ /* @__PURE__ */ g("div", {
341
+ className: l.cardTitle,
342
+ children: [
343
+ /* @__PURE__ */ h("span", {
344
+ className: l.cardNum,
345
+ children: d.number
346
+ }),
347
+ " ",
348
+ /* @__PURE__ */ h("span", {
349
+ className: l.cardTagDot,
350
+ style: { background: u }
351
+ }),
352
+ /* @__PURE__ */ h(ae, {
353
+ text: e.title,
354
+ query: R
355
+ }),
356
+ r && /* @__PURE__ */ h("span", { className: s(c.pulseDot, l.cardOngoingDot) })
357
+ ]
358
+ }),
359
+ /* @__PURE__ */ h("div", {
360
+ className: l.cardTime,
361
+ children: f(e.start)
362
+ }),
363
+ !n.condensed && !!e.detail && /* @__PURE__ */ h("div", {
364
+ className: l.cardDetail,
365
+ children: /* @__PURE__ */ h(ae, {
366
+ text: e.detail,
367
+ query: R
368
+ })
369
+ }),
370
+ a && /* @__PURE__ */ h("div", {
371
+ className: l.cardDur,
372
+ children: r ? "ongoing · " + p(i) : "took " + p(i)
373
+ })
374
+ ] })
375
+ })
376
+ ] }, e.id);
377
+ })
378
+ ]
379
+ })
380
+ })
381
+ }), b === "bubble" && $]
382
+ }), /* @__PURE__ */ h("div", {
383
+ className: s(c.footnote, E?.footnote),
384
+ children: "Click a card to open details in the side panel · scroll zooms · drag pans · overlapping events stack around the axis with Z-shaped leads"
385
+ })]
386
+ }),
387
+ Z && T && /* @__PURE__ */ h("aside", {
388
+ className: s(c.aside, l.drawer, E?.drawer),
389
+ children: T(Z, {
390
+ close: () => q(null),
391
+ ongoing: Q
392
+ })
393
+ }),
394
+ Z && !T && /* @__PURE__ */ g("aside", {
395
+ className: s(c.aside, l.drawer, E?.drawer),
396
+ children: [
397
+ /* @__PURE__ */ g("div", {
398
+ className: l.drawerHead,
399
+ children: [
400
+ /* @__PURE__ */ h("span", {
401
+ className: l.drawerTag,
402
+ style: {
403
+ background: re(H(Z.tag), 12),
404
+ color: H(Z.tag)
405
+ },
406
+ children: Z.tag || "event"
407
+ }),
408
+ (ye ?? Z.subject) != null && /* @__PURE__ */ h("span", {
409
+ className: l.drawerSubject,
410
+ children: ye ?? Z.subject
411
+ }),
412
+ /* @__PURE__ */ h("div", { className: l.drawerSpacer }),
413
+ /* @__PURE__ */ h("button", {
414
+ type: "button",
415
+ className: c.asideClose,
416
+ "aria-label": "Close details",
417
+ onClick: () => q(null),
418
+ children: "✕"
419
+ })
420
+ ]
421
+ }),
422
+ /* @__PURE__ */ h("div", {
423
+ className: l.drawerTitle,
424
+ children: Z.title
425
+ }),
426
+ /* @__PURE__ */ h("div", {
427
+ className: l.drawerTiming,
428
+ children: f(Z.start) + (Q ? " · ongoing, " + p(B - Z.start) + " so far" : Z.end > Z.start ? " → " + f(Z.end) + " · " + p(Z.end - Z.start) : "")
429
+ }),
430
+ /* @__PURE__ */ h("div", {
431
+ className: l.drawerDetail,
432
+ children: Z.detail || "—"
433
+ }),
434
+ /* @__PURE__ */ h("div", {
435
+ className: c.asideSection,
436
+ children: "Raw event"
437
+ }),
438
+ /* @__PURE__ */ h("pre", {
439
+ className: c.asideRaw,
440
+ children: JSON.stringify(Z, null, 2)
441
+ })
442
+ ]
443
+ }),
444
+ (b === "right" || b === "floating") && $
445
+ ]
446
+ }),
447
+ b === "bottom" && $,
448
+ j && (() => {
449
+ let e = z.find((e) => e.id === j.id), t = e ? z.indexOf(e) : -1, n = e && w ? w(e, {
450
+ index: t,
451
+ number: String(t + 1).padStart(2, "0"),
452
+ color: H(e.tag),
453
+ ongoing: e.end == null,
454
+ condensed: W.get(e.id)?.condensed ?? !1,
455
+ durationMs: (e.end == null ? B : e.end) - e.start
456
+ }) : void 0;
457
+ return w && n == null ? null : /* @__PURE__ */ h(le, {
458
+ x: j.x,
459
+ y: j.y,
460
+ className: E?.tooltip,
461
+ children: n === void 0 ? /* @__PURE__ */ g(m, { children: [
462
+ /* @__PURE__ */ h("div", {
463
+ className: c.tooltipTitle,
464
+ children: j.title
465
+ }),
466
+ /* @__PURE__ */ h("div", {
467
+ className: s(c.tooltipLine, c.tooltipMono),
468
+ style: { marginTop: 4 },
469
+ children: j.time
470
+ }),
471
+ /* @__PURE__ */ h("div", {
472
+ className: c.tooltipLine,
473
+ children: j.durLine
474
+ }),
475
+ j.detail && /* @__PURE__ */ h("div", {
476
+ className: c.tooltipDim,
477
+ style: { marginTop: 5 },
478
+ children: j.detail
479
+ })
480
+ ] }) : n
481
+ });
482
+ })()
483
+ ]
484
+ });
485
+ });
486
+ export { _ as HistoryTimeline };