@hanzo/ui 8.0.8 → 8.0.12

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 (179) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/backends/gui/index.d.ts +2 -0
  3. package/dist/backends/shadcn/aspect-ratio.d.ts +4 -0
  4. package/dist/backends/shadcn/avatar.d.ts +6 -0
  5. package/dist/backends/shadcn/badge.d.ts +9 -0
  6. package/dist/backends/shadcn/button.d.ts +19 -0
  7. package/dist/backends/shadcn/card.d.ts +9 -0
  8. package/dist/backends/shadcn/checkbox.d.ts +9 -0
  9. package/dist/backends/shadcn/collapsible.d.ts +5 -0
  10. package/dist/backends/shadcn/command.d.ts +80 -0
  11. package/dist/backends/shadcn/dialog.d.ts +15 -0
  12. package/dist/backends/shadcn/dropdown-menu.d.ts +34 -0
  13. package/dist/backends/shadcn/index.d.ts +23 -0
  14. package/dist/backends/shadcn/input.d.ts +11 -0
  15. package/dist/backends/shadcn/label.d.ts +4 -0
  16. package/dist/backends/shadcn/popover.d.ts +7 -0
  17. package/dist/backends/shadcn/progress.d.ts +4 -0
  18. package/dist/backends/shadcn/scroll-area.d.ts +5 -0
  19. package/dist/backends/shadcn/select.d.ts +13 -0
  20. package/dist/backends/shadcn/separator.d.ts +4 -0
  21. package/dist/backends/shadcn/slider.d.ts +4 -0
  22. package/dist/backends/shadcn/switch.d.ts +4 -0
  23. package/dist/backends/shadcn/tabs.d.ts +7 -0
  24. package/dist/backends/shadcn/textarea.d.ts +4 -0
  25. package/dist/backends/shadcn/toaster.d.ts +10 -0
  26. package/dist/backends/shadcn/tooltip.d.ts +7 -0
  27. package/dist/backends/shadcn/utils.d.ts +8 -0
  28. package/dist/components.d.ts +1 -0
  29. package/dist/core/cn.d.ts +11 -0
  30. package/dist/core/fonts.d.ts +26 -0
  31. package/dist/core/index.d.ts +3 -0
  32. package/dist/core/tokens.d.ts +16 -0
  33. package/dist/index.cjs +1138 -283
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +1017 -3
  37. package/dist/index.js.map +1 -1
  38. package/dist/models/ModelSelector.d.ts +23 -0
  39. package/dist/models/catalog.d.ts +53 -0
  40. package/dist/models/index.d.ts +5 -0
  41. package/dist/models/types.d.ts +39 -0
  42. package/dist/oss/blueprint.d.ts +37 -0
  43. package/dist/oss/catalog.d.ts +67 -0
  44. package/dist/oss.cjs +190 -0
  45. package/dist/oss.cjs.map +1 -0
  46. package/dist/oss.d.ts +2 -0
  47. package/dist/oss.js +180 -0
  48. package/dist/oss.js.map +1 -0
  49. package/dist/primitives/AspectRatio.d.ts +1 -0
  50. package/dist/primitives/Avatar.d.ts +1 -0
  51. package/dist/primitives/AvatarFallback.d.ts +1 -0
  52. package/dist/primitives/AvatarImage.d.ts +1 -0
  53. package/dist/primitives/Badge.d.ts +1 -0
  54. package/dist/primitives/Button.d.ts +1 -0
  55. package/dist/primitives/Card.d.ts +1 -0
  56. package/dist/primitives/CardAction.d.ts +1 -0
  57. package/dist/primitives/CardContent.d.ts +1 -0
  58. package/dist/primitives/CardDescription.d.ts +1 -0
  59. package/dist/primitives/CardFooter.d.ts +1 -0
  60. package/dist/primitives/CardHeader.d.ts +1 -0
  61. package/dist/primitives/CardTitle.d.ts +1 -0
  62. package/dist/primitives/Checkbox.d.ts +1 -0
  63. package/dist/primitives/Collapsible.d.ts +1 -0
  64. package/dist/primitives/CollapsibleContent.d.ts +1 -0
  65. package/dist/primitives/CollapsibleTrigger.d.ts +1 -0
  66. package/dist/primitives/Command.d.ts +1 -0
  67. package/dist/primitives/CommandDialog.d.ts +1 -0
  68. package/dist/primitives/CommandEmpty.d.ts +1 -0
  69. package/dist/primitives/CommandGroup.d.ts +1 -0
  70. package/dist/primitives/CommandInput.d.ts +1 -0
  71. package/dist/primitives/CommandItem.d.ts +1 -0
  72. package/dist/primitives/CommandList.d.ts +1 -0
  73. package/dist/primitives/CommandSeparator.d.ts +1 -0
  74. package/dist/primitives/CommandShortcut.d.ts +1 -0
  75. package/dist/primitives/Dialog.d.ts +1 -0
  76. package/dist/primitives/DialogClose.d.ts +1 -0
  77. package/dist/primitives/DialogContent.d.ts +1 -0
  78. package/dist/primitives/DialogDescription.d.ts +1 -0
  79. package/dist/primitives/DialogFooter.d.ts +1 -0
  80. package/dist/primitives/DialogHeader.d.ts +1 -0
  81. package/dist/primitives/DialogOverlay.d.ts +1 -0
  82. package/dist/primitives/DialogPortal.d.ts +1 -0
  83. package/dist/primitives/DialogTitle.d.ts +1 -0
  84. package/dist/primitives/DialogTrigger.d.ts +1 -0
  85. package/dist/primitives/DropdownMenu.d.ts +1 -0
  86. package/dist/primitives/DropdownMenuCheckboxItem.d.ts +1 -0
  87. package/dist/primitives/DropdownMenuContent.d.ts +1 -0
  88. package/dist/primitives/DropdownMenuGroup.d.ts +1 -0
  89. package/dist/primitives/DropdownMenuItem.d.ts +1 -0
  90. package/dist/primitives/DropdownMenuLabel.d.ts +1 -0
  91. package/dist/primitives/DropdownMenuPortal.d.ts +1 -0
  92. package/dist/primitives/DropdownMenuRadioGroup.d.ts +1 -0
  93. package/dist/primitives/DropdownMenuRadioItem.d.ts +1 -0
  94. package/dist/primitives/DropdownMenuSeparator.d.ts +1 -0
  95. package/dist/primitives/DropdownMenuShortcut.d.ts +1 -0
  96. package/dist/primitives/DropdownMenuSub.d.ts +1 -0
  97. package/dist/primitives/DropdownMenuSubContent.d.ts +1 -0
  98. package/dist/primitives/DropdownMenuSubTrigger.d.ts +1 -0
  99. package/dist/primitives/DropdownMenuTrigger.d.ts +1 -0
  100. package/dist/primitives/Input.d.ts +1 -0
  101. package/dist/primitives/Label.d.ts +1 -0
  102. package/dist/primitives/Popover.d.ts +1 -0
  103. package/dist/primitives/PopoverAnchor.d.ts +1 -0
  104. package/dist/primitives/PopoverContent.d.ts +1 -0
  105. package/dist/primitives/PopoverTrigger.d.ts +1 -0
  106. package/dist/primitives/Progress.d.ts +1 -0
  107. package/dist/primitives/ScrollArea.d.ts +1 -0
  108. package/dist/primitives/ScrollBar.d.ts +1 -0
  109. package/dist/primitives/Select.d.ts +1 -0
  110. package/dist/primitives/SelectContent.d.ts +1 -0
  111. package/dist/primitives/SelectGroup.d.ts +1 -0
  112. package/dist/primitives/SelectItem.d.ts +1 -0
  113. package/dist/primitives/SelectLabel.d.ts +1 -0
  114. package/dist/primitives/SelectScrollDownButton.d.ts +1 -0
  115. package/dist/primitives/SelectScrollUpButton.d.ts +1 -0
  116. package/dist/primitives/SelectSeparator.d.ts +1 -0
  117. package/dist/primitives/SelectTrigger.d.ts +1 -0
  118. package/dist/primitives/SelectValue.d.ts +1 -0
  119. package/dist/primitives/Separator.d.ts +1 -0
  120. package/dist/primitives/Slider.d.ts +1 -0
  121. package/dist/primitives/Switch.d.ts +1 -0
  122. package/dist/primitives/Tabs.d.ts +1 -0
  123. package/dist/primitives/TabsContent.d.ts +1 -0
  124. package/dist/primitives/TabsList.d.ts +1 -0
  125. package/dist/primitives/TabsTrigger.d.ts +1 -0
  126. package/dist/primitives/Textarea.d.ts +1 -0
  127. package/dist/primitives/Toaster.d.ts +1 -0
  128. package/dist/primitives/Tooltip.d.ts +1 -0
  129. package/dist/primitives/TooltipContent.d.ts +1 -0
  130. package/dist/primitives/TooltipProvider.d.ts +1 -0
  131. package/dist/primitives/TooltipTrigger.d.ts +1 -0
  132. package/dist/primitives/badgeVariants.d.ts +1 -0
  133. package/dist/primitives/buttonVariants.d.ts +1 -0
  134. package/dist/primitives/index.d.ts +1 -0
  135. package/dist/primitives/toast.d.ts +1 -0
  136. package/dist/product/AnimatedLogo.d.ts +47 -0
  137. package/dist/product/BackendState.d.ts +42 -0
  138. package/dist/product/Charts.d.ts +4 -0
  139. package/dist/product/CommerceResource.d.ts +32 -0
  140. package/dist/product/ConfirmDelete.d.ts +8 -0
  141. package/dist/product/DataTable.d.ts +30 -2
  142. package/dist/product/Field.d.ts +7 -2
  143. package/dist/product/Filters.d.ts +29 -0
  144. package/dist/product/OrgMark.d.ts +21 -0
  145. package/dist/product/OrgSwitcher.d.ts +8 -1
  146. package/dist/product/PrimaryButton.d.ts +5 -0
  147. package/dist/product/SiteFooter.d.ts +28 -0
  148. package/dist/product/SiteNav.d.ts +60 -0
  149. package/dist/product/accent.d.ts +33 -0
  150. package/dist/product/animatedLogo.logic.d.ts +52 -0
  151. package/dist/product/brand.d.ts +45 -0
  152. package/dist/product/host.d.ts +21 -0
  153. package/dist/product/index.cjs +3205 -257
  154. package/dist/product/index.cjs.map +1 -1
  155. package/dist/product/index.d.ts +12 -0
  156. package/dist/product/index.js +3103 -1
  157. package/dist/product/index.js.map +1 -1
  158. package/dist/product/social/CampaignCard.d.ts +13 -0
  159. package/dist/product/social/ChannelBadge.d.ts +12 -0
  160. package/dist/product/social/PostAgenda.d.ts +5 -0
  161. package/dist/product/social/PostCard.d.ts +15 -0
  162. package/dist/product/social/PostComposer.d.ts +24 -0
  163. package/dist/product/social/ProviderReadinessList.d.ts +10 -0
  164. package/dist/product/social/SocialSummaryBar.d.ts +9 -0
  165. package/dist/product/social/ViewToggle.d.ts +5 -0
  166. package/dist/product/social/format.d.ts +16 -0
  167. package/dist/product/social/index.d.ts +9 -0
  168. package/dist/product/surfaces.data.d.ts +1 -0
  169. package/dist/styles/hanzo-motion.css +52 -0
  170. package/dist/telemetry.cjs +15 -0
  171. package/dist/telemetry.cjs.map +1 -0
  172. package/dist/telemetry.d.ts +1 -0
  173. package/dist/telemetry.js +4 -0
  174. package/dist/telemetry.js.map +1 -0
  175. package/package.json +106 -19
  176. package/dist/chunk-GDGVXU7W.js +0 -1999
  177. package/dist/chunk-GDGVXU7W.js.map +0 -1
  178. package/dist/chunk-HSPMQQVJ.cjs +0 -2066
  179. package/dist/chunk-HSPMQQVJ.cjs.map +0 -1
@@ -1,5 +1,3107 @@
1
1
  'use client';
2
- export { AppHeader, BarChart, BarRows, BrandMark, CHART_OTHER, CHART_PALETTE, ComboBox, ContextMenu, Boxes as CustomModelMark, DataTable, Donut, Donut2 as DonutRing, DropdownMenu, EmptyState, FadeIn, FieldRow, FieldSelect, FieldSlider, FieldSwitch, FieldText, FieldTextArea, FloatingMenu, GenericLogo, HanzoMark, HintButton, LegendDot, LineChart, MenuItemView, MenuLabelView, MenuPanel, MenuSeparatorView, MetricCard, Sparkline2 as MetricSparkline, MiniBars, OrgSwitcher, PageHeader, Panel, PortalTheme, PrimaryButton, ProductIcon, ProviderLogo, Reorder, SERIES, LG as SLIDEOVER_LG, SURFACES, SelectMenu, SlideOver, Sparkline, StatusTag, ToastProvider, UtilBar, asColor, colorForIndex, filterOptions, filterOrgs, isKnownOption, orgScope, otherSurfaces, providerInitials, renderMenuItems, rowShift, targetIndex, useToast, utilColor } from '../chunk-GDGVXU7W.js';
2
+ import { ThemeToggle } from '../chunk-42CU5GSF.js';
3
3
  export { AgnosticThemeToggle, ThemeToggle, ThemeToggleNext } from '../chunk-42CU5GSF.js';
