@hanzo/ui 8.0.6 → 8.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/dist/ThemeToggleNext-7727UR5W.js +4 -0
  2. package/dist/ThemeToggleNext-7727UR5W.js.map +1 -0
  3. package/dist/ThemeToggleNext-ICB5KL5J.cjs +19 -0
  4. package/dist/ThemeToggleNext-ICB5KL5J.cjs.map +1 -0
  5. package/dist/billing.cjs +15 -0
  6. package/dist/billing.cjs.map +1 -0
  7. package/{types → dist}/billing.d.ts +0 -1
  8. package/dist/billing.js +4 -0
  9. package/dist/billing.js.map +1 -0
  10. package/dist/canvas.cjs +15 -0
  11. package/dist/canvas.cjs.map +1 -0
  12. package/dist/canvas.d.ts +1 -0
  13. package/dist/canvas.js +4 -0
  14. package/dist/canvas.js.map +1 -0
  15. package/{types → dist}/cd/layout.d.ts +0 -1
  16. package/{types → dist}/cd/status.d.ts +0 -1
  17. package/{types → dist}/cd/time.d.ts +0 -1
  18. package/{types → dist}/cd/types.d.ts +0 -1
  19. package/dist/chunk-42CU5GSF.js +98 -0
  20. package/dist/chunk-42CU5GSF.js.map +1 -0
  21. package/dist/chunk-GDGVXU7W.js +1999 -0
  22. package/dist/chunk-GDGVXU7W.js.map +1 -0
  23. package/dist/chunk-HSPMQQVJ.cjs +2066 -0
  24. package/dist/chunk-HSPMQQVJ.cjs.map +1 -0
  25. package/dist/chunk-YBXVUV7P.cjs +103 -0
  26. package/dist/chunk-YBXVUV7P.cjs.map +1 -0
  27. package/dist/dashboard.cjs +15 -0
  28. package/dist/dashboard.cjs.map +1 -0
  29. package/dist/dashboard.d.ts +1 -0
  30. package/dist/dashboard.js +4 -0
  31. package/dist/dashboard.js.map +1 -0
  32. package/dist/data.cjs +15 -0
  33. package/dist/data.cjs.map +1 -0
  34. package/dist/data.d.ts +1 -0
  35. package/dist/data.js +4 -0
  36. package/dist/data.js.map +1 -0
  37. package/dist/gitops.cjs +15 -0
  38. package/dist/gitops.cjs.map +1 -0
  39. package/dist/gitops.d.ts +1 -0
  40. package/dist/gitops.js +4 -0
  41. package/dist/gitops.js.map +1 -0
  42. package/dist/index.cjs +291 -0
  43. package/dist/index.cjs.map +1 -0
  44. package/{types → dist}/index.d.ts +0 -1
  45. package/dist/index.js +6 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/network.cjs +15 -0
  48. package/dist/network.cjs.map +1 -0
  49. package/{types → dist}/network.d.ts +0 -1
  50. package/dist/network.js +4 -0
  51. package/dist/network.js.map +1 -0
  52. package/dist/primitives/bases/data/index.cjs +15 -0
  53. package/dist/primitives/bases/data/index.cjs.map +1 -0
  54. package/dist/primitives/bases/data/index.d.ts +1 -0
  55. package/dist/primitives/bases/data/index.js +4 -0
  56. package/dist/primitives/bases/data/index.js.map +1 -0
  57. package/{types → dist}/product/AppHeader.d.ts +0 -1
  58. package/{types → dist}/product/BrandMark.d.ts +0 -1
  59. package/{types → dist}/product/Charts.d.ts +0 -1
  60. package/{types → dist}/product/ComboBox.d.ts +0 -1
  61. package/{types → dist}/product/DataTable.d.ts +0 -1
  62. package/{types → dist}/product/Donut.d.ts +0 -1
  63. package/{types → dist}/product/EmptyState.d.ts +0 -1
  64. package/{types → dist}/product/FadeIn.d.ts +0 -1
  65. package/{types → dist}/product/Field.d.ts +0 -1
  66. package/{types → dist}/product/HanzoMark.d.ts +0 -1
  67. package/{types → dist}/product/Metric.d.ts +0 -1
  68. package/{types → dist}/product/OrgSwitcher.d.ts +0 -1
  69. package/{types → dist}/product/PageHeader.d.ts +0 -1
  70. package/{types → dist}/product/PrimaryButton.d.ts +0 -1
  71. package/{types → dist}/product/ProductIcon.d.ts +0 -1
  72. package/{types → dist}/product/ProviderLogo.d.ts +0 -1
  73. package/{types → dist}/product/Reorder.d.ts +0 -1
  74. package/{types → dist}/product/SelectMenu.d.ts +7 -6
  75. package/{types → dist}/product/SlideOver.d.ts +0 -1
  76. package/{types → dist}/product/StatusTag.d.ts +0 -1
  77. package/dist/product/ThemeToggle.d.ts +21 -0
  78. package/dist/product/ThemeToggleNext.d.ts +4 -0
  79. package/{types → dist}/product/Toast.d.ts +0 -1
  80. package/{types → dist}/product/color.d.ts +0 -1
  81. package/{types → dist}/product/combobox/filter.d.ts +0 -1
  82. package/dist/product/index.cjs +278 -0
  83. package/dist/product/index.cjs.map +1 -0
  84. package/{types → dist}/product/index.d.ts +2 -1
  85. package/dist/product/index.js +5 -0
  86. package/dist/product/index.js.map +1 -0
  87. package/dist/product/menu/ContextMenu.d.ts +21 -0
  88. package/dist/product/menu/DropdownMenu.d.ts +29 -0
  89. package/dist/product/menu/FloatingMenu.d.ts +36 -0
  90. package/dist/product/menu/index.d.ts +5 -0
  91. package/dist/product/menu/items.d.ts +68 -0
  92. package/dist/product/menu/portal-theme.d.ts +28 -0
  93. package/dist/product/menu/roving.d.ts +8 -0
  94. package/{types → dist}/product/scope.d.ts +0 -1
  95. package/{types → dist}/product/surfaces.data.d.ts +0 -1
  96. package/dist/usage.cjs +15 -0
  97. package/dist/usage.cjs.map +1 -0
  98. package/dist/usage.d.ts +1 -0
  99. package/dist/usage.js +4 -0
  100. package/dist/usage.js.map +1 -0
  101. package/dist/wallet.cjs +15 -0
  102. package/dist/wallet.cjs.map +1 -0
  103. package/{types → dist}/wallet.d.ts +0 -1
  104. package/dist/wallet.js +4 -0
  105. package/dist/wallet.js.map +1 -0
  106. package/package.json +58 -32
  107. package/src/billing.ts +0 -9
  108. package/src/canvas.ts +0 -11
  109. package/src/cd/layout.ts +0 -184
  110. package/src/cd/status.ts +0 -158
  111. package/src/cd/time.ts +0 -52
  112. package/src/cd/types.ts +0 -318
  113. package/src/dashboard.ts +0 -8
  114. package/src/data.ts +0 -12
  115. package/src/gitops.ts +0 -5
  116. package/src/gui-env.d.ts +0 -27
  117. package/src/index.ts +0 -22
  118. package/src/network.ts +0 -11
  119. package/src/primitives/bases/data/index.ts +0 -13
  120. package/src/product/AppHeader.tsx +0 -183
  121. package/src/product/BrandMark.tsx +0 -27
  122. package/src/product/Charts.tsx +0 -471
  123. package/src/product/ComboBox.tsx +0 -147
  124. package/src/product/DataTable.tsx +0 -99
  125. package/src/product/Donut.tsx +0 -83
  126. package/src/product/EmptyState.tsx +0 -129
  127. package/src/product/FadeIn.tsx +0 -38
  128. package/src/product/Field.tsx +0 -160
  129. package/src/product/HanzoMark.tsx +0 -31
  130. package/src/product/Metric.tsx +0 -253
  131. package/src/product/OrgSwitcher.tsx +0 -332
  132. package/src/product/PageHeader.tsx +0 -31
  133. package/src/product/PrimaryButton.tsx +0 -17
  134. package/src/product/ProductIcon.tsx +0 -61
  135. package/src/product/ProviderLogo.tsx +0 -137
  136. package/src/product/Reorder.test.ts +0 -41
  137. package/src/product/Reorder.tsx +0 -110
  138. package/src/product/SelectMenu.tsx +0 -94
  139. package/src/product/SlideOver.tsx +0 -197
  140. package/src/product/StatusTag.tsx +0 -49
  141. package/src/product/ThemeToggle.tsx +0 -25
  142. package/src/product/Toast.tsx +0 -166
  143. package/src/product/color.ts +0 -17
  144. package/src/product/combobox/filter.test.ts +0 -51
  145. package/src/product/combobox/filter.ts +0 -39
  146. package/src/product/index.ts +0 -70
  147. package/src/product/scope.test.ts +0 -92
  148. package/src/product/scope.ts +0 -123
  149. package/src/product/surfaces.data.ts +0 -42
  150. package/src/usage.ts +0 -8
  151. package/src/wallet.ts +0 -11
  152. package/types/billing.d.ts.map +0 -1
  153. package/types/canvas.d.ts +0 -2
  154. package/types/canvas.d.ts.map +0 -1
  155. package/types/cd/layout.d.ts.map +0 -1
  156. package/types/cd/status.d.ts.map +0 -1
  157. package/types/cd/time.d.ts.map +0 -1
  158. package/types/cd/types.d.ts.map +0 -1
  159. package/types/dashboard.d.ts +0 -2
  160. package/types/dashboard.d.ts.map +0 -1
  161. package/types/data.d.ts +0 -2
  162. package/types/data.d.ts.map +0 -1
  163. package/types/gitops.d.ts +0 -2
  164. package/types/gitops.d.ts.map +0 -1
  165. package/types/index.d.ts.map +0 -1
  166. package/types/network.d.ts.map +0 -1
  167. package/types/primitives/bases/data/index.d.ts +0 -2
  168. package/types/primitives/bases/data/index.d.ts.map +0 -1
  169. package/types/product/AppHeader.d.ts.map +0 -1
  170. package/types/product/BrandMark.d.ts.map +0 -1
  171. package/types/product/Charts.d.ts.map +0 -1
  172. package/types/product/ComboBox.d.ts.map +0 -1
  173. package/types/product/DataTable.d.ts.map +0 -1
  174. package/types/product/Donut.d.ts.map +0 -1
  175. package/types/product/EmptyState.d.ts.map +0 -1
  176. package/types/product/FadeIn.d.ts.map +0 -1
  177. package/types/product/Field.d.ts.map +0 -1
  178. package/types/product/HanzoMark.d.ts.map +0 -1
  179. package/types/product/Metric.d.ts.map +0 -1
  180. package/types/product/OrgSwitcher.d.ts.map +0 -1
  181. package/types/product/PageHeader.d.ts.map +0 -1
  182. package/types/product/PrimaryButton.d.ts.map +0 -1
  183. package/types/product/ProductIcon.d.ts.map +0 -1
  184. package/types/product/ProviderLogo.d.ts.map +0 -1
  185. package/types/product/Reorder.d.ts.map +0 -1
  186. package/types/product/SelectMenu.d.ts.map +0 -1
  187. package/types/product/SlideOver.d.ts.map +0 -1
  188. package/types/product/StatusTag.d.ts.map +0 -1
  189. package/types/product/ThemeToggle.d.ts +0 -2
  190. package/types/product/ThemeToggle.d.ts.map +0 -1
  191. package/types/product/Toast.d.ts.map +0 -1
  192. package/types/product/color.d.ts.map +0 -1
  193. package/types/product/combobox/filter.d.ts.map +0 -1
  194. package/types/product/index.d.ts.map +0 -1
  195. package/types/product/scope.d.ts.map +0 -1
  196. package/types/product/surfaces.data.d.ts.map +0 -1
  197. package/types/usage.d.ts +0 -2
  198. package/types/usage.d.ts.map +0 -1
  199. package/types/wallet.d.ts.map +0 -1
  200. /package/{src → dist}/styles/hanzo-motion.css +0 -0
