@hanzo/build 0.2.126 → 0.2.128

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 (59) hide show
  1. package/lib/api/machines.d.ts +8 -0
  2. package/lib/api/machines.js +16 -5
  3. package/lib/api/places.d.ts +12 -4
  4. package/lib/api/places.js +11 -3
  5. package/lib/automations.js +74 -35
  6. package/lib/awake.d.ts +24 -0
  7. package/lib/awake.js +68 -0
  8. package/lib/clipboard.d.ts +2 -0
  9. package/lib/clipboard.js +10 -0
  10. package/lib/customize/agents.js +149 -31
  11. package/lib/customize/connectors.js +91 -34
  12. package/lib/customize/drafted.js +23 -10
  13. package/lib/customize/index.js +40 -10
  14. package/lib/customize/inventory.d.ts +4 -1
  15. package/lib/customize/inventory.js +66 -17
  16. package/lib/customize/plugins.js +43 -15
  17. package/lib/customize/skills.js +87 -23
  18. package/lib/customize/ui.d.ts +29 -3
  19. package/lib/customize/ui.js +89 -12
  20. package/lib/desk.d.ts +1 -1
  21. package/lib/desk.js +67 -40
  22. package/lib/dev-mode.d.ts +22 -0
  23. package/lib/dev-mode.js +80 -0
  24. package/lib/environment.js +4 -4
  25. package/lib/forge.js +97 -24
  26. package/lib/handoff.d.ts +8 -0
  27. package/lib/handoff.js +22 -0
  28. package/lib/index.d.ts +1 -0
  29. package/lib/index.js +1 -0
  30. package/lib/landing.js +100 -25
  31. package/lib/library.js +108 -39
  32. package/lib/make.js +3 -2
  33. package/lib/mind.d.ts +9 -29
  34. package/lib/mind.js +43 -4
  35. package/lib/pane.d.ts +13 -0
  36. package/lib/pane.js +4 -0
  37. package/lib/panel.d.ts +4 -0
  38. package/lib/panel.js +49 -46
  39. package/lib/plans.js +36 -15
  40. package/lib/project.js +72 -63
  41. package/lib/reply.d.ts +6 -1
  42. package/lib/reply.js +19 -9
  43. package/lib/run.js +23 -41
  44. package/lib/scheduled.js +36 -16
  45. package/lib/settings/account.js +2 -1
  46. package/lib/settings/billing.js +9 -4
  47. package/lib/settings/credits.d.ts +2 -1
  48. package/lib/settings/credits.js +2 -2
  49. package/lib/settings/machines.js +41 -18
  50. package/lib/settings/notifications.js +2 -1
  51. package/lib/shelf.d.ts +4 -1
  52. package/lib/shelf.js +79 -14
  53. package/lib/suggest.d.ts +6 -0
  54. package/lib/suggest.js +7 -1
  55. package/lib/suggestions.js +2 -1
  56. package/lib/summary.js +3 -2
  57. package/lib/sync.js +3 -3
  58. package/lib/transcript.js +13 -6
  59. package/package.json +11 -1
package/lib/mind.d.ts CHANGED
@@ -1,35 +1,15 @@
1
- /**
2
- * Which model answers, and how hard it thinks: one store for Chat and Dev, and
3
- * the catalog both offer. The composer (@hanzo/ui/chat) changes it.
4
- *
5
- * GET /v1/models the catalog, read once per platform and shared
6
- * hanzo.mind the person's choice, in this browser: {model, effort}
7
- *
8
- * The effort is always under the composer; the model chip only where the person
9
- * turned it on (Settings → Appearance › Model in composer). Enso
10
- * routes every ask — a message in Chat, a step in Dev — so naming a model is an
11
- * override, and the panel says so before it offers one. A premium model is
12
- * picked for the screen it was picked on (`usePick`) and never kept, so the next
13
- * conversation or run opens on what was kept, Enso until something else is.
14
- *
15
- * The efforts are Auto, High and Max, Chat's words (Hanzo's
16
- * ThinkingEffort), Auto until another is chosen. A coding run takes low, medium
17
- * or high (apps/coding `efforts`), so `level` is what a run names: medium for
18
- * Auto, what a run took before anyone chose, and high for the rest, the most it
19
- * takes. Auto names one rather than none, because a run that names none takes
20
- * an effort the person saved to their account once (apps/coding start.go) and
21
- * no screen shows any more.
22
- */
23
1
  import type { Modes } from '@hanzo/ui/chat';
24
2
  import { type Target } from './api/call.ts';
25
3
  import { type Model } from './api/models.ts';
26
- export type Effort = 'auto' | 'high' | 'max';
27
- /** The efforts a Dev run offers, in order: the composer's own list (Chat offers every one), less Low and Medium. Marked English, drawn through `t`. */
28
- export declare const EFFORTS: (import("@hanzo/ui/chat").Way<import("@hanzo/ui/chat").Effort> & {
29
- id: Effort;
30
- })[];
31
- /** The effort a coding run names (apps/coding takes low, medium or high): medium for Auto, high for the rest. */
32
- export declare const level: (effort: Effort) => 'medium' | 'high';
4
+ export type Effort = 'auto' | 'low' | 'high' | 'max';
5
+ /** The efforts a Dev run offers, in order: Auto (medium), Fast (low), High, and Max. Marked English, drawn through `t`. */
6
+ export declare const EFFORTS: {
7
+ id: "auto" | "high" | "low" | "max";
8
+ label: string;
9
+ note: string;
10
+ }[];
11
+ /** The effort a coding run names (apps/coding takes low, medium or high): low for Fast, medium for Auto, high for High/Max. */
12
+ export declare const level: (effort: Effort) => 'low' | 'medium' | 'high';
33
13
  /** What a person chose: the model (Enso routes) and the effort. */
