@devalok/shilp-sutra 0.33.2 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/dist/_chunks/badge-group.js +306 -246
  2. package/dist/_chunks/chat.js +513 -0
  3. package/dist/_chunks/date-picker.js +748 -0
  4. package/dist/_chunks/document-preview.js +109 -90
  5. package/dist/_chunks/file-preview.js +492 -504
  6. package/dist/_chunks/framer.js +5564 -5613
  7. package/dist/_chunks/image-preview.js +127 -88
  8. package/dist/_chunks/keybinding.js +12 -14
  9. package/dist/_chunks/link-context.js +19 -16
  10. package/dist/_chunks/mention-suggestion.js +353 -350
  11. package/dist/_chunks/motion-provider.js +26 -20
  12. package/dist/_chunks/popover.js +127 -0
  13. package/dist/_chunks/primitives.js +7584 -6425
  14. package/dist/_chunks/rich-chat-input.js +2070 -0
  15. package/dist/_chunks/rolldown-runtime.js +21 -0
  16. package/dist/_chunks/shared.js +126 -0
  17. package/dist/_chunks/sonner.js +605 -734
  18. package/dist/_chunks/stat-row.js +418 -440
  19. package/dist/_chunks/tiptap.js +15850 -19964
  20. package/dist/_chunks/tree-view.js +231 -290
  21. package/dist/_chunks/use-calendar.js +161 -208
  22. package/dist/_chunks/vendor-client.js +314 -2199
  23. package/dist/_chunks/vendor-utils.js +1721 -2978
  24. package/dist/ai/ai-command-provider.js +23 -17
  25. package/dist/ai/block-renderer.js +68 -51
  26. package/dist/ai/blocks/index.js +2 -12
  27. package/dist/ai/command-bar.js +470 -519
  28. package/dist/ai/conversation.js +241 -227
  29. package/dist/ai/index.js +181 -167
  30. package/dist/ai/types.js +0 -1
  31. package/dist/composed/activity-feed.js +232 -202
  32. package/dist/composed/avatar-group.js +164 -222
  33. package/dist/composed/bulk-action-bar.js +174 -165
  34. package/dist/composed/command-palette.js +290 -308
  35. package/dist/composed/confirm-dialog.js +28 -48
  36. package/dist/composed/content-card.js +69 -108
  37. package/dist/composed/date-picker/index.js +3 -13
  38. package/dist/composed/deadline-indicator.js +68 -74
  39. package/dist/composed/emoji-picker.js +83 -110
  40. package/dist/composed/empty-state.js +64 -103
  41. package/dist/composed/error-boundary.js +129 -127
  42. package/dist/composed/file-preview.js +2 -12
  43. package/dist/composed/filter-bar.js +98 -130
  44. package/dist/composed/form-section.js +61 -45
  45. package/dist/composed/global-loading.js +34 -47
  46. package/dist/composed/index.js +34 -92
  47. package/dist/composed/inline-edit.js +92 -107
  48. package/dist/composed/lib/string-utils.js +8 -8
  49. package/dist/composed/loading-skeleton.js +103 -171
  50. package/dist/composed/markdown-viewer.js +187 -139
  51. package/dist/composed/master-detail.js +147 -156
  52. package/dist/composed/member-picker.js +46 -49
  53. package/dist/composed/multi-select-popover.js +181 -179
  54. package/dist/composed/page-header.js +54 -76
  55. package/dist/composed/page-skeletons.js +143 -127
  56. package/dist/composed/priority-indicator.js +105 -111
  57. package/dist/composed/responsive-overlay.js +36 -41
  58. package/dist/composed/rich-chat-input.js +2 -1860
  59. package/dist/composed/rich-text-editor.js +561 -424
  60. package/dist/composed/schedule-view.js +134 -185
  61. package/dist/composed/simple-tooltip.js +21 -21
  62. package/dist/composed/status-badge.js +133 -137
  63. package/dist/hooks/index.js +7 -12
  64. package/dist/hooks/use-color-mode.js +28 -25
  65. package/dist/hooks/use-mobile.js +13 -13
  66. package/dist/hooks/use-toast.js +2 -4
  67. package/dist/hooks/use-touch-device.js +9 -11
  68. package/dist/hooks/use-viewport-height.js +14 -14
  69. package/dist/motion/index.js +3 -11
  70. package/dist/motion/primitives-index.js +226 -186
  71. package/dist/shell/app-command-palette.js +203 -234
  72. package/dist/shell/bottom-navbar.js +150 -190
  73. package/dist/shell/command-registry.js +13 -14
  74. package/dist/shell/index.js +10 -20
  75. package/dist/shell/link-context.js +2 -5
  76. package/dist/shell/notification-center.js +238 -259
  77. package/dist/shell/notification-preferences.js +241 -184
  78. package/dist/shell/sidebar.js +251 -281
  79. package/dist/shell/top-bar.js +203 -237
  80. package/dist/tailwind/index.cjs +426 -451
  81. package/dist/tailwind/index.js +2 -4
  82. package/dist/tailwind/preset.d.ts.map +1 -1
  83. package/dist/tailwind/preset.js +443 -468
  84. package/dist/ui/accordion.js +52 -60
  85. package/dist/ui/alert-dialog.js +111 -156
  86. package/dist/ui/alert.js +177 -99
  87. package/dist/ui/aspect-ratio.js +13 -16
  88. package/dist/ui/autocomplete.js +112 -148
  89. package/dist/ui/avatar.js +196 -169
  90. package/dist/ui/badge-group.js +2 -7
  91. package/dist/ui/badge-indicator.js +42 -51
  92. package/dist/ui/badge.js +2 -15
  93. package/dist/ui/banner.js +76 -68
  94. package/dist/ui/breadcrumb.js +65 -84
  95. package/dist/ui/button-group.js +109 -102
  96. package/dist/ui/button-processing.js +69 -73
  97. package/dist/ui/button.js +393 -279
  98. package/dist/ui/card.js +151 -157
  99. package/dist/ui/charts/index.js +1002 -1319
  100. package/dist/ui/chat/index.js +2 -11
  101. package/dist/ui/checkbox.js +77 -100
  102. package/dist/ui/code.js +18 -32
  103. package/dist/ui/collapsible.js +21 -29
  104. package/dist/ui/color-input.js +453 -372
  105. package/dist/ui/color-swatch.js +60 -90
  106. package/dist/ui/combobox.js +244 -293
  107. package/dist/ui/container.js +18 -24
  108. package/dist/ui/context-menu.js +154 -203
  109. package/dist/ui/data-table-body.js +116 -213
  110. package/dist/ui/data-table-bulk-actions.js +43 -59
  111. package/dist/ui/data-table-card.js +84 -71
  112. package/dist/ui/data-table-context.js +39 -42
  113. package/dist/ui/data-table-header.js +98 -139
  114. package/dist/ui/data-table-pagination.js +69 -82
  115. package/dist/ui/data-table-toolbar.js +104 -130
  116. package/dist/ui/data-table.js +278 -354
  117. package/dist/ui/devalok-grain.js +77 -66
  118. package/dist/ui/dialog.js +122 -151
  119. package/dist/ui/dropdown-menu.js +152 -203
  120. package/dist/ui/file-upload.js +242 -266
  121. package/dist/ui/form.js +60 -56
  122. package/dist/ui/hover-card.js +54 -54
  123. package/dist/ui/icon-button.js +21 -26
  124. package/dist/ui/icon-context.js +17 -17
  125. package/dist/ui/icon-group.js +22 -29
  126. package/dist/ui/icon.js +201 -121
  127. package/dist/ui/index.js +74 -350
  128. package/dist/ui/input-otp.d.ts.map +1 -1
  129. package/dist/ui/input-otp.js +44 -48
  130. package/dist/ui/input.js +92 -169
  131. package/dist/ui/label.js +17 -22
  132. package/dist/ui/lib/date-utils.js +14 -11
  133. package/dist/ui/lib/motion.js +77 -36
  134. package/dist/ui/lib/utils.js +39 -16
  135. package/dist/ui/link.js +13 -24
  136. package/dist/ui/menubar.js +132 -210
  137. package/dist/ui/navigation-menu.js +164 -194
  138. package/dist/ui/number-input.js +72 -95
  139. package/dist/ui/pagination.js +122 -159
  140. package/dist/ui/popover.js +2 -131
  141. package/dist/ui/progress-ring.js +133 -143
  142. package/dist/ui/progress.js +51 -95
  143. package/dist/ui/radio.js +41 -50
  144. package/dist/ui/search-input.js +51 -53
  145. package/dist/ui/segmented-control.js +93 -114
  146. package/dist/ui/select.js +131 -157
  147. package/dist/ui/separator.js +15 -25
  148. package/dist/ui/sheet.js +135 -163
  149. package/dist/ui/sidebar.js +357 -600
  150. package/dist/ui/skeleton.js +179 -231
  151. package/dist/ui/slider.js +24 -34
  152. package/dist/ui/spinner.js +226 -205
  153. package/dist/ui/split-button.js +227 -276
  154. package/dist/ui/stack.js +56 -70
  155. package/dist/ui/stat-card.js +259 -251
  156. package/dist/ui/status-dot.js +67 -63
  157. package/dist/ui/stepper.js +119 -168
  158. package/dist/ui/switch.js +51 -54
  159. package/dist/ui/table.js +57 -90
  160. package/dist/ui/tabs.js +139 -156
  161. package/dist/ui/text.js +52 -59
  162. package/dist/ui/textarea.js +40 -57
  163. package/dist/ui/toast-types.js +0 -1
  164. package/dist/ui/toast.js +554 -536
  165. package/dist/ui/toaster.js +23 -33
  166. package/dist/ui/toggle-group.js +37 -41
  167. package/dist/ui/toggle.js +36 -40
  168. package/dist/ui/tooltip.js +80 -65
  169. package/dist/ui/tree-view/index.js +2 -6
  170. package/dist/ui/visually-hidden.js +12 -10
  171. package/llms-full.txt +1 -1
  172. package/llms.txt +12 -0
  173. package/package.json +3 -3
  174. package/dist/_chunks/date-time-picker.js +0 -851
  175. package/dist/_chunks/typing-indicator.js +0 -565
