@hanzo/ui 8.0.11 → 8.0.13

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 (169) hide show
  1. package/dist/backends/gui/index.d.ts +2 -0
  2. package/dist/backends/shadcn/aspect-ratio.d.ts +4 -0
  3. package/dist/backends/shadcn/avatar.d.ts +6 -0
  4. package/dist/backends/shadcn/badge.d.ts +9 -0
  5. package/dist/backends/shadcn/button.d.ts +19 -0
  6. package/dist/backends/shadcn/card.d.ts +9 -0
  7. package/dist/backends/shadcn/checkbox.d.ts +9 -0
  8. package/dist/backends/shadcn/collapsible.d.ts +5 -0
  9. package/dist/backends/shadcn/command.d.ts +80 -0
  10. package/dist/backends/shadcn/dialog.d.ts +15 -0
  11. package/dist/backends/shadcn/dropdown-menu.d.ts +34 -0
  12. package/dist/backends/shadcn/index.d.ts +23 -0
  13. package/dist/backends/shadcn/input.d.ts +11 -0
  14. package/dist/backends/shadcn/label.d.ts +4 -0
  15. package/dist/backends/shadcn/popover.d.ts +7 -0
  16. package/dist/backends/shadcn/progress.d.ts +4 -0
  17. package/dist/backends/shadcn/scroll-area.d.ts +5 -0
  18. package/dist/backends/shadcn/select.d.ts +13 -0
  19. package/dist/backends/shadcn/separator.d.ts +4 -0
  20. package/dist/backends/shadcn/slider.d.ts +4 -0
  21. package/dist/backends/shadcn/switch.d.ts +4 -0
  22. package/dist/backends/shadcn/tabs.d.ts +7 -0
  23. package/dist/backends/shadcn/textarea.d.ts +4 -0
  24. package/dist/backends/shadcn/toaster.d.ts +10 -0
  25. package/dist/backends/shadcn/tooltip.d.ts +7 -0
  26. package/dist/backends/shadcn/utils.d.ts +8 -0
  27. package/dist/components.d.ts +1 -0
  28. package/dist/core/cn.d.ts +11 -0
  29. package/dist/core/fonts.d.ts +26 -0
  30. package/dist/core/index.d.ts +3 -0
  31. package/dist/core/tokens.d.ts +16 -0
  32. package/dist/gitops.cjs +3 -3
  33. package/dist/gitops.d.ts +1 -1
  34. package/dist/gitops.js +1 -1
  35. package/dist/index.cjs +1138 -291
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.js +1017 -3
  39. package/dist/index.js.map +1 -1
  40. package/dist/models/ModelSelector.d.ts +23 -0
  41. package/dist/models/catalog.d.ts +53 -0
  42. package/dist/models/index.d.ts +5 -0
  43. package/dist/models/types.d.ts +39 -0
  44. package/dist/primitives/AspectRatio.d.ts +1 -0
  45. package/dist/primitives/Avatar.d.ts +1 -0
  46. package/dist/primitives/AvatarFallback.d.ts +1 -0
  47. package/dist/primitives/AvatarImage.d.ts +1 -0
  48. package/dist/primitives/Badge.d.ts +1 -0
  49. package/dist/primitives/Button.d.ts +1 -0
  50. package/dist/primitives/Card.d.ts +1 -0
  51. package/dist/primitives/CardAction.d.ts +1 -0
  52. package/dist/primitives/CardContent.d.ts +1 -0
  53. package/dist/primitives/CardDescription.d.ts +1 -0
  54. package/dist/primitives/CardFooter.d.ts +1 -0
  55. package/dist/primitives/CardHeader.d.ts +1 -0
  56. package/dist/primitives/CardTitle.d.ts +1 -0
  57. package/dist/primitives/Checkbox.d.ts +1 -0
  58. package/dist/primitives/Collapsible.d.ts +1 -0
  59. package/dist/primitives/CollapsibleContent.d.ts +1 -0
  60. package/dist/primitives/CollapsibleTrigger.d.ts +1 -0
  61. package/dist/primitives/Command.d.ts +1 -0
  62. package/dist/primitives/CommandDialog.d.ts +1 -0
  63. package/dist/primitives/CommandEmpty.d.ts +1 -0
  64. package/dist/primitives/CommandGroup.d.ts +1 -0
  65. package/dist/primitives/CommandInput.d.ts +1 -0
  66. package/dist/primitives/CommandItem.d.ts +1 -0
  67. package/dist/primitives/CommandList.d.ts +1 -0
  68. package/dist/primitives/CommandSeparator.d.ts +1 -0
  69. package/dist/primitives/CommandShortcut.d.ts +1 -0
  70. package/dist/primitives/Dialog.d.ts +1 -0
  71. package/dist/primitives/DialogClose.d.ts +1 -0
  72. package/dist/primitives/DialogContent.d.ts +1 -0
  73. package/dist/primitives/DialogDescription.d.ts +1 -0
  74. package/dist/primitives/DialogFooter.d.ts +1 -0
  75. package/dist/primitives/DialogHeader.d.ts +1 -0
  76. package/dist/primitives/DialogOverlay.d.ts +1 -0
  77. package/dist/primitives/DialogPortal.d.ts +1 -0
  78. package/dist/primitives/DialogTitle.d.ts +1 -0
  79. package/dist/primitives/DialogTrigger.d.ts +1 -0
  80. package/dist/primitives/DropdownMenu.d.ts +1 -0
  81. package/dist/primitives/DropdownMenuCheckboxItem.d.ts +1 -0
  82. package/dist/primitives/DropdownMenuContent.d.ts +1 -0
  83. package/dist/primitives/DropdownMenuGroup.d.ts +1 -0
  84. package/dist/primitives/DropdownMenuItem.d.ts +1 -0
  85. package/dist/primitives/DropdownMenuLabel.d.ts +1 -0
  86. package/dist/primitives/DropdownMenuPortal.d.ts +1 -0
  87. package/dist/primitives/DropdownMenuRadioGroup.d.ts +1 -0
  88. package/dist/primitives/DropdownMenuRadioItem.d.ts +1 -0
  89. package/dist/primitives/DropdownMenuSeparator.d.ts +1 -0
  90. package/dist/primitives/DropdownMenuShortcut.d.ts +1 -0
  91. package/dist/primitives/DropdownMenuSub.d.ts +1 -0
  92. package/dist/primitives/DropdownMenuSubContent.d.ts +1 -0
  93. package/dist/primitives/DropdownMenuSubTrigger.d.ts +1 -0
  94. package/dist/primitives/DropdownMenuTrigger.d.ts +1 -0
  95. package/dist/primitives/Input.d.ts +1 -0
  96. package/dist/primitives/Label.d.ts +1 -0
  97. package/dist/primitives/Popover.d.ts +1 -0
  98. package/dist/primitives/PopoverAnchor.d.ts +1 -0
  99. package/dist/primitives/PopoverContent.d.ts +1 -0
  100. package/dist/primitives/PopoverTrigger.d.ts +1 -0
  101. package/dist/primitives/Progress.d.ts +1 -0
  102. package/dist/primitives/ScrollArea.d.ts +1 -0
  103. package/dist/primitives/ScrollBar.d.ts +1 -0
  104. package/dist/primitives/Select.d.ts +1 -0
  105. package/dist/primitives/SelectContent.d.ts +1 -0
  106. package/dist/primitives/SelectGroup.d.ts +1 -0
  107. package/dist/primitives/SelectItem.d.ts +1 -0
  108. package/dist/primitives/SelectLabel.d.ts +1 -0
  109. package/dist/primitives/SelectScrollDownButton.d.ts +1 -0
  110. package/dist/primitives/SelectScrollUpButton.d.ts +1 -0
  111. package/dist/primitives/SelectSeparator.d.ts +1 -0
  112. package/dist/primitives/SelectTrigger.d.ts +1 -0
  113. package/dist/primitives/SelectValue.d.ts +1 -0
  114. package/dist/primitives/Separator.d.ts +1 -0
  115. package/dist/primitives/Slider.d.ts +1 -0
  116. package/dist/primitives/Switch.d.ts +1 -0
  117. package/dist/primitives/Tabs.d.ts +1 -0
  118. package/dist/primitives/TabsContent.d.ts +1 -0
  119. package/dist/primitives/TabsList.d.ts +1 -0
  120. package/dist/primitives/TabsTrigger.d.ts +1 -0
  121. package/dist/primitives/Textarea.d.ts +1 -0
  122. package/dist/primitives/Toaster.d.ts +1 -0
  123. package/dist/primitives/Tooltip.d.ts +1 -0
  124. package/dist/primitives/TooltipContent.d.ts +1 -0
  125. package/dist/primitives/TooltipProvider.d.ts +1 -0
  126. package/dist/primitives/TooltipTrigger.d.ts +1 -0
  127. package/dist/primitives/badgeVariants.d.ts +1 -0
  128. package/dist/primitives/buttonVariants.d.ts +1 -0
  129. package/dist/primitives/index.d.ts +1 -0
  130. package/dist/primitives/toast.d.ts +1 -0
  131. package/dist/product/AnimatedLogo.d.ts +47 -0
  132. package/dist/product/BackendState.d.ts +42 -0
  133. package/dist/product/Charts.d.ts +4 -0
  134. package/dist/product/CommerceResource.d.ts +32 -0
  135. package/dist/product/ConfirmDelete.d.ts +8 -0
  136. package/dist/product/DataTable.d.ts +30 -2
  137. package/dist/product/Field.d.ts +7 -2
  138. package/dist/product/Filters.d.ts +29 -0
  139. package/dist/product/PrimaryButton.d.ts +5 -0
  140. package/dist/product/SiteFooter.d.ts +28 -0
  141. package/dist/product/SiteNav.d.ts +60 -0
  142. package/dist/product/accent.d.ts +33 -0
  143. package/dist/product/animatedLogo.logic.d.ts +52 -0
  144. package/dist/product/brand.d.ts +45 -0
  145. package/dist/product/host.d.ts +21 -0
  146. package/dist/product/index.cjs +3516 -265
  147. package/dist/product/index.cjs.map +1 -1
  148. package/dist/product/index.d.ts +11 -0
  149. package/dist/product/index.js +3402 -1
  150. package/dist/product/index.js.map +1 -1
  151. package/dist/product/social/CampaignCard.d.ts +13 -0
  152. package/dist/product/social/ChannelBadge.d.ts +14 -0
  153. package/dist/product/social/PostAgenda.d.ts +5 -0
  154. package/dist/product/social/PostCard.d.ts +6 -0
  155. package/dist/product/social/PostComposer.d.ts +24 -0
  156. package/dist/product/social/ProviderReadinessList.d.ts +4 -0
  157. package/dist/product/social/SocialResource.d.ts +7 -0
  158. package/dist/product/social/SocialSummaryBar.d.ts +4 -0
  159. package/dist/product/social/ViewToggle.d.ts +5 -0
  160. package/dist/product/social/api.d.ts +128 -0
  161. package/dist/product/social/format.d.ts +16 -0
  162. package/dist/product/social/index.d.ts +11 -0
  163. package/dist/product/surfaces.data.d.ts +1 -0
  164. package/dist/styles/hanzo-motion.css +52 -0
  165. package/package.json +90 -15
  166. package/dist/chunk-M2ILMK44.cjs +0 -2104
  167. package/dist/chunk-M2ILMK44.cjs.map +0 -1
  168. package/dist/chunk-YSURJUOA.js +0 -2035
  169. package/dist/chunk-YSURJUOA.js.map +0 -1