34
14
  export interface Choice {
35
15
  model: string;
package/lib/mind.js CHANGED
@@ -1,3 +1,26 @@
1
+ /**
2
+ * Which model answers, and how hard it thinks: one store for Chat and Dev, and
3
+ * the catalog both offer. The composer (@hanzo/ui/chat) changes it.
4
+ *
5
+ * GET /v1/models the catalog, read once per platform and shared
6
+ * hanzo.mind the person's choice, in this browser: {model, effort}
7
+ *
8
+ * The effort is always under the composer; the model chip only where the person
9
+ * turned it on (Settings → Appearance › Model in composer). Enso
10
+ * routes every ask — a message in Chat, a step in Dev — so naming a model is an
11
+ * override, and the panel says so before it offers one. A premium model is
12
+ * picked for the screen it was picked on (`usePick`) and never kept, so the next
13
+ * conversation or run opens on what was kept, Enso until something else is.
14
+ *
15
+ * The efforts are Auto, High and Max, Chat's words (Hanzo's
16
+ * ThinkingEffort), Auto until another is chosen. A coding run takes low, medium
17
+ * or high (apps/coding `efforts`), so `level` is what a run names: medium for
18
+ * Auto, what a run took before anyone chose, and high for the rest, the most it
19
+ * takes. Auto names one rather than none, because a run that names none takes
20
+ * an effort the person saved to their account once (apps/coding start.go) and
21
+ * no screen shows any more.
22
+ */
23
+ import { phrase } from '@hanzo/i18n';
1
24
  import { EFFORTS as EVERY } from '@hanzo/ui/chat/pure';
2
25
  import { parseModels, thirdParty } from '@hanzo/ui/models/catalog';
3
26
  import { useEffect, useState, useSyncExternalStore } from 'react';
@@ -5,10 +28,26 @@ import { prepaid as readPrepaid } from './api/billing.js';
5
28
  import { Refusal } from './api/call.js';
6
29
  import { ENSO, models as read } from './api/models.js';
7
30
  import { usePick } from './pick.js';
8
- /** The efforts a Dev run offers, in order: the composer's own list (Chat offers every one), less Low and Medium. Marked English, drawn through `t`. */
9
- export const EFFORTS = EVERY.filter((e) => ['auto', 'high', 'max'].includes(e.id));
10
- /** The effort a coding run names (apps/coding takes low, medium or high): medium for Auto, high for the rest. */
11
- export const level = (effort) => (effort === 'auto' ? 'medium' : 'high');
31
+ const EFFORT_LABELS = {
32
+ low: phrase('Fast'),
33
+ };
34
+ const EFFORT_NOTES = {
35
+ auto: phrase('Matches thinking depth to the complexity of each prompt.'),
36
+ low: phrase('Fastest edits and replies for straightforward coding tasks.'),
37
+ high: phrase('Spends extra time reasoning through multi-step tasks and code.'),
38
+ max: phrase('Deepest reasoning and verification for complex architecture.'),
39
+ };
40
+ /** The efforts a Dev run offers, in order: Auto (medium), Fast (low), High, and Max. Marked English, drawn through `t`. */
41
+ export const EFFORTS = ['auto', 'low', 'high', 'max'].map((id) => {
42
+ const base = EVERY.find((e) => e.id === id);
43
+ return {
44
+ id,
45
+ label: EFFORT_LABELS[id] ?? base?.label ?? id,
46
+ note: EFFORT_NOTES[id] ?? base?.note ?? '',
47
+ };
48
+ });
49
+ /** The effort a coding run names (apps/coding takes low, medium or high): low for Fast, medium for Auto, high for High/Max. */
50
+ export const level = (effort) => effort === 'low' ? 'low' : effort === 'auto' ? 'medium' : 'high';
12
51
  export const FIRST = { model: ENSO, effort: 'auto' };
13
52
  /** Whether a plan grants only Enso Auto. An unknown plan is not taken for Free. */
14
53
  export const isFree = (plan) => plan === 'free';
package/lib/pane.d.ts CHANGED
@@ -15,3 +15,16 @@ export declare const pane: {
15
15
  readonly boxShadow: 'var(--shadow-sheet-2)';
16
16
  };
17
17
  export declare const gap = "var(--pane-gap, var(--space-2))";
18
+ /** The ring a control wears while the keyboard is on it: the colour and stroke of @hanzo/ui's own press ring (backends/gui/press.ts). */
19
+ export declare const RING: {
20
+ readonly outlineWidth: 2;
21
+ readonly outlineStyle: 'solid';
22
+ readonly outlineColor: '$outlineColor';
23
+ };
24
+ /** The same ring drawn inside a control's edge, for a row that fills its box. */
25
+ export declare const RING_INSET: {
26
+ readonly outlineWidth: 2;
27
+ readonly outlineStyle: 'solid';
28
+ readonly outlineColor: '$outlineColor';
29
+ readonly outlineOffset: -2;
30
+ };
package/lib/pane.js CHANGED
@@ -15,3 +15,7 @@ export const pane = {
15
15
  boxShadow: 'var(--shadow-sheet-2)',
16
16
  };
17
17
  export const gap = 'var(--pane-gap, var(--space-2))';
18
+ /** The ring a control wears while the keyboard is on it: the colour and stroke of @hanzo/ui's own press ring (backends/gui/press.ts). */
19
+ export const RING = { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' };
20
+ /** The same ring drawn inside a control's edge, for a row that fills its box. */
21
+ export const RING_INSET = { ...RING, outlineOffset: -2 };
package/lib/panel.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type ReactNode } from 'react';
2
+ import { type Browser, type Shown } from './host.tsx';
2
3
  import { type Deck, type Tab } from './tabs.ts';
3
4
  /** A kind of tab the surface offers. */
4
5
  export interface Kind {
@@ -68,6 +69,9 @@ export interface PageProps extends Acts {
68
69
  onPin?: (on: boolean) => void;
69
70
  suggested?: readonly Suggestion[];
70
71
  }
72
+ /** A row of the menu: its words, and what stands at its end. */
73
+ /** Hand the page's picture to `onCapture` as a file; a capture the host browser cancels or fails is dropped, with nothing thrown. */
74
+ export declare function screenshot(browser: Browser | null, shown: Shown | null, onCapture: Acts['onCapture']): Promise<void>;
71
75
  /**
72
76
  * A page tab: its bar, then an address, bytes rendered as their type, or the
73
77
  * suggestions of an empty tab.
package/lib/panel.js CHANGED
@@ -27,8 +27,10 @@ import { phrase } from '@hanzo/i18n';
27
27
  import { useI18n } from '@hanzo/i18n/react';
28
28
  import { ArrowLeft, ArrowRight, ChevronRight, Columns2, ExternalLink, Globe, Maximize2, Minimize2, Minus, MoreHorizontal, PanelLeftOpen, Pin, Plus, RotateCcw, RotateCw, X } from '@hanzogui/lucide-icons-2';
29
29
  import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from '@hanzo/ui';
30
- import { useEffect, useMemo, useRef, useState } from 'react';
30
+ import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
31
31
  import { createPortal } from 'react-dom';
32
+ import { RING, RING_INSET } from './pane.js';
33
+ import { copy } from './clipboard.js';
32
34
  import { useBrowse, useBrowser } from './host.js';
33
35
  import { useSide } from './side.js';
34
36
  import { destination, PAGE } from './tabs.js';
@@ -52,11 +54,12 @@ const quiet = (on = false, disabled = false) => ({
52
54
  justify: 'center',
53
55
  shrink: 0,
54
56
  rounded: 8,
57
+ borderWidth: 0,
55
58
  cursor: disabled ? 'default' : 'pointer',
56
59
  opacity: disabled ? 0.35 : 1,
57
60
  bg: on ? '$hover' : 'transparent',
58
61
  hoverStyle: disabled ? undefined : { bg: '$hover' },
59
- focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' },
62
+ focusVisibleStyle: RING,
60
63
  });
61
64
  /**
62
65
  * The header's control for the tabs, while they are hidden: an icon among the
@@ -68,7 +71,7 @@ export function PanelToggle({ open, onToggle }) {
68
71
  const { t } = useI18n();
69
72
  if (open)
70
73
  return null;
71
- return (_jsx(XStack, { render: "button", role: "button", "data-slot": "side-toggle", "aria-label": t('Show tabs'), "aria-expanded": false, "aria-keyshortcuts": SHORTCUTS, ...{ title: t('Show tabs ({keys})', { keys: KEYS }) }, onPress: onToggle, width: 32, height: 32, ...quiet(), children: _jsx(Plus, { size: 16 }) }));
74
+ return (_jsx(XStack, { render: "button", "data-slot": "side-toggle", "aria-label": t('Show tabs'), "aria-expanded": false, "aria-keyshortcuts": SHORTCUTS, ...{ title: t('Show tabs ({keys})', { keys: KEYS }) }, onPress: onToggle, width: 32, height: 32, ...quiet(), children: _jsx(Plus, { size: 16 }) }));
72
75
  }
73
76
  /** Our own hosts: a page of theirs answers a frame on any of our pages. */
74
77
  const OURS = ['hanzo.ai', 'hanzo.app', 'hanzo.bot'];
@@ -125,17 +128,17 @@ function popOut(tab) {
125
128
  /** A place's mark: its image, else its initial on a quiet tile. */
126
129
  function Mark({ icon, title }) {
127
130
  const [broken, setBroken] = useState(false);
128
- return (_jsx(XStack, { width: 40, height: 40, rounded: 10, items: "center", justify: "center", bg: "$edge", overflow: "hidden", shrink: 0, children: icon && !broken ? (_jsx("img", { src: icon, alt: "", width: 28, height: 28, style: { objectFit: 'contain' }, onError: () => setBroken(true) })) : (_jsx(SizableText, { size: "$4", fontWeight: "600", color: "$ink", "aria-hidden": true, children: (title.trim()[0] ?? '·').toUpperCase() })) }));
131
+ return (_jsx(XStack, { width: 40, height: 40, rounded: 10, items: "center", justify: "center", bg: "$edge", overflow: "hidden", shrink: 0, children: icon && !broken ? (_jsx(YStack, { render: _jsx("img", { src: icon, alt: "", width: 28, height: 28, onError: () => setBroken(true) }), "$platform-web": { objectFit: 'contain' } })) : (_jsx(SizableText, { size: "$4", fontWeight: "600", color: "$ink", "aria-hidden": true, children: (title.trim()[0] ?? '·').toUpperCase() })) }));
129
132
  }
130
133
  /** An empty page: the places the surface suggests, as cards in a row that scrolls sideways. */
131
134
  function Suggested({ suggested, onGo }) {
132
135
  const { t } = useI18n();
133
- return (_jsxs(YStack, { "data-slot": "side-suggested", px: "$4", pt: "$4", gap: "$3", children: [_jsx(SizableText, { fontSize: 13, color: "$soft", children: t('Suggested') }), suggested.length ? (_jsx(XStack, { role: "list", "aria-label": t('Suggested'), gap: "$2", overflowX: "auto", overflowY: "hidden", pb: "$2", children: suggested.map((s) => (_jsxs(YStack, { role: "listitem", render: "button", "aria-label": s.title, onPress: () => onGo(s.url), width: 120, shrink: 0, items: "center", gap: "$2", py: "$2.5", px: "$1.5", rounded: 12, cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: [_jsx(Mark, { icon: s.icon, title: s.title }), _jsx(SizableText, { fontSize: 13, color: "$ink", numberOfLines: 1, maxW: "100%", children: s.title })] }, s.url))) })) : (_jsx(SizableText, { fontSize: 13, color: "$soft", children: t('No suggestions.') }))] }));
136
+ return (_jsxs(YStack, { "data-slot": "side-suggested", px: "$4", pt: "$4", gap: "$3", children: [_jsx(SizableText, { fontSize: 13, color: "$soft", children: t('Suggested') }), suggested.length ? (_jsx(XStack, { role: "list", "aria-label": t('Suggested'), gap: "$2", overflowX: "auto", overflowY: "hidden", pb: "$2", children: suggested.map((s) => (_jsx(YStack, { role: "listitem", shrink: 0, children: _jsxs(YStack, { render: "button", "aria-label": s.title, onPress: () => onGo(s.url), width: 120, items: "center", gap: "$2", py: "$2.5", px: "$1.5", focusVisibleStyle: RING, children: [_jsx(Mark, { icon: s.icon, title: s.title }), _jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, maxW: "100%", children: s.title })] }) }, s.url))) })) : (_jsx(SizableText, { fontSize: 13, color: "$soft", children: t('No suggestions.') }))] }));
134
137
  }
135
138
  /** A remote address a browser page may not frame: what it is, and the one way to open it. */
136
139
  function Elsewhere({ tab }) {
137
140
  const { t } = useI18n();
138
- return (_jsxs(YStack, { flex: 1, items: "center", justify: "center", gap: "$3", p: "$5", "data-slot": "side-elsewhere", children: [_jsx(Globe, { size: 20, opacity: 0.6 }), _jsx(SizableText, { fontSize: 13, color: "$ink", numberOfLines: 1, maxW: "100%", children: tab.title || tab.url }), _jsxs(XStack, { render: "button", role: "button", onPress: () => popOut(tab), items: "center", gap: "$1.5", px: "$3", height: 32, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(ExternalLink, { size: 13 }), _jsx(SizableText, { fontSize: 13, color: "$ink", children: t('Open in a new window') })] })] }));
141
+ return (_jsxs(YStack, { flex: 1, items: "center", justify: "center", gap: "$3", p: "$5", "data-slot": "side-elsewhere", children: [_jsx(Globe, { size: 20, opacity: 0.6 }), _jsx(SizableText, { fontSize: 13, color: "$ink", numberOfLines: 1, maxW: "100%", children: tab.title || tab.url }), _jsxs(XStack, { render: "button", onPress: () => popOut(tab), items: "center", gap: "$1.5", px: "$3", minH: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: [_jsx(ExternalLink, { size: 13 }), _jsx(SizableText, { fontSize: 13, color: "$ink", children: t('Open in a new window') })] })] }));
139
142
  }
