@hanzo/ui 8.0.24 → 8.0.26

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