@@ -0,0 +1,1999 @@
1
+ 'use client';
2
+ import { ThemeToggle } from './chunk-42CU5GSF.js';
3
+ import { createContext, useState, useRef, useCallback, useLayoutEffect, useEffect, useMemo, cloneElement, useContext } from 'react';
4
+ import { useTheme, XStack, Text, YStack, Card, Theme, useThemeName, Portal, Input, Button, Spinner, Popover, Separator, useControllableState, Label, TextArea, Switch, Select, Slider, ScrollView } from '@hanzo/gui';
5
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
+ import { Check, ChevronRight, ChevronDown, RefreshCw, Grip, CreditCard, Users, Bot, MessageCircle, AppWindow, LayoutGrid, Sparkles, UserRound, Settings2, LogOut, ChevronsUpDown, Plus, Search, ExternalLink, ArrowRight, Cpu, Globe, Server, X, Info, CircleX, CircleCheck } from '@hanzogui/lucide-icons-2';
7
+ export { Boxes } from '@hanzogui/lucide-icons-2';
8
+ import { HanzoLogo } from '@hanzo/logo/react';
9
+ import { createPortal } from 'react-dom';
10
+
11
+ var CHART_PALETTE = [
12
+ "#7c5cff",
13
+ "#23c562",
14
+ "#ff9f45",
15
+ "#3aa0ff",
16
+ "#ff5d8f",
17
+ "#16c0c8",
18
+ "#c084fc",
19
+ "#f4c245"
20
+ ];
21
+ var CHART_OTHER = "#64748b";
22
+ var ACCENT = CHART_PALETTE[0];
23
+ var GRID = "rgba(148,163,184,0.16)";
24
+ var AXIS = "rgba(148,163,184,0.85)";
25
+ var tone = (theme, key, fallback) => {
26
+ const v = theme[key];
27
+ const got = v?.get?.();
28
+ return typeof got === "string" ? got : fallback;
29
+ };
30
+ var rampOpacity = (i, n) => n <= 1 ? 0.9 : 0.95 - i / (n - 1) * 0.62;
31
+ function useContainerWidth() {
32
+ const ref = useRef(null);
33
+ const [w, setW] = useState(0);
34
+ useEffect(() => {
35
+ const el = ref.current;
36
+ if (!el) return;
37
+ const measure = () => setW(el.clientWidth);
38
+ measure();
39
+ const ro = new ResizeObserver(measure);
40
+ ro.observe(el);
41
+ return () => ro.disconnect();
42
+ }, []);
43
+ return { ref, w };
44
+ }
45
+ function Sparkline({
46
+ values,
47
+ width = 120,
48
+ height = 36,
49
+ color
50
+ }) {
51
+ const theme = useTheme();
52
+ const clean = (values ?? []).filter((v) => Number.isFinite(v));
53
+ if (clean.length < 2) return null;
54
+ const stroke = color ?? tone(theme, "color11", "currentColor");
55
+ const max = Math.max(...clean);
56
+ const min = Math.min(...clean);
57
+ const span = max - min || 1;
58
+ const n = clean.length;
59
+ const px = (i) => i / (n - 1) * (width - 2) + 1;
60
+ const py = (v) => height - 2 - (v - min) / span * (height - 4);
61
+ const line = clean.map((v, i) => `${i === 0 ? "M" : "L"}${px(i).toFixed(1)},${py(v).toFixed(1)}`).join(" ");
62
+ const area = `${line} L${(width - 1).toFixed(1)},${height} L1,${height} Z`;
63
+ return /* @__PURE__ */ jsxs("svg", { width, height, "aria-hidden": true, style: { display: "block" }, children: [
64
+ /* @__PURE__ */ jsx("path", { d: area, fill: stroke, fillOpacity: 0.12 }),
65
+ /* @__PURE__ */ jsx("path", { d: line, fill: "none", stroke, strokeWidth: 1.5, strokeLinejoin: "round", strokeLinecap: "round" })
66
+ ] });
67
+ }
68
+ function Tooltip({ x, height, label, value }) {
69
+ const left = Math.max(0, x - 60);
70
+ return /* @__PURE__ */ jsx(
71
+ "div",
72
+ {
73
+ style: {
74
+ position: "absolute",
75
+ left,
76
+ top: 0,
77
+ height,
78
+ pointerEvents: "none",
79
+ display: "flex",
80
+ alignItems: "flex-start"
81
+ },
82
+ children: /* @__PURE__ */ jsxs(
83
+ "div",
84
+ {
85
+ style: {
86
+ background: "rgba(15,17,21,0.94)",
87
+ border: "1px solid rgba(148,163,184,0.25)",
88
+ borderRadius: 8,
89
+ padding: "6px 9px",
90
+ fontSize: 11,
91
+ lineHeight: 1.35,
92
+ color: "#e2e8f0",
93
+ whiteSpace: "nowrap",
94
+ boxShadow: "0 4px 16px rgba(0,0,0,0.4)"
95
+ },
96
+ children: [
97
+ /* @__PURE__ */ jsx("div", { style: { color: AXIS }, children: label }),
98
+ /* @__PURE__ */ jsx("div", { style: { fontWeight: 700 }, children: value })
99
+ ]
100
+ }
101
+ )
102
+ }
103
+ );
104
+ }
105
+ function nearestIndex(clientX, rect, padL, innerW, n) {
106
+ if (n <= 1) return 0;
107
+ const mx = clientX - rect.left - padL;
108
+ const i = Math.round(mx / (innerW || 1) * (n - 1));
109
+ return Math.max(0, Math.min(n - 1, i));
110
+ }
111
+ function axisTicks(data) {
112
+ const n = data.length;
113
+ if (n === 0) return [];
114
+ if (n === 1) return [{ i: 0, label: data[0].label, anchor: "middle" }];
115
+ const mid = Math.floor((n - 1) / 2);
116
+ const out = [
117
+ { i: 0, label: data[0].label, anchor: "start" },
118
+ { i: n - 1, label: data[n - 1].label, anchor: "end" }
119
+ ];
120
+ if (n >= 5) out.splice(1, 0, { i: mid, label: data[mid].label, anchor: "middle" });
121
+ return out;
122
+ }
123
+ function LineChart({
124
+ data,
125
+ height = 210,
126
+ color = ACCENT,
127
+ formatValue = (v) => String(v)
128
+ }) {
129
+ const { ref, w } = useContainerWidth();
130
+ const [hover, setHover] = useState(null);
131
+ const padL = 10;
132
+ const padR = 10;
133
+ const padT = 12;
134
+ const padB = 24;
135
+ const n = data.length;
136
+ const innerW = Math.max(1, w - padL - padR);
137
+ const innerH = Math.max(1, height - padT - padB);
138
+ const max = Math.max(...data.map((d) => d.value), 1);
139
+ const x = (i) => padL + (n <= 1 ? innerW / 2 : i / (n - 1) * innerW);
140
+ const y = (v) => padT + innerH - v / max * innerH;
141
+ const line = data.map((d, i) => `${i === 0 ? "M" : "L"}${x(i).toFixed(1)},${y(d.value).toFixed(1)}`).join(" ");
142
+ const area = n >= 2 ? `${line} L${x(n - 1).toFixed(1)},${(padT + innerH).toFixed(1)} L${x(0).toFixed(1)},${(padT + innerH).toFixed(1)} Z` : "";
143
+ const ticks = axisTicks(data);
144
+ return /* @__PURE__ */ jsxs("div", { ref, style: { position: "relative", width: "100%" }, children: [
145
+ w > 0 ? /* @__PURE__ */ jsxs(
146
+ "svg",
147
+ {
148
+ width: w,
149
+ height,
150
+ style: { display: "block" },
151
+ onMouseMove: (e) => setHover(nearestIndex(e.clientX, e.currentTarget.getBoundingClientRect(), padL, innerW, n)),
152
+ onMouseLeave: () => setHover(null),
153
+ children: [
154
+ [0, 0.5, 1].map((g) => /* @__PURE__ */ jsx("line", { x1: padL, x2: w - padR, y1: padT + innerH * g, y2: padT + innerH * g, stroke: GRID, strokeWidth: 1 }, g)),
155
+ area ? /* @__PURE__ */ jsx("path", { d: area, fill: color, fillOpacity: 0.1 }) : null,
156
+ n >= 2 ? /* @__PURE__ */ jsx("path", { d: line, fill: "none", stroke: color, strokeWidth: 2, strokeLinejoin: "round", strokeLinecap: "round" }) : null,
157
+ hover != null && data[hover] ? /* @__PURE__ */ jsxs(Fragment, { children: [
158
+ /* @__PURE__ */ jsx("line", { x1: x(hover), x2: x(hover), y1: padT, y2: padT + innerH, stroke: AXIS, strokeWidth: 1, strokeDasharray: "3 3" }),
159
+ /* @__PURE__ */ jsx("circle", { cx: x(hover), cy: y(data[hover].value), r: 4, fill: color, stroke: "#0f1115", strokeWidth: 2 })
160
+ ] }) : null,
161
+ ticks.map((t) => /* @__PURE__ */ jsx("text", { x: x(t.i), y: height - 7, fontSize: 10, fill: AXIS, textAnchor: t.anchor, children: t.label }, t.i))
162
+ ]
163
+ }
164
+ ) : null,
165
+ hover != null && data[hover] ? /* @__PURE__ */ jsx(Tooltip, { x: x(hover), height, label: data[hover].label, value: formatValue(data[hover].value) }) : null
166
+ ] });
167
+ }
168
+ function BarChart({
169
+ data,
170
+ height = 210,
171
+ color = ACCENT,
172
+ formatValue = (v) => String(v)
173
+ }) {
174
+ const { ref, w } = useContainerWidth();
175
+ const [hover, setHover] = useState(null);
176
+ const padL = 10;
177
+ const padR = 10;
178
+ const padT = 12;
179
+ const padB = 24;
180
+ const n = data.length;
181
+ const innerW = Math.max(1, w - padL - padR);
182
+ const innerH = Math.max(1, height - padT - padB);
183
+ const max = Math.max(...data.map((d) => d.value), 1);
184
+ const slot = innerW / Math.max(1, n);
185
+ const barW = Math.max(1, Math.min(slot * 0.62, 36));
186
+ const cx = (i) => padL + slot * i + slot / 2;
187
+ const ticks = axisTicks(data);
188
+ return /* @__PURE__ */ jsxs("div", { ref, style: { position: "relative", width: "100%" }, children: [
189
+ w > 0 ? /* @__PURE__ */ jsxs(
190
+ "svg",
191
+ {
192
+ width: w,
193
+ height,
194
+ style: { display: "block" },
195
+ onMouseMove: (e) => {
196
+ const rect = e.currentTarget.getBoundingClientRect();
197
+ const i = Math.floor((e.clientX - rect.left - padL) / (slot || 1));
198
+ setHover(Math.max(0, Math.min(n - 1, i)));
199
+ },
200
+ onMouseLeave: () => setHover(null),
201
+ children: [
202
+ [0, 0.5, 1].map((g) => /* @__PURE__ */ jsx("line", { x1: padL, x2: w - padR, y1: padT + innerH * g, y2: padT + innerH * g, stroke: GRID, strokeWidth: 1 }, g)),
203
+ data.map((d, i) => {
204
+ const h = d.value / max * innerH;
205
+ return /* @__PURE__ */ jsx(
206
+ "rect",
207
+ {
208
+ x: cx(i) - barW / 2,
209
+ y: padT + innerH - h,
210
+ width: barW,
211
+ height: Math.max(0, h),
212
+ rx: Math.min(3, barW / 2),
213
+ fill: color,
214
+ fillOpacity: hover === i ? 1 : 0.78
215
+ },
216
+ i
217
+ );
218
+ }),
219
+ ticks.map((t) => /* @__PURE__ */ jsx("text", { x: cx(t.i), y: height - 7, fontSize: 10, fill: AXIS, textAnchor: "middle", children: t.label }, t.i))
220
+ ]
221
+ }
222
+ ) : null,
223
+ hover != null && data[hover] ? /* @__PURE__ */ jsx(Tooltip, { x: cx(hover), height, label: data[hover].label, value: formatValue(data[hover].value) }) : null
224
+ ] });
225
+ }
226
+ function Donut({
227
+ slices,
228
+ size = 160,
229
+ thickness = 22,
230
+ center,
231
+ legend = false
232
+ }) {
233
+ const theme = useTheme();
234
+ const fg = tone(theme, "color12", "currentColor");
235
+ const positive = slices.filter((s) => s.value > 0);
236
+ const total = positive.reduce((sum, s) => sum + s.value, 0);
237
+ const r = size / 2;
238
+ const rInner = r - thickness;
239
+ const mid = (r + rInner) / 2;
240
+ if (total <= 0) {
241
+ return /* @__PURE__ */ jsx(XStack, { items: "center", justify: "center", height: size, children: /* @__PURE__ */ jsx(Text, { fontSize: "$6", color: "$color10", children: "\u2014" }) });
242
+ }
243
+ const ring = /* @__PURE__ */ jsxs("div", { style: { position: "relative", width: size, height: size }, children: [
244
+ /* @__PURE__ */ jsx("svg", { width: size, height: size, style: { display: "block" }, children: positive.length === 1 ? /* @__PURE__ */ jsx(
245
+ "circle",
246
+ {
247
+ cx: r,
248
+ cy: r,
249
+ r: mid,
250
+ fill: "none",
251
+ stroke: positive[0].color ?? fg,
252
+ strokeOpacity: positive[0].color ? 1 : 0.9,
253
+ strokeWidth: thickness
254
+ }
255
+ ) : renderArcs(positive, total, r, rInner, fg) }),
256
+ center ? /* @__PURE__ */ jsx(
257
+ "div",
258
+ {
259
+ style: {
260
+ position: "absolute",
261
+ inset: 0,
262
+ display: "flex",
263
+ flexDirection: "column",
264
+ alignItems: "center",
265
+ justifyContent: "center",
266
+ textAlign: "center",
267
+ pointerEvents: "none"
268
+ },
269
+ children: center
270
+ }
271
+ ) : null
272
+ ] });
273
+ if (!legend) return ring;
274
+ return /* @__PURE__ */ jsxs(XStack, { gap: "$4", items: "center", flexWrap: "wrap", children: [
275
+ ring,
276
+ /* @__PURE__ */ jsx(YStack, { gap: "$1.5", flex: 1, minW: 150, children: positive.map((s, i) => /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", children: [
277
+ /* @__PURE__ */ jsx(
278
+ "div",
279
+ {
280
+ style: {
281
+ width: 10,
282
+ height: 10,
283
+ borderRadius: 2,
284
+ backgroundColor: s.color ?? AXIS,
285
+ opacity: s.color ? 1 : rampOpacity(i, positive.length)
286
+ }
287
+ }
288
+ ),
289
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", flex: 1, numberOfLines: 1, children: s.label }),
290
+ /* @__PURE__ */ jsxs(Text, { fontSize: "$2", color: "$color12", fontWeight: "600", children: [
291
+ Math.round(s.value / total * 100),
292
+ "%"
293
+ ] })
294
+ ] }, s.label)) })
295
+ ] });
296
+ }
297
+ function renderArcs(slices, total, rOuter, rInner, fg) {
298
+ let a0 = -Math.PI / 2;
299
+ const paths = [];
300
+ slices.forEach((s, idx) => {
301
+ const frac = Math.max(0, s.value) / total;
302
+ if (frac <= 0) return;
303
+ const a1 = a0 + frac * Math.PI * 2;
304
+ paths.push(
305
+ /* @__PURE__ */ jsx(
306
+ "path",
307
+ {
308
+ d: annularArc(rOuter, rOuter, rOuter, rInner, a0, Math.min(a1, a0 + Math.PI * 1.9999)),
309
+ fill: s.color ?? fg,
310
+ fillOpacity: s.color ? 1 : rampOpacity(idx, slices.length)
311
+ },
312
+ s.label || idx
313
+ )
314
+ );
315
+ a0 = a1;
316
+ });
317
+ return /* @__PURE__ */ jsx(Fragment, { children: paths });
318
+ }
319
+ function polar(cx, cy, rad, a) {
320
+ return [cx + rad * Math.cos(a), cy + rad * Math.sin(a)];
321
+ }
322
+ function annularArc(cx, cy, rOuter, rInner, a0, a1) {
323
+ const large = a1 - a0 > Math.PI ? 1 : 0;
324
+ const [x0, y0] = polar(cx, cy, rOuter, a0);
325
+ const [x1, y1] = polar(cx, cy, rOuter, a1);
326
+ const [x2, y2] = polar(cx, cy, rInner, a1);
327
+ const [x3, y3] = polar(cx, cy, rInner, a0);
328
+ return `M${x0},${y0} A${rOuter},${rOuter} 0 ${large} 1 ${x1},${y1} L${x2},${y2} A${rInner},${rInner} 0 ${large} 0 ${x3},${y3} Z`;
329
+ }
330
+ function BarRows({ bars }) {
331
+ const max = Math.max(0, ...bars.map((b) => b.value));
332
+ if (max <= 0) {
333
+ return /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color10", children: "\u2014" });
334
+ }
335
+ return /* @__PURE__ */ jsx(YStack, { gap: "$2.5", children: bars.map((b) => /* @__PURE__ */ jsxs(XStack, { gap: "$3", items: "center", children: [
336
+ /* @__PURE__ */ jsx(Text, { width: 64, fontSize: "$2", color: "$color11", text: "right", children: b.label }),
337
+ /* @__PURE__ */ jsx(YStack, { flex: 1, height: 10, bg: "$color3", rounded: "$2", overflow: "hidden", children: /* @__PURE__ */ jsx(YStack, { height: 10, width: `${Math.max(2, b.value / max * 100)}%`, bg: "$color9", rounded: "$2" }) }),
338
+ /* @__PURE__ */ jsx(Text, { width: 56, fontSize: "$2", color: "$color12", fontWeight: "600", children: b.value.toLocaleString() })
339
+ ] }, b.label)) });
340
+ }
341
+ var SERIES = ["#6ea8fe", "#7ee787", "#f0a868", "#c792ea", "#56d4c4", "#e879a6", "#d6c15a", "#8b9bb4"];
342
+ var colorForIndex = (i) => SERIES[i % SERIES.length];
343
+ var TRACK = "rgba(128,128,128,0.18)";
344
+ function utilColor(pct) {
345
+ if (pct >= 90) return "#e5534b";
346
+ if (pct >= 70) return "#f0a868";
347
+ return "#7ee787";
348
+ }
349
+ function Sparkline2({
350
+ points,
351
+ width = 104,
352
+ height = 30,
353
+ color = SERIES[0]
354
+ }) {
355
+ if (!points || points.length < 2) return null;
356
+ const min = Math.min(...points);
357
+ const max = Math.max(...points);
358
+ const span = max - min || 1;
359
+ const stepX = width / (points.length - 1);
360
+ const y = (v) => height - 2 - (v - min) / span * (height - 4);
361
+ const d = points.map((p, i) => `${i === 0 ? "M" : "L"}${(i * stepX).toFixed(1)},${y(p).toFixed(1)}`).join(" ");
362
+ return /* @__PURE__ */ jsx("svg", { width, height, viewBox: `0 0 ${width} ${height}`, role: "img", "aria-label": "trend", children: /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: color, strokeWidth: 1.5, strokeLinejoin: "round", strokeLinecap: "round" }) });
363
+ }
364
+ function MiniBars({
365
+ bars,
366
+ width = 320,
367
+ height = 96,
368
+ color = SERIES[0]
369
+ }) {
370
+ if (!bars.length) return null;
371
+ const max = Math.max(...bars.map((b) => b.value), 1);
372
+ const gap = 4;
373
+ const bw = (width - gap * (bars.length - 1)) / bars.length;
374
+ return /* @__PURE__ */ jsx("svg", { width: "100%", height, viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", role: "img", "aria-label": "bars", children: bars.map((b, i) => {
375
+ const h = Math.max(1, b.value / max * (height - 2));
376
+ return /* @__PURE__ */ jsx("rect", { x: i * (bw + gap), y: height - h, width: bw, height: h, rx: 2, fill: color, opacity: 0.85, children: /* @__PURE__ */ jsx("title", { children: `${b.label}: ${b.value}` }) }, b.label + i);
377
+ }) });
378
+ }
379
+ function UtilBar({ value, width = 120, color }) {
380
+ const v = Math.max(0, Math.min(100, value));
381
+ return /* @__PURE__ */ jsxs("svg", { width, height: 8, viewBox: `0 0 ${width} 8`, role: "img", "aria-label": `${Math.round(v)}%`, children: [
382
+ /* @__PURE__ */ jsx("rect", { x: 0, y: 1, width, height: 6, rx: 3, fill: TRACK }),
383
+ /* @__PURE__ */ jsx("rect", { x: 0, y: 1, width: v / 100 * width, height: 6, rx: 3, fill: color ?? utilColor(v) })
384
+ ] });
385
+ }
386
+ function LegendDot({ color, label, value }) {
387
+ return /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", justify: "space-between", children: [
388
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", children: [
389
+ /* @__PURE__ */ jsx(YStack, { width: 10, height: 10, rounded: "$1", bg: color }),
390
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", children: label })
391
+ ] }),
392
+ value != null ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", fontWeight: "600", children: value }) : null
393
+ ] });
394
+ }
395
+ function MetricCard({
396
+ icon,
397
+ label,
398
+ value,
399
+ caption,
400
+ spark,
401
+ sparkColor,
402
+ delta
403
+ }) {
404
+ const up = delta ? delta.pct >= 0 : false;
405
+ return /* @__PURE__ */ jsxs(Card, { p: "$3.5", gap: "$2", borderWidth: 1, borderColor: "$borderColor", flex: 1, minW: 172, children: [
406
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", justify: "space-between", children: [
407
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", children: [
408
+ icon,
409
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", fontWeight: "600", children: label })
410
+ ] }),
411
+ delta ? /* @__PURE__ */ jsxs(Text, { fontSize: "$1", color: up ? "#7ee787" : "#e5534b", children: [
412
+ up ? "\u25B2" : "\u25BC",
413
+ " ",
414
+ Math.abs(delta.pct),
415
+ "%"
416
+ ] }) : null
417
+ ] }),
418
+ /* @__PURE__ */ jsxs(XStack, { items: "flex-end", justify: "space-between", gap: "$2", children: [
419
+ /* @__PURE__ */ jsx(Text, { fontSize: "$8", fontWeight: "900", color: "$color12", numberOfLines: 1, children: value }),
420
+ spark && spark.length >= 2 ? /* @__PURE__ */ jsx(Sparkline2, { points: spark, color: sparkColor ?? SERIES[0] }) : null
421
+ ] }),
422
+ caption ? /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color10", numberOfLines: 1, children: caption }) : null
423
+ ] });
424
+ }
425
+ function HintButton({
426
+ icon,
427
+ iconAfter,
428
+ children,
429
+ onPress,
430
+ disabled,
431
+ hint,
432
+ theme
433
+ }) {
434
+ const btn = /* @__PURE__ */ jsx(
435
+ Button,
436
+ {
437
+ size: "$2",
438
+ theme,
439
+ icon,
440
+ iconAfter,
441
+ disabled,
442
+ onPress: disabled ? void 0 : onPress,
443
+ children
444
+ }
445
+ );
446
+ if (!hint) return btn;
447
+ return /* @__PURE__ */ jsx("span", { title: hint, style: { display: "inline-flex" }, children: btn });
448
+ }
449
+ function Panel({
450
+ title,
451
+ right,
452
+ children,
453
+ minW = 280,
454
+ grow = true
455
+ }) {
456
+ return /* @__PURE__ */ jsxs(Card, { p: "$4", gap: "$3", borderWidth: 1, borderColor: "$borderColor", flex: grow ? 1 : void 0, minW, width: grow ? void 0 : "100%", children: [
457
+ /* @__PURE__ */ jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [
458
+ /* @__PURE__ */ jsx(Text, { fontSize: "$4", fontWeight: "800", color: "$color12", children: title }),
459
+ right
460
+ ] }),
461
+ children
462
+ ] });
463
+ }
464
+ function Donut2({
465
+ segments,
466
+ size = 160,
467
+ thickness = 18,
468
+ centerValue,
469
+ centerLabel,
470
+ trackColor = "#2a2d2e",
471
+ valueColor = "#ecedee",
472
+ labelColor = "#9ba1a6"
473
+ }) {
474
+ const total = segments.reduce((n, s) => n + Math.max(0, s.value), 0);
475
+ if (total <= 0) return null;
476
+ const r = (size - thickness) / 2;
477
+ const cx = size / 2;
478
+ const cy = size / 2;
479
+ const circ = 2 * Math.PI * r;
480
+ let offset = 0;
481
+ const arcs = segments.filter((s) => s.value > 0).map((s) => {
482
+ const frac = s.value / total;
483
+ const dash = frac * circ;
484
+ const node = /* @__PURE__ */ jsx(
485
+ "circle",
486
+ {
487
+ cx,
488
+ cy,
489
+ r,
490
+ fill: "none",
491
+ stroke: s.color,
492
+ strokeWidth: thickness,
493
+ strokeDasharray: `${dash} ${circ - dash}`,
494
+ strokeDashoffset: -offset
495
+ },
496
+ s.label
497
+ );
498
+ offset += dash;
499
+ return node;
500
+ });
501
+ return /* @__PURE__ */ jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, role: "img", "aria-label": "Donut chart", children: [
502
+ /* @__PURE__ */ jsx("circle", { cx, cy, r, fill: "none", stroke: trackColor, strokeWidth: thickness }),
503
+ /* @__PURE__ */ jsx("g", { transform: `rotate(-90 ${cx} ${cy})`, children: arcs }),
504
+ centerValue ? /* @__PURE__ */ jsx("text", { x: cx, y: cy - 2, textAnchor: "middle", fontSize: size * 0.2, fontWeight: "800", fill: valueColor, children: centerValue }) : null,
505
+ centerLabel ? /* @__PURE__ */ jsx("text", { x: cx, y: cy + size * 0.13, textAnchor: "middle", fontSize: size * 0.08, fill: labelColor, children: centerLabel }) : null
506
+ ] });
507
+ }
508
+
509
+ // src/product/combobox/filter.ts
510
+ var hay = (o) => `${o.value} ${o.label ?? ""} ${o.hint ?? ""}`.toLowerCase();
511
+ function filterOptions(options, query) {
512
+ const q = query.trim().toLowerCase();
513
+ if (!q) return options;
514
+ return options.filter((o) => hay(o).includes(q));
515
+ }
516
+ function isKnownOption(options, value) {
517
+ return options.some((o) => o.value === value);
518
+ }
519
+ var ITEM_MIN_HEIGHT = 30;
520
+ var ITEM_RADIUS = 7;
521
+ var ITEM_PX = 8;
522
+ var ITEM_GAP = 8;
523
+ var ICON_SLOT = 16;
524
+ var PANEL_RADIUS = 12;
525
+ var PANEL_PAD = 4;
526
+ var PANEL_GAP = 2;
527
+ var SEP_MARGIN = 4;
528
+ var FONT_LABEL = 13;
529
+ var FONT_MUTED = 11;
530
+ var FONT_SHORTCUT = 12;
531
+ var ACCENT2 = "var(--hanzo-accent, #8b5cf6)";
532
+ var ACCENT_SOFT = "var(--hanzo-accent-soft, rgba(139,92,246,0.16))";
533
+ var DANGER = "var(--hanzo-danger, #ef4444)";
534
+ function MenuPanel({
535
+ children,
536
+ minWidth = 200,
537
+ maxHeight = 360,
538
+ onKeyDown,
539
+ panelRef,
540
+ ...rest
541
+ }) {
542
+ return /* @__PURE__ */ jsx(
543
+ YStack,
544
+ {
545
+ ref: panelRef,
546
+ role: "menu",
547
+ bg: "$color2",
548
+ borderColor: "$borderColor",
549
+ borderWidth: 1,
550
+ rounded: PANEL_RADIUS,
551
+ p: PANEL_PAD,
552
+ gap: PANEL_GAP,
553
+ minW: minWidth,
554
+ maxH: maxHeight,
555
+ overflow: "scroll",
556
+ shadowColor: "rgba(0,0,0,0.45)",
557
+ shadowRadius: 20,
558
+ shadowOffset: { width: 0, height: 10 },
559
+ onKeyDown,
560
+ ...rest,
561
+ children
562
+ }
563
+ );
564
+ }
565
+ function MenuItemView({
566
+ icon,
567
+ label,
568
+ description,
569
+ shortcut,
570
+ selected = false,
571
+ disabled = false,
572
+ destructive = false,
573
+ hasSubmenu = false,
574
+ onSelect
575
+ }) {
576
+ const press = () => {
577
+ if (!disabled) onSelect();
578
+ };
579
+ const onKeyDown = (e) => {
580
+ if (disabled) return;
581
+ if (e.key === "Enter" || e.key === " ") {
582
+ e.preventDefault();
583
+ onSelect();
584
+ }
585
+ };
586
+ const labelColor = destructive ? DANGER : "$color12";
587
+ return /* @__PURE__ */ jsxs(
588
+ XStack,
589
+ {
590
+ role: "menuitem",
591
+ tabIndex: disabled ? -1 : 0,
592
+ "aria-disabled": disabled || void 0,
593
+ items: "center",
594
+ gap: ITEM_GAP,
595
+ px: ITEM_PX,
596
+ minH: ITEM_MIN_HEIGHT,
597
+ rounded: ITEM_RADIUS,
598
+ cursor: disabled ? "default" : "pointer",
599
+ opacity: disabled ? 0.4 : 1,
600
+ select: "none",
601
+ style: { outline: "none" },
602
+ hoverStyle: disabled ? {} : { bg: ACCENT_SOFT },
603
+ pressStyle: disabled ? {} : { bg: ACCENT_SOFT },
604
+ focusStyle: disabled ? {} : { bg: ACCENT_SOFT },
605
+ onPress: press,
606
+ onKeyDown,
607
+ children: [
608
+ /* @__PURE__ */ jsx(XStack, { width: ICON_SLOT, height: ICON_SLOT, items: "center", justify: "center", shrink: 0, children: icon ? /* @__PURE__ */ jsx(XStack, { items: "center", justify: "center", opacity: destructive ? 1 : 0.9, style: destructive ? { color: DANGER } : void 0, children: icon }) : null }),
609
+ /* @__PURE__ */ jsxs(YStack, { flex: 1, minW: 0, children: [
610
+ /* @__PURE__ */ jsx(Text, { fontSize: FONT_LABEL, lineHeight: 18, color: labelColor, numberOfLines: 1, children: label }),
611
+ description ? /* @__PURE__ */ jsx(Text, { fontSize: FONT_MUTED, lineHeight: 14, color: "$color11", numberOfLines: 1, children: description }) : null
612
+ ] }),
613
+ shortcut ? /* @__PURE__ */ jsx(Text, { fontSize: FONT_SHORTCUT, color: "$color11", shrink: 0, children: shortcut }) : null,
614
+ selected ? /* @__PURE__ */ jsx(Check, { size: 14, color: ACCENT2 }) : null,
615
+ hasSubmenu ? /* @__PURE__ */ jsx(ChevronRight, { size: 14, color: "var(--hanzo-muted, currentColor)", opacity: 0.6 }) : null
616
+ ]
617
+ }
618
+ );
619
+ }
620
+ function MenuSeparatorView() {
621
+ return /* @__PURE__ */ jsx(YStack, { height: 1, bg: "$borderColor", my: SEP_MARGIN, mx: SEP_MARGIN, role: "separator" });
622
+ }
623
+ function MenuLabelView({ children }) {
624
+ return /* @__PURE__ */ jsx(
625
+ Text,
626
+ {
627
+ fontSize: FONT_MUTED,
628
+ color: "$color11",
629
+ px: ITEM_PX,
630
+ py: SEP_MARGIN,
631
+ textTransform: "uppercase",
632
+ letterSpacing: 0.4,
633
+ select: "none",
634
+ children
635
+ }
636
+ );
637
+ }
638
+ function renderMenuItems(items, close) {
639
+ return items.map((it, i) => {
640
+ if (it.type === "separator") return /* @__PURE__ */ jsx(MenuSeparatorView, {}, it.key ?? `sep-${i}`);
641
+ if (it.type === "label") return /* @__PURE__ */ jsx(MenuLabelView, { children: it.label }, it.key ?? `lbl-${i}`);
642
+ const { key, onSelect, closeOnSelect = true, ...rest } = it;
643
+ return /* @__PURE__ */ jsx(
644
+ MenuItemView,
645
+ {
646
+ ...rest,
647
+ onSelect: () => {
648
+ onSelect();
649
+ if (closeOnSelect) close?.();
650
+ }
651
+ },
652
+ key
653
+ );
654
+ });
655
+ }
656
+ function PortalTheme({ name, children }) {
657
+ return /* @__PURE__ */ jsx(Theme, { name, children });
658
+ }
659
+
660
+ // src/product/menu/roving.ts
661
+ function menuKeyDown(e, onClose) {
662
+ if (e.key === "Escape") {
663
+ onClose?.();
664
+ return;
665
+ }
666
+ if (e.key !== "ArrowDown" && e.key !== "ArrowUp" && e.key !== "Home" && e.key !== "End") return;
667
+ if (typeof document === "undefined") return;
668
+ const panel = e.currentTarget;
669
+ const items = Array.from(
670
+ panel.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')
671
+ );
672
+ if (items.length === 0) return;
673
+ e.preventDefault();
674
+ const active = document.activeElement;
675
+ const current = active ? items.indexOf(active) : -1;
676
+ let next;
677
+ if (e.key === "Home") next = 0;
678
+ else if (e.key === "End") next = items.length - 1;
679
+ else if (e.key === "ArrowDown") next = current < 0 ? 0 : (current + 1) % items.length;
680
+ else next = current <= 0 ? items.length - 1 : current - 1;
681
+ items[next]?.focus();
682
+ }
683
+ var EDGE = 8;
684
+ function FloatingMenu({
685
+ open,
686
+ onClose,
687
+ anchorRect,
688
+ anchorEl,
689
+ gap = 4,
690
+ minWidth = 200,
691
+ maxHeight,
692
+ autoFocus = true,
693
+ children
694
+ }) {
695
+ const themeName = useThemeName();
696
+ const panelRef = useRef(null);
697
+ const [pos, setPos] = useState(null);
698
+ const setPanel = useCallback((n) => {
699
+ panelRef.current = n;
700
+ }, []);
701
+ const place = useCallback(() => {
702
+ if (typeof window === "undefined") return;
703
+ const a = anchorRect();
704
+ if (!a) return;
705
+ const node = panelRef.current;
706
+ const w = node?.offsetWidth || minWidth;
707
+ const h = node?.offsetHeight || 0;
708
+ let left = a.left;
709
+ let top = a.bottom + gap;
710
+ if (left + w > window.innerWidth - EDGE) left = Math.max(EDGE, window.innerWidth - w - EDGE);
711
+ if (h && top + h > window.innerHeight - EDGE) {
712
+ const above = a.top - gap - h;
713
+ top = above >= EDGE ? above : Math.max(EDGE, window.innerHeight - h - EDGE);
714
+ }
715
+ setPos({ left, top });
716
+ }, [anchorRect, gap, minWidth]);
717
+ useLayoutEffect(() => {
718
+ if (!open) {
719
+ setPos(null);
720
+ return;
721
+ }
722
+ place();
723
+ if (autoFocus) panelRef.current?.focus?.();
724
+ }, [open, place, autoFocus]);
725
+ useEffect(() => {
726
+ if (!open || typeof document === "undefined") return;
727
+ const onPointerDown = (e) => {
728
+ const t = e.target;
729
+ if (panelRef.current?.contains(t)) return;
730
+ const anchor = anchorEl?.();
731
+ if (anchor && anchor.contains(t)) return;
732
+ onClose();
733
+ };
734
+ const onKey = (e) => {
735
+ if (e.key === "Escape") onClose();
736
+ };
737
+ document.addEventListener("pointerdown", onPointerDown, true);
738
+ document.addEventListener("keydown", onKey, true);
739
+ window.addEventListener("scroll", onClose, true);
740
+ window.addEventListener("resize", onClose);
741
+ window.addEventListener("blur", onClose);
742
+ return () => {
743
+ document.removeEventListener("pointerdown", onPointerDown, true);
744
+ document.removeEventListener("keydown", onKey, true);
745
+ window.removeEventListener("scroll", onClose, true);
746
+ window.removeEventListener("resize", onClose);
747
+ window.removeEventListener("blur", onClose);
748
+ };
749
+ }, [open, onClose, anchorEl]);
750
+ if (!open) return null;
751
+ return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(PortalTheme, { name: themeName, children: /* @__PURE__ */ jsx(
752
+ MenuPanel,
753
+ {
754
+ panelRef: setPanel,
755
+ minWidth,
756
+ maxHeight,
757
+ tabIndex: -1,
758
+ onKeyDown: (e) => menuKeyDown(e, onClose),
759
+ style: {
760
+ position: "fixed",
761
+ left: pos?.left ?? 0,
762
+ top: pos?.top ?? 0,
763
+ zIndex: 1e5,
764
+ visibility: pos ? "visible" : "hidden"
765
+ },
766
+ children
767
+ }
768
+ ) }) });
769
+ }
770
+ function ComboBox({
771
+ value,
772
+ onChange,
773
+ options,
774
+ loading = false,
775
+ error = null,
776
+ onRetry,
777
+ placeholder,
778
+ disabled,
779
+ emptyText = "No matches \u2014 press to use what you typed.",
780
+ minWidth = 240
781
+ }) {
782
+ const [open, setOpen] = useState(false);
783
+ const rowRef = useRef(null);
784
+ const anchorRect = useCallback(() => rowRef.current?.getBoundingClientRect() ?? null, []);
785
+ const anchorEl = useCallback(() => rowRef.current, []);
786
+ const filtered = useMemo(() => filterOptions(options, value), [options, value]);
787
+ const pick = (v) => {
788
+ onChange(v);
789
+ setOpen(false);
790
+ };
791
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
792
+ /* @__PURE__ */ jsxs(XStack, { ref: rowRef, items: "center", gap: "$2", minW: minWidth, children: [
793
+ /* @__PURE__ */ jsx(
794
+ Input,
795
+ {
796
+ flex: 1,
797
+ value,
798
+ onChangeText: (v) => {
799
+ onChange(v);
800
+ if (!open) setOpen(true);
801
+ },
802
+ onFocus: () => setOpen(true),
803
+ disabled,
804
+ placeholder,
805
+ autoCapitalize: "none"
806
+ }
807
+ ),
808
+ /* @__PURE__ */ jsx(
809
+ Button,
810
+ {
811
+ size: "$2",
812
+ chromeless: true,
813
+ disabled,
814
+ icon: /* @__PURE__ */ jsx(ChevronDown, { size: 16, opacity: 0.7 }),
815
+ onPress: () => setOpen((o) => !o),
816
+ "aria-label": "Show options"
817
+ }
818
+ )
819
+ ] }),
820
+ /* @__PURE__ */ jsx(
821
+ FloatingMenu,
822
+ {
823
+ open,
824
+ onClose: () => setOpen(false),
825
+ anchorRect,
826
+ anchorEl,
827
+ autoFocus: false,
828
+ minWidth,
829
+ maxHeight: 300,
830
+ children: loading ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$2", children: [
831
+ /* @__PURE__ */ jsx(Spinner, { size: "small", color: "$color11" }),
832
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", children: "Loading options\u2026" })
833
+ ] }) : error ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$2", children: [
834
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", flex: 1, numberOfLines: 2, children: error }),
835
+ onRetry ? /* @__PURE__ */ jsx(Button, { size: "$1", chromeless: true, icon: /* @__PURE__ */ jsx(RefreshCw, { size: 12 }), onPress: onRetry, "aria-label": "Retry" }) : null
836
+ ] }) : filtered.length === 0 ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", px: "$2", py: "$2", children: emptyText }) : filtered.map((o) => /* @__PURE__ */ jsx(
837
+ MenuItemView,
838
+ {
839
+ label: o.label ?? o.value,
840
+ description: o.hint,
841
+ selected: o.value === value,
842
+ onSelect: () => pick(o.value)
843
+ },
844
+ o.value
845
+ ))
846
+ }
847
+ )
848
+ ] });
849
+ }
850
+
851
+ // src/product/surfaces.data.ts
852
+ var SURFACES = [
853
+ { id: "ai", label: "Hanzo AI", href: "https://hanzo.ai", hint: "hanzo.ai" },
854
+ { id: "console", label: "Console", href: "https://console.hanzo.ai", hint: "console.hanzo.ai" },
855
+ { id: "app", label: "App", href: "https://hanzo.app", hint: "hanzo.app" },
856
+ { id: "chat", label: "Chat", href: "https://hanzo.chat", hint: "hanzo.chat" },
857
+ { id: "bot", label: "Bot", href: "https://hanzo.bot", hint: "hanzo.bot" },
858
+ { id: "team", label: "Team", href: "https://hanzo.team", hint: "hanzo.team" },
859
+ { id: "billing", label: "Billing", href: "https://billing.hanzo.ai", hint: "billing.hanzo.ai" }
860
+ ];
861
+ function otherSurfaces(current) {
862
+ return current ? SURFACES.filter((s) => s.id !== current) : SURFACES;
863
+ }
864
+ function HanzoMark({ size = 22, color = "currentColor" }) {
865
+ return /* @__PURE__ */ jsxs(
866
+ "svg",
867
+ {
868
+ width: size,
869
+ height: size,
870
+ viewBox: "0 0 67 67",
871
+ role: "img",
872
+ "aria-label": "Hanzo",
873
+ fill: color,
874
+ style: { display: "block", flexShrink: 0 },
875
+ children: [
876
+ /* @__PURE__ */ jsx("path", { d: "M22.21 67V44.6369H0V67H22.21Z" }),
877
+ /* @__PURE__ */ jsx("path", { opacity: 0.55, d: "M0 44.6369L22.21 46.8285V44.6369H0Z" }),
878
+ /* @__PURE__ */ jsx("path", { d: "M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z" }),
879
+ /* @__PURE__ */ jsx("path", { d: "M22.21 0H0V22.3184H22.21V0Z" }),
880
+ /* @__PURE__ */ jsx("path", { d: "M66.7198 0H44.5098V22.3184H66.7198V0Z" }),
881
+ /* @__PURE__ */ jsx("path", { opacity: 0.55, d: "M66.6753 22.3185L44.5098 20.0822V22.3185H66.6753Z" }),
882
+ /* @__PURE__ */ jsx("path", { d: "M66.7198 67V44.6369H44.5098V67H66.7198Z" })
883
+ ]
884
+ }
885
+ );
886
+ }
887
+ function BrandMark({
888
+ size = 20,
889
+ wordmark = "Hanzo",
890
+ animated = true
891
+ }) {
892
+ if (!animated) return /* @__PURE__ */ jsx(HanzoMark, { size });
893
+ return /* @__PURE__ */ jsx(HanzoLogo, { animated: true, size, wordmark });
894
+ }
895
+ var SURFACE_ICON = {
896
+ ai: Sparkles,
897
+ console: LayoutGrid,
898
+ app: AppWindow,
899
+ chat: MessageCircle,
900
+ bot: Bot,
901
+ team: Users,
902
+ billing: CreditCard
903
+ };
904
+ var openHref = (href) => {
905
+ if (typeof window !== "undefined") window.open(href, "_blank", "noopener");
906
+ };
907
+ function MenuRow({ icon, label, onPress }) {
908
+ return /* @__PURE__ */ jsxs(XStack, { onPress, cursor: "pointer", items: "center", gap: "$2.5", px: "$2", py: "$2", rounded: "$3", hoverStyle: { bg: "$color5" }, children: [
909
+ icon,
910
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", children: label })
911
+ ] });
912
+ }
913
+ function AppHeader({
914
+ brand,
915
+ wordmark = "Hanzo",
916
+ onBrand,
917
+ org,
918
+ children,
919
+ current,
920
+ surfaces,
921
+ open,
922
+ user,
923
+ menu,
924
+ theme,
925
+ onProfile,
926
+ onTeam,
927
+ onBilling,
928
+ onSignOut
929
+ }) {
930
+ const [appsOpen, setAppsOpen] = useState(false);
931
+ const [menuOpen, setMenuOpen] = useState(false);
932
+ const items = surfaces ?? otherSurfaces(current);
933
+ const launch = (s) => {
934
+ setAppsOpen(false);
935
+ if (open) open(s);
936
+ else openHref(s.href);
937
+ };
938
+ return /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$3", height: 52, borderBottomWidth: 1, borderColor: "$borderColor", bg: "$background", children: [
939
+ /* @__PURE__ */ jsx(XStack, { items: "center", cursor: onBrand ? "pointer" : void 0, onPress: onBrand, children: brand ?? /* @__PURE__ */ jsx(BrandMark, { wordmark }) }),
940
+ org ? /* @__PURE__ */ jsx(XStack, { items: "center", minW: 0, children: org }) : null,
941
+ /* @__PURE__ */ jsx(XStack, { flex: 1, items: "center", minW: 0, children }),
942
+ items.length > 0 ? /* @__PURE__ */ jsxs(Popover, { open: appsOpen, onOpenChange: setAppsOpen, placement: "bottom-end", children: [
943
+ /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsx(Grip, { size: 16 }), "aria-label": "Apps" }) }),
944
+ /* @__PURE__ */ jsx(Popover.Content, { bordered: true, elevate: true, p: "$2", width: 230, bg: "$color2", borderColor: "$borderColor", children: /* @__PURE__ */ jsx(YStack, { gap: "$1", children: items.map((s) => {
945
+ const Icon = SURFACE_ICON[s.id];
946
+ return /* @__PURE__ */ jsxs(XStack, { onPress: () => launch(s), cursor: "pointer", items: "center", gap: "$2.5", px: "$2", py: "$2", rounded: "$3", hoverStyle: { bg: "$color5" }, children: [
947
+ /* @__PURE__ */ jsx(Icon, { size: 16 }),
948
+ /* @__PURE__ */ jsx(Text, { flex: 1, fontSize: "$2", fontWeight: "600", color: "$color12", children: s.label }),
949
+ s.hint ? /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color10", children: s.hint }) : null
950
+ ] }, s.id);
951
+ }) }) })
952
+ ] }) : null,
953
+ /* @__PURE__ */ jsxs(Popover, { open: menuOpen, onOpenChange: setMenuOpen, placement: "bottom-end", children: [
954
+ /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsx(UserRound, { size: 16 }), "aria-label": "Account", children: user ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", numberOfLines: 1, maxW: 140, children: user }) : null }) }),
955
+ /* @__PURE__ */ jsx(Popover.Content, { bordered: true, elevate: true, p: "$2", width: 220, bg: "$color2", borderColor: "$borderColor", children: menu ?? /* @__PURE__ */ jsxs(YStack, { gap: "$1", children: [
956
+ onProfile ? /* @__PURE__ */ jsx(MenuRow, { icon: /* @__PURE__ */ jsx(UserRound, { size: 15 }), label: "Profile", onPress: () => (setMenuOpen(false), onProfile()) }) : null,
957
+ theme !== null ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2.5", px: "$2", py: "$1", rounded: "$3", children: [
958
+ /* @__PURE__ */ jsx(Text, { flex: 1, fontSize: "$2", color: "$color12", children: "Theme" }),
959
+ theme ?? /* @__PURE__ */ jsx(ThemeToggle, {})
960
+ ] }) : null,
961
+ onTeam ? /* @__PURE__ */ jsx(MenuRow, { icon: /* @__PURE__ */ jsx(Settings2, { size: 15 }), label: "Team settings", onPress: () => (setMenuOpen(false), onTeam()) }) : null,
962
+ onBilling ? /* @__PURE__ */ jsx(MenuRow, { icon: /* @__PURE__ */ jsx(CreditCard, { size: 15 }), label: "Billing", onPress: () => (setMenuOpen(false), onBilling()) }) : null,
963
+ onSignOut ? /* @__PURE__ */ jsxs(Fragment, { children: [
964
+ /* @__PURE__ */ jsx(Separator, { borderColor: "$borderColor", my: "$1" }),
965
+ /* @__PURE__ */ jsx(MenuRow, { icon: /* @__PURE__ */ jsx(LogOut, { size: 15 }), label: "Sign out", onPress: () => (setMenuOpen(false), onSignOut()) })
966
+ ] }) : null
967
+ ] }) })
968
+ ] })
969
+ ] });
970
+ }
971
+
972
+ // src/product/scope.ts
973
+ function browserStorage() {
974
+ if (typeof window === "undefined") return null;
975
+ try {
976
+ return window.localStorage;
977
+ } catch {
978
+ return null;
979
+ }
980
+ }
981
+ function orgScope(config) {
982
+ const key = config.key ?? "hanzo.org";
983
+ const selectedKey = `${key}.selected`;
984
+ const store = () => config.storage ?? browserStorage();
985
+ const read = (k) => {
986
+ try {
987
+ return store()?.getItem(k) ?? null;
988
+ } catch {
989
+ return null;
990
+ }
991
+ };
992
+ const write = (k, v) => {
993
+ try {
994
+ if (v === null) store()?.removeItem(k);
995
+ else store()?.setItem(k, v);
996
+ } catch {
997
+ }
998
+ };
999
+ const goHome = () => {
1000
+ if (config.navigate) return config.navigate("/");
1001
+ if (typeof window !== "undefined") window.location.assign("/");
1002
+ };
1003
+ const doReload = () => {
1004
+ if (config.reload) return config.reload();
1005
+ if (typeof window !== "undefined") window.location.reload();
1006
+ };
1007
+ const scope = {
1008
+ currentOrg: () => read(key) || config.brandOrg,
1009
+ setCurrentOrg: (org) => write(key, !org || org === config.brandOrg ? null : org),
1010
+ isScopedAway: () => scope.currentOrg() !== config.brandOrg,
1011
+ hasSelectedOrg: () => read(selectedKey) === "1",
1012
+ enterOrg: (org) => {
1013
+ if (!org) return;
1014
+ scope.setCurrentOrg(org);
1015
+ write(selectedKey, "1");
1016
+ goHome();
1017
+ },
1018
+ leaveOrg: () => {
1019
+ write(selectedKey, null);
1020
+ scope.setCurrentOrg(config.brandOrg);
1021
+ goHome();
1022
+ },
1023
+ switchOrg: (org) => {
1024
+ if (!org || org === scope.currentOrg()) return;
1025
+ scope.setCurrentOrg(org);
1026
+ write(selectedKey, "1");
1027
+ doReload();
1028
+ }
1029
+ };
1030
+ return scope;
1031
+ }
1032
+ function filterOrgs(orgs, query) {
1033
+ const q = query.trim().toLowerCase();
1034
+ if (!q) return orgs;
1035
+ return orgs.filter(
1036
+ (o) => o.name.toLowerCase().includes(q) || (o.displayName ?? "").toLowerCase().includes(q)
1037
+ );
1038
+ }
1039
+ var titleCase = (s) => s ? s[0].toUpperCase() + s.slice(1) : s;
1040
+ var initialsOf = (o) => (o.displayName || o.name).split(/\s+/).map((w) => w[0]).join("").slice(0, 2).toUpperCase();
1041
+ function OrgAvatar({ org, size = 22 }) {
1042
+ if (org.logo) {
1043
+ return /* @__PURE__ */ jsx("img", { src: org.logo, alt: "", style: { height: size, width: size, objectFit: "contain", display: "block", borderRadius: 6 } });
1044
+ }
1045
+ return /* @__PURE__ */ jsx(YStack, { width: size, height: size, rounded: "$3", bg: "$color4", items: "center", justify: "center", children: /* @__PURE__ */ jsx(Text, { fontSize: "$1", fontWeight: "800", color: "$color12", children: initialsOf(org) }) });
1046
+ }
1047
+ function OrgSwitcher({ scope, orgs, pageSize = 20, create, picker = false }) {
1048
+ const currentId = scope.currentOrg();
1049
+ const [open, setOpen] = useState(false);
1050
+ const [query, setQuery] = useState("");
1051
+ const [debounced, setDebounced] = useState("");
1052
+ const [rows, setRows] = useState([]);
1053
+ const [loading, setLoading] = useState(false);
1054
+ const [loadingMore, setLoadingMore] = useState(false);
1055
+ const [hasMore, setHasMore] = useState(false);
1056
+ const [creating, setCreating] = useState(false);
1057
+ const [newName, setNewName] = useState("");
1058
+ const [busy, setBusy] = useState(false);
1059
+ const [err, setErr] = useState(null);
1060
+ const pageRef = useRef(0);
1061
+ const reqRef = useRef(0);
1062
+ useEffect(() => {
1063
+ const id = setTimeout(() => setDebounced(query.trim()), 250);
1064
+ return () => clearTimeout(id);
1065
+ }, [query]);
1066
+ const fetchPage = useCallback(
1067
+ async (page, q, append) => {
1068
+ if (!orgs) return;
1069
+ const token = ++reqRef.current;
1070
+ append ? setLoadingMore(true) : setLoading(true);
1071
+ try {
1072
+ const incoming = await orgs(page, q);
1073
+ if (token !== reqRef.current) return;
1074
+ pageRef.current = page;
1075
+ setRows((prev) => {
1076
+ const merged = append ? [...prev] : [];
1077
+ const seen = new Set(merged.map((o) => o.name));
1078
+ for (const o of incoming) if (!seen.has(o.name)) merged.push(o);
1079
+ return merged;
1080
+ });
1081
+ setHasMore(incoming.length >= pageSize);
1082
+ } catch {
1083
+ if (token !== reqRef.current) return;
1084
+ if (!append) setRows([]);
1085
+ setHasMore(false);
1086
+ } finally {
1087
+ if (token === reqRef.current) {
1088
+ setLoading(false);
1089
+ setLoadingMore(false);
1090
+ }
1091
+ }
1092
+ },
1093
+ [orgs, pageSize]
1094
+ );
1095
+ useEffect(() => {
1096
+ if (!open || !orgs) return;
1097
+ void fetchPage(0, debounced, false);
1098
+ }, [open, debounced, fetchPage, orgs]);
1099
+ const loadMore = useCallback(() => {
1100
+ if (loading || loadingMore || !hasMore) return;
1101
+ void fetchPage(pageRef.current + 1, debounced, true);
1102
+ }, [loading, loadingMore, hasMore, debounced, fetchPage]);
1103
+ const visible = useMemo(() => {
1104
+ if (orgs) return filterOrgs(rows, query);
1105
+ return [{ name: currentId, displayName: titleCase(currentId) }];
1106
+ }, [orgs, rows, query, currentId]);
1107
+ const current = useMemo(
1108
+ () => rows.find((o) => o.name === currentId) ?? { name: currentId, displayName: titleCase(currentId) },
1109
+ [rows, currentId]
1110
+ );
1111
+ const select = useCallback(
1112
+ (org) => {
1113
+ setOpen(false);
1114
+ scope.switchOrg(org);
1115
+ },
1116
+ [scope]
1117
+ );
1118
+ const submitCreate = async () => {
1119
+ const name = newName.trim();
1120
+ if (!name || !create) return;
1121
+ setBusy(true);
1122
+ setErr(null);
1123
+ try {
1124
+ const org = await create(name);
1125
+ scope.switchOrg(org);
1126
+ } catch (e) {
1127
+ setErr(e instanceof Error ? e.message : "Could not create the organization.");
1128
+ setBusy(false);
1129
+ }
1130
+ };
1131
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, placement: "bottom-start", children: [
1132
+ /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsx(OrgAvatar, { org: current, size: 18 }), iconAfter: /* @__PURE__ */ jsx(ChevronsUpDown, { size: 13 }), children: current.displayName || titleCase(current.name) }) }),
1133
+ /* @__PURE__ */ jsx(Popover.Content, { bordered: true, elevate: true, p: "$2", width: 300, bg: "$color2", borderColor: "$borderColor", children: creating ? /* @__PURE__ */ jsxs(YStack, { gap: "$2", children: [
1134
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", fontWeight: "700", children: "Create organization" }),
1135
+ /* @__PURE__ */ jsx(
1136
+ Input,
1137
+ {
1138
+ size: "$3",
1139
+ placeholder: "Organization name",
1140
+ value: newName,
1141
+ onChangeText: setNewName,
1142
+ autoCapitalize: "words",
1143
+ onSubmitEditing: () => void submitCreate()
1144
+ }
1145
+ ),
1146
+ err ? /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$red10", children: err }) : null,
1147
+ /* @__PURE__ */ jsxs(XStack, { gap: "$2", justify: "flex-end", children: [
1148
+ /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, onPress: () => setCreating(false), disabled: busy, children: "Cancel" }),
1149
+ /* @__PURE__ */ jsx(
1150
+ Button,
1151
+ {
1152
+ size: "$2",
1153
+ onPress: () => void submitCreate(),
1154
+ disabled: busy || !newName.trim(),
1155
+ icon: busy ? /* @__PURE__ */ jsx(Spinner, { size: "small" }) : /* @__PURE__ */ jsx(Plus, { size: 14 }),
1156
+ children: "Create"
1157
+ }
1158
+ )
1159
+ ] })
1160
+ ] }) : /* @__PURE__ */ jsxs(YStack, { gap: "$1", children: [
1161
+ orgs ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$1", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [
1162
+ /* @__PURE__ */ jsx(Search, { size: 13, opacity: 0.6 }),
1163
+ /* @__PURE__ */ jsx(
1164
+ Input,
1165
+ {
1166
+ flex: 1,
1167
+ size: "$2",
1168
+ borderWidth: 0,
1169
+ bg: "transparent",
1170
+ placeholder: "Find organization\u2026",
1171
+ value: query,
1172
+ onChangeText: setQuery,
1173
+ autoCapitalize: "none",
1174
+ autoCorrect: false
1175
+ }
1176
+ )
1177
+ ] }) : null,
1178
+ /* @__PURE__ */ jsxs(
1179
+ "div",
1180
+ {
1181
+ style: { maxHeight: 300, overflowY: "auto", display: "flex", flexDirection: "column" },
1182
+ onScroll: (e) => {
1183
+ const el = e.currentTarget;
1184
+ if (el.scrollHeight - el.scrollTop - el.clientHeight < 48) loadMore();
1185
+ },
1186
+ children: [
1187
+ loading ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$3", children: [
1188
+ /* @__PURE__ */ jsx(Spinner, { size: "small", color: "$color11" }),
1189
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", children: "Loading organizations\u2026" })
1190
+ ] }) : visible.length === 0 ? /* @__PURE__ */ jsx(Text, { px: "$2", py: "$2", fontSize: "$2", color: "$color10", children: query.trim() ? `No organizations match \u201C${query.trim()}\u201D.` : "No organizations yet." }) : visible.map((org) => /* @__PURE__ */ jsxs(
1191
+ XStack,
1192
+ {
1193
+ onPress: () => select(org.name),
1194
+ cursor: "pointer",
1195
+ items: "center",
1196
+ gap: "$2.5",
1197
+ px: "$2",
1198
+ py: "$2",
1199
+ rounded: "$3",
1200
+ bg: org.name === currentId ? "$color4" : "transparent",
1201
+ hoverStyle: { bg: "$color5" },
1202
+ children: [
1203
+ /* @__PURE__ */ jsx(OrgAvatar, { org }),
1204
+ /* @__PURE__ */ jsx(Text, { flex: 1, fontSize: "$2", color: "$color12", numberOfLines: 1, children: org.displayName || org.name }),
1205
+ org.name === currentId ? /* @__PURE__ */ jsx(Check, { size: 15 }) : null
1206
+ ]
1207
+ },
1208
+ org.name
1209
+ )),
1210
+ loadingMore ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$2", children: [
1211
+ /* @__PURE__ */ jsx(Spinner, { size: "small", color: "$color11" }),
1212
+ /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color10", children: "Loading more\u2026" })
1213
+ ] }) : hasMore ? /* @__PURE__ */ jsx(XStack, { onPress: loadMore, cursor: "pointer", items: "center", justify: "center", px: "$2", py: "$1.5", rounded: "$3", hoverStyle: { bg: "$color4" }, children: /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color11", fontWeight: "600", children: "Load more" }) }) : null
1214
+ ]
1215
+ }
1216
+ ),
1217
+ create ? /* @__PURE__ */ jsxs(
1218
+ XStack,
1219
+ {
1220
+ onPress: () => {
1221
+ setCreating(true);
1222
+ setErr(null);
1223
+ },
1224
+ cursor: "pointer",
1225
+ items: "center",
1226
+ gap: "$2.5",
1227
+ px: "$2",
1228
+ py: "$2",
1229
+ mt: "$1",
1230
+ rounded: "$3",
1231
+ borderTopWidth: 1,
1232
+ borderColor: "$borderColor",
1233
+ hoverStyle: { bg: "$color5" },
1234
+ children: [
1235
+ /* @__PURE__ */ jsx(YStack, { width: 22, height: 22, rounded: "$3", bg: "$color3", items: "center", justify: "center", children: /* @__PURE__ */ jsx(Plus, { size: 14 }) }),
1236
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", children: "Create organization" })
1237
+ ]
1238
+ }
1239
+ ) : null,
1240
+ picker ? /* @__PURE__ */ jsxs(
1241
+ XStack,
1242
+ {
1243
+ onPress: () => {
1244
+ setOpen(false);
1245
+ scope.leaveOrg();
1246
+ },
1247
+ cursor: "pointer",
1248
+ items: "center",
1249
+ gap: "$2.5",
1250
+ px: "$2",
1251
+ py: "$2",
1252
+ rounded: "$3",
1253
+ hoverStyle: { bg: "$color5" },
1254
+ children: [
1255
+ /* @__PURE__ */ jsx(YStack, { width: 22, height: 22, rounded: "$3", bg: "$color3", items: "center", justify: "center", children: /* @__PURE__ */ jsx(LayoutGrid, { size: 14 }) }),
1256
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", children: "All organizations" })
1257
+ ]
1258
+ }
1259
+ ) : null
1260
+ ] }) })
1261
+ ] });
1262
+ }
1263
+ function DropdownMenu({
1264
+ trigger,
1265
+ items,
1266
+ open,
1267
+ defaultOpen = false,
1268
+ onOpenChange,
1269
+ minWidth = 200,
1270
+ maxHeight
1271
+ }) {
1272
+ const [isOpen, setOpen] = useControllableState({
1273
+ prop: open,
1274
+ defaultProp: defaultOpen,
1275
+ onChange: onOpenChange
1276
+ });
1277
+ const anchorRef = useRef(null);
1278
+ const anchorRect = useCallback(() => anchorRef.current?.getBoundingClientRect() ?? null, []);
1279
+ const anchorEl = useCallback(() => anchorRef.current, []);
1280
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1281
+ /* @__PURE__ */ jsx(XStack, { ref: anchorRef, self: "flex-start", cursor: "pointer", onPress: () => setOpen(!isOpen), children: trigger }),
1282
+ /* @__PURE__ */ jsx(
1283
+ FloatingMenu,
1284
+ {
1285
+ open: isOpen,
1286
+ onClose: () => setOpen(false),
1287
+ anchorRect,
1288
+ anchorEl,
1289
+ minWidth,
1290
+ maxHeight,
1291
+ children: renderMenuItems(items, () => setOpen(false))
1292
+ }
1293
+ )
1294
+ ] });
1295
+ }
1296
+ function ContextMenu({ children, items, disabled, minWidth = 200, maxHeight }) {
1297
+ const [state, setState] = useState({ open: false, x: 0, y: 0 });
1298
+ const close = useCallback(() => setState((s) => s.open ? { ...s, open: false } : s), []);
1299
+ const anchorRect = useCallback(
1300
+ () => ({ left: state.x, top: state.y, right: state.x, bottom: state.y, width: 0, height: 0 }),
1301
+ [state.x, state.y]
1302
+ );
1303
+ const childOnContextMenu = children.props.onContextMenu;
1304
+ const target = cloneElement(children, {
1305
+ onContextMenu: (e) => {
1306
+ childOnContextMenu?.(e);
1307
+ if (disabled) return;
1308
+ e.preventDefault();
1309
+ e.stopPropagation();
1310
+ setState({ open: true, x: e.clientX, y: e.clientY });
1311
+ }
1312
+ });
1313
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1314
+ target,
1315
+ /* @__PURE__ */ jsx(FloatingMenu, { open: state.open, onClose: close, anchorRect, gap: 0, minWidth, maxHeight, children: renderMenuItems(items, close) })
1316
+ ] });
1317
+ }
1318
+ function DataTable({
1319
+ columns,
1320
+ rows,
1321
+ loading,
1322
+ empty = "Nothing here yet.",
1323
+ rowKey,
1324
+ onRowPress
1325
+ }) {
1326
+ if (loading) {
1327
+ return /* @__PURE__ */ jsx(XStack, { p: "$6", justify: "center", children: /* @__PURE__ */ jsx(Spinner, { size: "large", color: "$color11" }) });
1328
+ }
1329
+ if (rows.length === 0) {
1330
+ return /* @__PURE__ */ jsx(YStack, { p: "$6", items: "center", borderWidth: 1, borderColor: "$borderColor", rounded: "$4", children: /* @__PURE__ */ jsx(Text, { color: "$color11", children: empty }) });
1331
+ }
1332
+ return /* @__PURE__ */ jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", overflow: "hidden", children: [
1333
+ /* @__PURE__ */ jsx(XStack, { bg: "$color2", py: "$2.5", px: "$3", gap: "$3", children: columns.map((c) => /* @__PURE__ */ jsx(
1334
+ Text,
1335
+ {
1336
+ width: c.width,
1337
+ flex: c.width ? void 0 : 1,
1338
+ fontSize: "$2",
1339
+ fontWeight: "700",
1340
+ color: "$color11",
1341
+ children: c.header
1342
+ },
1343
+ c.key
1344
+ )) }),
1345
+ /* @__PURE__ */ jsx(YStack, { children: rows.map((row) => /* @__PURE__ */ jsx(
1346
+ XStack,
1347
+ {
1348
+ py: "$2.5",
1349
+ px: "$3",
1350
+ gap: "$3",
1351
+ borderTopWidth: 1,
1352
+ borderColor: "$borderColor",
1353
+ items: "center",
1354
+ hoverStyle: onRowPress ? { bg: "$color2" } : void 0,
1355
+ cursor: onRowPress ? "pointer" : void 0,
1356
+ onPress: onRowPress ? () => onRowPress(row) : void 0,
1357
+ children: columns.map((c) => /* @__PURE__ */ jsx(YStack, { width: c.width, flex: c.width ? void 0 : 1, children: c.render ? c.render(row) : /* @__PURE__ */ jsx(Text, { fontSize: "$3", numberOfLines: 1, children: String(row[c.key] ?? "") }) }, c.key))
1358
+ },
1359
+ rowKey(row)
1360
+ )) })
1361
+ ] });
1362
+ }
1363
+ function PrimaryButton(props) {
1364
+ return /* @__PURE__ */ jsx(Button, { theme: "light", ...props });
1365
+ }
1366
+ function openHref2(href) {
1367
+ if (typeof window !== "undefined") window.open(href, "_blank", "noopener");
1368
+ }
1369
+ function EmptyState({
1370
+ icon: Icon,
1371
+ title,
1372
+ description,
1373
+ bullets,
1374
+ primary,
1375
+ secondary
1376
+ }) {
1377
+ return /* @__PURE__ */ jsxs(
1378
+ Card,
1379
+ {
1380
+ borderWidth: 1,
1381
+ borderColor: "$borderColor",
1382
+ borderStyle: "dashed",
1383
+ p: "$6",
1384
+ gap: "$4",
1385
+ items: "center",
1386
+ maxWidth: 640,
1387
+ self: "center",
1388
+ width: "100%",
1389
+ children: [
1390
+ /* @__PURE__ */ jsx(
1391
+ YStack,
1392
+ {
1393
+ width: 48,
1394
+ height: 48,
1395
+ items: "center",
1396
+ justify: "center",
1397
+ rounded: "$4",
1398
+ bg: "$color3",
1399
+ children: /* @__PURE__ */ jsx(Icon, { size: 24 })
1400
+ }
1401
+ ),
1402
+ /* @__PURE__ */ jsxs(YStack, { gap: "$2", items: "center", maxW: 480, children: [
1403
+ /* @__PURE__ */ jsx(Text, { fontSize: "$6", fontWeight: "800", text: "center", children: title }),
1404
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", text: "center", children: description })
1405
+ ] }),
1406
+ bullets && bullets.length ? /* @__PURE__ */ jsx(YStack, { gap: "$2", self: "stretch", maxW: 420, mx: "auto", children: bullets.map((b) => /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "flex-start", children: [
1407
+ /* @__PURE__ */ jsx(YStack, { pt: "$1", children: /* @__PURE__ */ jsx(Check, { size: 14, color: "$color10" }) }),
1408
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", flex: 1, children: b })
1409
+ ] }, b)) }) : null,
1410
+ primary || secondary ? /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", justify: "center", children: [
1411
+ primary ? /* @__PURE__ */ jsx(
1412
+ PrimaryButton,
1413
+ {
1414
+ icon: primary.icon,
1415
+ iconAfter: primary.href ? /* @__PURE__ */ jsx(ExternalLink, { size: 15 }) : /* @__PURE__ */ jsx(ArrowRight, { size: 15 }),
1416
+ onPress: () => primary.href ? openHref2(primary.href) : primary.onPress?.(),
1417
+ children: primary.label
1418
+ }
1419
+ ) : null,
1420
+ secondary ? /* @__PURE__ */ jsx(
1421
+ Button,
1422
+ {
1423
+ chromeless: true,
1424
+ icon: secondary.icon,
1425
+ iconAfter: secondary.href ? /* @__PURE__ */ jsx(ExternalLink, { size: 14 }) : void 0,
1426
+ onPress: () => secondary.href ? openHref2(secondary.href) : secondary.onPress?.(),
1427
+ children: secondary.label
1428
+ }
1429
+ ) : null
1430
+ ] }) : null
1431
+ ]
1432
+ }
1433
+ );
1434
+ }
1435
+ function FadeIn({
1436
+ children,
1437
+ index = 0,
1438
+ step = 50,
1439
+ delayMs,
1440
+ style
1441
+ }) {
1442
+ const delay = delayMs ?? index * step;
1443
+ return /* @__PURE__ */ jsx("div", { className: "hz-fade-up", style: { animationDelay: `${delay}ms`, ...style }, children });
1444
+ }
1445
+ function FieldRow({ label, children }) {
1446
+ return /* @__PURE__ */ jsxs(XStack, { gap: "$3", items: "flex-start", flexWrap: "wrap", children: [
1447
+ /* @__PURE__ */ jsx(Label, { width: 180, pt: "$2", color: "$color11", fontSize: "$3", children: label }),
1448
+ /* @__PURE__ */ jsx(YStack, { flex: 1, minW: 240, children })
1449
+ ] });
1450
+ }
1451
+ function FieldText({
1452
+ value,
1453
+ onChange,
1454
+ disabled,
1455
+ secure,
1456
+ placeholder
1457
+ }) {
1458
+ return /* @__PURE__ */ jsx(
1459
+ Input,
1460
+ {
1461
+ value,
1462
+ onChangeText: onChange,
1463
+ disabled,
1464
+ secureTextEntry: secure,
1465
+ placeholder,
1466
+ autoCapitalize: "none"
1467
+ }
1468
+ );
1469
+ }
1470
+ function FieldTextArea({
1471
+ value,
1472
+ onChange,
1473
+ disabled,
1474
+ rows = 6
1475
+ }) {
1476
+ return /* @__PURE__ */ jsx(TextArea, { value, onChangeText: onChange, disabled, numberOfLines: rows });
1477
+ }
1478
+ function FieldSwitch({
1479
+ checked,
1480
+ onChange,
1481
+ disabled
1482
+ }) {
1483
+ return /* @__PURE__ */ jsx(Switch, { checked, onCheckedChange: onChange, disabled, size: "$3", children: /* @__PURE__ */ jsx(Switch.Thumb, {}) });
1484
+ }
1485
+ function FieldSelect({
1486
+ value,
1487
+ options,
1488
+ onChange,
1489
+ disabled
1490
+ }) {
1491
+ return /* @__PURE__ */ jsxs(Select, { value, onValueChange: onChange, disablePreventBodyScroll: true, native: true, children: [
1492
+ /* @__PURE__ */ jsx(Select.Trigger, { disabled, iconAfter: /* @__PURE__ */ jsx(ChevronDown, { size: 16 }), children: /* @__PURE__ */ jsx(Select.Value, { placeholder: "Select\u2026" }) }),
1493
+ /* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Viewport, { children: options.map((opt, i) => /* @__PURE__ */ jsx(Select.Item, { index: i, value: opt, children: /* @__PURE__ */ jsx(Select.ItemText, { children: opt }) }, opt)) }) })
1494
+ ] });
1495
+ }
1496
+ function FieldSlider({
1497
+ value,
1498
+ min,
1499
+ max,
1500
+ step,
1501
+ onChange,
1502
+ disabled
1503
+ }) {
1504
+ return /* @__PURE__ */ jsxs(XStack, { gap: "$3", items: "center", children: [
1505
+ /* @__PURE__ */ jsx(Text, { width: 56, fontSize: "$3", color: "$color11", children: value }),
1506
+ /* @__PURE__ */ jsxs(
1507
+ Slider,
1508
+ {
1509
+ flex: 1,
1510
+ min,
1511
+ max,
1512
+ step,
1513
+ value: [value],
1514
+ onValueChange: (v) => onChange(v[0] ?? min),
1515
+ disabled,
1516
+ children: [
1517
+ /* @__PURE__ */ jsx(Slider.Track, { children: /* @__PURE__ */ jsx(Slider.TrackActive, {}) }),
1518
+ /* @__PURE__ */ jsx(Slider.Thumb, { index: 0, circular: true })
1519
+ ]
1520
+ }
1521
+ )
1522
+ ] });
1523
+ }
1524
+ function PageHeader({
1525
+ title,
1526
+ subtitle,
1527
+ actions
1528
+ }) {
1529
+ return /* @__PURE__ */ jsxs(XStack, { justify: "space-between", items: "flex-start", gap: "$4", children: [
1530
+ /* @__PURE__ */ jsxs(YStack, { gap: "$1", children: [
1531
+ /* @__PURE__ */ jsx(Text, { fontSize: "$7", fontWeight: "800", children: title }),
1532
+ subtitle ? /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", children: subtitle }) : null
1533
+ ] }),
1534
+ actions ? /* @__PURE__ */ jsx(XStack, { gap: "$2", children: actions }) : null
1535
+ ] });
1536
+ }
1537
+
1538
+ // src/product/color.ts
1539
+ var asColor = (hex) => hex;
1540
+ function ProductIcon({
1541
+ icon: Icon,
1542
+ color,
1543
+ size = 24
1544
+ }) {
1545
+ const radius = Math.round(size * 0.28);
1546
+ const glyph = Math.round(size * 0.58);
1547
+ const tinted = typeof color === "string" && color.trim() !== "";
1548
+ if (tinted) {
1549
+ return /* @__PURE__ */ jsx(
1550
+ XStack,
1551
+ {
1552
+ width: size,
1553
+ height: size,
1554
+ items: "center",
1555
+ justify: "center",
1556
+ rounded: radius,
1557
+ style: { backgroundColor: color },
1558
+ children: /* @__PURE__ */ jsx(Icon, { size: glyph, color: asColor("#ffffff") })
1559
+ }
1560
+ );
1561
+ }
1562
+ return /* @__PURE__ */ jsx(XStack, { width: size, height: size, items: "center", justify: "center", rounded: radius, bg: "$color12", children: /* @__PURE__ */ jsx(Icon, { size: glyph, color: "$color1" }) });
1563
+ }
1564
+ var KNOWN = {
1565
+ openrouter: Globe,
1566
+ nvidia: Cpu
1567
+ };
1568
+ var isFirstParty = (provider) => {
1569
+ const p = provider.trim().toLowerCase();
1570
+ return p === "hanzo" || p === "zen";
1571
+ };
1572
+ function EnsoMark({ size, color }) {
1573
+ return /* @__PURE__ */ jsx("svg", { width: size, height: size, viewBox: "0 0 100 100", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M66.22 83.26 A37 37 0 1 1 85.57 60.20", fill: "none", stroke: color, strokeWidth: 11, strokeLinecap: "round" }) });
1574
+ }
1575
+ var HANZO_PATHS = [
1576
+ "M22.21 67V44.6369H0V67H22.21Z",
1577
+ "M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z",
1578
+ "M22.21 0H0V22.3184H22.21V0Z",
1579
+ "M66.7198 0H44.5098V22.3184H66.7198V0Z",
1580
+ "M66.7198 67V44.6369H44.5098V67H66.7198Z"
1581
+ ];
1582
+ function HanzoHMark({ size, color }) {
1583
+ return /* @__PURE__ */ jsx("svg", { width: size, height: size, viewBox: "0 0 67 67", "aria-hidden": "true", children: HANZO_PATHS.map((d) => /* @__PURE__ */ jsx("path", { d, fill: color }, d)) });
1584
+ }
1585
+ function providerInitials(provider) {
1586
+ const name = provider.trim();
1587
+ if (!name) return "\u2022";
1588
+ const words = name.split(/[\s/_-]+/).filter(Boolean);
1589
+ if (words.length >= 2) return (words[0][0] + words[1][0]).toUpperCase();
1590
+ return name.slice(0, 2).toUpperCase();
1591
+ }
1592
+ function ProviderLogo({ provider, size = 24 }) {
1593
+ const theme = useTheme();
1594
+ const radius = Math.round(size * 0.28);
1595
+ const iconSize = Math.round(size * 0.56);
1596
+ if (isFirstParty(provider)) {
1597
+ const fg = theme.color1?.get() ?? "#000000";
1598
+ const markSize = Math.round(size * 0.66);
1599
+ const isZen = provider.trim().toLowerCase() === "zen";
1600
+ return /* @__PURE__ */ jsx(XStack, { width: size, height: size, items: "center", justify: "center", rounded: radius, bg: "$color12", children: isZen ? /* @__PURE__ */ jsx(EnsoMark, { size: markSize, color: fg }) : /* @__PURE__ */ jsx(HanzoHMark, { size: Math.round(size * 0.56), color: fg }) });
1601
+ }
1602
+ const Known = KNOWN[provider.trim().toLowerCase()];
1603
+ if (Known) {
1604
+ return /* @__PURE__ */ jsx(
1605
+ XStack,
1606
+ {
1607
+ width: size,
1608
+ height: size,
1609
+ items: "center",
1610
+ justify: "center",
1611
+ rounded: radius,
1612
+ bg: "$color3",
1613
+ borderWidth: 1,
1614
+ borderColor: "$borderColor",
1615
+ children: /* @__PURE__ */ jsx(Known, { size: iconSize, color: "$color11" })
1616
+ }
1617
+ );
1618
+ }
1619
+ return /* @__PURE__ */ jsx(
1620
+ XStack,
1621
+ {
1622
+ width: size,
1623
+ height: size,
1624
+ items: "center",
1625
+ justify: "center",
1626
+ rounded: radius,
1627
+ bg: "$color3",
1628
+ borderWidth: 1,
1629
+ borderColor: "$borderColor",
1630
+ children: /* @__PURE__ */ jsx(Text, { fontSize: Math.round(size * 0.4), fontWeight: "800", color: "$color11", children: providerInitials(provider) })
1631
+ }
1632
+ );
1633
+ }
1634
+ function GenericLogo({ size = 24 }) {
1635
+ return /* @__PURE__ */ jsx(XStack, { width: size, height: size, items: "center", justify: "center", rounded: Math.round(size * 0.28), bg: "$color3", borderWidth: 1, borderColor: "$borderColor", children: /* @__PURE__ */ jsx(Server, { size: Math.round(size * 0.56), color: "$color11" }) });
1636
+ }
1637
+ function targetIndex(from, dy, rowH, count) {
1638
+ if (rowH <= 0 || count <= 0) return from;
1639
+ const raw = from + Math.round(dy / rowH);
1640
+ return Math.max(0, Math.min(raw, count - 1));
1641
+ }
1642
+ function rowShift(i, from, to, dy, rowH) {
1643
+ if (i === from) return dy;
1644
+ if (from < to && i > from && i <= to) return -rowH;
1645
+ if (from > to && i < from && i >= to) return rowH;
1646
+ return 0;
1647
+ }
1648
+ function Reorder({
1649
+ items,
1650
+ keyOf,
1651
+ rowHeight = 44,
1652
+ onReorder,
1653
+ renderItem
1654
+ }) {
1655
+ const [drag, setDrag] = useState(null);
1656
+ const startRef = useRef(null);
1657
+ const to = drag ? targetIndex(drag.from, drag.dy, rowHeight, items.length) : -1;
1658
+ const begin = useCallback(
1659
+ (index) => (e) => {
1660
+ const startY = e.clientY ?? e.nativeEvent?.clientY ?? 0;
1661
+ startRef.current = { from: index, startY };
1662
+ setDrag({ from: index, dy: 0 });
1663
+ const move = (ev) => {
1664
+ if (!startRef.current) return;
1665
+ setDrag({ from: startRef.current.from, dy: ev.clientY - startRef.current.startY });
1666
+ };
1667
+ const end = () => {
1668
+ const s = startRef.current;
1669
+ window.removeEventListener("pointermove", move);
1670
+ window.removeEventListener("pointerup", end);
1671
+ window.removeEventListener("pointercancel", end);
1672
+ startRef.current = null;
1673
+ setDrag((d) => {
1674
+ if (s && d) {
1675
+ const t = targetIndex(s.from, d.dy, rowHeight, items.length);
1676
+ if (t !== s.from) onReorder(s.from, t);
1677
+ }
1678
+ return null;
1679
+ });
1680
+ };
1681
+ window.addEventListener("pointermove", move);
1682
+ window.addEventListener("pointerup", end);
1683
+ window.addEventListener("pointercancel", end);
1684
+ },
1685
+ [items.length, rowHeight, onReorder]
1686
+ );
1687
+ return /* @__PURE__ */ jsx(YStack, { children: items.map((item, i) => {
1688
+ const dragging = drag?.from === i;
1689
+ const shift = drag && to >= 0 ? rowShift(i, drag.from, to, drag.dy, rowHeight) : 0;
1690
+ return /* @__PURE__ */ jsx(
1691
+ YStack,
1692
+ {
1693
+ height: rowHeight,
1694
+ justify: "center",
1695
+ className: "hz-drag-item",
1696
+ style: {
1697
+ transform: `translateY(${shift}px)`,
1698
+ zIndex: dragging ? 2 : 1,
1699
+ ...dragging ? { transition: "none", boxShadow: "0 8px 24px rgba(0,0,0,0.28)" } : null
1700
+ },
1701
+ children: renderItem(item, { onPointerDown: begin(i) }, dragging)
1702
+ },
1703
+ keyOf(item)
1704
+ );
1705
+ }) });
1706
+ }
1707
+ function SelectMenu({
1708
+ options,
1709
+ value,
1710
+ onChange,
1711
+ allLabel = "All",
1712
+ icon,
1713
+ minWidth = 130
1714
+ }) {
1715
+ const active = value === null ? null : options.find((o) => o.key === value) ?? null;
1716
+ const triggerLabel = active ? active.label : allLabel;
1717
+ const items = [
1718
+ { key: "__all__", label: allLabel, selected: value === null, onSelect: () => onChange(null) },
1719
+ ...options.map((o) => ({ key: o.key, label: o.label, selected: value === o.key, onSelect: () => onChange(o.key) }))
1720
+ ];
1721
+ return /* @__PURE__ */ jsx(
1722
+ DropdownMenu,
1723
+ {
1724
+ minWidth: Math.max(minWidth, 160),
1725
+ trigger: /* @__PURE__ */ jsx(
1726
+ Button,
1727
+ {
1728
+ size: "$2",
1729
+ minW: minWidth,
1730
+ justify: "space-between",
1731
+ borderWidth: 1,
1732
+ borderColor: "$borderColor",
1733
+ bg: value !== null ? "$color5" : "transparent",
1734
+ icon,
1735
+ iconAfter: /* @__PURE__ */ jsx(ChevronDown, { size: 14, opacity: 0.6 }),
1736
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", numberOfLines: 1, flex: 1, children: triggerLabel })
1737
+ }
1738
+ ),
1739
+ items
1740
+ }
1741
+ );
1742
+ }
1743
+ var LG = 1024;
1744
+ var lockCount = 0;
1745
+ var savedOverflow = "";
1746
+ function lockScroll() {
1747
+ if (typeof document === "undefined") return;
1748
+ if (lockCount === 0) {
1749
+ savedOverflow = document.body.style.overflow;
1750
+ document.body.style.overflow = "hidden";
1751
+ }
1752
+ lockCount++;
1753
+ }
1754
+ function unlockScroll() {
1755
+ if (typeof document === "undefined") return;
1756
+ lockCount = Math.max(0, lockCount - 1);
1757
+ if (lockCount === 0) document.body.style.overflow = savedOverflow;
1758
+ }
1759
+ function SlideOver({
1760
+ open,
1761
+ onClose,
1762
+ side = "right",
1763
+ size = 420,
1764
+ title,
1765
+ icon: Icon,
1766
+ iconColor,
1767
+ headerRight,
1768
+ ariaLabel,
1769
+ zIndex = 1e3,
1770
+ children
1771
+ }) {
1772
+ const panelRef = useRef(null);
1773
+ const openerRef = useRef(null);
1774
+ useEffect(() => {
1775
+ if (!open) return;
1776
+ openerRef.current = typeof document !== "undefined" ? document.activeElement : null;
1777
+ lockScroll();
1778
+ const t = window.setTimeout(() => {
1779
+ const el = panelRef.current;
1780
+ if (el && typeof el.focus === "function") el.focus();
1781
+ }, 0);
1782
+ return () => {
1783
+ window.clearTimeout(t);
1784
+ unlockScroll();
1785
+ const opener = openerRef.current;
1786
+ if (opener && opener instanceof HTMLElement && typeof opener.focus === "function") opener.focus();
1787
+ };
1788
+ }, [open]);
1789
+ useEffect(() => {
1790
+ if (!open) return;
1791
+ const onKey = (e) => {
1792
+ if (e.key === "Escape") {
1793
+ e.stopPropagation();
1794
+ onClose();
1795
+ }
1796
+ };
1797
+ window.addEventListener("keydown", onKey);
1798
+ return () => window.removeEventListener("keydown", onKey);
1799
+ }, [open, onClose]);
1800
+ const offscreen = side === "right" ? "translateX(100%)" : "translateX(-100%)";
1801
+ const edge = side === "right" ? { r: 0 } : { l: 0 };
1802
+ return /* @__PURE__ */ jsxs(
1803
+ YStack,
1804
+ {
1805
+ overflow: "hidden",
1806
+ pointerEvents: open ? "auto" : "none",
1807
+ "aria-hidden": !open,
1808
+ style: { position: "fixed", inset: 0, zIndex },
1809
+ children: [
1810
+ /* @__PURE__ */ jsx(
1811
+ YStack,
1812
+ {
1813
+ position: "absolute",
1814
+ t: 0,
1815
+ l: 0,
1816
+ r: 0,
1817
+ b: 0,
1818
+ bg: "rgba(0,0,0,0.55)",
1819
+ className: "hz-fade",
1820
+ style: { opacity: open ? 1 : 0 },
1821
+ onPress: onClose
1822
+ }
1823
+ ),
1824
+ /* @__PURE__ */ jsx(
1825
+ YStack,
1826
+ {
1827
+ ref: panelRef,
1828
+ tabIndex: -1,
1829
+ role: "dialog",
1830
+ "aria-modal": open ? true : void 0,
1831
+ "aria-label": typeof title === "string" ? title : ariaLabel,
1832
+ position: "absolute",
1833
+ t: 0,
1834
+ b: 0,
1835
+ ...edge,
1836
+ width: "100%",
1837
+ $lg: { width: size, maxW: "100vw" },
1838
+ bg: "$color1",
1839
+ borderLeftWidth: side === "right" ? 1 : 0,
1840
+ borderRightWidth: side === "left" ? 1 : 0,
1841
+ borderColor: "$borderColor",
1842
+ className: "hz-slide",
1843
+ style: { transform: open ? "translateX(0)" : offscreen, height: "100dvh" },
1844
+ children: title !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1845
+ /* @__PURE__ */ jsxs(
1846
+ XStack,
1847
+ {
1848
+ items: "center",
1849
+ gap: "$2.5",
1850
+ px: "$4",
1851
+ height: 56,
1852
+ borderBottomWidth: 1,
1853
+ borderColor: "$borderColor",
1854
+ children: [
1855
+ Icon ? /* @__PURE__ */ jsx(Icon, { size: 18, color: iconColor ? asColor(iconColor) : void 0 }) : null,
1856
+ /* @__PURE__ */ jsx(Text, { flex: 1, fontSize: "$5", fontWeight: "700", color: "$color12", numberOfLines: 1, children: title }),
1857
+ headerRight,
1858
+ /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsx(X, { size: 18 }), onPress: onClose, "aria-label": "Close" })
1859
+ ]
1860
+ }
1861
+ ),
1862
+ /* @__PURE__ */ jsx(ScrollView, { flex: 1, children: /* @__PURE__ */ jsx(YStack, { flex: 1, p: "$4", gap: "$3", children }) })
1863
+ ] }) : (
1864
+ // Bare mode — the caller owns the full panel layout (e.g. the nav drawer
1865
+ // renders its own header + scroll + footer).
1866
+ children
1867
+ )
1868
+ }
1869
+ )
1870
+ ]
1871
+ }
1872
+ );
1873
+ }
1874
+ var toneOf = (status) => {
1875
+ const s = status.toLowerCase();
1876
+ if (s === "green") return "green";
1877
+ if (s === "yellow") return "yellow";
1878
+ if (s === "red") return "red";
1879
+ if (["ready", "active", "running", "available", "ok"].includes(s)) return "green";
1880
+ if (["creating", "provisioning", "pending", "updating", "attaching"].includes(s)) return "yellow";
1881
+ if (["error", "failed", "degraded", "down"].includes(s)) return "red";
1882
+ return "neutral";
1883
+ };
1884
+ var TONE_BG = {
1885
+ green: "$color5",
1886
+ yellow: "$color4",
1887
+ red: "$color4",
1888
+ neutral: "$color3"
1889
+ };
1890
+ var TONE_FG = {
1891
+ green: "$color12",
1892
+ yellow: "$color12",
1893
+ red: "$color12",
1894
+ neutral: "$color11"
1895
+ };
1896
+ function StatusTag({ status }) {
1897
+ const tone2 = toneOf(status ?? "");
1898
+ return /* @__PURE__ */ jsx(Text, { fontSize: "$1", px: "$2", py: "$1", rounded: "$2", bg: TONE_BG[tone2], color: TONE_FG[tone2], children: status || "unknown" });
1899
+ }
1900
+ var ToastContext = createContext(null);
1901
+ var ACCENT3 = {
1902
+ success: "$green10",
1903
+ error: "$red10",
1904
+ info: "$color11"
1905
+ };
1906
+ var ICON = {
1907
+ success: CircleCheck,
1908
+ error: CircleX,
1909
+ info: Info
1910
+ };
1911
+ function ToastCard({ t, onClose }) {
1912
+ const Icon = ICON[t.kind];
1913
+ const accent = ACCENT3[t.kind];
1914
+ return /* @__PURE__ */ jsx(
1915
+ Card,
1916
+ {
1917
+ width: 360,
1918
+ maxWidth: "90%",
1919
+ p: "$3",
1920
+ gap: "$2",
1921
+ bg: "$color2",
1922
+ borderWidth: 1,
1923
+ borderColor: "$borderColor",
1924
+ borderLeftWidth: 3,
1925
+ borderLeftColor: accent,
1926
+ rounded: "$4",
1927
+ elevation: "$2",
1928
+ children: /* @__PURE__ */ jsxs(XStack, { gap: "$2.5", items: "flex-start", children: [
1929
+ /* @__PURE__ */ jsx(YStack, { pt: 1, children: /* @__PURE__ */ jsx(Icon, { size: 18, color: accent }) }),
1930
+ /* @__PURE__ */ jsxs(YStack, { flex: 1, gap: "$1", children: [
1931
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", fontWeight: "700", color: "$color12", children: t.title }),
1932
+ t.description ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", children: t.description }) : null
1933
+ ] }),
1934
+ /* @__PURE__ */ jsx(Button, { size: "$1", chromeless: true, icon: /* @__PURE__ */ jsx(X, { size: 14 }), onPress: onClose, "aria-label": "Dismiss" })
1935
+ ] })
1936
+ }
1937
+ );
1938
+ }
1939
+ function ToastViewport({ toasts, dismiss }) {
1940
+ const [mounted, setMounted] = useState(false);
1941
+ useEffect(() => setMounted(true), []);
1942
+ if (!mounted || typeof document === "undefined") return null;
1943
+ return createPortal(
1944
+ /* @__PURE__ */ jsx("div", { style: { position: "fixed", top: 16, right: 16, zIndex: 1e5, pointerEvents: "none" }, children: /* @__PURE__ */ jsx(YStack, { gap: "$2", items: "flex-end", children: toasts.map((t) => /* @__PURE__ */ jsx(YStack, { pointerEvents: "auto", children: /* @__PURE__ */ jsx(ToastCard, { t, onClose: () => dismiss(t.id) }) }, t.id)) }) }),
1945
+ document.body
1946
+ );
1947
+ }
1948
+ function ToastProvider({ children }) {
1949
+ const [toasts, setToasts] = useState([]);
1950
+ const timers = useRef(/* @__PURE__ */ new Map());
1951
+ const seq = useRef(0);
1952
+ const dismiss = useCallback((id) => {
1953
+ setToasts((ts) => ts.filter((t) => t.id !== id));
1954
+ const timer = timers.current.get(id);
1955
+ if (timer) {
1956
+ clearTimeout(timer);
1957
+ timers.current.delete(id);
1958
+ }
1959
+ }, []);
1960
+ const toast = useCallback(
1961
+ (input) => {
1962
+ const id = ++seq.current;
1963
+ const kind = input.kind ?? "info";
1964
+ const durationMs = input.durationMs ?? (kind === "error" ? 6e3 : 3500);
1965
+ setToasts((ts) => [...ts, { id, kind, title: input.title, description: input.description, durationMs }]);
1966
+ if (durationMs > 0) {
1967
+ timers.current.set(
1968
+ id,
1969
+ setTimeout(() => dismiss(id), durationMs)
1970
+ );
1971
+ }
1972
+ },
1973
+ [dismiss]
1974
+ );
1975
+ useEffect(() => {
1976
+ const map = timers.current;
1977
+ return () => map.forEach((t) => clearTimeout(t));
1978
+ }, []);
1979
+ const api = {
1980
+ toast,
1981
+ success: (title, description) => toast({ title, description, kind: "success" }),
1982
+ error: (title, description) => toast({ title, description, kind: "error" }),
1983
+ info: (title, description) => toast({ title, description, kind: "info" }),
1984
+ dismiss
1985
+ };
1986
+ return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: api, children: [
1987
+ children,
1988
+ /* @__PURE__ */ jsx(ToastViewport, { toasts, dismiss })
1989
+ ] });
1990
+ }
1991
+ function useToast() {
1992
+ const ctx = useContext(ToastContext);
1993
+ if (!ctx) throw new Error("useToast must be used within <ToastProvider>");
1994
+ return ctx;
1995
+ }
1996
+
1997
+ export { AppHeader, BarChart, BarRows, BrandMark, CHART_OTHER, CHART_PALETTE, ComboBox, ContextMenu, DataTable, Donut, Donut2, DropdownMenu, EmptyState, FadeIn, FieldRow, FieldSelect, FieldSlider, FieldSwitch, FieldText, FieldTextArea, FloatingMenu, GenericLogo, HanzoMark, HintButton, LG, LegendDot, LineChart, MenuItemView, MenuLabelView, MenuPanel, MenuSeparatorView, MetricCard, MiniBars, OrgSwitcher, PageHeader, Panel, PortalTheme, PrimaryButton, ProductIcon, ProviderLogo, Reorder, SERIES, SURFACES, SelectMenu, SlideOver, Sparkline, Sparkline2, StatusTag, ToastProvider, UtilBar, asColor, colorForIndex, filterOptions, filterOrgs, isKnownOption, orgScope, otherSurfaces, providerInitials, renderMenuItems, rowShift, targetIndex, useToast, utilColor };
1998
+ //# sourceMappingURL=chunk-GDGVXU7W.js.map
1999
+ //# sourceMappingURL=chunk-GDGVXU7W.js.map