140
143
  /** A row of the page's menu, px: a browser's menu is denser than a form's. */
141
144
  const ROW = 29;
@@ -148,6 +151,19 @@ const zoomed = (now, way) => {
148
151
  return ZOOMS[Math.max(0, Math.min(ZOOMS.length - 1, i))];
149
152
  };
150
153
  /** A row of the menu: its words, and what stands at its end. */
154
+ /** Hand the page's picture to `onCapture` as a file; a capture the host browser cancels or fails is dropped, with nothing thrown. */
155
+ export async function screenshot(browser, shown, onCapture) {
156
+ if (!shown || !browser?.capture || !onCapture)
157
+ return;
158
+ try {
159
+ const blob = await browser.capture(shown);
160
+ const name = `Screenshot ${new Date().toISOString().replace(/[:T]/g, '-').slice(0, 19)}.png`;
161
+ onCapture(new File([blob], name, { type: blob.type || 'image/png' }), { url: shown.url, title: shown.title });
162
+ }
163
+ catch {
164
+ // Cancelled or failed in the host browser.
165
+ }
166
+ }
151
167
  function Row({ label, onSelect, disabled, end }) {
152
168
  return (_jsxs(DropdownMenuItem, { disabled: disabled, onSelect: onSelect, minH: ROW, py: 0, children: [_jsx(SizableText, { fontSize: 13, color: "$ink", flex: 1, numberOfLines: 1, children: label }), end] }));
153
169
  }
