@hanzo/ui 8.0.24 → 8.0.25

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