@@ -1,1330 +1,1013 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as p, Fragment as te } from "react/jsx-runtime";
3
- import * as ne from "react";
4
- import { useRef as ye, useState as me, useEffect as xe, useCallback as Re } from "react";
5
- import { cn as H } from "../lib/utils.js";
6
- import { scaleBand as Xe, scaleLinear as oe, scalePoint as Le } from "d3-scale";
7
- import { tweens as se, motionProps as ce } from "../lib/motion.js";
8
- import { axisLeft as De, axisBottom as Pe, axisRight as ze, axisTop as Be } from "d3-axis";
9
- import { select as Ve } from "d3-selection";
10
- import { u as _e } from "../../_chunks/motion-provider.js";
11
- import { m as re } from "../../_chunks/framer.js";
12
- import { line as he, curveMonotoneX as de, curveLinear as Ae, stack as je, stackOrderNone as Te, stackOffsetNone as Ye, area as Ne, pie as Oe, arc as ve, lineRadial as We, curveLinearClosed as Ie } from "d3-shape";
13
- const Fe = {
14
- top: 20,
15
- right: 20,
16
- bottom: 40,
17
- left: 50
18
- }, be = ne.forwardRef(
19
- ({
20
- height: t = 300,
21
- margin: a,
22
- className: o,
23
- ariaLabel: x = "Chart",
24
- children: d,
25
- ...M
26
- }, i) => {
27
- const k = ye(null), [G, P] = me(0), v = { ...Fe, ...a };
28
- xe(() => {
29
- if (!k.current) return;
30
- const B = new ResizeObserver((N) => {
31
- const z = N[0];
32
- z && P(z.contentRect.width);
33
- });
34
- return B.observe(k.current), () => B.disconnect();
35
- }, []);
36
- const R = Math.max(0, G - v.left - v.right), Z = Math.max(0, t - v.top - v.bottom);
37
- return /* @__PURE__ */ e(
38
- "div",
39
- {
40
- ref: (B) => {
41
- k.current = B, typeof i == "function" ? i(B) : i && (i.current = B);
42
- },
43
- className: H("relative w-full", o),
44
- ...M,
45
- children: G > 0 && /* @__PURE__ */ e("svg", { width: G, height: t, role: "img", "aria-label": x, children: /* @__PURE__ */ e("g", { transform: `translate(${v.left},${v.top})`, children: d({ width: R, height: Z, margin: v }) }) })
46
- }
47
- );
48
- }
49
- );
50
- be.displayName = "ChartContainer";
51
- function ee({
52
- scale: t,
53
- orientation: a,
54
- transform: o,
55
- tickCount: x,
56
- tickFormat: d,
57
- label: M,
58
- className: i
59
- }) {
60
- const k = ye(null);
61
- return xe(() => {
62
- if (!k.current) return;
63
- const P = {
64
- top: Be,
65
- right: ze,
66
- bottom: Pe,
67
- left: De
68
- }[a];
69
- let v = P(t);
70
- x && (v = v.ticks(x)), d && (v = v.tickFormat(d));
71
- const R = Ve(k.current);
72
- R.call(v), R.selectAll(".tick line").attr("stroke", "var(--color-surface-border)"), R.selectAll(".tick text").attr("fill", "var(--color-surface-fg-muted)").attr("font-size", "var(--font-size-xs)"), R.selectAll(".domain").attr("stroke", "var(--color-surface-border-strong)");
73
- }, [t, a, x, d]), /* @__PURE__ */ e("g", { ref: k, transform: o, className: i, children: M && /* @__PURE__ */ e(
74
- "text",
75
- {
76
- textAnchor: "middle",
77
- fill: "var(--color-surface-fg-muted)",
78
- fontSize: "var(--font-size-sm)",
79
- ...a === "bottom" ? { x: "50%", dy: 35 } : a === "left" ? { transform: "rotate(-90)", y: -40, x: 0 } : {},
80
- children: M
81
- }
82
- ) });
2
+ import { a as e } from "../../_chunks/framer.js";
3
+ import { motionProps as t, tweens as n } from "../lib/motion.js";
4
+ import { cn as r } from "../lib/utils.js";
5
+ import { n as i } from "../../_chunks/motion-provider.js";
6
+ import * as a from "react";
7
+ import { useCallback as o, useEffect as s, useRef as c, useState as l } from "react";
8
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
9
+ import { scaleBand as p, scaleLinear as m, scalePoint as h } from "d3-scale";
10
+ import { axisBottom as g, axisLeft as _, axisRight as v, axisTop as y } from "d3-axis";
11
+ import { select as b } from "d3-selection";
12
+ import { arc as x, area as S, curveLinear as C, curveLinearClosed as w, curveMonotoneX as T, line as E, lineRadial as D, pie as O, stack as k, stackOffsetNone as A, stackOrderNone as j } from "d3-shape";
13
+ //#region src/ui/charts/_internal/types.ts
14
+ var M = {
15
+ top: 20,
16
+ right: 20,
17
+ bottom: 40,
18
+ left: 50
19
+ }, N = a.forwardRef(({ height: e = 300, margin: t, className: n, ariaLabel: i = "Chart", children: a, ...o }, u) => {
20
+ let f = c(null), [p, m] = l(0), h = {
21
+ ...M,
22
+ ...t
23
+ };
24
+ s(() => {
25
+ if (!f.current) return;
26
+ let e = new ResizeObserver((e) => {
27
+ let t = e[0];
28
+ t && m(t.contentRect.width);
29
+ });
30
+ return e.observe(f.current), () => e.disconnect();
31
+ }, []);
32
+ let g = Math.max(0, p - h.left - h.right), _ = Math.max(0, e - h.top - h.bottom);
33
+ return /* @__PURE__ */ d("div", {
34
+ ref: (e) => {
35
+ f.current = e, typeof u == "function" ? u(e) : u && (u.current = e);
36
+ },
37
+ className: r("relative w-full", n),
38
+ ...o,
39
+ children: p > 0 && /* @__PURE__ */ d("svg", {
40
+ width: p,
41
+ height: e,
42
+ role: "img",
43
+ "aria-label": i,
44
+ children: /* @__PURE__ */ d("g", {
45
+ transform: `translate(${h.left},${h.top})`,
46
+ children: a({
47
+ width: g,
48
+ height: _,
49
+ margin: h
50
+ })
51
+ })
52
+ })
53
+ });
54
+ });
55
+ N.displayName = "ChartContainer";
56
+ //#endregion
57
+ //#region src/ui/charts/_internal/axes.tsx
58
+ function P({ scale: e, orientation: t, transform: n, tickCount: r, tickFormat: i, label: a, className: o }) {
59
+ let l = c(null);
60
+ return s(() => {
61
+ if (!l.current) return;
62
+ let n = {
63
+ top: y,
64
+ right: v,
65
+ bottom: g,
66
+ left: _
67
+ }[t], a = n(e);
68
+ r && (a = a.ticks(r)), i && (a = a.tickFormat(i));
69
+ let o = b(l.current);
70
+ o.call(a), o.selectAll(".tick line").attr("stroke", "var(--color-surface-border)"), o.selectAll(".tick text").attr("fill", "var(--color-surface-fg-muted)").attr("font-size", "var(--font-size-xs)"), o.selectAll(".domain").attr("stroke", "var(--color-surface-border-strong)");
71
+ }, [
72
+ e,
73
+ t,
74
+ r,
75
+ i
76
+ ]), /* @__PURE__ */ d("g", {
77
+ ref: l,
78
+ transform: n,
79
+ className: o,
80
+ children: a && /* @__PURE__ */ d("text", {
81
+ textAnchor: "middle",
82
+ fill: "var(--color-surface-fg-muted)",
83
+ fontSize: "var(--font-size-sm)",
84
+ ...t === "bottom" ? {
85
+ x: "50%",
86
+ dy: 35
87
+ } : t === "left" ? {
88
+ transform: "rotate(-90)",
89
+ y: -40,
90
+ x: 0
91
+ } : {},
92
+ children: a
93
+ })
94
+ });
83
95
  }
84
- ee.displayName = "Axis";
85
- function fe({
86
- width: t,
87
- height: a,
88
- xScale: o,
89
- yScale: x,
90
- horizontal: d = !0,
91
- vertical: M = !1
92
- }) {
93
- return /* @__PURE__ */ p("g", { className: "grid-lines", children: [
94
- d && x?.ticks && x.ticks().map((i, k) => /* @__PURE__ */ e(
95
- "line",
96
- {
97
- x1: 0,
98
- x2: t,
99
- y1: x(i),
100
- y2: x(i),
101
- stroke: "var(--color-surface-border)",
102
- strokeDasharray: "3,3",
103
- opacity: 0.6
104
- },
105
- `h-${k}`
106
- )),
107
- M && o?.ticks && o.ticks().map((i, k) => /* @__PURE__ */ e(
108
- "line",
109
- {
110
- x1: o(i),
111
- x2: o(i),
112
- y1: 0,
113
- y2: a,
114
- stroke: "var(--color-surface-border)",
115
- strokeDasharray: "3,3",
116
- opacity: 0.6
117
- },
118
- `v-${k}`
119
- ))
120
- ] });
96
+ P.displayName = "Axis";
97
+ //#endregion
98
+ //#region src/ui/charts/_internal/grid-lines.tsx
99
+ function F({ width: e, height: t, xScale: n, yScale: r, horizontal: i = !0, vertical: a = !1 }) {
100
+ return /* @__PURE__ */ f("g", {
101
+ className: "grid-lines",
102
+ children: [i && r?.ticks && r.ticks().map((t, n) => /* @__PURE__ */ d("line", {
103
+ x1: 0,
104
+ x2: e,
105
+ y1: r(t),
106
+ y2: r(t),
107
+ stroke: "var(--color-surface-border)",
108
+ strokeDasharray: "3,3",
109
+ opacity: .6
110
+ }, `h-${n}`)), a && n?.ticks && n.ticks().map((e, r) => /* @__PURE__ */ d("line", {
111
+ x1: n(e),
112
+ x2: n(e),
113
+ y1: 0,
114
+ y2: t,
115
+ stroke: "var(--color-surface-border)",
116
+ strokeDasharray: "3,3",
117
+ opacity: .6
118
+ }, `v-${r}`))]
119
+ });
121
120
  }
122
- fe.displayName = "GridLines";
123
- function ie({ items: t, position: a = "bottom", className: o }) {
124
- return /* @__PURE__ */ e(
125
- "div",
126
- {
127
- className: H(
128
- "flex gap-ds-04 text-ds-sm text-surface-fg-muted",
129
- a === "left" || a === "right" ? "flex-col" : "flex-row flex-wrap justify-center",
130
- o
131
- ),
132
- children: t.map((d) => /* @__PURE__ */ p("div", { className: "flex items-center gap-ds-02", children: [
133
- /* @__PURE__ */ e(
134
- "span",
135
- {
136
- className: "inline-block h-3 w-3 shrink-0 rounded-ds-sm",
137
- style: { backgroundColor: d.color }
138
- }
139
- ),
140
- /* @__PURE__ */ e("span", { children: d.label })
141
- ] }, d.label))
142
- }
143
- );
121
+ F.displayName = "GridLines";
122
+ //#endregion
123
+ //#region src/ui/charts/_internal/legend.tsx
124
+ function I({ items: e, position: t = "bottom", className: n }) {
125
+ return /* @__PURE__ */ d("div", {
126
+ className: r("flex gap-ds-04 text-ds-sm text-surface-fg-muted", t === "left" || t === "right" ? "flex-col" : "flex-row flex-wrap justify-center", n),
127
+ children: e.map((e) => /* @__PURE__ */ f("div", {
128
+ className: "flex items-center gap-ds-02",
129
+ children: [/* @__PURE__ */ d("span", {
130
+ className: "inline-block h-3 w-3 shrink-0 rounded-ds-sm",
131
+ style: { backgroundColor: e.color }
132
+ }), /* @__PURE__ */ d("span", { children: e.label })]
133
+ }, e.label))
134
+ });
144
135
  }
145
- ie.displayName = "Legend";
146
- function ue({ state: t, className: a }) {
147
- return t.visible ? /* @__PURE__ */ e(
148
- "div",
149
- {
150
- className: H(
151
- "pointer-events-none absolute z-tooltip",
152
- "rounded-ds-md border border-surface-border-strong",
153
- "bg-surface-overlay px-ds-03 py-ds-02",
154
- "shadow-raised-hover",
155
- "text-ds-sm text-surface-fg",
156
- a
157
- ),
158
- style: { left: t.x + 12, top: t.y - 12 },
159
- children: t.content
160
- }
161
- ) : null;
136
+ I.displayName = "Legend";
137
+ //#endregion
138
+ //#region src/ui/charts/_internal/tooltip.tsx
139
+ function L({ state: e, className: t }) {
140
+ return e.visible ? /* @__PURE__ */ d("div", {
141
+ className: r("pointer-events-none absolute z-tooltip", "rounded-ds-md border border-surface-border-strong", "bg-surface-overlay px-ds-03 py-ds-02", "shadow-raised-hover", "text-ds-sm text-surface-fg", t),
142
+ style: {
143
+ left: e.x + 12,
144
+ top: e.y - 12
145
+ },
146
+ children: e.content
147
+ }) : null;
162
148
  }
163
- ue.displayName = "ChartTooltip";
164
- function pe() {
165
- const [t, a] = me({
166
- visible: !1,
167
- x: 0,
168
- y: 0,
169
- content: null
170
- }), o = Re((d, M, i) => {
171
- a({ visible: !0, x: d, y: M, content: i });
172
- }, []), x = Re(() => {
173
- a((d) => ({ ...d, visible: !1 }));
174
- }, []);
175
- return { tooltip: t, show: o, hide: x };
149
+ L.displayName = "ChartTooltip";
150
+ function R() {
151
+ let [e, t] = l({
152
+ visible: !1,
153
+ x: 0,
154
+ y: 0,
155
+ content: null
156
+ });
157
+ return {
158
+ tooltip: e,
159
+ show: o((e, n, r) => {
160
+ t({
161
+ visible: !0,
162
+ x: e,
163
+ y: n,
164
+ content: r
165
+ });
166
+ }, []),
167
+ hide: o(() => {
168
+ t((e) => ({
169
+ ...e,
170
+ visible: !1
171
+ }));
172
+ }, [])
173
+ };
176
174
  }
177
- const Me = [
178
- "chart-1",
179
- "chart-2",
180
- "chart-3",
181
- "chart-4",
182
- "chart-5",
183
- "chart-6",
184
- "chart-7",
185
- "chart-8"
175
+ //#endregion
176
+ //#region src/ui/charts/_internal/colors.ts
177
+ var z = [
178
+ "chart-1",
179
+ "chart-2",
180
+ "chart-3",
181
+ "chart-4",
182
+ "chart-5",
183
+ "chart-6",
184
+ "chart-7",
185
+ "chart-8"
186
186
  ];
187
- function $e(t) {
188
- return `var(--${t})`;
187
+ function B(e) {
188
+ return `var(--${e})`;
189
189
  }
190
- function ae(t, a = 0) {
191
- return t ? Me.includes(t) ? $e(t) : t : $e(Me[a % Me.length]);
190
+ function V(e, t = 0) {
191
+ return e ? z.includes(e) ? B(e) : e : B(z[t % z.length]);
192
192
  }
193
- function le() {
194
- const { reducedMotion: t } = _e();
195
- return t;
193
+ //#endregion
194
+ //#region src/ui/charts/_internal/animation.ts
195
+ function H() {
196
+ let { reducedMotion: e } = i();
197
+ return e;
196
198
  }
197
- function Ee(t, a = 300) {
198
- return t ? 0 : a;
199
+ function U(e, t = 300) {
200
+ return e ? 0 : t;
199
201
  }
200
- const Ue = ne.forwardRef(
201
- ({
202
- data: t,
203
- xKey: a,
204
- yKey: o,
205
- orientation: x = "vertical",
206
- stacked: d = !1,
207
- grouped: M = !1,
208
- color: i,
209
- height: k = 300,
210
- showGrid: G = !0,
211
- showTooltip: P = !0,
212
- showLegend: v = !1,
213
- animate: R = !0,
214
- barRadius: Z = 4,
215
- xLabel: B,
216
- yLabel: N,
217
- seriesLabels: z,
218
- ariaLabel: X,
219
- className: W,
220
- ...q
221
- }, j) => {
222
- const { tooltip: T, show: V, hide: J } = pe(), E = le(), m = x === "vertical", S = R && !E, y = Array.isArray(o) ? o : [o], c = y.length > 1, I = c ? y.map(
223
- (C, L) => ae(
224
- Array.isArray(i) ? i[L] : typeof i == "string" ? i : void 0,
225
- L
226
- )
227
- ) : [
228
- ae(
229
- typeof i == "string" ? i : Array.isArray(i) ? i[0] : void 0,
230
- 0
231
- )
232
- ];
233
- return /* @__PURE__ */ p(
234
- re.div,
235
- {
236
- ref: j,
237
- className: H("relative", W),
238
- ...S ? { initial: { opacity: 0, scale: 0.96 }, animate: { opacity: 1, scale: 1 }, transition: se.fade } : {},
239
- ...ce(q),
240
- children: [
241
- /* @__PURE__ */ e(be, { height: k, ariaLabel: X ?? "Bar chart", children: ({ width: C, height: L, margin: u }) => {
242
- const l = t.map((A) => String(A[a]));
243
- let s;
244
- d ? s = Math.max(
245
- ...t.map(
246
- (A) => y.reduce((w, $) => w + (Number(A[$]) || 0), 0)
247
- )
248
- ) : s = Math.max(
249
- ...t.flatMap((A) => y.map((w) => Number(A[w]) || 0))
250
- );
251
- const b = Xe().domain(l).range(m ? [0, C] : [0, L]).padding(0.2), n = oe().domain([0, s * 1.1]).range(m ? [L, 0] : [0, C]).nice(), r = b.bandwidth(), f = c && M ? r / y.length : r;
252
- return /* @__PURE__ */ p(te, { children: [
253
- G && /* @__PURE__ */ e(
254
- fe,
255
- {
256
- width: C,
257
- height: L,
258
- yScale: m ? n : void 0,
259
- xScale: m ? void 0 : n,
260
- horizontal: m,
261
- vertical: !m
262
- }
263
- ),
264
- t.map((A) => {
265
- const w = String(A[a]);
266
- let $ = 0;
267
- return y.map((Q, h) => {
268
- const g = Number(A[Q]) || 0, _ = I[h] || I[0];
269
- let Y, F, K, D;
270
- return m ? (Y = (b(w) ?? 0) + (M && c ? h * f : 0), F = n(d ? $ + g : g), K = f, D = d ? n($) - n($ + g) : L - n(g)) : (Y = d ? n($) : 0, F = (b(w) ?? 0) + (M && c ? h * f : 0), K = d ? n($ + g) - n($) : n(g), D = f), d && ($ += g), /* @__PURE__ */ e(
271
- "rect",
272
- {
273
- x: Y,
274
- y: F,
275
- width: Math.max(0, K),
276
- height: Math.max(0, D),
277
- rx: Z,
278
- fill: _,
279
- className: "transition-opacity hover:opacity-80",
280
- onMouseMove: (U) => {
281
- if (P) {
282
- const O = U.currentTarget.closest("div")?.getBoundingClientRect();
283
- V(
284
- U.clientX - (O?.left ?? 0),
285
- U.clientY - (O?.top ?? 0),
286
- /* @__PURE__ */ p("div", { children: [
287
- /* @__PURE__ */ e("div", { className: "font-medium", children: w }),
288
- c && /* @__PURE__ */ e("div", { className: "text-surface-fg-muted", children: z?.[h] ?? Q }),
289
- /* @__PURE__ */ e("div", { children: g.toLocaleString() })
290
- ] })
291
- );
292
- }
293
- },
294
- onMouseLeave: J
295
- },
296
- `${w}-${Q}`
297
- );
298
- });
299
- }),
300
- m ? /* @__PURE__ */ p(te, { children: [
301
- /* @__PURE__ */ e(
302
- ee,
303
- {
304
- scale: b,
305
- orientation: "bottom",
306
- transform: `translate(0,${L})`,
307
- label: B
308
- }
309
- ),
310
- /* @__PURE__ */ e(ee, { scale: n, orientation: "left", label: N })
311
- ] }) : /* @__PURE__ */ p(te, { children: [
312
- /* @__PURE__ */ e(
313
- ee,
314
- {
315
- scale: n,
316
- orientation: "bottom",
317
- transform: `translate(0,${L})`,
318
- label: B
319
- }
320
- ),
321
- /* @__PURE__ */ e(
322
- ee,
323
- {
324
- scale: b,
325
- orientation: "left",
326
- label: N
327
- }
328
- )
329
- ] })
330
- ] });
331
- } }),
332
- P && /* @__PURE__ */ e(ue, { state: T }),
333
- v && c && /* @__PURE__ */ e(
334
- ie,
335
- {
336
- items: y.map((C, L) => ({
337
- label: z?.[L] ?? C,
338
- color: I[L]
339
- })),
340
- className: "mt-ds-04"
341
- }
342
- )
343
- ]
344
- }
345
- );
346
- }
347
- );
348
- Ue.displayName = "BarChart";
349
- const Ze = ne.forwardRef(
350
- ({
351
- data: t,
352
- xKey: a,
353
- series: o,
354
- curved: x = !1,
355
- showDots: d = !1,
356
- dotSize: M = 4,
357
- strokeWidth: i = 2,
358
- height: k = 300,
359
- showGrid: G = !0,
360
- showTooltip: P = !0,
361
- showLegend: v = !1,
362
- animate: R = !0,
363
- xLabel: Z,
364
- yLabel: B,
365
- ariaLabel: N,
366
- className: z,
367
- ...X
368
- }, W) => {
369
- const { tooltip: q, show: j, hide: T } = pe(), V = le(), J = R && !V, E = o.map((m, S) => ae(m.color, S));
370
- return /* @__PURE__ */ p(
371
- re.div,
372
- {
373
- ref: W,
374
- className: H("relative", z),
375
- ...J ? { initial: { opacity: 0, scale: 0.96 }, animate: { opacity: 1, scale: 1 }, transition: se.fade } : {},
376
- ...ce(X),
377
- children: [
378
- /* @__PURE__ */ e(be, { height: k, ariaLabel: N ?? "Line chart", children: ({ width: m, height: S, margin: y }) => {
379
- const c = t.map((r) => r[a]), I = c.every((r) => typeof r == "number");
380
- let C, L;
381
- if (I) {
382
- const r = c, f = Math.min(...r), A = Math.max(...r), w = oe().domain([f, A]).range([0, m]);
383
- C = w, L = ($) => w(Number($[a]));
384
- } else {
385
- const r = c.map(String), f = Le().domain(r).range([0, m]).padding(0.5);
386
- C = f, L = (A) => f(String(A[a])) ?? 0;
387
- }
388
- const u = t.flatMap(
389
- (r) => o.map((f) => Number(r[f.key]) || 0)
390
- ), l = Math.max(...u), s = oe().domain([0, l * 1.1]).range([S, 0]).nice(), b = x ? de : Ae, n = he().curve(b).defined((r) => r != null);
391
- return /* @__PURE__ */ p(te, { children: [
392
- G && /* @__PURE__ */ e(
393
- fe,
394
- {
395
- width: m,
396
- height: S,
397
- yScale: s,
398
- horizontal: !0
399
- }
400
- ),
401
- o.map((r, f) => {
402
- const w = n.x(($) => L($)).y(($) => s(Number($[r.key]) || 0))(t) ?? "";
403
- return /* @__PURE__ */ p("g", { children: [
404
- /* @__PURE__ */ e(
405
- "path",
406
- {
407
- d: w,
408
- fill: "none",
409
- stroke: E[f],
410
- strokeWidth: i,
411
- strokeLinejoin: "round",
412
- strokeLinecap: "round"
413
- }
414
- ),
415
- d && t.map(($, Q) => {
416
- const h = L($), g = s(Number($[r.key]) || 0);
417
- return /* @__PURE__ */ e(
418
- "circle",
419
- {
420
- cx: h,
421
- cy: g,
422
- r: M,
423
- fill: E[f],
424
- className: "transition-opacity hover:opacity-80"
425
- },
426
- `${r.key}-dot-${Q}`
427
- );
428
- })
429
- ] }, r.key);
430
- }),
431
- P && t.map((r, f) => {
432
- const A = L(r), w = m / Math.max(t.length - 1, 1);
433
- return /* @__PURE__ */ e(
434
- "rect",
435
- {
436
- x: A - w / 2,
437
- y: 0,
438
- width: w,
439
- height: S,
440
- fill: "transparent",
441
- onMouseMove: ($) => {
442
- const Q = $.currentTarget.closest("div")?.getBoundingClientRect();
443
- j(
444
- $.clientX - (Q?.left ?? 0),
445
- $.clientY - (Q?.top ?? 0),
446
- /* @__PURE__ */ p("div", { children: [
447
- /* @__PURE__ */ e("div", { className: "font-medium", children: String(r[a]) }),
448
- o.map((h, g) => /* @__PURE__ */ p(
449
- "div",
450
- {
451
- className: "flex items-center gap-ds-02",
452
- children: [
453
- /* @__PURE__ */ e(
454
- "span",
455
- {
456
- className: "inline-block h-2 w-2 rounded-ds-full",
457
- style: { backgroundColor: E[g] }
458
- }
459
- ),
460
- /* @__PURE__ */ p("span", { className: "text-surface-fg-muted", children: [
461
- h.label,
462
- ":"
463
- ] }),
464
- " ",
465
- Number(r[h.key]).toLocaleString()
466
- ]
467
- },
468
- h.key
469
- ))
470
- ] })
471
- );
472
- },
473
- onMouseLeave: T
474
- },
475
- `hover-${f}`
476
- );
477
- }),
478
- /* @__PURE__ */ e(
479
- ee,
480
- {
481
- scale: C,
482
- orientation: "bottom",
483
- transform: `translate(0,${S})`,
484
- label: Z
485
- }
486
- ),
487
- /* @__PURE__ */ e(ee, { scale: s, orientation: "left", label: B })
488
- ] });
489
- } }),
490
- P && /* @__PURE__ */ e(ue, { state: q }),
491
- v && o.length > 1 && /* @__PURE__ */ e(
492
- ie,
493
- {
494
- items: o.map((m, S) => ({
495
- label: m.label,
496
- color: E[S]
497
- })),
498
- className: "mt-ds-04"
499
- }
500
- )
501
- ]
502
- }
503
- );
504
- }
505
- );
506
- Ze.displayName = "LineChart";
507
- const qe = ne.forwardRef(
508
- ({
509
- data: t,
510
- xKey: a,
511
- series: o,
512
- curved: x = !1,
513
- stacked: d = !1,
514
- fillOpacity: M = 0.3,
515
- gradient: i = !1,
516
- strokeWidth: k = 2,
517
- height: G = 300,
518
- showGrid: P = !0,
519
- showTooltip: v = !0,
520
- showLegend: R = !1,
521
- animate: Z = !0,
522
- xLabel: B,
523
- yLabel: N,
524
- ariaLabel: z,
525
- className: X,
526
- ...W
527
- }, q) => {
528
- const { tooltip: j, show: T, hide: V } = pe(), J = le(), E = Z && !J, m = o.map((y, c) => ae(y.color, c)), S = ne.useId();
529
- return /* @__PURE__ */ p(
530
- re.div,
531
- {
532
- ref: q,
533
- className: H("relative", X),
534
- ...E ? { initial: { opacity: 0, scale: 0.96 }, animate: { opacity: 1, scale: 1 }, transition: se.fade } : {},
535
- ...ce(W),
536
- children: [
537
- /* @__PURE__ */ e(be, { height: G, ariaLabel: z ?? "Area chart", children: ({ width: y, height: c, margin: I }) => {
538
- const C = t.map((h) => h[a]), L = C.every((h) => typeof h == "number");
539
- let u, l, s;
540
- if (L) {
541
- const h = C, g = Math.min(...h), _ = Math.max(...h), Y = oe().domain([g, _]).range([0, y]);
542
- u = Y, l = (F) => Y(Number(F[a])), s = (F) => Y(Number(t[F][a]));
543
- } else {
544
- const h = C.map(String), g = Le().domain(h).range([0, y]).padding(0.5);
545
- u = g, l = (_) => g(String(_[a])) ?? 0, s = (_) => g(String(t[_][a])) ?? 0;
546
- }
547
- let b;
548
- d ? b = Math.max(
549
- ...t.map(
550
- (h) => o.reduce((g, _) => g + (Number(h[_.key]) || 0), 0)
551
- )
552
- ) : b = Math.max(
553
- ...t.flatMap(
554
- (h) => o.map((g) => Number(h[g.key]) || 0)
555
- )
556
- );
557
- const n = oe().domain([0, b * 1.1]).range([c, 0]).nice(), r = x ? de : Ae, f = () => t.map((h, g) => {
558
- const _ = l(h), Y = y / Math.max(t.length - 1, 1);
559
- return /* @__PURE__ */ e(
560
- "rect",
561
- {
562
- x: _ - Y / 2,
563
- y: 0,
564
- width: Y,
565
- height: c,
566
- fill: "transparent",
567
- onMouseMove: (F) => {
568
- const K = F.currentTarget.closest("div")?.getBoundingClientRect();
569
- T(
570
- F.clientX - (K?.left ?? 0),
571
- F.clientY - (K?.top ?? 0),
572
- /* @__PURE__ */ p("div", { children: [
573
- /* @__PURE__ */ e("div", { className: "font-medium", children: String(h[a]) }),
574
- o.map((D, U) => /* @__PURE__ */ p(
575
- "div",
576
- {
577
- className: "flex items-center gap-ds-02",
578
- children: [
579
- /* @__PURE__ */ e(
580
- "span",
581
- {
582
- className: "inline-block h-2 w-2 rounded-ds-full",
583
- style: { backgroundColor: m[U] }
584
- }
585
- ),
586
- /* @__PURE__ */ p("span", { className: "text-surface-fg-muted", children: [
587
- D.label,
588
- ":"
589
- ] }),
590
- " ",
591
- Number(h[D.key]).toLocaleString()
592
- ]
593
- },
594
- D.key
595
- ))
596
- ] })
597
- );
598
- },
599
- onMouseLeave: V
600
- },
601
- `hover-${g}`
602
- );
603
- }), A = () => i ? /* @__PURE__ */ e("defs", { children: o.map((h, g) => /* @__PURE__ */ p(
604
- "linearGradient",
605
- {
606
- id: `${S}-gradient-${g}`,
607
- x1: "0",
608
- y1: "0",
609
- x2: "0",
610
- y2: "1",
611
- children: [
612
- /* @__PURE__ */ e(
613
- "stop",
614
- {
615
- offset: "0%",
616
- stopColor: m[g],
617
- stopOpacity: M
618
- }
619
- ),
620
- /* @__PURE__ */ e(
621
- "stop",
622
- {
623
- offset: "100%",
624
- stopColor: m[g],
625
- stopOpacity: 0.05
626
- }
627
- )
628
- ]
629
- },
630
- `grad-${g}`
631
- )) }) : null, w = () => /* @__PURE__ */ p(te, { children: [
632
- /* @__PURE__ */ e(
633
- ee,
634
- {
635
- scale: u,
636
- orientation: "bottom",
637
- transform: `translate(0,${c})`,
638
- label: B
639
- }
640
- ),
641
- /* @__PURE__ */ e(ee, { scale: n, orientation: "left", label: N })
642
- ] });
643
- if (d) {
644
- const h = o.map((D) => D.key), g = je().keys(h).order(Te).offset(Ye), _ = t.map((D) => {
645
- const U = { [a]: String(D[a]) };
646
- for (const O of o)
647
- U[O.key] = Number(D[O.key]) || 0;
648
- return U;
649
- }), Y = g(_), F = Ne().curve(r).x((D, U) => s(U)).y0((D) => n(D[0])).y1((D) => n(D[1])), K = he().curve(r).x((D, U) => s(U)).y((D) => n(D[1]));
650
- return /* @__PURE__ */ p(te, { children: [
651
- A(),
652
- P && /* @__PURE__ */ e(
653
- fe,
654
- {
655
- width: y,
656
- height: c,
657
- yScale: n,
658
- horizontal: !0
659
- }
660
- ),
661
- [...Y].reverse().map((D, U) => {
662
- const O = Y.length - 1 - U, ke = D, Se = F(ke) ?? "", we = K(ke) ?? "", Ge = i ? `url(#${S}-gradient-${O})` : m[O];
663
- return /* @__PURE__ */ p("g", { children: [
664
- /* @__PURE__ */ e(
665
- "path",
666
- {
667
- d: Se,
668
- fill: Ge,
669
- opacity: i ? 1 : M
670
- }
671
- ),
672
- /* @__PURE__ */ e(
673
- "path",
674
- {
675
- d: we,
676
- fill: "none",
677
- stroke: m[O],
678
- strokeWidth: k,
679
- strokeLinejoin: "round",
680
- strokeLinecap: "round"
681
- }
682
- )
683
- ] }, o[O].key);
684
- }),
685
- v && f(),
686
- w()
687
- ] });
688
- }
689
- const $ = Ne().curve(r).defined((h) => h != null), Q = he().curve(r).defined((h) => h != null);
690
- return /* @__PURE__ */ p(te, { children: [
691
- A(),
692
- P && /* @__PURE__ */ e(
693
- fe,
694
- {
695
- width: y,
696
- height: c,
697
- yScale: n,
698
- horizontal: !0
699
- }
700
- ),
701
- [...o].reverse().map((h, g) => {
702
- const _ = o.length - 1 - g, Y = $.x((O) => l(O)).y0(c).y1((O) => n(Number(O[h.key]) || 0)), F = Q.x((O) => l(O)).y((O) => n(Number(O[h.key]) || 0)), K = Y(t) ?? "", D = F(t) ?? "", U = i ? `url(#${S}-gradient-${_})` : m[_];
703
- return /* @__PURE__ */ p("g", { children: [
704
- /* @__PURE__ */ e(
705
- "path",
706
- {
707
- d: K,
708
- fill: U,
709
- opacity: i ? 1 : M
710
- }
711
- ),
712
- /* @__PURE__ */ e(
713
- "path",
714
- {
715
- d: D,
716
- fill: "none",
717
- stroke: m[_],
718
- strokeWidth: k,
719
- strokeLinejoin: "round",
720
- strokeLinecap: "round"
721
- }
722
- )
723
- ] }, h.key);
724
- }),
725
- v && f(),
726
- w()
727
- ] });
728
- } }),
729
- v && /* @__PURE__ */ e(ue, { state: j }),
730
- R && o.length > 1 && /* @__PURE__ */ e(
731
- ie,
732
- {
733
- items: o.map((y, c) => ({
734
- label: y.label,
735
- color: m[c]
736
- })),
737
- className: "mt-ds-04"
738
- }
739
- )
740
- ]
741
- }
742
- );
743
- }
744
- );
745
- qe.displayName = "AreaChart";
746
- const Je = ne.forwardRef(
747
- ({
748
- data: t,
749
- variant: a = "pie",
750
- innerRadius: o = 0.6,
751
- padAngle: x = 0,
752
- cornerRadius: d = 0,
753
- height: M = 300,
754
- showTooltip: i = !0,
755
- showLegend: k = !1,
756
- showLabels: G = !1,
757
- animate: P = !0,
758
- className: v,
759
- centerLabel: R,
760
- ariaLabel: Z,
761
- ...B
762
- }, N) => {
763
- const z = ye(null), [X, W] = me(0), [q, j] = me(null), { tooltip: T, show: V, hide: J } = pe(), E = le(), m = P && !E;
764
- xe(() => {
765
- if (!z.current) return;
766
- const n = new ResizeObserver((r) => {
767
- const f = r[0];
768
- f && W(f.contentRect.width);
769
- });
770
- return n.observe(z.current), () => n.disconnect();
771
- }, []);
772
- const y = (X > 0 ? Math.min(X, M) : M) / 2, c = a === "donut" ? y * o : 0, I = t.map((n, r) => ae(n.color, r)), C = t.reduce((n, r) => n + r.value, 0), u = Oe().value((n) => n.value).padAngle(x).sort(null)(t), l = ve().innerRadius(c).outerRadius(y - 2).cornerRadius(d), s = c + (y - 2 - c) * 0.7, b = ve().innerRadius(s).outerRadius(s);
773
- return /* @__PURE__ */ p(
774
- re.div,
775
- {
776
- ref: (n) => {
777
- z.current = n, typeof N == "function" ? N(n) : N && (N.current = n);
778
- },
779
- className: H("relative w-full", v),
780
- ...m ? { initial: { opacity: 0, scale: 0.96 }, animate: { opacity: 1, scale: 1 }, transition: se.fade } : {},
781
- ...ce(B),
782
- children: [
783
- X > 0 && /* @__PURE__ */ p(te, { children: [
784
- /* @__PURE__ */ e(
785
- "svg",
786
- {
787
- width: X,
788
- height: M,
789
- role: "img",
790
- "aria-label": Z ?? "Pie chart",
791
- children: /* @__PURE__ */ p("g", { transform: `translate(${X / 2},${M / 2})`, children: [
792
- u.map((n, r) => {
793
- const f = l(n);
794
- if (!f) return null;
795
- const [A, w] = l.centroid(n), $ = Math.atan2(w, A), Q = Math.cos($) * 4, h = Math.sin($) * 4, g = q === r;
796
- return /* @__PURE__ */ e(
797
- "path",
798
- {
799
- d: f,
800
- fill: I[r],
801
- className: "cursor-pointer transition-transform",
802
- style: {
803
- transform: g ? `translate(${Q}px, ${h}px)` : void 0
804
- },
805
- onMouseEnter: () => j(r),
806
- onMouseMove: (_) => {
807
- if (i) {
808
- const Y = _.currentTarget.closest("div")?.getBoundingClientRect(), F = C > 0 ? (n.data.value / C * 100).toFixed(1) : "0";
809
- V(
810
- _.clientX - (Y?.left ?? 0),
811
- _.clientY - (Y?.top ?? 0),
812
- /* @__PURE__ */ p("div", { children: [
813
- /* @__PURE__ */ e("div", { className: "font-medium", children: n.data.label }),
814
- /* @__PURE__ */ p("div", { children: [
815
- n.data.value.toLocaleString(),
816
- " (",
817
- F,
818
- "%)"
819
- ] })
820
- ] })
821
- );
822
- }
823
- },
824
- onMouseLeave: () => {
825
- j(null), J();
826
- }
827
- },
828
- `slice-${n.data.label}-${r}`
829
- );
830
- }),
831
- G && u.map((n, r) => {
832
- const [f, A] = b.centroid(n), w = C > 0 ? (n.data.value / C * 100).toFixed(0) : "0";
833
- return C > 0 && n.data.value / C < 0.03 ? null : /* @__PURE__ */ p(
834
- "text",
835
- {
836
- x: f,
837
- y: A,
838
- textAnchor: "middle",
839
- dominantBaseline: "central",
840
- className: "pointer-events-none fill-accent-fg text-ds-xs font-medium",
841
- children: [
842
- w,
843
- "%"
844
- ]
845
- },
846
- `label-${n.data.label}-${r}`
847
- );
848
- }),
849
- a === "donut" && R && c > 0 && /* @__PURE__ */ e(
850
- "foreignObject",
851
- {
852
- x: -c * 0.7,
853
- y: -c * 0.7,
854
- width: c * 1.4,
855
- height: c * 1.4,
856
- children: /* @__PURE__ */ e("div", { className: "flex h-full w-full items-center justify-center text-center text-surface-fg", children: R })
857
- }
858
- )
859
- ] })
860
- }
861
- ),
862
- i && /* @__PURE__ */ e(ue, { state: T })
863
- ] }),
864
- k && /* @__PURE__ */ e(
865
- ie,
866
- {
867
- items: t.map((n, r) => ({
868
- label: n.label,
869
- color: I[r]
870
- })),
871
- className: "mt-ds-04"
872
- }
873
- )
874
- ]
875
- }
876
- );
877
- }
878
- );
879
- Je.displayName = "PieChart";
880
- const Ce = { duration: 1, ease: "easeOut" }, Qe = ne.forwardRef(
881
- ({
882
- data: t,
883
- variant: a = "line",
884
- width: o = 120,
885
- height: x = 32,
886
- color: d,
887
- showLastDot: M = !1,
888
- strokeWidth: i = 1.5,
889
- animate: k = !0,
890
- className: G,
891
- ...P
892
- }, v) => {
893
- const R = ae(d, 0), Z = le(), B = k && !Z;
894
- if (!t.length) return null;
895
- const N = a === "bar" ? 1 : i, z = o - N * 2, X = x - N * 2, W = oe().domain([0, Math.max(t.length - 1, 1)]).range([N, N + z]), q = Math.min(...t), j = Math.max(...t), T = q === j ? [q - 1, j + 1] : [q, j], V = oe().domain(T).range([N + X, N]);
896
- if (a === "bar") {
897
- const c = Math.max(
898
- 1,
899
- (z - 1 * (t.length - 1)) / t.length
900
- ), I = N + X;
901
- return /* @__PURE__ */ e(
902
- "svg",
903
- {
904
- ref: v,
905
- width: o,
906
- height: x,
907
- role: "img",
908
- "aria-label": "Sparkline bar chart",
909
- className: H("inline-block align-middle", G),
910
- ...P,
911
- children: t.map((C, L) => {
912
- const u = N + L * (c + 1), l = V(C), s = Math.max(1, I - l);
913
- return /* @__PURE__ */ e(
914
- "rect",
915
- {
916
- x: u,
917
- y: l,
918
- width: c,
919
- height: s,
920
- rx: Math.min(1, c / 2),
921
- fill: R
922
- },
923
- L
924
- );
925
- })
926
- }
927
- );
928
- }
929
- if (a === "area") {
930
- const y = Ne().curve(de).x((l, s) => W(s)).y0(N + X).y1((l) => V(l)), c = he().curve(de).x((l, s) => W(s)).y((l) => V(l)), I = y(t) ?? "", C = c(t) ?? "", L = W(t.length - 1), u = V(t[t.length - 1]);
931
- return /* @__PURE__ */ p(
932
- "svg",
933
- {
934
- ref: v,
935
- width: o,
936
- height: x,
937
- role: "img",
938
- "aria-label": "Sparkline area chart",
939
- className: H("inline-block align-middle", G),
940
- ...P,
941
- children: [
942
- /* @__PURE__ */ e("path", { d: I, fill: R, opacity: 0.2 }),
943
- B ? /* @__PURE__ */ e(
944
- re.path,
945
- {
946
- d: C,
947
- fill: "none",
948
- stroke: R,
949
- strokeWidth: i,
950
- strokeLinejoin: "round",
951
- strokeLinecap: "round",
952
- initial: { pathLength: 0 },
953
- animate: { pathLength: 1 },
954
- transition: Ce
955
- }
956
- ) : /* @__PURE__ */ e(
957
- "path",
958
- {
959
- d: C,
960
- fill: "none",
961
- stroke: R,
962
- strokeWidth: i,
963
- strokeLinejoin: "round",
964
- strokeLinecap: "round"
965
- }
966
- ),
967
- M && /* @__PURE__ */ e(
968
- "circle",
969
- {
970
- cx: L,
971
- cy: u,
972
- r: i + 1,
973
- fill: R
974
- }
975
- )
976
- ]
977
- }
978
- );
979
- }
980
- const E = he().curve(de).x((y, c) => W(c)).y((y) => V(y))(t) ?? "", m = W(t.length - 1), S = V(t[t.length - 1]);
981
- return /* @__PURE__ */ p(
982
- "svg",
983
- {
984
- ref: v,
985
- width: o,
986
- height: x,
987
- role: "img",
988
- "aria-label": "Sparkline chart",
989
- className: H("inline-block align-middle", G),
990
- ...P,
991
- children: [
992
- B ? /* @__PURE__ */ e(
993
- re.path,
994
- {
995
- d: E,
996
- fill: "none",
997
- stroke: R,
998
- strokeWidth: i,
999
- strokeLinejoin: "round",
1000
- strokeLinecap: "round",
1001
- initial: { pathLength: 0 },
1002
- animate: { pathLength: 1 },
1003
- transition: Ce
1004
- }
1005
- ) : /* @__PURE__ */ e(
1006
- "path",
1007
- {
1008
- d: E,
1009
- fill: "none",
1010
- stroke: R,
1011
- strokeWidth: i,
1012
- strokeLinejoin: "round",
1013
- strokeLinecap: "round"
1014
- }
1015
- ),
1016
- M && /* @__PURE__ */ e(
1017
- "circle",
1018
- {
1019
- cx: m,
1020
- cy: S,
1021
- r: i + 1,
1022
- fill: R
1023
- }
1024
- )
1025
- ]
1026
- }
1027
- );
1028
- }
1029
- );
1030
- Qe.displayName = "Sparkline";
1031
- const ge = (t) => t * Math.PI / 180, He = ne.forwardRef(
1032
- ({
1033
- value: t,
1034
- max: a = 100,
1035
- min: o = 0,
1036
- label: x,
1037
- valueLabel: d,
1038
- color: M,
1039
- trackColor: i = "var(--color-surface-border)",
1040
- height: k = 200,
1041
- startAngle: G = -120,
1042
- endAngle: P = 120,
1043
- thickness: v = 16,
1044
- animate: R = !0,
1045
- className: Z,
1046
- ...B
1047
- }, N) => {
1048
- const z = le(), X = Ee(z, R ? 600 : 0), W = R && !z, q = ae(M, 0), j = k, T = j / 2, V = Math.min(Math.max(t, o), a), J = a === o ? 0 : (V - o) / (a - o), E = G + (P - G) * J, m = typeof d == "function" ? d(V) : typeof d == "string" ? d : String(V), S = ve().innerRadius(T - v).outerRadius(T).startAngle(ge(G)).endAngle(ge(P)).cornerRadius(v / 2), y = ve().innerRadius(T - v).outerRadius(T).startAngle(ge(G)).endAngle(ge(E)).cornerRadius(v / 2), c = S(null) ?? "", I = y(null) ?? "";
1049
- return /* @__PURE__ */ e(
1050
- re.div,
1051
- {
1052
- ref: N,
1053
- className: H("inline-flex flex-col items-center", Z),
1054
- ...W ? { initial: { opacity: 0, scale: 0.96 }, animate: { opacity: 1, scale: 1 }, transition: se.fade } : {},
1055
- ...ce(B),
1056
- role: "meter",
1057
- "aria-valuenow": V,
1058
- "aria-valuemin": o,
1059
- "aria-valuemax": a,
1060
- "aria-label": x ?? "Gauge chart",
1061
- children: /* @__PURE__ */ e("svg", { width: j, height: j, role: "img", "aria-hidden": "true", children: /* @__PURE__ */ p("g", { transform: `translate(${T},${T})`, children: [
1062
- /* @__PURE__ */ e("path", { d: c, fill: i }),
1063
- /* @__PURE__ */ e(
1064
- "path",
1065
- {
1066
- d: I,
1067
- fill: q,
1068
- style: X > 0 ? { transition: `d ${X}ms ease-out` } : void 0
1069
- }
1070
- ),
1071
- /* @__PURE__ */ e(
1072
- "text",
1073
- {
1074
- x: 0,
1075
- y: x ? -4 : 0,
1076
- textAnchor: "middle",
1077
- dominantBaseline: "central",
1078
- className: "fill-surface-fg text-ds-2xl font-semibold",
1079
- children: m
1080
- }
1081
- ),
1082
- x && /* @__PURE__ */ e(
1083
- "text",
1084
- {
1085
- x: 0,
1086
- y: 20,
1087
- textAnchor: "middle",
1088
- dominantBaseline: "central",
1089
- className: "fill-surface-fg-muted text-ds-xs",
1090
- children: x
1091
- }
1092
- )
1093
- ] }) })
1094
- }
1095
- );
1096
- }
1097
- );
1098
- He.displayName = "GaugeChart";
1099
- const Ke = ne.forwardRef(
1100
- ({
1101
- data: t,
1102
- axes: a,
1103
- series: o,
1104
- maxValue: x,
1105
- levels: d = 5,
1106
- fillOpacity: M = 0.25,
1107
- showDots: i = !1,
1108
- height: k = 300,
1109
- showTooltip: G = !0,
1110
- showLegend: P = !1,
1111
- animate: v = !0,
1112
- ariaLabel: R,
1113
- className: Z,
1114
- ...B
1115
- }, N) => {
1116
- const z = ye(null), [X, W] = me(0), { tooltip: q, show: j, hide: T } = pe(), V = le(), J = v && !V;
1117
- xe(() => {
1118
- if (!z.current) return;
1119
- const u = new ResizeObserver((l) => {
1120
- const s = l[0];
1121
- s && W(s.contentRect.width);
1122
- });
1123
- return u.observe(z.current), () => u.disconnect();
1124
- }, []);
1125
- const m = (X > 0 ? Math.min(X, k) : k) / 2 - 40, S = o.map((u, l) => ae(u.color, l)), y = x ?? Math.max(
1126
- ...t.flatMap((u) => o.map((l) => Number(u[l.key]) || 0)),
1127
- 1
1128
- ), c = 2 * Math.PI / a.length, I = We().radius((u) => m * u / y).angle((u, l) => l * c).curve(Ie), C = (u) => a.map((l, s) => Number(t[s]?.[u]) || 0), L = (u, l) => {
1129
- const s = c * u - Math.PI / 2, b = m * l / y;
1130
- return {
1131
- x: b * Math.cos(s),
1132
- y: b * Math.sin(s)
1133
- };
1134
- };
1135
- return /* @__PURE__ */ p(
1136
- re.div,
1137
- {
1138
- ref: (u) => {
1139
- z.current = u, typeof N == "function" ? N(u) : N && (N.current = u);
1140
- },
1141
- className: H("relative w-full", Z),
1142
- ...J ? { initial: { opacity: 0, scale: 0.96 }, animate: { opacity: 1, scale: 1 }, transition: se.fade } : {},
1143
- ...ce(B),
1144
- children: [
1145
- X > 0 && /* @__PURE__ */ p(te, { children: [
1146
- /* @__PURE__ */ e(
1147
- "svg",
1148
- {
1149
- width: X,
1150
- height: k,
1151
- role: "img",
1152
- "aria-label": R ?? "Radar chart",
1153
- children: /* @__PURE__ */ p("g", { transform: `translate(${X / 2},${k / 2})`, children: [
1154
- Array.from({ length: d }, (u, l) => {
1155
- const s = m / d * (l + 1), b = a.map((n, r) => {
1156
- const f = c * r - Math.PI / 2;
1157
- return `${s * Math.cos(f)},${s * Math.sin(f)}`;
1158
- }).join(" ");
1159
- return /* @__PURE__ */ e(
1160
- "polygon",
1161
- {
1162
- points: b,
1163
- fill: "none",
1164
- stroke: "var(--color-surface-border)",
1165
- strokeDasharray: "3,3",
1166
- strokeWidth: 1
1167
- },
1168
- `grid-${l}`
1169
- );
1170
- }),
1171
- a.map((u, l) => {
1172
- const s = c * l - Math.PI / 2, b = m * Math.cos(s), n = m * Math.sin(s);
1173
- return /* @__PURE__ */ e(
1174
- "line",
1175
- {
1176
- x1: 0,
1177
- y1: 0,
1178
- x2: b,
1179
- y2: n,
1180
- stroke: "var(--color-surface-border)",
1181
- strokeWidth: 1
1182
- },
1183
- `axis-${l}`
1184
- );
1185
- }),
1186
- a.map((u, l) => {
1187
- const s = c * l - Math.PI / 2, b = m + 18, n = b * Math.cos(s), r = b * Math.sin(s);
1188
- let f = "middle";
1189
- return Math.abs(Math.cos(s)) > 0.1 && (f = Math.cos(s) > 0 ? "start" : "end"), /* @__PURE__ */ e(
1190
- "text",
1191
- {
1192
- x: n,
1193
- y: r,
1194
- textAnchor: f,
1195
- dominantBaseline: "central",
1196
- className: "fill-surface-fg-muted text-ds-xs",
1197
- children: u
1198
- },
1199
- `label-${l}`
1200
- );
1201
- }),
1202
- Array.from({ length: d }, (u, l) => {
1203
- const s = Math.round(y / d * (l + 1)), b = m / d * (l + 1), n = -Math.PI / 2, r = b * Math.cos(n) + 4, f = b * Math.sin(n);
1204
- return /* @__PURE__ */ e(
1205
- "text",
1206
- {
1207
- x: r,
1208
- y: f,
1209
- textAnchor: "start",
1210
- dominantBaseline: "auto",
1211
- className: "fill-surface-fg-subtle text-ds-xs",
1212
- children: s
1213
- },
1214
- `level-label-${l}`
1215
- );
1216
- }),
1217
- o.map((u, l) => {
1218
- const s = C(u.key), b = I(s);
1219
- return b ? /* @__PURE__ */ p("g", { children: [
1220
- /* @__PURE__ */ e(
1221
- "path",
1222
- {
1223
- d: b,
1224
- fill: S[l],
1225
- fillOpacity: M,
1226
- stroke: S[l],
1227
- strokeWidth: 2,
1228
- strokeLinejoin: "round"
1229
- }
1230
- ),
1231
- i && s.map((n, r) => {
1232
- const { x: f, y: A } = L(r, n);
1233
- return /* @__PURE__ */ e(
1234
- "circle",
1235
- {
1236
- cx: f,
1237
- cy: A,
1238
- r: 4,
1239
- fill: S[l],
1240
- stroke: "var(--color-surface-base)",
1241
- strokeWidth: 2,
1242
- className: "transition-opacity"
1243
- },
1244
- `dot-${u.key}-${r}`
1245
- );
1246
- })
1247
- ] }, u.key) : null;
1248
- }),
1249
- G && a.map((u, l) => {
1250
- const s = c * l - Math.PI / 2, b = m * Math.cos(s), n = m * Math.sin(s);
1251
- return /* @__PURE__ */ e(
1252
- "circle",
1253
- {
1254
- cx: b,
1255
- cy: n,
1256
- r: 16,
1257
- fill: "transparent",
1258
- className: "cursor-pointer",
1259
- onMouseMove: (r) => {
1260
- const f = r.currentTarget.closest("div")?.getBoundingClientRect();
1261
- j(
1262
- r.clientX - (f?.left ?? 0),
1263
- r.clientY - (f?.top ?? 0),
1264
- /* @__PURE__ */ p("div", { children: [
1265
- /* @__PURE__ */ e("div", { className: "font-medium", children: u }),
1266
- o.map((A, w) => {
1267
- const $ = Number(t[l]?.[A.key]) || 0;
1268
- return /* @__PURE__ */ p(
1269
- "div",
1270
- {
1271
- className: "flex items-center gap-ds-02",
1272
- children: [
1273
- /* @__PURE__ */ e(
1274
- "span",
1275
- {
1276
- className: "inline-block h-2 w-2 rounded-ds-full",
1277
- style: { backgroundColor: S[w] }
1278
- }
1279
- ),
1280
- /* @__PURE__ */ p("span", { className: "text-surface-fg-muted", children: [
1281
- A.label,
1282
- ":"
1283
- ] }),
1284
- " ",
1285
- $.toLocaleString()
1286
- ]
1287
- },
1288
- A.key
1289
- );
1290
- })
1291
- ] })
1292
- );
1293
- },
1294
- onMouseLeave: T
1295
- },
1296
- `hover-${l}`
1297
- );
1298
- })
1299
- ] })
1300
- }
1301
- ),
1302
- G && /* @__PURE__ */ e(ue, { state: q })
1303
- ] }),
1304
- P && /* @__PURE__ */ e(
1305
- ie,
1306
- {
1307
- items: o.map((u, l) => ({
1308
- label: u.label,
1309
- color: S[l]
1310
- })),
1311
- className: "mt-ds-04"
1312
- }
1313
- )
1314
- ]
1315
- }
1316
- );
1317
- }
1318
- );
1319
- Ke.displayName = "RadarChart";
1320
- export {
1321
- qe as AreaChart,
1322
- Ue as BarChart,
1323
- be as ChartContainer,
1324
- He as GaugeChart,
1325
- ie as Legend,
1326
- Ze as LineChart,
1327
- Je as PieChart,
1328
- Ke as RadarChart,
1329
- Qe as Sparkline
1330
- };
202
+ //#endregion
203
+ //#region src/ui/charts/bar-chart.tsx
204
+ var W = a.forwardRef(({ data: i, xKey: a, yKey: o, orientation: s = "vertical", stacked: c = !1, grouped: l = !1, color: h, height: g = 300, showGrid: _ = !0, showTooltip: v = !0, showLegend: y = !1, animate: b = !0, barRadius: x = 4, xLabel: S, yLabel: C, seriesLabels: w, ariaLabel: T, className: E, ...D }, O) => {
205
+ let { tooltip: k, show: A, hide: j } = R(), M = H(), z = s === "vertical", B = b && !M, U = Array.isArray(o) ? o : [o], W = U.length > 1, G = W ? U.map((e, t) => V(Array.isArray(h) ? h[t] : typeof h == "string" ? h : void 0, t)) : [V(typeof h == "string" ? h : Array.isArray(h) ? h[0] : void 0, 0)];
206
+ return /* @__PURE__ */ f(e.div, {
207
+ ref: O,
208
+ className: r("relative", E),
209
+ ...B ? {
210
+ initial: {
211
+ opacity: 0,
212
+ scale: .96
213
+ },
214
+ animate: {
215
+ opacity: 1,
216
+ scale: 1
217
+ },
218
+ transition: n.fade
219
+ } : {},
220
+ ...t(D),
221
+ children: [
222
+ /* @__PURE__ */ d(N, {
223
+ height: g,
224
+ ariaLabel: T ?? "Bar chart",
225
+ children: ({ width: e, height: t, margin: n }) => {
226
+ let r = i.map((e) => String(e[a])), o;
227
+ o = Math.max(...c ? i.map((e) => U.reduce((t, n) => t + (Number(e[n]) || 0), 0)) : i.flatMap((e) => U.map((t) => Number(e[t]) || 0)));
228
+ let s = p().domain(r).range(z ? [0, e] : [0, t]).padding(.2), h = m().domain([0, o * 1.1]).range(z ? [t, 0] : [0, e]).nice(), g = s.bandwidth(), y = W && l ? g / U.length : g;
229
+ return /* @__PURE__ */ f(u, { children: [
230
+ _ && /* @__PURE__ */ d(F, {
231
+ width: e,
232
+ height: t,
233
+ yScale: z ? h : void 0,
234
+ xScale: z ? void 0 : h,
235
+ horizontal: z,
236
+ vertical: !z
237
+ }),
238
+ i.map((e) => {
239
+ let n = String(e[a]), r = 0;
240
+ return U.map((i, a) => {
241
+ let o = Number(e[i]) || 0, u = G[a] || G[0], p, m, g, _;
242
+ return z ? (p = (s(n) ?? 0) + (l && W ? a * y : 0), m = h(c ? r + o : o), g = y, _ = c ? h(r) - h(r + o) : t - h(o)) : (p = c ? h(r) : 0, m = (s(n) ?? 0) + (l && W ? a * y : 0), g = c ? h(r + o) - h(r) : h(o), _ = y), c && (r += o), /* @__PURE__ */ d("rect", {
243
+ x: p,
244
+ y: m,
245
+ width: Math.max(0, g),
246
+ height: Math.max(0, _),
247
+ rx: x,
248
+ fill: u,
249
+ className: "transition-opacity hover:opacity-80",
250
+ onMouseMove: (e) => {
251
+ if (v) {
252
+ let t = e.currentTarget.closest("div")?.getBoundingClientRect();
253
+ A(e.clientX - (t?.left ?? 0), e.clientY - (t?.top ?? 0), /* @__PURE__ */ f("div", { children: [
254
+ /* @__PURE__ */ d("div", {
255
+ className: "font-medium",
256
+ children: n
257
+ }),
258
+ W && /* @__PURE__ */ d("div", {
259
+ className: "text-surface-fg-muted",
260
+ children: w?.[a] ?? i
261
+ }),
262
+ /* @__PURE__ */ d("div", { children: o.toLocaleString() })
263
+ ] }));
264
+ }
265
+ },
266
+ onMouseLeave: j
267
+ }, `${n}-${i}`);
268
+ });
269
+ }),
270
+ z ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(P, {
271
+ scale: s,
272
+ orientation: "bottom",
273
+ transform: `translate(0,${t})`,
274
+ label: S
275
+ }), /* @__PURE__ */ d(P, {
276
+ scale: h,
277
+ orientation: "left",
278
+ label: C
279
+ })] }) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(P, {
280
+ scale: h,
281
+ orientation: "bottom",
282
+ transform: `translate(0,${t})`,
283
+ label: S
284
+ }), /* @__PURE__ */ d(P, {
285
+ scale: s,
286
+ orientation: "left",
287
+ label: C
288
+ })] })
289
+ ] });
290
+ }
291
+ }),
292
+ v && /* @__PURE__ */ d(L, { state: k }),
293
+ y && W && /* @__PURE__ */ d(I, {
294
+ items: U.map((e, t) => ({
295
+ label: w?.[t] ?? e,
296
+ color: G[t]
297
+ })),
298
+ className: "mt-ds-04"
299
+ })
300
+ ]
301
+ });
302
+ });
303
+ W.displayName = "BarChart";
304
+ //#endregion
305
+ //#region src/ui/charts/line-chart.tsx
306
+ var G = a.forwardRef(({ data: i, xKey: a, series: o, curved: s = !1, showDots: c = !1, dotSize: l = 4, strokeWidth: p = 2, height: g = 300, showGrid: _ = !0, showTooltip: v = !0, showLegend: y = !1, animate: b = !0, xLabel: x, yLabel: S, ariaLabel: w, className: D, ...O }, k) => {
307
+ let { tooltip: A, show: j, hide: M } = R(), z = H(), B = b && !z, U = o.map((e, t) => V(e.color, t));
308
+ return /* @__PURE__ */ f(e.div, {
309
+ ref: k,
310
+ className: r("relative", D),
311
+ ...B ? {
312
+ initial: {
313
+ opacity: 0,
314
+ scale: .96
315
+ },
316
+ animate: {
317
+ opacity: 1,
318
+ scale: 1
319
+ },
320
+ transition: n.fade
321
+ } : {},
322
+ ...t(O),
323
+ children: [
324
+ /* @__PURE__ */ d(N, {
325
+ height: g,
326
+ ariaLabel: w ?? "Line chart",
327
+ children: ({ width: e, height: t, margin: n }) => {
328
+ let r = i.map((e) => e[a]), g = r.every((e) => typeof e == "number"), y, b;
329
+ if (g) {
330
+ let t = r, n = Math.min(...t), i = Math.max(...t), o = m().domain([n, i]).range([0, e]);
331
+ y = o, b = (e) => o(Number(e[a]));
332
+ } else {
333
+ let t = r.map(String), n = h().domain(t).range([0, e]).padding(.5);
334
+ y = n, b = (e) => n(String(e[a])) ?? 0;
335
+ }
336
+ let w = i.flatMap((e) => o.map((t) => Number(e[t.key]) || 0)), D = Math.max(...w), O = m().domain([0, D * 1.1]).range([t, 0]).nice(), k = s ? T : C, A = E().curve(k).defined((e) => e != null);
337
+ return /* @__PURE__ */ f(u, { children: [
338
+ _ && /* @__PURE__ */ d(F, {
339
+ width: e,
340
+ height: t,
341
+ yScale: O,
342
+ horizontal: !0
343
+ }),
344
+ o.map((e, t) => /* @__PURE__ */ f("g", { children: [/* @__PURE__ */ d("path", {
345
+ d: A.x((e) => b(e)).y((t) => O(Number(t[e.key]) || 0))(i) ?? "",
346
+ fill: "none",
347
+ stroke: U[t],
348
+ strokeWidth: p,
349
+ strokeLinejoin: "round",
350
+ strokeLinecap: "round"
351
+ }), c && i.map((n, r) => /* @__PURE__ */ d("circle", {
352
+ cx: b(n),
353
+ cy: O(Number(n[e.key]) || 0),
354
+ r: l,
355
+ fill: U[t],
356
+ className: "transition-opacity hover:opacity-80"
357
+ }, `${e.key}-dot-${r}`))] }, e.key)),
358
+ v && i.map((n, r) => {
359
+ let s = b(n), c = e / Math.max(i.length - 1, 1);
360
+ return /* @__PURE__ */ d("rect", {
361
+ x: s - c / 2,
362
+ y: 0,
363
+ width: c,
364
+ height: t,
365
+ fill: "transparent",
366
+ onMouseMove: (e) => {
367
+ let t = e.currentTarget.closest("div")?.getBoundingClientRect();
368
+ j(e.clientX - (t?.left ?? 0), e.clientY - (t?.top ?? 0), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("div", {
369
+ className: "font-medium",
370
+ children: String(n[a])
371
+ }), o.map((e, t) => /* @__PURE__ */ f("div", {
372
+ className: "flex items-center gap-ds-02",
373
+ children: [
374
+ /* @__PURE__ */ d("span", {
375
+ className: "inline-block h-2 w-2 rounded-ds-full",
376
+ style: { backgroundColor: U[t] }
377
+ }),
378
+ /* @__PURE__ */ f("span", {
379
+ className: "text-surface-fg-muted",
380
+ children: [e.label, ":"]
381
+ }),
382
+ " ",
383
+ Number(n[e.key]).toLocaleString()
384
+ ]
385
+ }, e.key))] }));
386
+ },
387
+ onMouseLeave: M
388
+ }, `hover-${r}`);
389
+ }),
390
+ /* @__PURE__ */ d(P, {
391
+ scale: y,
392
+ orientation: "bottom",
393
+ transform: `translate(0,${t})`,
394
+ label: x
395
+ }),
396
+ /* @__PURE__ */ d(P, {
397
+ scale: O,
398
+ orientation: "left",
399
+ label: S
400
+ })
401
+ ] });
402
+ }
403
+ }),
404
+ v && /* @__PURE__ */ d(L, { state: A }),
405
+ y && o.length > 1 && /* @__PURE__ */ d(I, {
406
+ items: o.map((e, t) => ({
407
+ label: e.label,
408
+ color: U[t]
409
+ })),
410
+ className: "mt-ds-04"
411
+ })
412
+ ]
413
+ });
414
+ });
415
+ G.displayName = "LineChart";
416
+ //#endregion
417
+ //#region src/ui/charts/area-chart.tsx
418
+ var K = a.forwardRef(({ data: i, xKey: o, series: s, curved: c = !1, stacked: l = !1, fillOpacity: p = .3, gradient: g = !1, strokeWidth: _ = 2, height: v = 300, showGrid: y = !0, showTooltip: b = !0, showLegend: x = !1, animate: w = !0, xLabel: D, yLabel: O, ariaLabel: M, className: z, ...B }, U) => {
419
+ let { tooltip: W, show: G, hide: K } = R(), q = H(), J = w && !q, Y = s.map((e, t) => V(e.color, t)), X = a.useId();
420
+ return /* @__PURE__ */ f(e.div, {
421
+ ref: U,
422
+ className: r("relative", z),
423
+ ...J ? {
424
+ initial: {
425
+ opacity: 0,
426
+ scale: .96
427
+ },
428
+ animate: {
429
+ opacity: 1,
430
+ scale: 1
431
+ },
432
+ transition: n.fade
433
+ } : {},
434
+ ...t(B),
435
+ children: [
436
+ /* @__PURE__ */ d(N, {
437
+ height: v,
438
+ ariaLabel: M ?? "Area chart",
439
+ children: ({ width: e, height: t, margin: n }) => {
440
+ let r = i.map((e) => e[o]), a = r.every((e) => typeof e == "number"), v, x, w;
441
+ if (a) {
442
+ let t = r, n = Math.min(...t), a = Math.max(...t), s = m().domain([n, a]).range([0, e]);
443
+ v = s, x = (e) => s(Number(e[o])), w = (e) => s(Number(i[e][o]));
444
+ } else {
445
+ let t = r.map(String), n = h().domain(t).range([0, e]).padding(.5);
446
+ v = n, x = (e) => n(String(e[o])) ?? 0, w = (e) => n(String(i[e][o])) ?? 0;
447
+ }
448
+ let M;
449
+ M = Math.max(...l ? i.map((e) => s.reduce((t, n) => t + (Number(e[n.key]) || 0), 0)) : i.flatMap((e) => s.map((t) => Number(e[t.key]) || 0)));
450
+ let N = m().domain([0, M * 1.1]).range([t, 0]).nice(), I = c ? T : C, L = () => i.map((n, r) => {
451
+ let a = x(n), c = e / Math.max(i.length - 1, 1);
452
+ return /* @__PURE__ */ d("rect", {
453
+ x: a - c / 2,
454
+ y: 0,
455
+ width: c,
456
+ height: t,
457
+ fill: "transparent",
458
+ onMouseMove: (e) => {
459
+ let t = e.currentTarget.closest("div")?.getBoundingClientRect();
460
+ G(e.clientX - (t?.left ?? 0), e.clientY - (t?.top ?? 0), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("div", {
461
+ className: "font-medium",
462
+ children: String(n[o])
463
+ }), s.map((e, t) => /* @__PURE__ */ f("div", {
464
+ className: "flex items-center gap-ds-02",
465
+ children: [
466
+ /* @__PURE__ */ d("span", {
467
+ className: "inline-block h-2 w-2 rounded-ds-full",
468
+ style: { backgroundColor: Y[t] }
469
+ }),
470
+ /* @__PURE__ */ f("span", {
471
+ className: "text-surface-fg-muted",
472
+ children: [e.label, ":"]
473
+ }),
474
+ " ",
475
+ Number(n[e.key]).toLocaleString()
476
+ ]
477
+ }, e.key))] }));
478
+ },
479
+ onMouseLeave: K
480
+ }, `hover-${r}`);
481
+ }), R = () => g ? /* @__PURE__ */ d("defs", { children: s.map((e, t) => /* @__PURE__ */ f("linearGradient", {
482
+ id: `${X}-gradient-${t}`,
483
+ x1: "0",
484
+ y1: "0",
485
+ x2: "0",
486
+ y2: "1",
487
+ children: [/* @__PURE__ */ d("stop", {
488
+ offset: "0%",
489
+ stopColor: Y[t],
490
+ stopOpacity: p
491
+ }), /* @__PURE__ */ d("stop", {
492
+ offset: "100%",
493
+ stopColor: Y[t],
494
+ stopOpacity: .05
495
+ })]
496
+ }, `grad-${t}`)) }) : null, z = () => /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(P, {
497
+ scale: v,
498
+ orientation: "bottom",
499
+ transform: `translate(0,${t})`,
500
+ label: D
501
+ }), /* @__PURE__ */ d(P, {
502
+ scale: N,
503
+ orientation: "left",
504
+ label: O
505
+ })] });
506
+ if (l) {
507
+ let n = s.map((e) => e.key), r = k().keys(n).order(j).offset(A)(i.map((e) => {
508
+ let t = { [o]: String(e[o]) };
509
+ for (let n of s) t[n.key] = Number(e[n.key]) || 0;
510
+ return t;
511
+ })), a = S().curve(I).x((e, t) => w(t)).y0((e) => N(e[0])).y1((e) => N(e[1])), c = E().curve(I).x((e, t) => w(t)).y((e) => N(e[1]));
512
+ return /* @__PURE__ */ f(u, { children: [
513
+ R(),
514
+ y && /* @__PURE__ */ d(F, {
515
+ width: e,
516
+ height: t,
517
+ yScale: N,
518
+ horizontal: !0
519
+ }),
520
+ [...r].reverse().map((e, t) => {
521
+ let n = r.length - 1 - t, i = e, o = a(i) ?? "", l = c(i) ?? "";
522
+ return /* @__PURE__ */ f("g", { children: [/* @__PURE__ */ d("path", {
523
+ d: o,
524
+ fill: g ? `url(#${X}-gradient-${n})` : Y[n],
525
+ opacity: g ? 1 : p
526
+ }), /* @__PURE__ */ d("path", {
527
+ d: l,
528
+ fill: "none",
529
+ stroke: Y[n],
530
+ strokeWidth: _,
531
+ strokeLinejoin: "round",
532
+ strokeLinecap: "round"
533
+ })] }, s[n].key);
534
+ }),
535
+ b && L(),
536
+ z()
537
+ ] });
538
+ }
539
+ let B = S().curve(I).defined((e) => e != null), V = E().curve(I).defined((e) => e != null);
540
+ return /* @__PURE__ */ f(u, { children: [
541
+ R(),
542
+ y && /* @__PURE__ */ d(F, {
543
+ width: e,
544
+ height: t,
545
+ yScale: N,
546
+ horizontal: !0
547
+ }),
548
+ [...s].reverse().map((e, n) => {
549
+ let r = s.length - 1 - n, a = B.x((e) => x(e)).y0(t).y1((t) => N(Number(t[e.key]) || 0)), o = V.x((e) => x(e)).y((t) => N(Number(t[e.key]) || 0)), c = a(i) ?? "", l = o(i) ?? "";
550
+ return /* @__PURE__ */ f("g", { children: [/* @__PURE__ */ d("path", {
551
+ d: c,
552
+ fill: g ? `url(#${X}-gradient-${r})` : Y[r],
553
+ opacity: g ? 1 : p
554
+ }), /* @__PURE__ */ d("path", {
555
+ d: l,
556
+ fill: "none",
557
+ stroke: Y[r],
558
+ strokeWidth: _,
559
+ strokeLinejoin: "round",
560
+ strokeLinecap: "round"
561
+ })] }, e.key);
562
+ }),
563
+ b && L(),
564
+ z()
565
+ ] });
566
+ }
567
+ }),
568
+ b && /* @__PURE__ */ d(L, { state: W }),
569
+ x && s.length > 1 && /* @__PURE__ */ d(I, {
570
+ items: s.map((e, t) => ({
571
+ label: e.label,
572
+ color: Y[t]
573
+ })),
574
+ className: "mt-ds-04"
575
+ })
576
+ ]
577
+ });
578
+ });
579
+ K.displayName = "AreaChart";
580
+ //#endregion
581
+ //#region src/ui/charts/pie-chart.tsx
582
+ var q = a.forwardRef(({ data: i, variant: a = "pie", innerRadius: o = .6, padAngle: p = 0, cornerRadius: m = 0, height: h = 300, showTooltip: g = !0, showLegend: _ = !1, showLabels: v = !1, animate: y = !0, className: b, centerLabel: S, ariaLabel: C, ...w }, T) => {
583
+ let E = c(null), [D, k] = l(0), [A, j] = l(null), { tooltip: M, show: N, hide: P } = R(), F = H(), z = y && !F;
584
+ s(() => {
585
+ if (!E.current) return;
586
+ let e = new ResizeObserver((e) => {
587
+ let t = e[0];
588
+ t && k(t.contentRect.width);
589
+ });
590
+ return e.observe(E.current), () => e.disconnect();
591
+ }, []);
592
+ let B = (D > 0 ? Math.min(D, h) : h) / 2, U = a === "donut" ? B * o : 0, W = i.map((e, t) => V(e.color, t)), G = i.reduce((e, t) => e + t.value, 0), K = O().value((e) => e.value).padAngle(p).sort(null)(i), q = x().innerRadius(U).outerRadius(B - 2).cornerRadius(m), J = U + (B - 2 - U) * .7, Y = x().innerRadius(J).outerRadius(J);
593
+ return /* @__PURE__ */ f(e.div, {
594
+ ref: (e) => {
595
+ E.current = e, typeof T == "function" ? T(e) : T && (T.current = e);
596
+ },
597
+ className: r("relative w-full", b),
598
+ ...z ? {
599
+ initial: {
600
+ opacity: 0,
601
+ scale: .96
602
+ },
603
+ animate: {
604
+ opacity: 1,
605
+ scale: 1
606
+ },
607
+ transition: n.fade
608
+ } : {},
609
+ ...t(w),
610
+ children: [D > 0 && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("svg", {
611
+ width: D,
612
+ height: h,
613
+ role: "img",
614
+ "aria-label": C ?? "Pie chart",
615
+ children: /* @__PURE__ */ f("g", {
616
+ transform: `translate(${D / 2},${h / 2})`,
617
+ children: [
618
+ K.map((e, t) => {
619
+ let n = q(e);
620
+ if (!n) return null;
621
+ let [r, i] = q.centroid(e), a = Math.atan2(i, r), o = Math.cos(a) * 4, s = Math.sin(a) * 4, c = A === t;
622
+ return /* @__PURE__ */ d("path", {
623
+ d: n,
624
+ fill: W[t],
625
+ className: "cursor-pointer transition-transform",
626
+ style: { transform: c ? `translate(${o}px, ${s}px)` : void 0 },
627
+ onMouseEnter: () => j(t),
628
+ onMouseMove: (t) => {
629
+ if (g) {
630
+ let n = t.currentTarget.closest("div")?.getBoundingClientRect(), r = G > 0 ? (e.data.value / G * 100).toFixed(1) : "0";
631
+ N(t.clientX - (n?.left ?? 0), t.clientY - (n?.top ?? 0), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("div", {
632
+ className: "font-medium",
633
+ children: e.data.label
634
+ }), /* @__PURE__ */ f("div", { children: [
635
+ e.data.value.toLocaleString(),
636
+ " (",
637
+ r,
638
+ "%)"
639
+ ] })] }));
640
+ }
641
+ },
642
+ onMouseLeave: () => {
643
+ j(null), P();
644
+ }
645
+ }, `slice-${e.data.label}-${t}`);
646
+ }),
647
+ v && K.map((e, t) => {
648
+ let [n, r] = Y.centroid(e), i = G > 0 ? (e.data.value / G * 100).toFixed(0) : "0";
649
+ return G > 0 && e.data.value / G < .03 ? null : /* @__PURE__ */ f("text", {
650
+ x: n,
651
+ y: r,
652
+ textAnchor: "middle",
653
+ dominantBaseline: "central",
654
+ className: "pointer-events-none fill-accent-fg text-ds-xs font-medium",
655
+ children: [i, "%"]
656
+ }, `label-${e.data.label}-${t}`);
657
+ }),
658
+ a === "donut" && S && U > 0 && /* @__PURE__ */ d("foreignObject", {
659
+ x: -U * .7,
660
+ y: -U * .7,
661
+ width: U * 1.4,
662
+ height: U * 1.4,
663
+ children: /* @__PURE__ */ d("div", {
664
+ className: "flex h-full w-full items-center justify-center text-center text-surface-fg",
665
+ children: S
666
+ })
667
+ })
668
+ ]
669
+ })
670
+ }), g && /* @__PURE__ */ d(L, { state: M })] }), _ && /* @__PURE__ */ d(I, {
671
+ items: i.map((e, t) => ({
672
+ label: e.label,
673
+ color: W[t]
674
+ })),
675
+ className: "mt-ds-04"
676
+ })]
677
+ });
678
+ });
679
+ q.displayName = "PieChart";
680
+ //#endregion
681
+ //#region src/ui/charts/sparkline.tsx
682
+ var J = {
683
+ duration: 1,
684
+ ease: "easeOut"
685
+ }, Y = a.forwardRef(({ data: t, variant: n = "line", width: i = 120, height: a = 32, color: o, showLastDot: s = !1, strokeWidth: c = 1.5, animate: l = !0, className: u, ...p }, h) => {
686
+ let g = V(o, 0), _ = H(), v = l && !_;
687
+ if (!t.length) return null;
688
+ let y = n === "bar" ? 1 : c, b = i - y * 2, x = a - y * 2, C = m().domain([0, Math.max(t.length - 1, 1)]).range([y, y + b]), w = Math.min(...t), D = Math.max(...t), O = w === D ? [w - 1, D + 1] : [w, D], k = m().domain(O).range([y + x, y]);
689
+ if (n === "bar") {
690
+ let e = Math.max(1, (b - 1 * (t.length - 1)) / t.length), n = y + x;
691
+ return /* @__PURE__ */ d("svg", {
692
+ ref: h,
693
+ width: i,
694
+ height: a,
695
+ role: "img",
696
+ "aria-label": "Sparkline bar chart",
697
+ className: r("inline-block align-middle", u),
698
+ ...p,
699
+ children: t.map((t, r) => {
700
+ let i = y + r * (e + 1), a = k(t);
701
+ return /* @__PURE__ */ d("rect", {
702
+ x: i,
703
+ y: a,
704
+ width: e,
705
+ height: Math.max(1, n - a),
706
+ rx: Math.min(1, e / 2),
707
+ fill: g
708
+ }, r);
709
+ })
710
+ });
711
+ }
712
+ if (n === "area") {
713
+ let n = S().curve(T).x((e, t) => C(t)).y0(y + x).y1((e) => k(e)), o = E().curve(T).x((e, t) => C(t)).y((e) => k(e)), l = n(t) ?? "", m = o(t) ?? "", _ = C(t.length - 1), b = k(t[t.length - 1]);
714
+ return /* @__PURE__ */ f("svg", {
715
+ ref: h,
716
+ width: i,
717
+ height: a,
718
+ role: "img",
719
+ "aria-label": "Sparkline area chart",
720
+ className: r("inline-block align-middle", u),
721
+ ...p,
722
+ children: [
723
+ /* @__PURE__ */ d("path", {
724
+ d: l,
725
+ fill: g,
726
+ opacity: .2
727
+ }),
728
+ v ? /* @__PURE__ */ d(e.path, {
729
+ d: m,
730
+ fill: "none",
731
+ stroke: g,
732
+ strokeWidth: c,
733
+ strokeLinejoin: "round",
734
+ strokeLinecap: "round",
735
+ initial: { pathLength: 0 },
736
+ animate: { pathLength: 1 },
737
+ transition: J
738
+ }) : /* @__PURE__ */ d("path", {
739
+ d: m,
740
+ fill: "none",
741
+ stroke: g,
742
+ strokeWidth: c,
743
+ strokeLinejoin: "round",
744
+ strokeLinecap: "round"
745
+ }),
746
+ s && /* @__PURE__ */ d("circle", {
747
+ cx: _,
748
+ cy: b,
749
+ r: c + 1,
750
+ fill: g
751
+ })
752
+ ]
753
+ });
754
+ }
755
+ let A = E().curve(T).x((e, t) => C(t)).y((e) => k(e))(t) ?? "", j = C(t.length - 1), M = k(t[t.length - 1]);
756
+ return /* @__PURE__ */ f("svg", {
757
+ ref: h,
758
+ width: i,
759
+ height: a,
760
+ role: "img",
761
+ "aria-label": "Sparkline chart",
762
+ className: r("inline-block align-middle", u),
763
+ ...p,
764
+ children: [v ? /* @__PURE__ */ d(e.path, {
765
+ d: A,
766
+ fill: "none",
767
+ stroke: g,
768
+ strokeWidth: c,
769
+ strokeLinejoin: "round",
770
+ strokeLinecap: "round",
771
+ initial: { pathLength: 0 },
772
+ animate: { pathLength: 1 },
773
+ transition: J
774
+ }) : /* @__PURE__ */ d("path", {
775
+ d: A,
776
+ fill: "none",
777
+ stroke: g,
778
+ strokeWidth: c,
779
+ strokeLinejoin: "round",
780
+ strokeLinecap: "round"
781
+ }), s && /* @__PURE__ */ d("circle", {
782
+ cx: j,
783
+ cy: M,
784
+ r: c + 1,
785
+ fill: g
786
+ })]
787
+ });
788
+ });
789
+ Y.displayName = "Sparkline";
790
+ //#endregion
791
+ //#region src/ui/charts/gauge-chart.tsx
792
+ var X = (e) => e * Math.PI / 180, Z = a.forwardRef(({ value: i, max: a = 100, min: o = 0, label: s, valueLabel: c, color: l, trackColor: u = "var(--color-surface-border)", height: p = 200, startAngle: m = -120, endAngle: h = 120, thickness: g = 16, animate: _ = !0, className: v, ...y }, b) => {
793
+ let S = H(), C = U(S, _ ? 600 : 0), w = _ && !S, T = V(l, 0), E = p, D = E / 2, O = Math.min(Math.max(i, o), a), k = a === o ? 0 : (O - o) / (a - o), A = m + (h - m) * k, j = typeof c == "function" ? c(O) : typeof c == "string" ? c : String(O), M = x().innerRadius(D - g).outerRadius(D).startAngle(X(m)).endAngle(X(h)).cornerRadius(g / 2), N = x().innerRadius(D - g).outerRadius(D).startAngle(X(m)).endAngle(X(A)).cornerRadius(g / 2), P = M(null) ?? "", F = N(null) ?? "";
794
+ return /* @__PURE__ */ d(e.div, {
795
+ ref: b,
796
+ className: r("inline-flex flex-col items-center", v),
797
+ ...w ? {
798
+ initial: {
799
+ opacity: 0,
800
+ scale: .96
801
+ },
802
+ animate: {
803
+ opacity: 1,
804
+ scale: 1
805
+ },
806
+ transition: n.fade
807
+ } : {},
808
+ ...t(y),
809
+ role: "meter",
810
+ "aria-valuenow": O,
811
+ "aria-valuemin": o,
812
+ "aria-valuemax": a,
813
+ "aria-label": s ?? "Gauge chart",
814
+ children: /* @__PURE__ */ d("svg", {
815
+ width: E,
816
+ height: E,
817
+ role: "img",
818
+ "aria-hidden": "true",
819
+ children: /* @__PURE__ */ f("g", {
820
+ transform: `translate(${D},${D})`,
821
+ children: [
822
+ /* @__PURE__ */ d("path", {
823
+ d: P,
824
+ fill: u
825
+ }),
826
+ /* @__PURE__ */ d("path", {
827
+ d: F,
828
+ fill: T,
829
+ style: C > 0 ? { transition: `d ${C}ms ease-out` } : void 0
830
+ }),
831
+ /* @__PURE__ */ d("text", {
832
+ x: 0,
833
+ y: s ? -4 : 0,
834
+ textAnchor: "middle",
835
+ dominantBaseline: "central",
836
+ className: "fill-surface-fg text-ds-2xl font-semibold",
837
+ children: j
838
+ }),
839
+ s && /* @__PURE__ */ d("text", {
840
+ x: 0,
841
+ y: 20,
842
+ textAnchor: "middle",
843
+ dominantBaseline: "central",
844
+ className: "fill-surface-fg-muted text-ds-xs",
845
+ children: s
846
+ })
847
+ ]
848
+ })
849
+ })
850
+ });
851
+ });
852
+ Z.displayName = "GaugeChart";
853
+ //#endregion
854
+ //#region src/ui/charts/radar-chart.tsx
855
+ var Q = a.forwardRef(({ data: i, axes: a, series: o, maxValue: p, levels: m = 5, fillOpacity: h = .25, showDots: g = !1, height: _ = 300, showTooltip: v = !0, showLegend: y = !1, animate: b = !0, ariaLabel: x, className: S, ...C }, T) => {
856
+ let E = c(null), [O, k] = l(0), { tooltip: A, show: j, hide: M } = R(), N = H(), P = b && !N;
857
+ s(() => {
858
+ if (!E.current) return;
859
+ let e = new ResizeObserver((e) => {
860
+ let t = e[0];
861
+ t && k(t.contentRect.width);
862
+ });
863
+ return e.observe(E.current), () => e.disconnect();
864
+ }, []);
865
+ let F = (O > 0 ? Math.min(O, _) : _) / 2 - 40, z = o.map((e, t) => V(e.color, t)), B = p ?? Math.max(...i.flatMap((e) => o.map((t) => Number(e[t.key]) || 0)), 1), U = 2 * Math.PI / a.length, W = D().radius((e) => F * e / B).angle((e, t) => t * U).curve(w), G = (e) => a.map((t, n) => Number(i[n]?.[e]) || 0), K = (e, t) => {
866
+ let n = U * e - Math.PI / 2, r = F * t / B;
867
+ return {
868
+ x: r * Math.cos(n),
869
+ y: r * Math.sin(n)
870
+ };
871
+ };
872
+ return /* @__PURE__ */ f(e.div, {
873
+ ref: (e) => {
874
+ E.current = e, typeof T == "function" ? T(e) : T && (T.current = e);
875
+ },
876
+ className: r("relative w-full", S),
877
+ ...P ? {
878
+ initial: {
879
+ opacity: 0,
880
+ scale: .96
881
+ },
882
+ animate: {
883
+ opacity: 1,
884
+ scale: 1
885
+ },
886
+ transition: n.fade
887
+ } : {},
888
+ ...t(C),
889
+ children: [O > 0 && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("svg", {
890
+ width: O,
891
+ height: _,
892
+ role: "img",
893
+ "aria-label": x ?? "Radar chart",
894
+ children: /* @__PURE__ */ f("g", {
895
+ transform: `translate(${O / 2},${_ / 2})`,
896
+ children: [
897
+ Array.from({ length: m }, (e, t) => {
898
+ let n = F / m * (t + 1);
899
+ return /* @__PURE__ */ d("polygon", {
900
+ points: a.map((e, t) => {
901
+ let r = U * t - Math.PI / 2;
902
+ return `${n * Math.cos(r)},${n * Math.sin(r)}`;
903
+ }).join(" "),
904
+ fill: "none",
905
+ stroke: "var(--color-surface-border)",
906
+ strokeDasharray: "3,3",
907
+ strokeWidth: 1
908
+ }, `grid-${t}`);
909
+ }),
910
+ a.map((e, t) => {
911
+ let n = U * t - Math.PI / 2;
912
+ return /* @__PURE__ */ d("line", {
913
+ x1: 0,
914
+ y1: 0,
915
+ x2: F * Math.cos(n),
916
+ y2: F * Math.sin(n),
917
+ stroke: "var(--color-surface-border)",
918
+ strokeWidth: 1
919
+ }, `axis-${t}`);
920
+ }),
921
+ a.map((e, t) => {
922
+ let n = U * t - Math.PI / 2, r = F + 18, i = r * Math.cos(n), a = r * Math.sin(n), o = "middle";
923
+ return Math.abs(Math.cos(n)) > .1 && (o = Math.cos(n) > 0 ? "start" : "end"), /* @__PURE__ */ d("text", {
924
+ x: i,
925
+ y: a,
926
+ textAnchor: o,
927
+ dominantBaseline: "central",
928
+ className: "fill-surface-fg-muted text-ds-xs",
929
+ children: e
930
+ }, `label-${t}`);
931
+ }),
932
+ Array.from({ length: m }, (e, t) => {
933
+ let n = Math.round(B / m * (t + 1)), r = F / m * (t + 1), i = -Math.PI / 2;
934
+ return /* @__PURE__ */ d("text", {
935
+ x: r * Math.cos(i) + 4,
936
+ y: r * Math.sin(i),
937
+ textAnchor: "start",
938
+ dominantBaseline: "auto",
939
+ className: "fill-surface-fg-subtle text-ds-xs",
940
+ children: n
941
+ }, `level-label-${t}`);
942
+ }),
943
+ o.map((e, t) => {
944
+ let n = G(e.key), r = W(n);
945
+ return r ? /* @__PURE__ */ f("g", { children: [/* @__PURE__ */ d("path", {
946
+ d: r,
947
+ fill: z[t],
948
+ fillOpacity: h,
949
+ stroke: z[t],
950
+ strokeWidth: 2,
951
+ strokeLinejoin: "round"
952
+ }), g && n.map((n, r) => {
953
+ let { x: i, y: a } = K(r, n);
954
+ return /* @__PURE__ */ d("circle", {
955
+ cx: i,
956
+ cy: a,
957
+ r: 4,
958
+ fill: z[t],
959
+ stroke: "var(--color-surface-base)",
960
+ strokeWidth: 2,
961
+ className: "transition-opacity"
962
+ }, `dot-${e.key}-${r}`);
963
+ })] }, e.key) : null;
964
+ }),
965
+ v && a.map((e, t) => {
966
+ let n = U * t - Math.PI / 2;
967
+ return /* @__PURE__ */ d("circle", {
968
+ cx: F * Math.cos(n),
969
+ cy: F * Math.sin(n),
970
+ r: 16,
971
+ fill: "transparent",
972
+ className: "cursor-pointer",
973
+ onMouseMove: (n) => {
974
+ let r = n.currentTarget.closest("div")?.getBoundingClientRect();
975
+ j(n.clientX - (r?.left ?? 0), n.clientY - (r?.top ?? 0), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("div", {
976
+ className: "font-medium",
977
+ children: e
978
+ }), o.map((e, n) => {
979
+ let r = Number(i[t]?.[e.key]) || 0;
980
+ return /* @__PURE__ */ f("div", {
981
+ className: "flex items-center gap-ds-02",
982
+ children: [
983
+ /* @__PURE__ */ d("span", {
984
+ className: "inline-block h-2 w-2 rounded-ds-full",
985
+ style: { backgroundColor: z[n] }
986
+ }),
987
+ /* @__PURE__ */ f("span", {
988
+ className: "text-surface-fg-muted",
989
+ children: [e.label, ":"]
990
+ }),
991
+ " ",
992
+ r.toLocaleString()
993
+ ]
994
+ }, e.key);
995
+ })] }));
996
+ },
997
+ onMouseLeave: M
998
+ }, `hover-${t}`);
999
+ })
1000
+ ]
1001
+ })
1002
+ }), v && /* @__PURE__ */ d(L, { state: A })] }), y && /* @__PURE__ */ d(I, {
1003
+ items: o.map((e, t) => ({
1004
+ label: e.label,
1005
+ color: z[t]
1006
+ })),
1007
+ className: "mt-ds-04"
1008
+ })]
1009
+ });
1010
+ });
1011
+ Q.displayName = "RadarChart";
1012
+ //#endregion
1013
+ export { K as AreaChart, W as BarChart, N as ChartContainer, Z as GaugeChart, I as Legend, G as LineChart, q as PieChart, Q as RadarChart, Y as Sparkline };