@@ -155,8 +171,8 @@ function Row({ label, onSelect, disabled, end }) {
155
171
  function Zoom({ level, onLevel, disabled }) {
156
172
  const { t } = useI18n();
157
173
  const step = (way) => () => onLevel(zoomed(level, way));
158
- const box = (label, onPress, child) => (_jsx(XStack, { render: "button", role: "button", "aria-label": label, "aria-disabled": disabled || undefined, onPress: disabled ? undefined : onPress, width: 24, height: 24, ...quiet(false, disabled), rounded: 6, children: child }));
159
- return (_jsxs(XStack, { "data-slot": "page-zoom", role: "group", "aria-label": t('Zoom'), items: "center", gap: "$2", px: 8, height: 38, opacity: disabled ? 0.5 : 1, children: [_jsx(SizableText, { fontSize: 13, color: "$ink", flex: 1, children: t('Zoom') }), _jsxs(XStack, { items: "center", gap: 2, borderWidth: 1, borderColor: "$borderColor", rounded: 8, px: 2, height: 28, children: [box(t('Zoom out'), step(-1), _jsx(Minus, { size: 12 })), _jsx(SizableText, { fontSize: 12, color: "$ink", width: 40, text: "center", "aria-live": "polite", children: `${level}%` }), box(t('Zoom in'), step(1), _jsx(Plus, { size: 12 }))] }), box(t('Reset zoom'), () => onLevel(100), _jsx(RotateCcw, { size: 13 }))] }));
174
+ const box = (label, onSelect, child) => (_jsx(XStack, { render: "button", "aria-label": label, "aria-disabled": disabled || undefined, onPress: disabled ? undefined : onSelect, width: 24, height: 24, ...quiet(false, disabled), children: child }));
175
+ return (_jsxs(XStack, { "data-slot": "page-zoom", role: "group", "aria-label": t('Zoom'), items: "center", gap: "$2", px: 8, height: 38, opacity: disabled ? 0.5 : 1, children: [_jsx(SizableText, { fontSize: 13, color: "$ink", flex: 1, children: t('Zoom') }), _jsxs(XStack, { items: "center", gap: 2, borderWidth: 1, borderColor: "$borderColor", rounded: 8, px: 2, height: 28, children: [box(t('Zoom out'), step(-1), _jsx(Minus, { size: 12 })), _jsx(SizableText, { size: "$1", color: "$ink", width: 40, text: "center", "aria-live": "polite", fontVariant: ['tabular-nums'], children: `${level}%` }), box(t('Zoom in'), step(1), _jsx(Plus, { size: 12 }))] }), box(t('Reset zoom'), () => onLevel(100), _jsx(RotateCcw, { size: 13 }))] }));
160
176
  }
161
177
  /**
162
178
  * Skills, a submenu. Its panel is mounted only while open: a closed one stays
@@ -196,13 +212,6 @@ function Actions({ tab, here, frame, framed, same, level, onLevel, acts, browser
196
212
  const selection = browser?.selection ? await browser.selection(shown).catch(() => '') : pick();
197
213
  acts.onAsk({ url: shown.url, title: shown.title, ...(selection ? { selection } : {}) });
198
214
  };
199
- const capture = async () => {
200
- if (!shown || !browser?.capture || !acts.onCapture)
201
- return;
202
- const blob = await browser.capture(shown);
203
- const name = `Screenshot ${new Date().toISOString().replace(/[:T]/g, '-').slice(0, 19)}.png`;
204
- acts.onCapture(new File([blob], name, { type: blob.type || 'image/png' }), { url: shown.url, title: shown.title });
205
- };
206
215
  const print = browser?.print ?? (same ? () => frame.current?.contentWindow?.print() : undefined);
207
216
  const zoom = Boolean(browser?.zoom) || framed;
208
217
  const ours = [
@@ -210,7 +219,7 @@ function Actions({ tab, here, frame, framed, same, level, onLevel, acts, browser
210
219
  acts.onDev && shown && hosted(shown.url) ? _jsx(Row, { label: t('Open in Dev'), onSelect: () => acts.onDev?.({ url: shown.url, title: shown.title }) }, "dev") : null,
211
220
  acts.skills?.length ? _jsx(Skills, { skills: acts.skills, here: here }, "skills") : null,
212
221
  _jsx(Row, { label: t('Open in a new window'), disabled: none, onSelect: () => popOut(tab) }, "out"),
213
- _jsx(Row, { label: t('Copy link'), disabled: none || !tab.url, onSelect: () => tab.url && void navigator.clipboard?.writeText(tab.url) }, "copy"),
222
+ _jsx(Row, { label: t('Copy link'), disabled: none || !tab.url, onSelect: () => tab.url && void copy(tab.url) }, "copy"),
214
223
  onPin ? _jsx(Row, { label: tab.pinned ? t('Unpin tab') : t('Pin tab'), onSelect: () => onPin(!tab.pinned) }, "pin") : null,
215
224
  ].filter(Boolean);
216
225
  const page = [
@@ -218,7 +227,7 @@ function Actions({ tab, here, frame, framed, same, level, onLevel, acts, browser
218
227
  print ? _jsx(Row, { label: t('Print'), disabled: none, onSelect: () => shown && print(shown) }, "print") : null,
219
228
  zoom ? _jsx(Zoom, { level: level, onLevel: onLevel, disabled: none }, "zoom") : null,
220
229
  browser?.devices ? _jsx(Row, { label: t('Show device toolbar'), disabled: none, onSelect: () => shown && browser.devices?.(shown) }, "devices") : null,
221
- browser?.capture && acts.onCapture ? _jsx(Row, { label: t('Take a screenshot'), disabled: none, onSelect: () => void capture() }, "capture") : null,
230
+ browser?.capture && acts.onCapture ? _jsx(Row, { label: t('Take a screenshot'), disabled: none, onSelect: () => void screenshot(browser, shown, acts.onCapture) }, "capture") : null,
222
231
  ].filter(Boolean);
223
232
  const own = [
224
233
  browser?.passwords ? _jsx(Row, { label: t('Passwords and autofill'), onSelect: browser.passwords, end: _jsx(ChevronRight, { size: 14, opacity: 0.6 }) }, "passwords") : null,
@@ -228,7 +237,7 @@ function Actions({ tab, here, frame, framed, same, level, onLevel, acts, browser
228
237
  ].filter(Boolean);
229
238
  const settings = browser?.settings ? [_jsx(Row, { label: t('Browser settings'), onSelect: browser.settings }, "settings")] : [];
230
239
  const groups = [ours, page, own, settings].filter((g) => g.length);
231
- return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(XStack, { render: "button", role: "button", "aria-label": t('Page actions'), width: PILL, height: PILL, ...quiet(), rounded: 999, bg: "$edge", children: _jsx(MoreHorizontal, { size: 16 }) }) }), _jsx(DropdownMenuContent, { align: "end", minW: 240, "data-slot": "page-menu", children: groups.flatMap((g, i) => (i ? [_jsx(DropdownMenuSeparator, {}, `line-${i}`), ...g] : g)) })] }));
240
+ return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(XStack, { render: "button", "aria-label": t('Page actions'), width: PILL, height: PILL, ...quiet(), children: _jsx(MoreHorizontal, { size: 16 }) }) }), _jsx(DropdownMenuContent, { align: "end", minW: 240, "data-slot": "page-menu", children: groups.flatMap((g, i) => (i ? [_jsx(DropdownMenuSeparator, {}, `line-${i}`), ...g] : g)) })] }));
232
241
  }
233
242
  /**
234
243
  * A page tab: its bar, then an address, bytes rendered as their type, or the
@@ -284,27 +293,21 @@ export function Page({ tab, onGo, onBack, onForward, onTitle, onPin, suggested =
284
293
  };
285
294
  // A frame scaled from its corner, its box grown to fill the panel at the scale.
286
295
  const scale = native || level === 100 ? null : { width: `${10000 / level}%`, height: `${10000 / level}%`, transform: `scale(${level / 100})`, transformOrigin: '0 0' };
287
- return (_jsxs(YStack, { flex: 1, minH: 0, "data-slot": "side-page", children: [_jsxs(XStack, { "data-slot": "side-bar", height: BAR, px: "$2", gap: "$2", items: "center", borderBottomWidth: 1, borderColor: "$borderColor", shrink: 0, children: [_jsxs(XStack, { items: "center", height: PILL, px: 4, gap: 2, rounded: 999, bg: "$edge", shrink: 0, children: [_jsx(XStack, { render: "button", role: "button", "aria-label": t('Back'), "aria-disabled": !back || undefined, onPress: back ? onBack : undefined, width: 28, height: 28, ...quiet(false, !back), rounded: 999, children: _jsx(ArrowLeft, { size: 15, ...MIRROR }) }), _jsx(XStack, { render: "button", role: "button", "aria-label": t('Forward'), "aria-disabled": !ahead || undefined, onPress: ahead ? onForward : undefined, width: 28, height: 28, ...quiet(false, !ahead), rounded: 999, children: _jsx(ArrowRight, { size: 15, ...MIRROR }) }), _jsx(XStack, { render: "button", role: "button", "aria-label": t('Reload this tab'), onPress: () => again((n) => n + 1), width: 28, height: 28, ...quiet(), rounded: 999, children: _jsx(RotateCw, { size: 14 }) })] }), _jsx(XStack, { flex: 1, minW: 0, items: "center", height: PILL, px: "$3.5", rounded: 999, bg: "$edge", borderWidth: 1,
288
- // Focused, the address is the bar's one ringed thing, as a browser's is.
289
- borderColor: typing ? '$outlineColor' : 'transparent', "data-slot": "side-address", children: _jsx("input", { value: own ? tab.title : typed, readOnly: own, placeholder: t('Search or enter a URL'), "aria-label": t('Address'), spellCheck: false, autoFocus: !own && !tab.url, onFocus: (e) => {
290
- setTyping(true);
291
- e.currentTarget.select();
292
- }, onBlur: () => setTyping(false), onChange: (e) => setTyped(e.target.value), onKeyDown: (e) => {
293
- if (e.key === 'Enter')
294
- go();
295
- if (e.key === 'Escape')
296
- setTyped(tab.url ?? '');
297
- }, style: {
298
- width: '100%',
299
- border: 0,
300
- outline: 'none',
301
- background: 'transparent',
302
- color: 'var(--foreground)',
303
- font: 'inherit',
304
- fontSize: 14,
305
- // The resting bar reads centred, as a browser's new tab does; typed in, it reads from the line's start.
306
- textAlign: typing || typed ? 'start' : 'center',
307
- } }, tab.id) }), _jsx(Actions, { tab: tab, here: here, frame: frame, framed: framed, same: same, level: level, onLevel: zoomTo, acts: acts, browser: browser, onPin: onPin })] }), !src ? (_jsx(Suggested, { suggested: suggested, onGo: onGo })) : native && Browse ? (_jsx(YStack, { flex: 1, minH: 0, children: _jsx(Browse, { url: src, title: tab.title, onGo: onGo, onTitle: onTitle }) }, round)) : elsewhere ? (_jsx(Elsewhere, { tab: tab })) : picture && !own ? (_jsx(YStack, { flex: 1, minH: 0, items: "center", justify: "center", p: "$3", overflowY: "auto", overflowX: "hidden", children: _jsx("img", { src: src, alt: tab.title, style: { maxWidth: '100%', maxHeight: '100%', objectFit: 'contain', ...(scale ? { transform: scale.transform } : null) } }, round) })) : shows ? (_jsx(YStack, { flex: 1, minH: 0, overflow: "hidden", position: "relative", children: _jsx("iframe", { ref: frame, src: src, title: tab.title, sandbox: local ? 'allow-scripts allow-popups allow-forms' : 'allow-same-origin allow-scripts allow-popups allow-forms allow-modals', style: { position: 'absolute', top: 0, left: 0, border: 0, width: '100%', height: '100%', display: 'block', background: 'var(--background)', ...scale } }, round) })) : (_jsxs(YStack, { flex: 1, items: "center", justify: "center", p: "$5", gap: "$2", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('{type} previews aren’t supported yet.', { type: (ext || type || 'This').toUpperCase() }) }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Open it in a new window to view it.') })] }))] }));
296
+ return (_jsxs(YStack, { flex: 1, minH: 0, "data-slot": "side-page", children: [_jsxs(XStack, { "data-slot": "side-bar", minH: BAR, px: "$2", py: "$1", gap: "$2", items: "center", borderBottomWidth: 1, borderColor: "$borderColor", shrink: 0, children: [_jsxs(XStack, { items: "center", minH: PILL, px: 4, gap: 2, rounded: 999, bg: "$edge", shrink: 0, children: [_jsx(XStack, { render: "button", "aria-label": t('Back'), "aria-disabled": !back || undefined, onPress: back ? onBack : undefined, width: 28, height: 28, ...quiet(false, !back), children: _jsx(ArrowLeft, { size: 15, ...MIRROR }) }), _jsx(XStack, { render: "button", "aria-label": t('Forward'), "aria-disabled": !ahead || undefined, onPress: ahead ? onForward : undefined, width: 28, height: 28, ...quiet(false, !ahead), children: _jsx(ArrowRight, { size: 15, ...MIRROR }) }), _jsx(XStack, { render: "button", "aria-label": t('Reload this tab'), onPress: () => again((n) => n + 1), width: 28, height: 28, ...quiet(), children: _jsx(RotateCw, { size: 14 }) })] }), _jsx(XStack, { flex: 1, minW: 0, items: "center", minH: PILL, px: "$3.5", rounded: 999, bg: "$edge", borderWidth: 1, "data-slot": "side-address", children: _jsx(SizableText, { render: _jsx("input", { value: own ? tab.title : typed, readOnly: own, placeholder: t('Search or enter a URL'), "aria-label": t('Address'), spellCheck: false, autoFocus: !own && !tab.url, onFocus: (e) => {
297
+ setTyping(true);
298
+ e.currentTarget.select();
299
+ }, onBlur: () => setTyping(false), onChange: (e) => setTyped(e.target.value), onKeyDown: (e) => {
300
+ if (e.key === 'Enter')
301
+ go();
302
+ if (e.key === 'Escape')
303
+ setTyped(tab.url ?? '');
304
+ } }), width: "100%", color: "$ink", fontFamily: "$body", size: "$2",
305
+ // The resting bar reads centred, as a browser's new tab does; typed in, it reads from the line's start.
306
+ text: typing || typed ? 'start' : 'center', "$platform-web": { outline: 'none' } }, tab.id) }), _jsx(Actions, { tab: tab, here: here, frame: frame, framed: framed, same: same, level: level, onLevel: zoomTo, acts: acts, browser: browser, onPin: onPin })] }), !src ? (_jsx(Suggested, { suggested: suggested, onGo: onGo })) : native && Browse ? (_jsx(YStack, { flex: 1, minH: 0, children: _jsx(Browse, { url: src, title: tab.title, onGo: onGo, onTitle: onTitle }) }, round)) : elsewhere ? (_jsx(Elsewhere, { tab: tab })) : picture && !own ? (_jsx(YStack, { flex: 1, minH: 0, items: "center", justify: "center", p: "$3", overflowY: "auto", overflowX: "hidden", children: _jsx(YStack, { render: _jsx("img", { src: src, alt: tab.title }), maxW: "100%", maxH: "100%", "$platform-web": { objectFit: 'contain', ...(scale ? { transform: scale.transform } : null) } }, round) })) : shows ? (_jsx(YStack, { flex: 1, minH: 0, overflow: "hidden", position: "relative", children: _jsx(YStack, { render: "iframe", ref: frame, ...{
307
+ src,
308
+ title: tab.title,
309
+ sandbox: local ? 'allow-scripts allow-popups allow-forms' : 'allow-same-origin allow-scripts allow-popups allow-forms allow-modals',
310
+ }, position: "absolute", t: 0, l: 0, width: scale ? scale.width : '100%', height: scale ? scale.height : '100%', display: "block", "$platform-web": scale ? { transform: scale.transform, transformOrigin: scale.transformOrigin } : undefined }, round) })) : (_jsxs(YStack, { flex: 1, items: "center", justify: "center", p: "$5", gap: "$2", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('{type} previews aren’t supported yet.', { type: (ext || type || 'This').toUpperCase() }) }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Open it in a new window to view it.') })] }))] }));
308
311
  }
309
312
  const DRAG = 'text/x-hanzo-tab';
310
313
  /**
@@ -319,7 +322,7 @@ function Leaf({ tab, on, side, index, label, icon }) {
319
322
  /** The tab itself, as the strip draws it. */
320
323
  function Strip({ tab, on, side, index, label, icon, ...rest }) {
321
324
  const { t } = useI18n();
322
- return (_jsxs(XStack, { ...rest, "data-slot": "side-tab", "data-tab": tab.id, items: "center", gap: "$1", pl: "$2.5", pr: "$1", height: 30,
325
+ return (_jsxs(XStack, { ...rest, "data-slot": "side-tab", "data-tab": tab.id, items: "center", gap: "$1", pl: "$2.5", pr: "$1", minH: 30,
323
326
  // As wide as a title wants up to a browser tab's width, sharing the strip
324
327
  // as a browser's tabs do when there are many.
325
328
  flexBasis: 236, shrink: 1, minW: 56, maxW: 236, rounded: 8, borderWidth: 1, borderColor: on ? '$borderColor' : 'transparent', bg: on ? '$edge' : 'transparent', hoverStyle: { bg: on ? '$edge' : '$hover' }, ...{
@@ -367,7 +370,7 @@ function Strip({ tab, on, side, index, label, icon, ...rest }) {
367
370
  e.preventDefault?.();
368
371
  side.shut(tab.id);
369
372
  }
370
- }, flex: 1, minW: 0, items: "center", gap: "$2", cursor: "pointer", children: [icon ? (_jsx(XStack, { "aria-hidden": true, shrink: 0, opacity: on ? 1 : 0.7, children: icon })) : null, _jsx(SizableText, { fontSize: 13, color: on ? '$ink' : '$soft', numberOfLines: 1, children: label })] }), tab.pinned ? (_jsx(XStack, { render: "button", role: "button", "aria-label": t('Unpin {tab}', { tab: label }), tabIndex: -1, onPress: () => side.unpin(tab.id), width: 22, height: 22, items: "center", justify: "center", rounded: 6, cursor: "pointer", opacity: on ? 0.8 : 0.55, hoverStyle: { bg: '$hover', opacity: 1 }, children: _jsx(Pin, { size: 12 }) })) : (_jsx(XStack, { render: "button", role: "button", "aria-label": t('Close {tab}', { tab: label }), tabIndex: -1, onPress: () => side.shut(tab.id), width: 22, height: 22, items: "center", justify: "center", rounded: 6, cursor: "pointer", opacity: on ? 0.8 : 0.45, hoverStyle: { bg: '$hover', opacity: 1 },
373
+ }, flex: 1, minW: 0, minH: 28, items: "center", gap: "$2", cursor: "pointer", focusVisibleStyle: RING_INSET, children: [icon ? (_jsx(XStack, { "aria-hidden": true, shrink: 0, opacity: on ? 1 : 0.7, children: icon })) : null, _jsx(SizableText, { fontSize: 13, color: on ? '$ink' : '$soft', numberOfLines: 1, children: label })] }), tab.pinned ? (_jsx(XStack, { render: "button", "aria-label": t('Unpin {tab}', { tab: label }), tabIndex: -1, onPress: () => side.unpin(tab.id), minW: 22, minH: 22, items: "center", justify: "center", rounded: 6, cursor: "pointer", opacity: on ? 0.8 : 0.55, hoverStyle: { bg: '$hover', opacity: 1 }, focusVisibleStyle: RING, children: _jsx(Pin, { size: 12 }) })) : (_jsx(XStack, { render: "button", "aria-label": t('Close {tab}', { tab: label }), tabIndex: -1, onPress: () => side.shut(tab.id), minW: 22, minH: 22, items: "center", justify: "center", rounded: 6, cursor: "pointer", opacity: on ? 0.8 : 0.45, hoverStyle: { bg: '$hover', opacity: 1 }, focusVisibleStyle: RING,
371
374
  // The chosen tab's cross: the others keep their room for their titles when the strip is shared.
372
375
  display: on ? 'flex' : 'none', children: _jsx(X, { size: 12 }) }))] }));
373
376
  }
@@ -391,16 +394,16 @@ export function Panel({ side, kinds, onHide, sheet = false, bar, menu, label, su
391
394
  const mark = (t) => (t.kind === PAGE ? _jsx(Globe, { size: 14 }) : (kinds.find((k) => k.id === t.kind)?.icon ?? null));
392
395
  const blank = () => side.open({ kind: PAGE, title: BLANK, url: '' });
393
396
  const poppable = tab?.kind === PAGE && (tab.body !== undefined || Boolean(tab.url));
394
- const plus = (_jsx(XStack, { render: "button", role: "button", "aria-label": say('Open a tab'), width: 28, height: 28, ...quiet(), onPress: closed.length ? undefined : blank, children: _jsx(Plus, { size: 16 }) }));
395
- const body = (_jsxs(YStack, { role: "complementary", "aria-label": label ?? say('Side panel'), "data-slot": "side", flex: 1, minW: 0, minH: 0, overflow: "hidden", rounded: "inherit", children: [_jsxs(XStack, { "data-slot": "side-strip", height: STRIP, px: "$2", gap: "$1.5", items: "center", borderBottomWidth: 1, borderColor: "$borderColor", shrink: 0, children: [column?.hidden && !column.full ? (_jsxs(XStack, { render: "button", role: "button", "data-slot": "side-show", onPress: column.show, height: 32, px: "$2", gap: "$1.5", ...quiet(), children: [_jsx(PanelLeftOpen, { size: 16 }), _jsx(SizableText, { fontSize: 13, color: "$ink", children: column.main === 'run' ? say('Show run') : column.main === 'chat' ? say('Show chat') : say('Show {main}', { main: column.main }) })] })) : null, _jsx(XStack, { role: "tablist", "aria-label": say('Tabs'), shrink: 1, minW: 0, gap: "$1", items: "center", overflowX: "auto", overflowY: "hidden", "$platform-web": { scrollbarWidth: 'none' }, children: side.tabs.map((t, i) => (_jsx(Leaf, { tab: t, on: t.id === side.at, side: side, index: i, label: title(t), icon: mark(t) }, t.id))) }), closed.length ? (_jsx(DropdownMenu, { trigger: plus, items: [
397
+ const plus = (_jsx(XStack, { render: "button", "aria-label": say('Open a tab'), width: 28, height: 28, ...quiet(), onPress: closed.length ? undefined : blank, children: _jsx(Plus, { size: 16 }) }));
398
+ const body = (_jsxs(YStack, { role: "complementary", "aria-label": label ?? say('Side panel'), "data-slot": "side", flex: 1, minW: 0, minH: 0, overflow: "hidden", rounded: "inherit", children: [_jsxs(XStack, { "data-slot": "side-strip", height: STRIP, px: "$2", gap: "$1.5", items: "center", borderBottomWidth: 1, borderColor: "$borderColor", shrink: 0, children: [column?.hidden && !column.full ? (_jsxs(XStack, { render: "button", "data-slot": "side-show", onPress: column.show, minH: 32, px: "$2", gap: "$1.5", ...quiet(), children: [_jsx(PanelLeftOpen, { size: 16 }), _jsx(SizableText, { fontSize: 13, color: "$ink", children: column.main === 'run' ? say('Show run') : column.main === 'chat' ? say('Show chat') : say('Show {main}', { main: column.main }) })] })) : null, _jsx(XStack, { role: "tablist", "aria-label": say('Tabs'), shrink: 1, minW: 0, gap: "$1", items: "center", overflowX: "auto", overflowY: "hidden", "$platform-web": { scrollbarWidth: 'none' }, children: side.tabs.map((t, i) => (_jsx(Leaf, { tab: t, on: t.id === side.at, side: side, index: i, label: title(t), icon: mark(t) }, t.id))) }), closed.length ? (_jsx(DropdownMenu, { trigger: plus, items: [
396
399
  ...closed.map((k) => ({ key: k.id, label: k.label, onSelect: () => side.open({ kind: k.id, title: k.label }) })),
397
400
  { key: PAGE, label: say('Page'), description: say('An address, framed here'), onSelect: blank },
398
- ] })) : (plus), _jsx(XStack, { flex: 1 }), menu, _jsx(XStack, { render: "button", role: "button", "aria-label": say('Open this tab in a new window'), "aria-disabled": !poppable || undefined, onPress: poppable ? () => popOut(tab) : undefined, width: 28, height: 28, ...quiet(false, !poppable), children: _jsx(ExternalLink, { size: 14 }) }), column ? (_jsx(XStack, { render: "button", role: "button", "data-slot": "side-full", "aria-label": column.full ? say('Exit full screen') : say('Full screen'), "aria-pressed": column.full, "aria-keyshortcuts": column.full ? 'Escape' : undefined, ...{ title: column.full ? say('Exit full screen ({key})', { key: 'Esc' }) : say('Full screen') }, onPress: () => column.fill(!column.full), width: 28, height: 28, ...quiet(column.full), children: column.full ? _jsx(Minimize2, { size: 14 }) : _jsx(Maximize2, { size: 14 }) })) : null, _jsx(XStack, { render: "button", role: "button", "data-slot": "side-toggle", "aria-label": say('Hide tabs'), "aria-expanded": true, "aria-keyshortcuts": SHORTCUTS, ...{ title: say('Hide tabs ({keys})', { keys: KEYS }) }, onPress: onHide, width: 32, height: 32, ...quiet(true), children: _jsx(Columns2, { size: 16 }) })] }), bar, _jsx(YStack, { id: "side-body", role: "tabpanel", "aria-labelledby": tab ? `side-tab-${tab.id}` : undefined,
401
+ ] })) : (plus), _jsx(XStack, { flex: 1 }), menu, _jsx(XStack, { render: "button", "aria-label": say('Open this tab in a new window'), "aria-disabled": !poppable || undefined, onPress: poppable ? () => popOut(tab) : undefined, width: 28, height: 28, ...quiet(false, !poppable), children: _jsx(ExternalLink, { size: 14 }) }), column ? (_jsx(XStack, { render: "button", "data-slot": "side-full", "aria-label": column.full ? say('Exit full screen') : say('Full screen'), "aria-pressed": column.full, "aria-keyshortcuts": column.full ? 'Escape' : undefined, ...{ title: column.full ? say('Exit full screen ({key})', { key: 'Esc' }) : say('Full screen') }, onPress: () => column.fill(!column.full), width: 28, height: 28, ...quiet(column.full), children: column.full ? _jsx(Minimize2, { size: 14 }) : _jsx(Maximize2, { size: 14 }) })) : null, _jsx(XStack, { render: "button", "data-slot": "side-toggle", "aria-label": say('Hide tabs'), "aria-expanded": true, "aria-keyshortcuts": SHORTCUTS, ...{ title: say('Hide tabs ({keys})', { keys: KEYS }) }, onPress: onHide, width: 32, height: 32, ...quiet(true), children: _jsx(Columns2, { size: 16 }) })] }), bar, _jsx(YStack, { id: "side-body", role: "tabpanel", "aria-labelledby": tab ? `side-tab-${tab.id}` : undefined,
399
402
  // What a tab lays over itself (a door's "Connecting…") stays inside it, under the strip.
400
- position: "relative", flex: 1, minH: 0, overflowY: bleed ? 'hidden' : 'auto', overflowX: "hidden", px: bleed ? 0 : '$3', py: bleed ? 0 : '$3', children: !tab ? (_jsx(YStack, { flex: 1, items: "center", justify: "center", p: "$5", children: _jsx(SizableText, { fontSize: 13, color: "$soft", children: say('No tabs open.') }) })) : tab.kind === PAGE ? (_jsx(Page, { tab: tab, onGo: (url) => side.go(tab.id, url), onBack: () => side.back(tab.id), onForward: () => side.forward(tab.id), onTitle: (t) => side.rename(tab.id, t), onPin: (on) => (on ? side.pin(tab.id) : side.unpin(tab.id)), suggested: suggested, ...acts }, tab.id)) : kind ? (kind.render()) : (_jsx(SizableText, { size: "$2", color: "$soft", children: say('This tab is not offered here.') })) })] }));
403
+ position: "relative", flex: 1, minH: 0, overflowY: bleed ? 'hidden' : 'auto', overflowX: "hidden", px: bleed ? 0 : '$3', py: bleed ? 0 : '$3', children: !tab ? (_jsx(YStack, { flex: 1, items: "center", justify: "center", p: "$5", children: _jsx(SizableText, { fontSize: 13, color: "$soft", children: say('No tabs open.') }) })) : tab.kind === PAGE ? (_jsx(Page, { tab: tab, onGo: (url) => side.go(tab.id, url), onBack: () => side.back(tab.id), onForward: () => side.forward(tab.id), onTitle: (t) => side.rename(tab.id, t), onPin: (on) => (on ? side.pin(tab.id) : side.unpin(tab.id)), suggested: suggested, ...acts }, tab.id)) : kind ? (_jsx(Fragment, { children: kind.render() }, tab.id)) : (_jsx(SizableText, { size: "$2", color: "$soft", children: say('This tab is not offered here.') })) })] }));
401
404
  if (!sheet || typeof document === 'undefined')
402
405
  return body;
403
406
  // A phone: the panel over the whole window, clear of the notch and the home
404
407
  // indicator. The strip's toggle puts it away.
405
- return createPortal(_jsx(YStack, { "data-slot": "side-sheet", position: "fixed", t: 0, r: 0, b: 0, l: 0, z: 60, bg: "$background", style: { paddingTop: 'env(safe-area-inset-top)', paddingBottom: 'env(safe-area-inset-bottom)' }, children: body }), document.body);
408
+ return createPortal(_jsx(YStack, { "data-slot": "side-sheet", position: "fixed", t: 0, r: 0, b: 0, l: 0, z: 60, bg: "$background", pt: 'env(safe-area-inset-top)', pb: 'env(safe-area-inset-bottom)', children: body }), document.body);
406
409
  }
package/lib/plans.js CHANGED
@@ -14,14 +14,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { SizableText, XStack, YStack } from '@hanzo/gui';
15
15
  import { useI18n } from '@hanzo/i18n/react';
16
16
  import { Check, ChevronLeft } from '@hanzogui/lucide-icons-2';
17
- import { Button, Dialog, DialogContent, DialogTitle } from '@hanzo/ui';
18
- import { useState } from 'react';
17
+ import { Button, Dialog, DialogContent, DialogTitle, Skeleton } from '@hanzo/ui';
18
+ import { useId, useState } from 'react';
19
+ import { RING } from './pane.js';
19
20
  import { cancel, chosen, current, label, methods, money, plans, subscribe, subscriptions } from './api/billing.js';
20
21
  import { useRead } from './data.js';
21
22
  import { useHost, useTarget } from './host.js';
22
23
  import { path } from './route.js';
23
24
  import { AddCard } from './settings/card.js';
24
25
  import { day } from './settings/ui.js';
26
+ /** Maximum feature bullets shown per plan card at rest before a "+N more" disclosure. */
27
+ const FEATURE_CAP = 6;
25
28
  /** What a plan costs a month on a term, and what the term charges at once. */
26
29
  function price(p, term) {
27
30
  const month = term === 'year' && p.yearly ? p.yearly : p.monthly;
@@ -31,6 +34,7 @@ export function Plans() {
31
34
  const host = useHost();
32
35
  const target = useTarget();
33
36
  const { t } = useI18n();
37
+ const termGroupId = useId();
34
38
  const signed = Boolean(host.person);
35
39
  const list = useRead(() => plans(target), [], [target]);
36
40
  const subs = useRead(signed ? () => subscriptions(target) : null, [], [target, signed]);
@@ -41,6 +45,7 @@ export function Plans() {
41
45
  const [adding, setAdding] = useState(false);
42
46
  const [working, setWorking] = useState(false);
43
47
  const [note, setNote] = useState('');
48
+ const [expanded, setExpanded] = useState({});
44
49
  const on = current(subs.value);
45
50
  const org = host.org;
46
51
  const card = chosen(cards.value);
@@ -68,7 +73,7 @@ export function Plans() {
68
73
  /** The one thing a card can do, or a line saying why it does nothing. */
69
74
  const move = (p) => {
70
75
  if (mine(p)) {
71
- return (_jsx(Button, { size: "sm", variant: "outline", disabled: true, children: t('Current plan') }));
76
+ return (_jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", fullWidth: true, disabled: true, children: t('Current plan') }));
72
77
  }
73
78
  if (p.sales)
74
79
  return _jsx(Line, { children: t('Priced with our team for your organization.') });
@@ -83,16 +88,16 @@ export function Plans() {
83
88
  const paid = on;
84
89
  if (paid.ending)
85
90
  return _jsx(Line, { children: t('You move to {plan} when {current} ends on {date}.', { plan: p.name, current: paid.name, date: day(paid.ends) }) });
86
- return (_jsx(Button, { size: "sm", variant: "outline", onPress: () => setLeaving(true), children: t('Switch to {plan}', { plan: p.name }) }));
91
+ return (_jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", fullWidth: true, onPress: () => setLeaving(true), children: t('Switch to {plan}', { plan: p.name }) }));
87
92
  }
88
93
  if (on && on.price > 0)
89
94
  return _jsx(Line, { children: t('One paid plan at a time: {current} ends before {plan} begins.', { current: on.name, plan: p.name }) });
90
95
  if (!card) {
91
- return (_jsx(Button, { size: "sm", variant: "outline", onPress: () => setAdding(true), children: t('Add a card to upgrade') }));
96
+ return (_jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", fullWidth: true, onPress: () => setAdding(true), children: t('Add a card to upgrade') }));
92
97
  }
93
- return (_jsx(Button, { size: "sm", variant: p.popular ? 'primary' : 'outline', onPress: () => setBuying(p), children: t('Upgrade to {plan}', { plan: p.name }) }));
98
+ return (_jsx(Button, { size: "sm", variant: p.popular ? 'primary' : 'outline', borderColor: p.popular ? undefined : 'var(--border-strong)', fullWidth: true, onPress: () => setBuying(p), children: t('Upgrade to {plan}', { plan: p.name }) }));
94
99
  };
95
- return (_jsxs(YStack, { flex: 1, minH: 0, overflow: "scroll", children: [_jsxs(YStack, { width: "100%", maxW: 1100, mx: "auto", px: "$5", py: "$5", gap: "$5", children: [_jsxs(XStack, { render: "button", "aria-label": t('Back to billing'), items: "center", gap: "$1", self: "flex-start", onPress: () => host.go(path({ kind: 'settings', section: 'billing' })), children: [_jsx(ChevronLeft, { size: 16, 'data-i18n-mirror': '' }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Billing') })] }), _jsxs(XStack, { items: "flex-end", gap: "$4", flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 240, gap: "$1", children: [_jsx(SizableText, { render: "h1", size: "$7", color: "$ink", children: t('Plans that grow with you') }), _jsx(SizableText, { size: "$2", color: "$soft", children: !signed
100
+ return (_jsxs(YStack, { flex: 1, minH: 0, overflow: "scroll", children: [_jsxs(YStack, { width: "100%", maxW: 1100, mx: "auto", px: "$5", py: "$5", gap: "$5", children: [_jsxs(XStack, { render: "button", "aria-label": t('Back to billing'), items: "center", gap: "$1.5", self: "flex-start", onPress: () => host.go(path({ kind: 'settings', section: 'billing' })), children: [_jsx(ChevronLeft, { size: 16, 'data-i18n-mirror': '' }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Billing') })] }), _jsxs(XStack, { items: "flex-end", gap: "$4", flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 240, gap: "$1", children: [_jsx(SizableText, { render: "h1", size: "$7", color: "$ink", children: t('Plans that grow with you') }), _jsx(SizableText, { size: "$2", color: "$soft", children: !signed
96
101
  ? t('Sign in to see the plan you are on.')
97
102
  : on
98
103
  ? org
@@ -100,9 +105,25 @@ export function Plans() {
100
105
  : t('This organization is on {plan}.', { plan: on.name })
101
106
  : org
102
107
  ? t('{org} is on the free plan.', { org })
103
- : t('This organization is on the free plan.') })] }), yearly ? (_jsx(XStack, { role: "radiogroup", "aria-label": t('Billing period'), p: "$1", gap: "$1", rounded: "$10", borderWidth: 1, borderColor: "$borderColor", children: ['month', 'year'].map((k) => (_jsx(XStack, { render: "button", role: "radio", "aria-checked": term === k, "aria-label": k === 'month' ? t('Monthly') : t('Yearly'), onPress: () => setTerm(k), px: "$3", py: "$1.5", rounded: "$10", bg: term === k ? '$hover' : 'transparent', children: _jsx(SizableText, { size: "$2", color: term === k ? '$ink' : '$soft', children: k === 'month' ? t('Monthly') : t('Yearly') }) }, k))) })) : null] }), list.error ? (_jsx(Line, { children: list.error.message })) : list.loading && !list.value.length ? (_jsx(Line, { children: t('Reading plans…') })) : list.value.length === 0 ? (_jsx(Line, { children: t('This brand sells no plans.') })) : (_jsx(XStack, { flexWrap: "wrap", gap: "$4", children: list.value.map((p) => {
108
+ : t('This organization is on the free plan.') })] }), yearly ? (_jsx(XStack, { role: "radiogroup", "aria-label": t('Billing period'), p: 2, gap: 2, rounded: "$10", borderWidth: 1, borderColor: "var(--border-strong)", bg: "$panel", shrink: 0, children: ['month', 'year'].map((k, idx, arr) => {
109
+ const active = term === k;
110
+ return (_jsx(XStack, { id: `${termGroupId}-${k}`, render: "button", role: "radio", "aria-checked": active, "aria-label": k === 'month' ? t('Monthly') : t('Yearly'), onPress: () => setTerm(k), onKeyDown: ((e) => {
111
+ const step = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;
112
+ if (!step)
113
+ return;
114
+ e.preventDefault?.();
115
+ const next = arr[(idx + step + arr.length) % arr.length];
116
+ setTerm(next);
117
+ queueMicrotask(() => document.getElementById(`${termGroupId}-${next}`)?.focus());
118
+ }), items: "center", px: "$3", py: "$1.5", minH: 32, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$2", fontWeight: active ? '500' : '400', color: active ? '$ink' : '$soft', children: k === 'month' ? t('Monthly') : t('Yearly') }) }, k));
119
+ }) })) : null] }), list.error ? (_jsxs(YStack, { borderWidth: 1, borderColor: "var(--border-strong)", rounded: "$4", bg: "$panel", px: "$5", py: "$8", gap: "$3", items: "center", children: [_jsx(SizableText, { size: "$2", color: "var(--state-error)", text: "center", children: list.error.message }), _jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: list.reload, children: t('Try again') })] })) : list.loading && !list.value.length ? (_jsxs(YStack, { gap: "$3", "aria-busy": true, children: [_jsx(Line, { children: t('Reading plans…') }), _jsx(YStack, { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 260px), 1fr))", gap: "$4", width: "100%", children: [0, 1, 2].map((i) => (_jsxs(YStack, { gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", children: [_jsx(Skeleton, { layout: "block", width: "45%", height: 20, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "80%", height: 14, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "40%", height: 28, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "100%", height: 34, rounded: "$3" }), _jsxs(YStack, { gap: "$2", pt: "$2", borderTopWidth: 1, borderColor: "$borderColor", children: [_jsx(Skeleton, { layout: "block", width: "76%", height: 14, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "64%", height: 14, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "70%", height: 14, rounded: "$2" })] })] }, i))) })] })) : list.value.length === 0 ? (_jsx(YStack, { borderWidth: 1, borderColor: "var(--border-strong)", rounded: "$4", bg: "$panel", px: "$5", py: "$8", items: "center", children: _jsx(Line, { children: t('This brand sells no plans.') }) })) : (_jsx(YStack, { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 260px), 1fr))", gap: "$4", width: "100%", children: list.value.map((p) => {
104
120
  const cost = price(p, term);
105
- return (_jsxs(YStack, { "aria-label": t('{plan} plan', { plan: p.name }), flex: 1, minW: 240, maxW: 360, "$max-sm": { maxW: '100%' }, gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, borderColor: mine(p) || p.popular ? '$ink' : '$borderColor', bg: "$panel", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(SizableText, { flex: 1, size: "$5", color: "$ink", children: p.name }), mine(p) ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Current') })) : p.popular ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Popular') })) : null] }), p.description ? (_jsx(SizableText, { size: "$2", color: "$soft", children: p.description })) : null, _jsxs(YStack, { gap: "$0.5", children: [_jsx(SizableText, { size: "$7", color: "$ink", children: p.sales ? t('Custom') : cost.month === 0 ? t('Free') : money(cost.month, p.currency) }), _jsx(SizableText, { size: "$1", color: "$soft", children: p.sales
121
+ const isMine = mine(p);
122
+ const isExpanded = Boolean(expanded[p.id]);
123
+ const hasMoreFeatures = p.features.length > FEATURE_CAP;
124
+ const visibleFeatures = hasMoreFeatures && !isExpanded ? p.features.slice(0, FEATURE_CAP) : p.features;
125
+ const extraCount = p.features.length - FEATURE_CAP;
126
+ return (_jsxs(YStack, { "aria-label": t('{plan} plan', { plan: p.name }), minW: 0, gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, bg: "$panel", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(SizableText, { flex: 1, size: "$5", color: "$ink", children: p.name }), isMine ? (_jsx(XStack, { px: "$2", py: "$0.5", rounded: 999, bg: "$ink", shrink: 0, children: _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$background", children: t('Current') }) })) : p.popular ? (_jsx(XStack, { px: "$2", py: "$0.5", rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", bg: "$raised", shrink: 0, children: _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: t('Popular') }) })) : null] }), p.description ? (_jsx(SizableText, { size: "$2", color: "$soft", children: p.description })) : null, _jsxs(YStack, { gap: "$0.5", children: [_jsx(SizableText, { size: "$7", fontWeight: "600", color: "$ink", fontVariant: ['tabular-nums'], children: p.sales ? t('Custom') : cost.month === 0 ? t('Free') : money(cost.month, p.currency) }), _jsx(SizableText, { size: "$1", color: "$soft", children: p.sales
106
127
  ? t('Talk to us')
107
128
  : cost.month === 0
108
129
  ? t('Forever')
@@ -112,18 +133,18 @@ export function Plans() {
112
133
  : t('a month, {price} billed yearly', { price: money(cost.now, p.currency) })
113
134
  : p.perSeat
114
135
  ? t('per seat, a month')
115
- : t('a month') })] }), _jsx(XStack, { children: move(p) }), p.features.length ? (_jsx(YStack, { gap: "$2", borderTopWidth: 1, borderColor: "$borderColor", pt: "$3", children: p.features.map((f) => (_jsxs(XStack, { gap: "$2", items: "flex-start", children: [_jsx(YStack, { pt: 2, children: _jsx(Check, { size: 14 }) }), _jsx(SizableText, { flex: 1, size: "$2", color: "$soft", children: f })] }, f))) })) : null] }, p.id));
116
- }) })), note ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", children: note })) : null] }), _jsx(Dialog, { open: Boolean(buying), onOpenChange: (o) => !o && setBuying(null), children: _jsxs(DialogContent, { maxW: 420, showCloseButton: false, children: [_jsx(DialogTitle, { children: buying ? t('Upgrade to {plan}', { plan: buying.name }) : t('Upgrade') }), buying && card ? (_jsxs(YStack, { gap: "$3", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: term === 'year'
136
+ : t('a month') })] }), _jsx(XStack, { children: move(p) }), p.features.length ? (_jsxs(YStack, { gap: "$2", borderTopWidth: 1, borderColor: "$borderColor", pt: "$3", children: [visibleFeatures.map((f) => (_jsxs(XStack, { gap: "$2", items: "flex-start", children: [_jsx(YStack, { pt: 2, children: _jsx(Check, { size: 14 }) }), _jsx(SizableText, { flex: 1, size: "$2", color: "$soft", children: f })] }, f))), hasMoreFeatures ? (_jsx(XStack, { render: "button", "aria-expanded": isExpanded, onPress: () => setExpanded((prev) => ({ ...prev, [p.id]: !prev[p.id] })), self: "flex-start", px: "$2", ml: "$-2", minH: 28, items: "center", focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: isExpanded ? t('Show less') : t('+{n} more features', { n: extraCount }) }) })) : null] })) : null] }, p.id));
137
+ }) })), note ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", children: note })) : null] }), _jsx(Dialog, { open: Boolean(buying), onOpenChange: (o) => !o && !working && setBuying(null), children: _jsxs(DialogContent, { maxW: 420, showCloseButton: false, gap: "$3", children: [_jsx(DialogTitle, { children: buying ? t('Upgrade to {plan}', { plan: buying.name }) : t('Upgrade') }), buying && card ? (_jsxs(YStack, { gap: "$3", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: term === 'year'
117
138
  ? t('{card} is charged {amount} now, and again every year until you cancel.', { card: label(card), amount: money(price(buying, term).now, buying.currency) })