@@ -1,2035 +0,0 @@
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
- function monogram(name) {
972
- const words = name.trim().split(/[\s._/-]+/).filter(Boolean);
973
- const letters = words.slice(0, 2).map((w) => w[0] ?? "").join("");
974
- return (letters || name.trim().slice(0, 2)).toUpperCase();
975
- }
976
- function OrgMark({ org, size = 22, maxW }) {
977
- if (org.logo) {
978
- return /* @__PURE__ */ jsx(
979
- "img",
980
- {
981
- src: org.logo,
982
- alt: "",
983
- style: {
984
- height: size,
985
- width: maxW ? "auto" : size,
986
- maxWidth: maxW ?? size,
987
- objectFit: "contain",
988
- display: "block",
989
- borderRadius: 6,
990
- flexShrink: 0
991
- }
992
- }
993
- );
994
- }
995
- return /* @__PURE__ */ jsx(
996
- YStack,
997
- {
998
- width: size,
999
- height: size,
1000
- rounded: "$3",
1001
- bg: "$color4",
1002
- items: "center",
1003
- justify: "center",
1004
- style: { flexShrink: 0 },
1005
- children: /* @__PURE__ */ jsx(Text, { fontSize: Math.round(size * 0.4), fontWeight: "800", color: "$color12", children: monogram(org.displayName || org.name) })
1006
- }
1007
- );
1008
- }
1009
-
1010
- // src/product/scope.ts
1011
- function browserStorage() {
1012
- if (typeof window === "undefined") return null;
1013
- try {
1014
- return window.localStorage;
1015
- } catch {
1016
- return null;
1017
- }
1018
- }
1019
- function orgScope(config) {
1020
- const key = config.key ?? "hanzo.org";
1021
- const selectedKey = `${key}.selected`;
1022
- const store = () => config.storage ?? browserStorage();
1023
- const read = (k) => {
1024
- try {
1025
- return store()?.getItem(k) ?? null;
1026
- } catch {
1027
- return null;
1028
- }
1029
- };
1030
- const write = (k, v) => {
1031
- try {
1032
- if (v === null) store()?.removeItem(k);
1033
- else store()?.setItem(k, v);
1034
- } catch {
1035
- }
1036
- };
1037
- const goHome = () => {
1038
- if (config.navigate) return config.navigate("/");
1039
- if (typeof window !== "undefined") window.location.assign("/");
1040
- };
1041
- const doReload = () => {
1042
- if (config.reload) return config.reload();
1043
- if (typeof window !== "undefined") window.location.reload();
1044
- };
1045
- const scope = {
1046
- currentOrg: () => read(key) || config.brandOrg,
1047
- setCurrentOrg: (org) => write(key, !org || org === config.brandOrg ? null : org),
1048
- isScopedAway: () => scope.currentOrg() !== config.brandOrg,
1049
- hasSelectedOrg: () => read(selectedKey) === "1",
1050
- enterOrg: (org) => {
1051
- if (!org) return;
1052
- scope.setCurrentOrg(org);
1053
- write(selectedKey, "1");
1054
- goHome();
1055
- },
1056
- leaveOrg: () => {
1057
- write(selectedKey, null);
1058
- scope.setCurrentOrg(config.brandOrg);
1059
- goHome();
1060
- },
1061
- switchOrg: (org) => {
1062
- if (!org || org === scope.currentOrg()) return;
1063
- scope.setCurrentOrg(org);
1064
- write(selectedKey, "1");
1065
- doReload();
1066
- }
1067
- };
1068
- return scope;
1069
- }
1070
- function filterOrgs(orgs, query) {
1071
- const q = query.trim().toLowerCase();
1072
- if (!q) return orgs;
1073
- return orgs.filter(
1074
- (o) => o.name.toLowerCase().includes(q) || (o.displayName ?? "").toLowerCase().includes(q)
1075
- );
1076
- }
1077
- var titleCase = (s) => s ? s[0].toUpperCase() + s.slice(1) : s;
1078
- function OrgSwitcher({ scope, orgs, pageSize = 20, current: given, create, picker = false }) {
1079
- const currentId = scope.currentOrg();
1080
- const [open, setOpen] = useState(false);
1081
- const [query, setQuery] = useState("");
1082
- const [debounced, setDebounced] = useState("");
1083
- const [rows, setRows] = useState([]);
1084
- const [loading, setLoading] = useState(false);
1085
- const [loadingMore, setLoadingMore] = useState(false);
1086
- const [hasMore, setHasMore] = useState(false);
1087
- const [creating, setCreating] = useState(false);
1088
- const [newName, setNewName] = useState("");
1089
- const [busy, setBusy] = useState(false);
1090
- const [err, setErr] = useState(null);
1091
- const pageRef = useRef(0);
1092
- const reqRef = useRef(0);
1093
- useEffect(() => {
1094
- const id = setTimeout(() => setDebounced(query.trim()), 250);
1095
- return () => clearTimeout(id);
1096
- }, [query]);
1097
- const fetchPage = useCallback(
1098
- async (page, q, append) => {
1099
- if (!orgs) return;
1100
- const token = ++reqRef.current;
1101
- append ? setLoadingMore(true) : setLoading(true);
1102
- try {
1103
- const incoming = await orgs(page, q);
1104
- if (token !== reqRef.current) return;
1105
- pageRef.current = page;
1106
- setRows((prev) => {
1107
- const merged = append ? [...prev] : [];
1108
- const seen = new Set(merged.map((o) => o.name));
1109
- for (const o of incoming) if (!seen.has(o.name)) merged.push(o);
1110
- return merged;
1111
- });
1112
- setHasMore(incoming.length >= pageSize);
1113
- } catch {
1114
- if (token !== reqRef.current) return;
1115
- if (!append) setRows([]);
1116
- setHasMore(false);
1117
- } finally {
1118
- if (token === reqRef.current) {
1119
- setLoading(false);
1120
- setLoadingMore(false);
1121
- }
1122
- }
1123
- },
1124
- [orgs, pageSize]
1125
- );
1126
- useEffect(() => {
1127
- if (!open || !orgs) return;
1128
- void fetchPage(0, debounced, false);
1129
- }, [open, debounced, fetchPage, orgs]);
1130
- const loadMore = useCallback(() => {
1131
- if (loading || loadingMore || !hasMore) return;
1132
- void fetchPage(pageRef.current + 1, debounced, true);
1133
- }, [loading, loadingMore, hasMore, debounced, fetchPage]);
1134
- const visible = useMemo(() => {
1135
- if (orgs) return filterOrgs(rows, query);
1136
- return [{ name: currentId, displayName: titleCase(currentId) }];
1137
- }, [orgs, rows, query, currentId]);
1138
- const current = useMemo(() => {
1139
- if (given && given.name === currentId) return given;
1140
- return rows.find((o) => o.name === currentId) ?? { name: currentId, displayName: titleCase(currentId) };
1141
- }, [given, rows, currentId]);
1142
- const currentLabel = current.displayName || titleCase(current.name);
1143
- const select = useCallback(
1144
- (org) => {
1145
- setOpen(false);
1146
- scope.switchOrg(org);
1147
- },
1148
- [scope]
1149
- );
1150
- const submitCreate = async () => {
1151
- const name = newName.trim();
1152
- if (!name || !create) return;
1153
- setBusy(true);
1154
- setErr(null);
1155
- try {
1156
- const org = await create(name);
1157
- scope.switchOrg(org);
1158
- } catch (e) {
1159
- setErr(e instanceof Error ? e.message : "Could not create the organization.");
1160
- setBusy(false);
1161
- }
1162
- };
1163
- return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, placement: "bottom-start", children: [
1164
- /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { chromeless: true, height: 44, px: "$2", justify: "flex-start", "aria-label": `${currentLabel} \xB7 switch organization`, children: /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2.5", flex: 1, minW: 0, children: [
1165
- /* @__PURE__ */ jsx(OrgMark, { org: current, size: 30 }),
1166
- /* @__PURE__ */ jsx(Text, { flex: 1, minW: 0, fontSize: "$4", fontWeight: "800", color: "$color12", numberOfLines: 1, children: currentLabel }),
1167
- /* @__PURE__ */ jsx(ChevronsUpDown, { size: 15, color: "$color9" })
1168
- ] }) }) }),
1169
- /* @__PURE__ */ jsx(Popover.Content, { bordered: true, elevate: true, p: "$2", width: 300, bg: "$color2", borderColor: "$borderColor", children: creating ? /* @__PURE__ */ jsxs(YStack, { gap: "$2", children: [
1170
- /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", fontWeight: "700", children: "Create organization" }),
1171
- /* @__PURE__ */ jsx(
1172
- Input,
1173
- {
1174
- size: "$3",
1175
- placeholder: "Organization name",
1176
- value: newName,
1177
- onChangeText: setNewName,
1178
- autoCapitalize: "words",
1179
- onSubmitEditing: () => void submitCreate()
1180
- }
1181
- ),
1182
- err ? /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$red10", children: err }) : null,
1183
- /* @__PURE__ */ jsxs(XStack, { gap: "$2", justify: "flex-end", children: [
1184
- /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, onPress: () => setCreating(false), disabled: busy, children: "Cancel" }),
1185
- /* @__PURE__ */ jsx(
1186
- Button,
1187
- {
1188
- size: "$2",
1189
- onPress: () => void submitCreate(),
1190
- disabled: busy || !newName.trim(),
1191
- icon: busy ? /* @__PURE__ */ jsx(Spinner, { size: "small" }) : /* @__PURE__ */ jsx(Plus, { size: 14 }),
1192
- children: "Create"
1193
- }
1194
- )
1195
- ] })
1196
- ] }) : /* @__PURE__ */ jsxs(YStack, { gap: "$1", children: [
1197
- orgs ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$1", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [
1198
- /* @__PURE__ */ jsx(Search, { size: 13, opacity: 0.6 }),
1199
- /* @__PURE__ */ jsx(
1200
- Input,
1201
- {
1202
- flex: 1,
1203
- size: "$2",
1204
- borderWidth: 0,
1205
- bg: "transparent",
1206
- placeholder: "Find organization\u2026",
1207
- value: query,
1208
- onChangeText: setQuery,
1209
- autoCapitalize: "none",
1210
- autoCorrect: false
1211
- }
1212
- )
1213
- ] }) : null,
1214
- /* @__PURE__ */ jsxs(
1215
- "div",
1216
- {
1217
- style: { maxHeight: 300, overflowY: "auto", display: "flex", flexDirection: "column" },
1218
- onScroll: (e) => {
1219
- const el = e.currentTarget;
1220
- if (el.scrollHeight - el.scrollTop - el.clientHeight < 48) loadMore();
1221
- },
1222
- children: [
1223
- loading ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$3", children: [
1224
- /* @__PURE__ */ jsx(Spinner, { size: "small", color: "$color11" }),
1225
- /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", children: "Loading organizations\u2026" })
1226
- ] }) : 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(
1227
- XStack,
1228
- {
1229
- onPress: () => select(org.name),
1230
- cursor: "pointer",
1231
- items: "center",
1232
- gap: "$2.5",
1233
- px: "$2",
1234
- py: "$2",
1235
- rounded: "$3",
1236
- bg: org.name === currentId ? "$color4" : "transparent",
1237
- hoverStyle: { bg: "$color5" },
1238
- children: [
1239
- /* @__PURE__ */ jsx(OrgMark, { org }),
1240
- /* @__PURE__ */ jsx(Text, { flex: 1, fontSize: "$2", color: "$color12", numberOfLines: 1, children: org.displayName || org.name }),
1241
- org.name === currentId ? /* @__PURE__ */ jsx(Check, { size: 15 }) : null
1242
- ]
1243
- },
1244
- org.name
1245
- )),
1246
- loadingMore ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$2", children: [
1247
- /* @__PURE__ */ jsx(Spinner, { size: "small", color: "$color11" }),
1248
- /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color10", children: "Loading more\u2026" })
1249
- ] }) : 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
1250
- ]
1251
- }
1252
- ),
1253
- create ? /* @__PURE__ */ jsxs(
1254
- XStack,
1255
- {
1256
- onPress: () => {
1257
- setCreating(true);
1258
- setErr(null);
1259
- },
1260
- cursor: "pointer",
1261
- items: "center",
1262
- gap: "$2.5",
1263
- px: "$2",
1264
- py: "$2",
1265
- mt: "$1",
1266
- rounded: "$3",
1267
- borderTopWidth: 1,
1268
- borderColor: "$borderColor",
1269
- hoverStyle: { bg: "$color5" },
1270
- children: [
1271
- /* @__PURE__ */ jsx(YStack, { width: 22, height: 22, rounded: "$3", bg: "$color3", items: "center", justify: "center", children: /* @__PURE__ */ jsx(Plus, { size: 14 }) }),
1272
- /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", children: "Create organization" })
1273
- ]
1274
- }
1275
- ) : null,
1276
- picker ? /* @__PURE__ */ jsxs(
1277
- XStack,
1278
- {
1279
- onPress: () => {
1280
- setOpen(false);
1281
- scope.leaveOrg();
1282
- },
1283
- cursor: "pointer",
1284
- items: "center",
1285
- gap: "$2.5",
1286
- px: "$2",
1287
- py: "$2",
1288
- rounded: "$3",
1289
- hoverStyle: { bg: "$color5" },
1290
- children: [
1291
- /* @__PURE__ */ jsx(YStack, { width: 22, height: 22, rounded: "$3", bg: "$color3", items: "center", justify: "center", children: /* @__PURE__ */ jsx(LayoutGrid, { size: 14 }) }),
1292
- /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", children: "All organizations" })
1293
- ]
1294
- }
1295
- ) : null
1296
- ] }) })
1297
- ] });
1298
- }
1299
- function DropdownMenu({
1300
- trigger,
1301
- items,
1302
- open,
1303
- defaultOpen = false,
1304
- onOpenChange,
1305
- minWidth = 200,
1306
- maxHeight
1307
- }) {
1308
- const [isOpen, setOpen] = useControllableState({
1309
- prop: open,
1310
- defaultProp: defaultOpen,
1311
- onChange: onOpenChange
1312
- });
1313
- const anchorRef = useRef(null);
1314
- const anchorRect = useCallback(() => anchorRef.current?.getBoundingClientRect() ?? null, []);
1315
- const anchorEl = useCallback(() => anchorRef.current, []);
1316
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1317
- /* @__PURE__ */ jsx(XStack, { ref: anchorRef, self: "flex-start", cursor: "pointer", onPress: () => setOpen(!isOpen), children: trigger }),
1318
- /* @__PURE__ */ jsx(
1319
- FloatingMenu,
1320
- {
1321
- open: isOpen,
1322
- onClose: () => setOpen(false),
1323
- anchorRect,
1324
- anchorEl,
1325
- minWidth,
1326
- maxHeight,
1327
- children: renderMenuItems(items, () => setOpen(false))
1328
- }
1329
- )
1330
- ] });
1331
- }
1332
- function ContextMenu({ children, items, disabled, minWidth = 200, maxHeight }) {
1333
- const [state, setState] = useState({ open: false, x: 0, y: 0 });
1334
- const close = useCallback(() => setState((s) => s.open ? { ...s, open: false } : s), []);
1335
- const anchorRect = useCallback(
1336
- () => ({ left: state.x, top: state.y, right: state.x, bottom: state.y, width: 0, height: 0 }),
1337
- [state.x, state.y]
1338
- );
1339
- const childOnContextMenu = children.props.onContextMenu;
1340
- const target = cloneElement(children, {
1341
- onContextMenu: (e) => {
1342
- childOnContextMenu?.(e);
1343
- if (disabled) return;
1344
- e.preventDefault();
1345
- e.stopPropagation();
1346
- setState({ open: true, x: e.clientX, y: e.clientY });
1347
- }
1348
- });
1349
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1350
- target,
1351
- /* @__PURE__ */ jsx(FloatingMenu, { open: state.open, onClose: close, anchorRect, gap: 0, minWidth, maxHeight, children: renderMenuItems(items, close) })
1352
- ] });
1353
- }
1354
- function DataTable({
1355
- columns,
1356
- rows,
1357
- loading,
1358
- empty = "Nothing here yet.",
1359
- rowKey,
1360
- onRowPress
1361
- }) {
1362
- if (loading) {
1363
- return /* @__PURE__ */ jsx(XStack, { p: "$6", justify: "center", children: /* @__PURE__ */ jsx(Spinner, { size: "large", color: "$color11" }) });
1364
- }
1365
- if (rows.length === 0) {
1366
- return /* @__PURE__ */ jsx(YStack, { p: "$6", items: "center", borderWidth: 1, borderColor: "$borderColor", rounded: "$4", children: /* @__PURE__ */ jsx(Text, { color: "$color11", children: empty }) });
1367
- }
1368
- return /* @__PURE__ */ jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", overflow: "hidden", children: [
1369
- /* @__PURE__ */ jsx(XStack, { bg: "$color2", py: "$2.5", px: "$3", gap: "$3", children: columns.map((c) => /* @__PURE__ */ jsx(
1370
- Text,
1371
- {
1372
- width: c.width,
1373
- flex: c.width ? void 0 : 1,
1374
- fontSize: "$2",
1375
- fontWeight: "700",
1376
- color: "$color11",
1377
- children: c.header
1378
- },
1379
- c.key
1380
- )) }),
1381
- /* @__PURE__ */ jsx(YStack, { children: rows.map((row) => /* @__PURE__ */ jsx(
1382
- XStack,
1383
- {
1384
- py: "$2.5",
1385
- px: "$3",
1386
- gap: "$3",
1387
- borderTopWidth: 1,
1388
- borderColor: "$borderColor",
1389
- items: "center",
1390
- hoverStyle: onRowPress ? { bg: "$color2" } : void 0,
1391
- cursor: onRowPress ? "pointer" : void 0,
1392
- onPress: onRowPress ? () => onRowPress(row) : void 0,
1393
- 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))
1394
- },
1395
- rowKey(row)
1396
- )) })
1397
- ] });
1398
- }
1399
- function PrimaryButton(props) {
1400
- return /* @__PURE__ */ jsx(Button, { theme: "light", ...props });
1401
- }
1402
- function openHref2(href) {
1403
- if (typeof window !== "undefined") window.open(href, "_blank", "noopener");
1404
- }
1405
- function EmptyState({
1406
- icon: Icon,
1407
- title,
1408
- description,
1409
- bullets,
1410
- primary,
1411
- secondary
1412
- }) {
1413
- return /* @__PURE__ */ jsxs(
1414
- Card,
1415
- {
1416
- borderWidth: 1,
1417
- borderColor: "$borderColor",
1418
- borderStyle: "dashed",
1419
- p: "$6",
1420
- gap: "$4",
1421
- items: "center",
1422
- maxWidth: 640,
1423
- self: "center",
1424
- width: "100%",
1425
- children: [
1426
- /* @__PURE__ */ jsx(
1427
- YStack,
1428
- {
1429
- width: 48,
1430
- height: 48,
1431
- items: "center",
1432
- justify: "center",
1433
- rounded: "$4",
1434
- bg: "$color3",
1435
- children: /* @__PURE__ */ jsx(Icon, { size: 24 })
1436
- }
1437
- ),
1438
- /* @__PURE__ */ jsxs(YStack, { gap: "$2", items: "center", maxW: 480, children: [
1439
- /* @__PURE__ */ jsx(Text, { fontSize: "$6", fontWeight: "800", text: "center", children: title }),
1440
- /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", text: "center", children: description })
1441
- ] }),
1442
- 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: [
1443
- /* @__PURE__ */ jsx(YStack, { pt: "$1", children: /* @__PURE__ */ jsx(Check, { size: 14, color: "$color10" }) }),
1444
- /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", flex: 1, children: b })
1445
- ] }, b)) }) : null,
1446
- primary || secondary ? /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", justify: "center", children: [
1447
- primary ? /* @__PURE__ */ jsx(
1448
- PrimaryButton,
1449
- {
1450
- icon: primary.icon,
1451
- iconAfter: primary.href ? /* @__PURE__ */ jsx(ExternalLink, { size: 15 }) : /* @__PURE__ */ jsx(ArrowRight, { size: 15 }),
1452
- onPress: () => primary.href ? openHref2(primary.href) : primary.onPress?.(),
1453
- children: primary.label
1454
- }
1455
- ) : null,
1456
- secondary ? /* @__PURE__ */ jsx(
1457
- Button,
1458
- {
1459
- chromeless: true,
1460
- icon: secondary.icon,
1461
- iconAfter: secondary.href ? /* @__PURE__ */ jsx(ExternalLink, { size: 14 }) : void 0,
1462
- onPress: () => secondary.href ? openHref2(secondary.href) : secondary.onPress?.(),
1463
- children: secondary.label
1464
- }
1465
- ) : null
1466
- ] }) : null
1467
- ]
1468
- }
1469
- );
1470
- }
1471
- function FadeIn({
1472
- children,
1473
- index = 0,
1474
- step = 50,
1475
- delayMs,
1476
- style
1477
- }) {
1478
- const delay = delayMs ?? index * step;
1479
- return /* @__PURE__ */ jsx("div", { className: "hz-fade-up", style: { animationDelay: `${delay}ms`, ...style }, children });
1480
- }
1481
- function FieldRow({ label, children }) {
1482
- return /* @__PURE__ */ jsxs(XStack, { gap: "$3", items: "flex-start", flexWrap: "wrap", children: [
1483
- /* @__PURE__ */ jsx(Label, { width: 180, pt: "$2", color: "$color11", fontSize: "$3", children: label }),
1484
- /* @__PURE__ */ jsx(YStack, { flex: 1, minW: 240, children })
1485
- ] });
1486
- }
1487
- function FieldText({
1488
- value,
1489
- onChange,
1490
- disabled,
1491
- secure,
1492
- placeholder
1493
- }) {
1494
- return /* @__PURE__ */ jsx(
1495
- Input,
1496
- {
1497
- value,
1498
- onChangeText: onChange,
1499
- disabled,
1500
- secureTextEntry: secure,
1501
- placeholder,
1502
- autoCapitalize: "none"
1503
- }
1504
- );
1505
- }
1506
- function FieldTextArea({
1507
- value,
1508
- onChange,
1509
- disabled,
1510
- rows = 6
1511
- }) {
1512
- return /* @__PURE__ */ jsx(TextArea, { value, onChangeText: onChange, disabled, numberOfLines: rows });
1513
- }
1514
- function FieldSwitch({
1515
- checked,
1516
- onChange,
1517
- disabled
1518
- }) {
1519
- return /* @__PURE__ */ jsx(Switch, { checked, onCheckedChange: onChange, disabled, size: "$3", children: /* @__PURE__ */ jsx(Switch.Thumb, {}) });
1520
- }
1521
- function FieldSelect({
1522
- value,
1523
- options,
1524
- onChange,
1525
- disabled
1526
- }) {
1527
- return /* @__PURE__ */ jsxs(Select, { value, onValueChange: onChange, disablePreventBodyScroll: true, native: true, children: [
1528
- /* @__PURE__ */ jsx(Select.Trigger, { disabled, iconAfter: /* @__PURE__ */ jsx(ChevronDown, { size: 16 }), children: /* @__PURE__ */ jsx(Select.Value, { placeholder: "Select\u2026" }) }),
1529
- /* @__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)) }) })
1530
- ] });
1531
- }
1532
- function FieldSlider({
1533
- value,
1534
- min,
1535
- max,
1536
- step,
1537
- onChange,
1538
- disabled
1539
- }) {
1540
- return /* @__PURE__ */ jsxs(XStack, { gap: "$3", items: "center", children: [
1541
- /* @__PURE__ */ jsx(Text, { width: 56, fontSize: "$3", color: "$color11", children: value }),
1542
- /* @__PURE__ */ jsxs(
1543
- Slider,
1544
- {
1545
- flex: 1,
1546
- min,
1547
- max,
1548
- step,
1549
- value: [value],
1550
- onValueChange: (v) => onChange(v[0] ?? min),
1551
- disabled,
1552
- children: [
1553
- /* @__PURE__ */ jsx(Slider.Track, { children: /* @__PURE__ */ jsx(Slider.TrackActive, {}) }),
1554
- /* @__PURE__ */ jsx(Slider.Thumb, { index: 0, circular: true })
1555
- ]
1556
- }
1557
- )
1558
- ] });
1559
- }
1560
- function PageHeader({
1561
- title,
1562
- subtitle,
1563
- actions
1564
- }) {
1565
- return /* @__PURE__ */ jsxs(XStack, { justify: "space-between", items: "flex-start", gap: "$4", children: [
1566
- /* @__PURE__ */ jsxs(YStack, { gap: "$1", children: [
1567
- /* @__PURE__ */ jsx(Text, { fontSize: "$7", fontWeight: "800", children: title }),
1568
- subtitle ? /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", children: subtitle }) : null
1569
- ] }),
1570
- actions ? /* @__PURE__ */ jsx(XStack, { gap: "$2", children: actions }) : null
1571
- ] });
1572
- }
1573
-
1574
- // src/product/color.ts
1575
- var asColor = (hex) => hex;
1576
- function ProductIcon({
1577
- icon: Icon,
1578
- color,
1579
- size = 24
1580
- }) {
1581
- const radius = Math.round(size * 0.28);
1582
- const glyph = Math.round(size * 0.58);
1583
- const tinted = typeof color === "string" && color.trim() !== "";
1584
- if (tinted) {
1585
- return /* @__PURE__ */ jsx(
1586
- XStack,
1587
- {
1588
- width: size,
1589
- height: size,
1590
- items: "center",
1591
- justify: "center",
1592
- rounded: radius,
1593
- style: { backgroundColor: color },
1594
- children: /* @__PURE__ */ jsx(Icon, { size: glyph, color: asColor("#ffffff") })
1595
- }
1596
- );
1597
- }
1598
- return /* @__PURE__ */ jsx(XStack, { width: size, height: size, items: "center", justify: "center", rounded: radius, bg: "$color12", children: /* @__PURE__ */ jsx(Icon, { size: glyph, color: "$color1" }) });
1599
- }
1600
- var KNOWN = {
1601
- openrouter: Globe,
1602
- nvidia: Cpu
1603
- };
1604
- var isFirstParty = (provider) => {
1605
- const p = provider.trim().toLowerCase();
1606
- return p === "hanzo" || p === "zen";
1607
- };
1608
- function EnsoMark({ size, color }) {
1609
- 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" }) });
1610
- }
1611
- var HANZO_PATHS = [
1612
- "M22.21 67V44.6369H0V67H22.21Z",
1613
- "M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z",
1614
- "M22.21 0H0V22.3184H22.21V0Z",
1615
- "M66.7198 0H44.5098V22.3184H66.7198V0Z",
1616
- "M66.7198 67V44.6369H44.5098V67H66.7198Z"
1617
- ];
1618
- function HanzoHMark({ size, color }) {
1619
- 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)) });
1620
- }
1621
- function providerInitials(provider) {
1622
- const name = provider.trim();
1623
- if (!name) return "\u2022";
1624
- const words = name.split(/[\s/_-]+/).filter(Boolean);
1625
- if (words.length >= 2) return (words[0][0] + words[1][0]).toUpperCase();
1626
- return name.slice(0, 2).toUpperCase();
1627
- }
1628
- function ProviderLogo({ provider, size = 24 }) {
1629
- const theme = useTheme();
1630
- const radius = Math.round(size * 0.28);
1631
- const iconSize = Math.round(size * 0.56);
1632
- if (isFirstParty(provider)) {
1633
- const fg = theme.color1?.get() ?? "#000000";
1634
- const markSize = Math.round(size * 0.66);
1635
- const isZen = provider.trim().toLowerCase() === "zen";
1636
- 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 }) });
1637
- }
1638
- const Known = KNOWN[provider.trim().toLowerCase()];
1639
- if (Known) {
1640
- return /* @__PURE__ */ jsx(
1641
- XStack,
1642
- {
1643
- width: size,
1644
- height: size,
1645
- items: "center",
1646
- justify: "center",
1647
- rounded: radius,
1648
- bg: "$color3",
1649
- borderWidth: 1,
1650
- borderColor: "$borderColor",
1651
- children: /* @__PURE__ */ jsx(Known, { size: iconSize, color: "$color11" })
1652
- }
1653
- );
1654
- }
1655
- return /* @__PURE__ */ jsx(
1656
- XStack,
1657
- {
1658
- width: size,
1659
- height: size,
1660
- items: "center",
1661
- justify: "center",
1662
- rounded: radius,
1663
- bg: "$color3",
1664
- borderWidth: 1,
1665
- borderColor: "$borderColor",
1666
- children: /* @__PURE__ */ jsx(Text, { fontSize: Math.round(size * 0.4), fontWeight: "800", color: "$color11", children: providerInitials(provider) })
1667
- }
1668
- );
1669
- }
1670
- function GenericLogo({ size = 24 }) {
1671
- 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" }) });
1672
- }
1673
- function targetIndex(from, dy, rowH, count) {
1674
- if (rowH <= 0 || count <= 0) return from;
1675
- const raw = from + Math.round(dy / rowH);
1676
- return Math.max(0, Math.min(raw, count - 1));
1677
- }
1678
- function rowShift(i, from, to, dy, rowH) {
1679
- if (i === from) return dy;
1680
- if (from < to && i > from && i <= to) return -rowH;
1681
- if (from > to && i < from && i >= to) return rowH;
1682
- return 0;
1683
- }
1684
- function Reorder({
1685
- items,
1686
- keyOf,
1687
- rowHeight = 44,
1688
- onReorder,
1689
- renderItem
1690
- }) {
1691
- const [drag, setDrag] = useState(null);
1692
- const startRef = useRef(null);
1693
- const to = drag ? targetIndex(drag.from, drag.dy, rowHeight, items.length) : -1;
1694
- const begin = useCallback(
1695
- (index) => (e) => {
1696
- const startY = e.clientY ?? e.nativeEvent?.clientY ?? 0;
1697
- startRef.current = { from: index, startY };
1698
- setDrag({ from: index, dy: 0 });
1699
- const move = (ev) => {
1700
- if (!startRef.current) return;
1701
- setDrag({ from: startRef.current.from, dy: ev.clientY - startRef.current.startY });
1702
- };
1703
- const end = () => {
1704
- const s = startRef.current;
1705
- window.removeEventListener("pointermove", move);
1706
- window.removeEventListener("pointerup", end);
1707
- window.removeEventListener("pointercancel", end);
1708
- startRef.current = null;
1709
- setDrag((d) => {
1710
- if (s && d) {
1711
- const t = targetIndex(s.from, d.dy, rowHeight, items.length);
1712
- if (t !== s.from) onReorder(s.from, t);
1713
- }
1714
- return null;
1715
- });
1716
- };
1717
- window.addEventListener("pointermove", move);
1718
- window.addEventListener("pointerup", end);
1719
- window.addEventListener("pointercancel", end);
1720
- },
1721
- [items.length, rowHeight, onReorder]
1722
- );
1723
- return /* @__PURE__ */ jsx(YStack, { children: items.map((item, i) => {
1724
- const dragging = drag?.from === i;
1725
- const shift = drag && to >= 0 ? rowShift(i, drag.from, to, drag.dy, rowHeight) : 0;
1726
- return /* @__PURE__ */ jsx(
1727
- YStack,
1728
- {
1729
- height: rowHeight,
1730
- justify: "center",
1731
- className: "hz-drag-item",
1732
- style: {
1733
- transform: `translateY(${shift}px)`,
1734
- zIndex: dragging ? 2 : 1,
1735
- ...dragging ? { transition: "none", boxShadow: "0 8px 24px rgba(0,0,0,0.28)" } : null
1736
- },
1737
- children: renderItem(item, { onPointerDown: begin(i) }, dragging)
1738
- },
1739
- keyOf(item)
1740
- );
1741
- }) });
1742
- }
1743
- function SelectMenu({
1744
- options,
1745
- value,
1746
- onChange,
1747
- allLabel = "All",
1748
- icon,
1749
- minWidth = 130
1750
- }) {
1751
- const active = value === null ? null : options.find((o) => o.key === value) ?? null;
1752
- const triggerLabel = active ? active.label : allLabel;
1753
- const items = [
1754
- { key: "__all__", label: allLabel, selected: value === null, onSelect: () => onChange(null) },
1755
- ...options.map((o) => ({ key: o.key, label: o.label, selected: value === o.key, onSelect: () => onChange(o.key) }))
1756
- ];
1757
- return /* @__PURE__ */ jsx(
1758
- DropdownMenu,
1759
- {
1760
- minWidth: Math.max(minWidth, 160),
1761
- trigger: /* @__PURE__ */ jsx(
1762
- Button,
1763
- {
1764
- size: "$2",
1765
- minW: minWidth,
1766
- justify: "space-between",
1767
- borderWidth: 1,
1768
- borderColor: "$borderColor",
1769
- bg: value !== null ? "$color5" : "transparent",
1770
- icon,
1771
- iconAfter: /* @__PURE__ */ jsx(ChevronDown, { size: 14, opacity: 0.6 }),
1772
- children: /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", numberOfLines: 1, flex: 1, children: triggerLabel })
1773
- }
1774
- ),
1775
- items
1776
- }
1777
- );
1778
- }
1779
- var LG = 1024;
1780
- var lockCount = 0;
1781
- var savedOverflow = "";
1782
- function lockScroll() {
1783
- if (typeof document === "undefined") return;
1784
- if (lockCount === 0) {
1785
- savedOverflow = document.body.style.overflow;
1786
- document.body.style.overflow = "hidden";
1787
- }
1788
- lockCount++;
1789
- }
1790
- function unlockScroll() {
1791
- if (typeof document === "undefined") return;
1792
- lockCount = Math.max(0, lockCount - 1);
1793
- if (lockCount === 0) document.body.style.overflow = savedOverflow;
1794
- }
1795
- function SlideOver({
1796
- open,
1797
- onClose,
1798
- side = "right",
1799
- size = 420,
1800
- title,
1801
- icon: Icon,
1802
- iconColor,
1803
- headerRight,
1804
- ariaLabel,
1805
- zIndex = 1e3,
1806
- children
1807
- }) {
1808
- const panelRef = useRef(null);
1809
- const openerRef = useRef(null);
1810
- useEffect(() => {
1811
- if (!open) return;
1812
- openerRef.current = typeof document !== "undefined" ? document.activeElement : null;
1813
- lockScroll();
1814
- const t = window.setTimeout(() => {
1815
- const el = panelRef.current;
1816
- if (el && typeof el.focus === "function") el.focus();
1817
- }, 0);
1818
- return () => {
1819
- window.clearTimeout(t);
1820
- unlockScroll();
1821
- const opener = openerRef.current;
1822
- if (opener && opener instanceof HTMLElement && typeof opener.focus === "function") opener.focus();
1823
- };
1824
- }, [open]);
1825
- useEffect(() => {
1826
- if (!open) return;
1827
- const onKey = (e) => {
1828
- if (e.key === "Escape") {
1829
- e.stopPropagation();
1830
- onClose();
1831
- }
1832
- };
1833
- window.addEventListener("keydown", onKey);
1834
- return () => window.removeEventListener("keydown", onKey);
1835
- }, [open, onClose]);
1836
- const offscreen = side === "right" ? "translateX(100%)" : "translateX(-100%)";
1837
- const edge = side === "right" ? { r: 0 } : { l: 0 };
1838
- return /* @__PURE__ */ jsxs(
1839
- YStack,
1840
- {
1841
- overflow: "hidden",
1842
- pointerEvents: open ? "auto" : "none",
1843
- "aria-hidden": !open,
1844
- style: { position: "fixed", inset: 0, zIndex },
1845
- children: [
1846
- /* @__PURE__ */ jsx(
1847
- YStack,
1848
- {
1849
- position: "absolute",
1850
- t: 0,
1851
- l: 0,
1852
- r: 0,
1853
- b: 0,
1854
- bg: "rgba(0,0,0,0.55)",
1855
- className: "hz-fade",
1856
- style: { opacity: open ? 1 : 0 },
1857
- onPress: onClose
1858
- }
1859
- ),
1860
- /* @__PURE__ */ jsx(
1861
- YStack,
1862
- {
1863
- ref: panelRef,
1864
- tabIndex: -1,
1865
- role: "dialog",
1866
- "aria-modal": open ? true : void 0,
1867
- "aria-label": typeof title === "string" ? title : ariaLabel,
1868
- position: "absolute",
1869
- t: 0,
1870
- b: 0,
1871
- ...edge,
1872
- width: "100%",
1873
- $lg: { width: size, maxW: "100vw" },
1874
- bg: "$color1",
1875
- borderLeftWidth: side === "right" ? 1 : 0,
1876
- borderRightWidth: side === "left" ? 1 : 0,
1877
- borderColor: "$borderColor",
1878
- className: "hz-slide",
1879
- style: { transform: open ? "translateX(0)" : offscreen, height: "100dvh" },
1880
- children: title !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1881
- /* @__PURE__ */ jsxs(
1882
- XStack,
1883
- {
1884
- items: "center",
1885
- gap: "$2.5",
1886
- px: "$4",
1887
- height: 56,
1888
- borderBottomWidth: 1,
1889
- borderColor: "$borderColor",
1890
- children: [
1891
- Icon ? /* @__PURE__ */ jsx(Icon, { size: 18, color: iconColor ? asColor(iconColor) : void 0 }) : null,
1892
- /* @__PURE__ */ jsx(Text, { flex: 1, fontSize: "$5", fontWeight: "700", color: "$color12", numberOfLines: 1, children: title }),
1893
- headerRight,
1894
- /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsx(X, { size: 18 }), onPress: onClose, "aria-label": "Close" })
1895
- ]
1896
- }
1897
- ),
1898
- /* @__PURE__ */ jsx(ScrollView, { flex: 1, children: /* @__PURE__ */ jsx(YStack, { flex: 1, p: "$4", gap: "$3", children }) })
1899
- ] }) : (
1900
- // Bare mode — the caller owns the full panel layout (e.g. the nav drawer
1901
- // renders its own header + scroll + footer).
1902
- children
1903
- )
1904
- }
1905
- )
1906
- ]
1907
- }
1908
- );
1909
- }
1910
- var toneOf = (status) => {
1911
- const s = status.toLowerCase();
1912
- if (s === "green") return "green";
1913
- if (s === "yellow") return "yellow";
1914
- if (s === "red") return "red";
1915
- if (["ready", "active", "running", "available", "ok"].includes(s)) return "green";
1916
- if (["creating", "provisioning", "pending", "updating", "attaching"].includes(s)) return "yellow";
1917
- if (["error", "failed", "degraded", "down"].includes(s)) return "red";
1918
- return "neutral";
1919
- };
1920
- var TONE_BG = {
1921
- green: "$color5",
1922
- yellow: "$color4",
1923
- red: "$color4",
1924
- neutral: "$color3"
1925
- };
1926
- var TONE_FG = {
1927
- green: "$color12",
1928
- yellow: "$color12",
1929
- red: "$color12",
1930
- neutral: "$color11"
1931
- };
1932
- function StatusTag({ status }) {
1933
- const tone2 = toneOf(status ?? "");
1934
- return /* @__PURE__ */ jsx(Text, { fontSize: "$1", px: "$2", py: "$1", rounded: "$2", bg: TONE_BG[tone2], color: TONE_FG[tone2], children: status || "unknown" });
1935
- }
1936
- var ToastContext = createContext(null);
1937
- var ACCENT3 = {
1938
- success: "$green10",
1939
- error: "$red10",
1940
- info: "$color11"
1941
- };
1942
- var ICON = {
1943
- success: CircleCheck,
1944
- error: CircleX,
1945
- info: Info
1946
- };
1947
- function ToastCard({ t, onClose }) {
1948
- const Icon = ICON[t.kind];
1949
- const accent = ACCENT3[t.kind];
1950
- return /* @__PURE__ */ jsx(
1951
- Card,
1952
- {
1953
- width: 360,
1954
- maxWidth: "90%",
1955
- p: "$3",
1956
- gap: "$2",
1957
- bg: "$color2",
1958
- borderWidth: 1,
1959
- borderColor: "$borderColor",
1960
- borderLeftWidth: 3,
1961
- borderLeftColor: accent,
1962
- rounded: "$4",
1963
- elevation: "$2",
1964
- children: /* @__PURE__ */ jsxs(XStack, { gap: "$2.5", items: "flex-start", children: [
1965
- /* @__PURE__ */ jsx(YStack, { pt: 1, children: /* @__PURE__ */ jsx(Icon, { size: 18, color: accent }) }),
1966
- /* @__PURE__ */ jsxs(YStack, { flex: 1, gap: "$1", children: [
1967
- /* @__PURE__ */ jsx(Text, { fontSize: "$3", fontWeight: "700", color: "$color12", children: t.title }),
1968
- t.description ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", children: t.description }) : null
1969
- ] }),
1970
- /* @__PURE__ */ jsx(Button, { size: "$1", chromeless: true, icon: /* @__PURE__ */ jsx(X, { size: 14 }), onPress: onClose, "aria-label": "Dismiss" })
1971
- ] })
1972
- }
1973
- );
1974
- }
1975
- function ToastViewport({ toasts, dismiss }) {
1976
- const [mounted, setMounted] = useState(false);
1977
- useEffect(() => setMounted(true), []);
1978
- if (!mounted || typeof document === "undefined") return null;
1979
- return createPortal(
1980
- /* @__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)) }) }),
1981
- document.body
1982
- );
1983
- }
1984
- function ToastProvider({ children }) {
1985
- const [toasts, setToasts] = useState([]);
1986
- const timers = useRef(/* @__PURE__ */ new Map());
1987
- const seq = useRef(0);
1988
- const dismiss = useCallback((id) => {
1989
- setToasts((ts) => ts.filter((t) => t.id !== id));
1990
- const timer = timers.current.get(id);
1991
- if (timer) {
1992
- clearTimeout(timer);
1993
- timers.current.delete(id);
1994
- }
1995
- }, []);
1996
- const toast = useCallback(
1997
- (input) => {
1998
- const id = ++seq.current;
1999
- const kind = input.kind ?? "info";
2000
- const durationMs = input.durationMs ?? (kind === "error" ? 6e3 : 3500);
2001
- setToasts((ts) => [...ts, { id, kind, title: input.title, description: input.description, durationMs }]);
2002
- if (durationMs > 0) {
2003
- timers.current.set(
2004
- id,
2005
- setTimeout(() => dismiss(id), durationMs)
2006
- );
2007
- }
2008
- },
2009
- [dismiss]
2010
- );
2011
- useEffect(() => {
2012
- const map = timers.current;
2013
- return () => map.forEach((t) => clearTimeout(t));
2014
- }, []);
2015
- const api = {
2016
- toast,
2017
- success: (title, description) => toast({ title, description, kind: "success" }),
2018
- error: (title, description) => toast({ title, description, kind: "error" }),
2019
- info: (title, description) => toast({ title, description, kind: "info" }),
2020
- dismiss
2021
- };
2022
- return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: api, children: [
2023
- children,
2024
- /* @__PURE__ */ jsx(ToastViewport, { toasts, dismiss })
2025
- ] });
2026
- }
2027
- function useToast() {
2028
- const ctx = useContext(ToastContext);
2029
- if (!ctx) throw new Error("useToast must be used within <ToastProvider>");
2030
- return ctx;
2031
- }
2032
-
2033
- 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, OrgMark, OrgSwitcher, PageHeader, Panel, PortalTheme, PrimaryButton, ProductIcon, ProviderLogo, Reorder, SERIES, SURFACES, SelectMenu, SlideOver, Sparkline, Sparkline2, StatusTag, ToastProvider, UtilBar, asColor, colorForIndex, filterOptions, filterOrgs, isKnownOption, monogram, orgScope, otherSurfaces, providerInitials, renderMenuItems, rowShift, targetIndex, useToast, utilColor };
2034
- //# sourceMappingURL=chunk-YSURJUOA.js.map
2035
- //# sourceMappingURL=chunk-YSURJUOA.js.map