4
+ import { createContext, useRef, useState, useEffect, useCallback, useLayoutEffect, useMemo, cloneElement, useContext, useSyncExternalStore } from 'react';
5
+ import { useTheme, XStack, Text, YStack, Card, Theme, useThemeName, Portal, Input, Button, Spinner, Popover, Separator, useControllableState, Label, TextArea, Switch, Slider, ScrollView } from '@hanzo/gui';
6
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
+ import { Check, ChevronRight, ChevronDown, RefreshCw, Grip, CreditCard, Users, Bot, MessageCircle, AppWindow, LayoutGrid, Sparkles, UserRound, Settings2, LogOut, ChevronsUpDown, Plus, Search, TriangleAlert, ChevronUp, Trash2, ExternalLink, ArrowRight, Cpu, Globe, Server, X, Pencil, Calendar, AlertTriangle, CheckCircle2, List, Info, CircleX, CircleCheck } from '@hanzogui/lucide-icons-2';
8
+ export { Boxes as CustomModelMark } from '@hanzogui/lucide-icons-2';
9
+ import { surfaceById } from '@hanzo/products';
10
+ import { HanzoLogo } from '@hanzo/logo/react';
11
+ import { createPortal } from 'react-dom';
12
+
13
+ var CHART_PALETTE = [
14
+ "#7c5cff",
15
+ "#23c562",
16
+ "#ff9f45",
17
+ "#3aa0ff",
18
+ "#ff5d8f",
19
+ "#16c0c8",
20
+ "#c084fc",
21
+ "#f4c245"
22
+ ];
23
+ var CHART_OTHER = "#64748b";
24
+ var ACCENT = CHART_PALETTE[0];
25
+ var GRID = "rgba(148,163,184,0.16)";
26
+ var AXIS = "rgba(148,163,184,0.85)";
27
+ var tone = (theme, key, fallback) => {
28
+ const v = theme[key];
29
+ const got = v?.get?.();
30
+ return typeof got === "string" ? got : fallback;
31
+ };
32
+ var rampOpacity = (i, n) => n <= 1 ? 0.9 : 0.95 - i / (n - 1) * 0.62;
33
+ function useContainerWidth() {
34
+ const ref = useRef(null);
35
+ const [w, setW] = useState(0);
36
+ useEffect(() => {
37
+ const el = ref.current;
38
+ if (!el) return;
39
+ const measure = () => setW(el.clientWidth);
40
+ measure();
41
+ const ro = new ResizeObserver(measure);
42
+ ro.observe(el);
43
+ return () => ro.disconnect();
44
+ }, []);
45
+ return { ref, w };
46
+ }
47
+ function Sparkline({
48
+ values,
49
+ width = 120,
50
+ height = 36,
51
+ color
52
+ }) {
53
+ const theme = useTheme();
54
+ const clean = (values ?? []).filter((v) => Number.isFinite(v));
55
+ if (clean.length < 2) return null;
56
+ const stroke = color ?? tone(theme, "color11", "currentColor");
57
+ const max = Math.max(...clean);
58
+ const min = Math.min(...clean);
59
+ const span = max - min || 1;
60
+ const n = clean.length;
61
+ const px = (i) => i / (n - 1) * (width - 2) + 1;
62
+ const py = (v) => height - 2 - (v - min) / span * (height - 4);
63
+ const line = clean.map((v, i) => `${i === 0 ? "M" : "L"}${px(i).toFixed(1)},${py(v).toFixed(1)}`).join(" ");
64
+ const area = `${line} L${(width - 1).toFixed(1)},${height} L1,${height} Z`;
65
+ return /* @__PURE__ */ jsxs("svg", { width, height, "aria-hidden": true, style: { display: "block" }, children: [
66
+ /* @__PURE__ */ jsx("path", { d: area, fill: stroke, fillOpacity: 0.12 }),
67
+ /* @__PURE__ */ jsx("path", { d: line, fill: "none", stroke, strokeWidth: 1.5, strokeLinejoin: "round", strokeLinecap: "round" })
68
+ ] });
69
+ }
70
+ function Tooltip({ x, height, label, value }) {
71
+ const left = Math.max(0, x - 60);
72
+ return /* @__PURE__ */ jsx(
73
+ "div",
74
+ {
75
+ style: {
76
+ position: "absolute",
77
+ left,
78
+ top: 0,
79
+ height,
80
+ pointerEvents: "none",
81
+ display: "flex",
82
+ alignItems: "flex-start"
83
+ },
84
+ children: /* @__PURE__ */ jsxs(
85
+ "div",
86
+ {
87
+ style: {
88
+ background: "rgba(15,17,21,0.94)",
89
+ border: "1px solid rgba(148,163,184,0.25)",
90
+ borderRadius: 8,
91
+ padding: "6px 9px",
92
+ fontSize: 11,
93
+ lineHeight: 1.35,
94
+ color: "#e2e8f0",
95
+ whiteSpace: "nowrap",
96
+ boxShadow: "0 4px 16px rgba(0,0,0,0.4)"
97
+ },
98
+ children: [
99
+ /* @__PURE__ */ jsx("div", { style: { color: AXIS }, children: label }),
100
+ /* @__PURE__ */ jsx("div", { style: { fontWeight: 700 }, children: value })
101
+ ]
102
+ }
103
+ )
104
+ }
105
+ );
106
+ }
107
+ function nearestIndex(clientX, rect, padL, innerW, n) {
108
+ if (n <= 1) return 0;
109
+ const mx = clientX - rect.left - padL;
110
+ const i = Math.round(mx / (innerW || 1) * (n - 1));
111
+ return Math.max(0, Math.min(n - 1, i));
112
+ }
113
+ function axisTicks(data) {
114
+ const n = data.length;
115
+ if (n === 0) return [];
116
+ if (n === 1) return [{ i: 0, label: data[0].label, anchor: "middle" }];
117
+ const mid = Math.floor((n - 1) / 2);
118
+ const out = [
119
+ { i: 0, label: data[0].label, anchor: "start" },
120
+ { i: n - 1, label: data[n - 1].label, anchor: "end" }
121
+ ];
122
+ if (n >= 5) out.splice(1, 0, { i: mid, label: data[mid].label, anchor: "middle" });
123
+ return out;
124
+ }
125
+ function LineChart({
126
+ data,
127
+ height = 210,
128
+ color = ACCENT,
129
+ formatValue = (v) => String(v)
130
+ }) {
131
+ const { ref, w } = useContainerWidth();
132
+ const [hover, setHover] = useState(null);
133
+ const padL = 10;
134
+ const padR = 10;
135
+ const padT = 12;
136
+ const padB = 24;
137
+ const n = data.length;
138
+ const innerW = Math.max(1, w - padL - padR);
139
+ const innerH = Math.max(1, height - padT - padB);
140
+ const max = Math.max(...data.map((d) => d.value), 1);
141
+ const x = (i) => padL + (n <= 1 ? innerW / 2 : i / (n - 1) * innerW);
142
+ const y = (v) => padT + innerH - v / max * innerH;
143
+ const line = data.map((d, i) => `${i === 0 ? "M" : "L"}${x(i).toFixed(1)},${y(d.value).toFixed(1)}`).join(" ");
144
+ 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` : "";
145
+ const ticks = axisTicks(data);
146
+ return /* @__PURE__ */ jsxs("div", { ref, style: { position: "relative", width: "100%" }, children: [
147
+ w > 0 ? /* @__PURE__ */ jsxs(
148
+ "svg",
149
+ {
150
+ width: w,
151
+ height,
152
+ style: { display: "block" },
153
+ onMouseMove: (e) => setHover(nearestIndex(e.clientX, e.currentTarget.getBoundingClientRect(), padL, innerW, n)),
154
+ onMouseLeave: () => setHover(null),
155
+ children: [
156
+ [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)),
157
+ area ? /* @__PURE__ */ jsx("path", { d: area, fill: color, fillOpacity: 0.1 }) : null,
158
+ n >= 2 ? /* @__PURE__ */ jsx("path", { d: line, fill: "none", stroke: color, strokeWidth: 2, strokeLinejoin: "round", strokeLinecap: "round" }) : null,
159
+ hover != null && data[hover] ? /* @__PURE__ */ jsxs(Fragment, { children: [
160
+ /* @__PURE__ */ jsx("line", { x1: x(hover), x2: x(hover), y1: padT, y2: padT + innerH, stroke: AXIS, strokeWidth: 1, strokeDasharray: "3 3" }),
161
+ /* @__PURE__ */ jsx("circle", { cx: x(hover), cy: y(data[hover].value), r: 4, fill: color, stroke: "#0f1115", strokeWidth: 2 })
162
+ ] }) : null,
163
+ 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))
164
+ ]
165
+ }
166
+ ) : null,
167
+ hover != null && data[hover] ? /* @__PURE__ */ jsx(Tooltip, { x: x(hover), height, label: data[hover].label, value: formatValue(data[hover].value) }) : null
168
+ ] });
169
+ }
170
+ function BarChart({
171
+ data,
172
+ height = 210,
173
+ color = ACCENT,
174
+ formatValue = (v) => String(v)
175
+ }) {
176
+ const { ref, w } = useContainerWidth();
177
+ const [hover, setHover] = useState(null);
178
+ const padL = 10;
179
+ const padR = 10;
180
+ const padT = 12;
181
+ const padB = 24;
182
+ const n = data.length;
183
+ const innerW = Math.max(1, w - padL - padR);
184
+ const innerH = Math.max(1, height - padT - padB);
185
+ const max = Math.max(...data.map((d) => d.value), 1);
186
+ const slot = innerW / Math.max(1, n);
187
+ const barW = Math.max(1, Math.min(slot * 0.62, 36));
188
+ const cx = (i) => padL + slot * i + slot / 2;
189
+ const ticks = axisTicks(data);
190
+ return /* @__PURE__ */ jsxs("div", { ref, style: { position: "relative", width: "100%" }, children: [
191
+ w > 0 ? /* @__PURE__ */ jsxs(
192
+ "svg",
193
+ {
194
+ width: w,
195
+ height,
196
+ style: { display: "block" },
197
+ onMouseMove: (e) => {
198
+ const rect = e.currentTarget.getBoundingClientRect();
199
+ const i = Math.floor((e.clientX - rect.left - padL) / (slot || 1));
200
+ setHover(Math.max(0, Math.min(n - 1, i)));
201
+ },
202
+ onMouseLeave: () => setHover(null),
203
+ children: [
204
+ [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)),
205
+ data.map((d, i) => {
206
+ const h = d.value / max * innerH;
207
+ return /* @__PURE__ */ jsx(
208
+ "rect",
209
+ {
210
+ x: cx(i) - barW / 2,
211
+ y: padT + innerH - h,
212
+ width: barW,
213
+ height: Math.max(0, h),
214
+ rx: Math.min(3, barW / 2),
215
+ fill: color,
216
+ fillOpacity: hover === i ? 1 : 0.78
217
+ },
218
+ i
219
+ );
220
+ }),
221
+ ticks.map((t) => /* @__PURE__ */ jsx("text", { x: cx(t.i), y: height - 7, fontSize: 10, fill: AXIS, textAnchor: "middle", children: t.label }, t.i))
222
+ ]
223
+ }
224
+ ) : null,
225
+ hover != null && data[hover] ? /* @__PURE__ */ jsx(Tooltip, { x: cx(hover), height, label: data[hover].label, value: formatValue(data[hover].value) }) : null
226
+ ] });
227
+ }
228
+ function Donut({
229
+ slices,
230
+ size = 160,
231
+ thickness = 22,
232
+ center,
233
+ legend = false
234
+ }) {
235
+ const theme = useTheme();
236
+ const fg = tone(theme, "color12", "currentColor");
237
+ const positive = slices.filter((s) => s.value > 0);
238
+ const total = positive.reduce((sum, s) => sum + s.value, 0);
239
+ const r = size / 2;
240
+ const rInner = r - thickness;
241
+ const mid = (r + rInner) / 2;
242
+ if (total <= 0) {
243
+ return /* @__PURE__ */ jsx(XStack, { items: "center", justify: "center", height: size, children: /* @__PURE__ */ jsx(Text, { fontSize: "$6", color: "$color10", children: "\u2014" }) });
244
+ }
245
+ const ring = /* @__PURE__ */ jsxs("div", { style: { position: "relative", width: size, height: size }, children: [
246
+ /* @__PURE__ */ jsx("svg", { width: size, height: size, style: { display: "block" }, children: positive.length === 1 ? /* @__PURE__ */ jsx(
247
+ "circle",
248
+ {
249
+ cx: r,
250
+ cy: r,
251
+ r: mid,
252
+ fill: "none",
253
+ stroke: positive[0].color ?? fg,
254
+ strokeOpacity: positive[0].color ? 1 : 0.9,
255
+ strokeWidth: thickness
256
+ }
257
+ ) : renderArcs(positive, total, r, rInner, fg) }),
258
+ center ? /* @__PURE__ */ jsx(
259
+ "div",
260
+ {
261
+ style: {
262
+ position: "absolute",
263
+ inset: 0,
264
+ display: "flex",
265
+ flexDirection: "column",
266
+ alignItems: "center",
267
+ justifyContent: "center",
268
+ textAlign: "center",
269
+ pointerEvents: "none"
270
+ },
271
+ children: center
272
+ }
273
+ ) : null
274
+ ] });
275
+ if (!legend) return ring;
276
+ return /* @__PURE__ */ jsxs(XStack, { gap: "$4", items: "center", flexWrap: "wrap", children: [
277
+ ring,
278
+ /* @__PURE__ */ jsx(YStack, { gap: "$1.5", flex: 1, minW: 150, children: positive.map((s, i) => /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", children: [
279
+ /* @__PURE__ */ jsx(
280
+ "div",
281
+ {
282
+ style: {
283
+ width: 10,
284
+ height: 10,
285
+ borderRadius: 2,
286
+ backgroundColor: s.color ?? AXIS,
287
+ opacity: s.color ? 1 : rampOpacity(i, positive.length)
288
+ }
289
+ }
290
+ ),
291
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", flex: 1, numberOfLines: 1, children: s.label }),
292
+ /* @__PURE__ */ jsxs(Text, { fontSize: "$2", color: "$color12", fontWeight: "600", children: [
293
+ Math.round(s.value / total * 100),
294
+ "%"
295
+ ] })
296
+ ] }, s.label)) })
297
+ ] });
298
+ }
299
+ function renderArcs(slices, total, rOuter, rInner, fg) {
300
+ let a0 = -Math.PI / 2;
301
+ const paths = [];
302
+ slices.forEach((s, idx) => {
303
+ const frac = Math.max(0, s.value) / total;
304
+ if (frac <= 0) return;
305
+ const a1 = a0 + frac * Math.PI * 2;
306
+ paths.push(
307
+ /* @__PURE__ */ jsx(
308
+ "path",
309
+ {
310
+ d: annularArc(rOuter, rOuter, rOuter, rInner, a0, Math.min(a1, a0 + Math.PI * 1.9999)),
311
+ fill: s.color ?? fg,
312
+ fillOpacity: s.color ? 1 : rampOpacity(idx, slices.length)
313
+ },
314
+ s.label || idx
315
+ )
316
+ );
317
+ a0 = a1;
318
+ });
319
+ return /* @__PURE__ */ jsx(Fragment, { children: paths });
320
+ }
321
+ function polar(cx, cy, rad, a) {
322
+ return [cx + rad * Math.cos(a), cy + rad * Math.sin(a)];
323
+ }
324
+ function annularArc(cx, cy, rOuter, rInner, a0, a1) {
325
+ const large = a1 - a0 > Math.PI ? 1 : 0;
326
+ const [x0, y0] = polar(cx, cy, rOuter, a0);
327
+ const [x1, y1] = polar(cx, cy, rOuter, a1);
328
+ const [x2, y2] = polar(cx, cy, rInner, a1);
329
+ const [x3, y3] = polar(cx, cy, rInner, a0);
330
+ return `M${x0},${y0} A${rOuter},${rOuter} 0 ${large} 1 ${x1},${y1} L${x2},${y2} A${rInner},${rInner} 0 ${large} 0 ${x3},${y3} Z`;
331
+ }
332
+ function BarRows({ bars }) {
333
+ const max = Math.max(0, ...bars.map((b) => b.value));
334
+ if (max <= 0) {
335
+ return /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color10", children: "\u2014" });
336
+ }
337
+ return /* @__PURE__ */ jsx(YStack, { gap: "$2.5", children: bars.map((b) => /* @__PURE__ */ jsxs(XStack, { gap: "$3", items: "center", children: [
338
+ /* @__PURE__ */ jsx(Text, { width: 64, fontSize: "$2", color: "$color11", text: "right", children: b.label }),
339
+ /* @__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" }) }),
340
+ /* @__PURE__ */ jsx(Text, { width: 56, fontSize: "$2", color: "$color12", fontWeight: "600", children: b.value.toLocaleString() })
341
+ ] }, b.label)) });
342
+ }
343
+ var SERIES = ["#6ea8fe", "#7ee787", "#f0a868", "#c792ea", "#56d4c4", "#e879a6", "#d6c15a", "#8b9bb4"];
344
+ var colorForIndex = (i) => SERIES[i % SERIES.length];
345
+ var TRACK = "rgba(128,128,128,0.18)";
346
+ function utilColor(pct) {
347
+ if (pct >= 90) return "#e5534b";
348
+ if (pct >= 70) return "#f0a868";
349
+ return "#7ee787";
350
+ }
351
+ function Sparkline2({
352
+ points,
353
+ width = 104,
354
+ height = 30,
355
+ color = SERIES[0]
356
+ }) {
357
+ if (!points || points.length < 2) return null;
358
+ const min = Math.min(...points);
359
+ const max = Math.max(...points);
360
+ const span = max - min || 1;
361
+ const stepX = width / (points.length - 1);
362
+ const y = (v) => height - 2 - (v - min) / span * (height - 4);
363
+ const d = points.map((p, i) => `${i === 0 ? "M" : "L"}${(i * stepX).toFixed(1)},${y(p).toFixed(1)}`).join(" ");
364
+ 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" }) });
365
+ }
366
+ function MiniBars({
367
+ bars,
368
+ width = 320,
369
+ height = 96,
370
+ color = SERIES[0]
371
+ }) {
372
+ if (!bars.length) return null;
373
+ const max = Math.max(...bars.map((b) => b.value), 1);
374
+ const gap = 4;
375
+ const bw = (width - gap * (bars.length - 1)) / bars.length;
376
+ return /* @__PURE__ */ jsx("svg", { width: "100%", height, viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", role: "img", "aria-label": "bars", children: bars.map((b, i) => {
377
+ const h = Math.max(1, b.value / max * (height - 2));
378
+ 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);
379
+ }) });
380
+ }
381
+ function UtilBar({ value, width = 120, color }) {
382
+ const v = Math.max(0, Math.min(100, value));
383
+ return /* @__PURE__ */ jsxs("svg", { width, height: 8, viewBox: `0 0 ${width} 8`, role: "img", "aria-label": `${Math.round(v)}%`, children: [
384
+ /* @__PURE__ */ jsx("rect", { x: 0, y: 1, width, height: 6, rx: 3, fill: TRACK }),
385
+ /* @__PURE__ */ jsx("rect", { x: 0, y: 1, width: v / 100 * width, height: 6, rx: 3, fill: color ?? utilColor(v) })
386
+ ] });
387
+ }
388
+ function LegendDot({ color, label, value }) {
389
+ return /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", justify: "space-between", children: [
390
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", children: [
391
+ /* @__PURE__ */ jsx(YStack, { width: 10, height: 10, rounded: "$1", bg: color }),
392
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", children: label })
393
+ ] }),
394
+ value != null ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", fontWeight: "500", className: "hz-mono", children: value }) : null
395
+ ] });
396
+ }
397
+ function MetricCard({
398
+ icon,
399
+ label,
400
+ value,
401
+ caption,
402
+ spark,
403
+ sparkColor,
404
+ delta
405
+ }) {
406
+ const up = delta ? delta.pct >= 0 : false;
407
+ return /* @__PURE__ */ jsxs(Card, { p: "$3.5", gap: "$2", borderWidth: 1, borderColor: "$borderColor", flex: 1, minW: 172, children: [
408
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", justify: "space-between", children: [
409
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", children: [
410
+ icon,
411
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", fontWeight: "500", children: label })
412
+ ] }),
413
+ delta ? /* @__PURE__ */ jsxs(Text, { fontSize: "$1", color: up ? "#7ee787" : "#e5534b", children: [
414
+ up ? "\u25B2" : "\u25BC",
415
+ " ",
416
+ Math.abs(delta.pct),
417
+ "%"
418
+ ] }) : null
419
+ ] }),
420
+ /* @__PURE__ */ jsxs(XStack, { items: "flex-end", justify: "space-between", gap: "$2", children: [
421
+ /* @__PURE__ */ jsx(Text, { fontSize: "$8", fontWeight: "500", color: "$color12", numberOfLines: 1, className: "hz-mono", children: value }),
422
+ spark && spark.length >= 2 ? /* @__PURE__ */ jsx(Sparkline2, { points: spark, color: sparkColor ?? SERIES[0] }) : null
423
+ ] }),
424
+ caption ? /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color10", numberOfLines: 1, children: caption }) : null
425
+ ] });
426
+ }
427
+ function HintButton({
428
+ icon,
429
+ iconAfter,
430
+ children,
431
+ onPress,
432
+ disabled,
433
+ hint,
434
+ theme
435
+ }) {
436
+ const btn = /* @__PURE__ */ jsx(
437
+ Button,
438
+ {
439
+ size: "$2",
440
+ theme,
441
+ icon,
442
+ iconAfter,
443
+ disabled,
444
+ onPress: disabled ? void 0 : onPress,
445
+ children
446
+ }
447
+ );
448
+ if (!hint) return btn;
449
+ return /* @__PURE__ */ jsx("span", { title: hint, style: { display: "inline-flex" }, children: btn });
450
+ }
451
+ function Panel({
452
+ title,
453
+ right,
454
+ children,
455
+ minW = 280,
456
+ grow = true
457
+ }) {
458
+ return /* @__PURE__ */ jsxs(Card, { p: "$4", gap: "$3", borderWidth: 1, borderColor: "$borderColor", flex: grow ? 1 : void 0, minW, width: grow ? void 0 : "100%", children: [
459
+ /* @__PURE__ */ jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [
460
+ /* @__PURE__ */ jsx(Text, { fontSize: "$4", fontWeight: "500", color: "$color12", children: title }),
461
+ right
462
+ ] }),
463
+ children
464
+ ] });
465
+ }
466
+ function Donut2({
467
+ segments,
468
+ size = 160,
469
+ thickness = 18,
470
+ centerValue,
471
+ centerLabel,
472
+ trackColor = "#2a2d2e",
473
+ valueColor = "#ecedee",
474
+ labelColor = "#9ba1a6"
475
+ }) {
476
+ const total = segments.reduce((n, s) => n + Math.max(0, s.value), 0);
477
+ if (total <= 0) return null;
478
+ const r = (size - thickness) / 2;
479
+ const cx = size / 2;
480
+ const cy = size / 2;
481
+ const circ = 2 * Math.PI * r;
482
+ let offset = 0;
483
+ const arcs = segments.filter((s) => s.value > 0).map((s) => {
484
+ const frac = s.value / total;
485
+ const dash = frac * circ;
486
+ const node = /* @__PURE__ */ jsx(
487
+ "circle",
488
+ {
489
+ cx,
490
+ cy,
491
+ r,
492
+ fill: "none",
493
+ stroke: s.color,
494
+ strokeWidth: thickness,
495
+ strokeDasharray: `${dash} ${circ - dash}`,
496
+ strokeDashoffset: -offset
497
+ },
498
+ s.label
499
+ );
500
+ offset += dash;
501
+ return node;
502
+ });
503
+ return /* @__PURE__ */ jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, role: "img", "aria-label": "Donut chart", children: [
504
+ /* @__PURE__ */ jsx("circle", { cx, cy, r, fill: "none", stroke: trackColor, strokeWidth: thickness }),
505
+ /* @__PURE__ */ jsx("g", { transform: `rotate(-90 ${cx} ${cy})`, children: arcs }),
506
+ centerValue ? /* @__PURE__ */ jsx("text", { x: cx, y: cy - 2, textAnchor: "middle", fontSize: size * 0.2, fontWeight: "800", fill: valueColor, children: centerValue }) : null,
507
+ centerLabel ? /* @__PURE__ */ jsx("text", { x: cx, y: cy + size * 0.13, textAnchor: "middle", fontSize: size * 0.08, fill: labelColor, children: centerLabel }) : null
508
+ ] });
509
+ }
510
+
511
+ // src/product/combobox/filter.ts
512
+ var hay = (o) => `${o.value} ${o.label ?? ""} ${o.hint ?? ""}`.toLowerCase();
513
+ function filterOptions(options, query) {
514
+ const q = query.trim().toLowerCase();
515
+ if (!q) return options;
516
+ return options.filter((o) => hay(o).includes(q));
517
+ }
518
+ function isKnownOption(options, value) {
519
+ return options.some((o) => o.value === value);
520
+ }
521
+ var ITEM_MIN_HEIGHT = 30;
522
+ var ITEM_RADIUS = 7;
523
+ var ITEM_PX = 8;
524
+ var ITEM_GAP = 8;
525
+ var ICON_SLOT = 16;
526
+ var PANEL_RADIUS = 12;
527
+ var PANEL_PAD = 4;
528
+ var PANEL_GAP = 2;
529
+ var SEP_MARGIN = 4;
530
+ var FONT_LABEL = 13;
531
+ var FONT_MUTED = 11;
532
+ var FONT_SHORTCUT = 12;
533
+ var ACCENT2 = "var(--hanzo-accent, #8b5cf6)";
534
+ var ACCENT_SOFT = "var(--hanzo-accent-soft, rgba(139,92,246,0.16))";
535
+ var DANGER = "var(--hanzo-danger, #ef4444)";
536
+ function MenuPanel({
537
+ children,
538
+ minWidth = 200,
539
+ maxHeight = 360,
540
+ onKeyDown,
541
+ panelRef,
542
+ ...rest
543
+ }) {
544
+ return /* @__PURE__ */ jsx(
545
+ YStack,
546
+ {
547
+ ref: panelRef,
548
+ role: "menu",
549
+ bg: "$color2",
550
+ borderColor: "$borderColor",
551
+ borderWidth: 1,
552
+ rounded: PANEL_RADIUS,
553
+ p: PANEL_PAD,
554
+ gap: PANEL_GAP,
555
+ minW: minWidth,
556
+ maxH: maxHeight,
557
+ overflow: "scroll",
558
+ shadowColor: "rgba(0,0,0,0.45)",
559
+ shadowRadius: 20,
560
+ shadowOffset: { width: 0, height: 10 },
561
+ onKeyDown,
562
+ ...rest,
563
+ children
564
+ }
565
+ );
566
+ }
567
+ function MenuItemView({
568
+ icon,
569
+ label,
570
+ description,
571
+ shortcut,
572
+ selected = false,
573
+ disabled = false,
574
+ destructive = false,
575
+ hasSubmenu = false,
576
+ onSelect
577
+ }) {
578
+ const press = () => {
579
+ if (!disabled) onSelect();
580
+ };
581
+ const onKeyDown = (e) => {
582
+ if (disabled) return;
583
+ if (e.key === "Enter" || e.key === " ") {
584
+ e.preventDefault();
585
+ onSelect();
586
+ }
587
+ };
588
+ const labelColor = destructive ? DANGER : "$color12";
589
+ return /* @__PURE__ */ jsxs(
590
+ XStack,
591
+ {
592
+ role: "menuitem",
593
+ tabIndex: disabled ? -1 : 0,
594
+ "aria-disabled": disabled || void 0,
595
+ items: "center",
596
+ gap: ITEM_GAP,
597
+ px: ITEM_PX,
598
+ minH: ITEM_MIN_HEIGHT,
599
+ rounded: ITEM_RADIUS,
600
+ cursor: disabled ? "default" : "pointer",
601
+ opacity: disabled ? 0.4 : 1,
602
+ select: "none",
603
+ style: { outline: "none" },
604
+ hoverStyle: disabled ? {} : { bg: ACCENT_SOFT },
605
+ pressStyle: disabled ? {} : { bg: ACCENT_SOFT },
606
+ focusStyle: disabled ? {} : { bg: ACCENT_SOFT },
607
+ onPress: press,
608
+ onKeyDown,
609
+ children: [
610
+ /* @__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 }),
611
+ /* @__PURE__ */ jsxs(YStack, { flex: 1, minW: 0, children: [
612
+ /* @__PURE__ */ jsx(Text, { fontSize: FONT_LABEL, lineHeight: 18, color: labelColor, numberOfLines: 1, children: label }),
613
+ description ? /* @__PURE__ */ jsx(Text, { fontSize: FONT_MUTED, lineHeight: 14, color: "$color11", numberOfLines: 1, children: description }) : null
614
+ ] }),
615
+ shortcut ? /* @__PURE__ */ jsx(Text, { fontSize: FONT_SHORTCUT, color: "$color11", shrink: 0, children: shortcut }) : null,
616
+ selected ? /* @__PURE__ */ jsx(Check, { size: 14, color: ACCENT2 }) : null,
617
+ hasSubmenu ? /* @__PURE__ */ jsx(ChevronRight, { size: 14, color: "var(--hanzo-muted, currentColor)", opacity: 0.6 }) : null
618
+ ]
619
+ }
620
+ );
621
+ }
622
+ function MenuSeparatorView() {
623
+ return /* @__PURE__ */ jsx(YStack, { height: 1, bg: "$borderColor", my: SEP_MARGIN, mx: SEP_MARGIN, role: "separator" });
624
+ }
625
+ function MenuLabelView({ children }) {
626
+ return /* @__PURE__ */ jsx(
627
+ Text,
628
+ {
629
+ fontSize: FONT_MUTED,
630
+ color: "$color11",
631
+ px: ITEM_PX,
632
+ py: SEP_MARGIN,
633
+ textTransform: "uppercase",
634
+ letterSpacing: 0.4,
635
+ select: "none",
636
+ children
637
+ }
638
+ );
639
+ }
640
+ function renderMenuItems(items, close) {
641
+ return items.map((it, i) => {
642
+ if (it.type === "separator") return /* @__PURE__ */ jsx(MenuSeparatorView, {}, it.key ?? `sep-${i}`);
643
+ if (it.type === "label") return /* @__PURE__ */ jsx(MenuLabelView, { children: it.label }, it.key ?? `lbl-${i}`);
644
+ const { key, onSelect, closeOnSelect = true, ...rest } = it;
645
+ return /* @__PURE__ */ jsx(
646
+ MenuItemView,
647
+ {
648
+ ...rest,
649
+ onSelect: () => {
650
+ onSelect();
651
+ if (closeOnSelect) close?.();
652
+ }
653
+ },
654
+ key
655
+ );
656
+ });
657
+ }
658
+ function PortalTheme({ name, children }) {
659
+ return /* @__PURE__ */ jsx(Theme, { name, children });
660
+ }
661
+
662
+ // src/product/menu/roving.ts
663
+ function menuKeyDown(e, onClose) {
664
+ if (e.key === "Escape") {
665
+ onClose?.();
666
+ return;
667
+ }
668
+ if (e.key !== "ArrowDown" && e.key !== "ArrowUp" && e.key !== "Home" && e.key !== "End") return;
669
+ if (typeof document === "undefined") return;
670
+ const panel = e.currentTarget;
671
+ const items = Array.from(
672
+ panel.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')
673
+ );
674
+ if (items.length === 0) return;
675
+ e.preventDefault();
676
+ const active = document.activeElement;
677
+ const current2 = active ? items.indexOf(active) : -1;
678
+ let next;
679
+ if (e.key === "Home") next = 0;
680
+ else if (e.key === "End") next = items.length - 1;
681
+ else if (e.key === "ArrowDown") next = current2 < 0 ? 0 : (current2 + 1) % items.length;
682
+ else next = current2 <= 0 ? items.length - 1 : current2 - 1;
683
+ items[next]?.focus();
684
+ }
685
+ var EDGE = 8;
686
+ function FloatingMenu({
687
+ open,
688
+ onClose,
689
+ anchorRect,
690
+ anchorEl,
691
+ gap = 4,
692
+ minWidth = 200,
693
+ maxHeight,
694
+ autoFocus = true,
695
+ children
696
+ }) {
697
+ const themeName = useThemeName();
698
+ const panelRef = useRef(null);
699
+ const [pos, setPos] = useState(null);
700
+ const setPanel = useCallback((n) => {
701
+ panelRef.current = n;
702
+ }, []);
703
+ const place = useCallback(() => {
704
+ if (typeof window === "undefined") return;
705
+ const a = anchorRect();
706
+ if (!a) return;
707
+ const node = panelRef.current;
708
+ const w = node?.offsetWidth || minWidth;
709
+ const h = node?.offsetHeight || 0;
710
+ let left = a.left;
711
+ let top = a.bottom + gap;
712
+ if (left + w > window.innerWidth - EDGE) left = Math.max(EDGE, window.innerWidth - w - EDGE);
713
+ if (h && top + h > window.innerHeight - EDGE) {
714
+ const above = a.top - gap - h;
715
+ top = above >= EDGE ? above : Math.max(EDGE, window.innerHeight - h - EDGE);
716
+ }
717
+ setPos({ left, top });
718
+ }, [anchorRect, gap, minWidth]);
719
+ useLayoutEffect(() => {
720
+ if (!open) {
721
+ setPos(null);
722
+ return;
723
+ }
724
+ place();
725
+ if (autoFocus) panelRef.current?.focus?.();
726
+ }, [open, place, autoFocus]);
727
+ useEffect(() => {
728
+ if (!open || typeof document === "undefined") return;
729
+ const onPointerDown = (e) => {
730
+ const t = e.target;
731
+ if (panelRef.current?.contains(t)) return;
732
+ const anchor = anchorEl?.();
733
+ if (anchor && anchor.contains(t)) return;
734
+ onClose();
735
+ };
736
+ const onKey = (e) => {
737
+ if (e.key === "Escape") onClose();
738
+ };
739
+ document.addEventListener("pointerdown", onPointerDown, true);
740
+ document.addEventListener("keydown", onKey, true);
741
+ window.addEventListener("scroll", onClose, true);
742
+ window.addEventListener("resize", onClose);
743
+ window.addEventListener("blur", onClose);
744
+ return () => {
745
+ document.removeEventListener("pointerdown", onPointerDown, true);
746
+ document.removeEventListener("keydown", onKey, true);
747
+ window.removeEventListener("scroll", onClose, true);
748
+ window.removeEventListener("resize", onClose);
749
+ window.removeEventListener("blur", onClose);
750
+ };
751
+ }, [open, onClose, anchorEl]);
752
+ if (!open) return null;
753
+ return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(PortalTheme, { name: themeName, children: /* @__PURE__ */ jsx(
754
+ MenuPanel,
755
+ {
756
+ panelRef: setPanel,
757
+ minWidth,
758
+ maxHeight,
759
+ tabIndex: -1,
760
+ onKeyDown: (e) => menuKeyDown(e, onClose),
761
+ style: {
762
+ position: "fixed",
763
+ left: pos?.left ?? 0,
764
+ top: pos?.top ?? 0,
765
+ zIndex: 1e5,
766
+ visibility: pos ? "visible" : "hidden"
767
+ },
768
+ children
769
+ }
770
+ ) }) });
771
+ }
772
+ function ComboBox({
773
+ value,
774
+ onChange,
775
+ options,
776
+ loading = false,
777
+ error = null,
778
+ onRetry,
779
+ placeholder,
780
+ disabled,
781
+ emptyText = "No matches \u2014 press to use what you typed.",
782
+ minWidth = 240
783
+ }) {
784
+ const [open, setOpen] = useState(false);
785
+ const rowRef = useRef(null);
786
+ const anchorRect = useCallback(() => rowRef.current?.getBoundingClientRect() ?? null, []);
787
+ const anchorEl = useCallback(() => rowRef.current, []);
788
+ const filtered = useMemo(() => filterOptions(options, value), [options, value]);
789
+ const pick = (v) => {
790
+ onChange(v);
791
+ setOpen(false);
792
+ };
793
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
794
+ /* @__PURE__ */ jsxs(XStack, { ref: rowRef, items: "center", gap: "$2", minW: minWidth, children: [
795
+ /* @__PURE__ */ jsx(
796
+ Input,
797
+ {
798
+ flex: 1,
799
+ value,
800
+ onChangeText: (v) => {
801
+ onChange(v);
802
+ if (!open) setOpen(true);
803
+ },
804
+ onFocus: () => setOpen(true),
805
+ disabled,
806
+ placeholder,
807
+ autoCapitalize: "none"
808
+ }
809
+ ),
810
+ /* @__PURE__ */ jsx(
811
+ Button,
812
+ {
813
+ size: "$2",
814
+ chromeless: true,
815
+ disabled,
816
+ icon: /* @__PURE__ */ jsx(ChevronDown, { size: 16, opacity: 0.7 }),
817
+ onPress: () => setOpen((o) => !o),
818
+ "aria-label": "Show options"
819
+ }
820
+ )
821
+ ] }),
822
+ /* @__PURE__ */ jsx(
823
+ FloatingMenu,
824
+ {
825
+ open,
826
+ onClose: () => setOpen(false),
827
+ anchorRect,
828
+ anchorEl,
829
+ autoFocus: false,
830
+ minWidth,
831
+ maxHeight: 300,
832
+ children: loading ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$2", children: [
833
+ /* @__PURE__ */ jsx(Spinner, { size: "small", color: "$color11" }),
834
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", children: "Loading options\u2026" })
835
+ ] }) : error ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$2", children: [
836
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", flex: 1, numberOfLines: 2, children: error }),
837
+ onRetry ? /* @__PURE__ */ jsx(Button, { size: "$1", chromeless: true, icon: /* @__PURE__ */ jsx(RefreshCw, { size: 12 }), onPress: onRetry, "aria-label": "Retry" }) : null
838
+ ] }) : filtered.length === 0 ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", px: "$2", py: "$2", children: emptyText }) : filtered.map((o) => /* @__PURE__ */ jsx(
839
+ MenuItemView,
840
+ {
841
+ label: o.label ?? o.value,
842
+ description: o.hint,
843
+ selected: o.value === value,
844
+ onSelect: () => pick(o.value)
845
+ },
846
+ o.value
847
+ ))
848
+ }
849
+ )
850
+ ] });
851
+ }
852
+ var ORDER = ["ai", "console", "app", "chat", "bot", "team", "billing"];
853
+ var SURFACES = ORDER.map((id) => {
854
+ const s = surfaceById(id);
855
+ return { id, label: s.label, href: s.href, hint: s.domain };
856
+ });
857
+ function otherSurfaces(current2) {
858
+ return current2 ? SURFACES.filter((s) => s.id !== current2) : SURFACES;
859
+ }
860
+ function HanzoMark({ size = 22, color = "currentColor" }) {
861
+ return /* @__PURE__ */ jsxs(
862
+ "svg",
863
+ {
864
+ width: size,
865
+ height: size,
866
+ viewBox: "0 0 67 67",
867
+ role: "img",
868
+ "aria-label": "Hanzo",
869
+ fill: color,
870
+ style: { display: "block", flexShrink: 0 },
871
+ children: [
872
+ /* @__PURE__ */ jsx("path", { d: "M22.21 67V44.6369H0V67H22.21Z" }),
873
+ /* @__PURE__ */ jsx("path", { opacity: 0.55, d: "M0 44.6369L22.21 46.8285V44.6369H0Z" }),
874
+ /* @__PURE__ */ jsx("path", { d: "M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z" }),
875
+ /* @__PURE__ */ jsx("path", { d: "M22.21 0H0V22.3184H22.21V0Z" }),
876
+ /* @__PURE__ */ jsx("path", { d: "M66.7198 0H44.5098V22.3184H66.7198V0Z" }),
877
+ /* @__PURE__ */ jsx("path", { opacity: 0.55, d: "M66.6753 22.3185L44.5098 20.0822V22.3185H66.6753Z" }),
878
+ /* @__PURE__ */ jsx("path", { d: "M66.7198 67V44.6369H44.5098V67H66.7198Z" })
879
+ ]
880
+ }
881
+ );
882
+ }
883
+ function BrandMark({
884
+ size = 20,
885
+ wordmark = "Hanzo",
886
+ animated = true
887
+ }) {
888
+ if (!animated) return /* @__PURE__ */ jsx(HanzoMark, { size });
889
+ return /* @__PURE__ */ jsx(HanzoLogo, { animated: true, size, wordmark });
890
+ }
891
+ var SURFACE_ICON = {
892
+ ai: Sparkles,
893
+ console: LayoutGrid,
894
+ app: AppWindow,
895
+ chat: MessageCircle,
896
+ bot: Bot,
897
+ team: Users,
898
+ billing: CreditCard
899
+ };
900
+ var openHref = (href) => {
901
+ if (typeof window !== "undefined") window.open(href, "_blank", "noopener");
902
+ };
903
+ function MenuRow({ icon, label, onPress }) {
904
+ return /* @__PURE__ */ jsxs(XStack, { onPress, cursor: "pointer", items: "center", gap: "$2.5", px: "$2", py: "$2", rounded: "$3", hoverStyle: { bg: "$color5" }, children: [
905
+ icon,
906
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", children: label })
907
+ ] });
908
+ }
909
+ function AppHeader({
910
+ brand,
911
+ wordmark = "Hanzo",
912
+ onBrand,
913
+ org,
914
+ children,
915
+ current: current2,
916
+ surfaces,
917
+ open,
918
+ user,
919
+ menu,
920
+ theme,
921
+ onProfile,
922
+ onTeam,
923
+ onBilling,
924
+ onSignOut
925
+ }) {
926
+ const [appsOpen, setAppsOpen] = useState(false);
927
+ const [menuOpen, setMenuOpen] = useState(false);
928
+ const items = surfaces ?? otherSurfaces(current2);
929
+ const launch = (s) => {
930
+ setAppsOpen(false);
931
+ if (open) open(s);
932
+ else openHref(s.href);
933
+ };
934
+ return /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$3", height: 52, borderBottomWidth: 1, borderColor: "$borderColor", bg: "$background", children: [
935
+ /* @__PURE__ */ jsx(XStack, { items: "center", cursor: onBrand ? "pointer" : void 0, onPress: onBrand, children: brand ?? /* @__PURE__ */ jsx(BrandMark, { wordmark }) }),
936
+ org ? /* @__PURE__ */ jsx(XStack, { items: "center", minW: 0, children: org }) : null,
937
+ /* @__PURE__ */ jsx(XStack, { flex: 1, items: "center", minW: 0, children }),
938
+ items.length > 0 ? /* @__PURE__ */ jsxs(Popover, { open: appsOpen, onOpenChange: setAppsOpen, placement: "bottom-end", children: [
939
+ /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsx(Grip, { size: 16 }), "aria-label": "Apps" }) }),
940
+ /* @__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) => {
941
+ const Icon = SURFACE_ICON[s.id];
942
+ return /* @__PURE__ */ jsxs(XStack, { onPress: () => launch(s), cursor: "pointer", items: "center", gap: "$2.5", px: "$2", py: "$2", rounded: "$3", hoverStyle: { bg: "$color5" }, children: [
943
+ /* @__PURE__ */ jsx(Icon, { size: 16 }),
944
+ /* @__PURE__ */ jsx(Text, { flex: 1, fontSize: "$2", fontWeight: "600", color: "$color12", children: s.label }),
945
+ s.hint ? /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color10", children: s.hint }) : null
946
+ ] }, s.id);
947
+ }) }) })
948
+ ] }) : null,
949
+ /* @__PURE__ */ jsxs(Popover, { open: menuOpen, onOpenChange: setMenuOpen, placement: "bottom-end", children: [
950
+ /* @__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 }) }),
951
+ /* @__PURE__ */ jsx(Popover.Content, { bordered: true, elevate: true, p: "$2", width: 220, bg: "$color2", borderColor: "$borderColor", children: menu ?? /* @__PURE__ */ jsxs(YStack, { gap: "$1", children: [
952
+ onProfile ? /* @__PURE__ */ jsx(MenuRow, { icon: /* @__PURE__ */ jsx(UserRound, { size: 15 }), label: "Profile", onPress: () => (setMenuOpen(false), onProfile()) }) : null,
953
+ theme !== null ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2.5", px: "$2", py: "$1", rounded: "$3", children: [
954
+ /* @__PURE__ */ jsx(Text, { flex: 1, fontSize: "$2", color: "$color12", children: "Theme" }),
955
+ theme ?? /* @__PURE__ */ jsx(ThemeToggle, {})
956
+ ] }) : null,
957
+ onTeam ? /* @__PURE__ */ jsx(MenuRow, { icon: /* @__PURE__ */ jsx(Settings2, { size: 15 }), label: "Team settings", onPress: () => (setMenuOpen(false), onTeam()) }) : null,
958
+ onBilling ? /* @__PURE__ */ jsx(MenuRow, { icon: /* @__PURE__ */ jsx(CreditCard, { size: 15 }), label: "Billing", onPress: () => (setMenuOpen(false), onBilling()) }) : null,
959
+ onSignOut ? /* @__PURE__ */ jsxs(Fragment, { children: [
960
+ /* @__PURE__ */ jsx(Separator, { borderColor: "$borderColor", my: "$1" }),
961
+ /* @__PURE__ */ jsx(MenuRow, { icon: /* @__PURE__ */ jsx(LogOut, { size: 15 }), label: "Sign out", onPress: () => (setMenuOpen(false), onSignOut()) })
962
+ ] }) : null
963
+ ] }) })
964
+ ] })
965
+ ] });
966
+ }
967
+ function monogram(name) {
968
+ const words = name.trim().split(/[\s._/-]+/).filter(Boolean);
969
+ const letters = words.slice(0, 2).map((w) => w[0] ?? "").join("");
970
+ return (letters || name.trim().slice(0, 2)).toUpperCase();
971
+ }
972
+ function OrgMark({ org, size = 22, maxW }) {
973
+ if (org.logo) {
974
+ return /* @__PURE__ */ jsx(
975
+ "img",
976
+ {
977
+ src: org.logo,
978
+ alt: "",
979
+ style: {
980
+ height: size,
981
+ width: maxW ? "auto" : size,
982
+ maxWidth: maxW ?? size,
983
+ objectFit: "contain",
984
+ display: "block",
985
+ borderRadius: 6,
986
+ flexShrink: 0
987
+ }
988
+ }
989
+ );
990
+ }
991
+ return /* @__PURE__ */ jsx(
992
+ YStack,
993
+ {
994
+ width: size,
995
+ height: size,
996
+ rounded: "$3",
997
+ bg: "$color4",
998
+ items: "center",
999
+ justify: "center",
1000
+ style: { flexShrink: 0 },
1001
+ children: /* @__PURE__ */ jsx(Text, { fontSize: Math.round(size * 0.4), fontWeight: "800", color: "$color12", children: monogram(org.displayName || org.name) })
1002
+ }
1003
+ );
1004
+ }
1005
+
1006
+ // src/product/scope.ts
1007
+ function browserStorage() {
1008
+ if (typeof window === "undefined") return null;
1009
+ try {
1010
+ return window.localStorage;
1011
+ } catch {
1012
+ return null;
1013
+ }
1014
+ }
1015
+ function orgScope(config) {
1016
+ const key = config.key ?? "hanzo.org";
1017
+ const selectedKey = `${key}.selected`;
1018
+ const store = () => config.storage ?? browserStorage();
1019
+ const read = (k) => {
1020
+ try {
1021
+ return store()?.getItem(k) ?? null;
1022
+ } catch {
1023
+ return null;
1024
+ }
1025
+ };
1026
+ const write = (k, v) => {
1027
+ try {
1028
+ if (v === null) store()?.removeItem(k);
1029
+ else store()?.setItem(k, v);
1030
+ } catch {
1031
+ }
1032
+ };
1033
+ const goHome = () => {
1034
+ if (config.navigate) return config.navigate("/");
1035
+ if (typeof window !== "undefined") window.location.assign("/");
1036
+ };
1037
+ const doReload = () => {
1038
+ if (config.reload) return config.reload();
1039
+ if (typeof window !== "undefined") window.location.reload();
1040
+ };
1041
+ const scope = {
1042
+ currentOrg: () => read(key) || config.brandOrg,
1043
+ setCurrentOrg: (org) => write(key, !org || org === config.brandOrg ? null : org),
1044
+ isScopedAway: () => scope.currentOrg() !== config.brandOrg,
1045
+ hasSelectedOrg: () => read(selectedKey) === "1",
1046
+ enterOrg: (org) => {
1047
+ if (!org) return;
1048
+ scope.setCurrentOrg(org);
1049
+ write(selectedKey, "1");
1050
+ goHome();
1051
+ },
1052
+ leaveOrg: () => {
1053
+ write(selectedKey, null);
1054
+ scope.setCurrentOrg(config.brandOrg);
1055
+ goHome();
1056
+ },
1057
+ switchOrg: (org) => {
1058
+ if (!org || org === scope.currentOrg()) return;
1059
+ scope.setCurrentOrg(org);
1060
+ write(selectedKey, "1");
1061
+ doReload();
1062
+ }
1063
+ };
1064
+ return scope;
1065
+ }
1066
+ function filterOrgs(orgs, query) {
1067
+ const q = query.trim().toLowerCase();
1068
+ if (!q) return orgs;
1069
+ return orgs.filter(
1070
+ (o) => o.name.toLowerCase().includes(q) || (o.displayName ?? "").toLowerCase().includes(q)
1071
+ );
1072
+ }
1073
+ var titleCase = (s) => s ? s[0].toUpperCase() + s.slice(1) : s;
1074
+ function OrgSwitcher({ scope, orgs, pageSize = 20, current: given, create, picker = false }) {
1075
+ const currentId = scope.currentOrg();
1076
+ const [open, setOpen] = useState(false);
1077
+ const [query, setQuery] = useState("");
1078
+ const [debounced, setDebounced] = useState("");
1079
+ const [rows, setRows] = useState([]);
1080
+ const [loading, setLoading] = useState(false);
1081
+ const [loadingMore, setLoadingMore] = useState(false);
1082
+ const [hasMore, setHasMore] = useState(false);
1083
+ const [creating, setCreating] = useState(false);
1084
+ const [newName, setNewName] = useState("");
1085
+ const [busy, setBusy] = useState(false);
1086
+ const [err, setErr] = useState(null);
1087
+ const pageRef = useRef(0);
1088
+ const reqRef = useRef(0);
1089
+ useEffect(() => {
1090
+ const id = setTimeout(() => setDebounced(query.trim()), 250);
1091
+ return () => clearTimeout(id);
1092
+ }, [query]);
1093
+ const fetchPage = useCallback(
1094
+ async (page, q, append) => {
1095
+ if (!orgs) return;
1096
+ const token = ++reqRef.current;
1097
+ append ? setLoadingMore(true) : setLoading(true);
1098
+ try {
1099
+ const incoming = await orgs(page, q);
1100
+ if (token !== reqRef.current) return;
1101
+ pageRef.current = page;
1102
+ setRows((prev) => {
1103
+ const merged = append ? [...prev] : [];
1104
+ const seen = new Set(merged.map((o) => o.name));
1105
+ for (const o of incoming) if (!seen.has(o.name)) merged.push(o);
1106
+ return merged;
1107
+ });
1108
+ setHasMore(incoming.length >= pageSize);
1109
+ } catch {
1110
+ if (token !== reqRef.current) return;
1111
+ if (!append) setRows([]);
1112
+ setHasMore(false);
1113
+ } finally {
1114
+ if (token === reqRef.current) {
1115
+ setLoading(false);
1116
+ setLoadingMore(false);
1117
+ }
1118
+ }
1119
+ },
1120
+ [orgs, pageSize]
1121
+ );
1122
+ useEffect(() => {
1123
+ if (!open || !orgs) return;
1124
+ void fetchPage(0, debounced, false);
1125
+ }, [open, debounced, fetchPage, orgs]);
1126
+ const loadMore = useCallback(() => {
1127
+ if (loading || loadingMore || !hasMore) return;
1128
+ void fetchPage(pageRef.current + 1, debounced, true);
1129
+ }, [loading, loadingMore, hasMore, debounced, fetchPage]);
1130
+ const visible = useMemo(() => {
1131
+ if (orgs) return filterOrgs(rows, query);
1132
+ return [{ name: currentId, displayName: titleCase(currentId) }];
1133
+ }, [orgs, rows, query, currentId]);
1134
+ const current2 = useMemo(() => {
1135
+ if (given && given.name === currentId) return given;
1136
+ return rows.find((o) => o.name === currentId) ?? { name: currentId, displayName: titleCase(currentId) };
1137
+ }, [given, rows, currentId]);
1138
+ const currentLabel = current2.displayName || titleCase(current2.name);
1139
+ const select = useCallback(
1140
+ (org) => {
1141
+ setOpen(false);
1142
+ scope.switchOrg(org);
1143
+ },
1144
+ [scope]
1145
+ );
1146
+ const submitCreate = async () => {
1147
+ const name = newName.trim();
1148
+ if (!name || !create) return;
1149
+ setBusy(true);
1150
+ setErr(null);
1151
+ try {
1152
+ const org = await create(name);
1153
+ scope.switchOrg(org);
1154
+ } catch (e) {
1155
+ setErr(e instanceof Error ? e.message : "Could not create the organization.");
1156
+ setBusy(false);
1157
+ }
1158
+ };
1159
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, placement: "bottom-start", children: [
1160
+ /* @__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: [
1161
+ /* @__PURE__ */ jsx(OrgMark, { org: current2, size: 30 }),
1162
+ /* @__PURE__ */ jsx(Text, { flex: 1, minW: 0, fontSize: "$4", fontWeight: "800", color: "$color12", numberOfLines: 1, children: currentLabel }),
1163
+ /* @__PURE__ */ jsx(ChevronsUpDown, { size: 15, color: "$color9" })
1164
+ ] }) }) }),
1165
+ /* @__PURE__ */ jsx(Popover.Content, { bordered: true, elevate: true, p: "$2", width: 300, bg: "$color2", borderColor: "$borderColor", children: creating ? /* @__PURE__ */ jsxs(YStack, { gap: "$2", children: [
1166
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", fontWeight: "700", children: "Create organization" }),
1167
+ /* @__PURE__ */ jsx(
1168
+ Input,
1169
+ {
1170
+ size: "$3",
1171
+ placeholder: "Organization name",
1172
+ value: newName,
1173
+ onChangeText: setNewName,
1174
+ autoCapitalize: "words",
1175
+ onSubmitEditing: () => void submitCreate()
1176
+ }
1177
+ ),
1178
+ err ? /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$red10", children: err }) : null,
1179
+ /* @__PURE__ */ jsxs(XStack, { gap: "$2", justify: "flex-end", children: [
1180
+ /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, onPress: () => setCreating(false), disabled: busy, children: "Cancel" }),
1181
+ /* @__PURE__ */ jsx(
1182
+ Button,
1183
+ {
1184
+ size: "$2",
1185
+ onPress: () => void submitCreate(),
1186
+ disabled: busy || !newName.trim(),
1187
+ icon: busy ? /* @__PURE__ */ jsx(Spinner, { size: "small" }) : /* @__PURE__ */ jsx(Plus, { size: 14 }),
1188
+ children: "Create"
1189
+ }
1190
+ )
1191
+ ] })
1192
+ ] }) : /* @__PURE__ */ jsxs(YStack, { gap: "$1", children: [
1193
+ orgs ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$1", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [
1194
+ /* @__PURE__ */ jsx(Search, { size: 13, opacity: 0.6 }),
1195
+ /* @__PURE__ */ jsx(
1196
+ Input,
1197
+ {
1198
+ flex: 1,
1199
+ size: "$2",
1200
+ borderWidth: 0,
1201
+ bg: "transparent",
1202
+ placeholder: "Find organization\u2026",
1203
+ value: query,
1204
+ onChangeText: setQuery,
1205
+ autoCapitalize: "none",
1206
+ autoCorrect: false
1207
+ }
1208
+ )
1209
+ ] }) : null,
1210
+ /* @__PURE__ */ jsxs(
1211
+ "div",
1212
+ {
1213
+ style: { maxHeight: 300, overflowY: "auto", display: "flex", flexDirection: "column" },
1214
+ onScroll: (e) => {
1215
+ const el = e.currentTarget;
1216
+ if (el.scrollHeight - el.scrollTop - el.clientHeight < 48) loadMore();
1217
+ },
1218
+ children: [
1219
+ loading ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$3", children: [
1220
+ /* @__PURE__ */ jsx(Spinner, { size: "small", color: "$color11" }),
1221
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", children: "Loading organizations\u2026" })
1222
+ ] }) : 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(
1223
+ XStack,
1224
+ {
1225
+ onPress: () => select(org.name),
1226
+ cursor: "pointer",
1227
+ items: "center",
1228
+ gap: "$2.5",
1229
+ px: "$2",
1230
+ py: "$2",
1231
+ rounded: "$3",
1232
+ bg: org.name === currentId ? "$color4" : "transparent",
1233
+ hoverStyle: { bg: "$color5" },
1234
+ children: [
1235
+ /* @__PURE__ */ jsx(OrgMark, { org }),
1236
+ /* @__PURE__ */ jsx(Text, { flex: 1, fontSize: "$2", color: "$color12", numberOfLines: 1, children: org.displayName || org.name }),
1237
+ org.name === currentId ? /* @__PURE__ */ jsx(Check, { size: 15 }) : null
1238
+ ]
1239
+ },
1240
+ org.name
1241
+ )),
1242
+ loadingMore ? /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", px: "$2", py: "$2", children: [
1243
+ /* @__PURE__ */ jsx(Spinner, { size: "small", color: "$color11" }),
1244
+ /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color10", children: "Loading more\u2026" })
1245
+ ] }) : 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
1246
+ ]
1247
+ }
1248
+ ),
1249
+ create ? /* @__PURE__ */ jsxs(
1250
+ XStack,
1251
+ {
1252
+ onPress: () => {
1253
+ setCreating(true);
1254
+ setErr(null);
1255
+ },
1256
+ cursor: "pointer",
1257
+ items: "center",
1258
+ gap: "$2.5",
1259
+ px: "$2",
1260
+ py: "$2",
1261
+ mt: "$1",
1262
+ rounded: "$3",
1263
+ borderTopWidth: 1,
1264
+ borderColor: "$borderColor",
1265
+ hoverStyle: { bg: "$color5" },
1266
+ children: [
1267
+ /* @__PURE__ */ jsx(YStack, { width: 22, height: 22, rounded: "$3", bg: "$color3", items: "center", justify: "center", children: /* @__PURE__ */ jsx(Plus, { size: 14 }) }),
1268
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", children: "Create organization" })
1269
+ ]
1270
+ }
1271
+ ) : null,
1272
+ picker ? /* @__PURE__ */ jsxs(
1273
+ XStack,
1274
+ {
1275
+ onPress: () => {
1276
+ setOpen(false);
1277
+ scope.leaveOrg();
1278
+ },
1279
+ cursor: "pointer",
1280
+ items: "center",
1281
+ gap: "$2.5",
1282
+ px: "$2",
1283
+ py: "$2",
1284
+ rounded: "$3",
1285
+ hoverStyle: { bg: "$color5" },
1286
+ children: [
1287
+ /* @__PURE__ */ jsx(YStack, { width: 22, height: 22, rounded: "$3", bg: "$color3", items: "center", justify: "center", children: /* @__PURE__ */ jsx(LayoutGrid, { size: 14 }) }),
1288
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", children: "All organizations" })
1289
+ ]
1290
+ }
1291
+ ) : null
1292
+ ] }) })
1293
+ ] });
1294
+ }
1295
+ function DropdownMenu({
1296
+ trigger,
1297
+ items,
1298
+ open,
1299
+ defaultOpen = false,
1300
+ onOpenChange,
1301
+ minWidth = 200,
1302
+ maxHeight
1303
+ }) {
1304
+ const [isOpen, setOpen] = useControllableState({
1305
+ prop: open,
1306
+ defaultProp: defaultOpen,
1307
+ onChange: onOpenChange
1308
+ });
1309
+ const anchorRef = useRef(null);
1310
+ const anchorRect = useCallback(() => anchorRef.current?.getBoundingClientRect() ?? null, []);
1311
+ const anchorEl = useCallback(() => anchorRef.current, []);
1312
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1313
+ /* @__PURE__ */ jsx(XStack, { ref: anchorRef, self: "flex-start", cursor: "pointer", onPress: () => setOpen(!isOpen), children: trigger }),
1314
+ /* @__PURE__ */ jsx(
1315
+ FloatingMenu,
1316
+ {
1317
+ open: isOpen,
1318
+ onClose: () => setOpen(false),
1319
+ anchorRect,
1320
+ anchorEl,
1321
+ minWidth,
1322
+ maxHeight,
1323
+ children: renderMenuItems(items, () => setOpen(false))
1324
+ }
1325
+ )
1326
+ ] });
1327
+ }
1328
+ function ContextMenu({ children, items, disabled, minWidth = 200, maxHeight }) {
1329
+ const [state, setState] = useState({ open: false, x: 0, y: 0 });
1330
+ const close = useCallback(() => setState((s) => s.open ? { ...s, open: false } : s), []);
1331
+ const anchorRect = useCallback(
1332
+ () => ({ left: state.x, top: state.y, right: state.x, bottom: state.y, width: 0, height: 0 }),
1333
+ [state.x, state.y]
1334
+ );
1335
+ const childOnContextMenu = children.props.onContextMenu;
1336
+ const target = cloneElement(children, {
1337
+ onContextMenu: (e) => {
1338
+ childOnContextMenu?.(e);
1339
+ if (disabled) return;
1340
+ e.preventDefault();
1341
+ e.stopPropagation();
1342
+ setState({ open: true, x: e.clientX, y: e.clientY });
1343
+ }
1344
+ });
1345
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1346
+ target,
1347
+ /* @__PURE__ */ jsx(FloatingMenu, { open: state.open, onClose: close, anchorRect, gap: 0, minWidth, maxHeight, children: renderMenuItems(items, close) })
1348
+ ] });
1349
+ }
1350
+ var isExternal = (href) => /^https?:\/\//.test(href);
1351
+ var defaultLink = ({ href, children, onNavigate }) => /* @__PURE__ */ jsx(
1352
+ "a",
1353
+ {
1354
+ href,
1355
+ onClick: onNavigate,
1356
+ ...isExternal(href) ? { target: "_blank", rel: "noopener noreferrer" } : null,
1357
+ style: { textDecoration: "none", color: "inherit", display: "block" },
1358
+ children
1359
+ }
1360
+ );
1361
+ function ProductCell({ product, link, icon, close }) {
1362
+ const glyph = icon?.(product.id);
1363
+ return /* @__PURE__ */ jsx(YStack, { minW: 200, flex: 1, flexBasis: 200, children: link({
1364
+ href: product.url,
1365
+ onNavigate: close,
1366
+ children: /* @__PURE__ */ jsxs(XStack, { gap: "$2.5", items: "flex-start", p: "$2.5", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: "$color4" }, children: [
1367
+ glyph ? /* @__PURE__ */ jsx(YStack, { pt: "$0.5", children: glyph }) : null,
1368
+ /* @__PURE__ */ jsxs(YStack, { minW: 0, gap: "$0.5", children: [
1369
+ product.verb ? /* @__PURE__ */ jsx(Text, { fontSize: 11, color: "$color10", textTransform: "uppercase", letterSpacing: 0.4, children: product.verb }) : null,
1370
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color12", children: product.name }),
1371
+ /* @__PURE__ */ jsx(Text, { fontSize: 12, color: "$color10", lineHeight: 16, children: product.job })
1372
+ ] })
1373
+ ] })
1374
+ }) });
1375
+ }
1376
+ function Column({ title, links, link, icon, close }) {
1377
+ return /* @__PURE__ */ jsxs(YStack, { minW: 160, flex: 1, gap: "$1", children: [
1378
+ /* @__PURE__ */ jsx(Text, { fontSize: 11, color: "$color10", textTransform: "uppercase", letterSpacing: 0.5, px: "$2", pb: "$1", children: title }),
1379
+ links.map((l) => /* @__PURE__ */ jsxs(XStack, { px: "$2", py: "$1", rounded: "$3", hoverStyle: { bg: "$color4" }, gap: "$2", items: "center", children: [
1380
+ icon?.(l.id) ?? null,
1381
+ link({
1382
+ href: l.href,
1383
+ onNavigate: close,
1384
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", children: l.label })
1385
+ })
1386
+ ] }, l.id))
1387
+ ] });
1388
+ }
1389
+ function Launcher({ menu, link, icon, close }) {
1390
+ return /* @__PURE__ */ jsxs(
1391
+ YStack,
1392
+ {
1393
+ position: "absolute",
1394
+ t: 52,
1395
+ l: 0,
1396
+ r: 0,
1397
+ z: 50,
1398
+ bg: "$background",
1399
+ borderBottomWidth: 1,
1400
+ borderColor: "$borderColor",
1401
+ px: "$4",
1402
+ py: "$4",
1403
+ gap: "$3",
1404
+ maxH: "80vh",
1405
+ overflow: "scroll",
1406
+ children: [
1407
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$3", flexWrap: "wrap", children: [
1408
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", children: menu.eyebrow }),
1409
+ /* @__PURE__ */ jsx(XStack, { ml: "auto", children: link({
1410
+ href: menu.allProducts.href,
1411
+ onNavigate: close,
1412
+ children: /* @__PURE__ */ jsxs(Text, { fontSize: "$2", color: "$color12", children: [
1413
+ menu.allProducts.label,
1414
+ " \u2192"
1415
+ ] })
1416
+ }) })
1417
+ ] }),
1418
+ /* @__PURE__ */ jsx(XStack, { gap: "$2.5", flexWrap: "wrap", children: menu.products.map((p) => /* @__PURE__ */ jsx(ProductCell, { product: p, link, icon, close }, p.id)) }),
1419
+ /* @__PURE__ */ jsx(Separator, {}),
1420
+ /* @__PURE__ */ jsxs(XStack, { gap: "$4", flexWrap: "wrap", items: "flex-start", children: [
1421
+ /* @__PURE__ */ jsx(Column, { title: "Platform", links: menu.utilities, link, icon, close }),
1422
+ /* @__PURE__ */ jsx(Column, { title: "Install", links: menu.installs, link, icon, close })
1423
+ ] })
1424
+ ]
1425
+ }
1426
+ );
1427
+ }
1428
+ function Cta({ action, link }) {
1429
+ return /* @__PURE__ */ jsx(XStack, { bg: "$color12", px: "$3", py: "$1.5", rounded: "$3", hoverStyle: { opacity: 0.9 }, children: link({
1430
+ href: action.href,
1431
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$background", children: action.label })
1432
+ }) });
1433
+ }
1434
+ function MobilePanel({ header, menu, link, icon, close }) {
1435
+ return /* @__PURE__ */ jsxs(
1436
+ YStack,
1437
+ {
1438
+ position: "absolute",
1439
+ t: 52,
1440
+ l: 0,
1441
+ r: 0,
1442
+ z: 50,
1443
+ bg: "$background",
1444
+ borderBottomWidth: 1,
1445
+ borderColor: "$borderColor",
1446
+ px: "$3",
1447
+ py: "$3",
1448
+ gap: "$3",
1449
+ maxH: "80vh",
1450
+ overflow: "scroll",
1451
+ children: [
1452
+ /* @__PURE__ */ jsx(YStack, { gap: "$1", children: header.localNav.map((l) => /* @__PURE__ */ jsx(XStack, { px: "$2", py: "$1.5", rounded: "$3", hoverStyle: { bg: "$color4" }, children: link({
1453
+ href: l.href,
1454
+ onNavigate: close,
1455
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color12", children: l.label })
1456
+ }) }, l.id)) }),
1457
+ menu ? /* @__PURE__ */ jsxs(Fragment, { children: [
1458
+ /* @__PURE__ */ jsx(Separator, {}),
1459
+ /* @__PURE__ */ jsx(YStack, { gap: "$1", children: menu.products.map((p) => /* @__PURE__ */ jsxs(XStack, { px: "$2", py: "$1.5", rounded: "$3", hoverStyle: { bg: "$color4" }, gap: "$2", items: "center", children: [
1460
+ icon?.(p.id) ?? null,
1461
+ link({
1462
+ href: p.url,
1463
+ onNavigate: close,
1464
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color12", children: p.name })
1465
+ })
1466
+ ] }, p.id)) }),
1467
+ /* @__PURE__ */ jsx(Separator, {}),
1468
+ /* @__PURE__ */ jsx(Column, { title: "Platform", links: menu.utilities, link, icon, close }),
1469
+ /* @__PURE__ */ jsx(Column, { title: "Install", links: menu.installs, link, icon, close })
1470
+ ] }) : null
1471
+ ]
1472
+ }
1473
+ );
1474
+ }
1475
+ function SiteNav({ header, menu, brand, actions, link = defaultLink, icon, active, meetLabel = "Meet Hanzo" }) {
1476
+ const [launcher, setLauncher] = useState(false);
1477
+ const [mobile, setMobile] = useState(false);
1478
+ const root = useRef(null);
1479
+ useEffect(() => {
1480
+ if (!launcher && !mobile) return;
1481
+ const dismiss = () => {
1482
+ setLauncher(false);
1483
+ setMobile(false);
1484
+ };
1485
+ const onKey = (e) => {
1486
+ if (e.key === "Escape") dismiss();
1487
+ };
1488
+ const onDown = (e) => {
1489
+ if (root.current && !root.current.contains(e.target)) dismiss();
1490
+ };
1491
+ document.addEventListener("keydown", onKey);
1492
+ document.addEventListener("mousedown", onDown);
1493
+ return () => {
1494
+ document.removeEventListener("keydown", onKey);
1495
+ document.removeEventListener("mousedown", onDown);
1496
+ };
1497
+ }, [launcher, mobile]);
1498
+ return /* @__PURE__ */ jsxs(YStack, { ref: root, position: "relative", bg: "$background", children: [
1499
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$1", px: "$3", height: 52, borderBottomWidth: 1, borderColor: "$borderColor", children: [
1500
+ brand ? /* @__PURE__ */ jsx(XStack, { items: "center", pr: "$2", children: brand }) : null,
1501
+ menu ? /* @__PURE__ */ jsx(
1502
+ XStack,
1503
+ {
1504
+ cursor: "pointer",
1505
+ px: "$2.5",
1506
+ py: "$1.5",
1507
+ rounded: "$3",
1508
+ bg: launcher ? "$color4" : "transparent",
1509
+ hoverStyle: { bg: "$color4" },
1510
+ onPress: () => setLauncher(!launcher),
1511
+ accessibilityRole: "button",
1512
+ "aria-expanded": launcher,
1513
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", children: meetLabel })
1514
+ }
1515
+ ) : null,
1516
+ /* @__PURE__ */ jsx(XStack, { items: "center", gap: "$0.5", flex: 1, minW: 0, $sm: { display: "none" }, children: header.localNav.map((l) => /* @__PURE__ */ jsx(
1517
+ XStack,
1518
+ {
1519
+ px: "$2.5",
1520
+ py: "$1.5",
1521
+ rounded: "$3",
1522
+ hoverStyle: { bg: "$color4" },
1523
+ onMouseEnter: () => launcher && setLauncher(false),
1524
+ children: link({
1525
+ href: l.href,
1526
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: active === l.id ? "$color12" : "$color11", children: l.label })
1527
+ })
1528
+ },
1529
+ l.id
1530
+ )) }),
1531
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", ml: "auto", children: [
1532
+ actions,
1533
+ /* @__PURE__ */ jsx(Cta, { action: header.action, link }),
1534
+ /* @__PURE__ */ jsx(
1535
+ XStack,
1536
+ {
1537
+ display: "none",
1538
+ $sm: { display: "flex" },
1539
+ cursor: "pointer",
1540
+ px: "$2",
1541
+ py: "$1.5",
1542
+ rounded: "$3",
1543
+ hoverStyle: { bg: "$color4" },
1544
+ onPress: () => setMobile(!mobile),
1545
+ accessibilityRole: "button",
1546
+ "aria-label": mobile ? "Close menu" : "Open menu",
1547
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", children: mobile ? "Close" : "Menu" })
1548
+ }
1549
+ )
1550
+ ] })
1551
+ ] }),
1552
+ launcher && menu ? /* @__PURE__ */ jsx(Launcher, { menu, link, icon, close: () => setLauncher(false) }) : null,
1553
+ mobile ? /* @__PURE__ */ jsx(MobilePanel, { header, menu, link, icon, close: () => setMobile(false) }) : null
1554
+ ] });
1555
+ }
1556
+ var isExternal2 = (href) => /^https?:\/\//.test(href);
1557
+ var defaultLink2 = ({ href, children }) => /* @__PURE__ */ jsx(
1558
+ "a",
1559
+ {
1560
+ href,
1561
+ ...isExternal2(href) ? { target: "_blank", rel: "noopener noreferrer" } : null,
1562
+ style: { textDecoration: "none", color: "inherit" },
1563
+ children
1564
+ }
1565
+ );
1566
+ function SiteFooter({ footer, brand, tagline, meta, link = defaultLink2 }) {
1567
+ return /* @__PURE__ */ jsxs(YStack, { borderTopWidth: 1, borderColor: "$borderColor", bg: "$background", px: "$4", py: "$5", gap: "$4", children: [
1568
+ /* @__PURE__ */ jsxs(XStack, { gap: "$5", flexWrap: "wrap", items: "flex-start", children: [
1569
+ brand || tagline ? /* @__PURE__ */ jsxs(YStack, { gap: "$2", minW: 200, flex: 1, children: [
1570
+ brand,
1571
+ tagline ? /* @__PURE__ */ jsx(Text, { fontSize: 12, color: "$color10", lineHeight: 18, maxW: 280, children: tagline }) : null
1572
+ ] }) : null,
1573
+ footer.columns.map((column) => /* @__PURE__ */ jsxs(YStack, { gap: "$1.5", minW: 140, children: [
1574
+ /* @__PURE__ */ jsx(Text, { fontSize: 11, color: "$color10", textTransform: "uppercase", letterSpacing: 0.5, pb: "$1", children: column.title }),
1575
+ column.links.map((l) => /* @__PURE__ */ jsx(XStack, { hoverStyle: { opacity: 0.7 }, children: link({
1576
+ href: l.href,
1577
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", children: l.label })
1578
+ }) }, l.id))
1579
+ ] }, column.id))
1580
+ ] }),
1581
+ /* @__PURE__ */ jsx(Separator, {}),
1582
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$3", flexWrap: "wrap", children: [
1583
+ /* @__PURE__ */ jsx(Text, { fontSize: 12, color: "$color10", children: footer.legal.copyright }),
1584
+ /* @__PURE__ */ jsx(XStack, { items: "center", gap: "$3", flexWrap: "wrap", children: footer.legal.links.map((l) => /* @__PURE__ */ jsx(XStack, { hoverStyle: { opacity: 0.7 }, children: link({
1585
+ href: l.href,
1586
+ children: /* @__PURE__ */ jsx(Text, { fontSize: 12, color: "$color10", children: l.label })
1587
+ }) }, l.id)) }),
1588
+ meta ? /* @__PURE__ */ jsx(XStack, { ml: "auto", items: "center", gap: "$3", children: meta }) : null
1589
+ ] })
1590
+ ] });
1591
+ }
1592
+ var HostCtx = createContext({});
1593
+ var HostProvider = ({ actions, children }) => /* @__PURE__ */ jsx(HostCtx.Provider, { value: actions, children });
1594
+ var useHost = () => useContext(HostCtx);
1595
+ function classifyBackend(e) {
1596
+ const status = typeof e?.status === "number" ? e.status : 0;
1597
+ const message = e instanceof Error ? e.message : String(e);
1598
+ if (status === 503) return { kind: "not-initialized", message };
1599
+ if (status === 404 || status === 405) return { kind: "unavailable", message };
1600
+ if (status === 501) return { kind: "not-implemented", message };
1601
+ if (status === 402) return { kind: "billing", message };
1602
+ if (status === 401) return { kind: "signin", message };
1603
+ if (status === 403) return { kind: "access", message };
1604
+ return { kind: "error", message };
1605
+ }
1606
+ function classifyRead(e) {
1607
+ const s = classifyBackend(e);
1608
+ return s.kind === "billing" ? null : s;
1609
+ }
1610
+ var TITLES = {
1611
+ "not-initialized": "Backend not initialized",
1612
+ unavailable: "Not available on this deployment yet",
1613
+ "not-implemented": "Not yet available",
1614
+ access: "Not enabled for your account",
1615
+ signin: "Your session expired",
1616
+ billing: "Add credits to continue",
1617
+ error: "Could not reach the backend"
1618
+ };
1619
+ var BODIES = {
1620
+ "not-initialized": "The /v1 route is mounted but its runtime (or the console API key it proxies to) is not configured on this deployment yet. Real data appears here once it is \u2014 no placeholder data is shown.",
1621
+ unavailable: "This endpoint is not mounted at the gateway on this host yet. The view lights up automatically once the route is live.",
1622
+ // 501 — a real, planned capability whose body ships in a later phase.
1623
+ "not-implemented": "This capability is planned but not wired yet. The backend answers honestly rather than pretending it worked \u2014 nothing here is fabricated, and the view lights up automatically once it ships.",
1624
+ // 403 for a SIGNED-IN user — never "sign in".
1625
+ access: "You're signed in, but this isn't enabled for your organization on this deployment, or it's an admin-only surface. It appears here automatically once your account has access \u2014 nothing is fabricated.",
1626
+ // 401 — the session itself lapsed; re-auth returns to this exact page.
1627
+ signin: "Your session has expired or isn\u2019t recognized here. Sign in again to continue where you left off.",
1628
+ // Empty → the card shows the backend's own message (the honest "Insufficient
1629
+ // balance. Please add credits…" from the gateway billing gate).
1630
+ billing: "",
1631
+ error: ""
1632
+ };
1633
+ function BackendStateCard({
1634
+ state,
1635
+ onRetry,
1636
+ hint
1637
+ }) {
1638
+ const { signIn, addCredits } = useHost();
1639
+ return /* @__PURE__ */ jsxs(Card, { borderWidth: 1, borderColor: "$borderColor", p: "$4", gap: "$2", maxWidth: 640, children: [
1640
+ /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", children: [
1641
+ /* @__PURE__ */ jsx(TriangleAlert, { size: 16 }),
1642
+ /* @__PURE__ */ jsx(Text, { fontSize: "$4", fontWeight: "700", children: TITLES[state.kind] })
1643
+ ] }),
1644
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", children: BODIES[state.kind] || state.message }),
1645
+ hint ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", children: hint }) : null,
1646
+ state.kind === "signin" && signIn ? /* @__PURE__ */ jsx(Button, { size: "$2", theme: "light", self: "flex-start", onPress: signIn, children: "Sign in again" }) : state.kind === "billing" && addCredits ? (
1647
+ // 402 — the org has no funded balance. Offer a top-up CTA (and keep Retry so
1648
+ // a returning, funded caller can reload in place).
1649
+ /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", children: [
1650
+ /* @__PURE__ */ jsx(Button, { size: "$2", theme: "light", self: "flex-start", icon: /* @__PURE__ */ jsx(CreditCard, { size: 14 }), onPress: addCredits, children: "Add credits" }),
1651
+ onRetry ? /* @__PURE__ */ jsx(Button, { size: "$2", self: "flex-start", onPress: onRetry, children: "Retry" }) : null
1652
+ ] })
1653
+ ) : onRetry ? /* @__PURE__ */ jsx(Button, { size: "$2", self: "flex-start", onPress: onRetry, children: "Retry" }) : null
1654
+ ] });
1655
+ }
1656
+ function PageHeader({
1657
+ title,
1658
+ subtitle,
1659
+ actions
1660
+ }) {
1661
+ return (
1662
+ // flexWrap lets the actions drop below the title on narrow screens; flex={1}
1663
+ // minW={0} lets the title column shrink so a long subtitle WRAPS instead of
1664
+ // running off the viewport (a flex child defaults to min-width:auto = content
1665
+ // width, which would overflow on mobile).
1666
+ /* @__PURE__ */ jsxs(XStack, { justify: "space-between", items: "flex-start", gap: "$3", flexWrap: "wrap", children: [
1667
+ /* @__PURE__ */ jsxs(YStack, { gap: "$1", flex: 1, minW: 200, children: [
1668
+ /* @__PURE__ */ jsx(Text, { fontSize: "$7", fontWeight: "500", letterSpacing: -0.4, children: title }),
1669
+ subtitle ? /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", children: subtitle }) : null
1670
+ ] }),
1671
+ actions ? /* @__PURE__ */ jsx(XStack, { gap: "$2", items: "center", flexWrap: "wrap", width: "100%", $md: { width: "auto", justify: "flex-end" }, children: actions }) : null
1672
+ ] })
1673
+ );
1674
+ }
1675
+ function SkeletonRows({ columns, count = 6 }) {
1676
+ return /* @__PURE__ */ jsx(YStack, { children: Array.from({ length: count }).map((_, r) => /* @__PURE__ */ jsx(XStack, { py: "$2.5", px: "$3", gap: "$3", borderTopWidth: 1, borderColor: "$borderColor", items: "center", children: columns.map((c, i) => /* @__PURE__ */ jsx(YStack, { width: c.width, flex: c.width ? void 0 : 1, minW: c.width ? void 0 : FLEX_MIN_COL_W, items: c.align === "right" ? "flex-end" : "flex-start", children: /* @__PURE__ */ jsx(
1677
+ "div",
1678
+ {
1679
+ className: "hz-skeleton",
1680
+ style: { height: 12, borderRadius: 6, width: `${[62, 40, 54, 34, 48][(i + r) % 5]}%` },
1681
+ "aria-hidden": true
1682
+ }
1683
+ ) }, c.key)) }, r)) });
1684
+ }
1685
+ function DataTable({
1686
+ columns,
1687
+ rows,
1688
+ loading,
1689
+ empty = "Nothing here yet.",
1690
+ rowKey,
1691
+ onRowPress,
1692
+ isRowExpanded,
1693
+ renderExpanded,
1694
+ sort,
1695
+ onSortChange
1696
+ }) {
1697
+ const minTableW = columns.reduce((sum, c) => sum + (c.width ?? FLEX_MIN_COL_W), 0) + (columns.length + 1) * 12;
1698
+ return /* @__PURE__ */ jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", overflow: "hidden", children: [
1699
+ /* @__PURE__ */ jsx(YStack, { style: { overflowX: "auto", overflowY: "visible" }, children: /* @__PURE__ */ jsxs(YStack, { minW: minTableW, children: [
1700
+ /* @__PURE__ */ jsx(XStack, { bg: "$color1", py: "$2.5", px: "$3", gap: "$3", borderBottomWidth: 1, borderColor: "$borderColor", role: "row", children: columns.map((c) => {
1701
+ const sortable = c.sortable === true && !!onSortChange;
1702
+ const active = sortable && sort?.key === c.key;
1703
+ const Caret = !sortable ? null : !active ? ChevronsUpDown : sort?.dir === "asc" ? ChevronUp : ChevronDown;
1704
+ return /* @__PURE__ */ jsxs(
1705
+ XStack,
1706
+ {
1707
+ width: c.width,
1708
+ flex: c.width ? void 0 : 1,
1709
+ minW: c.width ? void 0 : FLEX_MIN_COL_W,
1710
+ items: "center",
1711
+ gap: "$1",
1712
+ justify: c.align === "right" ? "flex-end" : "flex-start",
1713
+ role: "columnheader",
1714
+ "aria-sort": sortable ? active ? sort?.dir === "asc" ? "ascending" : "descending" : "none" : void 0,
1715
+ "aria-label": sortable ? `Sort by ${c.header}` : void 0,
1716
+ cursor: sortable ? "pointer" : void 0,
1717
+ hoverStyle: sortable ? { opacity: 0.75 } : void 0,
1718
+ onPress: sortable ? () => onSortChange?.(c.key) : void 0,
1719
+ children: [
1720
+ /* @__PURE__ */ jsx(
1721
+ Text,
1722
+ {
1723
+ fontSize: "$1",
1724
+ fontWeight: "500",
1725
+ color: active ? "$color12" : "$color10",
1726
+ text: c.align === "right" ? "right" : "left",
1727
+ className: c.mono ? "hz-tnum" : void 0,
1728
+ children: c.header
1729
+ }
1730
+ ),
1731
+ Caret ? /* @__PURE__ */ jsx(Caret, { size: 12, color: active ? "$color12" : "$color9" }) : null
1732
+ ]
1733
+ },
1734
+ c.key
1735
+ );
1736
+ }) }),
1737
+ loading ? /* @__PURE__ */ jsx(SkeletonRows, { columns }) : rows.length > 0 ? /* @__PURE__ */ jsx(YStack, { children: rows.map((row) => {
1738
+ const expanded = (isRowExpanded?.(row) ?? false) && !!renderExpanded;
1739
+ return /* @__PURE__ */ jsxs(YStack, { children: [
1740
+ /* @__PURE__ */ jsx(
1741
+ XStack,
1742
+ {
1743
+ className: "hz-row",
1744
+ py: "$2.5",
1745
+ px: "$3",
1746
+ gap: "$3",
1747
+ borderTopWidth: 1,
1748
+ borderColor: "$borderColor",
1749
+ items: "center",
1750
+ bg: expanded ? "$color2" : void 0,
1751
+ hoverStyle: onRowPress ? { bg: "$color2" } : void 0,
1752
+ cursor: onRowPress ? "pointer" : void 0,
1753
+ onPress: onRowPress ? () => onRowPress(row) : void 0,
1754
+ children: columns.map((c) => {
1755
+ const cell = c.render ? c.render(row) : String(row[c.key] ?? "");
1756
+ return /* @__PURE__ */ jsx(
1757
+ YStack,
1758
+ {
1759
+ width: c.width,
1760
+ flex: c.width ? void 0 : 1,
1761
+ minW: c.width ? void 0 : FLEX_MIN_COL_W,
1762
+ justify: "center",
1763
+ items: c.align === "right" ? "flex-end" : "flex-start",
1764
+ children: typeof cell === "string" || typeof cell === "number" ? /* @__PURE__ */ jsx(
1765
+ Text,
1766
+ {
1767
+ fontSize: "$3",
1768
+ numberOfLines: 1,
1769
+ color: "$color12",
1770
+ text: c.align === "right" ? "right" : "left",
1771
+ className: c.mono ? "hz-mono" : void 0,
1772
+ children: cell
1773
+ }
1774
+ ) : cell
1775
+ },
1776
+ c.key
1777
+ );
1778
+ })
1779
+ }
1780
+ ),
1781
+ expanded && renderExpanded ? /* @__PURE__ */ jsx(YStack, { borderTopWidth: 1, borderColor: "$borderColor", bg: "$color1", children: renderExpanded(row) }) : null
1782
+ ] }, rowKey(row));
1783
+ }) }) : null
1784
+ ] }) }),
1785
+ !loading && rows.length === 0 ? /* @__PURE__ */ jsx(YStack, { py: "$8", px: "$4", items: "center", gap: "$1", borderTopWidth: 1, borderColor: "$borderColor", children: /* @__PURE__ */ jsx(Text, { color: "$color10", fontSize: "$3", text: "center", children: empty }) }) : null
1786
+ ] });
1787
+ }
1788
+ var FLEX_MIN_COL_W = 120;
1789
+ function CommerceResource({
1790
+ title,
1791
+ subtitle,
1792
+ load,
1793
+ columns,
1794
+ rowKey,
1795
+ empty,
1796
+ hint,
1797
+ actions
1798
+ }) {
1799
+ const [state, setState] = useState({ phase: "loading" });
1800
+ const loadRef = useRef(load);
1801
+ loadRef.current = load;
1802
+ const reload = useCallback(() => {
1803
+ setState({ phase: "loading" });
1804
+ loadRef.current().then((r) => setState({ phase: "ready", data: r.rows })).catch((e) => setState({ phase: "error", error: classifyBackend(e) }));
1805
+ }, []);
1806
+ useEffect(() => {
1807
+ reload();
1808
+ }, [reload]);
1809
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1810
+ /* @__PURE__ */ jsx(
1811
+ PageHeader,
1812
+ {
1813
+ title,
1814
+ subtitle,
1815
+ actions: /* @__PURE__ */ jsxs(XStack, { gap: "$2", children: [
1816
+ actions?.(reload),
1817
+ /* @__PURE__ */ jsx(Button, { size: "$2", icon: /* @__PURE__ */ jsx(RefreshCw, { size: 15 }), onPress: reload, children: "Refresh" })
1818
+ ] })
1819
+ }
1820
+ ),
1821
+ state.phase === "error" ? /* @__PURE__ */ jsx(BackendStateCard, { state: state.error, onRetry: reload, hint }) : /* @__PURE__ */ jsx(
1822
+ DataTable,
1823
+ {
1824
+ columns,
1825
+ rows: state.phase === "ready" ? state.data : [],
1826
+ loading: state.phase === "loading",
1827
+ rowKey,
1828
+ empty
1829
+ }
1830
+ )
1831
+ ] });
1832
+ }
1833
+ function ConfirmDelete({
1834
+ message,
1835
+ confirmLabel,
1836
+ run,
1837
+ onDone
1838
+ }) {
1839
+ const [busy, setBusy] = useState(false);
1840
+ const [err, setErr] = useState(null);
1841
+ const go = async () => {
1842
+ setBusy(true);
1843
+ setErr(null);
1844
+ try {
1845
+ await run();
1846
+ onDone();
1847
+ } catch (e) {
1848
+ setErr(classifyBackend(e).message || "Failed to delete.");
1849
+ setBusy(false);
1850
+ }
1851
+ };
1852
+ return /* @__PURE__ */ jsxs(YStack, { gap: "$3", children: [
1853
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", children: message }),
1854
+ err ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$red10", children: err }) : null,
1855
+ /* @__PURE__ */ jsxs(XStack, { gap: "$2", flexWrap: "wrap", children: [
1856
+ /* @__PURE__ */ jsx(
1857
+ Button,
1858
+ {
1859
+ onPress: go,
1860
+ disabled: busy,
1861
+ icon: /* @__PURE__ */ jsx(Trash2, { size: 15 }),
1862
+ style: { backgroundColor: "#dc2626", borderColor: "#dc2626", color: "#fff" },
1863
+ children: busy ? "Deleting\u2026" : confirmLabel
1864
+ }
1865
+ ),
1866
+ /* @__PURE__ */ jsx(Button, { chromeless: true, onPress: () => onDone(), disabled: busy, children: "Cancel" })
1867
+ ] })
1868
+ ] });
1869
+ }
1870
+ function Segmented({
1871
+ options,
1872
+ value,
1873
+ onChange,
1874
+ size = "$2"
1875
+ }) {
1876
+ return /* @__PURE__ */ jsx(XStack, { gap: "$1", flexWrap: "wrap", items: "center", children: options.map((o) => {
1877
+ const active = o.value === value;
1878
+ return /* @__PURE__ */ jsx(
1879
+ Button,
1880
+ {
1881
+ size,
1882
+ bg: active ? "$color5" : "transparent",
1883
+ borderWidth: 1,
1884
+ borderColor: active ? "$color7" : "$borderColor",
1885
+ "aria-pressed": active,
1886
+ onPress: () => onChange(o.value),
1887
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$2", fontWeight: active ? "700" : "500", color: active ? "$color12" : "$color11", children: o.label })
1888
+ },
1889
+ o.value
1890
+ );
1891
+ }) });
1892
+ }
1893
+ function SearchInput({ value, onChange, placeholder }) {
1894
+ return /* @__PURE__ */ jsxs(XStack, { flex: 1, minW: 180, items: "center", gap: "$2", px: "$3", borderWidth: 1, borderColor: "$borderColor", rounded: "$4", bg: "$color1", children: [
1895
+ /* @__PURE__ */ jsx(Search, { size: 15, color: "$color10" }),
1896
+ /* @__PURE__ */ jsx(Input, { flex: 1, value, onChangeText: onChange, placeholder, borderWidth: 0, bg: "transparent", px: "$0", fontSize: "$3" })
1897
+ ] });
1898
+ }
1899
+
1900
+ // src/product/brand.ts
1901
+ var HANZO_MARK_CONTENT = '<path d="M22.21 67V44.6369H0V67H22.21Z"/><path d="M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z"/><path d="M22.21 0H0V22.3184H22.21V0Z"/><path d="M66.7198 0H44.5098V22.3184H66.7198V0Z"/><path d="M66.7198 67V44.6369H44.5098V67H66.7198Z"/>';
1902
+ var HANZO = {
1903
+ id: "hanzo",
1904
+ name: "Hanzo",
1905
+ viewBox: "0 0 67 67",
1906
+ content: HANZO_MARK_CONTENT,
1907
+ href: "https://hanzo.ai"
1908
+ };
1909
+ var LUX = {
1910
+ id: "lux",
1911
+ name: "Lux",
1912
+ viewBox: "0 0 100 100",
1913
+ content: '<path d="M50 85 L15 25 L85 25 Z"/>',
1914
+ href: "https://lux.network"
1915
+ };
1916
+ var ZOO = {
1917
+ id: "zoo",
1918
+ name: "Zoo",
1919
+ viewBox: "0 0 1024 1024",
1920
+ fullColor: true,
1921
+ content: '<defs><clipPath id="zooClip"><circle cx="512" cy="511" r="270"/></clipPath><clipPath id="zooGClip"><circle cx="513" cy="369" r="234"/></clipPath><clipPath id="zooRClip"><circle cx="365" cy="595" r="234"/></clipPath></defs><g clip-path="url(#zooClip)"><circle cx="513" cy="369" r="234" fill="#00A652"/><circle cx="365" cy="595" r="234" fill="#ED1C24"/><circle cx="643" cy="595" r="234" fill="#2E3192"/><g clip-path="url(#zooGClip)"><circle cx="365" cy="595" r="234" fill="#FCF006"/><circle cx="643" cy="595" r="234" fill="#01ACF1"/></g><g clip-path="url(#zooRClip)"><circle cx="643" cy="595" r="234" fill="#EA018E"/></g><g clip-path="url(#zooGClip)"><g clip-path="url(#zooRClip)"><circle cx="643" cy="595" r="234" fill="#FFFFFF"/></g></g></g>',
1922
+ href: "https://zoo.ngo"
1923
+ };
1924
+ var PARS = {
1925
+ id: "pars",
1926
+ name: "Pars",
1927
+ viewBox: "-120 -120 240 240",
1928
+ content: '<path d="M0,-100 L30,-60 L100,-40 L60,0 L100,40 L30,60 L0,100 L-30,60 L-100,40 L-60,0 L-100,-40 L-30,-60 Z" fill="none" stroke="currentColor" stroke-width="4" stroke-linejoin="round"/><path d="M0,-70 L22,-42 L70,-28 L42,0 L70,28 L22,42 L0,70 L-22,42 L-70,28 L-42,0 L-70,-28 L-22,-42 Z" fill="currentColor" fill-opacity="0.15" stroke="currentColor" stroke-width="3" stroke-linejoin="round"/><circle r="55" fill="none" stroke="currentColor" stroke-width="1.5" opacity="0.4"/><circle r="35" fill="none" stroke="currentColor" stroke-width="1.5" opacity="0.4"/><circle r="8" fill="currentColor"/>',
1929
+ href: "https://pars.network"
1930
+ };
1931
+ var BRANDS = { hanzo: HANZO, lux: LUX, zoo: ZOO, pars: PARS };
1932
+ function resolveBrand(id) {
1933
+ return id && BRANDS[id] || HANZO;
1934
+ }
1935
+
1936
+ // src/product/animatedLogo.logic.ts
1937
+ var HOUSE_EASE = "cubic-bezier(0.16, 1, 0.3, 1)";
1938
+ var DEFAULT_DURATION_MS = 360;
1939
+ var DEFAULT_INTRO_MS = 1500;
1940
+ var DEFAULT_GAP = 8;
1941
+ function wordmarkText(name, surface) {
1942
+ const s = surface?.trim();
1943
+ return s ? `${name} ${s}` : name;
1944
+ }
1945
+ function isExpanded(s) {
1946
+ return s.hovered || s.focused || s.introShowing;
1947
+ }
1948
+ function wordmarkStyle(i) {
1949
+ return {
1950
+ width: i.expanded ? i.naturalWidth ?? "auto" : 0,
1951
+ opacity: i.expanded ? 1 : 0,
1952
+ marginLeft: i.expanded ? i.gap : 0,
1953
+ transition: i.reduce ? "none" : `width ${i.durationMs}ms ${i.easing}, opacity ${i.durationMs}ms ${i.easing}, margin-left ${i.durationMs}ms ${i.easing}`
1954
+ };
1955
+ }
1956
+ function usePrefersReducedMotion() {
1957
+ const [reduce, setReduce] = useState(false);
1958
+ useEffect(() => {
1959
+ if (typeof window === "undefined" || !window.matchMedia) return;
1960
+ const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
1961
+ const sync = () => setReduce(mq.matches);
1962
+ sync();
1963
+ mq.addEventListener("change", sync);
1964
+ return () => mq.removeEventListener("change", sync);
1965
+ }, []);
1966
+ return reduce;
1967
+ }
1968
+ function AnimatedLogo({
1969
+ surface,
1970
+ brand = HANZO,
1971
+ size = 22,
1972
+ gap = DEFAULT_GAP,
1973
+ introMs = DEFAULT_INTRO_MS,
1974
+ durationMs = DEFAULT_DURATION_MS,
1975
+ easing = HOUSE_EASE,
1976
+ href,
1977
+ onClick,
1978
+ component,
1979
+ className,
1980
+ style,
1981
+ "aria-label": ariaLabel
1982
+ }) {
1983
+ const reduce = usePrefersReducedMotion();
1984
+ const label = ariaLabel ?? wordmarkText(brand.name, surface);
1985
+ const [hovered, setHovered] = useState(false);
1986
+ const [focused, setFocused] = useState(false);
1987
+ const [introShowing, setIntroShowing] = useState(introMs > 0);
1988
+ const [naturalWidth, setNaturalWidth] = useState(void 0);
1989
+ const wordRef = useRef(null);
1990
+ useEffect(() => {
1991
+ if (introMs <= 0) return;
1992
+ if (reduce) {
1993
+ setIntroShowing(false);
1994
+ return;
1995
+ }
1996
+ const t = setTimeout(() => setIntroShowing(false), introMs);
1997
+ return () => clearTimeout(t);
1998
+ }, [introMs, reduce]);
1999
+ useLayoutEffect(() => {
2000
+ const el = wordRef.current;
2001
+ if (!el) return;
2002
+ const measure = () => setNaturalWidth(el.scrollWidth);
2003
+ measure();
2004
+ const fonts = typeof document !== "undefined" && document.fonts || null;
2005
+ if (fonts?.ready) fonts.ready.then(measure).catch(() => {
2006
+ });
2007
+ }, [brand.name, surface]);
2008
+ const expanded = isExpanded({ hovered, focused, introShowing });
2009
+ const ws = wordmarkStyle({ expanded, naturalWidth, gap, durationMs, easing, reduce });
2010
+ const Root = component ?? "a";
2011
+ const isAnchor = Root === "a";
2012
+ return /* @__PURE__ */ jsxs(
2013
+ Root,
2014
+ {
2015
+ ...isAnchor ? { href: href ?? brand.href ?? "/" } : { href: href ?? brand.href },
2016
+ onClick,
2017
+ "aria-label": label,
2018
+ title: label,
2019
+ className,
2020
+ onMouseEnter: () => setHovered(true),
2021
+ onMouseLeave: () => setHovered(false),
2022
+ onFocus: () => setFocused(true),
2023
+ onBlur: () => setFocused(false),
2024
+ style: {
2025
+ display: "inline-flex",
2026
+ alignItems: "center",
2027
+ textDecoration: "none",
2028
+ color: "inherit",
2029
+ cursor: "pointer",
2030
+ ...style
2031
+ },
2032
+ children: [
2033
+ /* @__PURE__ */ jsx(
2034
+ "svg",
2035
+ {
2036
+ width: size,
2037
+ height: size,
2038
+ viewBox: brand.viewBox,
2039
+ "aria-hidden": "true",
2040
+ focusable: "false",
2041
+ fill: brand.fullColor ? void 0 : "currentColor",
2042
+ style: { display: "block", flexShrink: 0 },
2043
+ dangerouslySetInnerHTML: { __html: brand.content }
2044
+ }
2045
+ ),
2046
+ /* @__PURE__ */ jsx(
2047
+ "span",
2048
+ {
2049
+ ref: wordRef,
2050
+ "aria-hidden": "true",
2051
+ style: {
2052
+ display: "inline-block",
2053
+ overflow: "hidden",
2054
+ whiteSpace: "nowrap",
2055
+ fontWeight: 600,
2056
+ fontSize: 15,
2057
+ letterSpacing: "-0.01em",
2058
+ lineHeight: 1,
2059
+ width: ws.width,
2060
+ opacity: ws.opacity,
2061
+ marginLeft: ws.marginLeft,
2062
+ transition: ws.transition
2063
+ },
2064
+ children: label
2065
+ }
2066
+ )
2067
+ ]
2068
+ }
2069
+ );
2070
+ }
2071
+ function isHexColor(v) {
2072
+ return typeof v === "string" && /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(v.trim());
2073
+ }
2074
+ function resolveAccent(theme) {
2075
+ if (!theme || !theme.isEnabled) return null;
2076
+ const hex = (theme.colorPrimary ?? "").trim();
2077
+ return isHexColor(hex) ? hex : null;
2078
+ }
2079
+ function expandHex(hex) {
2080
+ const h = hex.trim().toLowerCase();
2081
+ if (h.length === 4) return `#${h[1]}${h[1]}${h[2]}${h[2]}${h[3]}${h[3]}`;
2082
+ return h;
2083
+ }
2084
+ function contrastText(hex) {
2085
+ if (!isHexColor(hex)) return "#ffffff";
2086
+ const h = expandHex(hex);
2087
+ const r = parseInt(h.slice(1, 3), 16) / 255;
2088
+ const g = parseInt(h.slice(3, 5), 16) / 255;
2089
+ const b = parseInt(h.slice(5, 7), 16) / 255;
2090
+ const lin = (c) => c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
2091
+ const luminance = 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b);
2092
+ return luminance > 0.5 ? "#000000" : "#ffffff";
2093
+ }
2094
+ function accentFor(theme) {
2095
+ const hex = resolveAccent(theme);
2096
+ return { accent: hex, contrast: hex ? contrastText(hex) : "#ffffff" };
2097
+ }
2098
+ var DEFAULT = { accent: null, contrast: "#ffffff" };
2099
+ var current = DEFAULT;
2100
+ var listeners = /* @__PURE__ */ new Set();
2101
+ function setOrgAccent(theme) {
2102
+ const next = accentFor(theme);
2103
+ if (next.accent === current.accent) return;
2104
+ current = next.accent ? next : DEFAULT;
2105
+ for (const l of listeners) l();
2106
+ }
2107
+ function subscribe(cb) {
2108
+ listeners.add(cb);
2109
+ return () => {
2110
+ listeners.delete(cb);
2111
+ };
2112
+ }
2113
+ function useAccent() {
2114
+ return useSyncExternalStore(
2115
+ subscribe,
2116
+ () => current,
2117
+ () => DEFAULT
2118
+ );
2119
+ }
2120
+ function PrimaryButton(props) {
2121
+ const { accent, contrast } = useAccent();
2122
+ if (accent) {
2123
+ return /* @__PURE__ */ jsx(Button, { style: { backgroundColor: accent, color: contrast, borderColor: accent }, ...props });
2124
+ }
2125
+ return /* @__PURE__ */ jsx(Button, { theme: "light", ...props });
2126
+ }
2127
+ function openHref2(href) {
2128
+ if (typeof window !== "undefined") window.open(href, "_blank", "noopener");
2129
+ }
2130
+ function EmptyState({
2131
+ icon: Icon,
2132
+ title,
2133
+ description,
2134
+ bullets,
2135
+ primary,
2136
+ secondary
2137
+ }) {
2138
+ return /* @__PURE__ */ jsxs(
2139
+ Card,
2140
+ {
2141
+ borderWidth: 1,
2142
+ borderColor: "$borderColor",
2143
+ borderStyle: "dashed",
2144
+ p: "$6",
2145
+ gap: "$4",
2146
+ items: "center",
2147
+ maxWidth: 640,
2148
+ self: "center",
2149
+ width: "100%",
2150
+ children: [
2151
+ /* @__PURE__ */ jsx(
2152
+ YStack,
2153
+ {
2154
+ width: 48,
2155
+ height: 48,
2156
+ items: "center",
2157
+ justify: "center",
2158
+ rounded: "$4",
2159
+ bg: "$color3",
2160
+ children: /* @__PURE__ */ jsx(Icon, { size: 24 })
2161
+ }
2162
+ ),
2163
+ /* @__PURE__ */ jsxs(YStack, { gap: "$2", items: "center", maxW: 480, children: [
2164
+ /* @__PURE__ */ jsx(Text, { fontSize: "$6", fontWeight: "500", text: "center", letterSpacing: -0.3, children: title }),
2165
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", text: "center", children: description })
2166
+ ] }),
2167
+ 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: [
2168
+ /* @__PURE__ */ jsx(YStack, { pt: "$1", children: /* @__PURE__ */ jsx(Check, { size: 14, color: "$color10" }) }),
2169
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", flex: 1, children: b })
2170
+ ] }, b)) }) : null,
2171
+ primary || secondary ? /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", justify: "center", children: [
2172
+ primary ? /* @__PURE__ */ jsx(
2173
+ PrimaryButton,
2174
+ {
2175
+ icon: primary.icon,
2176
+ iconAfter: primary.href ? /* @__PURE__ */ jsx(ExternalLink, { size: 15 }) : /* @__PURE__ */ jsx(ArrowRight, { size: 15 }),
2177
+ onPress: () => primary.href ? openHref2(primary.href) : primary.onPress?.(),
2178
+ children: primary.label
2179
+ }
2180
+ ) : null,
2181
+ secondary ? /* @__PURE__ */ jsx(
2182
+ Button,
2183
+ {
2184
+ chromeless: true,
2185
+ icon: secondary.icon,
2186
+ iconAfter: secondary.href ? /* @__PURE__ */ jsx(ExternalLink, { size: 14 }) : void 0,
2187
+ onPress: () => secondary.href ? openHref2(secondary.href) : secondary.onPress?.(),
2188
+ children: secondary.label
2189
+ }
2190
+ ) : null
2191
+ ] }) : null
2192
+ ]
2193
+ }
2194
+ );
2195
+ }
2196
+ function FadeIn({
2197
+ children,
2198
+ index = 0,
2199
+ step = 50,
2200
+ delayMs,
2201
+ style
2202
+ }) {
2203
+ const delay = delayMs ?? index * step;
2204
+ return /* @__PURE__ */ jsx("div", { className: "hz-fade-up", style: { animationDelay: `${delay}ms`, ...style }, children });
2205
+ }
2206
+ function FieldRow({ label, children }) {
2207
+ return /* @__PURE__ */ jsxs(XStack, { gap: "$3", items: "flex-start", flexWrap: "wrap", children: [
2208
+ /* @__PURE__ */ jsx(Label, { width: "100%", pt: "$2", color: "$color11", fontSize: "$3", $md: { width: 180 }, children: label }),
2209
+ /* @__PURE__ */ jsx(YStack, { flex: 1, minW: 0, $md: { minW: 240 }, children })
2210
+ ] });
2211
+ }
2212
+ function FieldText({
2213
+ value,
2214
+ onChange,
2215
+ disabled,
2216
+ secure,
2217
+ placeholder
2218
+ }) {
2219
+ return /* @__PURE__ */ jsx(
2220
+ Input,
2221
+ {
2222
+ value,
2223
+ onChangeText: onChange,
2224
+ disabled,
2225
+ secureTextEntry: secure,
2226
+ placeholder,
2227
+ autoCapitalize: "none"
2228
+ }
2229
+ );
2230
+ }
2231
+ function FieldTextArea({
2232
+ value,
2233
+ onChange,
2234
+ disabled,
2235
+ rows = 6
2236
+ }) {
2237
+ return /* @__PURE__ */ jsx(TextArea, { value, onChangeText: onChange, disabled, numberOfLines: rows });
2238
+ }
2239
+ function FieldSwitch({
2240
+ checked,
2241
+ onChange,
2242
+ disabled
2243
+ }) {
2244
+ return /* @__PURE__ */ jsx(Switch, { checked, onCheckedChange: onChange, disabled, size: "$3", children: /* @__PURE__ */ jsx(Switch.Thumb, {}) });
2245
+ }
2246
+ var CHEVRON = `data:image/svg+xml,${encodeURIComponent(
2247
+ '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#9a9a9a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>'
2248
+ )}`;
2249
+ function selectStyle(disabled) {
2250
+ return {
2251
+ width: "100%",
2252
+ boxSizing: "border-box",
2253
+ appearance: "none",
2254
+ WebkitAppearance: "none",
2255
+ MozAppearance: "none",
2256
+ background: `var(--background) url("${CHEVRON}") no-repeat right 10px center`,
2257
+ color: "var(--color12)",
2258
+ border: "1px solid var(--borderColor)",
2259
+ borderRadius: 9,
2260
+ padding: "9px 34px 9px 12px",
2261
+ fontSize: 14,
2262
+ lineHeight: "20px",
2263
+ fontFamily: "inherit",
2264
+ height: 40,
2265
+ outline: "none",
2266
+ cursor: disabled ? "not-allowed" : "pointer",
2267
+ opacity: disabled ? 0.5 : 1
2268
+ };
2269
+ }
2270
+ var OPTION_STYLE = { background: "var(--color2)", color: "var(--color12)" };
2271
+ function FieldSelect({
2272
+ value,
2273
+ options,
2274
+ onChange,
2275
+ disabled,
2276
+ placeholder = "Select\u2026"
2277
+ }) {
2278
+ const showPlaceholder = value === "" || !options.includes(value);
2279
+ return /* @__PURE__ */ jsxs(
2280
+ "select",
2281
+ {
2282
+ value: showPlaceholder ? "" : value,
2283
+ onChange: (e) => onChange(e.currentTarget.value),
2284
+ disabled,
2285
+ "aria-label": placeholder,
2286
+ style: selectStyle(disabled),
2287
+ children: [
2288
+ showPlaceholder ? /* @__PURE__ */ jsx("option", { value: "", disabled: true, style: OPTION_STYLE, children: placeholder }) : null,
2289
+ options.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, style: OPTION_STYLE, children: opt }, opt))
2290
+ ]
2291
+ }
2292
+ );
2293
+ }
2294
+ function FieldSlider({
2295
+ value,
2296
+ min,
2297
+ max,
2298
+ step,
2299
+ onChange,
2300
+ disabled
2301
+ }) {
2302
+ return /* @__PURE__ */ jsxs(XStack, { gap: "$3", items: "center", children: [
2303
+ /* @__PURE__ */ jsx(Text, { width: 56, fontSize: "$3", color: "$color11", children: value }),
2304
+ /* @__PURE__ */ jsxs(
2305
+ Slider,
2306
+ {
2307
+ flex: 1,
2308
+ min,
2309
+ max,
2310
+ step,
2311
+ value: [value],
2312
+ onValueChange: (v) => onChange(v[0] ?? min),
2313
+ disabled,
2314
+ children: [
2315
+ /* @__PURE__ */ jsx(Slider.Track, { children: /* @__PURE__ */ jsx(Slider.TrackActive, {}) }),
2316
+ /* @__PURE__ */ jsx(Slider.Thumb, { index: 0, circular: true })
2317
+ ]
2318
+ }
2319
+ )
2320
+ ] });
2321
+ }
2322
+
2323
+ // src/product/color.ts
2324
+ var asColor = (hex) => hex;
2325
+ function ProductIcon({
2326
+ icon: Icon,
2327
+ color,
2328
+ size = 24
2329
+ }) {
2330
+ const radius = Math.round(size * 0.28);
2331
+ const glyph = Math.round(size * 0.58);
2332
+ const tinted = typeof color === "string" && color.trim() !== "";
2333
+ if (tinted) {
2334
+ return /* @__PURE__ */ jsx(
2335
+ XStack,
2336
+ {
2337
+ width: size,
2338
+ height: size,
2339
+ items: "center",
2340
+ justify: "center",
2341
+ rounded: radius,
2342
+ style: { backgroundColor: color },
2343
+ children: /* @__PURE__ */ jsx(Icon, { size: glyph, color: asColor("#ffffff") })
2344
+ }
2345
+ );
2346
+ }
2347
+ return /* @__PURE__ */ jsx(XStack, { width: size, height: size, items: "center", justify: "center", rounded: radius, bg: "$color12", children: /* @__PURE__ */ jsx(Icon, { size: glyph, color: "$color1" }) });
2348
+ }
2349
+ var KNOWN = {
2350
+ openrouter: Globe,
2351
+ nvidia: Cpu
2352
+ };
2353
+ var isFirstParty = (provider) => {
2354
+ const p = provider.trim().toLowerCase();
2355
+ return p === "hanzo" || p === "zen";
2356
+ };
2357
+ function EnsoMark({ size, color }) {
2358
+ 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" }) });
2359
+ }
2360
+ var HANZO_PATHS = [
2361
+ "M22.21 67V44.6369H0V67H22.21Z",
2362
+ "M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z",
2363
+ "M22.21 0H0V22.3184H22.21V0Z",
2364
+ "M66.7198 0H44.5098V22.3184H66.7198V0Z",
2365
+ "M66.7198 67V44.6369H44.5098V67H66.7198Z"
2366
+ ];
2367
+ function HanzoHMark({ size, color }) {
2368
+ 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)) });
2369
+ }
2370
+ function providerInitials(provider) {
2371
+ const name = provider.trim();
2372
+ if (!name) return "\u2022";
2373
+ const words = name.split(/[\s/_-]+/).filter(Boolean);
2374
+ if (words.length >= 2) return (words[0][0] + words[1][0]).toUpperCase();
2375
+ return name.slice(0, 2).toUpperCase();
2376
+ }
2377
+ function ProviderLogo({ provider, size = 24 }) {
2378
+ const theme = useTheme();
2379
+ const radius = Math.round(size * 0.28);
2380
+ const iconSize = Math.round(size * 0.56);
2381
+ if (isFirstParty(provider)) {
2382
+ const fg = theme.color1?.get() ?? "#000000";
2383
+ const markSize = Math.round(size * 0.66);
2384
+ const isZen = provider.trim().toLowerCase() === "zen";
2385
+ 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 }) });
2386
+ }
2387
+ const Known = KNOWN[provider.trim().toLowerCase()];
2388
+ if (Known) {
2389
+ return /* @__PURE__ */ jsx(
2390
+ XStack,
2391
+ {
2392
+ width: size,
2393
+ height: size,
2394
+ items: "center",
2395
+ justify: "center",
2396
+ rounded: radius,
2397
+ bg: "$color3",
2398
+ borderWidth: 1,
2399
+ borderColor: "$borderColor",
2400
+ children: /* @__PURE__ */ jsx(Known, { size: iconSize, color: "$color11" })
2401
+ }
2402
+ );
2403
+ }
2404
+ return /* @__PURE__ */ jsx(
2405
+ XStack,
2406
+ {
2407
+ width: size,
2408
+ height: size,
2409
+ items: "center",
2410
+ justify: "center",
2411
+ rounded: radius,
2412
+ bg: "$color3",
2413
+ borderWidth: 1,
2414
+ borderColor: "$borderColor",
2415
+ children: /* @__PURE__ */ jsx(Text, { fontSize: Math.round(size * 0.4), fontWeight: "800", color: "$color11", children: providerInitials(provider) })
2416
+ }
2417
+ );
2418
+ }
2419
+ function GenericLogo({ size = 24 }) {
2420
+ 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" }) });
2421
+ }
2422
+ function targetIndex(from, dy, rowH, count) {
2423
+ if (rowH <= 0 || count <= 0) return from;
2424
+ const raw = from + Math.round(dy / rowH);
2425
+ return Math.max(0, Math.min(raw, count - 1));
2426
+ }
2427
+ function rowShift(i, from, to, dy, rowH) {
2428
+ if (i === from) return dy;
2429
+ if (from < to && i > from && i <= to) return -rowH;
2430
+ if (from > to && i < from && i >= to) return rowH;
2431
+ return 0;
2432
+ }
2433
+ function Reorder({
2434
+ items,
2435
+ keyOf,
2436
+ rowHeight = 44,
2437
+ onReorder,
2438
+ renderItem
2439
+ }) {
2440
+ const [drag, setDrag] = useState(null);
2441
+ const startRef = useRef(null);
2442
+ const to = drag ? targetIndex(drag.from, drag.dy, rowHeight, items.length) : -1;
2443
+ const begin = useCallback(
2444
+ (index) => (e) => {
2445
+ const startY = e.clientY ?? e.nativeEvent?.clientY ?? 0;
2446
+ startRef.current = { from: index, startY };
2447
+ setDrag({ from: index, dy: 0 });
2448
+ const move = (ev) => {
2449
+ if (!startRef.current) return;
2450
+ setDrag({ from: startRef.current.from, dy: ev.clientY - startRef.current.startY });
2451
+ };
2452
+ const end = () => {
2453
+ const s = startRef.current;
2454
+ window.removeEventListener("pointermove", move);
2455
+ window.removeEventListener("pointerup", end);
2456
+ window.removeEventListener("pointercancel", end);
2457
+ startRef.current = null;
2458
+ setDrag((d) => {
2459
+ if (s && d) {
2460
+ const t = targetIndex(s.from, d.dy, rowHeight, items.length);
2461
+ if (t !== s.from) onReorder(s.from, t);
2462
+ }
2463
+ return null;
2464
+ });
2465
+ };
2466
+ window.addEventListener("pointermove", move);
2467
+ window.addEventListener("pointerup", end);
2468
+ window.addEventListener("pointercancel", end);
2469
+ },
2470
+ [items.length, rowHeight, onReorder]
2471
+ );
2472
+ return /* @__PURE__ */ jsx(YStack, { children: items.map((item, i) => {
2473
+ const dragging = drag?.from === i;
2474
+ const shift = drag && to >= 0 ? rowShift(i, drag.from, to, drag.dy, rowHeight) : 0;
2475
+ return /* @__PURE__ */ jsx(
2476
+ YStack,
2477
+ {
2478
+ height: rowHeight,
2479
+ justify: "center",
2480
+ className: "hz-drag-item",
2481
+ style: {
2482
+ transform: `translateY(${shift}px)`,
2483
+ zIndex: dragging ? 2 : 1,
2484
+ ...dragging ? { transition: "none", boxShadow: "0 8px 24px rgba(0,0,0,0.28)" } : null
2485
+ },
2486
+ children: renderItem(item, { onPointerDown: begin(i) }, dragging)
2487
+ },
2488
+ keyOf(item)
2489
+ );
2490
+ }) });
2491
+ }
2492
+ function SelectMenu({
2493
+ options,
2494
+ value,
2495
+ onChange,
2496
+ allLabel = "All",
2497
+ icon,
2498
+ minWidth = 130
2499
+ }) {
2500
+ const active = value === null ? null : options.find((o) => o.key === value) ?? null;
2501
+ const triggerLabel = active ? active.label : allLabel;
2502
+ const items = [
2503
+ { key: "__all__", label: allLabel, selected: value === null, onSelect: () => onChange(null) },
2504
+ ...options.map((o) => ({ key: o.key, label: o.label, selected: value === o.key, onSelect: () => onChange(o.key) }))
2505
+ ];
2506
+ return /* @__PURE__ */ jsx(
2507
+ DropdownMenu,
2508
+ {
2509
+ minWidth: Math.max(minWidth, 160),
2510
+ trigger: /* @__PURE__ */ jsx(
2511
+ Button,
2512
+ {
2513
+ size: "$2",
2514
+ minW: minWidth,
2515
+ justify: "space-between",
2516
+ borderWidth: 1,
2517
+ borderColor: "$borderColor",
2518
+ bg: value !== null ? "$color5" : "transparent",
2519
+ icon,
2520
+ iconAfter: /* @__PURE__ */ jsx(ChevronDown, { size: 14, opacity: 0.6 }),
2521
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color12", numberOfLines: 1, flex: 1, children: triggerLabel })
2522
+ }
2523
+ ),
2524
+ items
2525
+ }
2526
+ );
2527
+ }
2528
+ var LG = 1024;
2529
+ var lockCount = 0;
2530
+ var savedOverflow = "";
2531
+ function lockScroll() {
2532
+ if (typeof document === "undefined") return;
2533
+ if (lockCount === 0) {
2534
+ savedOverflow = document.body.style.overflow;
2535
+ document.body.style.overflow = "hidden";
2536
+ }
2537
+ lockCount++;
2538
+ }
2539
+ function unlockScroll() {
2540
+ if (typeof document === "undefined") return;
2541
+ lockCount = Math.max(0, lockCount - 1);
2542
+ if (lockCount === 0) document.body.style.overflow = savedOverflow;
2543
+ }
2544
+ function SlideOver({
2545
+ open,
2546
+ onClose,
2547
+ side = "right",
2548
+ size = 420,
2549
+ title,
2550
+ icon: Icon,
2551
+ iconColor,
2552
+ headerRight,
2553
+ ariaLabel,
2554
+ zIndex = 1e3,
2555
+ children
2556
+ }) {
2557
+ const panelRef = useRef(null);
2558
+ const openerRef = useRef(null);
2559
+ useEffect(() => {
2560
+ if (!open) return;
2561
+ openerRef.current = typeof document !== "undefined" ? document.activeElement : null;
2562
+ lockScroll();
2563
+ const t = window.setTimeout(() => {
2564
+ const el = panelRef.current;
2565
+ if (el && typeof el.focus === "function") el.focus();
2566
+ }, 0);
2567
+ return () => {
2568
+ window.clearTimeout(t);
2569
+ unlockScroll();
2570
+ const opener = openerRef.current;
2571
+ if (opener && opener instanceof HTMLElement && typeof opener.focus === "function") opener.focus();
2572
+ };
2573
+ }, [open]);
2574
+ useEffect(() => {
2575
+ if (!open) return;
2576
+ const onKey = (e) => {
2577
+ if (e.key === "Escape") {
2578
+ e.stopPropagation();
2579
+ onClose();
2580
+ }
2581
+ };
2582
+ window.addEventListener("keydown", onKey);
2583
+ return () => window.removeEventListener("keydown", onKey);
2584
+ }, [open, onClose]);
2585
+ const offscreen = side === "right" ? "translateX(100%)" : "translateX(-100%)";
2586
+ const edge = side === "right" ? { r: 0 } : { l: 0 };
2587
+ return /* @__PURE__ */ jsxs(
2588
+ YStack,
2589
+ {
2590
+ overflow: "hidden",
2591
+ pointerEvents: open ? "auto" : "none",
2592
+ "aria-hidden": !open,
2593
+ style: { position: "fixed", inset: 0, zIndex },
2594
+ children: [
2595
+ /* @__PURE__ */ jsx(
2596
+ YStack,
2597
+ {
2598
+ position: "absolute",
2599
+ t: 0,
2600
+ l: 0,
2601
+ r: 0,
2602
+ b: 0,
2603
+ bg: "rgba(0,0,0,0.55)",
2604
+ className: "hz-fade",
2605
+ style: { opacity: open ? 1 : 0 },
2606
+ onPress: onClose
2607
+ }
2608
+ ),
2609
+ /* @__PURE__ */ jsx(
2610
+ YStack,
2611
+ {
2612
+ ref: panelRef,
2613
+ tabIndex: -1,
2614
+ role: "dialog",
2615
+ "aria-modal": open ? true : void 0,
2616
+ "aria-label": typeof title === "string" ? title : ariaLabel,
2617
+ position: "absolute",
2618
+ t: 0,
2619
+ b: 0,
2620
+ ...edge,
2621
+ width: "100%",
2622
+ $lg: { width: size, maxW: "100vw" },
2623
+ bg: "$color1",
2624
+ borderLeftWidth: side === "right" ? 1 : 0,
2625
+ borderRightWidth: side === "left" ? 1 : 0,
2626
+ borderColor: "$borderColor",
2627
+ className: "hz-slide hz-elevation-4",
2628
+ style: {
2629
+ transform: open ? "translateX(0)" : offscreen,
2630
+ height: "100dvh",
2631
+ paddingTop: "env(safe-area-inset-top)",
2632
+ paddingBottom: "env(safe-area-inset-bottom)"
2633
+ },
2634
+ children: title !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
2635
+ /* @__PURE__ */ jsxs(
2636
+ XStack,
2637
+ {
2638
+ items: "center",
2639
+ gap: "$2.5",
2640
+ px: "$4",
2641
+ height: 56,
2642
+ borderBottomWidth: 1,
2643
+ borderColor: "$borderColor",
2644
+ children: [
2645
+ Icon ? /* @__PURE__ */ jsx(Icon, { size: 18, color: iconColor ? asColor(iconColor) : void 0 }) : null,
2646
+ /* @__PURE__ */ jsx(Text, { flex: 1, fontSize: "$5", fontWeight: "700", color: "$color12", numberOfLines: 1, children: title }),
2647
+ headerRight,
2648
+ /* @__PURE__ */ jsx(Button, { chromeless: true, width: 44, height: 44, icon: /* @__PURE__ */ jsx(X, { size: 18 }), onPress: onClose, "aria-label": "Close" })
2649
+ ]
2650
+ }
2651
+ ),
2652
+ /* @__PURE__ */ jsx(ScrollView, { flex: 1, children: /* @__PURE__ */ jsx(YStack, { flex: 1, p: "$4", gap: "$3", children }) })
2653
+ ] }) : (
2654
+ // Bare mode — the caller owns the full panel layout (e.g. the nav drawer
2655
+ // renders its own header + scroll + footer).
2656
+ children
2657
+ )
2658
+ }
2659
+ )
2660
+ ]
2661
+ }
2662
+ );
2663
+ }
2664
+ var toneOf = (status) => {
2665
+ const s = status.toLowerCase();
2666
+ if (s === "green") return "green";
2667
+ if (s === "yellow") return "yellow";
2668
+ if (s === "red") return "red";
2669
+ if (["ready", "active", "running", "available", "ok", "live", "succeeded", "connected", "synced", "imported"].includes(s)) return "green";
2670
+ if (["creating", "provisioning", "pending", "updating", "attaching", "building", "deploying", "queued", "importing"].includes(s))
2671
+ return "yellow";
2672
+ if (["error", "failed", "degraded", "down", "canceled", "conflict"].includes(s)) return "red";
2673
+ return "neutral";
2674
+ };
2675
+ var TONE_BG = {
2676
+ green: "$color5",
2677
+ yellow: "$color4",
2678
+ red: "$color4",
2679
+ neutral: "$color3"
2680
+ };
2681
+ var TONE_FG = {
2682
+ green: "$color12",
2683
+ yellow: "$color12",
2684
+ red: "$color12",
2685
+ neutral: "$color11"
2686
+ };
2687
+ function StatusTag({ status }) {
2688
+ const tone2 = toneOf(status ?? "");
2689
+ return /* @__PURE__ */ jsx(Text, { fontSize: "$1", px: "$2", py: "$1", rounded: "$2", bg: TONE_BG[tone2], color: TONE_FG[tone2], children: status || "unknown" });
2690
+ }
2691
+ var ToastContext = createContext(null);
2692
+ var ACCENT3 = {
2693
+ success: "$green10",
2694
+ error: "$red10",
2695
+ info: "$color11"
2696
+ };
2697
+ var ICON = {
2698
+ success: CircleCheck,
2699
+ error: CircleX,
2700
+ info: Info
2701
+ };
2702
+ function ToastCard({ t, onClose }) {
2703
+ const Icon = ICON[t.kind];
2704
+ const accent = ACCENT3[t.kind];
2705
+ return /* @__PURE__ */ jsx(
2706
+ Card,
2707
+ {
2708
+ width: 360,
2709
+ maxWidth: "90%",
2710
+ p: "$3",
2711
+ gap: "$2",
2712
+ bg: "$color2",
2713
+ borderWidth: 1,
2714
+ borderColor: "$borderColor",
2715
+ borderLeftWidth: 3,
2716
+ borderLeftColor: accent,
2717
+ rounded: "$4",
2718
+ elevation: "$2",
2719
+ children: /* @__PURE__ */ jsxs(XStack, { gap: "$2.5", items: "flex-start", children: [
2720
+ /* @__PURE__ */ jsx(YStack, { pt: 1, children: /* @__PURE__ */ jsx(Icon, { size: 18, color: accent }) }),
2721
+ /* @__PURE__ */ jsxs(YStack, { flex: 1, gap: "$1", children: [
2722
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", fontWeight: "700", color: "$color12", children: t.title }),
2723
+ t.description ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", children: t.description }) : null
2724
+ ] }),
2725
+ /* @__PURE__ */ jsx(Button, { size: "$1", chromeless: true, icon: /* @__PURE__ */ jsx(X, { size: 14 }), onPress: onClose, "aria-label": "Dismiss" })
2726
+ ] })
2727
+ }
2728
+ );
2729
+ }
2730
+ function ToastViewport({ toasts, dismiss }) {
2731
+ const [mounted, setMounted] = useState(false);
2732
+ useEffect(() => setMounted(true), []);
2733
+ if (!mounted || typeof document === "undefined") return null;
2734
+ return createPortal(
2735
+ /* @__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)) }) }),
2736
+ document.body
2737
+ );
2738
+ }
2739
+ function ToastProvider({ children }) {
2740
+ const [toasts, setToasts] = useState([]);
2741
+ const timers = useRef(/* @__PURE__ */ new Map());
2742
+ const seq = useRef(0);
2743
+ const dismiss = useCallback((id) => {
2744
+ setToasts((ts) => ts.filter((t) => t.id !== id));
2745
+ const timer = timers.current.get(id);
2746
+ if (timer) {
2747
+ clearTimeout(timer);
2748
+ timers.current.delete(id);
2749
+ }
2750
+ }, []);
2751
+ const toast = useCallback(
2752
+ (input) => {
2753
+ const id = ++seq.current;
2754
+ const kind = input.kind ?? "info";
2755
+ const durationMs = input.durationMs ?? (kind === "error" ? 6e3 : 3500);
2756
+ setToasts((ts) => [...ts, { id, kind, title: input.title, description: input.description, durationMs }]);
2757
+ if (durationMs > 0) {
2758
+ timers.current.set(
2759
+ id,
2760
+ setTimeout(() => dismiss(id), durationMs)
2761
+ );
2762
+ }
2763
+ },
2764
+ [dismiss]
2765
+ );
2766
+ useEffect(() => {
2767
+ const map = timers.current;
2768
+ return () => map.forEach((t) => clearTimeout(t));
2769
+ }, []);
2770
+ const api = {
2771
+ toast,
2772
+ success: (title, description) => toast({ title, description, kind: "success" }),
2773
+ error: (title, description) => toast({ title, description, kind: "error" }),
2774
+ info: (title, description) => toast({ title, description, kind: "info" }),
2775
+ dismiss
2776
+ };
2777
+ return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: api, children: [
2778
+ children,
2779
+ /* @__PURE__ */ jsx(ToastViewport, { toasts, dismiss })
2780
+ ] });
2781
+ }
2782
+ function useToast() {
2783
+ const ctx = useContext(ToastContext);
2784
+ if (!ctx) throw new Error("useToast must be used within <ToastProvider>");
2785
+ return ctx;
2786
+ }
2787
+ var META = {
2788
+ x: { label: "X", bg: "#0f0f12", fg: "#e6e6ea", mark: "\u{1D54F}" },
2789
+ facebook: { label: "Facebook", bg: "#1877f2", fg: "#ffffff", mark: "f" },
2790
+ instagram: { label: "Instagram", bg: "#e1306c", fg: "#ffffff", mark: "IG" },
2791
+ linkedin: { label: "LinkedIn", bg: "#0a66c2", fg: "#ffffff", mark: "in" },
2792
+ tiktok: { label: "TikTok", bg: "#111114", fg: "#25f4ee", mark: "TT" },
2793
+ youtube: { label: "YouTube", bg: "#ff0000", fg: "#ffffff", mark: "\u25B6" },
2794
+ threads: { label: "Threads", bg: "#111114", fg: "#e6e6ea", mark: "@" }
2795
+ };
2796
+ function ChannelBadge({
2797
+ channel,
2798
+ showLabel = false,
2799
+ size = 22
2800
+ }) {
2801
+ const m = META[channel] ?? META.x;
2802
+ return /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", children: [
2803
+ /* @__PURE__ */ jsx(
2804
+ YStack,
2805
+ {
2806
+ width: size,
2807
+ height: size,
2808
+ items: "center",
2809
+ justify: "center",
2810
+ rounded: "$2",
2811
+ bg: m.bg,
2812
+ children: /* @__PURE__ */ jsx(Text, { fontSize: "$1", fontWeight: "800", color: m.fg, children: m.mark })
2813
+ }
2814
+ ),
2815
+ showLabel ? /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color12", children: m.label }) : null
2816
+ ] });
2817
+ }
2818
+ var money = (cents) => `$${Math.round((cents || 0) / 100).toLocaleString()}`;
2819
+ function CampaignCard({ campaign }) {
2820
+ const pct = campaign.budget > 0 ? Math.min(100, campaign.spend / campaign.budget * 100) : 0;
2821
+ return /* @__PURE__ */ jsxs(Card, { p: "$4", gap: "$3", borderWidth: 1, borderColor: "$borderColor", width: "100%", children: [
2822
+ /* @__PURE__ */ jsxs(XStack, { items: "flex-start", justify: "space-between", gap: "$2", children: [
2823
+ /* @__PURE__ */ jsxs(YStack, { gap: "$1", children: [
2824
+ /* @__PURE__ */ jsx(Text, { fontSize: "$4", fontWeight: "700", children: campaign.name }),
2825
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", children: campaign.channel })
2826
+ ] }),
2827
+ /* @__PURE__ */ jsx(StatusTag, { status: campaign.status })
2828
+ ] }),
2829
+ campaign.objective ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color11", children: campaign.objective }) : null,
2830
+ /* @__PURE__ */ jsxs(YStack, { gap: "$1.5", children: [
2831
+ /* @__PURE__ */ jsxs(XStack, { justify: "space-between", children: [
2832
+ /* @__PURE__ */ jsxs(Text, { fontSize: "$1", color: "$color11", children: [
2833
+ money(campaign.spend),
2834
+ " spent"
2835
+ ] }),
2836
+ /* @__PURE__ */ jsxs(Text, { fontSize: "$1", color: "$color11", children: [
2837
+ money(campaign.budget),
2838
+ " budget"
2839
+ ] })
2840
+ ] }),
2841
+ /* @__PURE__ */ jsx(YStack, { height: 6, rounded: "$2", bg: "$color3", overflow: "hidden", children: /* @__PURE__ */ jsx(YStack, { height: 6, rounded: "$2", bg: "$color9", width: `${pct}%` }) })
2842
+ ] })
2843
+ ] });
2844
+ }
2845
+
2846
+ // src/product/social/format.ts
2847
+ function formatPostTime(unix) {
2848
+ if (!unix) return "\u2014";
2849
+ return new Date(unix * 1e3).toLocaleString(void 0, {
2850
+ month: "short",
2851
+ day: "numeric",
2852
+ hour: "2-digit",
2853
+ minute: "2-digit"
2854
+ });
2855
+ }
2856
+ function postDayBucket(unix) {
2857
+ const d = new Date(unix * 1e3);
2858
+ const key = `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
2859
+ const label = d.toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric" });
2860
+ return { key, label };
2861
+ }
2862
+ function postPreview(s) {
2863
+ const t = s.trim();
2864
+ return t.length > 72 ? `${t.slice(0, 72)}\u2026` : t || "\u2014";
2865
+ }
2866
+ function parsePostTime(dt) {
2867
+ const ms = Date.parse(dt.trim());
2868
+ return Number.isFinite(ms) && ms > 0 ? Math.floor(ms / 1e3) : 0;
2869
+ }
2870
+ function PostCard({
2871
+ post,
2872
+ onEdit,
2873
+ onDelete
2874
+ }) {
2875
+ const mediaCount = post.media?.length ?? 0;
2876
+ return /* @__PURE__ */ jsxs(Card, { p: "$3", gap: "$2.5", borderWidth: 1, borderColor: "$borderColor", width: "100%", children: [
2877
+ /* @__PURE__ */ jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [
2878
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", children: [
2879
+ /* @__PURE__ */ jsx(ChannelBadge, { channel: post.channel }),
2880
+ /* @__PURE__ */ jsx(StatusTag, { status: post.status })
2881
+ ] }),
2882
+ /* @__PURE__ */ jsxs(XStack, { gap: "$1", children: [
2883
+ onEdit ? /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsx(Pencil, { size: 15 }), onPress: () => onEdit(post) }) : null,
2884
+ onDelete ? /* @__PURE__ */ jsx(Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsx(Trash2, { size: 15 }), onPress: () => onDelete(post) }) : null
2885
+ ] })
2886
+ ] }),
2887
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color12", children: post.content }),
2888
+ /* @__PURE__ */ jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [
2889
+ post.scheduleAt ? /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color11", children: formatPostTime(post.scheduleAt) }) : /* @__PURE__ */ jsx(YStack, {}),
2890
+ mediaCount ? /* @__PURE__ */ jsxs(Text, { fontSize: "$1", color: "$color10", children: [
2891
+ mediaCount,
2892
+ " media"
2893
+ ] }) : null
2894
+ ] })
2895
+ ] });
2896
+ }
2897
+ function PostAgenda({ posts, onOpen }) {
2898
+ const days = useMemo(() => {
2899
+ const timed = posts.filter((p) => (p.scheduleAt ?? 0) > 0).sort((a, b) => (a.scheduleAt ?? 0) - (b.scheduleAt ?? 0));
2900
+ const groups = [];
2901
+ const index = /* @__PURE__ */ new Map();
2902
+ for (const p of timed) {
2903
+ const { key, label } = postDayBucket(p.scheduleAt ?? 0);
2904
+ let i = index.get(key);
2905
+ if (i === void 0) {
2906
+ i = groups.length;
2907
+ index.set(key, i);
2908
+ groups.push({ label, items: [] });
2909
+ }
2910
+ groups[i].items.push(p);
2911
+ }
2912
+ return groups;
2913
+ }, [posts]);
2914
+ if (days.length === 0) {
2915
+ return /* @__PURE__ */ jsx(
2916
+ EmptyState,
2917
+ {
2918
+ icon: Calendar,
2919
+ title: "Nothing on the calendar",
2920
+ description: "Scheduled and timed posts appear here, grouped by day. Compose a post and pick Schedule to plan ahead."
2921
+ }
2922
+ );
2923
+ }
2924
+ return /* @__PURE__ */ jsx(YStack, { gap: "$4", children: days.map((d) => /* @__PURE__ */ jsxs(YStack, { gap: "$2", children: [
2925
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$color11", children: d.label }),
2926
+ d.items.map((p) => /* @__PURE__ */ jsxs(
2927
+ XStack,
2928
+ {
2929
+ items: "center",
2930
+ justify: "space-between",
2931
+ gap: "$3",
2932
+ borderWidth: 1,
2933
+ borderColor: "$borderColor",
2934
+ rounded: "$4",
2935
+ px: "$4",
2936
+ py: "$3",
2937
+ cursor: "pointer",
2938
+ hoverStyle: { bg: "$color2" },
2939
+ onPress: () => onOpen(p),
2940
+ children: [
2941
+ /* @__PURE__ */ jsxs(YStack, { gap: "$1", flex: 1, children: [
2942
+ /* @__PURE__ */ jsx(Text, { fontSize: "$3", children: postPreview(p.content) }),
2943
+ /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", children: [
2944
+ /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color10", children: p.channel }),
2945
+ /* @__PURE__ */ jsxs(Text, { fontSize: "$1", color: "$color10", children: [
2946
+ "\xB7 ",
2947
+ formatPostTime(p.scheduleAt ?? 0)
2948
+ ] })
2949
+ ] })
2950
+ ] }),
2951
+ /* @__PURE__ */ jsx(StatusTag, { status: p.status })
2952
+ ]
2953
+ },
2954
+ p.id
2955
+ ))
2956
+ ] }, d.label)) });
2957
+ }
2958
+ var COMPOSE_MODES = ["draft", "schedule", "now"];
2959
+ var COMPOSE_LABEL = {
2960
+ draft: "Save draft",
2961
+ schedule: "Schedule",
2962
+ now: "Publish now"
2963
+ };
2964
+ function PostComposer({
2965
+ channels,
2966
+ providers,
2967
+ onSubmit
2968
+ }) {
2969
+ const [content, setContent] = useState("");
2970
+ const [channel, setChannel] = useState(channels[0] ?? "x");
2971
+ const [mode, setMode] = useState("draft");
2972
+ const [scheduleAt, setScheduleAt] = useState("");
2973
+ const [saving, setSaving] = useState(false);
2974
+ const [error, setError] = useState(null);
2975
+ const cap = providers.find((p) => p.provider === channel);
2976
+ const unconfigured = (mode === "now" || mode === "schedule") && !!cap && !cap.credentialsConfigured;
2977
+ const submit = async () => {
2978
+ if (!content.trim()) {
2979
+ setError("Content is required.");
2980
+ return;
2981
+ }
2982
+ let status = "draft";
2983
+ let at = 0;
2984
+ if (mode === "schedule") {
2985
+ at = parsePostTime(scheduleAt);
2986
+ if (at <= Math.floor(Date.now() / 1e3)) {
2987
+ setError("Pick a future date and time to schedule.");
2988
+ return;
2989
+ }
2990
+ status = "scheduled";
2991
+ } else if (mode === "now") {
2992
+ status = "scheduled";
2993
+ }
2994
+ setSaving(true);
2995
+ setError(null);
2996
+ const message = await onSubmit({ content: content.trim(), channel, status, scheduleAt: at }, mode);
2997
+ if (message) {
2998
+ setError(message);
2999
+ setSaving(false);
3000
+ }
3001
+ };
3002
+ return /* @__PURE__ */ jsxs(YStack, { gap: "$3", p: "$4", children: [
3003
+ /* @__PURE__ */ jsx(FieldRow, { label: "Content", children: /* @__PURE__ */ jsx(FieldTextArea, { value: content, onChange: setContent, disabled: saving }) }),
3004
+ /* @__PURE__ */ jsx(FieldRow, { label: "Channel", children: /* @__PURE__ */ jsx(FieldSelect, { value: channel, options: channels, onChange: setChannel, disabled: saving }) }),
3005
+ /* @__PURE__ */ jsx(FieldRow, { label: "When", children: /* @__PURE__ */ jsx(
3006
+ FieldSelect,
3007
+ {
3008
+ value: mode,
3009
+ options: [...COMPOSE_MODES],
3010
+ onChange: (v) => setMode(v),
3011
+ disabled: saving
3012
+ }
3013
+ ) }),
3014
+ mode === "schedule" ? /* @__PURE__ */ jsx(FieldRow, { label: "Schedule at", children: /* @__PURE__ */ jsx(
3015
+ FieldText,
3016
+ {
3017
+ value: scheduleAt,
3018
+ onChange: setScheduleAt,
3019
+ placeholder: "2026-07-15 09:00",
3020
+ disabled: saving
3021
+ }
3022
+ ) }) : null,
3023
+ unconfigured ? /* @__PURE__ */ jsxs(XStack, { items: "flex-start", gap: "$2", children: [
3024
+ /* @__PURE__ */ jsx(AlertTriangle, { size: 14, color: "var(--yellow10)" }),
3025
+ /* @__PURE__ */ jsxs(Text, { fontSize: "$1", color: "$color10", children: [
3026
+ channel,
3027
+ " isn\u2019t configured to publish yet \u2014 needs ",
3028
+ cap?.missingCredentials.join(", "),
3029
+ ". The post is saved and marked failed on publish until credentials are supplied."
3030
+ ] })
3031
+ ] }) : null,
3032
+ error ? /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$red10", children: error }) : null,
3033
+ /* @__PURE__ */ jsx(PrimaryButton, { onPress: submit, disabled: saving, children: saving ? "Working\u2026" : COMPOSE_LABEL[mode] })
3034
+ ] });
3035
+ }
3036
+ function ProviderReadinessList({ providers }) {
3037
+ return /* @__PURE__ */ jsxs(YStack, { gap: "$2", children: [
3038
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", color: "$color10", children: "Network publish-readiness" }),
3039
+ providers.map((p) => /* @__PURE__ */ jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", py: "$1", children: [
3040
+ /* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$2", children: [
3041
+ p.credentialsConfigured ? /* @__PURE__ */ jsx(CheckCircle2, { size: 14, color: "var(--green10)" }) : /* @__PURE__ */ jsx(AlertTriangle, { size: 14, color: "var(--yellow10)" }),
3042
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", children: p.provider })
3043
+ ] }),
3044
+ /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color10", children: p.credentialsConfigured ? "Ready" : `needs ${p.missingCredentials.join(", ")}` })
3045
+ ] }, p.provider))
3046
+ ] });
3047
+ }
3048
+ function SocialSummaryBar({ summary }) {
3049
+ const cells = [
3050
+ { label: "Posts", value: summary.posts },
3051
+ { label: "Scheduled", value: summary.scheduled },
3052
+ { label: "Published", value: summary.published },
3053
+ { label: "Accounts", value: summary.accounts }
3054
+ ];
3055
+ return /* @__PURE__ */ jsx(XStack, { gap: "$3", flexWrap: "wrap", children: cells.map((c) => /* @__PURE__ */ jsxs(
3056
+ YStack,
3057
+ {
3058
+ gap: "$1",
3059
+ borderWidth: 1,
3060
+ borderColor: "$borderColor",
3061
+ rounded: "$4",
3062
+ px: "$4",
3063
+ py: "$3",
3064
+ minW: 140,
3065
+ children: [
3066
+ /* @__PURE__ */ jsx(Text, { fontSize: "$1", color: "$color10", children: c.label }),
3067
+ /* @__PURE__ */ jsx(Text, { fontSize: "$6", fontWeight: "500", className: "hz-tnum", children: c.value })
3068
+ ]
3069
+ },
3070
+ c.label
3071
+ )) });
3072
+ }
3073
+ var OPTIONS = [
3074
+ { id: "list", label: "List", icon: List },
3075
+ { id: "calendar", label: "Calendar", icon: Calendar }
3076
+ ];
3077
+ function ViewToggle({
3078
+ view,
3079
+ onChange
3080
+ }) {
3081
+ return /* @__PURE__ */ jsx(XStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", overflow: "hidden", children: OPTIONS.map((o) => {
3082
+ const Icon = o.icon;
3083
+ const active = view === o.id;
3084
+ return /* @__PURE__ */ jsxs(
3085
+ XStack,
3086
+ {
3087
+ items: "center",
3088
+ gap: "$2",
3089
+ px: "$3",
3090
+ py: "$2",
3091
+ cursor: "pointer",
3092
+ bg: active ? "$color4" : "transparent",
3093
+ hoverStyle: { bg: active ? "$color4" : "$color2" },
3094
+ onPress: () => onChange(o.id),
3095
+ children: [
3096
+ /* @__PURE__ */ jsx(Icon, { size: 14 }),
3097
+ /* @__PURE__ */ jsx(Text, { fontSize: "$2", fontWeight: active ? "500" : "400", children: o.label })
3098
+ ]
3099
+ },
3100
+ o.id
3101
+ );
3102
+ }) });
3103
+ }
3104
+
3105
+ export { AnimatedLogo, AppHeader, BRANDS, BackendStateCard, BarChart, BarRows, BrandMark, CHART_OTHER, CHART_PALETTE, COMPOSE_MODES, CampaignCard, ChannelBadge, ComboBox, CommerceResource, ConfirmDelete, ContextMenu, DataTable, Donut, Donut2 as DonutRing, DropdownMenu, EmptyState, FadeIn, FieldRow, FieldSelect, FieldSlider, FieldSwitch, FieldText, FieldTextArea, FloatingMenu, GenericLogo, HANZO, HANZO_MARK_CONTENT, HanzoMark, HintButton, HostProvider, LUX, LegendDot, LineChart, MenuItemView, MenuLabelView, MenuPanel, MenuSeparatorView, MetricCard, Sparkline2 as MetricSparkline, MiniBars, OrgMark, OrgSwitcher, PARS, PageHeader, Panel, PortalTheme, PostAgenda, PostCard, PostComposer, PrimaryButton, ProductIcon, ProviderLogo, ProviderReadinessList, Reorder, SERIES, LG as SLIDEOVER_LG, SURFACES, SearchInput, Segmented, SelectMenu, SiteFooter, SiteNav, SlideOver, SocialSummaryBar, Sparkline, StatusTag, ToastProvider, UtilBar, ViewToggle, ZOO, accentFor, asColor, classifyBackend, classifyRead, colorForIndex, contrastText, filterOptions, filterOrgs, formatPostTime, isHexColor, isKnownOption, monogram, orgScope, otherSurfaces, parsePostTime, postDayBucket, postPreview, providerInitials, renderMenuItems, resolveAccent, resolveBrand, rowShift, setOrgAccent, targetIndex, useAccent, useContainerWidth, useHost, useToast, utilColor };
4
3106
  //# sourceMappingURL=index.js.map
5
3107
  //# sourceMappingURL=index.js.map