118
- : t('{card} is charged {amount} now, and again every month until you cancel.', { card: label(card), amount: money(price(buying, term).now, buying.currency) }) }), _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", onPress: () => setBuying(null), children: t('Not now') }), _jsx(Button, { size: "sm", disabled: working, onPress: () => void act(async () => {
139
+ : t('{card} is charged {amount} now, and again every month until you cancel.', { card: label(card), amount: money(price(buying, term).now, buying.currency) }) }), _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", disabled: working, onPress: () => setBuying(null), children: t('Not now') }), _jsx(Button, { size: "sm", variant: "primary", disabled: working, onPress: () => void act(async () => {
119
140
  await subscribe(target, { plan: buying.id, interval: yearly && buying.yearly ? term : 'month', method: card.id });
120
141
  return org ? t('{org} is on {plan}', { org, plan: buying.name }) : t('This organization is on {plan}', { plan: buying.name });
121
- }), children: t('Upgrade') })] })] })) : null] }) }), _jsx(Dialog, { open: leaving, onOpenChange: setLeaving, children: _jsxs(DialogContent, { maxW: 420, showCloseButton: false, children: [_jsx(DialogTitle, { children: t('Switch to the free plan?') }), on ? (_jsxs(YStack, { gap: "$3", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: day(on.ends)
142
+ }), children: working ? t('Upgrading…') : t('Upgrade') })] })] })) : null] }) }), _jsx(Dialog, { open: leaving, onOpenChange: (o) => !working && setLeaving(o), children: _jsxs(DialogContent, { maxW: 420, showCloseButton: false, gap: "$3", children: [_jsx(DialogTitle, { children: t('Switch to the free plan?') }), on ? (_jsxs(YStack, { gap: "$3", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: day(on.ends)
122
143
  ? t('{plan} stays on until {date}, and nothing is charged after that.', { plan: on.name, date: day(on.ends) })
123
- : t('{plan} stays on until the end of this period, and nothing is charged after that.', { plan: on.name }) }), _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", onPress: () => setLeaving(false), children: t('Keep {plan}', { plan: on.name }) }), _jsx(Button, { size: "sm", variant: "destructive", disabled: working, onPress: () => void act(async () => {
144
+ : t('{plan} stays on until the end of this period, and nothing is charged after that.', { plan: on.name }) }), _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", disabled: working, onPress: () => setLeaving(false), children: t('Keep {plan}', { plan: on.name }) }), _jsx(Button, { size: "sm", variant: "destructive", disabled: working, onPress: () => void act(async () => {
124
145
  await cancel(target, on.id);
125
146
  return t('{plan} ends on {date}', { plan: on.name, date: day(on.ends) });
126
- }), children: t('Switch') })] })] })) : null] }) }), _jsx(AddCard, { open: adding, onOpenChange: setAdding, onSaved: (m) => {
147
+ }), children: working ? t('Switching…') : t('Switch') })] })] })) : null] }) }), _jsx(AddCard, { open: adding, onOpenChange: setAdding, onSaved: (m) => {
127
148
  cards.reload();
128
149
  setNote(t('{card} is saved', { card: label(m) }));
129
150
  } })] }));