@kuntiwar/tonalkit 0.0.0-stage → 1.0.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,2501 @@
1
+ "use client";
2
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+ var _chunkEH6TVKAUcjs = require('./chunk-EH6TVKAU.cjs');
14
+
15
+ // src/provider/ThemeProvider.tsx
16
+ var _react = require('react');
17
+
18
+ // src/utils/cx.ts
19
+ function cx(...values) {
20
+ const out = [];
21
+ for (const v of values) {
22
+ if (!v && v !== 0) continue;
23
+ if (Array.isArray(v)) {
24
+ const inner = cx(...v);
25
+ if (inner) out.push(inner);
26
+ } else out.push(String(v));
27
+ }
28
+ return out.join(" ");
29
+ }
30
+
31
+ // src/provider/ThemeProvider.tsx
32
+ var _jsxruntime = require('react/jsx-runtime');
33
+ var defaultVars = _chunkEH6TVKAUcjs.themeToCssVars.call(void 0, _chunkEH6TVKAUcjs.blueTheme);
34
+ var ThemeContext = _react.createContext.call(void 0, {
35
+ theme: _chunkEH6TVKAUcjs.blueTheme,
36
+ setTheme: () => {
37
+ },
38
+ cssVars: defaultVars
39
+ });
40
+ function resolve(t) {
41
+ return typeof t === "string" ? _nullishCoalesce(_chunkEH6TVKAUcjs.themes[t], () => ( _chunkEH6TVKAUcjs.blueTheme)) : t;
42
+ }
43
+ function ThemeProvider({
44
+ theme: themeProp,
45
+ defaultTheme = "blue",
46
+ onThemeChange,
47
+ target = "wrapper",
48
+ paintSurface = true,
49
+ className,
50
+ style,
51
+ children
52
+ }) {
53
+ const [inner, setInner] = _react.useState.call(void 0, () => resolve(defaultTheme));
54
+ const theme = themeProp !== void 0 ? resolve(themeProp) : inner;
55
+ const setTheme = _react.useCallback.call(void 0,
56
+ (next) => {
57
+ const t = resolve(next);
58
+ if (themeProp === void 0) setInner(t);
59
+ _optionalChain([onThemeChange, 'optionalCall', _3 => _3(t)]);
60
+ },
61
+ [themeProp, onThemeChange]
62
+ );
63
+ const cssVars = _react.useMemo.call(void 0, () => _chunkEH6TVKAUcjs.themeToCssVars.call(void 0, theme), [theme]);
64
+ const value = _react.useMemo.call(void 0, () => ({ theme, setTheme, cssVars }), [theme, setTheme, cssVars]);
65
+ _react.useEffect.call(void 0, () => {
66
+ if (target !== "root") return;
67
+ const el = document.documentElement;
68
+ const entries = Object.entries(cssVars);
69
+ for (const [k, v] of entries) el.style.setProperty(k, v);
70
+ const prevScheme = el.style.colorScheme;
71
+ el.style.colorScheme = theme.mode;
72
+ el.dataset.tkTheme = theme.name;
73
+ return () => {
74
+ for (const [k] of entries) el.style.removeProperty(k);
75
+ el.style.colorScheme = prevScheme;
76
+ delete el.dataset.tkTheme;
77
+ };
78
+ }, [target, cssVars, theme]);
79
+ if (target === "root") {
80
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThemeContext.Provider, { value, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cx("tk-root", paintSurface && "tk-root--surface", className), "data-tk-theme": theme.name, style, children }) });
81
+ }
82
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThemeContext.Provider, { value, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
83
+ "div",
84
+ {
85
+ className: cx("tk-root", paintSurface && "tk-root--surface", className),
86
+ "data-tk-theme": theme.name,
87
+ style: { ...cssVars, colorScheme: theme.mode, ...style },
88
+ children
89
+ }
90
+ ) });
91
+ }
92
+ function useTheme() {
93
+ return _react.useContext.call(void 0, ThemeContext);
94
+ }
95
+
96
+ // src/hooks/useMediaQuery.ts
97
+
98
+ function useMediaQuery(query) {
99
+ const subscribe = _react.useCallback.call(void 0,
100
+ (cb) => {
101
+ if (typeof window === "undefined" || !window.matchMedia) return () => {
102
+ };
103
+ const mql = window.matchMedia(query);
104
+ mql.addEventListener("change", cb);
105
+ return () => mql.removeEventListener("change", cb);
106
+ },
107
+ [query]
108
+ );
109
+ const get = () => typeof window !== "undefined" && window.matchMedia ? window.matchMedia(query).matches : false;
110
+ return _react.useSyncExternalStore.call(void 0, subscribe, get, () => false);
111
+ }
112
+ function useBreakpointUp(bp) {
113
+ return useMediaQuery(`(min-width: ${_chunkEH6TVKAUcjs.breakpoints[bp]}px)`);
114
+ }
115
+ function useBreakpoint() {
116
+ const sm = useBreakpointUp("sm");
117
+ const md = useBreakpointUp("md");
118
+ const lg = useBreakpointUp("lg");
119
+ const xl = useBreakpointUp("xl");
120
+ const flags = [true, sm, md, lg, xl];
121
+ let current = "xs";
122
+ _chunkEH6TVKAUcjs.breakpointKeys.forEach((k, i) => {
123
+ if (flags[i]) current = k;
124
+ });
125
+ return current;
126
+ }
127
+
128
+ // src/hooks/useControllableState.ts
129
+
130
+ function useControllableState({ value, defaultValue, onChange }) {
131
+ const [inner, setInner] = _react.useState.call(void 0, defaultValue);
132
+ const controlled = value !== void 0;
133
+ const current = controlled ? value : inner;
134
+ const onChangeRef = _react.useRef.call(void 0, onChange);
135
+ onChangeRef.current = onChange;
136
+ const currentRef = _react.useRef.call(void 0, current);
137
+ currentRef.current = current;
138
+ const set = _react.useCallback.call(void 0,
139
+ (next) => {
140
+ if (Object.is(next, currentRef.current)) return;
141
+ if (!controlled) setInner(next);
142
+ _optionalChain([onChangeRef, 'access', _4 => _4.current, 'optionalCall', _5 => _5(next)]);
143
+ },
144
+ [controlled]
145
+ );
146
+ return [current, set];
147
+ }
148
+
149
+ // src/layout/Container.tsx
150
+
151
+
152
+ var Container = _react.forwardRef.call(void 0, function Container2({ maxWidth = "lg", disableGutters, as: Tag = "div", className, ...rest }, ref) {
153
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
154
+ Tag,
155
+ {
156
+ ref,
157
+ className: cx("tk-container", maxWidth ? `tk-container--${maxWidth}` : "tk-container--fluid", disableGutters && "tk-container--disable-gutters", className),
158
+ ...rest
159
+ }
160
+ );
161
+ });
162
+
163
+ // src/layout/Grid.tsx
164
+
165
+
166
+ var unit = (n) => `calc(var(--tk-space, 4px) * ${n})`;
167
+ var Grid = _react.forwardRef.call(void 0, function Grid2({ columns = 12, gap = 4, rowGap, columnGap, alignItems, justifyItems, as: Tag = "div", className, style, ...rest }, ref) {
168
+ const s = {
169
+ "--tk-grid-cols": columns,
170
+ "--tk-grid-row-gap": unit(_nullishCoalesce(rowGap, () => ( gap))),
171
+ "--tk-grid-col-gap": unit(_nullishCoalesce(columnGap, () => ( gap))),
172
+ alignItems,
173
+ justifyItems,
174
+ ...style
175
+ };
176
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tag, { ref, className: cx("tk-grid", className), style: s, ...rest });
177
+ });
178
+ var Col = _react.forwardRef.call(void 0, function Col2({ span, xs, sm, md, lg, xl, offset, full, as: Tag = "div", className, style, ...rest }, ref) {
179
+ const spans = { xs: _nullishCoalesce(xs, () => ( span)), sm, md, lg, xl };
180
+ const offsets = typeof offset === "number" ? { xs: offset } : _nullishCoalesce(offset, () => ( {}));
181
+ const classes = [];
182
+ for (const bp of _chunkEH6TVKAUcjs.breakpointKeys) {
183
+ const v = spans[bp];
184
+ if (v !== void 0) classes.push(v === "auto" ? `tk-col-${bp}-auto` : `tk-col-${bp}-${Math.min(12, Math.max(1, v))}`);
185
+ const o = offsets[bp];
186
+ if (o !== void 0) classes.push(`tk-col-offset-${bp}-${Math.min(11, Math.max(0, o))}`);
187
+ }
188
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
189
+ Tag,
190
+ {
191
+ ref,
192
+ className: cx("tk-col", full && "tk-col--full", classes, className),
193
+ style: { minWidth: 0, ...style },
194
+ ...rest
195
+ }
196
+ );
197
+ });
198
+
199
+ // src/layout/Stack.tsx
200
+
201
+
202
+ var Stack = _react.forwardRef.call(void 0, function Stack2({ direction = "column", spacing = 2, alignItems, justifyContent, wrap, divider, as: Tag = "div", className, style, children, ...rest }, ref) {
203
+ const items = _react.Children.toArray(children);
204
+ const content = divider ? items.flatMap((child, i) => {
205
+ const key = _react.isValidElement.call(void 0, child) && child.key != null ? String(child.key) : String(i);
206
+ return i === 0 ? [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: child }, key)] : [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: divider }, `d-${key}`), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: child }, key)];
207
+ }) : items;
208
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
209
+ Tag,
210
+ {
211
+ ref,
212
+ className: cx("tk-stack", `tk-stack--${direction}`, wrap && "tk-stack--wrap", className),
213
+ style: { gap: `calc(var(--tk-space, 4px) * ${spacing})`, alignItems, justifyContent, ...style },
214
+ ...rest,
215
+ children: content
216
+ }
217
+ );
218
+ });
219
+
220
+ // src/components/Icon/Icon.tsx
221
+
222
+
223
+ var iconPaths = {
224
+ add: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",
225
+ remove: "M19 13H5v-2h14v2z",
226
+ close: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z",
227
+ check: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z",
228
+ "check-circle": "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z",
229
+ info: "M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z",
230
+ warning: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z",
231
+ error: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",
232
+ "chevron-left": "M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z",
233
+ "chevron-right": "M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z",
234
+ "expand-more": "M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z",
235
+ "expand-less": "M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z",
236
+ "first-page": "M18.41 16.59 13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z",
237
+ "last-page": "M5.59 7.41 10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z",
238
+ menu: "M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z",
239
+ search: "M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z",
240
+ home: "M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z",
241
+ person: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z",
242
+ settings: "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z",
243
+ mail: "M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z",
244
+ notifications: "M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z",
245
+ star: "M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z",
246
+ favorite: "M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z",
247
+ delete: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",
248
+ edit: "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 0 0 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",
249
+ upload: "M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z",
250
+ download: "M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z",
251
+ file: "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13z",
252
+ calendar: "M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z",
253
+ "visibility": "M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z",
254
+ "visibility-off": "M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z",
255
+ "more-vert": "M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z",
256
+ copy: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z",
257
+ folder: "M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z",
258
+ dashboard: "M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z"
259
+ };
260
+ var Icon = _react.forwardRef.call(void 0, function Icon2({ name, size = 24, title, className, children, style, ...rest }, ref) {
261
+ const dim = typeof size === "number" ? `${size}px` : size;
262
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
263
+ "svg",
264
+ {
265
+ ref,
266
+ className: cx("tk-icon", className),
267
+ viewBox: "0 0 24 24",
268
+ width: dim,
269
+ height: dim,
270
+ fill: "currentColor",
271
+ focusable: "false",
272
+ role: title ? "img" : void 0,
273
+ "aria-hidden": title ? void 0 : true,
274
+ "aria-label": title,
275
+ style,
276
+ ...rest,
277
+ children: name ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: iconPaths[name] }) : children
278
+ }
279
+ );
280
+ });
281
+
282
+ // src/hooks/useFloating.ts
283
+
284
+
285
+ // src/hooks/useIsomorphicLayoutEffect.ts
286
+
287
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? _react.useLayoutEffect : _react.useEffect;
288
+
289
+ // src/hooks/useFloating.ts
290
+ var opposite = { top: "bottom", bottom: "top", left: "right", right: "left" };
291
+ var PAD = 8;
292
+ function place(anchor, float, placement, offset) {
293
+ const [side, align = "center"] = placement.split("-");
294
+ let top = 0;
295
+ let left = 0;
296
+ if (side === "top") top = anchor.top - float.height - offset;
297
+ else if (side === "bottom") top = anchor.top + anchor.height + offset;
298
+ else if (side === "left") left = anchor.left - float.width - offset;
299
+ else left = anchor.left + anchor.width + offset;
300
+ if (side === "top" || side === "bottom") {
301
+ if (align === "start") left = anchor.left;
302
+ else if (align === "end") left = anchor.left + anchor.width - float.width;
303
+ else left = anchor.left + anchor.width / 2 - float.width / 2;
304
+ } else {
305
+ if (align === "start") top = anchor.top;
306
+ else if (align === "end") top = anchor.top + anchor.height - float.height;
307
+ else top = anchor.top + anchor.height / 2 - float.height / 2;
308
+ }
309
+ return { top, left };
310
+ }
311
+ function computePosition(anchor, float, placement, offset, vw, vh) {
312
+ const [side, align] = placement.split("-");
313
+ let used = placement;
314
+ let pos = place(anchor, float, placement, offset);
315
+ const overflows = (p) => p.top < PAD || p.left < PAD || p.top + float.height > vh - PAD || p.left + float.width > vw - PAD;
316
+ if (overflows(pos)) {
317
+ const flipped = align ? `${opposite[side]}-${align}` : opposite[side];
318
+ const alt = place(anchor, float, flipped, offset);
319
+ const mainFits = side === "top" || side === "bottom" ? alt.top >= PAD && alt.top + float.height <= vh - PAD : alt.left >= PAD && alt.left + float.width <= vw - PAD;
320
+ if (mainFits) {
321
+ pos = alt;
322
+ used = flipped;
323
+ }
324
+ }
325
+ const left = Math.max(PAD, Math.min(pos.left, vw - float.width - PAD));
326
+ const top = Math.max(PAD, Math.min(pos.top, vh - float.height - PAD));
327
+ return { top, left, placement: used };
328
+ }
329
+ function useFloating({ open, anchorRef, point, placement = "bottom", offset = 8 }) {
330
+ const floatingRef = _react.useRef.call(void 0, null);
331
+ const [state, setState] = _react.useState.call(void 0, null);
332
+ const update = _react.useCallback.call(void 0, () => {
333
+ const el = floatingRef.current;
334
+ if (!el) return;
335
+ let anchor = null;
336
+ if (point) anchor = { top: point.y, left: point.x, width: 0, height: 0 };
337
+ else if (_optionalChain([anchorRef, 'optionalAccess', _6 => _6.current])) {
338
+ const r = anchorRef.current.getBoundingClientRect();
339
+ anchor = { top: r.top, left: r.left, width: r.width, height: r.height };
340
+ }
341
+ if (!anchor) return;
342
+ const fr = el.getBoundingClientRect();
343
+ const next = computePosition(anchor, { top: 0, left: 0, width: fr.width, height: fr.height }, placement, offset, window.innerWidth, window.innerHeight);
344
+ setState((prev) => prev && prev.top === next.top && prev.left === next.left && prev.placement === next.placement ? prev : next);
345
+ }, [anchorRef, point, placement, offset]);
346
+ useIsomorphicLayoutEffect(() => {
347
+ if (!open) {
348
+ setState(null);
349
+ return;
350
+ }
351
+ update();
352
+ }, [open, update]);
353
+ _react.useEffect.call(void 0, () => {
354
+ if (!open) return;
355
+ const onChange = () => update();
356
+ window.addEventListener("resize", onChange);
357
+ window.addEventListener("scroll", onChange, true);
358
+ let ro;
359
+ if (typeof ResizeObserver !== "undefined" && floatingRef.current) {
360
+ ro = new ResizeObserver(onChange);
361
+ ro.observe(floatingRef.current);
362
+ }
363
+ return () => {
364
+ window.removeEventListener("resize", onChange);
365
+ window.removeEventListener("scroll", onChange, true);
366
+ _optionalChain([ro, 'optionalAccess', _7 => _7.disconnect, 'call', _8 => _8()]);
367
+ };
368
+ }, [open, update]);
369
+ const style = {
370
+ position: "fixed",
371
+ top: _nullishCoalesce(_optionalChain([state, 'optionalAccess', _9 => _9.top]), () => ( 0)),
372
+ left: _nullishCoalesce(_optionalChain([state, 'optionalAccess', _10 => _10.left]), () => ( 0)),
373
+ visibility: state ? "visible" : "hidden"
374
+ };
375
+ return { floatingRef, style, placement: _nullishCoalesce(_optionalChain([state, 'optionalAccess', _11 => _11.placement]), () => ( placement)), update };
376
+ }
377
+
378
+ // src/hooks/usePresence.ts
379
+
380
+ function usePresence(open, exitMs = 200) {
381
+ const [mounted, setMounted] = _react.useState.call(void 0, open);
382
+ const [visible, setVisible] = _react.useState.call(void 0, false);
383
+ _react.useEffect.call(void 0, () => {
384
+ if (open) {
385
+ setMounted(true);
386
+ let inner = 0;
387
+ const outer = requestAnimationFrame(() => {
388
+ inner = requestAnimationFrame(() => setVisible(true));
389
+ });
390
+ return () => {
391
+ cancelAnimationFrame(outer);
392
+ cancelAnimationFrame(inner);
393
+ };
394
+ }
395
+ setVisible(false);
396
+ const t = setTimeout(() => setMounted(false), exitMs);
397
+ return () => clearTimeout(t);
398
+ }, [open, exitMs]);
399
+ return { mounted, visible };
400
+ }
401
+
402
+ // src/components/Accordion/Accordion.tsx
403
+
404
+
405
+ // src/components/Collapse/Collapse.tsx
406
+
407
+
408
+ var Collapse = _react.forwardRef.call(void 0, function Collapse2({ open, className, children, ...rest }, ref) {
409
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, className: cx("tk-collapse", open && "tk-collapse--open", className), "aria-hidden": !open, ...rest, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-collapse__inner", children }) });
410
+ });
411
+
412
+ // src/components/Accordion/Accordion.tsx
413
+
414
+ var Ctx = _react.createContext.call(void 0, null);
415
+ var Accordion = _react.forwardRef.call(void 0, function Accordion2({ type = "single", collapsible = true, value, defaultValue = [], onChange, variant = "outlined", className, children, ...rest }, ref) {
416
+ const baseId = _react.useId.call(void 0, );
417
+ const [open, setOpen] = useControllableState({ value, defaultValue, onChange });
418
+ const toggle = (v) => {
419
+ const isOpen = open.includes(v);
420
+ if (type === "multiple") setOpen(isOpen ? open.filter((x) => x !== v) : [...open, v]);
421
+ else if (isOpen) {
422
+ if (collapsible) setOpen([]);
423
+ } else setOpen([v]);
424
+ };
425
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Ctx.Provider, { value: { open, toggle, variant, baseId }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, className: cx("tk-accordion", `tk-accordion--${variant}`, className), ...rest, children }) });
426
+ });
427
+ var AccordionItem = _react.forwardRef.call(void 0, function AccordionItem2({ value, title, subtitle, icon, disabled, className, children, ...rest }, ref) {
428
+ const ctx = _react.useContext.call(void 0, Ctx);
429
+ if (!ctx) throw new Error("AccordionItem must be used inside <Accordion>");
430
+ const isOpen = ctx.open.includes(value);
431
+ const headerId = `${ctx.baseId}-h-${value}`;
432
+ const panelId = `${ctx.baseId}-p-${value}`;
433
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, className: cx("tk-accordion__item", isOpen && "tk-accordion__item--open", disabled && "tk-accordion__item--disabled", className), ...rest, children: [
434
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "tk-accordion__heading", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { type: "button", id: headerId, className: "tk-accordion__trigger", "aria-expanded": isOpen, "aria-controls": panelId, disabled, onClick: () => ctx.toggle(value), children: [
435
+ icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-accordion__icon", children: icon }) : null,
436
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-accordion__titles", children: [
437
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-accordion__title", children: title }),
438
+ subtitle ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-accordion__subtitle", children: subtitle }) : null
439
+ ] }),
440
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "expand-more", className: "tk-accordion__chevron" })
441
+ ] }) }),
442
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Collapse, { open: isOpen, id: panelId, role: "region", "aria-labelledby": headerId, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-accordion__content", children }) })
443
+ ] });
444
+ });
445
+
446
+ // src/components/Alert/Alert.tsx
447
+
448
+
449
+ // src/utils/colors.ts
450
+ var colorClass = (c) => c ? `tk-c-${c}` : void 0;
451
+
452
+ // src/components/Alert/Alert.tsx
453
+
454
+ var defaultIcons = { info: "info", success: "check-circle", warning: "warning", error: "error" };
455
+ var Alert = _react.forwardRef.call(void 0, function Alert2({ severity = "info", variant = "tonal", title, icon, onClose, action, className, children, ...rest }, ref) {
456
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, role: "alert", className: cx("tk-alert", `tk-alert--${variant}`, colorClass(severity), className), ...rest, children: [
457
+ icon !== false ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-alert__icon", children: _nullishCoalesce(icon, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: defaultIcons[severity] }))) }) : null,
458
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-alert__body", children: [
459
+ title ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-alert__title", children: title }) : null,
460
+ children ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-alert__message", children }) : null
461
+ ] }),
462
+ action ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-alert__action", children: action }) : null,
463
+ onClose ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-alert__close", "aria-label": "Close", onClick: onClose, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "close", size: 20 }) }) : null
464
+ ] });
465
+ });
466
+
467
+ // src/components/Avatar/Avatar.tsx
468
+
469
+
470
+ var palette = ["primary", "secondary", "tertiary", "info", "success", "warning", "error"];
471
+ function initialsOf(name) {
472
+ const parts = name.trim().split(/\s+/).filter(Boolean);
473
+ if (parts.length === 0) return "";
474
+ const first = _nullishCoalesce(parts[0][0], () => ( ""));
475
+ const last = parts.length > 1 ? _nullishCoalesce(parts[parts.length - 1][0], () => ( "")) : "";
476
+ return (first + last).toUpperCase();
477
+ }
478
+ function hash(str) {
479
+ let h = 0;
480
+ for (let i = 0; i < str.length; i++) h = h * 31 + str.charCodeAt(i) | 0;
481
+ return Math.abs(h);
482
+ }
483
+ var dims = { sm: 32, md: 40, lg: 56, xl: 96 };
484
+ var Avatar = _react.forwardRef.call(void 0, function Avatar2({ src, alt, name, size = "md", shape = "circle", status, children, className, style, ...rest }, ref) {
485
+ const [failed, setFailed] = _react.useState.call(void 0, false);
486
+ const px = typeof size === "number" ? size : dims[size];
487
+ const tone = name ? palette[hash(name) % palette.length] : "secondary";
488
+ const showImg = src && !failed;
489
+ const content = showImg ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { className: "tk-avatar__img", src, alt: _nullishCoalesce(_nullishCoalesce(alt, () => ( name)), () => ( "")), onError: () => setFailed(true) }) : name ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-label": name, role: "img", children: initialsOf(name) }) : _nullishCoalesce(children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "person", size: px * 0.6 })));
490
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
491
+ "span",
492
+ {
493
+ ref,
494
+ className: cx("tk-avatar", `tk-c-${tone}`, shape === "rounded" && "tk-avatar--rounded", className),
495
+ style: { "--tk-avatar-size": `${px}px`, ...style },
496
+ ...rest,
497
+ children: [
498
+ content,
499
+ status ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: cx("tk-avatar__status", `tk-avatar__status--${status}`), role: "img", "aria-label": status }) : null
500
+ ]
501
+ }
502
+ );
503
+ });
504
+ var AvatarGroup = _react.forwardRef.call(void 0, function AvatarGroup2({ max = 4, size = "md", className, children, ...rest }, ref) {
505
+ const items = _react.Children.toArray(children);
506
+ const shown = items.slice(0, max);
507
+ const extra = items.length - shown.length;
508
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, role: "group", className: cx("tk-avatar-group", className), ...rest, children: [
509
+ shown,
510
+ extra > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Avatar, { size, className: "tk-avatar--more", children: `+${extra}` }) : null
511
+ ] });
512
+ });
513
+
514
+ // src/components/Badge/Badge.tsx
515
+
516
+
517
+ var Badge = _react.forwardRef.call(void 0, function Badge2({ count, content, dot, max = 99, showZero, invisible, color = "error", position = "top-end", overlap = "rectangular", srLabel, children, className, ...rest }, ref) {
518
+ const hidden = invisible || !dot && content === void 0 && (count === void 0 || count === 0 && !showZero);
519
+ let text = content;
520
+ if (text === void 0 && count !== void 0) text = count > max ? `${max}+` : String(count);
521
+ const anchored = children !== void 0;
522
+ const bubbleClass = cx("tk-badge", dot && "tk-badge--dot", hidden && "tk-badge--hidden", anchored && "tk-badge--anchored", anchored && `tk-badge--${position}`, overlap === "circular" && "tk-badge--circular", colorClass(color), !anchored && className);
523
+ const inner = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
524
+ !dot && text,
525
+ srLabel && !hidden ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-visually-hidden", children: srLabel }) : null
526
+ ] });
527
+ if (!anchored) {
528
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ref, className: bubbleClass, ...rest, children: inner });
529
+ }
530
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { ref, className: cx("tk-badge-anchor", className), ...rest, children: [
531
+ children,
532
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: bubbleClass, children: inner })
533
+ ] });
534
+ });
535
+
536
+ // src/components/Breadcrumb/Breadcrumb.tsx
537
+
538
+
539
+ var Breadcrumb = _react.forwardRef.call(void 0, function Breadcrumb2({ items, separator, maxItems, itemsBeforeCollapse = 1, itemsAfterCollapse = 2, className, ...rest }, ref) {
540
+ const [expanded, setExpanded] = _react.useState.call(void 0, false);
541
+ const collapse = !expanded && maxItems !== void 0 && items.length > maxItems;
542
+ const visible = collapse ? [...items.slice(0, itemsBeforeCollapse), "ellipsis", ...items.slice(items.length - itemsAfterCollapse)] : items;
543
+ const sep = _nullishCoalesce(separator, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "chevron-right", size: 18 })));
544
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "nav", { ref, "aria-label": "Breadcrumb", className: cx("tk-breadcrumb", className), ...rest, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { className: "tk-breadcrumb__list", children: visible.map((item, i) => {
545
+ const last = i === visible.length - 1;
546
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: "tk-breadcrumb__item", children: [
547
+ item === "ellipsis" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-breadcrumb__ellipsis", "aria-label": "Show hidden pages", onClick: () => setExpanded(true), children: "\u2026" }) : last ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-breadcrumb__current", "aria-current": "page", children: [
548
+ item.icon,
549
+ item.label
550
+ ] }) : item.href || item.onClick ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "a", { className: "tk-breadcrumb__link", href: item.href, onClick: item.onClick, children: [
551
+ item.icon,
552
+ item.label
553
+ ] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-breadcrumb__text", children: [
554
+ item.icon,
555
+ item.label
556
+ ] }),
557
+ !last ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-breadcrumb__sep", "aria-hidden": "true", children: sep }) : null
558
+ ] }, item === "ellipsis" ? "ellipsis" : i);
559
+ }) }) });
560
+ });
561
+
562
+ // src/components/Button/Button.tsx
563
+
564
+
565
+ // src/components/Loader/Loader.tsx
566
+
567
+
568
+ var sizes = { sm: 16, md: 24, lg: 40 };
569
+ var Spinner = _react.forwardRef.call(void 0, function Spinner2({ size = "md", color, label = "Loading", className, style, ...rest }, ref) {
570
+ const px = typeof size === "number" ? size : sizes[size];
571
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
572
+ "span",
573
+ {
574
+ ref,
575
+ role: "progressbar",
576
+ "aria-label": label,
577
+ className: cx("tk-spinner", colorClass(color), className),
578
+ style: { "--tk-spinner-size": `${px}px`, ...style },
579
+ ...rest,
580
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { viewBox: "0 0 48 48", focusable: "false", "aria-hidden": "true", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { cx: "24", cy: "24", r: "20" }) })
581
+ }
582
+ );
583
+ });
584
+ var Loader = _react.forwardRef.call(void 0, function Loader2({ variant = "spinner", size = "md", color, label, className, ...rest }, ref) {
585
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, role: "status", "aria-live": "polite", className: cx("tk-loader", `tk-loader--${size}`, colorClass(color), className), ...rest, children: [
586
+ variant === "spinner" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { size, color, label: _nullishCoalesce(label, () => ( "Loading")) }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: cx("tk-loader__anim", `tk-loader__anim--${variant}`), "aria-hidden": "true", children: [
587
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "i", {}),
588
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "i", {}),
589
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "i", {})
590
+ ] }),
591
+ label ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-loader__label", children: label }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-visually-hidden", children: "Loading" })
592
+ ] });
593
+ });
594
+
595
+ // src/components/Button/Button.tsx
596
+
597
+ var Button = _react.forwardRef.call(void 0, function Button2({ variant = "filled", size = "md", color = "primary", startIcon, endIcon, loading, fullWidth, iconOnly, shape = "round", selected, badge, as: Tag = "button", className, children, disabled, type, onClick, ...rest }, ref) {
598
+ const isButton = Tag === "button";
599
+ const inactive = disabled || loading;
600
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
601
+ Tag,
602
+ {
603
+ ref,
604
+ className: cx("tk-btn", `tk-btn--${variant}`, `tk-btn--${size}`, colorClass(color), iconOnly && "tk-btn--icon", shape === "square" && "tk-btn--square", fullWidth && "tk-btn--full", selected && "tk-btn--selected", loading && "tk-btn--loading", (startIcon || loading) && !iconOnly && "tk-btn--has-start", endIcon && !iconOnly && "tk-btn--has-end", className),
605
+ type: isButton ? _nullishCoalesce(type, () => ( "button")) : void 0,
606
+ disabled: isButton ? inactive : void 0,
607
+ "aria-disabled": !isButton && inactive ? true : void 0,
608
+ "aria-busy": loading || void 0,
609
+ "aria-pressed": selected === void 0 ? void 0 : selected,
610
+ onClick: inactive ? void 0 : onClick,
611
+ ...rest,
612
+ children: [
613
+ loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { size: size === "lg" ? 24 : 18, className: "tk-btn__spinner" }) : startIcon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-btn__icon", children: startIcon }) : null,
614
+ children !== void 0 && children !== null && !iconOnly ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-btn__label", children }) : iconOnly && !loading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-btn__icon", children }) : null,
615
+ endIcon && !iconOnly ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-btn__icon", children: endIcon }) : null,
616
+ badge !== void 0 && badge !== false ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Badge, { className: "tk-btn__badge", dot: badge === true, content: badge === true ? void 0 : String(badge) }) : null
617
+ ]
618
+ }
619
+ );
620
+ });
621
+
622
+ // src/components/Calendar/Calendar.tsx
623
+
624
+
625
+ // src/components/Calendar/dates.ts
626
+ var startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
627
+ var startOfMonth = (d) => new Date(d.getFullYear(), d.getMonth(), 1);
628
+ var addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
629
+ var addMonths = (d, n) => {
630
+ const target = new Date(d.getFullYear(), d.getMonth() + n, 1);
631
+ const last = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate();
632
+ return new Date(target.getFullYear(), target.getMonth(), Math.min(d.getDate(), last));
633
+ };
634
+ var isSameDay = (a, b) => !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
635
+ var isSameMonth = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();
636
+ var compareDay = (a, b) => startOfDay(a).getTime() - startOfDay(b).getTime();
637
+ var keyOf = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
638
+ function monthGrid(month, weekStartsOn) {
639
+ const first = startOfMonth(month);
640
+ const offset = (first.getDay() - weekStartsOn + 7) % 7;
641
+ const start = addDays(first, -offset);
642
+ return Array.from({ length: 6 }, (_, w) => Array.from({ length: 7 }, (_2, d) => addDays(start, w * 7 + d)));
643
+ }
644
+
645
+ // src/components/Calendar/Calendar.tsx
646
+
647
+ var emptyRange = { start: null, end: null };
648
+ var Calendar = _react.forwardRef.call(void 0, function Calendar2(props, ref) {
649
+ const {
650
+ mode = "single",
651
+ month: monthProp,
652
+ defaultMonth,
653
+ onMonthChange,
654
+ locale = "en-US",
655
+ weekStartsOn = 0,
656
+ min,
657
+ max,
658
+ disabledDate,
659
+ showOutsideDays = true,
660
+ showToday,
661
+ disabled,
662
+ className,
663
+ value: _v,
664
+ defaultValue: _dv,
665
+ onChange: _oc,
666
+ ...rest
667
+ } = props;
668
+ const isRange = mode === "range";
669
+ const [selected, setSelected] = useControllableState({
670
+ value: props.value,
671
+ defaultValue: _nullishCoalesce(props.defaultValue, () => ( (isRange ? emptyRange : null))),
672
+ onChange: (v) => _optionalChain([props, 'access', _12 => _12.onChange, 'optionalCall', _13 => _13(v)])
673
+ });
674
+ const range2 = isRange ? _nullishCoalesce(selected, () => ( emptyRange)) : emptyRange;
675
+ const single = !isRange ? selected : null;
676
+ const today = _react.useMemo.call(void 0, () => startOfDay(/* @__PURE__ */ new Date()), []);
677
+ const initial = _nullishCoalesce(_nullishCoalesce(defaultMonth, () => ( (isRange ? range2.start : single))), () => ( today));
678
+ const [month, setMonthState] = useControllableState({ value: monthProp ? startOfMonth(monthProp) : void 0, defaultValue: startOfMonth(initial), onChange: onMonthChange });
679
+ const [view, setView] = _react.useState.call(void 0, "days");
680
+ const [focusDate, setFocusDate] = _react.useState.call(void 0, () => single && isSameMonth(single, month) ? single : isSameMonth(today, month) ? today : month);
681
+ const [hover, setHover] = _react.useState.call(void 0, null);
682
+ const gridRef = _react.useRef.call(void 0, null);
683
+ const shouldFocus = _react.useRef.call(void 0, false);
684
+ const titleId = _react.useId.call(void 0, );
685
+ const setMonth = (d) => setMonthState(startOfMonth(d));
686
+ const weeks = _react.useMemo.call(void 0, () => monthGrid(month, weekStartsOn), [month, weekStartsOn]);
687
+ const monthLabel = _react.useMemo.call(void 0, () => new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(month), [locale, month]);
688
+ const weekdays = _react.useMemo.call(void 0, () => {
689
+ const short = new Intl.DateTimeFormat(locale, { weekday: "short" });
690
+ const long = new Intl.DateTimeFormat(locale, { weekday: "long" });
691
+ return Array.from({ length: 7 }, (_, i) => {
692
+ const d = new Date(2023, 0, 1 + (i + weekStartsOn) % 7);
693
+ return { short: short.format(d), long: long.format(d) };
694
+ });
695
+ }, [locale, weekStartsOn]);
696
+ const dayLabel = _react.useMemo.call(void 0, () => new Intl.DateTimeFormat(locale, { weekday: "long", year: "numeric", month: "long", day: "numeric" }), [locale]);
697
+ const isDisabled = (d) => !!disabled || !!min && compareDay(d, min) < 0 || !!max && compareDay(d, max) > 0 || !!_optionalChain([disabledDate, 'optionalCall', _14 => _14(d)]);
698
+ _react.useEffect.call(void 0, () => {
699
+ if (!shouldFocus.current) return;
700
+ shouldFocus.current = false;
701
+ _optionalChain([gridRef, 'access', _15 => _15.current, 'optionalAccess', _16 => _16.querySelector, 'call', _17 => _17(`[data-date="${keyOf(focusDate)}"]`), 'optionalAccess', _18 => _18.focus, 'call', _19 => _19()]);
702
+ });
703
+ const moveFocus = (d) => {
704
+ shouldFocus.current = true;
705
+ setFocusDate(d);
706
+ if (!isSameMonth(d, month)) setMonth(d);
707
+ };
708
+ const pick = (d) => {
709
+ if (isDisabled(d)) return;
710
+ setFocusDate(d);
711
+ if (!isRange) {
712
+ setSelected(d);
713
+ if (!isSameMonth(d, month)) setMonth(d);
714
+ return;
715
+ }
716
+ const { start, end } = range2;
717
+ if (!start || start && end) setSelected({ start: d, end: null });
718
+ else if (compareDay(d, start) < 0) setSelected({ start: d, end: null });
719
+ else setSelected({ start, end: d });
720
+ if (!isSameMonth(d, month)) setMonth(d);
721
+ };
722
+ const onKey = (e) => {
723
+ const map = {
724
+ ArrowLeft: addDays(focusDate, -1),
725
+ ArrowRight: addDays(focusDate, 1),
726
+ ArrowUp: addDays(focusDate, -7),
727
+ ArrowDown: addDays(focusDate, 7),
728
+ PageUp: addMonths(focusDate, e.shiftKey ? -12 : -1),
729
+ PageDown: addMonths(focusDate, e.shiftKey ? 12 : 1),
730
+ Home: addDays(focusDate, -((focusDate.getDay() - weekStartsOn + 7) % 7)),
731
+ End: addDays(focusDate, 6 - (focusDate.getDay() - weekStartsOn + 7) % 7)
732
+ };
733
+ const next = map[e.key];
734
+ if (next) {
735
+ e.preventDefault();
736
+ moveFocus(next);
737
+ }
738
+ };
739
+ const years = _react.useMemo.call(void 0, () => {
740
+ const y = month.getFullYear();
741
+ return Array.from({ length: 25 }, (_, i) => y - 12 + i);
742
+ }, [month]);
743
+ const previewEnd = isRange && range2.start && !range2.end ? hover : range2.end;
744
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, className: cx("tk-cal", disabled && "tk-cal--disabled", className), ...rest, children: [
745
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-cal__header", children: [
746
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { type: "button", className: "tk-cal__title", id: titleId, "aria-live": "polite", "aria-expanded": view === "years", onClick: () => setView(view === "days" ? "years" : "days"), disabled, children: [
747
+ monthLabel,
748
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: view === "years" ? "expand-less" : "expand-more", size: 20 })
749
+ ] }),
750
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-cal__nav", children: [
751
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-cal__navbtn", "aria-label": "Previous month", disabled: disabled || view === "years", onClick: () => setMonth(addMonths(month, -1)), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "chevron-left" }) }),
752
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-cal__navbtn", "aria-label": "Next month", disabled: disabled || view === "years", onClick: () => setMonth(addMonths(month, 1)), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "chevron-right" }) })
753
+ ] })
754
+ ] }),
755
+ view === "years" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-cal__years", role: "listbox", "aria-label": "Select year", children: years.map((y) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", role: "option", "aria-selected": y === month.getFullYear(), className: cx("tk-cal__year", y === month.getFullYear() && "tk-cal__year--selected", y === today.getFullYear() && "tk-cal__year--today"), onClick: () => {
756
+ setMonth(new Date(y, month.getMonth(), 1));
757
+ setFocusDate(new Date(y, month.getMonth(), 1));
758
+ setView("days");
759
+ }, children: y }, y)) }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: gridRef, role: "grid", "aria-labelledby": titleId, className: "tk-cal__grid", onKeyDown: onKey, onMouseLeave: () => setHover(null), children: [
760
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "row", className: "tk-cal__row", children: weekdays.map((w, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "columnheader", className: "tk-cal__weekday", "aria-label": w.long, children: w.short.slice(0, 2) }, i)) }),
761
+ weeks.map((week, wi) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "row", className: "tk-cal__row", children: week.map((d) => {
762
+ const outside = !isSameMonth(d, month);
763
+ if (outside && !showOutsideDays) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "gridcell", className: "tk-cal__cell" }, keyOf(d));
764
+ const sel = isRange ? isSameDay(d, range2.start) || isSameDay(d, range2.end) : isSameDay(d, single);
765
+ const lo = range2.start && previewEnd ? compareDay(range2.start, previewEnd) <= 0 ? range2.start : previewEnd : null;
766
+ const hi = range2.start && previewEnd ? compareDay(range2.start, previewEnd) <= 0 ? previewEnd : range2.start : null;
767
+ const inRange = isRange && !!lo && !!hi && compareDay(d, lo) > 0 && compareDay(d, hi) < 0;
768
+ const isStart = isRange && !!lo && isSameDay(d, lo) && !!hi && !isSameDay(lo, hi);
769
+ const isEnd = isRange && !!hi && isSameDay(d, hi) && !!lo && !isSameDay(lo, hi);
770
+ const dis = isDisabled(d);
771
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "gridcell", className: cx("tk-cal__cell", inRange && "tk-cal__cell--range", isStart && "tk-cal__cell--range-start", isEnd && "tk-cal__cell--range-end"), "aria-selected": sel || inRange || void 0, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
772
+ "button",
773
+ {
774
+ type: "button",
775
+ "data-date": keyOf(d),
776
+ tabIndex: isSameDay(d, focusDate) ? 0 : -1,
777
+ "aria-label": dayLabel.format(d),
778
+ "aria-current": isSameDay(d, today) ? "date" : void 0,
779
+ "aria-disabled": dis || void 0,
780
+ disabled: dis,
781
+ className: cx("tk-cal__day", sel && "tk-cal__day--selected", isSameDay(d, today) && "tk-cal__day--today", outside && "tk-cal__day--outside"),
782
+ onClick: () => pick(d),
783
+ onMouseEnter: () => setHover(d),
784
+ onFocus: () => setFocusDate(d),
785
+ children: d.getDate()
786
+ }
787
+ ) }, keyOf(d));
788
+ }) }, wi))
789
+ ] }),
790
+ showToday && view === "days" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-cal__footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-cal__today", disabled: disabled || isDisabled(today), onClick: () => {
791
+ pick(today);
792
+ moveFocus(today);
793
+ }, children: "Today" }) }) : null
794
+ ] });
795
+ });
796
+
797
+ // src/components/Card/Card.tsx
798
+
799
+
800
+ var Card = _react.forwardRef.call(void 0, function Card2({ variant = "elevated", interactive, orientation = "vertical", as: Tag = "div", className, onClick, ...rest }, ref) {
801
+ const clickable = _nullishCoalesce(interactive, () => ( !!onClick));
802
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
803
+ Tag,
804
+ {
805
+ ref,
806
+ className: cx("tk-card", `tk-card--${variant}`, orientation === "horizontal" && "tk-card--horizontal", clickable && "tk-card--interactive", className),
807
+ onClick,
808
+ tabIndex: clickable && Tag === "div" ? 0 : void 0,
809
+ role: clickable && Tag === "div" ? "button" : void 0,
810
+ onKeyDown: clickable && Tag === "div" && onClick ? (e) => {
811
+ if (e.key === "Enter" || e.key === " ") {
812
+ e.preventDefault();
813
+ e.currentTarget.click();
814
+ }
815
+ } : void 0,
816
+ ...rest
817
+ }
818
+ );
819
+ });
820
+ var CardHeader = _react.forwardRef.call(void 0, function CardHeader2({ title, subtitle, avatar, action, className, ...rest }, ref) {
821
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, className: cx("tk-card__header", className), ...rest, children: [
822
+ avatar ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-card__avatar", children: avatar }) : null,
823
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-card__heading", children: [
824
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-card__title", children: title }),
825
+ subtitle ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-card__subtitle", children: subtitle }) : null
826
+ ] }),
827
+ action ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-card__action", children: action }) : null
828
+ ] });
829
+ });
830
+ var CardMedia = _react.forwardRef.call(void 0, function CardMedia2({ src, alt = "", height = 180, className, style, children, ...rest }, ref) {
831
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, className: cx("tk-card__media", className), style: { height, ...style }, ...rest, children: [
832
+ src ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src, alt }) : null,
833
+ children
834
+ ] });
835
+ });
836
+ var CardContent = _react.forwardRef.call(void 0, function CardContent2({ className, ...rest }, ref) {
837
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, className: cx("tk-card__content", className), ...rest });
838
+ });
839
+ var CardActions = _react.forwardRef.call(void 0, function CardActions2({ align = "start", className, ...rest }, ref) {
840
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, className: cx("tk-card__actions", `tk-card__actions--${align}`, className), ...rest });
841
+ });
842
+
843
+ // src/components/Checkbox/Checkbox.tsx
844
+
845
+
846
+ // src/utils/refs.ts
847
+ function mergeRefs(...refs) {
848
+ return (node) => {
849
+ for (const ref of refs) {
850
+ if (!ref) continue;
851
+ if (typeof ref === "function") ref(node);
852
+ else ref.current = node;
853
+ }
854
+ };
855
+ }
856
+
857
+ // src/components/Checkbox/Checkbox.tsx
858
+
859
+ var Checkbox = _react.forwardRef.call(void 0, function Checkbox2({ label, description, indeterminate, error, color, labelPlacement = "end", className, id: idProp, disabled, ...rest }, ref) {
860
+ const autoId = _react.useId.call(void 0, );
861
+ const id = _nullishCoalesce(idProp, () => ( autoId));
862
+ const inner = _react.useRef.call(void 0, null);
863
+ _react.useEffect.call(void 0, () => {
864
+ if (inner.current) inner.current.indeterminate = !!indeterminate;
865
+ }, [indeterminate]);
866
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: cx("tk-check", colorClass(error ? "error" : color), labelPlacement === "start" && "tk-check--reverse", disabled && "tk-check--disabled", className), htmlFor: id, children: [
867
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-check__control", children: [
868
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "input", { ref: mergeRefs(ref, inner), id, type: "checkbox", className: "tk-check__input", disabled, "aria-invalid": error || void 0, ...rest }),
869
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-check__box", "aria-hidden": "true", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { viewBox: "0 0 24 24", className: "tk-check__mark", children: [
870
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { className: "tk-check__tick", d: "M5 12.5l4.5 4.5L19 7.5" }),
871
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { className: "tk-check__dash", d: "M6 12h12" })
872
+ ] }) })
873
+ ] }),
874
+ label || description ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-check__text", children: [
875
+ label ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-check__label", children: label }) : null,
876
+ description ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-check__desc", children: description }) : null
877
+ ] }) : null
878
+ ] });
879
+ });
880
+
881
+ // src/components/Chip/Chip.tsx
882
+
883
+
884
+ var Chip = _react.forwardRef.call(void 0, function Chip2({ variant = "assist", selected, onClick, onDelete, icon, avatar, elevated, disabled, size = "md", className, children, ...rest }, ref) {
885
+ const interactive = !!onClick || variant === "filter";
886
+ const leading = avatar ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-chip__avatar", children: avatar }) : variant === "filter" && selected ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "check", size: 18 }) : icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-chip__icon", children: icon }) : null;
887
+ const main = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
888
+ leading,
889
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-chip__label", children })
890
+ ] });
891
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
892
+ "div",
893
+ {
894
+ ref,
895
+ className: cx("tk-chip", `tk-chip--${variant}`, `tk-chip--${size}`, selected && "tk-chip--selected", elevated && "tk-chip--elevated", disabled && "tk-chip--disabled", onDelete && "tk-chip--deletable", leading && "tk-chip--has-leading", className),
896
+ ...rest,
897
+ children: [
898
+ interactive ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-chip__main", disabled, "aria-pressed": variant === "filter" || selected !== void 0 ? !!selected : void 0, onClick, children: main }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-chip__main", children: main }),
899
+ onDelete ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
900
+ "button",
901
+ {
902
+ type: "button",
903
+ className: "tk-chip__delete",
904
+ disabled,
905
+ "aria-label": "Remove",
906
+ onClick: onDelete,
907
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "close", size: 18 })
908
+ }
909
+ ) : null
910
+ ]
911
+ }
912
+ );
913
+ });
914
+
915
+ // src/components/ContextMenu/ContextMenu.tsx
916
+
917
+
918
+ // src/hooks/useOutsideClick.ts
919
+
920
+ function useOutsideClick(refs, handler, enabled = true) {
921
+ const handlerRef = _react.useRef.call(void 0, handler);
922
+ handlerRef.current = handler;
923
+ const refsRef = _react.useRef.call(void 0, refs);
924
+ refsRef.current = refs;
925
+ _react.useEffect.call(void 0, () => {
926
+ if (!enabled) return;
927
+ const onDown = (e) => {
928
+ const target = e.target;
929
+ if (!target) return;
930
+ if (refsRef.current.some((r) => r.current && r.current.contains(target))) return;
931
+ handlerRef.current(e);
932
+ };
933
+ document.addEventListener("pointerdown", onDown, true);
934
+ return () => document.removeEventListener("pointerdown", onDown, true);
935
+ }, [enabled]);
936
+ }
937
+
938
+ // src/utils/Portal.tsx
939
+
940
+ var _reactdom = require('react-dom');
941
+
942
+ function Portal({ children }) {
943
+ const { theme, cssVars } = useTheme();
944
+ const [mounted, setMounted] = _react.useState.call(void 0, false);
945
+ _react.useEffect.call(void 0, () => setMounted(true), []);
946
+ if (!mounted || typeof document === "undefined") return null;
947
+ return _reactdom.createPortal.call(void 0,
948
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-root tk-portal", "data-tk-theme": theme.name, style: { ...cssVars, colorScheme: theme.mode }, children }),
949
+ document.body
950
+ );
951
+ }
952
+
953
+ // src/components/ContextMenu/ContextMenu.tsx
954
+
955
+ var ContextMenu = _react.forwardRef.call(void 0, function ContextMenu2({ items, trigger = "double-right-click", doubleClickDelay = 500, disabled, onOpenChange, as: Tag = "div", className, children, onKeyDown, ...rest }, ref) {
956
+ const [point, setPoint] = _react.useState.call(void 0, null);
957
+ const open = point !== null;
958
+ const last = _react.useRef.call(void 0, null);
959
+ const menuRef = _react.useRef.call(void 0, null);
960
+ const wrapRef = _react.useRef.call(void 0, null);
961
+ const { floatingRef, style } = useFloating({ open, point, placement: "bottom-start", offset: 2 });
962
+ const setOpen = _react.useCallback.call(void 0, (p) => {
963
+ setPoint(p);
964
+ _optionalChain([onOpenChange, 'optionalCall', _20 => _20(p !== null)]);
965
+ }, [onOpenChange]);
966
+ const close = _react.useCallback.call(void 0, () => {
967
+ setOpen(null);
968
+ _optionalChain([wrapRef, 'access', _21 => _21.current, 'optionalAccess', _22 => _22.focus, 'optionalCall', _23 => _23({ preventScroll: true })]);
969
+ }, [setOpen]);
970
+ const onContextMenu = (e) => {
971
+ if (disabled) return;
972
+ e.preventDefault();
973
+ const now = Date.now();
974
+ const prev = last.current;
975
+ const near = prev && Math.hypot(prev.x - e.clientX, prev.y - e.clientY) < 24;
976
+ if (trigger === "right-click" || prev && near && now - prev.t <= doubleClickDelay) {
977
+ last.current = null;
978
+ setOpen({ x: e.clientX, y: e.clientY });
979
+ } else {
980
+ last.current = { t: now, x: e.clientX, y: e.clientY };
981
+ }
982
+ };
983
+ const handleKeyDown = (e) => {
984
+ _optionalChain([onKeyDown, 'optionalCall', _24 => _24(e)]);
985
+ if (disabled || e.defaultPrevented) return;
986
+ if (e.key === "ContextMenu" || e.shiftKey && e.key === "F10") {
987
+ e.preventDefault();
988
+ const r = e.currentTarget.getBoundingClientRect();
989
+ setOpen({ x: r.left + Math.min(24, r.width / 2), y: r.top + Math.min(24, r.height / 2) });
990
+ }
991
+ };
992
+ useOutsideClick([menuRef], () => setOpen(null), open);
993
+ _react.useEffect.call(void 0, () => {
994
+ if (!open) return;
995
+ const onScroll = () => setOpen(null);
996
+ window.addEventListener("resize", onScroll);
997
+ window.addEventListener("blur", onScroll);
998
+ return () => {
999
+ window.removeEventListener("resize", onScroll);
1000
+ window.removeEventListener("blur", onScroll);
1001
+ };
1002
+ }, [open, setOpen]);
1003
+ _react.useEffect.call(void 0, () => {
1004
+ if (open) _optionalChain([menuRef, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.querySelector, 'call', _27 => _27('[role="menuitem"]:not([aria-disabled="true"])'), 'optionalAccess', _28 => _28.focus, 'call', _29 => _29()]);
1005
+ }, [open]);
1006
+ const enabledItems = () => Array.from(_nullishCoalesce(_optionalChain([menuRef, 'access', _30 => _30.current, 'optionalAccess', _31 => _31.querySelectorAll, 'call', _32 => _32('[role="menuitem"]:not([aria-disabled="true"])')]), () => ( [])));
1007
+ const onMenuKey = (e) => {
1008
+ const els = enabledItems();
1009
+ const i = els.indexOf(document.activeElement);
1010
+ if (e.key === "ArrowDown") {
1011
+ e.preventDefault();
1012
+ _optionalChain([els, 'access', _33 => _33[(i + 1) % els.length], 'optionalAccess', _34 => _34.focus, 'call', _35 => _35()]);
1013
+ } else if (e.key === "ArrowUp") {
1014
+ e.preventDefault();
1015
+ _optionalChain([els, 'access', _36 => _36[(i - 1 + els.length) % els.length], 'optionalAccess', _37 => _37.focus, 'call', _38 => _38()]);
1016
+ } else if (e.key === "Home") {
1017
+ e.preventDefault();
1018
+ _optionalChain([els, 'access', _39 => _39[0], 'optionalAccess', _40 => _40.focus, 'call', _41 => _41()]);
1019
+ } else if (e.key === "End") {
1020
+ e.preventDefault();
1021
+ _optionalChain([els, 'access', _42 => _42[els.length - 1], 'optionalAccess', _43 => _43.focus, 'call', _44 => _44()]);
1022
+ } else if (e.key === "Escape") {
1023
+ e.preventDefault();
1024
+ e.stopPropagation();
1025
+ close();
1026
+ } else if (e.key === "Tab") {
1027
+ e.preventDefault();
1028
+ close();
1029
+ }
1030
+ };
1031
+ const select = (item) => {
1032
+ if (item.disabled) return;
1033
+ setOpen(null);
1034
+ _optionalChain([wrapRef, 'access', _45 => _45.current, 'optionalAccess', _46 => _46.focus, 'optionalCall', _47 => _47({ preventScroll: true })]);
1035
+ _optionalChain([item, 'access', _48 => _48.onSelect, 'optionalCall', _49 => _49()]);
1036
+ };
1037
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1038
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1039
+ Tag,
1040
+ {
1041
+ ref: (n) => {
1042
+ wrapRef.current = n;
1043
+ if (typeof ref === "function") ref(n);
1044
+ else if (ref) ref.current = n;
1045
+ },
1046
+ className: cx("tk-contextmenu-area", className),
1047
+ onContextMenu,
1048
+ onKeyDown: handleKeyDown,
1049
+ ...rest,
1050
+ children
1051
+ }
1052
+ ),
1053
+ open ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Portal, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1054
+ "div",
1055
+ {
1056
+ ref: (n) => {
1057
+ menuRef.current = n;
1058
+ floatingRef.current = n;
1059
+ },
1060
+ role: "menu",
1061
+ "aria-orientation": "vertical",
1062
+ style,
1063
+ className: "tk-menu",
1064
+ onKeyDown: onMenuKey,
1065
+ onContextMenu: (e) => e.preventDefault(),
1066
+ children: items.map((item, i) => {
1067
+ if (item.divider) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "separator", className: "tk-menu__divider" }, _nullishCoalesce(item.id, () => ( `d${i}`)));
1068
+ if (item.heading) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-menu__heading", role: "presentation", children: item.label }, _nullishCoalesce(item.id, () => ( `h${i}`)));
1069
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1070
+ "div",
1071
+ {
1072
+ role: "menuitem",
1073
+ tabIndex: -1,
1074
+ "aria-disabled": item.disabled || void 0,
1075
+ className: cx("tk-menu__item", item.danger && "tk-menu__item--danger", item.disabled && "tk-menu__item--disabled"),
1076
+ onClick: () => select(item),
1077
+ onKeyDown: (e) => {
1078
+ if (e.key === "Enter" || e.key === " ") {
1079
+ e.preventDefault();
1080
+ select(item);
1081
+ }
1082
+ },
1083
+ onMouseMove: (e) => {
1084
+ if (!item.disabled && document.activeElement !== e.currentTarget) e.currentTarget.focus({ preventScroll: true });
1085
+ },
1086
+ children: [
1087
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-menu__icon", children: item.icon }),
1088
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-menu__label", children: item.label }),
1089
+ item.shortcut ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-menu__shortcut", children: item.shortcut }) : null
1090
+ ]
1091
+ },
1092
+ _nullishCoalesce(item.id, () => ( i))
1093
+ );
1094
+ })
1095
+ }
1096
+ ) }) : null
1097
+ ] });
1098
+ });
1099
+
1100
+ // src/components/Dialog/Dialog.tsx
1101
+
1102
+
1103
+ // src/components/Modal/Modal.tsx
1104
+
1105
+
1106
+ // src/hooks/useFocusTrap.ts
1107
+
1108
+ var FOCUSABLE = 'a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[contenteditable="true"]';
1109
+ function useFocusTrap(ref, active) {
1110
+ _react.useEffect.call(void 0, () => {
1111
+ if (!active) return;
1112
+ const node = ref.current;
1113
+ if (!node) return;
1114
+ const previouslyFocused = document.activeElement;
1115
+ const focusables = () => Array.from(node.querySelectorAll(FOCUSABLE)).filter((el) => el.offsetParent !== null || el === document.activeElement);
1116
+ if (!node.contains(document.activeElement)) {
1117
+ const first = _nullishCoalesce(node.querySelector("[data-tk-autofocus]"), () => ( focusables()[0]));
1118
+ (_nullishCoalesce(first, () => ( node))).focus({ preventScroll: true });
1119
+ }
1120
+ const onKeyDown = (e) => {
1121
+ if (e.key !== "Tab") return;
1122
+ const items = focusables();
1123
+ if (items.length === 0) {
1124
+ e.preventDefault();
1125
+ node.focus();
1126
+ return;
1127
+ }
1128
+ const first = items[0];
1129
+ const last = items[items.length - 1];
1130
+ const activeEl = document.activeElement;
1131
+ if (e.shiftKey && (activeEl === first || activeEl === node)) {
1132
+ e.preventDefault();
1133
+ last.focus();
1134
+ } else if (!e.shiftKey && activeEl === last) {
1135
+ e.preventDefault();
1136
+ first.focus();
1137
+ }
1138
+ };
1139
+ node.addEventListener("keydown", onKeyDown);
1140
+ return () => {
1141
+ node.removeEventListener("keydown", onKeyDown);
1142
+ _optionalChain([previouslyFocused, 'optionalAccess', _50 => _50.focus, 'optionalCall', _51 => _51({ preventScroll: true })]);
1143
+ };
1144
+ }, [active, ref]);
1145
+ }
1146
+
1147
+ // src/hooks/useScrollLock.ts
1148
+
1149
+ var locks = 0;
1150
+ var saved = null;
1151
+ function useScrollLock(active) {
1152
+ _react.useEffect.call(void 0, () => {
1153
+ if (!active) return;
1154
+ const body = document.body;
1155
+ if (locks === 0) {
1156
+ saved = { overflow: body.style.overflow, paddingRight: body.style.paddingRight };
1157
+ const scrollbar = window.innerWidth - document.documentElement.clientWidth;
1158
+ body.style.overflow = "hidden";
1159
+ if (scrollbar > 0) body.style.paddingRight = `${scrollbar}px`;
1160
+ }
1161
+ locks += 1;
1162
+ return () => {
1163
+ locks -= 1;
1164
+ if (locks === 0 && saved) {
1165
+ body.style.overflow = saved.overflow;
1166
+ body.style.paddingRight = saved.paddingRight;
1167
+ saved = null;
1168
+ }
1169
+ };
1170
+ }, [active]);
1171
+ }
1172
+
1173
+ // src/components/Modal/Modal.tsx
1174
+
1175
+ var Modal = _react.forwardRef.call(void 0, function Modal2({ open, onClose, size = "md", closeOnBackdrop = true, closeOnEsc = true, role = "dialog", className, backdropClassName, children, onKeyDown, ...rest }, ref) {
1176
+ const { mounted, visible } = usePresence(open, 200);
1177
+ const panelRef = _react.useRef.call(void 0, null);
1178
+ useFocusTrap(panelRef, open && mounted);
1179
+ useScrollLock(open);
1180
+ const onCloseRef = _react.useRef.call(void 0, onClose);
1181
+ onCloseRef.current = onClose;
1182
+ _react.useEffect.call(void 0, () => {
1183
+ if (!open || !closeOnEsc) return;
1184
+ const handler = (e) => {
1185
+ if (e.key !== "Escape" || e.defaultPrevented) return;
1186
+ const all = document.querySelectorAll(".tk-modal");
1187
+ if (all[all.length - 1] !== _optionalChain([panelRef, 'access', _52 => _52.current, 'optionalAccess', _53 => _53.closest, 'call', _54 => _54(".tk-modal")])) return;
1188
+ e.preventDefault();
1189
+ _optionalChain([onCloseRef, 'access', _55 => _55.current, 'optionalCall', _56 => _56()]);
1190
+ };
1191
+ document.addEventListener("keydown", handler);
1192
+ return () => document.removeEventListener("keydown", handler);
1193
+ }, [open, closeOnEsc]);
1194
+ if (!mounted) return null;
1195
+ const onBackdrop = (e) => {
1196
+ if (closeOnBackdrop && e.target === e.currentTarget) _optionalChain([onClose, 'optionalCall', _57 => _57()]);
1197
+ };
1198
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Portal, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cx("tk-modal", visible && "tk-modal--open"), children: [
1199
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cx("tk-modal__backdrop", backdropClassName), "aria-hidden": "true" }),
1200
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-modal__wrap", onMouseDown: onBackdrop, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1201
+ "div",
1202
+ {
1203
+ ref: mergeRefs(ref, panelRef),
1204
+ role,
1205
+ "aria-modal": "true",
1206
+ tabIndex: -1,
1207
+ className: cx("tk-modal__panel", `tk-modal__panel--${size}`, className),
1208
+ onKeyDown: (e) => _optionalChain([onKeyDown, 'optionalCall', _58 => _58(e)]),
1209
+ ...rest,
1210
+ children
1211
+ }
1212
+ ) })
1213
+ ] }) });
1214
+ });
1215
+
1216
+ // src/components/Dialog/Dialog.tsx
1217
+
1218
+ var Dialog = _react.forwardRef.call(void 0, function Dialog2({ title, description, icon, actions, variant = "basic", size = "sm", closeOnBackdrop, className, children, ...rest }, ref) {
1219
+ const titleId = _react.useId.call(void 0, );
1220
+ const descId = _react.useId.call(void 0, );
1221
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1222
+ Modal,
1223
+ {
1224
+ ref,
1225
+ size,
1226
+ role: variant === "alert" ? "alertdialog" : "dialog",
1227
+ closeOnBackdrop: _nullishCoalesce(closeOnBackdrop, () => ( variant !== "alert")),
1228
+ "aria-labelledby": title ? titleId : void 0,
1229
+ "aria-describedby": description ? descId : void 0,
1230
+ className: cx("tk-dialog", icon && "tk-dialog--icon", className),
1231
+ ...rest,
1232
+ children: [
1233
+ icon || title || description ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-dialog__header", children: [
1234
+ icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-dialog__icon", children: icon }) : null,
1235
+ title ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { id: titleId, className: "tk-dialog__title", children: title }) : null,
1236
+ description ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { id: descId, className: "tk-dialog__desc", children: description }) : null
1237
+ ] }) : null,
1238
+ children ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-dialog__body", children }) : null,
1239
+ actions ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-dialog__actions", children: actions }) : null
1240
+ ]
1241
+ }
1242
+ );
1243
+ });
1244
+
1245
+ // src/components/Divider/Divider.tsx
1246
+
1247
+
1248
+ var Divider = _react.forwardRef.call(void 0, function Divider2({ orientation = "horizontal", variant = "full", align = "center", className, children, ...rest }, ref) {
1249
+ const cls = cx("tk-divider", `tk-divider--${orientation}`, variant !== "full" && `tk-divider--${variant}`, children && "tk-divider--labelled", children && `tk-divider--${align}`, className);
1250
+ if (children) {
1251
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, role: "separator", "aria-orientation": orientation, className: cls, ...rest, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-divider__label", children }) });
1252
+ }
1253
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "hr", { ref, "aria-orientation": orientation, className: cls, ...rest });
1254
+ });
1255
+
1256
+ // src/components/FileUpload/FileUpload.tsx
1257
+
1258
+
1259
+ function formatBytes(bytes) {
1260
+ if (bytes < 1024) return `${bytes} B`;
1261
+ const units = ["KB", "MB", "GB"];
1262
+ let n = bytes / 1024;
1263
+ let i = 0;
1264
+ while (n >= 1024 && i < units.length - 1) {
1265
+ n /= 1024;
1266
+ i++;
1267
+ }
1268
+ return `${n.toFixed(n < 10 ? 1 : 0)} ${units[i]}`;
1269
+ }
1270
+ function matchesAccept(file, accept) {
1271
+ if (!accept) return true;
1272
+ const rules = accept.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
1273
+ const name = file.name.toLowerCase();
1274
+ const type = file.type.toLowerCase();
1275
+ return rules.some((r) => r.startsWith(".") ? name.endsWith(r) : r.endsWith("/*") ? type.startsWith(r.slice(0, -1)) : type === r);
1276
+ }
1277
+ var FileUpload = _react.forwardRef.call(void 0, function FileUpload2({ accept, multiple, maxSize, maxFiles, value, defaultValue = [], onChange, onReject, disabled, variant = "dropzone", title, hint, showFileList = true, error, helperText, className, ...rest }, ref) {
1278
+ const [files, setFiles] = useControllableState({ value, defaultValue, onChange });
1279
+ const [dragging, setDragging] = _react.useState.call(void 0, false);
1280
+ const [rejections, setRejections] = _react.useState.call(void 0, []);
1281
+ const inputRef = _react.useRef.call(void 0, null);
1282
+ const id = _react.useId.call(void 0, );
1283
+ const add = (incoming) => {
1284
+ if (disabled || incoming.length === 0) return;
1285
+ const rejected = [];
1286
+ let accepted = [];
1287
+ for (const f of incoming) {
1288
+ if (!matchesAccept(f, accept)) rejected.push({ file: f, reason: "type" });
1289
+ else if (maxSize !== void 0 && f.size > maxSize) rejected.push({ file: f, reason: "size" });
1290
+ else accepted.push(f);
1291
+ }
1292
+ const base = multiple ? files : [];
1293
+ if (!multiple) accepted = accepted.slice(0, 1);
1294
+ if (maxFiles !== void 0) {
1295
+ const room = Math.max(0, maxFiles - base.length);
1296
+ for (const f of accepted.slice(room)) rejected.push({ file: f, reason: "count" });
1297
+ accepted = accepted.slice(0, room);
1298
+ }
1299
+ setRejections(rejected);
1300
+ if (rejected.length) _optionalChain([onReject, 'optionalCall', _59 => _59(rejected)]);
1301
+ if (accepted.length) setFiles([...base, ...accepted]);
1302
+ };
1303
+ const onDrop = (e) => {
1304
+ e.preventDefault();
1305
+ setDragging(false);
1306
+ add(Array.from(e.dataTransfer.files));
1307
+ };
1308
+ const open = () => !disabled && _optionalChain([inputRef, 'access', _60 => _60.current, 'optionalAccess', _61 => _61.click, 'call', _62 => _62()]);
1309
+ const reasonText = (r) => r.reason === "type" ? "file type not allowed" : r.reason === "size" ? `larger than ${formatBytes(_nullishCoalesce(maxSize, () => ( 0)))}` : `limit of ${maxFiles} files reached`;
1310
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, className: cx("tk-upload", disabled && "tk-upload--disabled", error && "tk-upload--error", className), ...rest, children: [
1311
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1312
+ "input",
1313
+ {
1314
+ ref: inputRef,
1315
+ id,
1316
+ type: "file",
1317
+ className: "tk-visually-hidden",
1318
+ accept,
1319
+ multiple,
1320
+ disabled,
1321
+ tabIndex: -1,
1322
+ onChange: (e) => {
1323
+ add(Array.from(_nullishCoalesce(e.target.files, () => ( []))));
1324
+ e.target.value = "";
1325
+ }
1326
+ }
1327
+ ),
1328
+ variant === "dropzone" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1329
+ "div",
1330
+ {
1331
+ role: "button",
1332
+ tabIndex: disabled ? -1 : 0,
1333
+ "aria-disabled": disabled,
1334
+ className: cx("tk-upload__zone", dragging && "tk-upload__zone--drag"),
1335
+ onClick: open,
1336
+ onKeyDown: (e) => {
1337
+ if (e.key === "Enter" || e.key === " ") {
1338
+ e.preventDefault();
1339
+ open();
1340
+ }
1341
+ },
1342
+ onDragOver: (e) => {
1343
+ e.preventDefault();
1344
+ if (!disabled) setDragging(true);
1345
+ },
1346
+ onDragLeave: () => setDragging(false),
1347
+ onDrop,
1348
+ children: [
1349
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "upload", size: 32, className: "tk-upload__icon" }),
1350
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-upload__title", children: _nullishCoalesce(title, () => ( /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1351
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-upload__link", children: "Click to upload" }),
1352
+ " or drag and drop"
1353
+ ] }))) }),
1354
+ hint ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-upload__hint", children: hint }) : null
1355
+ ]
1356
+ }
1357
+ ) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-upload__button-row", children: [
1358
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { variant: "outlined", startIcon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "upload" }), disabled, onClick: open, children: _nullishCoalesce(title, () => ( "Choose file")) }),
1359
+ hint ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-upload__hint", children: hint }) : null
1360
+ ] }),
1361
+ helperText ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-upload__helper", children: helperText }) : null,
1362
+ rejections.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "tk-upload__errors", role: "alert", children: rejections.map((r, i) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { children: [
1363
+ r.file.name,
1364
+ ": ",
1365
+ reasonText(r)
1366
+ ] }, i)) }) : null,
1367
+ showFileList && files.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "tk-upload__list", children: files.map((f, i) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: "tk-upload__item", children: [
1368
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "file", className: "tk-upload__file-icon" }),
1369
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-upload__name", children: f.name }),
1370
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-upload__size", children: formatBytes(f.size) }),
1371
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-upload__remove", "aria-label": `Remove ${f.name}`, disabled, onClick: () => setFiles(files.filter((_, j) => j !== i)), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "close", size: 18 }) })
1372
+ ] }, `${f.name}-${i}`)) }) : null
1373
+ ] });
1374
+ });
1375
+
1376
+ // src/components/Input/Input.tsx
1377
+
1378
+
1379
+ // src/components/Input/FieldShell.tsx
1380
+
1381
+ function FieldShell({
1382
+ id,
1383
+ variant = "outlined",
1384
+ label,
1385
+ helperText,
1386
+ error,
1387
+ disabled,
1388
+ startAdornment,
1389
+ endAdornment,
1390
+ fullWidth,
1391
+ size = "md",
1392
+ focused,
1393
+ filled,
1394
+ multiline,
1395
+ required,
1396
+ counter: counter2,
1397
+ helperId,
1398
+ className,
1399
+ style,
1400
+ children,
1401
+ onContainerMouseDown
1402
+ }) {
1403
+ const floating = focused || filled;
1404
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1405
+ "div",
1406
+ {
1407
+ className: cx("tk-field", `tk-field--${variant}`, `tk-field--${size}`, floating && "tk-field--float", focused && "tk-field--focused", error && "tk-field--error", disabled && "tk-field--disabled", fullWidth && "tk-field--full", multiline && "tk-field--multiline", !!label && "tk-field--has-label", className),
1408
+ style,
1409
+ children: [
1410
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-field__container", onMouseDown: onContainerMouseDown, children: [
1411
+ startAdornment ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-field__adorn tk-field__adorn--start", children: startAdornment }) : null,
1412
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-field__control", children: [
1413
+ children,
1414
+ label ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "tk-field__label", htmlFor: id, children: [
1415
+ label,
1416
+ required ? " *" : ""
1417
+ ] }) : null
1418
+ ] }),
1419
+ endAdornment ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-field__adorn tk-field__adorn--end", children: endAdornment }) : null,
1420
+ variant === "outlined" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "fieldset", { className: "tk-field__outline", "aria-hidden": "true", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "legend", { className: "tk-field__legend", children: label ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
1421
+ label,
1422
+ required ? " *" : ""
1423
+ ] }) : null }) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-field__indicator", "aria-hidden": "true" })
1424
+ ] }),
1425
+ helperText || counter2 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-field__footer", children: [
1426
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { id: helperId, className: "tk-field__helper", children: helperText }),
1427
+ counter2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-field__counter", children: counter2 }) : null
1428
+ ] }) : null
1429
+ ]
1430
+ }
1431
+ );
1432
+ }
1433
+
1434
+ // src/components/Input/Input.tsx
1435
+
1436
+ function setNativeValue(el, value) {
1437
+ const proto = el instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
1438
+ const setter = _optionalChain([Object, 'access', _63 => _63.getOwnPropertyDescriptor, 'call', _64 => _64(proto, "value"), 'optionalAccess', _65 => _65.set]);
1439
+ _optionalChain([setter, 'optionalAccess', _66 => _66.call, 'call', _67 => _67(el, value)]);
1440
+ el.dispatchEvent(new Event("input", { bubbles: true }));
1441
+ }
1442
+ var Input = _react.forwardRef.call(void 0, function Input2({ variant, label, helperText, error, disabled, startAdornment, endAdornment, fullWidth, size, clearable, onClear, showCounter, wrapperClassName, id: idProp, type = "text", value, defaultValue, onChange, onFocus, onBlur, maxLength, required, className, style, ...rest }, ref) {
1443
+ const autoId = _react.useId.call(void 0, );
1444
+ const id = _nullishCoalesce(idProp, () => ( autoId));
1445
+ const helperId = `${id}-helper`;
1446
+ const inner = _react.useRef.call(void 0, null);
1447
+ const [focused, setFocused] = _react.useState.call(void 0, false);
1448
+ const [innerValue, setInnerValue] = _react.useState.call(void 0, String(_nullishCoalesce(defaultValue, () => ( ""))));
1449
+ const [reveal, setReveal] = _react.useState.call(void 0, false);
1450
+ const controlled = value !== void 0;
1451
+ const current = controlled ? String(_nullishCoalesce(value, () => ( ""))) : innerValue;
1452
+ const isPassword = type === "password";
1453
+ const handleChange = (e) => {
1454
+ if (!controlled) setInnerValue(e.target.value);
1455
+ _optionalChain([onChange, 'optionalCall', _68 => _68(e)]);
1456
+ };
1457
+ const trailing = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1458
+ clearable && current && !disabled ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-field__action", "aria-label": "Clear", tabIndex: -1, onClick: () => {
1459
+ if (inner.current) setNativeValue(inner.current, "");
1460
+ _optionalChain([inner, 'access', _69 => _69.current, 'optionalAccess', _70 => _70.focus, 'call', _71 => _71()]);
1461
+ _optionalChain([onClear, 'optionalCall', _72 => _72()]);
1462
+ }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "close", size: 20 }) }) : null,
1463
+ isPassword ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-field__action", "aria-label": reveal ? "Hide password" : "Show password", "aria-pressed": reveal, onClick: () => setReveal((r) => !r), disabled, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: reveal ? "visibility-off" : "visibility", size: 20 }) }) : null,
1464
+ endAdornment
1465
+ ] });
1466
+ const hasTrailing = clearable && current || isPassword || endAdornment;
1467
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1468
+ FieldShell,
1469
+ {
1470
+ id,
1471
+ helperId,
1472
+ variant,
1473
+ label,
1474
+ helperText,
1475
+ error,
1476
+ disabled,
1477
+ startAdornment,
1478
+ endAdornment: hasTrailing ? trailing : void 0,
1479
+ fullWidth,
1480
+ size,
1481
+ focused,
1482
+ filled: current.length > 0,
1483
+ required,
1484
+ className: wrapperClassName,
1485
+ style,
1486
+ counter: showCounter && maxLength ? `${current.length} / ${maxLength}` : void 0,
1487
+ onContainerMouseDown: (e) => {
1488
+ if (e.target !== inner.current && !e.target.closest("button")) {
1489
+ e.preventDefault();
1490
+ _optionalChain([inner, 'access', _73 => _73.current, 'optionalAccess', _74 => _74.focus, 'call', _75 => _75()]);
1491
+ }
1492
+ },
1493
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1494
+ "input",
1495
+ {
1496
+ ref: mergeRefs(ref, inner),
1497
+ id,
1498
+ className: ["tk-field__input", className].filter(Boolean).join(" "),
1499
+ type: isPassword && reveal ? "text" : type,
1500
+ value: controlled ? value : void 0,
1501
+ defaultValue: controlled ? void 0 : defaultValue,
1502
+ disabled,
1503
+ required,
1504
+ maxLength,
1505
+ "aria-invalid": error || void 0,
1506
+ "aria-describedby": helperText ? helperId : void 0,
1507
+ onChange: handleChange,
1508
+ onFocus: (e) => {
1509
+ setFocused(true);
1510
+ _optionalChain([onFocus, 'optionalCall', _76 => _76(e)]);
1511
+ },
1512
+ onBlur: (e) => {
1513
+ setFocused(false);
1514
+ _optionalChain([onBlur, 'optionalCall', _77 => _77(e)]);
1515
+ },
1516
+ ...rest
1517
+ }
1518
+ )
1519
+ }
1520
+ );
1521
+ });
1522
+
1523
+ // src/components/InputTags/InputTags.tsx
1524
+
1525
+
1526
+ var InputTags = _react.forwardRef.call(void 0, function InputTags2({ value, defaultValue = [], onChange, placeholder, delimiters = ["Enter", ","], max, allowDuplicates = false, validate, addOnBlur = true, onReject, variant, label, helperText, error, disabled, startAdornment, endAdornment, fullWidth, size, id: idProp, name, className }, ref) {
1527
+ const autoId = _react.useId.call(void 0, );
1528
+ const id = _nullishCoalesce(idProp, () => ( autoId));
1529
+ const [tags, setTags] = useControllableState({ value, defaultValue, onChange });
1530
+ const [text, setText] = _react.useState.call(void 0, "");
1531
+ const [focused, setFocused] = _react.useState.call(void 0, false);
1532
+ const [invalid, setInvalid] = _react.useState.call(void 0, null);
1533
+ const inputRef = _react.useRef.call(void 0, null);
1534
+ const commit = (raw) => {
1535
+ const tag = raw.trim();
1536
+ if (!tag) return false;
1537
+ if (max !== void 0 && tags.length >= max) {
1538
+ _optionalChain([onReject, 'optionalCall', _78 => _78(tag, "max")]);
1539
+ return false;
1540
+ }
1541
+ if (!allowDuplicates && tags.includes(tag)) {
1542
+ _optionalChain([onReject, 'optionalCall', _79 => _79(tag, "duplicate")]);
1543
+ return false;
1544
+ }
1545
+ if (validate) {
1546
+ const res = validate(tag);
1547
+ if (res !== true) {
1548
+ setInvalid(typeof res === "string" ? res : "Invalid value");
1549
+ _optionalChain([onReject, 'optionalCall', _80 => _80(tag, "invalid")]);
1550
+ return false;
1551
+ }
1552
+ }
1553
+ setInvalid(null);
1554
+ setTags([...tags, tag]);
1555
+ return true;
1556
+ };
1557
+ const onKeyDown = (e) => {
1558
+ if (delimiters.includes(e.key)) {
1559
+ if (text.trim()) {
1560
+ e.preventDefault();
1561
+ if (commit(text)) setText("");
1562
+ } else if (e.key === ",") e.preventDefault();
1563
+ } else if (e.key === "Backspace" && !text && tags.length) {
1564
+ setTags(tags.slice(0, -1));
1565
+ }
1566
+ };
1567
+ const onPaste = (e) => {
1568
+ const pasted = e.clipboardData.getData("text");
1569
+ if (!/[,\n]/.test(pasted)) return;
1570
+ e.preventDefault();
1571
+ let next = [...tags];
1572
+ for (const part of pasted.split(/[,\n]/)) {
1573
+ const t = part.trim();
1574
+ if (!t || max !== void 0 && next.length >= max || !allowDuplicates && next.includes(t)) continue;
1575
+ if (validate && validate(t) !== true) continue;
1576
+ next = [...next, t];
1577
+ }
1578
+ setTags(next);
1579
+ };
1580
+ const helperId = `${id}-helper`;
1581
+ const message = _nullishCoalesce(invalid, () => ( helperText));
1582
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1583
+ FieldShell,
1584
+ {
1585
+ id,
1586
+ helperId,
1587
+ variant,
1588
+ label,
1589
+ helperText: message,
1590
+ error: error || !!invalid,
1591
+ disabled,
1592
+ startAdornment,
1593
+ endAdornment,
1594
+ fullWidth,
1595
+ size,
1596
+ className,
1597
+ focused,
1598
+ filled: tags.length > 0 || text.length > 0,
1599
+ multiline: true,
1600
+ counter: max !== void 0 ? `${tags.length} / ${max}` : void 0,
1601
+ onContainerMouseDown: (e) => {
1602
+ if (!e.target.closest("button")) {
1603
+ e.preventDefault();
1604
+ _optionalChain([inputRef, 'access', _81 => _81.current, 'optionalAccess', _82 => _82.focus, 'call', _83 => _83()]);
1605
+ }
1606
+ },
1607
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-field__tags", children: [
1608
+ tags.map((tag, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Chip, { variant: "input", size: "md", disabled, onDelete: () => setTags(tags.filter((_, j) => j !== i)), children: tag }, `${tag}-${i}`)),
1609
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1610
+ "input",
1611
+ {
1612
+ ref: (node) => {
1613
+ inputRef.current = node;
1614
+ if (typeof ref === "function") ref(node);
1615
+ else if (ref) ref.current = node;
1616
+ },
1617
+ id,
1618
+ name,
1619
+ className: "tk-field__input",
1620
+ value: text,
1621
+ disabled,
1622
+ placeholder,
1623
+ autoComplete: "off",
1624
+ "aria-invalid": error || !!invalid || void 0,
1625
+ "aria-describedby": message ? helperId : void 0,
1626
+ onChange: (e) => {
1627
+ setText(e.target.value);
1628
+ if (invalid) setInvalid(null);
1629
+ },
1630
+ onKeyDown,
1631
+ onPaste,
1632
+ onFocus: () => setFocused(true),
1633
+ onBlur: () => {
1634
+ setFocused(false);
1635
+ if (addOnBlur && text.trim() && commit(text)) setText("");
1636
+ }
1637
+ }
1638
+ )
1639
+ ] })
1640
+ }
1641
+ );
1642
+ });
1643
+
1644
+ // src/components/Navbar/Navbar.tsx
1645
+
1646
+
1647
+ var Navbar = _react.forwardRef.call(void 0, function Navbar2({ brand, title, links, actions, onMenuClick, position = "static", variant = "surface", elevateOnScroll, bordered, className, ...rest }, ref) {
1648
+ const [scrolled, setScrolled] = _react.useState.call(void 0, false);
1649
+ _react.useEffect.call(void 0, () => {
1650
+ if (!elevateOnScroll) return;
1651
+ const onScroll = () => setScrolled(window.scrollY > 4);
1652
+ onScroll();
1653
+ window.addEventListener("scroll", onScroll, { passive: true });
1654
+ return () => window.removeEventListener("scroll", onScroll);
1655
+ }, [elevateOnScroll]);
1656
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1657
+ "header",
1658
+ {
1659
+ ref,
1660
+ className: cx("tk-navbar", `tk-navbar--${variant}`, `tk-navbar--${position}`, (scrolled || bordered) && "tk-navbar--raised", scrolled && "tk-navbar--scrolled", className),
1661
+ ...rest,
1662
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-navbar__inner", children: [
1663
+ onMenuClick ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-navbar__menu", "aria-label": "Open menu", onClick: onMenuClick, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "menu" }) }) : null,
1664
+ brand ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-navbar__brand", children: brand }) : null,
1665
+ title ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-navbar__title", children: title }) : null,
1666
+ _optionalChain([links, 'optionalAccess', _84 => _84.length]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "nav", { className: "tk-navbar__links", "aria-label": "Primary", children: links.map((l, i) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1667
+ "a",
1668
+ {
1669
+ className: cx("tk-navbar__link", l.active && "tk-navbar__link--active", l.disabled && "tk-navbar__link--disabled"),
1670
+ href: l.href,
1671
+ "aria-current": l.active ? "page" : void 0,
1672
+ "aria-disabled": l.disabled || void 0,
1673
+ onClick: l.disabled ? (e) => e.preventDefault() : l.onClick,
1674
+ children: [
1675
+ l.icon,
1676
+ l.label
1677
+ ]
1678
+ },
1679
+ i
1680
+ )) }) : null,
1681
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-navbar__spacer" }),
1682
+ actions ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-navbar__actions", children: actions }) : null
1683
+ ] })
1684
+ }
1685
+ );
1686
+ });
1687
+
1688
+ // src/components/Pagination/Pagination.tsx
1689
+
1690
+
1691
+ var range = (start, end) => Array.from({ length: Math.max(0, end - start + 1) }, (_, i) => start + i);
1692
+ function usePagination({ count, page, siblingCount = 1, boundaryCount = 1, showFirstLast = false }) {
1693
+ return _react.useMemo.call(void 0, () => {
1694
+ const startPages = range(1, Math.min(boundaryCount, count));
1695
+ const endPages = range(Math.max(count - boundaryCount + 1, boundaryCount + 1), count);
1696
+ const siblingsStart = Math.max(Math.min(page - siblingCount, count - boundaryCount - siblingCount * 2 - 1), boundaryCount + 2);
1697
+ const siblingsEnd = Math.min(Math.max(page + siblingCount, boundaryCount + siblingCount * 2 + 2), endPages.length > 0 ? endPages[0] - 2 : count - 1);
1698
+ const items = [
1699
+ ...showFirstLast ? ["first"] : [],
1700
+ "prev",
1701
+ ...startPages,
1702
+ ...siblingsStart > boundaryCount + 2 ? ["start-ellipsis"] : boundaryCount + 1 < count - boundaryCount ? [boundaryCount + 1] : [],
1703
+ ...range(siblingsStart, siblingsEnd),
1704
+ ...siblingsEnd < count - boundaryCount - 1 ? ["end-ellipsis"] : count - boundaryCount > boundaryCount ? [count - boundaryCount] : [],
1705
+ ...endPages,
1706
+ "next",
1707
+ ...showFirstLast ? ["last"] : []
1708
+ ];
1709
+ return items;
1710
+ }, [count, page, siblingCount, boundaryCount, showFirstLast]);
1711
+ }
1712
+ var Pagination = _react.forwardRef.call(void 0, function Pagination2({ count, page, defaultPage = 1, onChange, siblingCount, boundaryCount, showFirstLast, variant = "text", size = "md", shape = "round", disabled, className, ...rest }, ref) {
1713
+ const [current, setCurrent] = useControllableState({ value: page, defaultValue: defaultPage, onChange });
1714
+ const items = usePagination({ count, page: current, siblingCount, boundaryCount, showFirstLast });
1715
+ const go = (p) => !disabled && p >= 1 && p <= count && setCurrent(p);
1716
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "nav", { ref, "aria-label": "Pagination", className: cx("tk-pagination", `tk-pagination--${variant}`, `tk-pagination--${size}`, shape === "square" && "tk-pagination--square", className), ...rest, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "tk-pagination__list", children: items.map((item, i) => {
1717
+ if (item === "start-ellipsis" || item === "end-ellipsis") return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { className: "tk-pagination__ellipsis", "aria-hidden": "true", children: "\u2026" }, item);
1718
+ const nav = typeof item === "string";
1719
+ const target = item === "prev" ? current - 1 : item === "next" ? current + 1 : item === "first" ? 1 : item === "last" ? count : item;
1720
+ const isDisabled = disabled || nav && (item === "prev" || item === "first" ? current <= 1 : current >= count);
1721
+ const selected = !nav && item === current;
1722
+ const label = item === "prev" ? "Previous page" : item === "next" ? "Next page" : item === "first" ? "First page" : item === "last" ? "Last page" : `Page ${item}`;
1723
+ const icon = item === "prev" ? "chevron-left" : item === "next" ? "chevron-right" : item === "first" ? "first-page" : "last-page";
1724
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: cx("tk-pagination__item", selected && "tk-pagination__item--selected"), "aria-label": label, "aria-current": selected ? "page" : void 0, disabled: isDisabled, onClick: () => go(target), children: nav ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: icon, size: 20 }) : item }) }, `${item}-${i}`);
1725
+ }) }) });
1726
+ });
1727
+
1728
+ // src/components/Panel/Panel.tsx
1729
+
1730
+
1731
+ var Panel = _react.forwardRef.call(void 0, function Panel2({ title, subtitle, icon, headerActions, footer, toggleable, collapsed, defaultCollapsed = false, onToggle, variant = "outlined", className, children, ...rest }, ref) {
1732
+ const id = _react.useId.call(void 0, );
1733
+ const [isCollapsed, setCollapsed] = useControllableState({ value: collapsed, defaultValue: defaultCollapsed, onChange: onToggle });
1734
+ const hasHeader = title || subtitle || icon || headerActions || toggleable;
1735
+ const open = !toggleable || !isCollapsed;
1736
+ const headerContent = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1737
+ icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-panel__icon", children: icon }) : null,
1738
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-panel__titles", children: [
1739
+ title ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-panel__title", children: title }) : null,
1740
+ subtitle ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-panel__subtitle", children: subtitle }) : null
1741
+ ] })
1742
+ ] });
1743
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, className: cx("tk-panel", `tk-panel--${variant}`, className), ...rest, children: [
1744
+ hasHeader ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-panel__header", children: [
1745
+ toggleable ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { type: "button", className: "tk-panel__toggle", "aria-expanded": open, "aria-controls": id, onClick: () => setCollapsed(!isCollapsed), children: [
1746
+ headerContent,
1747
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "expand-more", className: cx("tk-panel__chevron", open && "tk-panel__chevron--open") })
1748
+ ] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-panel__toggle tk-panel__toggle--static", children: headerContent }),
1749
+ headerActions ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-panel__actions", children: headerActions }) : null
1750
+ ] }) : null,
1751
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Collapse, { open, id, children: [
1752
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-panel__body", children }),
1753
+ footer ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-panel__footer", children: footer }) : null
1754
+ ] })
1755
+ ] });
1756
+ });
1757
+
1758
+ // src/components/Popover/Popover.tsx
1759
+
1760
+
1761
+ var Popover = _react.forwardRef.call(void 0, function Popover2({ content, open, defaultOpen = false, onOpenChange, placement = "bottom-start", offset = 8, trigger = "click", closeOnOutsideClick = true, closeOnEsc = true, children, className, anchorClassName, ...rest }, ref) {
1762
+ const id = _react.useId.call(void 0, );
1763
+ const [isOpen, setOpen] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
1764
+ const anchorRef = _react.useRef.call(void 0, null);
1765
+ const panelRef = _react.useRef.call(void 0, null);
1766
+ const hoverTimer = _react.useRef.call(void 0, void 0);
1767
+ const { floatingRef, style } = useFloating({ open: isOpen, anchorRef, placement, offset });
1768
+ const close = _react.useCallback.call(void 0, () => {
1769
+ setOpen(false);
1770
+ }, [setOpen]);
1771
+ useOutsideClick([anchorRef, panelRef], close, isOpen && closeOnOutsideClick);
1772
+ _react.useEffect.call(void 0, () => {
1773
+ if (!isOpen || !closeOnEsc) return;
1774
+ const onKey = (e) => {
1775
+ if (e.key === "Escape") {
1776
+ close();
1777
+ _optionalChain([anchorRef, 'access', _85 => _85.current, 'optionalAccess', _86 => _86.querySelector, 'call', _87 => _87("button,a,[tabindex]"), 'optionalAccess', _88 => _88.focus, 'call', _89 => _89()]);
1778
+ }
1779
+ };
1780
+ document.addEventListener("keydown", onKey);
1781
+ return () => document.removeEventListener("keydown", onKey);
1782
+ }, [isOpen, closeOnEsc, close]);
1783
+ _react.useEffect.call(void 0, () => () => clearTimeout(hoverTimer.current), []);
1784
+ const enter = () => {
1785
+ clearTimeout(hoverTimer.current);
1786
+ setOpen(true);
1787
+ };
1788
+ const leave = () => {
1789
+ hoverTimer.current = setTimeout(close, 150);
1790
+ };
1791
+ const child = _react.isValidElement.call(void 0, children) ? _react.cloneElement.call(void 0, children, { "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-controls": isOpen ? id : void 0 }) : children;
1792
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1793
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1794
+ "span",
1795
+ {
1796
+ ref: anchorRef,
1797
+ className: cx("tk-popover-anchor", anchorClassName),
1798
+ onClick: trigger === "click" ? () => setOpen(!isOpen) : void 0,
1799
+ onMouseEnter: trigger === "hover" ? enter : void 0,
1800
+ onMouseLeave: trigger === "hover" ? leave : void 0,
1801
+ children: child
1802
+ }
1803
+ ),
1804
+ isOpen ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Portal, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1805
+ "div",
1806
+ {
1807
+ ref: (n) => {
1808
+ panelRef.current = n;
1809
+ floatingRef.current = n;
1810
+ if (typeof ref === "function") ref(n);
1811
+ else if (ref) ref.current = n;
1812
+ },
1813
+ id,
1814
+ role: "dialog",
1815
+ style,
1816
+ className: cx("tk-popover", className),
1817
+ onMouseEnter: trigger === "hover" ? enter : void 0,
1818
+ onMouseLeave: trigger === "hover" ? leave : void 0,
1819
+ ...rest,
1820
+ children: content
1821
+ }
1822
+ ) }) : null
1823
+ ] });
1824
+ });
1825
+
1826
+ // src/components/Progress/Progress.tsx
1827
+
1828
+
1829
+ var clamp = (n) => Math.min(100, Math.max(0, n));
1830
+ var ProgressBar = _react.forwardRef.call(void 0, function ProgressBar2({ value, buffer, indeterminate, color, size = "sm", showValue, label, className, ...rest }, ref) {
1831
+ const unknown = indeterminate || value === void 0;
1832
+ const v = clamp(_nullishCoalesce(value, () => ( 0)));
1833
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, className: cx("tk-progress", `tk-progress--${size}`, colorClass(color), className), ...rest, children: [
1834
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1835
+ "div",
1836
+ {
1837
+ className: cx("tk-progress__track", unknown && "tk-progress__track--indeterminate"),
1838
+ role: "progressbar",
1839
+ "aria-label": label,
1840
+ "aria-valuemin": 0,
1841
+ "aria-valuemax": 100,
1842
+ "aria-valuenow": unknown ? void 0 : v,
1843
+ children: [
1844
+ buffer !== void 0 && !unknown ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-progress__buffer", style: { width: `${clamp(buffer)}%` } }) : null,
1845
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-progress__bar", style: unknown ? void 0 : { width: `${v}%` } }),
1846
+ unknown ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-progress__bar tk-progress__bar--2" }) : null
1847
+ ]
1848
+ }
1849
+ ),
1850
+ showValue && !unknown ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-progress__value", children: [
1851
+ Math.round(v),
1852
+ "%"
1853
+ ] }) : null
1854
+ ] });
1855
+ });
1856
+ var ProgressCircle = _react.forwardRef.call(void 0, function ProgressCircle2({ value, indeterminate, color, size = 48, thickness = 4, showValue, label, className, style, ...rest }, ref) {
1857
+ const unknown = indeterminate || value === void 0;
1858
+ const v = clamp(_nullishCoalesce(value, () => ( 0)));
1859
+ const r = (size - thickness) / 2;
1860
+ const c = 2 * Math.PI * r;
1861
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1862
+ "div",
1863
+ {
1864
+ ref,
1865
+ role: "progressbar",
1866
+ "aria-label": label,
1867
+ "aria-valuemin": 0,
1868
+ "aria-valuemax": 100,
1869
+ "aria-valuenow": unknown ? void 0 : v,
1870
+ className: cx("tk-progress-circle", unknown && "tk-progress-circle--indeterminate", colorClass(color), className),
1871
+ style: { width: size, height: size, ...style },
1872
+ ...rest,
1873
+ children: [
1874
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { viewBox: `0 0 ${size} ${size}`, width: size, height: size, "aria-hidden": "true", children: [
1875
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { className: "tk-progress-circle__track", cx: size / 2, cy: size / 2, r, strokeWidth: thickness }),
1876
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1877
+ "circle",
1878
+ {
1879
+ className: "tk-progress-circle__bar",
1880
+ cx: size / 2,
1881
+ cy: size / 2,
1882
+ r,
1883
+ strokeWidth: thickness,
1884
+ strokeDasharray: unknown ? `${c * 0.25} ${c}` : c,
1885
+ strokeDashoffset: unknown ? 0 : c * (1 - v / 100)
1886
+ }
1887
+ )
1888
+ ] }),
1889
+ showValue && !unknown ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-progress-circle__value", children: [
1890
+ Math.round(v),
1891
+ "%"
1892
+ ] }) : null
1893
+ ]
1894
+ }
1895
+ );
1896
+ });
1897
+
1898
+ // src/components/Radio/Radio.tsx
1899
+
1900
+
1901
+ var RadioGroupContext = _react.createContext.call(void 0, null);
1902
+ var RadioGroup = _react.forwardRef.call(void 0, function RadioGroup2({ value, defaultValue, onChange, name, label, orientation = "vertical", disabled, color, className, children, ...rest }, ref) {
1903
+ const autoName = _react.useId.call(void 0, );
1904
+ const labelId = _react.useId.call(void 0, );
1905
+ const [current, setCurrent] = useControllableState({ value, defaultValue, onChange: (v) => v !== void 0 && _optionalChain([onChange, 'optionalCall', _90 => _90(v)]) });
1906
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RadioGroupContext.Provider, { value: { name: _nullishCoalesce(name, () => ( autoName)), value: current, onChange: (v) => setCurrent(v), disabled, color }, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, role: "radiogroup", "aria-labelledby": label ? labelId : void 0, className: cx("tk-radio-group", `tk-radio-group--${orientation}`, className), ...rest, children: [
1907
+ label ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { id: labelId, className: "tk-radio-group__label", children: label }) : null,
1908
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-radio-group__items", children })
1909
+ ] }) });
1910
+ });
1911
+ var Radio = _react.forwardRef.call(void 0, function Radio2({ value, label, description, color, className, id: idProp, disabled, checked, onChange, name, ...rest }, ref) {
1912
+ const group = _react.useContext.call(void 0, RadioGroupContext);
1913
+ const autoId = _react.useId.call(void 0, );
1914
+ const id = _nullishCoalesce(idProp, () => ( autoId));
1915
+ const isDisabled = _nullishCoalesce(disabled, () => ( _optionalChain([group, 'optionalAccess', _91 => _91.disabled])));
1916
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: cx("tk-radio", colorClass(_nullishCoalesce(color, () => ( _optionalChain([group, 'optionalAccess', _92 => _92.color])))), isDisabled && "tk-radio--disabled", className), htmlFor: id, children: [
1917
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-radio__control", children: [
1918
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1919
+ "input",
1920
+ {
1921
+ ref,
1922
+ id,
1923
+ type: "radio",
1924
+ className: "tk-radio__input",
1925
+ name: _nullishCoalesce(_optionalChain([group, 'optionalAccess', _93 => _93.name]), () => ( name)),
1926
+ value,
1927
+ disabled: isDisabled,
1928
+ checked: group ? group.value === value : checked,
1929
+ onChange: (e) => {
1930
+ if (group) group.onChange(value);
1931
+ _optionalChain([onChange, 'optionalCall', _94 => _94(e)]);
1932
+ },
1933
+ ...rest
1934
+ }
1935
+ ),
1936
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-radio__circle", "aria-hidden": "true" })
1937
+ ] }),
1938
+ label || description ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-radio__text", children: [
1939
+ label ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-radio__label", children: label }) : null,
1940
+ description ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-radio__desc", children: description }) : null
1941
+ ] }) : null
1942
+ ] });
1943
+ });
1944
+
1945
+ // src/components/Sidebar/Sidebar.tsx
1946
+
1947
+
1948
+ // src/components/Tooltip/Tooltip.tsx
1949
+
1950
+
1951
+ var Tooltip = _react.forwardRef.call(void 0, function Tooltip2({ content, title, variant = "plain", actions, placement = "top", delay = 300, disabled, children, className, ...rest }, ref) {
1952
+ const id = _react.useId.call(void 0, );
1953
+ const [open, setOpen] = _react.useState.call(void 0, false);
1954
+ const anchorRef = _react.useRef.call(void 0, null);
1955
+ const timer = _react.useRef.call(void 0, void 0);
1956
+ const { floatingRef, style, placement: used } = useFloating({ open, anchorRef, placement, offset: 8 });
1957
+ const show = _react.useCallback.call(void 0, () => {
1958
+ clearTimeout(timer.current);
1959
+ timer.current = setTimeout(() => setOpen(true), delay);
1960
+ }, [delay]);
1961
+ const hide = _react.useCallback.call(void 0, () => {
1962
+ clearTimeout(timer.current);
1963
+ setOpen(false);
1964
+ }, []);
1965
+ _react.useEffect.call(void 0, () => () => clearTimeout(timer.current), []);
1966
+ _react.useEffect.call(void 0, () => {
1967
+ if (!open) return;
1968
+ const onKey = (e) => e.key === "Escape" && hide();
1969
+ document.addEventListener("keydown", onKey);
1970
+ return () => document.removeEventListener("keydown", onKey);
1971
+ }, [open, hide]);
1972
+ const child = _react.isValidElement.call(void 0, children) ? _react.cloneElement.call(void 0, children, { "aria-describedby": open && !disabled ? id : void 0 }) : children;
1973
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1974
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1975
+ "span",
1976
+ {
1977
+ ref: (n) => {
1978
+ anchorRef.current = n;
1979
+ if (typeof ref === "function") ref(n);
1980
+ else if (ref) ref.current = n;
1981
+ },
1982
+ className: cx("tk-tooltip-anchor", className),
1983
+ onMouseEnter: disabled ? void 0 : show,
1984
+ onMouseLeave: variant === "rich" ? () => {
1985
+ timer.current = setTimeout(hide, 120);
1986
+ } : hide,
1987
+ onFocus: disabled ? void 0 : show,
1988
+ onBlur: hide,
1989
+ ...rest,
1990
+ children: child
1991
+ }
1992
+ ),
1993
+ open && !disabled ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Portal, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1994
+ "div",
1995
+ {
1996
+ ref: floatingRef,
1997
+ id,
1998
+ role: "tooltip",
1999
+ style,
2000
+ className: cx("tk-tooltip", `tk-tooltip--${variant}`, `tk-tooltip--${used.split("-")[0]}`),
2001
+ onMouseEnter: () => clearTimeout(timer.current),
2002
+ onMouseLeave: hide,
2003
+ children: [
2004
+ variant === "rich" && title ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-tooltip__title", children: title }) : null,
2005
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-tooltip__content", children: content }),
2006
+ variant === "rich" && actions ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-tooltip__actions", children: actions }) : null
2007
+ ]
2008
+ }
2009
+ ) }) : null
2010
+ ] });
2011
+ });
2012
+
2013
+ // src/components/Sidebar/Sidebar.tsx
2014
+
2015
+ function containsActive(item, id) {
2016
+ return !!id && !!_optionalChain([item, 'access', _95 => _95.children, 'optionalAccess', _96 => _96.some, 'call', _97 => _97((c) => c.id === id || containsActive(c, id))]);
2017
+ }
2018
+ function Node({ item, depth, activeId, collapsed, onSelect }) {
2019
+ const hasChildren = !!_optionalChain([item, 'access', _98 => _98.children, 'optionalAccess', _99 => _99.length]);
2020
+ const [expanded, setExpanded] = _react.useState.call(void 0, () => containsActive(item, activeId));
2021
+ _react.useEffect.call(void 0, () => {
2022
+ if (containsActive(item, activeId)) setExpanded(true);
2023
+ }, [activeId, item]);
2024
+ if (item.divider) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { role: "separator", className: "tk-sidebar__divider" });
2025
+ if (item.heading) return collapsed ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { className: "tk-sidebar__heading", children: item.label });
2026
+ const active = item.id === activeId;
2027
+ const Tag = item.href && !hasChildren ? "a" : "button";
2028
+ const handle = (e) => {
2029
+ if (item.disabled) return;
2030
+ if (hasChildren && !collapsed) setExpanded((v) => !v);
2031
+ _optionalChain([onSelect, 'optionalCall', _100 => _100(item.id, item, e)]);
2032
+ };
2033
+ const iconNode = item.icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-sidebar__icon", children: collapsed && item.badge !== void 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Badge, { dot: true, overlap: "circular", color: "error", children: item.icon }) : item.icon }) : null;
2034
+ const content = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2035
+ Tag,
2036
+ {
2037
+ className: cx("tk-sidebar__item", active && "tk-sidebar__item--active", item.disabled && "tk-sidebar__item--disabled"),
2038
+ ...Tag === "a" ? { href: item.href } : { type: "button" },
2039
+ "aria-current": active ? "page" : void 0,
2040
+ "aria-expanded": hasChildren ? expanded : void 0,
2041
+ "aria-disabled": item.disabled || void 0,
2042
+ disabled: Tag === "button" ? item.disabled : void 0,
2043
+ style: depth > 0 && !collapsed ? { paddingInlineStart: 16 + depth * 16 } : void 0,
2044
+ onClick: handle,
2045
+ children: [
2046
+ iconNode,
2047
+ !collapsed ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-sidebar__label", children: item.label }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-visually-hidden", children: item.label }),
2048
+ !collapsed && item.badge !== void 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-sidebar__badge", children: item.badge }) : null,
2049
+ !collapsed && hasChildren ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "expand-more", size: 20, className: cx("tk-sidebar__chevron", expanded && "tk-sidebar__chevron--open") }) : null
2050
+ ]
2051
+ }
2052
+ );
2053
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: "tk-sidebar__node", children: [
2054
+ collapsed ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tooltip, { content: item.label, placement: "right", delay: 150, children: content }) : content,
2055
+ hasChildren && !collapsed ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Collapse, { open: expanded, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "tk-sidebar__list", children: item.children.map((c) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Node, { item: c, depth: depth + 1, activeId, collapsed: false, onSelect }, c.id)) }) }) : null
2056
+ ] });
2057
+ }
2058
+ var Sidebar = _react.forwardRef.call(void 0, function Sidebar2({ items, activeId, onSelect, collapsed, defaultCollapsed = false, onCollapsedChange, collapsible, header, footer, variant = "permanent", open = false, onClose, width = 280, dense, className, style, "aria-label": ariaLabel = "Main navigation", ...rest }, ref) {
2059
+ const [isCollapsed, setCollapsed] = useControllableState({ value: collapsed, defaultValue: defaultCollapsed, onChange: onCollapsedChange });
2060
+ const temporary = variant === "temporary";
2061
+ const { mounted, visible } = usePresence(temporary && open, 250);
2062
+ const panelRef = _react.useRef.call(void 0, null);
2063
+ useFocusTrap(panelRef, temporary && open && mounted);
2064
+ useScrollLock(temporary && open);
2065
+ const onCloseRef = _react.useRef.call(void 0, onClose);
2066
+ onCloseRef.current = onClose;
2067
+ _react.useEffect.call(void 0, () => {
2068
+ if (!temporary || !open) return;
2069
+ const h = (e) => {
2070
+ if (e.key === "Escape") _optionalChain([onCloseRef, 'access', _101 => _101.current, 'optionalCall', _102 => _102()]);
2071
+ };
2072
+ document.addEventListener("keydown", h);
2073
+ return () => document.removeEventListener("keydown", h);
2074
+ }, [temporary, open]);
2075
+ const rail = !temporary && isCollapsed;
2076
+ const body = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
2077
+ header || collapsible ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-sidebar__header", children: [
2078
+ collapsible && !temporary ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-sidebar__toggle", "aria-label": isCollapsed ? "Expand sidebar" : "Collapse sidebar", "aria-expanded": !isCollapsed, onClick: () => setCollapsed(!isCollapsed), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "menu" }) }) : null,
2079
+ !rail && header ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-sidebar__brand", children: header }) : null
2080
+ ] }) : null,
2081
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "nav", { className: "tk-sidebar__nav", "aria-label": ariaLabel, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "tk-sidebar__list", children: items.map((item) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2082
+ Node,
2083
+ {
2084
+ item,
2085
+ depth: 0,
2086
+ activeId,
2087
+ collapsed: rail,
2088
+ onSelect: (id, it, e) => {
2089
+ _optionalChain([onSelect, 'optionalCall', _103 => _103(id, it, e)]);
2090
+ if (temporary && !_optionalChain([it, 'access', _104 => _104.children, 'optionalAccess', _105 => _105.length])) _optionalChain([onClose, 'optionalCall', _106 => _106()]);
2091
+ }
2092
+ },
2093
+ item.id
2094
+ )) }) }),
2095
+ footer && !rail ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-sidebar__footer", children: footer }) : null
2096
+ ] });
2097
+ if (!temporary) {
2098
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "aside", { ref, className: cx("tk-sidebar", rail && "tk-sidebar--rail", dense && "tk-sidebar--dense", className), style: { width: rail ? 80 : width, ...style }, ...rest, children: body });
2099
+ }
2100
+ if (!mounted) return null;
2101
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Portal, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cx("tk-drawer", visible && "tk-drawer--open"), children: [
2102
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-drawer__scrim", onClick: onClose, "aria-hidden": "true" }),
2103
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2104
+ "aside",
2105
+ {
2106
+ ref: mergeRefs(ref, panelRef),
2107
+ role: "dialog",
2108
+ "aria-modal": "true",
2109
+ "aria-label": ariaLabel,
2110
+ tabIndex: -1,
2111
+ className: cx("tk-sidebar", "tk-sidebar--temporary", dense && "tk-sidebar--dense", className),
2112
+ style: { width, ...style },
2113
+ ...rest,
2114
+ children: body
2115
+ }
2116
+ )
2117
+ ] }) });
2118
+ });
2119
+
2120
+ // src/components/Skeleton/Skeleton.tsx
2121
+
2122
+
2123
+ var Skeleton = _react.forwardRef.call(void 0, function Skeleton2({ variant = "text", width, height, animation = "pulse", lines = 1, className, style, ...rest }, ref) {
2124
+ const base = cx("tk-skeleton", `tk-skeleton--${variant}`, animation && `tk-skeleton--${animation}`);
2125
+ if (variant === "text" && lines > 1) {
2126
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, "aria-hidden": "true", className: cx("tk-skeleton-lines", className), style, ...rest, children: Array.from({ length: lines }, (_, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: base, style: { width: i === lines - 1 ? "60%" : width, height } }, i)) });
2127
+ }
2128
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, "aria-hidden": "true", className: cx(base, className), style: { width, height, ...style }, ...rest });
2129
+ });
2130
+
2131
+ // src/components/Stepper/Stepper.tsx
2132
+
2133
+
2134
+ var Stepper = _react.forwardRef.call(void 0, function Stepper2({ steps, activeStep, orientation = "horizontal", onStepClick, linear = true, alternativeLabel, className, ...rest }, ref) {
2135
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { ref, className: cx("tk-stepper", `tk-stepper--${orientation}`, alternativeLabel && orientation === "horizontal" && "tk-stepper--alt", className), ...rest, children: steps.map((step, i) => {
2136
+ const completed = _nullishCoalesce(step.completed, () => ( i < activeStep));
2137
+ const active = i === activeStep;
2138
+ const clickable = !!onStepClick && !step.disabled && (!linear || completed || active);
2139
+ const state = step.error ? "error" : active ? "active" : completed ? "completed" : "upcoming";
2140
+ const indicator = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-step__indicator", "aria-hidden": "true", children: step.error ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "warning", size: 16 }) : step.icon ? step.icon : completed && !active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "check", size: 16 }) : i + 1 });
2141
+ const labels = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-step__labels", children: [
2142
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-step__label", children: step.label }),
2143
+ step.optional ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-step__desc", children: "Optional" }) : null,
2144
+ step.description ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-step__desc", children: step.description }) : null
2145
+ ] });
2146
+ const head = clickable ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { type: "button", className: "tk-step__head", onClick: () => _optionalChain([onStepClick, 'optionalCall', _107 => _107(i)]), "aria-current": active ? "step" : void 0, children: [
2147
+ indicator,
2148
+ labels
2149
+ ] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-step__head", "aria-current": active ? "step" : void 0, children: [
2150
+ indicator,
2151
+ labels
2152
+ ] });
2153
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: cx("tk-step", `tk-step--${state}`, i === steps.length - 1 && "tk-step--last"), children: [
2154
+ head,
2155
+ orientation === "vertical" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-step__body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Collapse, { open: active && !!step.content, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-step__content", children: step.content }) }) }) : null
2156
+ ] }, i);
2157
+ }) });
2158
+ });
2159
+
2160
+ // src/components/Tabs/Tabs.tsx
2161
+
2162
+
2163
+
2164
+ var Ctx2 = _react.createContext.call(void 0, null);
2165
+ var useTabs = () => {
2166
+ const c = _react.useContext.call(void 0, Ctx2);
2167
+ if (!c) throw new Error("Tab components must be used inside <Tabs>");
2168
+ return c;
2169
+ };
2170
+ var Tabs = _react.forwardRef.call(void 0, function Tabs2({ value, defaultValue, onChange, variant = "primary", fullWidth, className, children, ...rest }, ref) {
2171
+ const baseId = _react.useId.call(void 0, );
2172
+ const [current, setCurrent] = useControllableState({ value, defaultValue, onChange: (v) => v !== void 0 && _optionalChain([onChange, 'optionalCall', _108 => _108(v)]) });
2173
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Ctx2.Provider, { value: { value: current, setValue: (v) => setCurrent(v), baseId, variant, fullWidth }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, className: cx("tk-tabs", className), ...rest, children }) });
2174
+ });
2175
+ var TabList = _react.forwardRef.call(void 0, function TabList2({ className, children, onKeyDown, ...rest }, ref) {
2176
+ const { value, variant, fullWidth } = useTabs();
2177
+ const listRef = _react.useRef.call(void 0, null);
2178
+ const [indicator, setIndicator] = _react.useState.call(void 0, null);
2179
+ useIsomorphicLayoutEffect(() => {
2180
+ const list = listRef.current;
2181
+ if (!list) return;
2182
+ const measure = () => {
2183
+ const active = list.querySelector('[role="tab"][aria-selected="true"]');
2184
+ if (!active) return setIndicator(null);
2185
+ const label = variant === "primary" ? active.querySelector(".tk-tab__content") : null;
2186
+ const target = _nullishCoalesce(label, () => ( active));
2187
+ const lr = list.getBoundingClientRect();
2188
+ const tr = target.getBoundingClientRect();
2189
+ setIndicator({ left: tr.left - lr.left + list.scrollLeft, width: tr.width });
2190
+ _optionalChain([active, 'access', _109 => _109.scrollIntoView, 'optionalCall', _110 => _110({ block: "nearest", inline: "nearest" })]);
2191
+ };
2192
+ measure();
2193
+ const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : void 0;
2194
+ _optionalChain([ro, 'optionalAccess', _111 => _111.observe, 'call', _112 => _112(list)]);
2195
+ return () => _optionalChain([ro, 'optionalAccess', _113 => _113.disconnect, 'call', _114 => _114()]);
2196
+ }, [value, variant, children]);
2197
+ const handleKey = (e) => {
2198
+ _optionalChain([onKeyDown, 'optionalCall', _115 => _115(e)]);
2199
+ const tabs = Array.from(_nullishCoalesce(_optionalChain([listRef, 'access', _116 => _116.current, 'optionalAccess', _117 => _117.querySelectorAll, 'call', _118 => _118('[role="tab"]:not([disabled])')]), () => ( [])));
2200
+ const i = tabs.indexOf(document.activeElement);
2201
+ if (i < 0) return;
2202
+ const rtl = getComputedStyle(listRef.current).direction === "rtl";
2203
+ let next = -1;
2204
+ if (e.key === (rtl ? "ArrowLeft" : "ArrowRight")) next = (i + 1) % tabs.length;
2205
+ else if (e.key === (rtl ? "ArrowRight" : "ArrowLeft")) next = (i - 1 + tabs.length) % tabs.length;
2206
+ else if (e.key === "Home") next = 0;
2207
+ else if (e.key === "End") next = tabs.length - 1;
2208
+ if (next >= 0) {
2209
+ e.preventDefault();
2210
+ tabs[next].focus();
2211
+ tabs[next].click();
2212
+ }
2213
+ };
2214
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: mergeRefs(ref, listRef), role: "tablist", className: cx("tk-tablist", `tk-tablist--${variant}`, fullWidth && "tk-tablist--full", className), onKeyDown: handleKey, ...rest, children: [
2215
+ children,
2216
+ indicator ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-tablist__indicator", style: { transform: `translateX(${indicator.left}px)`, width: indicator.width } }) : null
2217
+ ] });
2218
+ });
2219
+ var Tab = _react.forwardRef.call(void 0, function Tab2({ value, icon, badge, className, children, onClick, ...rest }, ref) {
2220
+ const ctx = useTabs();
2221
+ const selected = ctx.value === value;
2222
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2223
+ "button",
2224
+ {
2225
+ ref,
2226
+ type: "button",
2227
+ role: "tab",
2228
+ id: `${ctx.baseId}-tab-${value}`,
2229
+ "aria-selected": selected,
2230
+ "aria-controls": `${ctx.baseId}-panel-${value}`,
2231
+ tabIndex: selected ? 0 : -1,
2232
+ className: cx("tk-tab", selected && "tk-tab--selected", icon && children && "tk-tab--icon-label", className),
2233
+ onClick: (e) => {
2234
+ _optionalChain([onClick, 'optionalCall', _119 => _119(e)]);
2235
+ if (!e.defaultPrevented) ctx.setValue(value);
2236
+ },
2237
+ ...rest,
2238
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tk-tab__content", children: [
2239
+ icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-tab__icon", children: icon }) : null,
2240
+ children ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-tab__label", children }) : null,
2241
+ badge !== void 0 && badge !== false ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Badge, { className: "tk-tab__badge", dot: badge === true, count: typeof badge === "number" ? badge : void 0 }) : null
2242
+ ] })
2243
+ }
2244
+ );
2245
+ });
2246
+ var TabPanel = _react.forwardRef.call(void 0, function TabPanel2({ value, keepMounted, className, children, ...rest }, ref) {
2247
+ const ctx = useTabs();
2248
+ const active = ctx.value === value;
2249
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, role: "tabpanel", id: `${ctx.baseId}-panel-${value}`, "aria-labelledby": `${ctx.baseId}-tab-${value}`, hidden: !active, tabIndex: 0, className: cx("tk-tabpanel", className), ...rest, children: active || keepMounted ? children : null });
2250
+ });
2251
+
2252
+ // src/components/Textarea/Textarea.tsx
2253
+
2254
+
2255
+ var Textarea = _react.forwardRef.call(void 0, function Textarea2({ variant, label, helperText, error, disabled, startAdornment, endAdornment, fullWidth, size, autoResize, minRows = 3, maxRows, showCounter, id: idProp, value, defaultValue, onChange, onFocus, onBlur, maxLength, required, className, style, ...rest }, ref) {
2256
+ const autoId = _react.useId.call(void 0, );
2257
+ const id = _nullishCoalesce(idProp, () => ( autoId));
2258
+ const helperId = `${id}-helper`;
2259
+ const inner = _react.useRef.call(void 0, null);
2260
+ const [focused, setFocused] = _react.useState.call(void 0, false);
2261
+ const [innerValue, setInnerValue] = _react.useState.call(void 0, String(_nullishCoalesce(defaultValue, () => ( ""))));
2262
+ const controlled = value !== void 0;
2263
+ const current = controlled ? String(_nullishCoalesce(value, () => ( ""))) : innerValue;
2264
+ const resize = _react.useCallback.call(void 0, () => {
2265
+ const el = inner.current;
2266
+ if (!el || !autoResize) return;
2267
+ const cs = getComputedStyle(el);
2268
+ const line = parseFloat(cs.lineHeight) || 24;
2269
+ const pad = parseFloat(cs.paddingTop) + parseFloat(cs.paddingBottom);
2270
+ el.style.height = "auto";
2271
+ const max = maxRows ? line * maxRows + pad : Infinity;
2272
+ el.style.height = `${Math.min(el.scrollHeight, max)}px`;
2273
+ el.style.overflowY = el.scrollHeight > max ? "auto" : "hidden";
2274
+ }, [autoResize, maxRows]);
2275
+ useIsomorphicLayoutEffect(resize, [resize, current]);
2276
+ const handleChange = (e) => {
2277
+ if (!controlled) setInnerValue(e.target.value);
2278
+ _optionalChain([onChange, 'optionalCall', _120 => _120(e)]);
2279
+ };
2280
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2281
+ FieldShell,
2282
+ {
2283
+ id,
2284
+ helperId,
2285
+ variant,
2286
+ label,
2287
+ helperText,
2288
+ error,
2289
+ disabled,
2290
+ startAdornment,
2291
+ endAdornment,
2292
+ fullWidth,
2293
+ size,
2294
+ focused,
2295
+ filled: current.length > 0,
2296
+ multiline: true,
2297
+ required,
2298
+ style,
2299
+ counter: showCounter && maxLength ? `${current.length} / ${maxLength}` : void 0,
2300
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2301
+ "textarea",
2302
+ {
2303
+ ref: mergeRefs(ref, inner),
2304
+ id,
2305
+ className: cx("tk-field__input", "tk-field__textarea", autoResize && "tk-field__textarea--auto", className),
2306
+ rows: minRows,
2307
+ value: controlled ? value : void 0,
2308
+ defaultValue: controlled ? void 0 : defaultValue,
2309
+ disabled,
2310
+ required,
2311
+ maxLength,
2312
+ "aria-invalid": error || void 0,
2313
+ "aria-describedby": helperText ? helperId : void 0,
2314
+ onChange: handleChange,
2315
+ onFocus: (e) => {
2316
+ setFocused(true);
2317
+ _optionalChain([onFocus, 'optionalCall', _121 => _121(e)]);
2318
+ },
2319
+ onBlur: (e) => {
2320
+ setFocused(false);
2321
+ _optionalChain([onBlur, 'optionalCall', _122 => _122(e)]);
2322
+ },
2323
+ ...rest
2324
+ }
2325
+ )
2326
+ }
2327
+ );
2328
+ });
2329
+
2330
+ // src/components/Toast/Toast.tsx
2331
+
2332
+
2333
+ var ToastContext = _react.createContext.call(void 0, null);
2334
+ function useToast() {
2335
+ const ctx = _react.useContext.call(void 0, ToastContext);
2336
+ if (!ctx) throw new Error("useToast must be used inside <ToastProvider>");
2337
+ return ctx;
2338
+ }
2339
+ var icons = { info: "info", success: "check-circle", warning: "warning", error: "error" };
2340
+ function ToastItem({ item, defaultDuration, onDismiss, onRemove }) {
2341
+ const { id, options, closing } = item;
2342
+ const duration = _nullishCoalesce(options.duration, () => ( defaultDuration));
2343
+ const [paused, setPaused] = _react.useState.call(void 0, false);
2344
+ const remaining = _react.useRef.call(void 0, duration);
2345
+ const startedAt = _react.useRef.call(void 0, 0);
2346
+ _react.useEffect.call(void 0, () => {
2347
+ if (closing || duration === 0 || paused) return;
2348
+ startedAt.current = Date.now();
2349
+ const t = setTimeout(() => onDismiss(id), remaining.current);
2350
+ return () => {
2351
+ clearTimeout(t);
2352
+ remaining.current = Math.max(500, remaining.current - (Date.now() - startedAt.current));
2353
+ };
2354
+ }, [closing, duration, paused, id, onDismiss]);
2355
+ _react.useEffect.call(void 0, () => {
2356
+ if (!closing) return;
2357
+ const t = setTimeout(() => onRemove(id), 200);
2358
+ return () => clearTimeout(t);
2359
+ }, [closing, id, onRemove]);
2360
+ const severity = _nullishCoalesce(options.severity, () => ( "neutral"));
2361
+ const icon = options.icon === false ? null : _nullishCoalesce(options.icon, () => ( (severity !== "neutral" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: icons[severity] }) : null)));
2362
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2363
+ "div",
2364
+ {
2365
+ role: severity === "error" ? "alert" : "status",
2366
+ className: cx("tk-toast", `tk-toast--${severity}`, closing && "tk-toast--closing"),
2367
+ onMouseEnter: () => setPaused(true),
2368
+ onMouseLeave: () => setPaused(false),
2369
+ onFocus: () => setPaused(true),
2370
+ onBlur: () => setPaused(false),
2371
+ children: [
2372
+ icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tk-toast__icon", children: icon }) : null,
2373
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tk-toast__body", children: [
2374
+ options.title ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-toast__title", children: options.title }) : null,
2375
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tk-toast__message", children: options.message })
2376
+ ] }),
2377
+ options.action ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-toast__action", onClick: () => {
2378
+ _optionalChain([options, 'access', _123 => _123.action, 'optionalAccess', _124 => _124.onClick, 'optionalCall', _125 => _125()]);
2379
+ onDismiss(id);
2380
+ }, children: options.action.label }) : null,
2381
+ options.closable !== false ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tk-toast__close", "aria-label": "Close", onClick: () => onDismiss(id), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "close", size: 20 }) }) : null
2382
+ ]
2383
+ }
2384
+ );
2385
+ }
2386
+ var counter = 0;
2387
+ function ToastProvider({ children, placement = "bottom-center", duration = 5e3, max = 4 }) {
2388
+ const [items, setItems] = _react.useState.call(void 0, []);
2389
+ const remove = _react.useCallback.call(void 0, (id) => {
2390
+ setItems((list) => {
2391
+ const found = list.find((i) => i.id === id);
2392
+ if (found) _optionalChain([found, 'access', _126 => _126.options, 'access', _127 => _127.onClose, 'optionalCall', _128 => _128()]);
2393
+ return list.filter((i) => i.id !== id);
2394
+ });
2395
+ }, []);
2396
+ const dismiss = _react.useCallback.call(void 0, (id) => setItems((list) => list.map((i) => i.id === id ? { ...i, closing: true } : i)), []);
2397
+ const dismissAll = _react.useCallback.call(void 0, () => setItems((list) => list.map((i) => ({ ...i, closing: true }))), []);
2398
+ const show = _react.useCallback.call(void 0, (options) => {
2399
+ const id = _nullishCoalesce(options.id, () => ( `toast-${++counter}`));
2400
+ setItems((list) => {
2401
+ const without = list.filter((i) => i.id !== id);
2402
+ const next = [...without, { id, options, closing: false }];
2403
+ const active = next.filter((i) => !i.closing);
2404
+ const overflow = active.length - max;
2405
+ if (overflow > 0) {
2406
+ const drop = new Set(active.slice(0, overflow).map((i) => i.id));
2407
+ return next.map((i) => drop.has(i.id) ? { ...i, closing: true } : i);
2408
+ }
2409
+ return next;
2410
+ });
2411
+ return id;
2412
+ }, [max]);
2413
+ const api = _react.useMemo.call(void 0, () => ({
2414
+ show,
2415
+ info: (message, o) => show({ ...o, message, severity: "info" }),
2416
+ success: (message, o) => show({ ...o, message, severity: "success" }),
2417
+ warning: (message, o) => show({ ...o, message, severity: "warning" }),
2418
+ error: (message, o) => show({ ...o, message, severity: "error" }),
2419
+ dismiss,
2420
+ dismissAll
2421
+ }), [show, dismiss, dismissAll]);
2422
+ const ordered = placement.startsWith("top") ? [...items].reverse() : items;
2423
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ToastContext.Provider, { value: api, children: [
2424
+ children,
2425
+ items.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Portal, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cx("tk-toaster", `tk-toaster--${placement}`), children: ordered.map((item) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ToastItem, { item, defaultDuration: duration, onDismiss: dismiss, onRemove: remove }, item.id)) }) }) : null
2426
+ ] });
2427
+ }
2428
+
2429
+
2430
+
2431
+
2432
+
2433
+
2434
+
2435
+
2436
+
2437
+
2438
+
2439
+
2440
+
2441
+
2442
+
2443
+
2444
+
2445
+
2446
+
2447
+
2448
+
2449
+
2450
+
2451
+
2452
+
2453
+
2454
+
2455
+
2456
+
2457
+
2458
+
2459
+
2460
+
2461
+
2462
+
2463
+
2464
+
2465
+
2466
+
2467
+
2468
+
2469
+
2470
+
2471
+
2472
+
2473
+
2474
+
2475
+
2476
+
2477
+
2478
+
2479
+
2480
+
2481
+
2482
+
2483
+
2484
+
2485
+
2486
+
2487
+
2488
+
2489
+
2490
+
2491
+
2492
+
2493
+
2494
+
2495
+
2496
+
2497
+
2498
+
2499
+
2500
+ exports.Accordion = Accordion; exports.AccordionItem = AccordionItem; exports.Alert = Alert; exports.Avatar = Avatar; exports.AvatarGroup = AvatarGroup; exports.Badge = Badge; exports.Breadcrumb = Breadcrumb; exports.Button = Button; exports.Calendar = Calendar; exports.Card = Card; exports.CardActions = CardActions; exports.CardContent = CardContent; exports.CardHeader = CardHeader; exports.CardMedia = CardMedia; exports.Checkbox = Checkbox; exports.Chip = Chip; exports.Col = Col; exports.Collapse = Collapse; exports.Container = Container; exports.ContextMenu = ContextMenu; exports.Dialog = Dialog; exports.Divider = Divider; exports.FileUpload = FileUpload; exports.Grid = Grid; exports.Icon = Icon; exports.Input = Input; exports.InputTags = InputTags; exports.Loader = Loader; exports.Modal = Modal; exports.Navbar = Navbar; exports.Pagination = Pagination; exports.Panel = Panel; exports.Popover = Popover; exports.ProgressBar = ProgressBar; exports.ProgressCircle = ProgressCircle; exports.Radio = Radio; exports.RadioGroup = RadioGroup; exports.Sidebar = Sidebar; exports.Skeleton = Skeleton; exports.Spinner = Spinner; exports.Stack = Stack; exports.Stepper = Stepper; exports.Tab = Tab; exports.TabList = TabList; exports.TabPanel = TabPanel; exports.Tabs = Tabs; exports.Textarea = Textarea; exports.ThemeProvider = ThemeProvider; exports.ToastProvider = ToastProvider; exports.Tooltip = Tooltip; exports.blueTheme = _chunkEH6TVKAUcjs.blueTheme; exports.breakpointKeys = _chunkEH6TVKAUcjs.breakpointKeys; exports.breakpoints = _chunkEH6TVKAUcjs.breakpoints; exports.createTheme = _chunkEH6TVKAUcjs.createTheme; exports.darkTheme = _chunkEH6TVKAUcjs.darkTheme; exports.formatBytes = formatBytes; exports.iconPaths = iconPaths; exports.pinkTheme = _chunkEH6TVKAUcjs.pinkTheme; exports.themeToCss = _chunkEH6TVKAUcjs.themeToCss; exports.themeToCssVars = _chunkEH6TVKAUcjs.themeToCssVars; exports.themes = _chunkEH6TVKAUcjs.themes; exports.typographyScale = _chunkEH6TVKAUcjs.typographyScale; exports.useBreakpoint = useBreakpoint; exports.useBreakpointUp = useBreakpointUp; exports.useControllableState = useControllableState; exports.useFloating = useFloating; exports.useMediaQuery = useMediaQuery; exports.usePagination = usePagination; exports.usePresence = usePresence; exports.useTheme = useTheme; exports.useToast = useToast;
2501
+ //# sourceMappingURL=index.cjs.map